Skip to content

Commit

Permalink
chore: changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Jul 16, 2024
1 parent 72187d8 commit 7a75441
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-maps-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wagmi/vue": patch
---

Added `useBytecode` composable.
3 changes: 2 additions & 1 deletion packages/vue/src/composables/useBytecode.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { expectTypeOf, test } from 'vitest'

import type { Hex } from 'viem'

import { useBytecode } from './useBytecode.js'

test('select data', () => {
const result = useBytecode({
query: {
select(data) {
expectTypeOf(data).toEqualTypeOf<Hex | undefined>()
return data
},
},
Expand Down
46 changes: 23 additions & 23 deletions site/vue/api/composables/useBytecode.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: useBytecode
description: Hook for retrieving the bytecode at an address.
description: Composable for retrieving the bytecode at an address.
---

<script setup>
const packageName = 'wagmi'
const packageName = '@wagmi/vue'
const actionName = 'getBytecode'
const typeName = 'GetBytecode'
const TData = 'GetBytecodeData'
Expand All @@ -13,7 +13,7 @@ const TError = 'GetBytecodeErrorType'

# useBytecode

Hook for retrieving the bytecode at an address.
Composable for retrieving the bytecode at an address.

## Import

Expand All @@ -29,12 +29,12 @@ import { useBytecode } from '@wagmi/vue'
import { useBytecode } from '@wagmi/vue'
const { data: byteCode } = useBytecode({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2'
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -58,12 +58,12 @@ The contract address.
import { useBytecode } from '@wagmi/vue'
const { data: byteCode } = useBytecode({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2' // [!code focus]
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', // [!code focus]
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -81,13 +81,13 @@ The block number to check the bytecode at.
import { useBytecode } from '@wagmi/vue'
const { data: byteCode } = useBytecode({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
blockNumber: 16280770n // [!code focus]
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
blockNumber: 16280770n, // [!code focus]
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -105,13 +105,13 @@ The block tag to check the bytecode at.
import { useBytecode } from '@wagmi/vue'
const { data: byteCode } = useBytecode({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
blockTag: 'safe', // [!code focus]
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
blockTag: 'safe', // [!code focus]
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -130,13 +130,13 @@ import { useBytecode } from '@wagmi/vue'
import { mainnet } from '@wagmi/vue/chains'
const { data: byteCode } = useBytecode({
chainId: mainnet.id, // [!code focus]
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
chainId: mainnet.id, // [!code focus]
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -155,13 +155,13 @@ import { useBytecode } from '@wagmi/vue'
import { config } from './config' // [!code focus]
const { data: byteCode } = useBytecode({
config, // [!code focus]
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
config, // [!code focus]
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -180,13 +180,13 @@ import { useBytecode } from '@wagmi/vue'
import { config } from './config' // [!code focus]
const { data: byteCode } = useBytecode({
scopeKey: 'foo', // [!code focus]
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
scopeKey: 'foo', // [!code focus]
})
</script>
<template>
Byte code: {{ byteCode }}
Byte Code: {{ byteCode }}
</template>
```
<<< @/snippets/react/config.ts[config.ts]
Expand All @@ -197,7 +197,7 @@ const { data: byteCode } = useBytecode({
## Return Type

```ts
import { type UseBytecodeReturnType } from 'wagmi'
import { type UseBytecodeReturnType } from '@wagmi/vue'
```

<!--@include: @shared/query-result.md-->
Expand Down

0 comments on commit 7a75441

Please sign in to comment.