viem 2.0.0-beta.14 → 2.0.0-beta.16

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 (144) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +9 -3
  3. package/_cjs/actions/ens/getEnsName.js +4 -2
  4. package/_cjs/actions/ens/getEnsName.js.map +1 -1
  5. package/_cjs/actions/index.js +16 -2
  6. package/_cjs/actions/index.js.map +1 -1
  7. package/_cjs/chains/definitions/arbitrumSepolia.js +4 -0
  8. package/_cjs/chains/definitions/arbitrumSepolia.js.map +1 -1
  9. package/_cjs/chains/definitions/fantomSonicTestnet.js +26 -0
  10. package/_cjs/chains/definitions/fantomSonicTestnet.js.map +1 -0
  11. package/_cjs/chains/definitions/zilliqa.js +26 -0
  12. package/_cjs/chains/definitions/zilliqa.js.map +1 -0
  13. package/_cjs/chains/definitions/zilliqaTestnet.js +26 -0
  14. package/_cjs/chains/definitions/zilliqaTestnet.js.map +1 -0
  15. package/_cjs/chains/definitions/zkSyncSepoliaTestnet.js +35 -0
  16. package/_cjs/chains/definitions/zkSyncSepoliaTestnet.js.map +1 -0
  17. package/_cjs/chains/definitions/zkSyncTestnet.js +4 -0
  18. package/_cjs/chains/definitions/zkSyncTestnet.js.map +1 -1
  19. package/_cjs/chains/index.js +12 -4
  20. package/_cjs/chains/index.js.map +1 -1
  21. package/_cjs/chains/opStack/index.js +3 -3
  22. package/_cjs/chains/opStack/index.js.map +1 -1
  23. package/_cjs/chains/opStack/utils/getL2TransactionHash.js +2 -2
  24. package/_cjs/chains/opStack/utils/getL2TransactionHash.js.map +1 -1
  25. package/_cjs/chains/opStack/utils/{fromOpaqueData.js → opaqueDataToDepositData.js} +4 -4
  26. package/_cjs/chains/opStack/utils/opaqueDataToDepositData.js.map +1 -0
  27. package/_cjs/clients/transports/custom.js +8 -14
  28. package/_cjs/clients/transports/custom.js.map +1 -1
  29. package/_cjs/errors/abi.js +21 -1
  30. package/_cjs/errors/abi.js.map +1 -1
  31. package/_cjs/errors/version.js +1 -1
  32. package/_cjs/index.js +6 -2
  33. package/_cjs/index.js.map +1 -1
  34. package/_cjs/utils/abi/getAbiItem.js +46 -3
  35. package/_cjs/utils/abi/getAbiItem.js.map +1 -1
  36. package/_cjs/utils/hash/ripemd160.js +16 -0
  37. package/_cjs/utils/hash/ripemd160.js.map +1 -0
  38. package/_cjs/utils/hash/sha256.js +16 -0
  39. package/_cjs/utils/hash/sha256.js.map +1 -0
  40. package/_cjs/utils/index.js +5 -1
  41. package/_cjs/utils/index.js.map +1 -1
  42. package/_esm/actions/ens/getEnsName.js +4 -2
  43. package/_esm/actions/ens/getEnsName.js.map +1 -1
  44. package/_esm/actions/index.js +7 -0
  45. package/_esm/actions/index.js.map +1 -1
  46. package/_esm/chains/definitions/arbitrumSepolia.js +4 -0
  47. package/_esm/chains/definitions/arbitrumSepolia.js.map +1 -1
  48. package/_esm/chains/definitions/fantomSonicTestnet.js +23 -0
  49. package/_esm/chains/definitions/fantomSonicTestnet.js.map +1 -0
  50. package/_esm/chains/definitions/zilliqa.js +23 -0
  51. package/_esm/chains/definitions/zilliqa.js.map +1 -0
  52. package/_esm/chains/definitions/zilliqaTestnet.js +23 -0
  53. package/_esm/chains/definitions/zilliqaTestnet.js.map +1 -0
  54. package/_esm/chains/definitions/zkSyncSepoliaTestnet.js +32 -0
  55. package/_esm/chains/definitions/zkSyncSepoliaTestnet.js.map +1 -0
  56. package/_esm/chains/definitions/zkSyncTestnet.js +5 -0
  57. package/_esm/chains/definitions/zkSyncTestnet.js.map +1 -1
  58. package/_esm/chains/index.js +4 -0
  59. package/_esm/chains/index.js.map +1 -1
  60. package/_esm/chains/opStack/index.js +1 -1
  61. package/_esm/chains/opStack/index.js.map +1 -1
  62. package/_esm/chains/opStack/utils/getL2TransactionHash.js +2 -2
  63. package/_esm/chains/opStack/utils/getL2TransactionHash.js.map +1 -1
  64. package/_esm/chains/opStack/utils/{fromOpaqueData.js → opaqueDataToDepositData.js} +2 -2
  65. package/_esm/chains/opStack/utils/opaqueDataToDepositData.js.map +1 -0
  66. package/_esm/clients/transports/custom.js +8 -14
  67. package/_esm/clients/transports/custom.js.map +1 -1
  68. package/_esm/errors/abi.js +19 -0
  69. package/_esm/errors/abi.js.map +1 -1
  70. package/_esm/errors/version.js +1 -1
  71. package/_esm/index.js +2 -0
  72. package/_esm/index.js.map +1 -1
  73. package/_esm/utils/abi/getAbiItem.js +46 -2
  74. package/_esm/utils/abi/getAbiItem.js.map +1 -1
  75. package/_esm/utils/hash/ripemd160.js +12 -0
  76. package/_esm/utils/hash/ripemd160.js.map +1 -0
  77. package/_esm/utils/hash/sha256.js +12 -0
  78. package/_esm/utils/hash/sha256.js.map +1 -0
  79. package/_esm/utils/index.js +2 -0
  80. package/_esm/utils/index.js.map +1 -1
  81. package/_types/actions/ens/getEnsName.d.ts.map +1 -1
  82. package/_types/actions/index.d.ts +7 -0
  83. package/_types/actions/index.d.ts.map +1 -1
  84. package/_types/chains/definitions/arbitrumSepolia.d.ts +4 -0
  85. package/_types/chains/definitions/arbitrumSepolia.d.ts.map +1 -1
  86. package/_types/chains/definitions/fantomSonicTestnet.d.ts +38 -0
  87. package/_types/chains/definitions/fantomSonicTestnet.d.ts.map +1 -0
  88. package/_types/chains/definitions/zilliqa.d.ts +38 -0
  89. package/_types/chains/definitions/zilliqa.d.ts.map +1 -0
  90. package/_types/chains/definitions/zilliqaTestnet.d.ts +38 -0
  91. package/_types/chains/definitions/zilliqaTestnet.d.ts.map +1 -0
  92. package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts +533 -0
  93. package/_types/chains/definitions/zkSyncSepoliaTestnet.d.ts.map +1 -0
  94. package/_types/chains/definitions/zkSyncTestnet.d.ts +5 -0
  95. package/_types/chains/definitions/zkSyncTestnet.d.ts.map +1 -1
  96. package/_types/chains/index.d.ts +4 -0
  97. package/_types/chains/index.d.ts.map +1 -1
  98. package/_types/chains/opStack/index.d.ts +1 -1
  99. package/_types/chains/opStack/index.d.ts.map +1 -1
  100. package/_types/chains/opStack/utils/opaqueDataToDepositData.d.ts +15 -0
  101. package/_types/chains/opStack/utils/opaqueDataToDepositData.d.ts.map +1 -0
  102. package/_types/clients/transports/custom.d.ts +0 -2
  103. package/_types/clients/transports/custom.d.ts.map +1 -1
  104. package/_types/errors/abi.d.ts +14 -1
  105. package/_types/errors/abi.d.ts.map +1 -1
  106. package/_types/errors/version.d.ts +1 -1
  107. package/_types/index.d.ts +12 -0
  108. package/_types/index.d.ts.map +1 -1
  109. package/_types/types/eip1193.d.ts +12 -0
  110. package/_types/types/eip1193.d.ts.map +1 -1
  111. package/_types/utils/abi/getAbiItem.d.ts +2 -1
  112. package/_types/utils/abi/getAbiItem.d.ts.map +1 -1
  113. package/_types/utils/hash/ripemd160.d.ts +11 -0
  114. package/_types/utils/hash/ripemd160.d.ts.map +1 -0
  115. package/_types/utils/hash/sha256.d.ts +11 -0
  116. package/_types/utils/hash/sha256.d.ts.map +1 -0
  117. package/_types/utils/index.d.ts +2 -0
  118. package/_types/utils/index.d.ts.map +1 -1
  119. package/actions/ens/getEnsName.ts +3 -2
  120. package/actions/index.ts +31 -0
  121. package/chains/definitions/arbitrumSepolia.ts +4 -0
  122. package/chains/definitions/fantomSonicTestnet.ts +23 -0
  123. package/chains/definitions/zilliqa.ts +23 -0
  124. package/chains/definitions/zilliqaTestnet.ts +23 -0
  125. package/chains/definitions/zkSyncSepoliaTestnet.ts +32 -0
  126. package/chains/definitions/zkSyncTestnet.ts +5 -0
  127. package/chains/index.ts +4 -0
  128. package/chains/opStack/index.ts +5 -5
  129. package/chains/opStack/utils/getL2TransactionHash.ts +2 -2
  130. package/chains/opStack/utils/{fromOpaqueData.ts → opaqueDataToDepositData.ts} +9 -4
  131. package/clients/transports/custom.ts +3 -11
  132. package/errors/abi.ts +22 -1
  133. package/errors/version.ts +1 -1
  134. package/index.ts +31 -0
  135. package/package.json +1 -1
  136. package/types/eip1193.ts +12 -0
  137. package/utils/abi/getAbiItem.ts +71 -2
  138. package/utils/hash/ripemd160.ts +31 -0
  139. package/utils/hash/sha256.ts +31 -0
  140. package/utils/index.ts +2 -0
  141. package/_cjs/chains/opStack/utils/fromOpaqueData.js.map +0 -1
  142. package/_esm/chains/opStack/utils/fromOpaqueData.js.map +0 -1
  143. package/_types/chains/opStack/utils/fromOpaqueData.d.ts +0 -15
  144. package/_types/chains/opStack/utils/fromOpaqueData.d.ts.map +0 -1
@@ -0,0 +1,31 @@
1
+ import { sha256 as noble_sha256 } from '@noble/hashes/sha256'
2
+
3
+ import type { ErrorType } from '../../errors/utils.js'
4
+ import type { ByteArray, Hex } from '../../types/misc.js'
5
+ import { type IsHexErrorType, isHex } from '../data/isHex.js'
6
+ import { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'
7
+ import { type ToHexErrorType, toHex } from '../encoding/toHex.js'
8
+
9
+ type To = 'hex' | 'bytes'
10
+
11
+ export type Sha256Hash<TTo extends To> =
12
+ | (TTo extends 'bytes' ? ByteArray : never)
13
+ | (TTo extends 'hex' ? Hex : never)
14
+
15
+ export type Sha256ErrorType =
16
+ | IsHexErrorType
17
+ | ToBytesErrorType
18
+ | ToHexErrorType
19
+ | ErrorType
20
+
21
+ export function sha256<TTo extends To = 'hex'>(
22
+ value: Hex | ByteArray,
23
+ to_?: TTo,
24
+ ): Sha256Hash<TTo> {
25
+ const to = to_ || 'hex'
26
+ const bytes = noble_sha256(
27
+ isHex(value, { strict: false }) ? toBytes(value) : value,
28
+ )
29
+ if (to === 'bytes') return bytes as Sha256Hash<TTo>
30
+ return toHex(bytes) as Sha256Hash<TTo>
31
+ }
package/utils/index.ts CHANGED
@@ -351,6 +351,8 @@ export {
351
351
  } from './hash/getFunctionSelector.js'
352
352
  export { type IsHashErrorType, isHash } from './hash/isHash.js'
353
353
  export { type Keccak256ErrorType, keccak256 } from './hash/keccak256.js'
354
+ export { type Sha256ErrorType, sha256 } from './hash/sha256.js'
355
+ export { type Ripemd160ErrorType, ripemd160 } from './hash/ripemd160.js'
354
356
  export {
355
357
  type HashDomainErrorType,
356
358
  type HashTypedDataParameters,
@@ -1 +0,0 @@
1
- {"version":3,"file":"fromOpaqueData.js","sourceRoot":"","sources":["../../../../chains/opStack/utils/fromOpaqueData.ts"],"names":[],"mappings":";;;AAEA,yDAAsE;AACtE,2DAAyE;AACzE,mEAAgE;AAchE,SAAgB,cAAc,CAAC,UAAe;IAC5C,IAAI,MAAM,GAAG,CAAC,CAAA;IACd,MAAM,IAAI,GAAG,IAAA,gBAAK,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,CAAA;IACnD,MAAM,IAAI,EAAE,CAAA;IACZ,MAAM,KAAK,GAAG,IAAA,gBAAK,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,CAAA;IACpD,MAAM,IAAI,EAAE,CAAA;IACZ,MAAM,GAAG,GAAG,IAAA,gBAAK,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAA;IACjD,MAAM,IAAI,CAAC,CAAA;IACX,MAAM,UAAU,GAAG,MAAM,CAAC,IAAA,gBAAK,EAAC,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;IACvE,MAAM,IAAI,CAAC,CAAA;IACX,MAAM,IAAI,GACR,MAAM,GAAG,IAAA,cAAI,EAAC,UAAU,CAAC,GAAG,CAAC;QAC3B,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,IAAA,gBAAK,EAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;IAClD,OAAO;QACL,IAAI,EAAE,IAAA,wBAAW,EAAC,IAAI,CAAC;QACvB,KAAK,EAAE,IAAA,wBAAW,EAAC,KAAK,CAAC;QACzB,GAAG,EAAE,IAAA,wBAAW,EAAC,GAAG,CAAC;QACrB,UAAU;QACV,IAAI;KACL,CAAA;AACH,CAAC;AArBD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 @@
1
- import type { ErrorType } from '../../../errors/utils.js';
2
- import type { Hex } from '../../../types/misc.js';
3
- import { type SizeErrorType } from '../../../utils/data/size.js';
4
- import { type SliceErrorType } from '../../../utils/data/slice.js';
5
- export type FromOpaqueDataParameters = Hex;
6
- export type FromOpaqueDataReturnType = {
7
- mint: bigint;
8
- value: bigint;
9
- gas: bigint;
10
- isCreation: boolean;
11
- data: Hex;
12
- };
13
- export type FromOpaqueDataErrorType = SliceErrorType | SizeErrorType | ErrorType;
14
- export declare function fromOpaqueData(opaqueData: Hex): FromOpaqueDataReturnType;
15
- //# sourceMappingURL=fromOpaqueData.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fromOpaqueData.d.ts","sourceRoot":"","sources":["../../../../chains/opStack/utils/fromOpaqueData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,KAAK,aAAa,EAAQ,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,KAAK,cAAc,EAAS,MAAM,8BAA8B,CAAA;AAGzE,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAE1C,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,OAAO,CAAA;IACnB,IAAI,EAAE,GAAG,CAAA;CACV,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,cAAc,GAAG,aAAa,GAAG,SAAS,CAAA;AAEhF,wBAAgB,cAAc,CAAC,UAAU,EAAE,GAAG,GAAG,wBAAwB,CAqBxE"}