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.
Files changed (166) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/_cjs/errors/version.js +1 -1
  3. package/_cjs/index.js +18 -10
  4. package/_cjs/index.js.map +1 -1
  5. package/_cjs/utils/abi/decodeErrorResult.js +2 -2
  6. package/_cjs/utils/abi/decodeErrorResult.js.map +1 -1
  7. package/_cjs/utils/abi/decodeEventLog.js +2 -2
  8. package/_cjs/utils/abi/decodeEventLog.js.map +1 -1
  9. package/_cjs/utils/abi/decodeFunctionData.js +2 -2
  10. package/_cjs/utils/abi/decodeFunctionData.js.map +1 -1
  11. package/_cjs/utils/abi/encodeErrorResult.js +2 -2
  12. package/_cjs/utils/abi/encodeErrorResult.js.map +1 -1
  13. package/_cjs/utils/abi/encodeEventTopics.js +2 -2
  14. package/_cjs/utils/abi/encodeEventTopics.js.map +1 -1
  15. package/_cjs/utils/abi/encodeFunctionData.js +2 -2
  16. package/_cjs/utils/abi/encodeFunctionData.js.map +1 -1
  17. package/_cjs/utils/abi/getAbiItem.js +4 -4
  18. package/_cjs/utils/abi/getAbiItem.js.map +1 -1
  19. package/_cjs/utils/hash/hashSignature.js +11 -0
  20. package/_cjs/utils/hash/hashSignature.js.map +1 -0
  21. package/_cjs/utils/hash/toEventHash.js +6 -0
  22. package/_cjs/utils/hash/toEventHash.js.map +1 -0
  23. package/_cjs/utils/hash/toEventSelector.js +6 -0
  24. package/_cjs/utils/hash/toEventSelector.js.map +1 -0
  25. package/_cjs/utils/hash/toEventSignature.js +6 -0
  26. package/_cjs/utils/hash/toEventSignature.js.map +1 -0
  27. package/_cjs/utils/hash/toFunctionHash.js +6 -0
  28. package/_cjs/utils/hash/toFunctionHash.js.map +1 -0
  29. package/_cjs/utils/hash/toFunctionSelector.js +8 -0
  30. package/_cjs/utils/hash/toFunctionSelector.js.map +1 -0
  31. package/_cjs/utils/hash/toFunctionSignature.js +6 -0
  32. package/_cjs/utils/hash/toFunctionSignature.js.map +1 -0
  33. package/_cjs/utils/hash/toSignature.js +15 -0
  34. package/_cjs/utils/hash/toSignature.js.map +1 -0
  35. package/_cjs/utils/hash/toSignatureHash.js +10 -0
  36. package/_cjs/utils/hash/toSignatureHash.js.map +1 -0
  37. package/_cjs/utils/index.js +18 -6
  38. package/_cjs/utils/index.js.map +1 -1
  39. package/_esm/errors/version.js +1 -1
  40. package/_esm/index.js +14 -4
  41. package/_esm/index.js.map +1 -1
  42. package/_esm/utils/abi/decodeErrorResult.js +2 -2
  43. package/_esm/utils/abi/decodeErrorResult.js.map +1 -1
  44. package/_esm/utils/abi/decodeEventLog.js +2 -2
  45. package/_esm/utils/abi/decodeEventLog.js.map +1 -1
  46. package/_esm/utils/abi/decodeFunctionData.js +2 -2
  47. package/_esm/utils/abi/decodeFunctionData.js.map +1 -1
  48. package/_esm/utils/abi/encodeErrorResult.js +2 -2
  49. package/_esm/utils/abi/encodeErrorResult.js.map +1 -1
  50. package/_esm/utils/abi/encodeEventTopics.js +2 -2
  51. package/_esm/utils/abi/encodeEventTopics.js.map +1 -1
  52. package/_esm/utils/abi/encodeFunctionData.js +2 -2
  53. package/_esm/utils/abi/encodeFunctionData.js.map +1 -1
  54. package/_esm/utils/abi/getAbiItem.js +4 -4
  55. package/_esm/utils/abi/getAbiItem.js.map +1 -1
  56. package/_esm/utils/hash/hashSignature.js +7 -0
  57. package/_esm/utils/hash/hashSignature.js.map +1 -0
  58. package/_esm/utils/hash/toEventHash.js +2 -0
  59. package/_esm/utils/hash/toEventHash.js.map +1 -0
  60. package/_esm/utils/hash/toEventSelector.js +10 -0
  61. package/_esm/utils/hash/toEventSelector.js.map +1 -0
  62. package/_esm/utils/hash/toEventSignature.js +2 -0
  63. package/_esm/utils/hash/toEventSignature.js.map +1 -0
  64. package/_esm/utils/hash/toFunctionHash.js +2 -0
  65. package/_esm/utils/hash/toFunctionHash.js.map +1 -0
  66. package/_esm/utils/hash/toFunctionSelector.js +11 -0
  67. package/_esm/utils/hash/toFunctionSelector.js.map +1 -0
  68. package/_esm/utils/hash/toFunctionSignature.js +2 -0
  69. package/_esm/utils/hash/toFunctionSignature.js.map +1 -0
  70. package/_esm/utils/hash/toSignature.js +28 -0
  71. package/_esm/utils/hash/toSignature.js.map +1 -0
  72. package/_esm/utils/hash/toSignatureHash.js +9 -0
  73. package/_esm/utils/hash/toSignatureHash.js.map +1 -0
  74. package/_esm/utils/index.js +14 -2
  75. package/_esm/utils/index.js.map +1 -1
  76. package/_types/errors/version.d.ts +1 -1
  77. package/_types/index.d.ts +22 -4
  78. package/_types/index.d.ts.map +1 -1
  79. package/_types/utils/abi/decodeErrorResult.d.ts +2 -2
  80. package/_types/utils/abi/decodeErrorResult.d.ts.map +1 -1
  81. package/_types/utils/abi/decodeEventLog.d.ts +2 -2
  82. package/_types/utils/abi/decodeEventLog.d.ts.map +1 -1
  83. package/_types/utils/abi/decodeFunctionData.d.ts +2 -2
  84. package/_types/utils/abi/decodeFunctionData.d.ts.map +1 -1
  85. package/_types/utils/abi/encodeErrorResult.d.ts +2 -2
  86. package/_types/utils/abi/encodeErrorResult.d.ts.map +1 -1
  87. package/_types/utils/abi/encodeEventTopics.d.ts +2 -2
  88. package/_types/utils/abi/encodeEventTopics.d.ts.map +1 -1
  89. package/_types/utils/abi/encodeFunctionData.d.ts +2 -2
  90. package/_types/utils/abi/encodeFunctionData.d.ts.map +1 -1
  91. package/_types/utils/abi/getAbiItem.d.ts +2 -2
  92. package/_types/utils/abi/getAbiItem.d.ts.map +1 -1
  93. package/_types/utils/hash/hashSignature.d.ts +6 -0
  94. package/_types/utils/hash/hashSignature.d.ts.map +1 -0
  95. package/_types/utils/hash/toEventHash.d.ts +2 -0
  96. package/_types/utils/hash/toEventHash.d.ts.map +1 -0
  97. package/_types/utils/hash/toEventSelector.d.ts +12 -0
  98. package/_types/utils/hash/toEventSelector.d.ts.map +1 -0
  99. package/_types/utils/hash/toEventSignature.d.ts +2 -0
  100. package/_types/utils/hash/toEventSignature.d.ts.map +1 -0
  101. package/_types/utils/hash/toFunctionHash.d.ts +2 -0
  102. package/_types/utils/hash/toFunctionHash.d.ts.map +1 -0
  103. package/_types/utils/hash/toFunctionSelector.d.ts +14 -0
  104. package/_types/utils/hash/toFunctionSelector.d.ts.map +1 -0
  105. package/_types/utils/hash/toFunctionSignature.d.ts +2 -0
  106. package/_types/utils/hash/toFunctionSignature.d.ts.map +1 -0
  107. package/_types/utils/hash/toSignature.d.ts +23 -0
  108. package/_types/utils/hash/toSignature.d.ts.map +1 -0
  109. package/_types/utils/hash/toSignatureHash.d.ts +10 -0
  110. package/_types/utils/hash/toSignatureHash.d.ts.map +1 -0
  111. package/_types/utils/index.d.ts +22 -2
  112. package/_types/utils/index.d.ts.map +1 -1
  113. package/errors/version.ts +1 -1
  114. package/index.ts +39 -15
  115. package/package.json +1 -1
  116. package/utils/abi/decodeErrorResult.ts +5 -5
  117. package/utils/abi/decodeEventLog.ts +5 -5
  118. package/utils/abi/decodeFunctionData.ts +5 -5
  119. package/utils/abi/encodeErrorResult.ts +5 -5
  120. package/utils/abi/encodeEventTopics.ts +6 -6
  121. package/utils/abi/encodeFunctionData.ts +5 -5
  122. package/utils/abi/getAbiItem.ts +8 -8
  123. package/utils/hash/{getEventSelector.ts → hashSignature.ts} +5 -6
  124. package/utils/hash/toEventHash.ts +4 -0
  125. package/utils/hash/toEventSelector.ts +16 -0
  126. package/utils/hash/toEventSignature.ts +4 -0
  127. package/utils/hash/toFunctionHash.ts +4 -0
  128. package/utils/hash/toFunctionSelector.ts +23 -0
  129. package/utils/hash/toFunctionSignature.ts +4 -0
  130. package/utils/hash/toSignature.ts +34 -0
  131. package/utils/hash/toSignatureHash.ts +17 -0
  132. package/utils/index.ts +39 -7
  133. package/_cjs/utils/hash/getEventSelector.js +0 -10
  134. package/_cjs/utils/hash/getEventSelector.js.map +0 -1
  135. package/_cjs/utils/hash/getEventSignature.js +0 -9
  136. package/_cjs/utils/hash/getEventSignature.js.map +0 -1
  137. package/_cjs/utils/hash/getFunctionSelector.js +0 -11
  138. package/_cjs/utils/hash/getFunctionSelector.js.map +0 -1
  139. package/_cjs/utils/hash/getFunctionSignature.js +0 -15
  140. package/_cjs/utils/hash/getFunctionSignature.js.map +0 -1
  141. package/_cjs/utils/hash/hashFunction.js +0 -17
  142. package/_cjs/utils/hash/hashFunction.js.map +0 -1
  143. package/_esm/utils/hash/getEventSelector.js +0 -6
  144. package/_esm/utils/hash/getEventSelector.js.map +0 -1
  145. package/_esm/utils/hash/getEventSignature.js +0 -5
  146. package/_esm/utils/hash/getEventSignature.js.map +0 -1
  147. package/_esm/utils/hash/getFunctionSelector.js +0 -7
  148. package/_esm/utils/hash/getFunctionSelector.js.map +0 -1
  149. package/_esm/utils/hash/getFunctionSignature.js +0 -11
  150. package/_esm/utils/hash/getFunctionSignature.js.map +0 -1
  151. package/_esm/utils/hash/hashFunction.js +0 -12
  152. package/_esm/utils/hash/hashFunction.js.map +0 -1
  153. package/_types/utils/hash/getEventSelector.d.ts +0 -7
  154. package/_types/utils/hash/getEventSelector.d.ts.map +0 -1
  155. package/_types/utils/hash/getEventSignature.d.ts +0 -6
  156. package/_types/utils/hash/getEventSignature.d.ts.map +0 -1
  157. package/_types/utils/hash/getFunctionSelector.d.ts +0 -9
  158. package/_types/utils/hash/getFunctionSelector.d.ts.map +0 -1
  159. package/_types/utils/hash/getFunctionSignature.d.ts +0 -6
  160. package/_types/utils/hash/getFunctionSignature.d.ts.map +0 -1
  161. package/_types/utils/hash/hashFunction.d.ts +0 -11
  162. package/_types/utils/hash/hashFunction.d.ts.map +0 -1
  163. package/utils/hash/getEventSignature.ts +0 -15
  164. package/utils/hash/getFunctionSelector.ts +0 -22
  165. package/utils/hash/getFunctionSignature.ts +0 -19
  166. 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
- }