viem 2.3.1 → 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 +11 -0
- 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/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/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/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/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/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/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/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
@@ -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
|
-
}
|
@@ -1,22 +0,0 @@
|
|
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 { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
|
6
|
-
import {
|
7
|
-
type GetFunctionSignatureErrorType,
|
8
|
-
getFunctionSignature,
|
9
|
-
} from './getFunctionSignature.js'
|
10
|
-
import { type Keccak256ErrorType, keccak256 } from './keccak256.js'
|
11
|
-
|
12
|
-
const hash = (value: string) => keccak256(toBytes(value))
|
13
|
-
|
14
|
-
export type GetFunctionSelectorErrorType =
|
15
|
-
| GetFunctionSignatureErrorType
|
16
|
-
| Keccak256ErrorType
|
17
|
-
| SliceErrorType
|
18
|
-
| ToBytesErrorType
|
19
|
-
| ErrorType
|
20
|
-
|
21
|
-
export const getFunctionSelector = (fn: string | AbiFunction) =>
|
22
|
-
slice(hash(getFunctionSignature(fn)), 0, 4)
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { 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 GetFunctionSignatureErrorType =
|
10
|
-
| NormalizeSignatureErrorType
|
11
|
-
| ErrorType
|
12
|
-
|
13
|
-
export const getFunctionSignature = (fn_: string | AbiFunction) => {
|
14
|
-
const fn = (() => {
|
15
|
-
if (typeof fn_ === 'string') return fn_
|
16
|
-
return formatAbiItem(fn_)
|
17
|
-
})()
|
18
|
-
return normalizeSignature(fn)
|
19
|
-
}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
import type { AbiEvent, AbiFunction } from 'abitype'
|
2
|
-
import {
|
3
|
-
type FormatAbiItemErrorType,
|
4
|
-
formatAbiItem,
|
5
|
-
} from '../abi/formatAbiItem.js'
|
6
|
-
import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
|
7
|
-
|
8
|
-
import type { ErrorType } from '../../errors/utils.js'
|
9
|
-
import {
|
10
|
-
type GetFunctionSignatureErrorType,
|
11
|
-
getFunctionSignature,
|
12
|
-
} from './getFunctionSignature.js'
|
13
|
-
import { type Keccak256ErrorType, keccak256 } from './keccak256.js'
|
14
|
-
|
15
|
-
const hash = (value: string) => keccak256(toBytes(value))
|
16
|
-
|
17
|
-
export type HashFunctionErrorType =
|
18
|
-
| Keccak256ErrorType
|
19
|
-
| ToBytesErrorType
|
20
|
-
| GetFunctionSignatureErrorType
|
21
|
-
| ErrorType
|
22
|
-
|
23
|
-
export function hashFunction(def: string) {
|
24
|
-
return hash(getFunctionSignature(def))
|
25
|
-
}
|
26
|
-
|
27
|
-
export type HashAbiItemErrorType =
|
28
|
-
| Keccak256ErrorType
|
29
|
-
| ToBytesErrorType
|
30
|
-
| FormatAbiItemErrorType
|
31
|
-
| ErrorType
|
32
|
-
|
33
|
-
export function hashAbiItem(abiItem: AbiFunction | AbiEvent) {
|
34
|
-
return hash(formatAbiItem(abiItem))
|
35
|
-
}
|