viem 2.9.26 → 2.9.28

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 (164) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/_cjs/actions/public/verifyHash.js +12 -3
  3. package/_cjs/actions/public/verifyHash.js.map +1 -1
  4. package/_cjs/actions/public/verifyMessage.js +2 -2
  5. package/_cjs/actions/public/verifyMessage.js.map +1 -1
  6. package/_cjs/actions/public/watchEvent.js +7 -5
  7. package/_cjs/actions/public/watchEvent.js.map +1 -1
  8. package/_cjs/chains/definitions/areonNetwork.js.map +1 -1
  9. package/_cjs/chains/definitions/areonNetworkTestnet.js.map +1 -1
  10. package/_cjs/chains/definitions/bxnTestnet.js +1 -0
  11. package/_cjs/chains/definitions/bxnTestnet.js.map +1 -1
  12. package/_cjs/chains/definitions/cyber.js +0 -1
  13. package/_cjs/chains/definitions/cyber.js.map +1 -1
  14. package/_cjs/chains/definitions/darwinia.js.map +1 -1
  15. package/_cjs/chains/definitions/immutableZkEvmTestnet.js.map +1 -1
  16. package/_cjs/chains/definitions/reyaNetwork.js.map +1 -1
  17. package/_cjs/chains/definitions/yooldoVerse.js +21 -0
  18. package/_cjs/chains/definitions/yooldoVerse.js.map +1 -0
  19. package/_cjs/chains/definitions/yooldoVerseTestnet.js +22 -0
  20. package/_cjs/chains/definitions/yooldoVerseTestnet.js.map +1 -0
  21. package/_cjs/chains/index.js +6 -2
  22. package/_cjs/chains/index.js.map +1 -1
  23. package/_cjs/errors/version.js +1 -1
  24. package/_cjs/experimental/eip5792/actions/sendCalls.js +2 -2
  25. package/_cjs/experimental/eip5792/actions/sendCalls.js.map +1 -1
  26. package/_cjs/utils/abi/parseEventLogs.js +4 -4
  27. package/_cjs/utils/abi/parseEventLogs.js.map +1 -1
  28. package/_cjs/utils/encoding/toRlp.js +2 -2
  29. package/_cjs/utils/encoding/toRlp.js.map +1 -1
  30. package/_cjs/utils/signature/hexToSignature.js +18 -3
  31. package/_cjs/utils/signature/hexToSignature.js.map +1 -1
  32. package/_cjs/utils/signature/recoverMessageAddress.js.map +1 -1
  33. package/_cjs/utils/signature/recoverPublicKey.js +22 -6
  34. package/_cjs/utils/signature/recoverPublicKey.js.map +1 -1
  35. package/_cjs/utils/signature/recoverTransactionAddress.js +1 -0
  36. package/_cjs/utils/signature/recoverTransactionAddress.js.map +1 -1
  37. package/_cjs/utils/signature/signatureToCompactSignature.js +4 -3
  38. package/_cjs/utils/signature/signatureToCompactSignature.js.map +1 -1
  39. package/_cjs/utils/signature/verifyMessage.js.map +1 -1
  40. package/_cjs/zksync/utils/assertEip712Request.js +2 -2
  41. package/_cjs/zksync/utils/assertEip712Request.js.map +1 -1
  42. package/_esm/actions/public/verifyHash.js +11 -2
  43. package/_esm/actions/public/verifyHash.js.map +1 -1
  44. package/_esm/actions/public/verifyMessage.js +1 -1
  45. package/_esm/actions/public/verifyMessage.js.map +1 -1
  46. package/_esm/actions/public/watchEvent.js +3 -1
  47. package/_esm/actions/public/watchEvent.js.map +1 -1
  48. package/_esm/celo/fees.js +0 -1
  49. package/_esm/celo/fees.js.map +1 -1
  50. package/_esm/chains/definitions/areonNetwork.js +1 -1
  51. package/_esm/chains/definitions/areonNetwork.js.map +1 -1
  52. package/_esm/chains/definitions/areonNetworkTestnet.js +1 -1
  53. package/_esm/chains/definitions/areonNetworkTestnet.js.map +1 -1
  54. package/_esm/chains/definitions/bxnTestnet.js +1 -0
  55. package/_esm/chains/definitions/bxnTestnet.js.map +1 -1
  56. package/_esm/chains/definitions/cyber.js +0 -1
  57. package/_esm/chains/definitions/cyber.js.map +1 -1
  58. package/_esm/chains/definitions/darwinia.js +1 -1
  59. package/_esm/chains/definitions/darwinia.js.map +1 -1
  60. package/_esm/chains/definitions/immutableZkEvmTestnet.js +1 -1
  61. package/_esm/chains/definitions/immutableZkEvmTestnet.js.map +1 -1
  62. package/_esm/chains/definitions/reyaNetwork.js +1 -1
  63. package/_esm/chains/definitions/reyaNetwork.js.map +1 -1
  64. package/_esm/chains/definitions/yooldoVerse.js +18 -0
  65. package/_esm/chains/definitions/yooldoVerse.js.map +1 -0
  66. package/_esm/chains/definitions/yooldoVerseTestnet.js +19 -0
  67. package/_esm/chains/definitions/yooldoVerseTestnet.js.map +1 -0
  68. package/_esm/chains/index.js +2 -0
  69. package/_esm/chains/index.js.map +1 -1
  70. package/_esm/errors/version.js +1 -1
  71. package/_esm/experimental/eip5792/actions/sendCalls.js +1 -1
  72. package/_esm/experimental/eip5792/actions/sendCalls.js.map +1 -1
  73. package/_esm/utils/abi/parseEventLogs.js +1 -1
  74. package/_esm/utils/abi/parseEventLogs.js.map +1 -1
  75. package/_esm/utils/encoding/toRlp.js +1 -1
  76. package/_esm/utils/encoding/toRlp.js.map +1 -1
  77. package/_esm/utils/signature/hexToSignature.js +18 -3
  78. package/_esm/utils/signature/hexToSignature.js.map +1 -1
  79. package/_esm/utils/signature/recoverMessageAddress.js.map +1 -1
  80. package/_esm/utils/signature/recoverPublicKey.js +25 -9
  81. package/_esm/utils/signature/recoverPublicKey.js.map +1 -1
  82. package/_esm/utils/signature/recoverTransactionAddress.js +1 -0
  83. package/_esm/utils/signature/recoverTransactionAddress.js.map +1 -1
  84. package/_esm/utils/signature/signatureToCompactSignature.js +2 -1
  85. package/_esm/utils/signature/signatureToCompactSignature.js.map +1 -1
  86. package/_esm/utils/signature/verifyMessage.js.map +1 -1
  87. package/_esm/zksync/utils/assertEip712Request.js +1 -1
  88. package/_esm/zksync/utils/assertEip712Request.js.map +1 -1
  89. package/_types/actions/public/verifyHash.d.ts +5 -5
  90. package/_types/actions/public/verifyHash.d.ts.map +1 -1
  91. package/_types/actions/public/verifyMessage.d.ts +2 -2
  92. package/_types/actions/public/verifyMessage.d.ts.map +1 -1
  93. package/_types/actions/public/verifyTypedData.d.ts +2 -2
  94. package/_types/actions/public/verifyTypedData.d.ts.map +1 -1
  95. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  96. package/_types/celo/fees.d.ts +1 -1
  97. package/_types/celo/fees.d.ts.map +1 -1
  98. package/_types/chains/definitions/bxnTestnet.d.ts +1 -1
  99. package/_types/chains/definitions/bxnTestnet.d.ts.map +1 -1
  100. package/_types/chains/definitions/cyber.d.ts +1 -1
  101. package/_types/chains/definitions/cyber.d.ts.map +1 -1
  102. package/_types/chains/definitions/yooldoVerse.d.ts +35 -0
  103. package/_types/chains/definitions/yooldoVerse.d.ts.map +1 -0
  104. package/_types/chains/definitions/yooldoVerseTestnet.d.ts +35 -0
  105. package/_types/chains/definitions/yooldoVerseTestnet.d.ts.map +1 -0
  106. package/_types/chains/index.d.ts +2 -0
  107. package/_types/chains/index.d.ts.map +1 -1
  108. package/_types/errors/version.d.ts +1 -1
  109. package/_types/experimental/eip3074/utils/recoverAuthMessageAddress.d.ts +2 -2
  110. package/_types/experimental/eip3074/utils/recoverAuthMessageAddress.d.ts.map +1 -1
  111. package/_types/utils/abi/parseEventLogs.d.ts +1 -1
  112. package/_types/utils/abi/parseEventLogs.d.ts.map +1 -1
  113. package/_types/utils/encoding/toRlp.d.ts.map +1 -1
  114. package/_types/utils/signature/hexToSignature.d.ts +5 -0
  115. package/_types/utils/signature/hexToSignature.d.ts.map +1 -1
  116. package/_types/utils/signature/recoverAddress.d.ts +2 -2
  117. package/_types/utils/signature/recoverAddress.d.ts.map +1 -1
  118. package/_types/utils/signature/recoverMessageAddress.d.ts +2 -2
  119. package/_types/utils/signature/recoverMessageAddress.d.ts.map +1 -1
  120. package/_types/utils/signature/recoverPublicKey.d.ts +2 -2
  121. package/_types/utils/signature/recoverPublicKey.d.ts.map +1 -1
  122. package/_types/utils/signature/recoverTransactionAddress.d.ts +2 -2
  123. package/_types/utils/signature/recoverTransactionAddress.d.ts.map +1 -1
  124. package/_types/utils/signature/recoverTypedDataAddress.d.ts +2 -2
  125. package/_types/utils/signature/recoverTypedDataAddress.d.ts.map +1 -1
  126. package/_types/utils/signature/signatureToCompactSignature.d.ts +2 -1
  127. package/_types/utils/signature/signatureToCompactSignature.d.ts.map +1 -1
  128. package/_types/utils/signature/verifyMessage.d.ts +2 -2
  129. package/_types/utils/signature/verifyMessage.d.ts.map +1 -1
  130. package/_types/utils/signature/verifyTypedData.d.ts +2 -2
  131. package/_types/utils/signature/verifyTypedData.d.ts.map +1 -1
  132. package/_types/zksync/utils/assertEip712Request.d.ts +1 -1
  133. package/_types/zksync/utils/assertEip712Request.d.ts.map +1 -1
  134. package/actions/public/verifyHash.ts +15 -7
  135. package/actions/public/verifyMessage.ts +8 -3
  136. package/actions/public/verifyTypedData.ts +2 -2
  137. package/actions/public/watchEvent.ts +6 -6
  138. package/celo/fees.ts +5 -5
  139. package/chains/definitions/areonNetwork.ts +1 -1
  140. package/chains/definitions/areonNetworkTestnet.ts +1 -1
  141. package/chains/definitions/bxnTestnet.ts +1 -0
  142. package/chains/definitions/cyber.ts +0 -1
  143. package/chains/definitions/darwinia.ts +1 -1
  144. package/chains/definitions/immutableZkEvmTestnet.ts +1 -1
  145. package/chains/definitions/reyaNetwork.ts +1 -1
  146. package/chains/definitions/yooldoVerse.ts +18 -0
  147. package/chains/definitions/yooldoVerseTestnet.ts +19 -0
  148. package/chains/index.ts +2 -0
  149. package/errors/version.ts +1 -1
  150. package/experimental/eip3074/utils/recoverAuthMessageAddress.ts +2 -2
  151. package/experimental/eip5792/actions/sendCalls.ts +1 -1
  152. package/package.json +1 -1
  153. package/utils/abi/parseEventLogs.ts +3 -3
  154. package/utils/encoding/toRlp.ts +1 -1
  155. package/utils/signature/hexToSignature.ts +16 -3
  156. package/utils/signature/recoverAddress.ts +2 -2
  157. package/utils/signature/recoverMessageAddress.ts +7 -2
  158. package/utils/signature/recoverPublicKey.ts +36 -13
  159. package/utils/signature/recoverTransactionAddress.ts +3 -2
  160. package/utils/signature/recoverTypedDataAddress.ts +2 -2
  161. package/utils/signature/signatureToCompactSignature.ts +2 -6
  162. package/utils/signature/verifyMessage.ts +7 -2
  163. package/utils/signature/verifyTypedData.ts +2 -2
  164. package/zksync/utils/assertEip712Request.ts +4 -1
@@ -1 +1 @@
1
- {"version":3,"file":"verifyTypedData.d.ts","sourceRoot":"","sources":["../../../utils/signature/verifyTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,8BAA8B,CAAA;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,KAAK,iCAAiC,EAEvC,MAAM,8BAA8B,CAAA;AAErC,MAAM,MAAM,yBAAyB,CACnC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjE,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,IACpE,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG;IAChD,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAA;IAChB,8BAA8B;IAC9B,SAAS,EAAE,GAAG,GAAG,SAAS,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAA;AAE/C,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,mBAAmB,GACnB,iCAAiC,GACjC,SAAS,CAAA;AAEb;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACnC,KAAK,CAAC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,EAEpD,UAAU,EAAE,yBAAyB,CAAC,SAAS,EAAE,WAAW,CAAC,GAC5D,OAAO,CAAC,yBAAyB,CAAC,CAapC"}
1
+ {"version":3,"file":"verifyTypedData.d.ts","sourceRoot":"","sources":["../../../utils/signature/verifyTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAE,KAAK,mBAAmB,EAAc,MAAM,0BAA0B,CAAA;AAC/E,OAAO,EACL,KAAK,uBAAuB,EAE7B,MAAM,8BAA8B,CAAA;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,KAAK,iCAAiC,EAEvC,MAAM,8BAA8B,CAAA;AAErC,MAAM,MAAM,yBAAyB,CACnC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EACjE,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,GAAG,MAAM,SAAS,IACpE,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,GAAG;IAChD,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAA;IAChB,8BAA8B;IAC9B,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,SAAS,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAA;AAE/C,MAAM,MAAM,wBAAwB,GAChC,uBAAuB,GACvB,mBAAmB,GACnB,iCAAiC,GACjC,SAAS,CAAA;AAEb;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CACnC,KAAK,CAAC,SAAS,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3D,WAAW,SAAS,MAAM,SAAS,GAAG,cAAc,EAEpD,UAAU,EAAE,yBAAyB,CAAC,SAAS,EAAE,WAAW,CAAC,GAC5D,OAAO,CAAC,yBAAyB,CAAC,CAapC"}
@@ -1,6 +1,6 @@
1
1
  import type { ErrorType } from '../../errors/utils.js';
2
- import { type AssertRequestErrorType } from '../../index.js';
3
2
  import type { ExactPartial } from '../../types/utils.js';
3
+ import { type AssertRequestErrorType } from '../../utils/transaction/assertRequest.js';
4
4
  import type { zkSync } from '../../zksync/chains.js';
5
5
  import type { SendTransactionParameters } from '../actions/sendTransaction.js';
6
6
  export type AssertEip712RequestParameters = ExactPartial<SendTransactionParameters<typeof zkSync>>;
@@ -1 +1 @@
1
- {"version":3,"file":"assertEip712Request.d.ts","sourceRoot":"","sources":["../../../zksync/utils/assertEip712Request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,KAAK,sBAAsB,EAAiB,MAAM,gBAAgB,CAAA;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAI9E,MAAM,MAAM,6BAA6B,GAAG,YAAY,CACtD,yBAAyB,CAAC,OAAO,MAAM,CAAC,CACzC,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,sBAAsB,GAAG,SAAS,CAAA;AAE7E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,6BAA6B,QAItE"}
1
+ {"version":3,"file":"assertEip712Request.d.ts","sourceRoot":"","sources":["../../../zksync/utils/assertEip712Request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EACL,KAAK,sBAAsB,EAE5B,MAAM,0CAA0C,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAI9E,MAAM,MAAM,6BAA6B,GAAG,YAAY,CACtD,yBAAyB,CAAC,OAAO,MAAM,CAAC,CACzC,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,sBAAsB,GAAG,SAAS,CAAA;AAE7E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,6BAA6B,QAItE"}
@@ -7,16 +7,19 @@ import { universalSignatureValidatorByteCode } from '../../constants/contracts.j
7
7
  import { CallExecutionError } from '../../errors/contract.js'
8
8
  import type { ErrorType } from '../../errors/utils.js'
9
9
  import type { Chain } from '../../types/chain.js'
10
- import type { ByteArray, Hex } from '../../types/misc.js'
11
- import type { EncodeDeployDataErrorType } from '../../utils/abi/encodeDeployData.js'
10
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
11
+ import {
12
+ type EncodeDeployDataErrorType,
13
+ encodeDeployData,
14
+ } from '../../utils/abi/encodeDeployData.js'
12
15
  import {
13
16
  type IsBytesEqualErrorType,
14
17
  isBytesEqual,
15
18
  } from '../../utils/data/isBytesEqual.js'
16
- import type { IsHexErrorType } from '../../utils/data/isHex.js'
17
- import type { ToHexErrorType } from '../../utils/encoding/toHex.js'
19
+ import { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'
20
+ import { type ToHexErrorType, bytesToHex } from '../../utils/encoding/toHex.js'
18
21
  import { getAction } from '../../utils/getAction.js'
19
- import { encodeDeployData, isHex, toHex } from '../../utils/index.js'
22
+ import { signatureToHex } from '../../utils/signature/signatureToHex.js'
20
23
  import { type CallErrorType, type CallParameters, call } from './call.js'
21
24
 
22
25
  export type VerifyHashParameters = Pick<
@@ -28,7 +31,7 @@ export type VerifyHashParameters = Pick<
28
31
  /** The hash to be verified. */
29
32
  hash: Hex
30
33
  /** The signature that was generated by signing the message with the address's private key. */
31
- signature: Hex | ByteArray
34
+ signature: Hex | ByteArray | Signature
32
35
  }
33
36
 
34
37
  export type VerifyHashReturnType = boolean
@@ -52,7 +55,12 @@ export async function verifyHash<TChain extends Chain | undefined>(
52
55
  client: Client<Transport, TChain>,
53
56
  { address, hash, signature, ...callRequest }: VerifyHashParameters,
54
57
  ): Promise<VerifyHashReturnType> {
55
- const signatureHex = isHex(signature) ? signature : toHex(signature)
58
+ const signatureHex = (() => {
59
+ if (isHex(signature)) return signature
60
+ if (typeof signature === 'object' && 'r' in signature && 's' in signature)
61
+ return signatureToHex(signature)
62
+ return bytesToHex(signature)
63
+ })()
56
64
 
57
65
  try {
58
66
  const { data } = await getAction(
@@ -4,8 +4,13 @@ import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
5
5
  import type { ErrorType } from '../../errors/utils.js'
6
6
  import type { Chain } from '../../types/chain.js'
7
- import type { ByteArray, Hex, SignableMessage } from '../../types/misc.js'
8
- import { hashMessage } from '../../utils/index.js'
7
+ import type {
8
+ ByteArray,
9
+ Hex,
10
+ SignableMessage,
11
+ Signature,
12
+ } from '../../types/misc.js'
13
+ import { hashMessage } from '../../utils/signature/hashMessage.js'
9
14
  import type { HashMessageErrorType } from '../../utils/signature/hashMessage.js'
10
15
  import {
11
16
  type VerifyHashErrorType,
@@ -19,7 +24,7 @@ export type VerifyMessageParameters = Omit<VerifyHashParameters, 'hash'> & {
19
24
  /** The message to be verified. */
20
25
  message: SignableMessage
21
26
  /** The signature that was generated by signing the message with the address's private key. */
22
- signature: Hex | ByteArray
27
+ signature: Hex | ByteArray | Signature
23
28
  }
24
29
 
25
30
  export type VerifyMessageReturnType = boolean
@@ -4,7 +4,7 @@ import type { Client } from '../../clients/createClient.js'
4
4
  import type { Transport } from '../../clients/transports/createTransport.js'
5
5
  import type { ErrorType } from '../../errors/utils.js'
6
6
  import type { Chain } from '../../types/chain.js'
7
- import type { ByteArray, Hex } from '../../types/misc.js'
7
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
8
8
  import type { TypedDataDefinition } from '../../types/typedData.js'
9
9
  import {
10
10
  type HashTypedDataErrorType,
@@ -24,7 +24,7 @@ export type VerifyTypedDataParameters<
24
24
  /** The address to verify the typed data for. */
25
25
  address: Address
26
26
  /** The signature to verify */
27
- signature: Hex | ByteArray
27
+ signature: Hex | ByteArray | Signature
28
28
  }
29
29
 
30
30
  export type VerifyTypedDataReturnType = boolean
@@ -11,7 +11,10 @@ import type { Filter } from '../../types/filter.js'
11
11
  import type { Log } from '../../types/log.js'
12
12
  import type { LogTopic } from '../../types/misc.js'
13
13
  import type { GetPollOptions } from '../../types/transport.js'
14
- import type { EncodeEventTopicsParameters } from '../../utils/index.js'
14
+ import {
15
+ type EncodeEventTopicsParameters,
16
+ encodeEventTopics,
17
+ } from '../../utils/abi/encodeEventTopics.js'
15
18
  import { type ObserveErrorType, observe } from '../../utils/observe.js'
16
19
  import { poll } from '../../utils/poll.js'
17
20
  import { type StringifyErrorType, stringify } from '../../utils/stringify.js'
@@ -23,12 +26,9 @@ import {
23
26
  import { InvalidInputRpcError } from '../../errors/rpc.js'
24
27
  import type { ErrorType } from '../../errors/utils.js'
25
28
  import type { BlockNumber } from '../../types/block.js'
29
+ import { decodeEventLog } from '../../utils/abi/decodeEventLog.js'
30
+ import { formatLog } from '../../utils/formatters/log.js'
26
31
  import { getAction } from '../../utils/getAction.js'
27
- import {
28
- decodeEventLog,
29
- encodeEventTopics,
30
- formatLog,
31
- } from '../../utils/index.js'
32
32
  import {
33
33
  type CreateEventFilterParameters,
34
34
  createEventFilter,
package/celo/fees.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { Client } from '../clients/createClient.js'
2
- import {
3
- type Address,
4
- type ChainEstimateFeesPerGasFnParameters,
5
- type ChainFees,
6
- type Hex,
2
+ import type {
3
+ Address,
4
+ ChainEstimateFeesPerGasFnParameters,
5
+ ChainFees,
6
+ Hex,
7
7
  } from '../index.js'
8
8
 
9
9
  import { formatters } from './formatters.js'
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const areonNetwork = defineChain({
3
+ export const areonNetwork = /*#__PURE__*/ defineChain({
4
4
  id: 463,
5
5
  name: 'Areon Network',
6
6
  nativeCurrency: { decimals: 18, name: 'AREA', symbol: 'AREA' },
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const areonNetworkTestnet = defineChain({
3
+ export const areonNetworkTestnet = /*#__PURE__*/ defineChain({
4
4
  id: 462,
5
5
  name: 'Areon Network Testnet',
6
6
  nativeCurrency: { decimals: 18, name: 'TAREA', symbol: 'TAREA' },
@@ -20,4 +20,5 @@ export const bxnTestnet = /*#__PURE__*/ defineChain({
20
20
  apiUrl: 'https://testnet-explorer.blackfort.network/api',
21
21
  },
22
22
  },
23
+ testnet: true,
23
24
  })
@@ -22,5 +22,4 @@ export const cyber = /*#__PURE__*/ defineChain({
22
22
  blockCreated: 43798,
23
23
  },
24
24
  },
25
- testnet: true,
26
25
  })
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const darwinia = defineChain({
3
+ export const darwinia = /*#__PURE__*/ defineChain({
4
4
  id: 46,
5
5
  name: 'Darwinia Network',
6
6
  nativeCurrency: {
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const immutableZkEvmTestnet = defineChain({
3
+ export const immutableZkEvmTestnet = /*#__PURE__*/ defineChain({
4
4
  id: 13473,
5
5
  name: 'Immutable zkEVM Testnet',
6
6
  nativeCurrency: {
@@ -1,6 +1,6 @@
1
1
  import { defineChain } from '../../utils/chain/defineChain.js'
2
2
 
3
- export const reyaNetwork = defineChain({
3
+ export const reyaNetwork = /*#__PURE__*/ defineChain({
4
4
  id: 1729,
5
5
  name: 'Reya Network',
6
6
  nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },
@@ -0,0 +1,18 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const yooldoVerse = /*#__PURE__*/ defineChain({
4
+ id: 50_005,
5
+ name: 'Yooldo Verse',
6
+ nativeCurrency: { name: 'OAS', symbol: 'OAS', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.yooldo-verse.xyz'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Yooldo Verse Explorer',
15
+ url: 'https://explorer.yooldo-verse.xyz',
16
+ },
17
+ },
18
+ })
@@ -0,0 +1,19 @@
1
+ import { defineChain } from '../../utils/chain/defineChain.js'
2
+
3
+ export const yooldoVerseTestnet = /*#__PURE__*/ defineChain({
4
+ id: 50_006,
5
+ name: 'Yooldo Verse Testnet',
6
+ nativeCurrency: { name: 'OAS', symbol: 'OAS', decimals: 18 },
7
+ rpcUrls: {
8
+ default: {
9
+ http: ['https://rpc.testnet.yooldo-verse.xyz'],
10
+ },
11
+ },
12
+ blockExplorers: {
13
+ default: {
14
+ name: 'Yooldo Verse Testnet Explorer',
15
+ url: 'https://explorer.testnet.yooldo-verse.xyz',
16
+ },
17
+ },
18
+ testnet: true,
19
+ })
package/chains/index.ts CHANGED
@@ -247,6 +247,8 @@ export {
247
247
  export { xLayer } from './definitions/xLayer.js'
248
248
  export { xdc } from './definitions/xdc.js'
249
249
  export { xdcTestnet } from './definitions/xdcTestnet.js'
250
+ export { yooldoVerse } from './definitions/yooldoVerse.js'
251
+ export { yooldoVerseTestnet } from './definitions/yooldoVerseTestnet.js'
250
252
  export { zetachain } from './definitions/zetachain.js'
251
253
  export { zetachainAthensTestnet } from './definitions/zetachainAthensTestnet.js'
252
254
  export { zhejiang } from './definitions/zhejiang.js'
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.9.26'
1
+ export const version = '2.9.28'
@@ -1,6 +1,6 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
- import type { ByteArray, Hex } from '../../../types/misc.js'
3
+ import type { ByteArray, Hex, Signature } from '../../../types/misc.js'
4
4
 
5
5
  import type { ErrorType } from '../../../errors/utils.js'
6
6
  import { keccak256 } from '../../../utils/hash/keccak256.js'
@@ -11,7 +11,7 @@ import {
11
11
  import { type ToAuthMessageParameters, toAuthMessage } from './toAuthMessage.js'
12
12
 
13
13
  export type RecoverAuthMessageAddressParameters = ToAuthMessageParameters & {
14
- signature: Hex | ByteArray
14
+ signature: Hex | ByteArray | Signature
15
15
  }
16
16
 
17
17
  export type RecoverAuthMessageAddressReturnType = Address
@@ -15,7 +15,7 @@ import type { OneOf } from '../../../types/utils.js'
15
15
  import { parseAccount } from '../../../utils/accounts.js'
16
16
  import type { RequestErrorType } from '../../../utils/buildRequest.js'
17
17
  import { numberToHex } from '../../../utils/encoding/toHex.js'
18
- import { getTransactionError } from '../../../utils/index.js'
18
+ import { getTransactionError } from '../../../utils/errors/getTransactionError.js'
19
19
 
20
20
  export type SendCallsParameters<
21
21
  chain extends Chain | undefined = Chain | undefined,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.9.26",
4
+ "version": "2.9.28",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -1,13 +1,13 @@
1
1
  import type { Abi } from 'abitype'
2
- import type { ErrorType } from '../../errors/utils.js'
3
2
  import {
4
3
  AbiEventSignatureNotFoundError,
5
4
  DecodeLogDataMismatch,
6
5
  DecodeLogTopicsMismatch,
7
- type RpcLog,
8
- } from '../../index.js'
6
+ } from '../../errors/abi.js'
7
+ import type { ErrorType } from '../../errors/utils.js'
9
8
  import type { ContractEventName } from '../../types/contract.js'
10
9
  import type { Log } from '../../types/log.js'
10
+ import type { RpcLog } from '../../types/rpc.js'
11
11
  import {
12
12
  type DecodeEventLogErrorType,
13
13
  decodeEventLog,
@@ -1,5 +1,5 @@
1
+ import { BaseError } from '../../errors/base.js'
1
2
  import type { ErrorType } from '../../errors/utils.js'
2
- import { BaseError } from '../../index.js'
3
3
  import type { ByteArray, Hex } from '../../types/misc.js'
4
4
  import {
5
5
  type CreateCursorErrorType,
@@ -21,11 +21,24 @@ export type HexToSignatureErrorType = NumberToHexErrorType | ErrorType
21
21
  */
22
22
  export function hexToSignature(signatureHex: Hex) {
23
23
  const { r, s } = secp256k1.Signature.fromCompact(signatureHex.slice(2, 130))
24
- const v = BigInt(`0x${signatureHex.slice(130)}`)
24
+ const yParityOrV = Number(`0x${signatureHex.slice(130)}`)
25
+ const [v, yParity] = (() => {
26
+ if (yParityOrV === 0 || yParityOrV === 1) return [undefined, yParityOrV]
27
+ if (yParityOrV === 27) return [BigInt(yParityOrV), 0]
28
+ if (yParityOrV === 28) return [BigInt(yParityOrV), 1]
29
+ throw new Error('Invalid yParityOrV value')
30
+ })()
31
+
32
+ if (typeof v !== 'undefined')
33
+ return {
34
+ r: numberToHex(r, { size: 32 }),
35
+ s: numberToHex(s, { size: 32 }),
36
+ v,
37
+ yParity,
38
+ } satisfies Signature
25
39
  return {
26
40
  r: numberToHex(r, { size: 32 }),
27
41
  s: numberToHex(s, { size: 32 }),
28
- v,
29
- yParity: v === 28n ? 1 : 0,
42
+ yParity,
30
43
  } satisfies Signature
31
44
  }
@@ -1,14 +1,14 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
3
  import { publicKeyToAddress } from '../../accounts/utils/publicKeyToAddress.js'
4
- import type { ByteArray, Hex } from '../../types/misc.js'
4
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
5
5
 
6
6
  import type { ErrorType } from '../../errors/utils.js'
7
7
  import { recoverPublicKey } from './recoverPublicKey.js'
8
8
 
9
9
  export type RecoverAddressParameters = {
10
10
  hash: Hex | ByteArray
11
- signature: Hex | ByteArray
11
+ signature: Hex | ByteArray | Signature
12
12
  }
13
13
 
14
14
  export type RecoverAddressReturnType = Address
@@ -1,6 +1,11 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
- import type { ByteArray, Hex, SignableMessage } from '../../types/misc.js'
3
+ import type {
4
+ ByteArray,
5
+ Hex,
6
+ SignableMessage,
7
+ Signature,
8
+ } from '../../types/misc.js'
4
9
 
5
10
  import type { ErrorType } from '../../errors/utils.js'
6
11
  import { type HashMessageErrorType, hashMessage } from './hashMessage.js'
@@ -11,7 +16,7 @@ import {
11
16
 
12
17
  export type RecoverMessageAddressParameters = {
13
18
  message: SignableMessage
14
- signature: Hex | ByteArray
19
+ signature: Hex | ByteArray | Signature
15
20
  }
16
21
 
17
22
  export type RecoverMessageAddressReturnType = Address
@@ -1,12 +1,16 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
- import type { ByteArray, Hex } from '../../types/misc.js'
2
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
3
3
  import { type IsHexErrorType, isHex } from '../data/isHex.js'
4
- import { type HexToNumberErrorType, hexToNumber } from '../encoding/fromHex.js'
4
+ import {
5
+ type HexToNumberErrorType,
6
+ hexToBigInt,
7
+ hexToNumber,
8
+ } from '../encoding/fromHex.js'
5
9
  import { toHex } from '../encoding/toHex.js'
6
10
 
7
11
  export type RecoverPublicKeyParameters = {
8
12
  hash: Hex | ByteArray
9
- signature: Hex | ByteArray
13
+ signature: Hex | ByteArray | Signature
10
14
  }
11
15
 
12
16
  export type RecoverPublicKeyReturnType = Hex
@@ -20,20 +24,39 @@ export async function recoverPublicKey({
20
24
  hash,
21
25
  signature,
22
26
  }: RecoverPublicKeyParameters): Promise<RecoverPublicKeyReturnType> {
23
- const signatureHex = isHex(signature) ? signature : toHex(signature)
24
27
  const hashHex = isHex(hash) ? hash : toHex(hash)
25
28
 
26
- // Derive v = recoveryId + 27 from end of the signature (27 is added when signing the message)
27
- // The recoveryId represents the y-coordinate on the secp256k1 elliptic curve and can have a value [0, 1].
28
- let v = hexToNumber(`0x${signatureHex.slice(130)}`)
29
- if (v === 0 || v === 1) v += 27
30
-
31
29
  const { secp256k1 } = await import('@noble/curves/secp256k1')
32
- const publicKey = secp256k1.Signature.fromCompact(
33
- signatureHex.substring(2, 130),
34
- )
35
- .addRecoveryBit(v - 27)
30
+ const signature_ = (() => {
31
+ // typeof signature: `Signature`
32
+ if (typeof signature === 'object' && 'r' in signature && 's' in signature) {
33
+ const { r, s, v, yParity } = signature
34
+ const yParityOrV = Number(yParity ?? v)!
35
+ const recoveryBit = toRecoveryBit(yParityOrV)
36
+ return new secp256k1.Signature(
37
+ hexToBigInt(r),
38
+ hexToBigInt(s),
39
+ ).addRecoveryBit(recoveryBit)
40
+ }
41
+
42
+ // typeof signature: `Hex | ByteArray`
43
+ const signatureHex = isHex(signature) ? signature : toHex(signature)
44
+ const yParityOrV = hexToNumber(`0x${signatureHex.slice(130)}`)
45
+ const recoveryBit = toRecoveryBit(yParityOrV)
46
+ return secp256k1.Signature.fromCompact(
47
+ signatureHex.substring(2, 130),
48
+ ).addRecoveryBit(recoveryBit)
49
+ })()
50
+
51
+ const publicKey = signature_
36
52
  .recoverPublicKey(hashHex.substring(2))
37
53
  .toHex(false)
38
54
  return `0x${publicKey}`
39
55
  }
56
+
57
+ function toRecoveryBit(yParityOrV: number) {
58
+ if (yParityOrV === 0 || yParityOrV === 1) return yParityOrV
59
+ if (yParityOrV === 27) return 0
60
+ if (yParityOrV === 28) return 1
61
+ throw new Error('Invalid yParityOrV value')
62
+ }
@@ -1,6 +1,6 @@
1
1
  import type { Address } from 'abitype'
2
2
  import type { ErrorType } from '../../errors/utils.js'
3
- import type { ByteArray, Hex } from '../../types/misc.js'
3
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
4
4
  import type { TransactionSerialized } from '../../types/transaction.js'
5
5
  import { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'
6
6
  import { parseTransaction } from '../transaction/parseTransaction.js'
@@ -19,7 +19,7 @@ import {
19
19
 
20
20
  export type RecoverTransactionAddressParameters = {
21
21
  serializedTransaction: TransactionSerialized
22
- signature?: Hex | ByteArray
22
+ signature?: Hex | ByteArray | Signature
23
23
  }
24
24
 
25
25
  export type RecoverTransactionAddressReturnType = Address
@@ -53,6 +53,7 @@ export async function recoverTransactionAddress(
53
53
  s: undefined,
54
54
  v: undefined,
55
55
  yParity: undefined,
56
+ sidecars: undefined,
56
57
  })
57
58
 
58
59
  return await recoverAddress({
@@ -1,6 +1,6 @@
1
1
  import type { Address, TypedData } from 'abitype'
2
2
 
3
- import type { ByteArray, Hex } from '../../types/misc.js'
3
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
4
4
  import type { TypedDataDefinition } from '../../types/typedData.js'
5
5
 
6
6
  import type { ErrorType } from '../../errors/utils.js'
@@ -14,7 +14,7 @@ export type RecoverTypedDataAddressParameters<
14
14
  typedData extends TypedData | Record<string, unknown> = TypedData,
15
15
  primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,
16
16
  > = TypedDataDefinition<typedData, primaryType> & {
17
- signature: Hex | ByteArray
17
+ signature: Hex | ByteArray | Signature
18
18
  }
19
19
 
20
20
  export type RecoverTypedDataAddressReturnType = Address
@@ -1,11 +1,7 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
2
  import type { CompactSignature, Signature } from '../../types/misc.js'
3
- import {
4
- type BytesToHexErrorType,
5
- type HexToBytesErrorType,
6
- bytesToHex,
7
- hexToBytes,
8
- } from '../index.js'
3
+ import { type HexToBytesErrorType, hexToBytes } from '../encoding/toBytes.js'
4
+ import { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'
9
5
 
10
6
  export type SignatureToCompactSignatureErrorType =
11
7
  | HexToBytesErrorType
@@ -1,6 +1,11 @@
1
1
  import type { Address } from 'abitype'
2
2
 
3
- import type { ByteArray, Hex, SignableMessage } from '../../types/misc.js'
3
+ import type {
4
+ ByteArray,
5
+ Hex,
6
+ SignableMessage,
7
+ Signature,
8
+ } from '../../types/misc.js'
4
9
  import { type GetAddressErrorType, getAddress } from '../address/getAddress.js'
5
10
  import {
6
11
  type IsAddressEqualErrorType,
@@ -19,7 +24,7 @@ export type VerifyMessageParameters = {
19
24
  /** The message to be verified. */
20
25
  message: SignableMessage
21
26
  /** The signature that was generated by signing the message with the address's private key. */
22
- signature: Hex | ByteArray
27
+ signature: Hex | ByteArray | Signature
23
28
  }
24
29
 
25
30
  export type VerifyMessageReturnType = boolean
@@ -1,6 +1,6 @@
1
1
  import type { Address, TypedData } from 'abitype'
2
2
 
3
- import type { ByteArray, Hex } from '../../types/misc.js'
3
+ import type { ByteArray, Hex, Signature } from '../../types/misc.js'
4
4
  import type { TypedDataDefinition } from '../../types/typedData.js'
5
5
  import { type GetAddressErrorType, getAddress } from '../address/getAddress.js'
6
6
  import {
@@ -21,7 +21,7 @@ export type VerifyTypedDataParameters<
21
21
  /** The address to verify the typed data for. */
22
22
  address: Address
23
23
  /** The signature to verify */
24
- signature: Hex | ByteArray
24
+ signature: Hex | ByteArray | Signature
25
25
  }
26
26
 
27
27
  export type VerifyTypedDataReturnType = boolean
@@ -1,6 +1,9 @@
1
1
  import type { ErrorType } from '../../errors/utils.js'
2
- import { type AssertRequestErrorType, assertRequest } from '../../index.js'
3
2
  import type { ExactPartial } from '../../types/utils.js'
3
+ import {
4
+ type AssertRequestErrorType,
5
+ assertRequest,
6
+ } from '../../utils/transaction/assertRequest.js'
4
7
  import type { zkSync } from '../../zksync/chains.js'
5
8
  import type { SendTransactionParameters } from '../actions/sendTransaction.js'
6
9
  import { InvalidEip712TransactionError } from '../errors/transaction.js'