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
@@ -1,4 +1,4 @@
1
- import { Abi, AbiEvent, AbiParameters, Hash, Hex } from 'ox'
1
+ import { Abi, AbiEvent, AbiParameters, Address, Hash, Hex } from 'ox'
2
2
  import { describe, expect, test } from 'vp/test'
3
3
  import { wagmiContractConfig } from '../../../test/constants/abis.js'
4
4
  import { address } from '../../../test/constants/addresses.js'
@@ -216,6 +216,104 @@ describe('assertArgs', () => {
216
216
  `)
217
217
  })
218
218
 
219
+ test('behavior: named + unnamed inputs', () => {
220
+ const abiEvent = AbiEvent.from(
221
+ 'event Transfer(address indexed from, address indexed, uint256)',
222
+ )
223
+ const args = AbiEvent.decode(abiEvent, {
224
+ data: '0x0000000000000000000000000000000000000000000000000000000000000001',
225
+ topics: [
226
+ AbiEvent.getSelector(abiEvent),
227
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
228
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
229
+ ],
230
+ })
231
+ AbiEvent.assertArgs(abiEvent, args, {
232
+ 1: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
233
+ 2: 1n,
234
+ from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
235
+ })
236
+ expect(() =>
237
+ AbiEvent.assertArgs(abiEvent, args, {
238
+ 1: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
239
+ }),
240
+ ).toThrowErrorMatchingInlineSnapshot(`
241
+ [AbiEvent.ArgsMismatchError: Given arguments do not match the expected arguments.
242
+
243
+ Event: event Transfer(address indexed from, address indexed, uint256)
244
+ Expected Arguments:
245
+ 1: 0xa5Cc3C03994DB5B0d9a5EEdD10CaBab0813678ad
246
+ 2: 1
247
+ from: 0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC
248
+ Given Arguments:
249
+ 1: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac]
250
+ `)
251
+ })
252
+
253
+ test('error: args mismatch, positional and keyed', () => {
254
+ const abiEvent = AbiEvent.from(
255
+ 'event Transfer(address indexed from, address indexed to, uint256 value)',
256
+ )
257
+ const args = AbiEvent.decode(abiEvent, {
258
+ data: '0x0000000000000000000000000000000000000000000000000000000000000001',
259
+ topics: [
260
+ AbiEvent.getSelector(abiEvent),
261
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
262
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
263
+ ],
264
+ })
265
+ expect(() =>
266
+ // @ts-expect-error
267
+ AbiEvent.assertArgs(abiEvent, args, [
268
+ '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
269
+ ]),
270
+ ).toThrowErrorMatchingInlineSnapshot(`
271
+ [AbiEvent.ArgsMismatchError: Given arguments do not match the expected arguments.
272
+
273
+ Event: event Transfer(address indexed from, address indexed to, uint256 value)
274
+ Expected Arguments:
275
+ from: 0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC
276
+ to: 0xa5Cc3C03994DB5B0d9a5EEdD10CaBab0813678ad
277
+ value: 1
278
+ Given Arguments:
279
+ 0: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac]
280
+ `)
281
+ expect(() =>
282
+ AbiEvent.assertArgs(
283
+ abiEvent,
284
+ [
285
+ '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
286
+ '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
287
+ 1n,
288
+ ],
289
+ { from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac' },
290
+ ),
291
+ ).toThrowErrorMatchingInlineSnapshot(`
292
+ [AbiEvent.ArgsMismatchError: Given arguments do not match the expected arguments.
293
+
294
+ Event: event Transfer(address indexed from, address indexed to, uint256 value)
295
+ Expected Arguments:
296
+ 0: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac
297
+ 1: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad
298
+ 2: 1
299
+ Given Arguments:
300
+ from: 0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac]
301
+ `)
302
+ })
303
+
304
+ test('behavior: filter without values', () => {
305
+ const abiEvent = AbiEvent.from(
306
+ 'event Transfer(address indexed from, address indexed to, uint256 value)',
307
+ )
308
+ const args = [
309
+ '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
310
+ '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
311
+ 1n,
312
+ ]
313
+ AbiEvent.assertArgs(abiEvent, args, {})
314
+ AbiEvent.assertArgs(abiEvent, args, { from: undefined, to: null })
315
+ })
316
+
219
317
  test('error: args mismatch, string', () => {
220
318
  const abiEvent = AbiEvent.from('event Transfer(string indexed a)')
221
319
  const args = AbiEvent.decode(abiEvent, {
@@ -613,6 +711,244 @@ describe('decode', () => {
613
711
  )
614
712
  })
615
713
 
714
+ test('behavior: canonical indexed `address`, `bool`, `intN` and `uintN` topics', () => {
715
+ const abiEvent = AbiEvent.from(
716
+ 'event Foo(address indexed a, bool indexed b, int8 indexed c, uint8 d)',
717
+ )
718
+ expect(
719
+ AbiEvent.decode(abiEvent, {
720
+ data: '0x00000000000000000000000000000000000000000000000000000000000000ff',
721
+ topics: [
722
+ AbiEvent.getSelector(abiEvent),
723
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
724
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
725
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80',
726
+ ],
727
+ }),
728
+ ).toMatchInlineSnapshot(`
729
+ {
730
+ "a": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
731
+ "b": true,
732
+ "c": -128,
733
+ "d": 255,
734
+ }
735
+ `)
736
+
737
+ const abiEvent_2 = AbiEvent.from(
738
+ 'event Foo(bool indexed a, uint8 indexed b, int256 indexed c)',
739
+ )
740
+ expect(
741
+ AbiEvent.decode(abiEvent_2, {
742
+ topics: [
743
+ AbiEvent.getSelector(abiEvent_2),
744
+ '0x0000000000000000000000000000000000000000000000000000000000000000',
745
+ '0x00000000000000000000000000000000000000000000000000000000000000ff',
746
+ '0x8000000000000000000000000000000000000000000000000000000000000000',
747
+ ],
748
+ }),
749
+ ).toMatchInlineSnapshot(`
750
+ {
751
+ "a": false,
752
+ "b": 255,
753
+ "c": -57896044618658097711785492504343953926634992332820282019728792003956564819968n,
754
+ }
755
+ `)
756
+ })
757
+
758
+ test('error: non-canonical indexed `address` topic', () => {
759
+ const abiEvent = AbiEvent.from('event Foo(address indexed a)')
760
+ const topic =
761
+ '0xdeadbeef0000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
762
+
763
+ expect(() =>
764
+ AbiParameters.decode([{ type: 'address' }], topic),
765
+ ).toThrowError(Address.InvalidAddressError)
766
+ expect(() =>
767
+ AbiEvent.decode(abiEvent, {
768
+ topics: [AbiEvent.getSelector(abiEvent), topic],
769
+ }),
770
+ ).toThrowErrorMatchingInlineSnapshot(`
771
+ [Address.InvalidAddressError: Address "0xdeadbeef0000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac" is invalid.
772
+
773
+ Details: Address is not a 20 byte (40 hexadecimal character) value.]
774
+ `)
775
+ })
776
+
777
+ test('error: non-canonical indexed `bool` topic', () => {
778
+ const abiEvent = AbiEvent.from('event Foo(bool indexed a)')
779
+
780
+ expect(() =>
781
+ AbiEvent.decode(abiEvent, {
782
+ topics: [
783
+ AbiEvent.getSelector(abiEvent),
784
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
785
+ ],
786
+ }),
787
+ ).toThrowErrorMatchingInlineSnapshot(`
788
+ [Bytes.InvalidBytesBooleanError: Bytes value \`2\` is not a valid boolean.
789
+
790
+ The bytes array must contain a single byte of either a \`0\` or \`1\` value.]
791
+ `)
792
+ expect(() =>
793
+ AbiEvent.decode(abiEvent, {
794
+ topics: [
795
+ AbiEvent.getSelector(abiEvent),
796
+ '0x0000000000000000000000000000000000000000000000000000000000000011',
797
+ ],
798
+ }),
799
+ ).toThrowErrorMatchingInlineSnapshot(`
800
+ [Bytes.InvalidBytesBooleanError: Bytes value \`17\` is not a valid boolean.
801
+
802
+ The bytes array must contain a single byte of either a \`0\` or \`1\` value.]
803
+ `)
804
+ })
805
+
806
+ test('error: indexed `intN` and `uintN` topics out of range', () => {
807
+ const uint8 = AbiEvent.from('event Foo(uint8 indexed a)')
808
+ expect(() =>
809
+ AbiEvent.decode(uint8, {
810
+ topics: [
811
+ AbiEvent.getSelector(uint8),
812
+ '0x0000000000000000000000000000000000000000000000000000000000000100',
813
+ ],
814
+ }),
815
+ ).toThrowErrorMatchingInlineSnapshot(
816
+ `[Hex.IntegerOutOfRangeError: Number \`256\` is not in safe 8-bit unsigned integer range (\`0\` to \`255\`)]`,
817
+ )
818
+
819
+ const int8 = AbiEvent.from('event Foo(int8 indexed a)')
820
+ expect(() =>
821
+ AbiEvent.decode(int8, {
822
+ topics: [
823
+ AbiEvent.getSelector(int8),
824
+ '0x0000000000000000000000000000000000000000000000000000000000000080',
825
+ ],
826
+ }),
827
+ ).toThrowErrorMatchingInlineSnapshot(
828
+ `[Hex.IntegerOutOfRangeError: Number \`128\` is not in safe 8-bit signed integer range (\`-128\` to \`127\`)]`,
829
+ )
830
+ expect(() =>
831
+ AbiEvent.decode(int8, {
832
+ topics: [
833
+ AbiEvent.getSelector(int8),
834
+ '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',
835
+ ],
836
+ }),
837
+ ).toThrowErrorMatchingInlineSnapshot(
838
+ `[Hex.IntegerOutOfRangeError: Number \`-129\` is not in safe 8-bit signed integer range (\`-128\` to \`127\`)]`,
839
+ )
840
+
841
+ const uint64 = AbiEvent.from('event Foo(uint64 indexed a)')
842
+ expect(() =>
843
+ AbiEvent.decode(uint64, {
844
+ topics: [
845
+ AbiEvent.getSelector(uint64),
846
+ '0x8000000000000000000000000000000000000000000000000000000000000000',
847
+ ],
848
+ }),
849
+ ).toThrowErrorMatchingInlineSnapshot(
850
+ `[Hex.IntegerOutOfRangeError: Number \`57896044618658097711785492504343953926634992332820282019728792003956564819968\` is not in safe 64-bit unsigned integer range (\`0\` to \`18446744073709551615\`)]`,
851
+ )
852
+ })
853
+
854
+ test('error: indexed topic shorter than 32 bytes', () => {
855
+ const abiEvent = AbiEvent.from('event Foo(uint256 indexed a)')
856
+
857
+ expect(() =>
858
+ AbiEvent.decode(abiEvent, {
859
+ topics: [AbiEvent.getSelector(abiEvent), '0x01'],
860
+ }),
861
+ ).toThrowErrorMatchingInlineSnapshot(`
862
+ [AbiParameters.DataSizeTooSmallError: Data size of 1 bytes is too small for given parameters.
863
+
864
+ Params: (uint256 indexed a)
865
+ Data: 0x01 (1 bytes)]
866
+ `)
867
+ })
868
+
869
+ test('error: indexed topic longer than 32 bytes', () => {
870
+ const abiEvent = AbiEvent.from('event Foo(address indexed a)')
871
+
872
+ expect(() =>
873
+ AbiEvent.decode(abiEvent, {
874
+ topics: [
875
+ AbiEvent.getSelector(abiEvent),
876
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac00',
877
+ ],
878
+ }),
879
+ ).toThrowErrorMatchingInlineSnapshot(
880
+ `[Hex.SizeOverflowError: Size cannot exceed \`32\` bytes. Given size: \`33\` bytes.]`,
881
+ )
882
+ })
883
+
884
+ test('error: indexed `address` topic with invalid characters', () => {
885
+ const abiEvent = AbiEvent.from('event Foo(address indexed a)')
886
+ const topic =
887
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678zz'
888
+
889
+ expect(() =>
890
+ AbiEvent.decode(
891
+ abiEvent,
892
+ { topics: [AbiEvent.getSelector(abiEvent), topic] },
893
+ { checksumAddress: false },
894
+ ),
895
+ ).toThrowErrorMatchingInlineSnapshot(`
896
+ [Address.InvalidAddressError: Address "0xa5cc3c03994db5b0d9a5eedd10cabab0813678zz" is invalid.
897
+
898
+ Details: Address is not a 20 byte (40 hexadecimal character) value.]
899
+ `)
900
+ expect(() =>
901
+ AbiEvent.decode(abiEvent, {
902
+ topics: [AbiEvent.getSelector(abiEvent), topic],
903
+ }),
904
+ ).toThrowErrorMatchingInlineSnapshot(`
905
+ [Address.InvalidAddressError: Address "0xa5cc3c03994db5b0d9a5eedd10cabab0813678zz" is invalid.
906
+
907
+ Details: Address is not a 20 byte (40 hexadecimal character) value.]
908
+ `)
909
+ })
910
+
911
+ test('error: non-canonical indexed `bytesN` topics', () => {
912
+ const abiEvent = AbiEvent.from('event Foo(bytes4 indexed a)')
913
+
914
+ expect(
915
+ AbiEvent.decode(abiEvent, {
916
+ topics: [
917
+ AbiEvent.getSelector(abiEvent),
918
+ '0xdeadbeef00000000000000000000000000000000000000000000000000000000',
919
+ ],
920
+ }),
921
+ ).toMatchInlineSnapshot(`
922
+ {
923
+ "a": "0xdeadbeef",
924
+ }
925
+ `)
926
+ expect(() =>
927
+ AbiEvent.decode(abiEvent, {
928
+ topics: [
929
+ AbiEvent.getSelector(abiEvent),
930
+ '0xdeadbeef00000000000000000000000000000000000000000000000000000001',
931
+ ],
932
+ }),
933
+ ).toThrowErrorMatchingInlineSnapshot(
934
+ `[AbiParameters.BytesSizeMismatchError: Size of bytes "0xdeadbeef00000000000000000000000000000000000000000000000000000001" (bytes32) does not match expected size (bytes4).]`,
935
+ )
936
+
937
+ const bytes32 = AbiEvent.from('event Foo(bytes32 indexed a)')
938
+ expect(() =>
939
+ AbiEvent.decode(bytes32, {
940
+ topics: [
941
+ AbiEvent.getSelector(bytes32),
942
+ '0xdeadbeef000000000000000000000000000000000000000000000000000000zz',
943
+ ],
944
+ }),
945
+ ).toThrowErrorMatchingInlineSnapshot(`
946
+ [Hex.InvalidHexValueError: Value \`0xdeadbeef000000000000000000000000000000000000000000000000000000zz\` is an invalid hex value.
947
+
948
+ Hex values must start with \`"0x"\` and contain only hexadecimal characters (0-9, a-f, A-F).]
949
+ `)
950
+ })
951
+
616
952
  test('error: event selector topic mismatch', () => {
617
953
  const transfer = AbiEvent.from(
618
954
  'event Transfer(address indexed from, address indexed to, bool sender)',
@@ -719,6 +1055,127 @@ describe('decode', () => {
719
1055
  }
720
1056
  `)
721
1057
  })
1058
+
1059
+ test('behavior: with overloads, zero-input and named', () => {
1060
+ const abi = Abi.from(['event Foo()', 'event Foo(address indexed who)'])
1061
+ const log = {
1062
+ topics: [
1063
+ AbiEvent.getSelector('event Foo(address indexed who)'),
1064
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1065
+ ],
1066
+ } as const
1067
+
1068
+ expect(AbiEvent.decode(abi, 'Foo', log)).toMatchInlineSnapshot(`
1069
+ {
1070
+ "who": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1071
+ }
1072
+ `)
1073
+ expect(AbiEvent.decode(AbiEvent.fromAbi(abi, 'Foo'), log))
1074
+ .toMatchInlineSnapshot(`
1075
+ {
1076
+ "who": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1077
+ }
1078
+ `)
1079
+ expect(
1080
+ AbiEvent.decode(abi, 'Foo', {
1081
+ topics: [AbiEvent.getSelector('event Foo()')],
1082
+ }),
1083
+ ).toMatchInlineSnapshot(`undefined`)
1084
+ })
1085
+
1086
+ test('behavior: with overloads, anonymous and named', () => {
1087
+ const abi = Abi.from([
1088
+ { anonymous: true, inputs: [], name: 'Foo', type: 'event' },
1089
+ {
1090
+ inputs: [{ indexed: true, name: 'who', type: 'address' }],
1091
+ name: 'Foo',
1092
+ type: 'event',
1093
+ },
1094
+ ])
1095
+ const log = {
1096
+ topics: [
1097
+ AbiEvent.getSelector('event Foo(address indexed who)'),
1098
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1099
+ ],
1100
+ } as const
1101
+
1102
+ expect(AbiEvent.decode(abi, 'Foo', log)).toMatchInlineSnapshot(`
1103
+ {
1104
+ "who": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1105
+ }
1106
+ `)
1107
+ expect(AbiEvent.decode(AbiEvent.fromAbi(abi, 'Foo'), log))
1108
+ .toMatchInlineSnapshot(`
1109
+ {
1110
+ "who": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1111
+ }
1112
+ `)
1113
+ // Without a selector match, the log decodes with the event picked by name.
1114
+ expect(AbiEvent.decode(abi, 'Foo', { topics: [] })).toMatchInlineSnapshot(
1115
+ `undefined`,
1116
+ )
1117
+ })
1118
+
1119
+ test('behavior: with overloads, two named', () => {
1120
+ const abi = Abi.from([
1121
+ 'event Deposit(address indexed who, uint256 amount)',
1122
+ 'event Deposit(address indexed who, uint256 amount, bytes32 indexed ref)',
1123
+ ])
1124
+ const [deposit, depositWithRef] = abi
1125
+
1126
+ expect(
1127
+ AbiEvent.decode(abi, 'Deposit', {
1128
+ data: '0x0000000000000000000000000000000000000000000000000000000000000005',
1129
+ topics: [
1130
+ AbiEvent.getSelector(depositWithRef),
1131
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1132
+ '0x1111111111111111111111111111111111111111111111111111111111111111',
1133
+ ],
1134
+ }),
1135
+ ).toMatchInlineSnapshot(`
1136
+ {
1137
+ "amount": 5n,
1138
+ "ref": "0x1111111111111111111111111111111111111111111111111111111111111111",
1139
+ "who": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1140
+ }
1141
+ `)
1142
+ expect(
1143
+ AbiEvent.decode(abi, 'Deposit', {
1144
+ data: '0x0000000000000000000000000000000000000000000000000000000000000005',
1145
+ topics: [
1146
+ AbiEvent.getSelector(deposit),
1147
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1148
+ ],
1149
+ }),
1150
+ ).toMatchInlineSnapshot(`
1151
+ {
1152
+ "amount": 5n,
1153
+ "who": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1154
+ }
1155
+ `)
1156
+ })
1157
+
1158
+ test('error: with overloads, selector topic matches no overload', () => {
1159
+ const abi = Abi.from([
1160
+ 'event Deposit(address indexed who, uint256 amount)',
1161
+ 'event Deposit(address indexed who, uint256 amount, bytes32 indexed ref)',
1162
+ ])
1163
+
1164
+ expect(() =>
1165
+ AbiEvent.decode(abi, 'Deposit', {
1166
+ data: '0x0000000000000000000000000000000000000000000000000000000000000005',
1167
+ topics: [
1168
+ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
1169
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1170
+ ],
1171
+ }),
1172
+ ).toThrowErrorMatchingInlineSnapshot(`
1173
+ [AbiEvent.SelectorTopicMismatchError: topics[0]="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" does not match the expected topics[0]="0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c".
1174
+
1175
+ Event: event Deposit(address indexed who, uint256 amount)
1176
+ Selector: 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c]
1177
+ `)
1178
+ })
722
1179
  })
723
1180
 
724
1181
  describe('decodeLog', () => {
@@ -1073,6 +1530,67 @@ describe('extractLogs', () => {
1073
1530
  expect(decoded).toMatchInlineSnapshot(`[]`)
1074
1531
  })
1075
1532
 
1533
+ test('behavior: skips logs with non-canonical indexed topics', () => {
1534
+ const abi = Abi.from([
1535
+ 'event Transfer(address indexed from, address indexed to, uint256 value)',
1536
+ 'event Paused(bool indexed paused)',
1537
+ 'event Count(uint8 indexed count)',
1538
+ ])
1539
+ const [transfer, paused, count] = abi
1540
+ const logs = [
1541
+ {
1542
+ data: '0x0000000000000000000000000000000000000000000000000000000000000001',
1543
+ topics: [
1544
+ AbiEvent.getSelector(transfer),
1545
+ '0xdeadbeef0000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1546
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1547
+ ],
1548
+ },
1549
+ {
1550
+ data: '0x',
1551
+ topics: [
1552
+ AbiEvent.getSelector(paused),
1553
+ '0x0000000000000000000000000000000000000000000000000000000000000002',
1554
+ ],
1555
+ },
1556
+ {
1557
+ data: '0x',
1558
+ topics: [
1559
+ AbiEvent.getSelector(count),
1560
+ '0x0000000000000000000000000000000000000000000000000000000000000100',
1561
+ ],
1562
+ },
1563
+ ] as const
1564
+
1565
+ expect(AbiEvent.extractLogs(abi, logs)).toMatchInlineSnapshot(`[]`)
1566
+ expect(
1567
+ AbiEvent.extractLogs(abi, logs, {
1568
+ args: { paused: false },
1569
+ eventName: 'Paused',
1570
+ }),
1571
+ ).toMatchInlineSnapshot(`[]`)
1572
+ expect(
1573
+ AbiEvent.extractLogs(abi, logs, { strict: false }).map(
1574
+ ({ args, eventName }) => ({ args, eventName }),
1575
+ ),
1576
+ ).toMatchInlineSnapshot(`
1577
+ [
1578
+ {
1579
+ "args": {},
1580
+ "eventName": "Transfer",
1581
+ },
1582
+ {
1583
+ "args": {},
1584
+ "eventName": "Paused",
1585
+ },
1586
+ {
1587
+ "args": {},
1588
+ "eventName": "Count",
1589
+ },
1590
+ ]
1591
+ `)
1592
+ })
1593
+
1076
1594
  test('behavior: filters by event name', () => {
1077
1595
  const transfer = AbiEvent.from(
1078
1596
  'event Transfer(address indexed from, address indexed to, uint256 value)',
@@ -1351,6 +1869,118 @@ describe('extractLogs', () => {
1351
1869
  `)
1352
1870
  })
1353
1871
 
1872
+ test('behavior: filters by arguments of named + unnamed inputs', () => {
1873
+ const transfer = AbiEvent.from(
1874
+ 'event Transfer(address indexed from, address indexed, uint256)',
1875
+ )
1876
+ const log = {
1877
+ data: '0x0000000000000000000000000000000000000000000000000000000000000001',
1878
+ topics: [
1879
+ AbiEvent.getSelector(transfer),
1880
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1881
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad',
1882
+ ],
1883
+ } as const
1884
+
1885
+ expect(
1886
+ AbiEvent.extractLogs([transfer], [log], {
1887
+ args: { from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad' },
1888
+ }),
1889
+ ).toMatchInlineSnapshot(`[]`)
1890
+ expect(
1891
+ AbiEvent.extractLogs([transfer], [log], {
1892
+ args: { 1: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac' },
1893
+ }),
1894
+ ).toMatchInlineSnapshot(`[]`)
1895
+ expect(
1896
+ AbiEvent.extractLogs([transfer], [log], {
1897
+ args: {
1898
+ 1: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad',
1899
+ 2: 1n,
1900
+ from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ac',
1901
+ },
1902
+ }),
1903
+ ).toMatchInlineSnapshot(`
1904
+ [
1905
+ {
1906
+ "args": {
1907
+ "1": "0xa5Cc3C03994DB5B0d9a5EEdD10CaBab0813678ad",
1908
+ "2": 1n,
1909
+ "from": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1910
+ },
1911
+ "data": "0x0000000000000000000000000000000000000000000000000000000000000001",
1912
+ "eventName": "Transfer",
1913
+ "topics": [
1914
+ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
1915
+ "0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac",
1916
+ "0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad",
1917
+ ],
1918
+ },
1919
+ ]
1920
+ `)
1921
+ })
1922
+
1923
+ test('behavior: non-strict mode keys named + unnamed inputs like `decode`', () => {
1924
+ const transfer = AbiEvent.from(
1925
+ 'event Transfer(address indexed from, address indexed, uint256)',
1926
+ )
1927
+ const selector = AbiEvent.getSelector(transfer)
1928
+ const from =
1929
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
1930
+ const logs = [
1931
+ // The second indexed input is read from data.
1932
+ {
1933
+ data: '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ad0000000000000000000000000000000000000000000000000000000000000001',
1934
+ topics: [selector, from],
1935
+ },
1936
+ // The topic does not decode as an address.
1937
+ { data: '0x', topics: [selector, '0xdead'] },
1938
+ ] as const
1939
+
1940
+ expect(
1941
+ AbiEvent.extractLogs([transfer], logs, { strict: false }).map(
1942
+ (log) => log.args,
1943
+ ),
1944
+ ).toMatchInlineSnapshot(`
1945
+ [
1946
+ {
1947
+ "1": "0xa5Cc3C03994DB5B0d9a5EEdD10CaBab0813678ad",
1948
+ "2": 1n,
1949
+ "from": "0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC",
1950
+ },
1951
+ {},
1952
+ ]
1953
+ `)
1954
+ expect(
1955
+ AbiEvent.extractLogs([transfer], logs, {
1956
+ args: { from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad' },
1957
+ strict: false,
1958
+ }),
1959
+ ).toMatchInlineSnapshot(`[]`)
1960
+ })
1961
+
1962
+ test('behavior: positional and keyed arguments do not match', () => {
1963
+ const named = AbiEvent.from('event Transfer(address indexed from)')
1964
+ const unnamed = AbiEvent.from('event Transfer(address indexed)')
1965
+ const topic =
1966
+ '0x000000000000000000000000a5cc3c03994db5b0d9a5eedd10cabab0813678ac'
1967
+
1968
+ expect(
1969
+ AbiEvent.extractLogs(
1970
+ [named] as readonly unknown[],
1971
+ [{ data: '0x', topics: [AbiEvent.getSelector(named), topic] }],
1972
+ { args: ['0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad'] },
1973
+ ),
1974
+ ).toMatchInlineSnapshot(`[]`)
1975
+ expect(
1976
+ AbiEvent.extractLogs(
1977
+ [unnamed] as readonly unknown[],
1978
+ [{ data: '0x', topics: [AbiEvent.getSelector(unnamed), topic] }],
1979
+ { args: { from: '0xa5cc3c03994db5b0d9a5eedd10cabab0813678ad' } },
1980
+ ),
1981
+ ).toMatchInlineSnapshot(`[]`)
1982
+ })
1983
+
1354
1984
  test('behavior: filters by non-indexed `bytes` and `bytes32` arguments in either case', () => {
1355
1985
  const payload = AbiEvent.from('event Payload(bytes data, bytes32 key)')
1356
1986
  const log = {
@@ -1905,16 +2535,21 @@ describe('encode', () => {
1905
2535
  `)
1906
2536
  })
1907
2537
 
1908
- test('behavior: odd-length indexed bytes32 arg', () => {
1909
- const event = AbiEvent.from('event Foo(bytes32 indexed a)')
1910
- expect(AbiEvent.encode(event, { a: `0x${'1'.repeat(63)}` }))
1911
- .toMatchInlineSnapshot(`
1912
- {
1913
- "topics": [
1914
- "0x54b5e571557045df8a69633aeac8e206d92b03f48563fab6a430493d299de727",
1915
- "0x1111111111111111111111111111111111111111111111111111111111111110",
1916
- ],
1917
- }
2538
+ test('error: odd-length indexed bytesN arg', () => {
2539
+ const event = AbiEvent.from(
2540
+ 'event Foo(bytes4 indexed a, bytes32 indexed b)',
2541
+ )
2542
+ expect(() => AbiEvent.encode(event, { a: '0x1234567' }))
2543
+ .toThrowErrorMatchingInlineSnapshot(`
2544
+ [Hex.InvalidLengthError: Hex value \`"0x1234567"\` is an odd length (7 nibbles).
2545
+
2546
+ It must be an even length.]
2547
+ `)
2548
+ expect(() => AbiEvent.encode(event, { b: `0x${'1'.repeat(63)}` }))
2549
+ .toThrowErrorMatchingInlineSnapshot(`
2550
+ [Hex.InvalidLengthError: Hex value \`"0x111111111111111111111111111111111111111111111111111111111111111"\` is an odd length (63 nibbles).
2551
+
2552
+ It must be an even length.]
1918
2553
  `)
1919
2554
  })
1920
2555