viem 2.2.0 → 2.4.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 +29 -0
- package/_cjs/actions/ens/getEnsAddress.js +12 -3
- package/_cjs/actions/ens/getEnsAddress.js.map +1 -1
- package/_cjs/actions/ens/getEnsAvatar.js +7 -2
- package/_cjs/actions/ens/getEnsAvatar.js.map +1 -1
- package/_cjs/actions/ens/getEnsName.js +12 -3
- package/_cjs/actions/ens/getEnsName.js.map +1 -1
- package/_cjs/actions/ens/getEnsText.js +12 -3
- package/_cjs/actions/ens/getEnsText.js.map +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js +1 -1
- package/_cjs/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_cjs/chains/definitions/baseSepolia.js +3 -3
- package/_cjs/chains/definitions/baseSepolia.js.map +1 -1
- package/_cjs/chains/definitions/gnosis.js +3 -2
- package/_cjs/chains/definitions/gnosis.js.map +1 -1
- package/_cjs/chains/definitions/goerli.js +2 -2
- package/_cjs/chains/definitions/goerli.js.map +1 -1
- package/_cjs/chains/definitions/mainnet.js +2 -2
- package/_cjs/chains/definitions/sepolia.js +2 -2
- package/_cjs/chains/definitions/sepolia.js.map +1 -1
- package/_cjs/constants/abis.js +64 -0
- package/_cjs/constants/abis.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +18 -10
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/abi/decodeErrorResult.js +2 -2
- package/_cjs/utils/abi/decodeErrorResult.js.map +1 -1
- package/_cjs/utils/abi/decodeEventLog.js +2 -2
- package/_cjs/utils/abi/decodeEventLog.js.map +1 -1
- package/_cjs/utils/abi/decodeFunctionData.js +2 -2
- package/_cjs/utils/abi/decodeFunctionData.js.map +1 -1
- package/_cjs/utils/abi/encodeErrorResult.js +2 -2
- package/_cjs/utils/abi/encodeErrorResult.js.map +1 -1
- package/_cjs/utils/abi/encodeEventTopics.js +2 -2
- package/_cjs/utils/abi/encodeEventTopics.js.map +1 -1
- package/_cjs/utils/abi/encodeFunctionData.js +2 -2
- package/_cjs/utils/abi/encodeFunctionData.js.map +1 -1
- package/_cjs/utils/abi/getAbiItem.js +4 -4
- package/_cjs/utils/abi/getAbiItem.js.map +1 -1
- package/_cjs/utils/ens/errors.js +6 -0
- package/_cjs/utils/ens/errors.js.map +1 -1
- package/_cjs/utils/hash/hashSignature.js +11 -0
- package/_cjs/utils/hash/hashSignature.js.map +1 -0
- package/_cjs/utils/hash/toEventHash.js +6 -0
- package/_cjs/utils/hash/toEventHash.js.map +1 -0
- package/_cjs/utils/hash/toEventSelector.js +6 -0
- package/_cjs/utils/hash/toEventSelector.js.map +1 -0
- package/_cjs/utils/hash/toEventSignature.js +6 -0
- package/_cjs/utils/hash/toEventSignature.js.map +1 -0
- package/_cjs/utils/hash/toFunctionHash.js +6 -0
- package/_cjs/utils/hash/toFunctionHash.js.map +1 -0
- package/_cjs/utils/hash/toFunctionSelector.js +8 -0
- package/_cjs/utils/hash/toFunctionSelector.js.map +1 -0
- package/_cjs/utils/hash/toFunctionSignature.js +6 -0
- package/_cjs/utils/hash/toFunctionSignature.js.map +1 -0
- package/_cjs/utils/hash/toSignature.js +15 -0
- package/_cjs/utils/hash/toSignature.js.map +1 -0
- package/_cjs/utils/hash/toSignatureHash.js +10 -0
- package/_cjs/utils/hash/toSignatureHash.js.map +1 -0
- package/_cjs/utils/index.js +18 -6
- package/_cjs/utils/index.js.map +1 -1
- package/_esm/actions/ens/getEnsAddress.js +12 -3
- package/_esm/actions/ens/getEnsAddress.js.map +1 -1
- package/_esm/actions/ens/getEnsAvatar.js +7 -2
- package/_esm/actions/ens/getEnsAvatar.js.map +1 -1
- package/_esm/actions/ens/getEnsName.js +12 -3
- package/_esm/actions/ens/getEnsName.js.map +1 -1
- package/_esm/actions/ens/getEnsText.js +12 -3
- package/_esm/actions/ens/getEnsText.js.map +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js +1 -1
- package/_esm/actions/public/estimateFeesPerGas.js.map +1 -1
- package/_esm/chains/definitions/baseSepolia.js +3 -3
- package/_esm/chains/definitions/baseSepolia.js.map +1 -1
- package/_esm/chains/definitions/gnosis.js +3 -2
- package/_esm/chains/definitions/gnosis.js.map +1 -1
- package/_esm/chains/definitions/goerli.js +2 -2
- package/_esm/chains/definitions/goerli.js.map +1 -1
- package/_esm/chains/definitions/mainnet.js +2 -2
- package/_esm/chains/definitions/sepolia.js +2 -2
- package/_esm/chains/definitions/sepolia.js.map +1 -1
- package/_esm/constants/abis.js +64 -0
- package/_esm/constants/abis.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +14 -4
- package/_esm/index.js.map +1 -1
- package/_esm/utils/abi/decodeErrorResult.js +2 -2
- package/_esm/utils/abi/decodeErrorResult.js.map +1 -1
- package/_esm/utils/abi/decodeEventLog.js +2 -2
- package/_esm/utils/abi/decodeEventLog.js.map +1 -1
- package/_esm/utils/abi/decodeFunctionData.js +2 -2
- package/_esm/utils/abi/decodeFunctionData.js.map +1 -1
- package/_esm/utils/abi/encodeErrorResult.js +2 -2
- package/_esm/utils/abi/encodeErrorResult.js.map +1 -1
- package/_esm/utils/abi/encodeEventTopics.js +2 -2
- package/_esm/utils/abi/encodeEventTopics.js.map +1 -1
- package/_esm/utils/abi/encodeFunctionData.js +2 -2
- package/_esm/utils/abi/encodeFunctionData.js.map +1 -1
- package/_esm/utils/abi/getAbiItem.js +4 -4
- package/_esm/utils/abi/getAbiItem.js.map +1 -1
- package/_esm/utils/ens/errors.js +6 -0
- package/_esm/utils/ens/errors.js.map +1 -1
- package/_esm/utils/hash/hashSignature.js +7 -0
- package/_esm/utils/hash/hashSignature.js.map +1 -0
- package/_esm/utils/hash/toEventHash.js +2 -0
- package/_esm/utils/hash/toEventHash.js.map +1 -0
- package/_esm/utils/hash/toEventSelector.js +10 -0
- package/_esm/utils/hash/toEventSelector.js.map +1 -0
- package/_esm/utils/hash/toEventSignature.js +2 -0
- package/_esm/utils/hash/toEventSignature.js.map +1 -0
- package/_esm/utils/hash/toFunctionHash.js +2 -0
- package/_esm/utils/hash/toFunctionHash.js.map +1 -0
- package/_esm/utils/hash/toFunctionSelector.js +11 -0
- package/_esm/utils/hash/toFunctionSelector.js.map +1 -0
- package/_esm/utils/hash/toFunctionSignature.js +2 -0
- package/_esm/utils/hash/toFunctionSignature.js.map +1 -0
- package/_esm/utils/hash/toSignature.js +28 -0
- package/_esm/utils/hash/toSignature.js.map +1 -0
- package/_esm/utils/hash/toSignatureHash.js +9 -0
- package/_esm/utils/hash/toSignatureHash.js.map +1 -0
- package/_esm/utils/index.js +14 -2
- package/_esm/utils/index.js.map +1 -1
- package/_types/actions/ens/getEnsAddress.d.ts +5 -1
- package/_types/actions/ens/getEnsAddress.d.ts.map +1 -1
- package/_types/actions/ens/getEnsAvatar.d.ts +2 -2
- package/_types/actions/ens/getEnsAvatar.d.ts.map +1 -1
- package/_types/actions/ens/getEnsName.d.ts +5 -1
- package/_types/actions/ens/getEnsName.d.ts.map +1 -1
- package/_types/actions/ens/getEnsText.d.ts +5 -1
- package/_types/actions/ens/getEnsText.d.ts.map +1 -1
- package/_types/actions/public/estimateFeesPerGas.d.ts.map +1 -1
- package/_types/chains/definitions/baseSepolia.d.ts +3 -3
- package/_types/chains/definitions/gnosis.d.ts +3 -2
- package/_types/chains/definitions/gnosis.d.ts.map +1 -1
- package/_types/chains/definitions/goerli.d.ts +2 -2
- package/_types/chains/definitions/mainnet.d.ts +2 -2
- package/_types/chains/definitions/sepolia.d.ts +2 -2
- package/_types/constants/abis.d.ts +95 -0
- package/_types/constants/abis.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +22 -4
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/abi/decodeErrorResult.d.ts +2 -2
- package/_types/utils/abi/decodeErrorResult.d.ts.map +1 -1
- package/_types/utils/abi/decodeEventLog.d.ts +2 -2
- package/_types/utils/abi/decodeEventLog.d.ts.map +1 -1
- package/_types/utils/abi/decodeFunctionData.d.ts +2 -2
- package/_types/utils/abi/decodeFunctionData.d.ts.map +1 -1
- package/_types/utils/abi/encodeErrorResult.d.ts +2 -2
- package/_types/utils/abi/encodeErrorResult.d.ts.map +1 -1
- package/_types/utils/abi/encodeEventTopics.d.ts +2 -2
- package/_types/utils/abi/encodeEventTopics.d.ts.map +1 -1
- package/_types/utils/abi/encodeFunctionData.d.ts +2 -2
- package/_types/utils/abi/encodeFunctionData.d.ts.map +1 -1
- package/_types/utils/abi/getAbiItem.d.ts +2 -2
- package/_types/utils/abi/getAbiItem.d.ts.map +1 -1
- package/_types/utils/ens/errors.d.ts.map +1 -1
- package/_types/utils/hash/hashSignature.d.ts +6 -0
- package/_types/utils/hash/hashSignature.d.ts.map +1 -0
- package/_types/utils/hash/toEventHash.d.ts +2 -0
- package/_types/utils/hash/toEventHash.d.ts.map +1 -0
- package/_types/utils/hash/toEventSelector.d.ts +12 -0
- package/_types/utils/hash/toEventSelector.d.ts.map +1 -0
- package/_types/utils/hash/toEventSignature.d.ts +2 -0
- package/_types/utils/hash/toEventSignature.d.ts.map +1 -0
- package/_types/utils/hash/toFunctionHash.d.ts +2 -0
- package/_types/utils/hash/toFunctionHash.d.ts.map +1 -0
- package/_types/utils/hash/toFunctionSelector.d.ts +14 -0
- package/_types/utils/hash/toFunctionSelector.d.ts.map +1 -0
- package/_types/utils/hash/toFunctionSignature.d.ts +2 -0
- package/_types/utils/hash/toFunctionSignature.d.ts.map +1 -0
- package/_types/utils/hash/toSignature.d.ts +23 -0
- package/_types/utils/hash/toSignature.d.ts.map +1 -0
- package/_types/utils/hash/toSignatureHash.d.ts +10 -0
- package/_types/utils/hash/toSignatureHash.d.ts.map +1 -0
- package/_types/utils/index.d.ts +22 -2
- package/_types/utils/index.d.ts.map +1 -1
- package/actions/ens/getEnsAddress.ts +18 -6
- package/actions/ens/getEnsAvatar.ts +10 -3
- package/actions/ens/getEnsName.ts +19 -6
- package/actions/ens/getEnsText.ts +18 -6
- package/actions/public/estimateFeesPerGas.ts +11 -10
- package/chains/definitions/baseSepolia.ts +3 -3
- package/chains/definitions/gnosis.ts +3 -2
- package/chains/definitions/goerli.ts +2 -2
- package/chains/definitions/mainnet.ts +2 -2
- package/chains/definitions/sepolia.ts +2 -2
- package/constants/abis.ts +64 -0
- package/errors/version.ts +1 -1
- package/index.ts +39 -15
- package/package.json +1 -1
- package/utils/abi/decodeErrorResult.ts +5 -5
- package/utils/abi/decodeEventLog.ts +5 -5
- package/utils/abi/decodeFunctionData.ts +5 -5
- package/utils/abi/encodeErrorResult.ts +5 -5
- package/utils/abi/encodeEventTopics.ts +6 -6
- package/utils/abi/encodeFunctionData.ts +5 -5
- package/utils/abi/getAbiItem.ts +8 -8
- package/utils/ens/errors.ts +3 -0
- package/utils/hash/{getEventSelector.ts → hashSignature.ts} +5 -6
- package/utils/hash/toEventHash.ts +4 -0
- package/utils/hash/toEventSelector.ts +16 -0
- package/utils/hash/toEventSignature.ts +4 -0
- package/utils/hash/toFunctionHash.ts +4 -0
- package/utils/hash/toFunctionSelector.ts +23 -0
- package/utils/hash/toFunctionSignature.ts +4 -0
- package/utils/hash/toSignature.ts +34 -0
- package/utils/hash/toSignatureHash.ts +17 -0
- package/utils/index.ts +39 -7
- package/_cjs/utils/hash/getEventSelector.js +0 -10
- package/_cjs/utils/hash/getEventSelector.js.map +0 -1
- package/_cjs/utils/hash/getEventSignature.js +0 -9
- package/_cjs/utils/hash/getEventSignature.js.map +0 -1
- package/_cjs/utils/hash/getFunctionSelector.js +0 -11
- package/_cjs/utils/hash/getFunctionSelector.js.map +0 -1
- package/_cjs/utils/hash/getFunctionSignature.js +0 -15
- package/_cjs/utils/hash/getFunctionSignature.js.map +0 -1
- package/_cjs/utils/hash/hashFunction.js +0 -17
- package/_cjs/utils/hash/hashFunction.js.map +0 -1
- package/_esm/utils/hash/getEventSelector.js +0 -6
- package/_esm/utils/hash/getEventSelector.js.map +0 -1
- package/_esm/utils/hash/getEventSignature.js +0 -5
- package/_esm/utils/hash/getEventSignature.js.map +0 -1
- package/_esm/utils/hash/getFunctionSelector.js +0 -7
- package/_esm/utils/hash/getFunctionSelector.js.map +0 -1
- package/_esm/utils/hash/getFunctionSignature.js +0 -11
- package/_esm/utils/hash/getFunctionSignature.js.map +0 -1
- package/_esm/utils/hash/hashFunction.js +0 -12
- package/_esm/utils/hash/hashFunction.js.map +0 -1
- package/_types/utils/hash/getEventSelector.d.ts +0 -7
- package/_types/utils/hash/getEventSelector.d.ts.map +0 -1
- package/_types/utils/hash/getEventSignature.d.ts +0 -6
- package/_types/utils/hash/getEventSignature.d.ts.map +0 -1
- package/_types/utils/hash/getFunctionSelector.d.ts +0 -9
- package/_types/utils/hash/getFunctionSelector.d.ts.map +0 -1
- package/_types/utils/hash/getFunctionSignature.d.ts +0 -6
- package/_types/utils/hash/getFunctionSignature.d.ts.map +0 -1
- package/_types/utils/hash/hashFunction.d.ts +0 -11
- package/_types/utils/hash/hashFunction.d.ts.map +0 -1
- package/utils/hash/getEventSignature.ts +0 -15
- package/utils/hash/getFunctionSelector.ts +0 -22
- package/utils/hash/getFunctionSignature.ts +0 -19
- package/utils/hash/hashFunction.ts +0 -35
@@ -10,9 +10,9 @@ import type { Hex } from '../../types/misc.js'
|
|
10
10
|
import type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'
|
11
11
|
import { type SliceErrorType, slice } from '../data/slice.js'
|
12
12
|
import {
|
13
|
-
type
|
14
|
-
|
15
|
-
} from '../hash/
|
13
|
+
type ToFunctionSelectorErrorType,
|
14
|
+
toFunctionSelector,
|
15
|
+
} from '../hash/toFunctionSelector.js'
|
16
16
|
import {
|
17
17
|
type DecodeAbiParametersErrorType,
|
18
18
|
decodeAbiParameters,
|
@@ -49,7 +49,7 @@ export type DecodeFunctionDataErrorType =
|
|
49
49
|
| AbiFunctionSignatureNotFoundError
|
50
50
|
| DecodeAbiParametersErrorType
|
51
51
|
| FormatAbiItemErrorType
|
52
|
-
|
|
52
|
+
| ToFunctionSelectorErrorType
|
53
53
|
| SliceErrorType
|
54
54
|
| ErrorType
|
55
55
|
|
@@ -61,7 +61,7 @@ export function decodeFunctionData<const abi extends Abi | readonly unknown[]>(
|
|
61
61
|
const description = abi.find(
|
62
62
|
(x) =>
|
63
63
|
x.type === 'function' &&
|
64
|
-
signature ===
|
64
|
+
signature === toFunctionSelector(formatAbiItem(x)),
|
65
65
|
)
|
66
66
|
if (!description)
|
67
67
|
throw new AbiFunctionSignatureNotFoundError(signature, {
|
@@ -11,9 +11,9 @@ import type {
|
|
11
11
|
import type { Hex } from '../../types/misc.js'
|
12
12
|
import { type ConcatHexErrorType, concatHex } from '../data/concat.js'
|
13
13
|
import {
|
14
|
-
type
|
15
|
-
|
16
|
-
} from '../hash/
|
14
|
+
type ToFunctionSelectorErrorType,
|
15
|
+
toFunctionSelector,
|
16
|
+
} from '../hash/toFunctionSelector.js'
|
17
17
|
|
18
18
|
import type { ErrorType } from '../../errors/utils.js'
|
19
19
|
import type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'
|
@@ -61,7 +61,7 @@ export type EncodeErrorResultReturnType = Hex
|
|
61
61
|
export type EncodeErrorResultErrorType =
|
62
62
|
| GetAbiItemErrorType
|
63
63
|
| FormatAbiItemErrorType
|
64
|
-
|
|
64
|
+
| ToFunctionSelectorErrorType
|
65
65
|
| EncodeAbiParametersErrorType
|
66
66
|
| ConcatHexErrorType
|
67
67
|
| ErrorType
|
@@ -85,7 +85,7 @@ export function encodeErrorResult<
|
|
85
85
|
throw new AbiErrorNotFoundError(undefined, { docsPath })
|
86
86
|
|
87
87
|
const definition = formatAbiItem(abiItem)
|
88
|
-
const signature =
|
88
|
+
const signature = toFunctionSelector(definition)
|
89
89
|
|
90
90
|
let data: Hex = '0x'
|
91
91
|
if (args && args.length > 0) {
|
@@ -22,11 +22,11 @@ import type {
|
|
22
22
|
import type { Hex } from '../../types/misc.js'
|
23
23
|
import type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'
|
24
24
|
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
|
25
|
-
import {
|
26
|
-
type GetEventSelectorErrorType,
|
27
|
-
getEventSelector,
|
28
|
-
} from '../hash/getEventSelector.js'
|
29
25
|
import { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'
|
26
|
+
import {
|
27
|
+
type ToEventSelectorErrorType,
|
28
|
+
toEventSelector,
|
29
|
+
} from '../hash/toEventSelector.js'
|
30
30
|
import {
|
31
31
|
type EncodeAbiParametersErrorType,
|
32
32
|
encodeAbiParameters,
|
@@ -71,7 +71,7 @@ export type EncodeEventTopicsErrorType =
|
|
71
71
|
| EncodeArgErrorType
|
72
72
|
| FormatAbiItemErrorType
|
73
73
|
| GetAbiItemErrorType
|
74
|
-
|
|
74
|
+
| ToEventSelectorErrorType
|
75
75
|
| ErrorType
|
76
76
|
|
77
77
|
export function encodeEventTopics<
|
@@ -91,7 +91,7 @@ export function encodeEventTopics<
|
|
91
91
|
throw new AbiEventNotFoundError(undefined, { docsPath })
|
92
92
|
|
93
93
|
const definition = formatAbiItem(abiItem)
|
94
|
-
const signature =
|
94
|
+
const signature = toEventSelector(definition as EventDefinition)
|
95
95
|
|
96
96
|
let topics: Hex[] = []
|
97
97
|
if (args && 'inputs' in abiItem) {
|
@@ -10,9 +10,9 @@ import type {
|
|
10
10
|
} from '../../types/contract.js'
|
11
11
|
import { type ConcatHexErrorType, concatHex } from '../data/concat.js'
|
12
12
|
import {
|
13
|
-
type
|
14
|
-
|
15
|
-
} from '../hash/
|
13
|
+
type ToFunctionSelectorErrorType,
|
14
|
+
toFunctionSelector,
|
15
|
+
} from '../hash/toFunctionSelector.js'
|
16
16
|
|
17
17
|
import type { ErrorType } from '../../errors/utils.js'
|
18
18
|
import type { Hex } from '../../types/misc.js'
|
@@ -71,7 +71,7 @@ export type EncodeFunctionDataErrorType =
|
|
71
71
|
| EncodeAbiParametersErrorType
|
72
72
|
| FormatAbiItemErrorType
|
73
73
|
| GetAbiItemErrorType
|
74
|
-
|
|
74
|
+
| ToFunctionSelectorErrorType
|
75
75
|
| ErrorType
|
76
76
|
|
77
77
|
export function encodeFunctionData<
|
@@ -97,7 +97,7 @@ export function encodeFunctionData<
|
|
97
97
|
throw new AbiFunctionNotFoundError(undefined, { docsPath })
|
98
98
|
|
99
99
|
const definition = formatAbiItem(abiItem)
|
100
|
-
const signature =
|
100
|
+
const signature = toFunctionSelector(definition)
|
101
101
|
const data =
|
102
102
|
'inputs' in abiItem && abiItem.inputs
|
103
103
|
? encodeAbiParameters(abiItem.inputs, args ?? [])
|
package/utils/abi/getAbiItem.ts
CHANGED
@@ -12,12 +12,12 @@ import type {
|
|
12
12
|
import type { Hex } from '../../types/misc.js'
|
13
13
|
import type { UnionEvaluate } from '../../types/utils.js'
|
14
14
|
import { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'
|
15
|
-
import { getEventSelector } from '../../utils/hash/getEventSelector.js'
|
16
|
-
import {
|
17
|
-
type GetFunctionSelectorErrorType,
|
18
|
-
getFunctionSelector,
|
19
|
-
} from '../../utils/hash/getFunctionSelector.js'
|
20
15
|
import { type IsAddressErrorType, isAddress } from '../address/isAddress.js'
|
16
|
+
import { toEventSelector } from '../hash/toEventSelector.js'
|
17
|
+
import {
|
18
|
+
type ToFunctionSelectorErrorType,
|
19
|
+
toFunctionSelector,
|
20
|
+
} from '../hash/toFunctionSelector.js'
|
21
21
|
|
22
22
|
export type GetAbiItemParameters<
|
23
23
|
abi extends Abi | readonly unknown[] = Abi,
|
@@ -56,7 +56,7 @@ export type GetAbiItemParameters<
|
|
56
56
|
export type GetAbiItemErrorType =
|
57
57
|
| IsArgOfTypeErrorType
|
58
58
|
| IsHexErrorType
|
59
|
-
|
|
59
|
+
| ToFunctionSelectorErrorType
|
60
60
|
| ErrorType
|
61
61
|
|
62
62
|
export type GetAbiItemReturnType<
|
@@ -86,8 +86,8 @@ export function getAbiItem<
|
|
86
86
|
const abiItems = (abi as Abi).filter((abiItem) => {
|
87
87
|
if (isSelector) {
|
88
88
|
if (abiItem.type === 'function')
|
89
|
-
return
|
90
|
-
if (abiItem.type === 'event') return
|
89
|
+
return toFunctionSelector(abiItem) === name
|
90
|
+
if (abiItem.type === 'event') return toEventSelector(abiItem) === name
|
91
91
|
return false
|
92
92
|
}
|
93
93
|
return 'name' in abiItem && abiItem.name === name
|
package/utils/ens/errors.ts
CHANGED
@@ -17,6 +17,9 @@ export function isNullUniversalResolverError(
|
|
17
17
|
if (!(cause instanceof ContractFunctionRevertedError)) return false
|
18
18
|
if (cause.data?.errorName === 'ResolverNotFound') return true
|
19
19
|
if (cause.data?.errorName === 'ResolverWildcardNotSupported') return true
|
20
|
+
if (cause.data?.errorName === 'ResolverNotContract') return true
|
21
|
+
if (cause.data?.errorName === 'ResolverError') return true
|
22
|
+
if (cause.data?.errorName === 'HttpError') return true
|
20
23
|
// Backwards compatibility for older UniversalResolver contracts
|
21
24
|
if (
|
22
25
|
cause.reason?.includes(
|
@@ -1,16 +1,15 @@
|
|
1
|
-
import type
|
1
|
+
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
|
2
2
|
|
3
3
|
import type { ErrorType } from '../../errors/utils.js'
|
4
|
-
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
|
5
|
-
import { getEventSignature } from './getEventSignature.js'
|
6
4
|
import { type Keccak256ErrorType, keccak256 } from './keccak256.js'
|
7
5
|
|
8
6
|
const hash = (value: string) => keccak256(toBytes(value))
|
9
7
|
|
10
|
-
export type
|
8
|
+
export type HashSignatureErrorType =
|
11
9
|
| Keccak256ErrorType
|
12
10
|
| ToBytesErrorType
|
13
11
|
| ErrorType
|
14
12
|
|
15
|
-
export
|
16
|
-
hash(
|
13
|
+
export function hashSignature(sig: string) {
|
14
|
+
return hash(sig)
|
15
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { ErrorType } from '../../errors/utils.js'
|
2
|
+
import {
|
3
|
+
type ToSignatureHashErrorType,
|
4
|
+
toSignatureHash,
|
5
|
+
} from './toSignatureHash.js'
|
6
|
+
|
7
|
+
export type ToEventSelectorErrorType = ToSignatureHashErrorType | ErrorType
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Returns the event selector for a given event definition.
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* const selector = toEventSelector('Transfer(address indexed from, address indexed to, uint256 amount)')
|
14
|
+
* // 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
|
15
|
+
*/
|
16
|
+
export const toEventSelector = toSignatureHash
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { AbiFunction } from 'abitype'
|
2
|
+
|
3
|
+
import type { ErrorType } from '../../errors/utils.js'
|
4
|
+
import { type SliceErrorType, slice } from '../data/slice.js'
|
5
|
+
import {
|
6
|
+
type ToSignatureHashErrorType,
|
7
|
+
toSignatureHash,
|
8
|
+
} from './toSignatureHash.js'
|
9
|
+
|
10
|
+
export type ToFunctionSelectorErrorType =
|
11
|
+
| ToSignatureHashErrorType
|
12
|
+
| SliceErrorType
|
13
|
+
| ErrorType
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Returns the function selector for a given function definition.
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* const selector = toFunctionSelector('function ownerOf(uint256 tokenId)')
|
20
|
+
* // 0x6352211e
|
21
|
+
*/
|
22
|
+
export const toFunctionSelector = (fn: string | AbiFunction) =>
|
23
|
+
slice(toSignatureHash(fn), 0, 4)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { type AbiEvent, type AbiFunction, formatAbiItem } from 'abitype'
|
2
|
+
|
3
|
+
import type { ErrorType } from '../../errors/utils.js'
|
4
|
+
import {
|
5
|
+
type NormalizeSignatureErrorType,
|
6
|
+
normalizeSignature,
|
7
|
+
} from './normalizeSignature.js'
|
8
|
+
|
9
|
+
export type ToSignatureErrorType = NormalizeSignatureErrorType | ErrorType
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Returns the signature for a given function or event definition.
|
13
|
+
*
|
14
|
+
* @example
|
15
|
+
* const signature = toSignature('function ownerOf(uint256 tokenId)')
|
16
|
+
* // 'ownerOf(uint256)'
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* const signature_3 = toSignature({
|
20
|
+
* name: 'ownerOf',
|
21
|
+
* type: 'function',
|
22
|
+
* inputs: [{ name: 'tokenId', type: 'uint256' }],
|
23
|
+
* outputs: [],
|
24
|
+
* stateMutability: 'view',
|
25
|
+
* })
|
26
|
+
* // 'ownerOf(uint256)'
|
27
|
+
*/
|
28
|
+
export const toSignature = (def: string | AbiFunction | AbiEvent) => {
|
29
|
+
const def_ = (() => {
|
30
|
+
if (typeof def === 'string') return def
|
31
|
+
return formatAbiItem(def)
|
32
|
+
})()
|
33
|
+
return normalizeSignature(def_)
|
34
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { AbiEvent, AbiFunction } from 'abitype'
|
2
|
+
|
3
|
+
import type { ErrorType } from '../../errors/utils.js'
|
4
|
+
import { type HashSignatureErrorType, hashSignature } from './hashSignature.js'
|
5
|
+
import { type ToSignatureErrorType, toSignature } from './toSignature.js'
|
6
|
+
|
7
|
+
export type ToSignatureHashErrorType =
|
8
|
+
| HashSignatureErrorType
|
9
|
+
| ToSignatureErrorType
|
10
|
+
| ErrorType
|
11
|
+
|
12
|
+
/**
|
13
|
+
* Returns the hash (of the function/event signature) for a given event or function definition.
|
14
|
+
*/
|
15
|
+
export function toSignatureHash(fn: string | AbiFunction | AbiEvent) {
|
16
|
+
return hashSignature(toSignature(fn))
|
17
|
+
}
|
package/utils/index.ts
CHANGED
@@ -342,13 +342,45 @@ export {
|
|
342
342
|
defineFormatter,
|
343
343
|
} from './formatters/formatter.js'
|
344
344
|
export {
|
345
|
-
type
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
} from './hash/
|
345
|
+
type ToEventSelectorErrorType,
|
346
|
+
toEventSelector,
|
347
|
+
/** @deprecated use `ToEventSelectorErrorType`. */
|
348
|
+
type ToEventSelectorErrorType as GetEventSelectorErrorType,
|
349
|
+
/** @deprecated use `toEventSelector`. */
|
350
|
+
toEventSelector as getEventSelector,
|
351
|
+
} from './hash/toEventSelector.js'
|
352
|
+
export {
|
353
|
+
type ToFunctionSelectorErrorType,
|
354
|
+
toFunctionSelector,
|
355
|
+
/** @deprecated use `ToFunctionSelectorErrorType`. */
|
356
|
+
type ToFunctionSelectorErrorType as GetFunctionSelectorErrorType,
|
357
|
+
/** @deprecated use `toFunctionSelector`. */
|
358
|
+
toFunctionSelector as getFunctionSelector,
|
359
|
+
} from './hash/toFunctionSelector.js'
|
360
|
+
export {
|
361
|
+
type ToEventSignatureErrorType,
|
362
|
+
toEventSignature,
|
363
|
+
/** @deprecated use `ToEventSignatureErrorType`. */
|
364
|
+
type ToEventSignatureErrorType as GetEventSignatureErrorType,
|
365
|
+
/** @deprecated use `toEventSignature`. */
|
366
|
+
toEventSignature as getEventSignature,
|
367
|
+
} from './hash/toEventSignature.js'
|
368
|
+
export {
|
369
|
+
type ToFunctionSignatureErrorType,
|
370
|
+
toFunctionSignature,
|
371
|
+
/** @deprecated use `ToFunctionSignatureErrorType`. */
|
372
|
+
type ToFunctionSignatureErrorType as GetFunctionSignatureErrorType,
|
373
|
+
/** @deprecated use `toFunctionSignature`. */
|
374
|
+
toFunctionSignature as getFunctionSignature,
|
375
|
+
} from './hash/toFunctionSignature.js'
|
376
|
+
export {
|
377
|
+
type ToEventHashErrorType,
|
378
|
+
toEventHash,
|
379
|
+
} from './hash/toEventHash.js'
|
380
|
+
export {
|
381
|
+
type ToFunctionHashErrorType,
|
382
|
+
toFunctionHash,
|
383
|
+
} from './hash/toFunctionHash.js'
|
352
384
|
export { type IsHashErrorType, isHash } from './hash/isHash.js'
|
353
385
|
export { type Keccak256ErrorType, keccak256 } from './hash/keccak256.js'
|
354
386
|
export { type Sha256ErrorType, sha256 } from './hash/sha256.js'
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getEventSelector = void 0;
|
4
|
-
const toBytes_js_1 = require("../encoding/toBytes.js");
|
5
|
-
const getEventSignature_js_1 = require("./getEventSignature.js");
|
6
|
-
const keccak256_js_1 = require("./keccak256.js");
|
7
|
-
const hash = (value) => (0, keccak256_js_1.keccak256)((0, toBytes_js_1.toBytes)(value));
|
8
|
-
const getEventSelector = (fn) => hash((0, getEventSignature_js_1.getEventSignature)(fn));
|
9
|
-
exports.getEventSelector = getEventSelector;
|
10
|
-
//# sourceMappingURL=getEventSelector.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getEventSelector.js","sourceRoot":"","sources":["../../../utils/hash/getEventSelector.ts"],"names":[],"mappings":";;;AAGA,uDAAuE;AACvE,iEAA0D;AAC1D,iDAAmE;AAEnE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,wBAAS,EAAC,IAAA,oBAAO,EAAC,KAAK,CAAC,CAAC,CAAA;AAOlD,MAAM,gBAAgB,GAAG,CAAC,EAAqB,EAAE,EAAE,CACxD,IAAI,CAAC,IAAA,wCAAiB,EAAC,EAAE,CAAC,CAAC,CAAA;AADhB,QAAA,gBAAgB,oBACA"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getEventSignature = void 0;
|
4
|
-
const getFunctionSignature_js_1 = require("./getFunctionSignature.js");
|
5
|
-
const getEventSignature = (fn) => {
|
6
|
-
return (0, getFunctionSignature_js_1.getFunctionSignature)(fn);
|
7
|
-
};
|
8
|
-
exports.getEventSignature = getEventSignature;
|
9
|
-
//# sourceMappingURL=getEventSignature.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getEventSignature.js","sourceRoot":"","sources":["../../../utils/hash/getEventSignature.ts"],"names":[],"mappings":";;;AAGA,uEAGkC;AAM3B,MAAM,iBAAiB,GAAG,CAAC,EAAqB,EAAE,EAAE;IACzD,OAAO,IAAA,8CAAoB,EAAC,EAAuB,CAAC,CAAA;AACtD,CAAC,CAAA;AAFY,QAAA,iBAAiB,qBAE7B"}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getFunctionSelector = void 0;
|
4
|
-
const slice_js_1 = require("../data/slice.js");
|
5
|
-
const toBytes_js_1 = require("../encoding/toBytes.js");
|
6
|
-
const getFunctionSignature_js_1 = require("./getFunctionSignature.js");
|
7
|
-
const keccak256_js_1 = require("./keccak256.js");
|
8
|
-
const hash = (value) => (0, keccak256_js_1.keccak256)((0, toBytes_js_1.toBytes)(value));
|
9
|
-
const getFunctionSelector = (fn) => (0, slice_js_1.slice)(hash((0, getFunctionSignature_js_1.getFunctionSignature)(fn)), 0, 4);
|
10
|
-
exports.getFunctionSelector = getFunctionSelector;
|
11
|
-
//# sourceMappingURL=getFunctionSelector.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getFunctionSelector.js","sourceRoot":"","sources":["../../../utils/hash/getFunctionSelector.ts"],"names":[],"mappings":";;;AAGA,+CAA6D;AAC7D,uDAAuE;AACvE,uEAGkC;AAClC,iDAAmE;AAEnE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,wBAAS,EAAC,IAAA,oBAAO,EAAC,KAAK,CAAC,CAAC,CAAA;AASlD,MAAM,mBAAmB,GAAG,CAAC,EAAwB,EAAE,EAAE,CAC9D,IAAA,gBAAK,EAAC,IAAI,CAAC,IAAA,8CAAoB,EAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;AADhC,QAAA,mBAAmB,uBACa"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getFunctionSignature = void 0;
|
4
|
-
const abitype_1 = require("abitype");
|
5
|
-
const normalizeSignature_js_1 = require("./normalizeSignature.js");
|
6
|
-
const getFunctionSignature = (fn_) => {
|
7
|
-
const fn = (() => {
|
8
|
-
if (typeof fn_ === 'string')
|
9
|
-
return fn_;
|
10
|
-
return (0, abitype_1.formatAbiItem)(fn_);
|
11
|
-
})();
|
12
|
-
return (0, normalizeSignature_js_1.normalizeSignature)(fn);
|
13
|
-
};
|
14
|
-
exports.getFunctionSignature = getFunctionSignature;
|
15
|
-
//# sourceMappingURL=getFunctionSignature.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getFunctionSignature.js","sourceRoot":"","sources":["../../../utils/hash/getFunctionSignature.ts"],"names":[],"mappings":";;;AAAA,qCAAyD;AAGzD,mEAGgC;AAMzB,MAAM,oBAAoB,GAAG,CAAC,GAAyB,EAAE,EAAE;IAChE,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;QACf,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAA;QACvC,OAAO,IAAA,uBAAa,EAAC,GAAG,CAAC,CAAA;IAC3B,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,IAAA,0CAAkB,EAAC,EAAE,CAAC,CAAA;AAC/B,CAAC,CAAA;AANY,QAAA,oBAAoB,wBAMhC"}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.hashAbiItem = exports.hashFunction = void 0;
|
4
|
-
const formatAbiItem_js_1 = require("../abi/formatAbiItem.js");
|
5
|
-
const toBytes_js_1 = require("../encoding/toBytes.js");
|
6
|
-
const getFunctionSignature_js_1 = require("./getFunctionSignature.js");
|
7
|
-
const keccak256_js_1 = require("./keccak256.js");
|
8
|
-
const hash = (value) => (0, keccak256_js_1.keccak256)((0, toBytes_js_1.toBytes)(value));
|
9
|
-
function hashFunction(def) {
|
10
|
-
return hash((0, getFunctionSignature_js_1.getFunctionSignature)(def));
|
11
|
-
}
|
12
|
-
exports.hashFunction = hashFunction;
|
13
|
-
function hashAbiItem(abiItem) {
|
14
|
-
return hash((0, formatAbiItem_js_1.formatAbiItem)(abiItem));
|
15
|
-
}
|
16
|
-
exports.hashAbiItem = hashAbiItem;
|
17
|
-
//# sourceMappingURL=hashFunction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hashFunction.js","sourceRoot":"","sources":["../../../utils/hash/hashFunction.ts"],"names":[],"mappings":";;;AACA,8DAGgC;AAChC,uDAAuE;AAGvE,uEAGkC;AAClC,iDAAmE;AAEnE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAA,wBAAS,EAAC,IAAA,oBAAO,EAAC,KAAK,CAAC,CAAC,CAAA;AAQzD,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,IAAA,8CAAoB,EAAC,GAAG,CAAC,CAAC,CAAA;AACxC,CAAC;AAFD,oCAEC;AAQD,SAAgB,WAAW,CAAC,OAA+B;IACzD,OAAO,IAAI,CAAC,IAAA,gCAAa,EAAC,OAAO,CAAC,CAAC,CAAA;AACrC,CAAC;AAFD,kCAEC"}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { toBytes } from '../encoding/toBytes.js';
|
2
|
-
import { getEventSignature } from './getEventSignature.js';
|
3
|
-
import { keccak256 } from './keccak256.js';
|
4
|
-
const hash = (value) => keccak256(toBytes(value));
|
5
|
-
export const getEventSelector = (fn) => hash(getEventSignature(fn));
|
6
|
-
//# sourceMappingURL=getEventSelector.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getEventSelector.js","sourceRoot":"","sources":["../../../utils/hash/getEventSelector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAA2B,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAEnE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AAOzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAqB,EAAE,EAAE,CACxD,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getEventSignature.js","sourceRoot":"","sources":["../../../utils/hash/getEventSignature.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAMlC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAqB,EAAE,EAAE;IACzD,OAAO,oBAAoB,CAAC,EAAuB,CAAC,CAAA;AACtD,CAAC,CAAA"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import { slice } from '../data/slice.js';
|
2
|
-
import { toBytes } from '../encoding/toBytes.js';
|
3
|
-
import { getFunctionSignature, } from './getFunctionSignature.js';
|
4
|
-
import { keccak256 } from './keccak256.js';
|
5
|
-
const hash = (value) => keccak256(toBytes(value));
|
6
|
-
export const getFunctionSelector = (fn) => slice(hash(getFunctionSignature(fn)), 0, 4);
|
7
|
-
//# sourceMappingURL=getFunctionSelector.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getFunctionSelector.js","sourceRoot":"","sources":["../../../utils/hash/getFunctionSelector.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAEL,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAA2B,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAEnE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AASzD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAwB,EAAE,EAAE,CAC9D,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { formatAbiItem } from 'abitype';
|
2
|
-
import { normalizeSignature, } from './normalizeSignature.js';
|
3
|
-
export const getFunctionSignature = (fn_) => {
|
4
|
-
const fn = (() => {
|
5
|
-
if (typeof fn_ === 'string')
|
6
|
-
return fn_;
|
7
|
-
return formatAbiItem(fn_);
|
8
|
-
})();
|
9
|
-
return normalizeSignature(fn);
|
10
|
-
};
|
11
|
-
//# sourceMappingURL=getFunctionSignature.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getFunctionSignature.js","sourceRoot":"","sources":["../../../utils/hash/getFunctionSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,SAAS,CAAA;AAGzD,OAAO,EAEL,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAMhC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAyB,EAAE,EAAE;IAChE,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE;QACf,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAA;QACvC,OAAO,aAAa,CAAC,GAAG,CAAC,CAAA;IAC3B,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,kBAAkB,CAAC,EAAE,CAAC,CAAA;AAC/B,CAAC,CAAA"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { formatAbiItem, } from '../abi/formatAbiItem.js';
|
2
|
-
import { toBytes } from '../encoding/toBytes.js';
|
3
|
-
import { getFunctionSignature, } from './getFunctionSignature.js';
|
4
|
-
import { keccak256 } from './keccak256.js';
|
5
|
-
const hash = (value) => keccak256(toBytes(value));
|
6
|
-
export function hashFunction(def) {
|
7
|
-
return hash(getFunctionSignature(def));
|
8
|
-
}
|
9
|
-
export function hashAbiItem(abiItem) {
|
10
|
-
return hash(formatAbiItem(abiItem));
|
11
|
-
}
|
12
|
-
//# sourceMappingURL=hashFunction.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hashFunction.js","sourceRoot":"","sources":["../../../utils/hash/hashFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,aAAa,GACd,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAyB,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGvE,OAAO,EAEL,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAA2B,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAEnE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;AAQzD,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAA;AACxC,CAAC;AAQD,MAAM,UAAU,WAAW,CAAC,OAA+B;IACzD,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;AACrC,CAAC"}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { AbiEvent } from 'abitype';
|
2
|
-
import type { ErrorType } from '../../errors/utils.js';
|
3
|
-
import { type ToBytesErrorType } from '../encoding/toBytes.js';
|
4
|
-
import { type Keccak256ErrorType } from './keccak256.js';
|
5
|
-
export type GetEventSelectorErrorType = Keccak256ErrorType | ToBytesErrorType | ErrorType;
|
6
|
-
export declare const getEventSelector: (fn: string | AbiEvent) => `0x${string}`;
|
7
|
-
//# sourceMappingURL=getEventSelector.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getEventSelector.d.ts","sourceRoot":"","sources":["../../../utils/hash/getEventSelector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;AAEvE,OAAO,EAAE,KAAK,kBAAkB,EAAa,MAAM,gBAAgB,CAAA;AAInE,MAAM,MAAM,yBAAyB,GACjC,kBAAkB,GAClB,gBAAgB,GAChB,SAAS,CAAA;AAEb,eAAO,MAAM,gBAAgB,OAAQ,MAAM,GAAG,QAAQ,kBACzB,CAAA"}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import type { AbiEvent } from 'abitype';
|
2
|
-
import type { ErrorType } from '../../errors/utils.js';
|
3
|
-
import { type GetFunctionSignatureErrorType } from './getFunctionSignature.js';
|
4
|
-
export type GetEventSignatureErrorType = GetFunctionSignatureErrorType | ErrorType;
|
5
|
-
export declare const getEventSignature: (fn: string | AbiEvent) => string;
|
6
|
-
//# sourceMappingURL=getEventSignature.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getEventSignature.d.ts","sourceRoot":"","sources":["../../../utils/hash/getEventSignature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,2BAA2B,CAAA;AAElC,MAAM,MAAM,0BAA0B,GAClC,6BAA6B,GAC7B,SAAS,CAAA;AAEb,eAAO,MAAM,iBAAiB,OAAQ,MAAM,GAAG,QAAQ,WAEtD,CAAA"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import type { AbiFunction } from 'abitype';
|
2
|
-
import type { ErrorType } from '../../errors/utils.js';
|
3
|
-
import { type SliceErrorType } from '../data/slice.js';
|
4
|
-
import { type ToBytesErrorType } from '../encoding/toBytes.js';
|
5
|
-
import { type GetFunctionSignatureErrorType } from './getFunctionSignature.js';
|
6
|
-
import { type Keccak256ErrorType } from './keccak256.js';
|
7
|
-
export type GetFunctionSelectorErrorType = GetFunctionSignatureErrorType | Keccak256ErrorType | SliceErrorType | ToBytesErrorType | ErrorType;
|
8
|
-
export declare const getFunctionSelector: (fn: string | AbiFunction) => `0x${string}`;
|
9
|
-
//# sourceMappingURL=getFunctionSelector.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getFunctionSelector.d.ts","sourceRoot":"","sources":["../../../utils/hash/getFunctionSelector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;AACvE,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,kBAAkB,EAAa,MAAM,gBAAgB,CAAA;AAInE,MAAM,MAAM,4BAA4B,GACpC,6BAA6B,GAC7B,kBAAkB,GAClB,cAAc,GACd,gBAAgB,GAChB,SAAS,CAAA;AAEb,eAAO,MAAM,mBAAmB,OAAQ,MAAM,GAAG,WAAW,kBACf,CAAA"}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { type AbiFunction } from 'abitype';
|
2
|
-
import type { ErrorType } from '../../errors/utils.js';
|
3
|
-
import { type NormalizeSignatureErrorType } from './normalizeSignature.js';
|
4
|
-
export type GetFunctionSignatureErrorType = NormalizeSignatureErrorType | ErrorType;
|
5
|
-
export declare const getFunctionSignature: (fn_: string | AbiFunction) => string;
|
6
|
-
//# sourceMappingURL=getFunctionSignature.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"getFunctionSignature.d.ts","sourceRoot":"","sources":["../../../utils/hash/getFunctionSignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,SAAS,CAAA;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,KAAK,2BAA2B,EAEjC,MAAM,yBAAyB,CAAA;AAEhC,MAAM,MAAM,6BAA6B,GACrC,2BAA2B,GAC3B,SAAS,CAAA;AAEb,eAAO,MAAM,oBAAoB,QAAS,MAAM,GAAG,WAAW,WAM7D,CAAA"}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { AbiEvent, AbiFunction } from 'abitype';
|
2
|
-
import { type FormatAbiItemErrorType } from '../abi/formatAbiItem.js';
|
3
|
-
import { type ToBytesErrorType } from '../encoding/toBytes.js';
|
4
|
-
import type { ErrorType } from '../../errors/utils.js';
|
5
|
-
import { type GetFunctionSignatureErrorType } from './getFunctionSignature.js';
|
6
|
-
import { type Keccak256ErrorType } from './keccak256.js';
|
7
|
-
export type HashFunctionErrorType = Keccak256ErrorType | ToBytesErrorType | GetFunctionSignatureErrorType | ErrorType;
|
8
|
-
export declare function hashFunction(def: string): `0x${string}`;
|
9
|
-
export type HashAbiItemErrorType = Keccak256ErrorType | ToBytesErrorType | FormatAbiItemErrorType | ErrorType;
|
10
|
-
export declare function hashAbiItem(abiItem: AbiFunction | AbiEvent): `0x${string}`;
|
11
|
-
//# sourceMappingURL=hashFunction.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hashFunction.d.ts","sourceRoot":"","sources":["../../../utils/hash/hashFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,KAAK,gBAAgB,EAAW,MAAM,wBAAwB,CAAA;AAEvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,KAAK,6BAA6B,EAEnC,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,KAAK,kBAAkB,EAAa,MAAM,gBAAgB,CAAA;AAInE,MAAM,MAAM,qBAAqB,GAC7B,kBAAkB,GAClB,gBAAgB,GAChB,6BAA6B,GAC7B,SAAS,CAAA;AAEb,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,iBAEvC;AAED,MAAM,MAAM,oBAAoB,GAC5B,kBAAkB,GAClB,gBAAgB,GAChB,sBAAsB,GACtB,SAAS,CAAA;AAEb,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,QAAQ,iBAE1D"}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import type { AbiEvent, AbiFunction } from 'abitype'
|
2
|
-
|
3
|
-
import type { ErrorType } from '../../errors/utils.js'
|
4
|
-
import {
|
5
|
-
type GetFunctionSignatureErrorType,
|
6
|
-
getFunctionSignature,
|
7
|
-
} from './getFunctionSignature.js'
|
8
|
-
|
9
|
-
export type GetEventSignatureErrorType =
|
10
|
-
| GetFunctionSignatureErrorType
|
11
|
-
| ErrorType
|
12
|
-
|
13
|
-
export const getEventSignature = (fn: string | AbiEvent) => {
|
14
|
-
return getFunctionSignature(fn as {} as AbiFunction)
|
15
|
-
}
|