Skip to content

Commit

Permalink
docs: update example data in decodeFunctionData and tab in decodeFunc…
Browse files Browse the repository at this point in the history
…tionResult (#2588)

docs: Update example data in decodeFunctionData and example tab in decodeFunctionResult
  • Loading branch information
iosh authored Aug 6, 2024
1 parent 1c5d64a commit 3e27073
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
10 changes: 5 additions & 5 deletions site/pages/docs/contract/decodeFunctionData.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { wagmiAbi } from './abi.ts'

const { functionName } = decodeFunctionData({
abi: wagmiAbi,
data: '0xc2985578'
data: '0x18160ddd'
})
// { functionName: 'totalSupply' }
```
Expand Down Expand Up @@ -60,9 +60,9 @@ import { wagmiAbi } from './abi'
// [!code word:args:1]
const { functionName, args } = decodeFunctionData({
abi: wagmiAbi,
data: '0x0423a1320000000000000000000000000000000000000000000000000000000000000001'
data: '0x70a08231000000000000000000000000fba3912ca04dd458c843e2ee08967fc04f3579c2'
})
// { functionName: 'balanceOf', args: [1n] }
// { functionName: 'balanceOf', args: ["0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2"] }
```

```ts [abi.ts]
Expand Down Expand Up @@ -115,7 +115,7 @@ The contract's ABI.
```ts
const { functionName } = decodeFunctionData({
abi: wagmiAbi, // [!code focus]
data: '0xc2985578'
data: '0x18160ddd'
})
```

Expand All @@ -128,6 +128,6 @@ The encoded calldata.
```ts
const { functionName } = decodeFunctionData({
abi: wagmiAbi,
data: '0xc2985578' // [!code focus]
data: '0x18160ddd' // [!code focus]
})
```
17 changes: 10 additions & 7 deletions site/pages/docs/contract/decodeFunctionResult.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ If your `abi` contains only one ABI item, you can omit the `functionName` (it be

```ts [example.ts]
import { decodeFunctionResult } from 'viem'
import { abiItem } from './abi.ts'

const value = decodeFunctionResult({
abi: [abiItem],
functionName: 'ownerOf', // [!code --]
data: '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
})
// '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac'
```
```ts [abi.ts]
const abiItem = {
inputs: [{ name: 'tokenId', type: 'uint256' }],
name: 'ownerOf',
Expand All @@ -63,14 +72,7 @@ const abiItem = {
type: 'function',
}

const value = decodeFunctionResult({
abi: [abiItem],
functionName: 'ownerOf', // [!code --]
data: '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
})
// '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac'
```

:::


Expand All @@ -96,6 +98,7 @@ const value = decodeFunctionResult({
* sender: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* z: 69
* }
*/
```

```ts [abi.ts]
Expand Down

0 comments on commit 3e27073

Please sign in to comment.