ox 1.8.15 → 1.8.18

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 (292) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/core/AbiError.d.ts +52 -6
  3. package/dist/core/AbiError.d.ts.map +1 -1
  4. package/dist/core/AbiError.js +60 -4
  5. package/dist/core/AbiError.js.map +1 -1
  6. package/dist/core/AbiEvent.d.ts +5 -3
  7. package/dist/core/AbiEvent.d.ts.map +1 -1
  8. package/dist/core/AbiEvent.js +89 -58
  9. package/dist/core/AbiEvent.js.map +1 -1
  10. package/dist/core/AbiFunction.d.ts +48 -2
  11. package/dist/core/AbiFunction.d.ts.map +1 -1
  12. package/dist/core/AbiFunction.js +59 -3
  13. package/dist/core/AbiFunction.js.map +1 -1
  14. package/dist/core/AbiItem.d.ts.map +1 -1
  15. package/dist/core/AbiItem.js +15 -5
  16. package/dist/core/AbiItem.js.map +1 -1
  17. package/dist/core/AbiParameters.d.ts +1 -1
  18. package/dist/core/AbiParameters.d.ts.map +1 -1
  19. package/dist/core/AbiParameters.js +8 -2
  20. package/dist/core/AbiParameters.js.map +1 -1
  21. package/dist/core/Address.d.ts +17 -2
  22. package/dist/core/Address.d.ts.map +1 -1
  23. package/dist/core/Address.js +17 -1
  24. package/dist/core/Address.js.map +1 -1
  25. package/dist/core/Authorization.d.ts +24 -2
  26. package/dist/core/Authorization.d.ts.map +1 -1
  27. package/dist/core/Authorization.js +29 -2
  28. package/dist/core/Authorization.js.map +1 -1
  29. package/dist/core/Base58.d.ts.map +1 -1
  30. package/dist/core/Base58.js +16 -4
  31. package/dist/core/Base58.js.map +1 -1
  32. package/dist/core/Blobs.d.ts +2 -3
  33. package/dist/core/Blobs.d.ts.map +1 -1
  34. package/dist/core/Blobs.js +38 -43
  35. package/dist/core/Blobs.js.map +1 -1
  36. package/dist/core/Bytes.d.ts.map +1 -1
  37. package/dist/core/Bytes.js +10 -2
  38. package/dist/core/Bytes.js.map +1 -1
  39. package/dist/core/Cbor.d.ts +13 -6
  40. package/dist/core/Cbor.d.ts.map +1 -1
  41. package/dist/core/Cbor.js +31 -18
  42. package/dist/core/Cbor.js.map +1 -1
  43. package/dist/core/Ens.js +2 -2
  44. package/dist/core/Ens.js.map +1 -1
  45. package/dist/core/FrameReceipt.d.ts.map +1 -1
  46. package/dist/core/FrameReceipt.js +4 -1
  47. package/dist/core/FrameReceipt.js.map +1 -1
  48. package/dist/core/Hex.d.ts.map +1 -1
  49. package/dist/core/Hex.js +34 -31
  50. package/dist/core/Hex.js.map +1 -1
  51. package/dist/core/Keystore.d.ts +31 -2
  52. package/dist/core/Keystore.d.ts.map +1 -1
  53. package/dist/core/Keystore.js +28 -2
  54. package/dist/core/Keystore.js.map +1 -1
  55. package/dist/core/Rlp.d.ts +1 -1
  56. package/dist/core/Rlp.d.ts.map +1 -1
  57. package/dist/core/Rlp.js +107 -0
  58. package/dist/core/Rlp.js.map +1 -1
  59. package/dist/core/RpcTransport.d.ts.map +1 -1
  60. package/dist/core/RpcTransport.js +3 -1
  61. package/dist/core/RpcTransport.js.map +1 -1
  62. package/dist/core/Secp256k1.d.ts.map +1 -1
  63. package/dist/core/Secp256k1.js +4 -1
  64. package/dist/core/Secp256k1.js.map +1 -1
  65. package/dist/core/Signature.d.ts +1 -1
  66. package/dist/core/Signature.d.ts.map +1 -1
  67. package/dist/core/Signature.js +4 -2
  68. package/dist/core/Signature.js.map +1 -1
  69. package/dist/core/Siwe.d.ts +4 -0
  70. package/dist/core/Siwe.d.ts.map +1 -1
  71. package/dist/core/Siwe.js +29 -3
  72. package/dist/core/Siwe.js.map +1 -1
  73. package/dist/core/Transaction.d.ts.map +1 -1
  74. package/dist/core/Transaction.js +4 -2
  75. package/dist/core/Transaction.js.map +1 -1
  76. package/dist/core/TransactionReceipt.d.ts.map +1 -1
  77. package/dist/core/TransactionReceipt.js +8 -2
  78. package/dist/core/TransactionReceipt.js.map +1 -1
  79. package/dist/core/TxEnvelopeEip1559.d.ts.map +1 -1
  80. package/dist/core/TxEnvelopeEip1559.js +2 -1
  81. package/dist/core/TxEnvelopeEip1559.js.map +1 -1
  82. package/dist/core/TxEnvelopeEip2930.d.ts.map +1 -1
  83. package/dist/core/TxEnvelopeEip2930.js +2 -1
  84. package/dist/core/TxEnvelopeEip2930.js.map +1 -1
  85. package/dist/core/TxEnvelopeEip7702.d.ts +1 -1
  86. package/dist/core/TxEnvelopeEip7702.d.ts.map +1 -1
  87. package/dist/core/TxEnvelopeEip7702.js +6 -1
  88. package/dist/core/TxEnvelopeEip7702.js.map +1 -1
  89. package/dist/core/TxEnvelopeLegacy.d.ts.map +1 -1
  90. package/dist/core/TxEnvelopeLegacy.js +49 -7
  91. package/dist/core/TxEnvelopeLegacy.js.map +1 -1
  92. package/dist/core/TypedData.d.ts +3 -1
  93. package/dist/core/TypedData.d.ts.map +1 -1
  94. package/dist/core/TypedData.js +23 -11
  95. package/dist/core/TypedData.js.map +1 -1
  96. package/dist/core/Value.d.ts.map +1 -1
  97. package/dist/core/Value.js +14 -3
  98. package/dist/core/Value.js.map +1 -1
  99. package/dist/core/internal/abiParameters.d.ts +3 -3
  100. package/dist/core/internal/abiParameters.d.ts.map +1 -1
  101. package/dist/core/internal/abiParameters.js +99 -69
  102. package/dist/core/internal/abiParameters.js.map +1 -1
  103. package/dist/core/internal/base58.d.ts.map +1 -1
  104. package/dist/core/internal/base58.js +9 -3
  105. package/dist/core/internal/base58.js.map +1 -1
  106. package/dist/core/internal/caches.d.ts +6 -0
  107. package/dist/core/internal/caches.d.ts.map +1 -1
  108. package/dist/core/internal/caches.js +3 -1
  109. package/dist/core/internal/caches.js.map +1 -1
  110. package/dist/core/internal/codec/hex.d.ts +13 -0
  111. package/dist/core/internal/codec/hex.d.ts.map +1 -1
  112. package/dist/core/internal/codec/hex.js +25 -2
  113. package/dist/core/internal/codec/hex.js.map +1 -1
  114. package/dist/core/internal/codec/int.d.ts.map +1 -1
  115. package/dist/core/internal/codec/int.js +48 -32
  116. package/dist/core/internal/codec/int.js.map +1 -1
  117. package/dist/core/internal/cursor.d.ts +24 -4
  118. package/dist/core/internal/cursor.d.ts.map +1 -1
  119. package/dist/core/internal/cursor.js +62 -11
  120. package/dist/core/internal/cursor.js.map +1 -1
  121. package/dist/core/internal/lru.d.ts +11 -12
  122. package/dist/core/internal/lru.d.ts.map +1 -1
  123. package/dist/core/internal/lru.js +22 -32
  124. package/dist/core/internal/lru.js.map +1 -1
  125. package/dist/core/internal/promise.d.ts.map +1 -1
  126. package/dist/core/internal/promise.js +13 -7
  127. package/dist/core/internal/promise.js.map +1 -1
  128. package/dist/erc4337/UserOperation.d.ts.map +1 -1
  129. package/dist/erc4337/UserOperation.js +1 -3
  130. package/dist/erc4337/UserOperation.js.map +1 -1
  131. package/dist/erc6492/SignatureErc6492.d.ts +1 -1
  132. package/dist/erc6492/SignatureErc6492.d.ts.map +1 -1
  133. package/dist/erc6492/SignatureErc6492.js +1 -1
  134. package/dist/erc6492/SignatureErc6492.js.map +1 -1
  135. package/dist/erc7821/Execute.d.ts +45 -0
  136. package/dist/erc7821/Execute.d.ts.map +1 -1
  137. package/dist/erc7821/Execute.js +70 -2
  138. package/dist/erc7821/Execute.js.map +1 -1
  139. package/dist/index.d.ts +1 -1
  140. package/dist/index.js +1 -1
  141. package/dist/tempo/KeyAuthorization.d.ts +9 -3
  142. package/dist/tempo/KeyAuthorization.d.ts.map +1 -1
  143. package/dist/tempo/KeyAuthorization.js +16 -0
  144. package/dist/tempo/KeyAuthorization.js.map +1 -1
  145. package/dist/tempo/SignatureEnvelope.d.ts +1 -1
  146. package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
  147. package/dist/tempo/SignatureEnvelope.js +53 -54
  148. package/dist/tempo/SignatureEnvelope.js.map +1 -1
  149. package/dist/tempo/TransactionReceipt.d.ts.map +1 -1
  150. package/dist/tempo/TransactionReceipt.js +4 -1
  151. package/dist/tempo/TransactionReceipt.js.map +1 -1
  152. package/dist/tempo/TransactionRequest.d.ts +1 -1
  153. package/dist/tempo/TransactionRequest.d.ts.map +1 -1
  154. package/dist/tempo/TransactionRequest.js +5 -2
  155. package/dist/tempo/TransactionRequest.js.map +1 -1
  156. package/dist/tempo/TxEnvelopeTempo.d.ts +30 -1
  157. package/dist/tempo/TxEnvelopeTempo.d.ts.map +1 -1
  158. package/dist/tempo/TxEnvelopeTempo.js +51 -2
  159. package/dist/tempo/TxEnvelopeTempo.js.map +1 -1
  160. package/dist/tempo/ZoneId.d.ts +3 -1
  161. package/dist/tempo/ZoneId.d.ts.map +1 -1
  162. package/dist/tempo/ZoneId.js +7 -1
  163. package/dist/tempo/ZoneId.js.map +1 -1
  164. package/dist/tempo/internal/virtualMasterPool.d.ts.map +1 -1
  165. package/dist/tempo/internal/virtualMasterPool.js +17 -6
  166. package/dist/tempo/internal/virtualMasterPool.js.map +1 -1
  167. package/dist/tempo/internal/webauthnData.d.ts +23 -0
  168. package/dist/tempo/internal/webauthnData.d.ts.map +1 -0
  169. package/dist/tempo/internal/webauthnData.js +75 -0
  170. package/dist/tempo/internal/webauthnData.js.map +1 -0
  171. package/dist/webauthn/Registration.d.ts +2 -0
  172. package/dist/webauthn/Registration.d.ts.map +1 -1
  173. package/dist/webauthn/Registration.js +2 -6
  174. package/dist/webauthn/Registration.js.map +1 -1
  175. package/dist/zod/TypedData.d.ts +4 -4
  176. package/dist/zod/tempo/KeyAuthorization.d.ts.map +1 -1
  177. package/dist/zod/tempo/KeyAuthorization.js +4 -2
  178. package/dist/zod/tempo/KeyAuthorization.js.map +1 -1
  179. package/dist/zod/tempo/SignatureEnvelope.d.ts.map +1 -1
  180. package/dist/zod/tempo/SignatureEnvelope.js +29 -29
  181. package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
  182. package/package.json +2 -2
  183. package/src/core/AbiError.ts +82 -8
  184. package/src/core/AbiEvent.bench.ts +45 -0
  185. package/src/core/AbiEvent.ts +120 -68
  186. package/src/core/AbiFunction.bench.ts +16 -0
  187. package/src/core/AbiFunction.ts +76 -4
  188. package/src/core/AbiItem.ts +13 -4
  189. package/src/core/AbiParameters.bench.ts +33 -0
  190. package/src/core/AbiParameters.ts +8 -1
  191. package/src/core/Address.ts +18 -1
  192. package/src/core/Authorization.ts +34 -4
  193. package/src/core/Base58.bench.ts +28 -0
  194. package/src/core/Base58.ts +15 -4
  195. package/src/core/Blobs.bench.ts +40 -0
  196. package/src/core/Blobs.ts +47 -55
  197. package/src/core/Bytes.bench.ts +34 -0
  198. package/src/core/Bytes.ts +10 -2
  199. package/src/core/Cbor.ts +36 -14
  200. package/src/core/Ens.ts +2 -2
  201. package/src/core/FrameReceipt.ts +4 -1
  202. package/src/core/Hex.bench.ts +17 -0
  203. package/src/core/Hex.ts +29 -32
  204. package/src/core/Keystore.ts +40 -3
  205. package/src/core/Rlp.ts +139 -1
  206. package/src/core/Rlp_tx.bench.ts +55 -0
  207. package/src/core/RpcTransport.ts +3 -1
  208. package/src/core/Secp256k1.ts +4 -1
  209. package/src/core/Signature.ts +7 -3
  210. package/src/core/Siwe.ts +29 -3
  211. package/src/core/Transaction.ts +4 -2
  212. package/src/core/TransactionReceipt.ts +8 -2
  213. package/src/core/TxEnvelopeEip1559.ts +4 -1
  214. package/src/core/TxEnvelopeEip2930.ts +4 -1
  215. package/src/core/TxEnvelopeEip7702.ts +9 -2
  216. package/src/core/TxEnvelopeLegacy.ts +58 -7
  217. package/src/core/TypedData.bench.ts +50 -0
  218. package/src/core/TypedData.ts +24 -11
  219. package/src/core/Value.ts +14 -3
  220. package/src/core/_test/AbiError.test.ts +105 -2
  221. package/src/core/_test/AbiEvent.fuzz.ts +1 -1
  222. package/src/core/_test/AbiEvent.test-d.ts +46 -0
  223. package/src/core/_test/AbiEvent.test.ts +646 -11
  224. package/src/core/_test/AbiFunction.test.ts +79 -6
  225. package/src/core/_test/AbiParameters.adversarial.fuzz.ts +1 -0
  226. package/src/core/_test/AbiParameters.decode.test.ts +143 -0
  227. package/src/core/_test/AbiParameters.encode.test.ts +36 -1
  228. package/src/core/_test/AbiParameters.test.ts +15 -0
  229. package/src/core/_test/Address.test.ts +41 -0
  230. package/src/core/_test/Authorization.test.ts +130 -0
  231. package/src/core/_test/Bytes.test.ts +33 -0
  232. package/src/core/_test/Caches.test.ts +20 -1
  233. package/src/core/_test/Cbor.test.ts +26 -0
  234. package/src/core/_test/FrameReceipt.test.ts +13 -0
  235. package/src/core/_test/Keystore.test.ts +65 -1
  236. package/src/core/_test/Rlp.fuzz.ts +55 -1
  237. package/src/core/_test/Rlp.test.ts +64 -0
  238. package/src/core/_test/RpcTransport.test.ts +15 -2
  239. package/src/core/_test/Secp256k1.test.ts +36 -0
  240. package/src/core/_test/Signature.test.ts +102 -0
  241. package/src/core/_test/Siwe.test.ts +123 -0
  242. package/src/core/_test/Transaction.test.ts +17 -0
  243. package/src/core/_test/TransactionEnvelopeEip1559.test.ts +28 -0
  244. package/src/core/_test/TransactionEnvelopeEip2930.test.ts +28 -0
  245. package/src/core/_test/TransactionEnvelopeEip7702.test.ts +133 -0
  246. package/src/core/_test/TransactionEnvelopeLegacy.test.ts +322 -1
  247. package/src/core/_test/TransactionReceipt.test.ts +41 -0
  248. package/src/core/_test/TypedData.test.ts +197 -0
  249. package/src/core/_test/Value.test.ts +21 -0
  250. package/src/core/_test/internal/cursor.test.ts +71 -0
  251. package/src/core/internal/abiParameters.ts +123 -81
  252. package/src/core/internal/base58.ts +9 -3
  253. package/src/core/internal/caches.ts +3 -1
  254. package/src/core/internal/codec/hex.ts +27 -2
  255. package/src/core/internal/codec/int.ts +45 -32
  256. package/src/core/internal/cursor.ts +84 -19
  257. package/src/core/internal/lru.ts +21 -35
  258. package/src/core/internal/promise.ts +11 -5
  259. package/src/erc4337/UserOperation.ts +3 -4
  260. package/src/erc4337/_test/UserOperation.test.ts +59 -1
  261. package/src/erc6492/SignatureErc6492.ts +1 -1
  262. package/src/erc6492/_test/SignatureErc6492.test.ts +48 -1
  263. package/src/erc7821/Execute.ts +83 -2
  264. package/src/erc7821/_test/Execute.test.ts +217 -1
  265. package/src/index.ts +1 -1
  266. package/src/tempo/KeyAuthorization.test.ts +91 -0
  267. package/src/tempo/KeyAuthorization.ts +32 -3
  268. package/src/tempo/SignatureEnvelope.test.ts +300 -28
  269. package/src/tempo/SignatureEnvelope.ts +62 -54
  270. package/src/tempo/TransactionReceipt.test.ts +8 -0
  271. package/src/tempo/TransactionReceipt.ts +4 -1
  272. package/src/tempo/TransactionRequest.test.ts +30 -0
  273. package/src/tempo/TransactionRequest.ts +7 -2
  274. package/src/tempo/TxEnvelopeTempo.test.ts +310 -0
  275. package/src/tempo/TxEnvelopeTempo.ts +64 -1
  276. package/src/tempo/VirtualMaster.bench.ts +7 -0
  277. package/src/tempo/ZoneId.test.ts +11 -0
  278. package/src/tempo/ZoneId.ts +7 -1
  279. package/src/tempo/configurableAccounts.e2e.test.ts +1 -1
  280. package/src/tempo/internal/virtualMasterPool.ts +20 -6
  281. package/src/tempo/internal/webauthnData.ts +84 -0
  282. package/src/version.ts +1 -1
  283. package/src/webauthn/Registration.ts +4 -6
  284. package/src/webauthn/_test/Registration.browser.test.ts +14 -0
  285. package/src/webauthn/_test/Registration.test.ts +60 -0
  286. package/src/zod/tempo/KeyAuthorization.ts +12 -5
  287. package/src/zod/tempo/SignatureEnvelope.ts +38 -32
  288. package/src/zod/tempo/_test/KeyAuthorization.test.ts +36 -0
  289. package/src/zod/tempo/_test/SignatureEnvelope.test.ts +138 -4
  290. package/src/core/_test/internal/lru.test.ts +0 -38
  291. package/src/core/_test/internal/uid.test.ts +0 -7
  292. package/src/core/internal/uid.ts +0 -15
@@ -72,7 +72,10 @@ export function assert(
72
72
  throw new MissingPropertiesError({ signature })
73
73
  if (typeof signature.s === 'undefined')
74
74
  throw new MissingPropertiesError({ signature })
75
- if (recovered && typeof signature.yParity === 'undefined')
75
+ if (
76
+ recovered &&
77
+ (signature.yParity === undefined || signature.yParity === null)
78
+ )
76
79
  throw new MissingPropertiesError({ signature })
77
80
  try {
78
81
  const r = BigInt(signature.r)
@@ -89,7 +92,7 @@ export function assert(
89
92
  throw new InvalidSError({ value: signature.s })
90
93
  }
91
94
  if (
92
- typeof signature.yParity === 'number' &&
95
+ signature.yParity !== undefined &&
93
96
  signature.yParity !== 0 &&
94
97
  signature.yParity !== 1
95
98
  )
@@ -867,6 +870,7 @@ export declare namespace toRpc {
867
870
  * @returns The {@link ox#Signature.Tuple}.
868
871
  */
869
872
  export function toTuple(signature: Signature): Tuple {
873
+ assert(signature, { recovered: true })
870
874
  const { r, s, yParity } = signature
871
875
 
872
876
  // RLP wants minimal-length big-endian; strip leading zero nibbles from the
@@ -875,7 +879,7 @@ export function toTuple(signature: Signature): Tuple {
875
879
  }
876
880
 
877
881
  export declare namespace toTuple {
878
- type ErrorType = Errors.GlobalErrorType
882
+ type ErrorType = assert.ErrorType | Errors.GlobalErrorType
879
883
  }
880
884
 
881
885
  /**
package/src/core/Siwe.ts CHANGED
@@ -23,6 +23,9 @@ export const prefixRegex =
23
23
  export const suffixRegex =
24
24
  /(?:URI: (?<uri>.+))\n(?:Version: (?<version>.+))\n(?:Chain ID: (?<chainId>\d+))\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\n(?:Issued At: (?<issuedAt>.+))(?:\nExpiration Time: (?<expirationTime>.+))?(?:\nNot Before: (?<notBefore>.+))?(?:\nRequest ID: (?<requestId>.*))?(?:\nResources:(?<resources>(?:\n- .+)*))?/
25
25
 
26
+ // Matches `suffixRegex` from the start of the input to its end.
27
+ const anchoredSuffixRegex = new RegExp(`^(?:${suffixRegex.source})$`)
28
+
26
29
  const siweDateTimeRegex =
27
30
  /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])[Tt]([01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:[Zz]|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/
28
31
 
@@ -245,6 +248,15 @@ export function createMessage(value: Message): string {
245
248
  `Provided value: ${statement}`,
246
249
  ],
247
250
  })
251
+ if (requestId && /[\n\r]/.test(requestId))
252
+ throw new InvalidMessageFieldError({
253
+ field: 'requestId',
254
+ metaMessages: [
255
+ "- Request ID must not include '\\n' or '\\r'.",
256
+ '',
257
+ `Provided value: ${requestId}`,
258
+ ],
259
+ })
248
260
  }
249
261
 
250
262
  // Construct message
@@ -394,6 +406,10 @@ function splitUri(value: string) {
394
406
  /**
395
407
  * [EIP-4361](https://eips.ethereum.org/EIPS/eip-4361) formatted message into message fields object.
396
408
  *
409
+ * The message can be the prefix (up to the statement), the suffix (from `URI`), or both.
410
+ * Returns an empty object when the message has any other text, such as fields that are
411
+ * out of order or text after the last field.
412
+ *
397
413
  * @example
398
414
  * ```ts twoslash
399
415
  * import { Siwe } from 'ox'
@@ -424,13 +440,23 @@ function splitUri(value: string) {
424
440
  * @returns Message fields object.
425
441
  */
426
442
  export function parseMessage(message: string): ExactPartial<Message> {
427
- const { scheme, statement, ...prefix } = (message.match(prefixRegex)
428
- ?.groups ?? {}) as {
443
+ const prefixMatch = message.match(prefixRegex)
444
+ const { scheme, statement, ...prefix } = (prefixMatch?.groups ?? {}) as {
429
445
  address: Address.Address
430
446
  domain: string
431
447
  scheme?: string
432
448
  statement?: string
433
449
  }
450
+ // The suffix starts where the prefix ends. Without a statement, the prefix
451
+ // is followed by one more line feed (as `createMessage` emits) or by none.
452
+ const rest = (() => {
453
+ const rest = message.slice(prefixMatch?.[0].length ?? 0)
454
+ if (prefixMatch && statement === undefined && rest.startsWith('\n'))
455
+ return rest.slice(1)
456
+ return rest
457
+ })()
458
+ const suffixMatch = rest.match(anchoredSuffixRegex)
459
+ if (rest && !suffixMatch) return {}
434
460
  const {
435
461
  chainId,
436
462
  expirationTime,
@@ -439,7 +465,7 @@ export function parseMessage(message: string): ExactPartial<Message> {
439
465
  requestId,
440
466
  resources: resources_,
441
467
  ...suffix
442
- } = (message.match(suffixRegex)?.groups ?? {}) as {
468
+ } = (suffixMatch?.groups ?? {}) as {
443
469
  chainId: string
444
470
  expirationTime?: string
445
471
  issuedAt?: string
@@ -407,9 +407,11 @@ export function fromRpc<
407
407
  transaction_.maxFeePerGas = BigInt(transaction.maxFeePerGas)
408
408
  if (transaction.maxPriorityFeePerGas)
409
409
  transaction_.maxPriorityFeePerGas = BigInt(transaction.maxPriorityFeePerGas)
410
+ // Own keys only: an inherited one such as `constructor` is not a type.
410
411
  if (transaction.type)
411
- transaction_.type =
412
- (fromRpcType as any)[transaction.type] ?? transaction.type
412
+ transaction_.type = Object.hasOwn(fromRpcType, transaction.type)
413
+ ? fromRpcType[transaction.type as keyof typeof fromRpcType]
414
+ : transaction.type
413
415
  if (signature)
414
416
  transaction_.v =
415
417
  transaction.type === '0x0' && typeof transaction.v !== 'undefined'
@@ -266,9 +266,15 @@ export function fromRpc<const receipt extends Rpc | null>(
266
266
  effectiveGasPrice: BigInt(receipt.effectiveGasPrice ?? 0n),
267
267
  gasUsed: BigInt(receipt.gasUsed ?? 0n),
268
268
  logs: receipt.logs.map((log) => Log.fromRpc(log, { pending: false })),
269
- status: fromRpcStatus[receipt.status],
269
+ // Own keys only: an inherited one such as `__proto__` or `toString` is
270
+ // not a status or type.
271
+ status: Object.hasOwn(fromRpcStatus, receipt.status)
272
+ ? fromRpcStatus[receipt.status]
273
+ : undefined,
270
274
  transactionIndex: Number(receipt.transactionIndex ?? 0),
271
- type: (fromRpcType as any)[receipt.type] || receipt.type,
275
+ type: Object.hasOwn(fromRpcType, receipt.type)
276
+ ? fromRpcType[receipt.type as keyof typeof fromRpcType]
277
+ : receipt.type,
272
278
  } as never
273
279
  }
274
280
 
@@ -71,7 +71,10 @@ export type Type = typeof type
71
71
  */
72
72
  export function assert(envelope: PartialBy<TxEnvelopeEip1559, 'type'>) {
73
73
  const { chainId, maxPriorityFeePerGas, maxFeePerGas, to } = envelope
74
- if (chainId <= 0)
74
+ if (
75
+ typeof chainId !== 'undefined' &&
76
+ (!Number.isSafeInteger(chainId) || chainId <= 0)
77
+ )
75
78
  throw new TransactionEnvelope.InvalidChainIdError({ chainId })
76
79
  if (to) Address.assert(to, { strict: false })
77
80
  if (maxFeePerGas && BigInt(maxFeePerGas) > 2n ** 256n - 1n)
@@ -69,7 +69,10 @@ export type Type = typeof type
69
69
  */
70
70
  export function assert(envelope: PartialBy<TxEnvelopeEip2930, 'type'>) {
71
71
  const { chainId, gasPrice, to } = envelope
72
- if (chainId <= 0)
72
+ if (
73
+ typeof chainId !== 'undefined' &&
74
+ (!Number.isSafeInteger(chainId) || chainId <= 0)
75
+ )
73
76
  throw new TransactionEnvelope.InvalidChainIdError({ chainId })
74
77
  if (to) Address.assert(to, { strict: false })
75
78
  if (gasPrice && BigInt(gasPrice) > 2n ** 256n - 1n)
@@ -197,10 +197,17 @@ export function deserialize(
197
197
  )
198
198
  // Authorization list is preserved even when empty for round-trip parity
199
199
  // with the legacy `authorizationList !== '0x'` hex check.
200
- if (Array.isArray(authorizationList))
200
+ if (Array.isArray(authorizationList)) {
201
+ // A transaction holds signed authorizations only.
202
+ for (const tuple of authorizationList)
203
+ if (!Array.isArray(tuple) || tuple.length !== 6)
204
+ throw new Authorization.InvalidError(
205
+ 'Expected [chainId, address, nonce, yParity, r, s].',
206
+ )
201
207
  transaction.authorizationList = Authorization.fromTupleList(
202
208
  Tx.bytesTreeToHex(authorizationList as never) as never,
203
209
  )
210
+ }
204
211
 
205
212
  const signature =
206
213
  r && s && yParity
@@ -222,7 +229,7 @@ export function deserialize(
222
229
  }
223
230
 
224
231
  export declare namespace deserialize {
225
- type ErrorType = Errors.GlobalErrorType
232
+ type ErrorType = Authorization.InvalidError | Errors.GlobalErrorType
226
233
  }
227
234
 
228
235
  /**
@@ -68,7 +68,10 @@ export type Type = typeof type
68
68
  export function assert(envelope: PartialBy<TxEnvelopeLegacy, 'type'>) {
69
69
  const { chainId, gasPrice, to } = envelope
70
70
  if (to) Address.assert(to, { strict: false })
71
- if (typeof chainId !== 'undefined' && chainId <= 0)
71
+ if (
72
+ typeof chainId !== 'undefined' &&
73
+ (!Number.isSafeInteger(chainId) || chainId <= 0)
74
+ )
72
75
  throw new TransactionEnvelope.InvalidChainIdError({ chainId })
73
76
  if (gasPrice && BigInt(gasPrice) > 2n ** 256n - 1n)
74
77
  throw new TransactionEnvelope.GasPriceTooHighError({ gasPrice })
@@ -111,7 +114,12 @@ export function deserialize(serialized: Hex.Hex): Compute<TxEnvelopeLegacy> {
111
114
  const [nonce, gasPrice, gas, to, value, data, chainIdOrV_, r, s] =
112
115
  tuple as readonly Bytes.Bytes[]
113
116
 
114
- if (!(tuple.length === 6 || tuple.length === 9))
117
+ if (
118
+ !Array.isArray(tuple) ||
119
+ !(tuple.length === 6 || tuple.length === 9) ||
120
+ // Every field is a byte string, never a nested list.
121
+ tuple.some((item) => !(item instanceof Uint8Array))
122
+ )
115
123
  throw new TransactionEnvelope.InvalidSerializedError({
116
124
  attributes: {
117
125
  nonce,
@@ -144,18 +152,46 @@ export function deserialize(serialized: Hex.Hex): Compute<TxEnvelopeLegacy> {
144
152
  if (nonce !== undefined) transaction.nonce = Tx.bytesToBigIntOrZero(nonce)
145
153
  const value_ = Tx.bytesToBigIntOrUndefined(value)
146
154
  if (value_ !== undefined) transaction.value = value_
155
+ // `gasPrice`, `r` and `s` are bounded by byte length, so that an oversized
156
+ // value is rejected before it is converted.
157
+ if ((gasPrice as Bytes.Bytes).length > 32)
158
+ throw new TransactionEnvelope.GasPriceTooHighError()
147
159
  const gasPrice_ = Tx.bytesToBigIntOrUndefined(gasPrice)
148
160
  if (gasPrice_ !== undefined) transaction.gasPrice = gasPrice_
149
161
 
150
- if (tuple.length === 6) return transaction
162
+ if (tuple.length === 6) {
163
+ assert(transaction)
164
+ return transaction
165
+ }
151
166
 
152
- const chainIdOrV = Tx.bytesToNumberOrUndefined(chainIdOrV_) ?? 0
167
+ // `chainId` and `yParity` are derived from `v` as a number, so `v` must be a
168
+ // safe integer (which fits in 7 bytes).
169
+ const chainIdOrV =
170
+ (chainIdOrV_ as Bytes.Bytes).length > 7
171
+ ? Number.NaN
172
+ : (Tx.bytesToNumberOrUndefined(chainIdOrV_) ?? 0)
173
+ if (!Number.isSafeInteger(chainIdOrV))
174
+ throw new TransactionEnvelope.InvalidSerializedError({
175
+ attributes: {},
176
+ serialized,
177
+ type,
178
+ })
153
179
 
154
180
  if ((s as Bytes.Bytes).length === 0 && (r as Bytes.Bytes).length === 0) {
155
181
  if (chainIdOrV > 0) transaction.chainId = Number(chainIdOrV)
182
+ assert(transaction)
156
183
  return transaction
157
184
  }
158
185
 
186
+ if ((r as Bytes.Bytes).length > 32)
187
+ throw new Signature.InvalidRError({
188
+ value: Tx.bytesToHex(r as Bytes.Bytes),
189
+ })
190
+ if ((s as Bytes.Bytes).length > 32)
191
+ throw new Signature.InvalidSError({
192
+ value: Tx.bytesToHex(s as Bytes.Bytes),
193
+ })
194
+
159
195
  const v = chainIdOrV
160
196
  const chainId: number | undefined = Math.floor((v - 35) / 2)
161
197
  if (chainId > 0) transaction.chainId = chainId
@@ -393,11 +429,18 @@ export function hash<presign extends boolean = false>(
393
429
  options: hash.Options<presign> = {},
394
430
  ): hash.ReturnType {
395
431
  const { presign } = options
432
+ const { chainId, v } = envelope
396
433
  return Hash.keccak256(
397
434
  serialize({
398
435
  ...envelope,
399
436
  ...(presign
400
437
  ? {
438
+ // An EIP-155 `v` carries the chain ID when `chainId` is absent.
439
+ chainId:
440
+ chainId ??
441
+ (typeof v === 'number' && v >= 37
442
+ ? Math.floor((v - 35) / 2)
443
+ : undefined),
401
444
  r: undefined,
402
445
  s: undefined,
403
446
  yParity: undefined,
@@ -509,6 +552,17 @@ export function serialize(
509
552
 
510
553
  if (signature) {
511
554
  const v = (() => {
555
+ // EIP-155 (explicit chainId)
556
+ if (chainId > 0) {
557
+ if (signature.v >= 35) {
558
+ // `v` must encode the same chain as `chainId`.
559
+ if (Math.floor((signature.v - 35) / 2) !== chainId)
560
+ throw new TransactionEnvelope.InvalidChainIdError({ chainId })
561
+ return signature.v
562
+ }
563
+ return chainId * 2 + 35 + Signature.vToYParity(signature.v)
564
+ }
565
+
512
566
  // EIP-155 (inferred chainId)
513
567
  if (signature.v >= 35) {
514
568
  const inferredChainId = Math.floor((signature.v - 35) / 2)
@@ -516,9 +570,6 @@ export function serialize(
516
570
  return 27 + (signature.v === 35 ? 0 : 1)
517
571
  }
518
572
 
519
- // EIP-155 (explicit chainId)
520
- if (chainId > 0) return chainId * 2 + 35 + signature.v - 27
521
-
522
573
  // Pre-EIP-155 (no chainId)
523
574
  const v = 27 + (signature.v === 27 ? 0 : 1)
524
575
  if (signature.v !== v)
@@ -0,0 +1,50 @@
1
+ import { bench, describe } from 'vp/test'
2
+ import * as TypedData from './TypedData.js'
3
+
4
+ const typedData = {
5
+ domain: {
6
+ chainId: 1,
7
+ name: 'Ether Mail',
8
+ verifyingContract: '0x0000000000000000000000000000000000000000',
9
+ version: '1',
10
+ },
11
+ message: {
12
+ contents: 'Hello, Bob!',
13
+ from: {
14
+ name: 'Cow',
15
+ wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
16
+ },
17
+ to: {
18
+ name: 'Bob',
19
+ wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
20
+ },
21
+ },
22
+ primaryType: 'Mail',
23
+ types: {
24
+ Mail: [
25
+ { name: 'from', type: 'Person' },
26
+ { name: 'to', type: 'Person' },
27
+ { name: 'contents', type: 'string' },
28
+ ],
29
+ Person: [
30
+ { name: 'name', type: 'string' },
31
+ { name: 'wallet', type: 'address' },
32
+ ],
33
+ },
34
+ } as const
35
+
36
+ describe('TypedData.getSignPayload', () => {
37
+ bench('Mail', () => {
38
+ TypedData.getSignPayload(typedData)
39
+ })
40
+ })
41
+
42
+ describe('TypedData.hashStruct', () => {
43
+ bench('Person', () => {
44
+ TypedData.hashStruct({
45
+ data: typedData.message.from,
46
+ primaryType: 'Person',
47
+ types: typedData.types,
48
+ })
49
+ })
50
+ })
@@ -5,6 +5,7 @@ import * as Bytes from './Bytes.js'
5
5
  import * as Errors from './Errors.js'
6
6
  import * as Hash from './Hash.js'
7
7
  import * as Hex from './Hex.js'
8
+ import { caches } from './internal/caches.js'
8
9
  import type { Compute } from './internal/types.js'
9
10
  import * as Json from './Json.js'
10
11
  import * as Solidity from './Solidity.js'
@@ -160,6 +161,8 @@ export function assert<
160
161
  expectedSize: Number.parseInt(size, 10),
161
162
  givenSize: Hex.size(value as Hex.Hex),
162
163
  })
164
+ if (size && (value as Hex.Hex).length % 2 !== 0)
165
+ throw new Hex.InvalidLengthError(value as Hex.Hex)
163
166
  }
164
167
 
165
168
  if (Object.hasOwn(types, type))
@@ -209,6 +212,7 @@ export declare namespace assert {
209
212
  | InvalidPrimaryTypeError
210
213
  | InvalidStructTypeError
211
214
  | InvalidTypeError
215
+ | Hex.InvalidLengthError
212
216
  | Hex.fromNumber.ErrorType
213
217
  | Hex.size.ErrorType
214
218
  | Errors.GlobalErrorType
@@ -407,6 +411,8 @@ export declare namespace encodeType {
407
411
  /**
408
412
  * Gets [EIP-712 Typed Data](https://eips.ethereum.org/EIPS/eip-712) schema for EIP-721 domain.
409
413
  *
414
+ * A field is part of the schema when it is present on the domain (not `undefined` or `null`).
415
+ *
410
416
  * @example
411
417
  * ```ts twoslash
412
418
  * import { TypedData } from 'ox'
@@ -433,18 +439,14 @@ export function extractEip712DomainTypes(
433
439
  domain: Domain | undefined,
434
440
  ): Parameter[] {
435
441
  return [
436
- typeof domain?.name === 'string' && { name: 'name', type: 'string' },
437
- typeof domain?.version === 'string' && { name: 'version', type: 'string' },
438
- (typeof domain?.chainId === 'number' ||
439
- typeof domain?.chainId === 'bigint') && {
440
- name: 'chainId',
441
- type: 'uint256',
442
- },
443
- domain?.verifyingContract && {
442
+ domain?.name != null && { name: 'name', type: 'string' },
443
+ domain?.version != null && { name: 'version', type: 'string' },
444
+ domain?.chainId != null && { name: 'chainId', type: 'uint256' },
445
+ domain?.verifyingContract != null && {
444
446
  name: 'verifyingContract',
445
447
  type: 'address',
446
448
  },
447
- domain?.salt && { name: 'salt', type: 'bytes32' },
449
+ domain?.salt != null && { name: 'salt', type: 'bytes32' },
448
450
  ].filter(Boolean) as Parameter[]
449
451
  }
450
452
 
@@ -913,6 +915,9 @@ export declare namespace encodeData {
913
915
  | Errors.GlobalErrorType
914
916
  }
915
917
 
918
+ /** Longest encoded type, in characters, whose hash is kept in the cache. */
919
+ const maxCachedTypeLength = 4_096
920
+
916
921
  /** @internal */
917
922
  export function hashType(value: {
918
923
  primaryType: string
@@ -922,8 +927,16 @@ export function hashType(value: {
922
927
  const { primaryType, types, typeHashes } = value
923
928
  const cached = typeHashes?.get(primaryType)
924
929
  if (cached) return cached
925
- const encodedHashType = Hex.fromString(encodeType({ primaryType, types }))
926
- const hash = Hash.keccak256(encodedHashType)
930
+ // Keyed by the encoded type, so equal struct definitions share one hash
931
+ // across calls, whichever object their types came from.
932
+ const type = encodeType({ primaryType, types })
933
+ let hash = caches.typeHash.get(type)
934
+ if (!hash) {
935
+ hash = Hash.keccak256(Hex.fromString(type))
936
+ // Only short encoded types are cached, so the cache's memory is bounded
937
+ // by its entry count rather than by the size of the types it was given.
938
+ if (type.length <= maxCachedTypeLength) caches.typeHash.set(type, hash)
939
+ }
927
940
  typeHashes?.set(primaryType, hash)
928
941
  return hash
929
942
  }
package/src/core/Value.ts CHANGED
@@ -10,7 +10,6 @@ export const exponents = {
10
10
  } as const
11
11
 
12
12
  const decimalNumberRegex = /^-?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)$/
13
- const trailingZerosRegex = /(0+)$/
14
13
 
15
14
  /**
16
15
  * Formats a `bigint` Value to its string representation (divided by the given exponent).
@@ -42,7 +41,7 @@ export function format(value: bigint, decimals = 0) {
42
41
  display.slice(0, display.length - decimals),
43
42
  display.slice(display.length - decimals),
44
43
  ]
45
- fraction = fraction.replace(trailingZerosRegex, '')
44
+ fraction = trimTrailingZeros(fraction)
46
45
  return `${negative ? '-' : ''}${integer || '0'}${
47
46
  fraction ? `.${fraction}` : ''
48
47
  }`
@@ -133,7 +132,7 @@ export function from(value: string, decimals = 0) {
133
132
  if (integer === '') integer = '0'
134
133
 
135
134
  // trim trailing zeros.
136
- fraction = fraction.replace(trailingZerosRegex, '')
135
+ fraction = trimTrailingZeros(fraction)
137
136
 
138
137
  // round off if the fraction is larger than the number of decimals.
139
138
  if (decimals === 0) {
@@ -195,6 +194,18 @@ export declare namespace from {
195
194
  type ErrorType = Errors.GlobalErrorType
196
195
  }
197
196
 
197
+ /**
198
+ * Removes trailing zeros with a backward scan, which stays linear in the
199
+ * length of the value.
200
+ *
201
+ * @internal
202
+ */
203
+ function trimTrailingZeros(value: string): string {
204
+ let end = value.length
205
+ while (end > 0 && value.charCodeAt(end - 1) === 48) end--
206
+ return value.slice(0, end)
207
+ }
208
+
198
209
  /**
199
210
  * Parses a string representation of Ether to a `bigint` Value (default: wei).
200
211
  *
@@ -116,6 +116,108 @@ describe('decode', () => {
116
116
  )
117
117
  })
118
118
 
119
+ test('behavior: solidity `Panic`', () => {
120
+ const data =
121
+ '0x4e487b710000000000000000000000000000000000000000000000000000000000000011'
122
+ expect(AbiError.decode(AbiError.solidityPanic, data)).toMatchInlineSnapshot(
123
+ `17`,
124
+ )
125
+ expect(
126
+ AbiError.decode(Abi.from(['error Paused()']), 'Panic', data),
127
+ ).toMatchInlineSnapshot(`17`)
128
+ expect(
129
+ AbiError.decode(
130
+ AbiError.solidityPanic,
131
+ AbiError.encode(AbiError.solidityPanic, [17]),
132
+ ),
133
+ ).toMatchInlineSnapshot(`17`)
134
+ })
135
+
136
+ test('behavior: uppercase data', () => {
137
+ const error = AbiError.from('error Unauthorized(address account)')
138
+ expect(
139
+ AbiError.decode(
140
+ error,
141
+ '0x8E4A23D6000000000000000000000000D8DA6BF26964AF9D7EED9E03E53415D37AA96045',
142
+ ),
143
+ ).toMatchInlineSnapshot(`"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"`)
144
+ })
145
+
146
+ test('error: selector mismatch', () => {
147
+ const abi = Abi.from([
148
+ 'error InsufficientAllowance(uint256 available, uint256 required)',
149
+ 'error InsufficientBalance(uint256 available, uint256 required)',
150
+ 'error Paused()',
151
+ ])
152
+ const data = AbiError.encode(
153
+ AbiError.fromAbi(abi, 'InsufficientAllowance'),
154
+ [1n, 2n],
155
+ )
156
+
157
+ expect(() =>
158
+ AbiError.decode(AbiError.fromAbi(abi, 'InsufficientBalance'), data),
159
+ ).toThrowErrorMatchingInlineSnapshot(`
160
+ [AbiError.SelectorMismatchError: Selector "0x2a1b2dd8" does not match the expected selector "0xcf479181".
161
+
162
+ Error: error InsufficientBalance(uint256 available, uint256 required)
163
+ Selector: 0xcf479181]
164
+ `)
165
+ expect(() => AbiError.decode(abi, 'InsufficientBalance', data))
166
+ .toThrowErrorMatchingInlineSnapshot(`
167
+ [AbiError.SelectorMismatchError: Selector "0x2a1b2dd8" does not match the expected selector "0xcf479181".
168
+
169
+ Error: error InsufficientBalance(uint256 available, uint256 required)
170
+ Selector: 0xcf479181]
171
+ `)
172
+ expect(() => AbiError.decode(abi, 'Paused', data))
173
+ .toThrowErrorMatchingInlineSnapshot(`
174
+ [AbiError.SelectorMismatchError: Selector "0x2a1b2dd8" does not match the expected selector "0x9e87fac8".
175
+
176
+ Error: error Paused()
177
+ Selector: 0x9e87fac8]
178
+ `)
179
+ expect(() => AbiError.decode(AbiError.solidityError, data))
180
+ .toThrowErrorMatchingInlineSnapshot(`
181
+ [AbiError.SelectorMismatchError: Selector "0x2a1b2dd8" does not match the expected selector "0x08c379a0".
182
+
183
+ Error: error Error(string message)
184
+ Selector: 0x08c379a0]
185
+ `)
186
+ })
187
+
188
+ test('error: selector mismatch, with overloads', () => {
189
+ const abi = Abi.from([
190
+ 'error Example()',
191
+ 'error Example(uint256 amount)',
192
+ 'error Other(uint256 amount)',
193
+ ])
194
+
195
+ expect(() =>
196
+ AbiError.decode(
197
+ abi,
198
+ 'Example',
199
+ AbiError.encode(AbiError.fromAbi(abi, 'Other'), [1n]),
200
+ ),
201
+ ).toThrowErrorMatchingInlineSnapshot(`
202
+ [AbiError.SelectorMismatchError: Selector "0x42d43c87" does not match the expected selector "0xb085b9a5".
203
+
204
+ Error: error Example()
205
+ Selector: 0xb085b9a5]
206
+ `)
207
+ expect(() =>
208
+ AbiError.decode(
209
+ abi,
210
+ 'Example',
211
+ AbiError.encode(AbiError.solidityError, ['denied']),
212
+ ),
213
+ ).toThrowErrorMatchingInlineSnapshot(`
214
+ [AbiError.SelectorMismatchError: Selector "0x08c379a0" does not match the expected selector "0xb085b9a5".
215
+
216
+ Error: error Example()
217
+ Selector: 0xb085b9a5]
218
+ `)
219
+ })
220
+
119
221
  describe('behavior: network', async () => {
120
222
  const hash = await anvilMainnet.request({
121
223
  method: 'eth_sendTransaction',
@@ -324,7 +426,7 @@ describe('decode', () => {
324
426
  'error InvalidSignature(uint r, uint s, uint8 yParity)',
325
427
  ])
326
428
  const data =
327
- '0xecde634900000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'
429
+ '0xe466f0a500000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'
328
430
 
329
431
  // Test both overload patterns
330
432
  const abiError = AbiError.fromAbi(abi, 'InvalidSignature')
@@ -340,7 +442,7 @@ describe('decode', () => {
340
442
  'error InvalidSignature(uint r, uint s, uint8 yParity)',
341
443
  ])
342
444
  const data =
343
- '0xecde634900000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'
445
+ '0xe466f0a500000000000000000000000000000000000000000000000000000000000001a400000000000000000000000000000000000000000000000000000000000000450000000000000000000000000000000000000000000000000000000000000001'
344
446
 
345
447
  // Test both overload patterns with options
346
448
  const abiError = AbiError.fromAbi(abi, 'InvalidSignature')
@@ -1212,6 +1314,7 @@ test('exports', () => {
1212
1314
  "solidityErrorSelector",
1213
1315
  "solidityPanic",
1214
1316
  "solidityPanicSelector",
1317
+ "SelectorMismatchError",
1215
1318
  ]
1216
1319
  `)
1217
1320
  })
@@ -244,7 +244,7 @@ describe('extractLogs', () => {
244
244
 
245
245
  const extracted = AbiEvent.extractLogs([value.abiEvent], [log])
246
246
 
247
- const array = value.inputs.some((input) => !input.name)
247
+ const array = value.inputs.every((input) => !input.name)
248
248
  expect(extracted.map((x) => [x.eventName, lowercase(x.args)])).toEqual([
249
249
  [value.abiEvent.name, lowercase(expectedArgs(value, array))],
250
250
  ])