viem 1.10.13 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -4
- package/_cjs/chains/definitions/kroma.js +26 -0
- package/_cjs/chains/definitions/kroma.js.map +1 -0
- package/_cjs/chains/definitions/kromaSepolia.js +26 -0
- package/_cjs/chains/definitions/kromaSepolia.js.map +1 -0
- package/_cjs/chains/definitions/optimismSepolia.js +39 -0
- package/_cjs/chains/definitions/optimismSepolia.js.map +1 -0
- package/_cjs/chains/index.js +8 -2
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/node.js +11 -11
- package/_cjs/errors/node.js.map +1 -1
- package/_cjs/errors/rpc.js +18 -18
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/index.js +5 -1
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/hash/getEventSelector.js +5 -6
- package/_cjs/utils/hash/getEventSelector.js.map +1 -1
- package/_cjs/utils/hash/getEventSignature.js +9 -0
- package/_cjs/utils/hash/getEventSignature.js.map +1 -0
- package/_cjs/utils/hash/getFunctionSelector.js +5 -6
- package/_cjs/utils/hash/getFunctionSelector.js.map +1 -1
- package/_cjs/utils/hash/getFunctionSignature.js +15 -0
- package/_cjs/utils/hash/getFunctionSignature.js.map +1 -0
- package/_cjs/utils/hash/hashFunction.js +2 -4
- package/_cjs/utils/hash/hashFunction.js.map +1 -1
- package/_esm/chains/definitions/kroma.js +23 -0
- package/_esm/chains/definitions/kroma.js.map +1 -0
- package/_esm/chains/definitions/kromaSepolia.js +23 -0
- package/_esm/chains/definitions/kromaSepolia.js.map +1 -0
- package/_esm/chains/definitions/optimismSepolia.js +36 -0
- package/_esm/chains/definitions/optimismSepolia.js.map +1 -0
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/node.js +11 -22
- package/_esm/errors/node.js.map +1 -1
- package/_esm/errors/rpc.js +18 -36
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/index.js +2 -0
- package/_esm/index.js.map +1 -1
- package/_esm/utils/hash/getEventSelector.js +5 -6
- package/_esm/utils/hash/getEventSelector.js.map +1 -1
- package/_esm/utils/hash/getEventSignature.js +5 -0
- package/_esm/utils/hash/getEventSignature.js.map +1 -0
- package/_esm/utils/hash/getFunctionSelector.js +5 -6
- package/_esm/utils/hash/getFunctionSelector.js.map +1 -1
- package/_esm/utils/hash/getFunctionSignature.js +11 -0
- package/_esm/utils/hash/getFunctionSignature.js.map +1 -0
- package/_esm/utils/hash/hashFunction.js +2 -4
- package/_esm/utils/hash/hashFunction.js.map +1 -1
- package/_types/chains/definitions/kroma.d.ts +26 -0
- package/_types/chains/definitions/kroma.d.ts.map +1 -0
- package/_types/chains/definitions/kromaSepolia.d.ts +26 -0
- package/_types/chains/definitions/kromaSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/optimismSepolia.d.ts +331 -0
- package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -0
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/index.d.ts +2 -0
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/hash/getEventSelector.d.ts +1 -2
- package/_types/utils/hash/getEventSelector.d.ts.map +1 -1
- package/_types/utils/hash/getEventSignature.d.ts +3 -0
- package/_types/utils/hash/getEventSignature.d.ts.map +1 -0
- package/_types/utils/hash/getFunctionSelector.d.ts.map +1 -1
- package/_types/utils/hash/getFunctionSignature.d.ts +3 -0
- package/_types/utils/hash/getFunctionSignature.d.ts.map +1 -0
- package/_types/utils/hash/hashFunction.d.ts.map +1 -1
- package/chains/definitions/kroma.ts +23 -0
- package/chains/definitions/kromaSepolia.ts +23 -0
- package/chains/definitions/optimismSepolia.ts +39 -0
- package/chains/index.ts +3 -0
- package/index.ts +2 -0
- package/package.json +1 -1
- package/utils/hash/getEventSelector.ts +7 -6
- package/utils/hash/getEventSignature.ts +7 -0
- package/utils/hash/getFunctionSelector.ts +7 -5
- package/utils/hash/getFunctionSignature.ts +17 -0
- package/utils/hash/hashFunction.ts +2 -7
@@ -1,9 +1,10 @@
|
|
1
1
|
import type { AbiEvent } from 'abitype'
|
2
|
-
import type { EventDefinition } from '../../types/contract.js'
|
3
2
|
|
4
|
-
import {
|
3
|
+
import { toBytes } from '../encoding/toBytes.js'
|
4
|
+
import { getEventSignature } from './getEventSignature.js'
|
5
|
+
import { keccak256 } from './keccak256.js'
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
const hash = (value: string) => keccak256(toBytes(value))
|
8
|
+
|
9
|
+
export const getEventSelector = (fn: string | AbiEvent) =>
|
10
|
+
hash(getEventSignature(fn))
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import type { AbiFunction } from 'abitype'
|
2
2
|
import { slice } from '../data/slice.js'
|
3
3
|
|
4
|
-
import {
|
4
|
+
import { toBytes } from '../encoding/toBytes.js'
|
5
|
+
import { getFunctionSignature } from './getFunctionSignature.js'
|
6
|
+
import { keccak256 } from './keccak256.js'
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
const hash = (value: string) => keccak256(toBytes(value))
|
9
|
+
|
10
|
+
export const getFunctionSelector = (fn: string | AbiFunction) =>
|
11
|
+
slice(hash(getFunctionSignature(fn)), 0, 4)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { AbiFunction } from 'abitype'
|
2
|
+
|
3
|
+
import { formatAbiItem } from '../abi/formatAbiItem.js'
|
4
|
+
import {
|
5
|
+
extractFunctionName,
|
6
|
+
extractFunctionParams,
|
7
|
+
} from '../contract/extractFunctionParts.js'
|
8
|
+
|
9
|
+
export const getFunctionSignature = (fn: string | AbiFunction) => {
|
10
|
+
if (typeof fn === 'string') {
|
11
|
+
const name = extractFunctionName(fn)
|
12
|
+
const params = extractFunctionParams(fn) || []
|
13
|
+
return `${name}(${params.map(({ type }) => type).join(',')})`
|
14
|
+
}
|
15
|
+
|
16
|
+
return formatAbiItem(fn)
|
17
|
+
}
|
@@ -1,19 +1,14 @@
|
|
1
1
|
import type { AbiEvent, AbiFunction } from 'abitype'
|
2
2
|
import { formatAbiItem } from '../abi/formatAbiItem.js'
|
3
|
-
import {
|
4
|
-
extractFunctionName,
|
5
|
-
extractFunctionParams,
|
6
|
-
} from '../contract/extractFunctionParts.js'
|
7
3
|
import { toBytes } from '../encoding/toBytes.js'
|
8
4
|
|
5
|
+
import { getFunctionSignature } from './getFunctionSignature.js'
|
9
6
|
import { keccak256 } from './keccak256.js'
|
10
7
|
|
11
8
|
const hash = (value: string) => keccak256(toBytes(value))
|
12
9
|
|
13
10
|
export function hashFunction(def: string) {
|
14
|
-
|
15
|
-
const params = extractFunctionParams(def) || []
|
16
|
-
return hash(`${name}(${params.map(({ type }) => type).join(',')})`)
|
11
|
+
return hash(getFunctionSignature(def))
|
17
12
|
}
|
18
13
|
|
19
14
|
export function hashAbiItem(abiItem: AbiFunction | AbiEvent) {
|