viem 1.10.14 → 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.
Files changed (56) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/_cjs/chains/definitions/optimismSepolia.js +39 -0
  3. package/_cjs/chains/definitions/optimismSepolia.js.map +1 -0
  4. package/_cjs/chains/index.js +4 -2
  5. package/_cjs/chains/index.js.map +1 -1
  6. package/_cjs/index.js +5 -1
  7. package/_cjs/index.js.map +1 -1
  8. package/_cjs/utils/hash/getEventSelector.js +5 -6
  9. package/_cjs/utils/hash/getEventSelector.js.map +1 -1
  10. package/_cjs/utils/hash/getEventSignature.js +9 -0
  11. package/_cjs/utils/hash/getEventSignature.js.map +1 -0
  12. package/_cjs/utils/hash/getFunctionSelector.js +5 -6
  13. package/_cjs/utils/hash/getFunctionSelector.js.map +1 -1
  14. package/_cjs/utils/hash/getFunctionSignature.js +15 -0
  15. package/_cjs/utils/hash/getFunctionSignature.js.map +1 -0
  16. package/_cjs/utils/hash/hashFunction.js +2 -4
  17. package/_cjs/utils/hash/hashFunction.js.map +1 -1
  18. package/_esm/chains/definitions/optimismSepolia.js +36 -0
  19. package/_esm/chains/definitions/optimismSepolia.js.map +1 -0
  20. package/_esm/chains/index.js +1 -0
  21. package/_esm/chains/index.js.map +1 -1
  22. package/_esm/index.js +2 -0
  23. package/_esm/index.js.map +1 -1
  24. package/_esm/utils/hash/getEventSelector.js +5 -6
  25. package/_esm/utils/hash/getEventSelector.js.map +1 -1
  26. package/_esm/utils/hash/getEventSignature.js +5 -0
  27. package/_esm/utils/hash/getEventSignature.js.map +1 -0
  28. package/_esm/utils/hash/getFunctionSelector.js +5 -6
  29. package/_esm/utils/hash/getFunctionSelector.js.map +1 -1
  30. package/_esm/utils/hash/getFunctionSignature.js +11 -0
  31. package/_esm/utils/hash/getFunctionSignature.js.map +1 -0
  32. package/_esm/utils/hash/hashFunction.js +2 -4
  33. package/_esm/utils/hash/hashFunction.js.map +1 -1
  34. package/_types/chains/definitions/optimismSepolia.d.ts +331 -0
  35. package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -0
  36. package/_types/chains/index.d.ts +1 -0
  37. package/_types/chains/index.d.ts.map +1 -1
  38. package/_types/index.d.ts +2 -0
  39. package/_types/index.d.ts.map +1 -1
  40. package/_types/utils/hash/getEventSelector.d.ts +1 -2
  41. package/_types/utils/hash/getEventSelector.d.ts.map +1 -1
  42. package/_types/utils/hash/getEventSignature.d.ts +3 -0
  43. package/_types/utils/hash/getEventSignature.d.ts.map +1 -0
  44. package/_types/utils/hash/getFunctionSelector.d.ts.map +1 -1
  45. package/_types/utils/hash/getFunctionSignature.d.ts +3 -0
  46. package/_types/utils/hash/getFunctionSignature.d.ts.map +1 -0
  47. package/_types/utils/hash/hashFunction.d.ts.map +1 -1
  48. package/chains/definitions/optimismSepolia.ts +39 -0
  49. package/chains/index.ts +1 -0
  50. package/index.ts +2 -0
  51. package/package.json +1 -1
  52. package/utils/hash/getEventSelector.ts +7 -6
  53. package/utils/hash/getEventSignature.ts +7 -0
  54. package/utils/hash/getFunctionSelector.ts +7 -5
  55. package/utils/hash/getFunctionSignature.ts +17 -0
  56. package/utils/hash/hashFunction.ts +2 -7
@@ -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
- const name = extractFunctionName(def)
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) {