viem 2.7.8 → 2.7.10

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 (180) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/_cjs/accounts/toAccount.js +2 -2
  3. package/_cjs/accounts/toAccount.js.map +1 -1
  4. package/_cjs/actions/public/call.js +1 -1
  5. package/_cjs/actions/public/call.js.map +1 -1
  6. package/_cjs/chains/definitions/base.js +6 -0
  7. package/_cjs/chains/definitions/base.js.map +1 -1
  8. package/_cjs/chains/definitions/baseGoerli.js +5 -0
  9. package/_cjs/chains/definitions/baseGoerli.js.map +1 -1
  10. package/_cjs/chains/definitions/baseSepolia.js +6 -0
  11. package/_cjs/chains/definitions/baseSepolia.js.map +1 -1
  12. package/_cjs/chains/definitions/etherlinkTestnet.js +24 -0
  13. package/_cjs/chains/definitions/etherlinkTestnet.js.map +1 -0
  14. package/_cjs/chains/definitions/kakarotSepolia.js +26 -0
  15. package/_cjs/chains/definitions/kakarotSepolia.js.map +1 -0
  16. package/_cjs/chains/definitions/optimism.js +5 -0
  17. package/_cjs/chains/definitions/optimism.js.map +1 -1
  18. package/_cjs/chains/definitions/optimismGoerli.js +5 -0
  19. package/_cjs/chains/definitions/optimismGoerli.js.map +1 -1
  20. package/_cjs/chains/definitions/optimismSepolia.js +5 -0
  21. package/_cjs/chains/definitions/optimismSepolia.js.map +1 -1
  22. package/_cjs/chains/definitions/pgn.js +5 -0
  23. package/_cjs/chains/definitions/pgn.js.map +1 -1
  24. package/_cjs/chains/definitions/pgnTestnet.js +10 -0
  25. package/_cjs/chains/definitions/pgnTestnet.js.map +1 -1
  26. package/_cjs/chains/definitions/xdc.js +6 -0
  27. package/_cjs/chains/definitions/xdc.js.map +1 -1
  28. package/_cjs/chains/definitions/xdcTestnet.js +6 -0
  29. package/_cjs/chains/definitions/xdcTestnet.js.map +1 -1
  30. package/_cjs/chains/definitions/zora.js +5 -0
  31. package/_cjs/chains/definitions/zora.js.map +1 -1
  32. package/_cjs/chains/definitions/zoraSepolia.js +5 -0
  33. package/_cjs/chains/definitions/zoraSepolia.js.map +1 -1
  34. package/_cjs/chains/index.js +9 -5
  35. package/_cjs/chains/index.js.map +1 -1
  36. package/_cjs/chains/opStack/abis.js +458 -1
  37. package/_cjs/chains/opStack/abis.js.map +1 -1
  38. package/_cjs/clients/decorators/wallet.js.map +1 -1
  39. package/_cjs/errors/address.js +6 -1
  40. package/_cjs/errors/address.js.map +1 -1
  41. package/_cjs/errors/version.js +1 -1
  42. package/_cjs/errors/version.js.map +1 -1
  43. package/_cjs/utils/abi/getAbiItem.js +3 -3
  44. package/_cjs/utils/abi/getAbiItem.js.map +1 -1
  45. package/_cjs/utils/address/isAddress.js +17 -2
  46. package/_cjs/utils/address/isAddress.js.map +1 -1
  47. package/_cjs/utils/address/isAddressEqual.js +2 -2
  48. package/_cjs/utils/address/isAddressEqual.js.map +1 -1
  49. package/_cjs/utils/lru.js +23 -0
  50. package/_cjs/utils/lru.js.map +1 -0
  51. package/_cjs/utils/transaction/parseTransaction.js +1 -1
  52. package/_cjs/utils/transaction/parseTransaction.js.map +1 -1
  53. package/_cjs/utils/transaction/serializeAccessList.js +1 -1
  54. package/_cjs/utils/transaction/serializeAccessList.js.map +1 -1
  55. package/_esm/accounts/toAccount.js +2 -2
  56. package/_esm/accounts/toAccount.js.map +1 -1
  57. package/_esm/actions/public/call.js +1 -1
  58. package/_esm/actions/public/call.js.map +1 -1
  59. package/_esm/chains/definitions/base.js +6 -0
  60. package/_esm/chains/definitions/base.js.map +1 -1
  61. package/_esm/chains/definitions/baseGoerli.js +5 -0
  62. package/_esm/chains/definitions/baseGoerli.js.map +1 -1
  63. package/_esm/chains/definitions/baseSepolia.js +6 -0
  64. package/_esm/chains/definitions/baseSepolia.js.map +1 -1
  65. package/_esm/chains/definitions/etherlinkTestnet.js +21 -0
  66. package/_esm/chains/definitions/etherlinkTestnet.js.map +1 -0
  67. package/_esm/chains/definitions/kakarotSepolia.js +23 -0
  68. package/_esm/chains/definitions/kakarotSepolia.js.map +1 -0
  69. package/_esm/chains/definitions/optimism.js +5 -0
  70. package/_esm/chains/definitions/optimism.js.map +1 -1
  71. package/_esm/chains/definitions/optimismGoerli.js +5 -0
  72. package/_esm/chains/definitions/optimismGoerli.js.map +1 -1
  73. package/_esm/chains/definitions/optimismSepolia.js +5 -0
  74. package/_esm/chains/definitions/optimismSepolia.js.map +1 -1
  75. package/_esm/chains/definitions/pgn.js +5 -0
  76. package/_esm/chains/definitions/pgn.js.map +1 -1
  77. package/_esm/chains/definitions/pgnTestnet.js +10 -0
  78. package/_esm/chains/definitions/pgnTestnet.js.map +1 -1
  79. package/_esm/chains/definitions/xdc.js +6 -0
  80. package/_esm/chains/definitions/xdc.js.map +1 -1
  81. package/_esm/chains/definitions/xdcTestnet.js +6 -0
  82. package/_esm/chains/definitions/xdcTestnet.js.map +1 -1
  83. package/_esm/chains/definitions/zora.js +5 -0
  84. package/_esm/chains/definitions/zora.js.map +1 -1
  85. package/_esm/chains/definitions/zoraSepolia.js +5 -0
  86. package/_esm/chains/definitions/zoraSepolia.js.map +1 -1
  87. package/_esm/chains/index.js +2 -0
  88. package/_esm/chains/index.js.map +1 -1
  89. package/_esm/chains/opStack/abis.js +457 -0
  90. package/_esm/chains/opStack/abis.js.map +1 -1
  91. package/_esm/clients/decorators/wallet.js.map +1 -1
  92. package/_esm/errors/address.js +6 -1
  93. package/_esm/errors/address.js.map +1 -1
  94. package/_esm/errors/version.js +1 -1
  95. package/_esm/errors/version.js.map +1 -1
  96. package/_esm/utils/abi/getAbiItem.js +3 -3
  97. package/_esm/utils/abi/getAbiItem.js.map +1 -1
  98. package/_esm/utils/address/isAddress.js +17 -2
  99. package/_esm/utils/address/isAddress.js.map +1 -1
  100. package/_esm/utils/address/isAddressEqual.js +2 -2
  101. package/_esm/utils/address/isAddressEqual.js.map +1 -1
  102. package/_esm/utils/lru.js +24 -0
  103. package/_esm/utils/lru.js.map +1 -0
  104. package/_esm/utils/transaction/parseTransaction.js +1 -1
  105. package/_esm/utils/transaction/parseTransaction.js.map +1 -1
  106. package/_esm/utils/transaction/serializeAccessList.js +1 -1
  107. package/_esm/utils/transaction/serializeAccessList.js.map +1 -1
  108. package/_types/accounts/toAccount.d.ts.map +1 -1
  109. package/_types/actions/public/call.d.ts.map +1 -1
  110. package/_types/chains/definitions/base.d.ts +6 -0
  111. package/_types/chains/definitions/base.d.ts.map +1 -1
  112. package/_types/chains/definitions/baseGoerli.d.ts +5 -0
  113. package/_types/chains/definitions/baseGoerli.d.ts.map +1 -1
  114. package/_types/chains/definitions/baseSepolia.d.ts +6 -0
  115. package/_types/chains/definitions/baseSepolia.d.ts.map +1 -1
  116. package/_types/chains/definitions/etherlinkTestnet.d.ts +35 -0
  117. package/_types/chains/definitions/etherlinkTestnet.d.ts.map +1 -0
  118. package/_types/chains/definitions/kakarotSepolia.d.ts +35 -0
  119. package/_types/chains/definitions/kakarotSepolia.d.ts.map +1 -0
  120. package/_types/chains/definitions/optimism.d.ts +5 -0
  121. package/_types/chains/definitions/optimism.d.ts.map +1 -1
  122. package/_types/chains/definitions/optimismGoerli.d.ts +5 -0
  123. package/_types/chains/definitions/optimismGoerli.d.ts.map +1 -1
  124. package/_types/chains/definitions/optimismSepolia.d.ts +5 -0
  125. package/_types/chains/definitions/optimismSepolia.d.ts.map +1 -1
  126. package/_types/chains/definitions/pgn.d.ts +5 -0
  127. package/_types/chains/definitions/pgn.d.ts.map +1 -1
  128. package/_types/chains/definitions/pgnTestnet.d.ts +10 -0
  129. package/_types/chains/definitions/pgnTestnet.d.ts.map +1 -1
  130. package/_types/chains/definitions/xdc.d.ts +6 -8
  131. package/_types/chains/definitions/xdc.d.ts.map +1 -1
  132. package/_types/chains/definitions/xdcTestnet.d.ts +6 -8
  133. package/_types/chains/definitions/xdcTestnet.d.ts.map +1 -1
  134. package/_types/chains/definitions/zora.d.ts +5 -0
  135. package/_types/chains/definitions/zora.d.ts.map +1 -1
  136. package/_types/chains/definitions/zoraSepolia.d.ts +5 -0
  137. package/_types/chains/definitions/zoraSepolia.d.ts.map +1 -1
  138. package/_types/chains/index.d.ts +2 -0
  139. package/_types/chains/index.d.ts.map +1 -1
  140. package/_types/chains/opStack/abis.d.ts +626 -0
  141. package/_types/chains/opStack/abis.d.ts.map +1 -1
  142. package/_types/clients/decorators/wallet.d.ts +1 -1
  143. package/_types/clients/decorators/wallet.d.ts.map +1 -1
  144. package/_types/errors/address.d.ts.map +1 -1
  145. package/_types/errors/version.d.ts +1 -1
  146. package/_types/errors/version.d.ts.map +1 -1
  147. package/_types/utils/address/isAddress.d.ts +9 -1
  148. package/_types/utils/address/isAddress.d.ts.map +1 -1
  149. package/_types/utils/address/isAddressEqual.d.ts.map +1 -1
  150. package/_types/utils/lru.d.ts +11 -0
  151. package/_types/utils/lru.d.ts.map +1 -0
  152. package/_types/utils/transaction/parseTransaction.d.ts.map +1 -1
  153. package/accounts/toAccount.ts +3 -2
  154. package/actions/public/call.ts +2 -1
  155. package/chains/definitions/base.ts +6 -0
  156. package/chains/definitions/baseGoerli.ts +5 -0
  157. package/chains/definitions/baseSepolia.ts +6 -0
  158. package/chains/definitions/etherlinkTestnet.ts +21 -0
  159. package/chains/definitions/kakarotSepolia.ts +23 -0
  160. package/chains/definitions/optimism.ts +5 -0
  161. package/chains/definitions/optimismGoerli.ts +5 -0
  162. package/chains/definitions/optimismSepolia.ts +5 -0
  163. package/chains/definitions/pgn.ts +5 -0
  164. package/chains/definitions/pgnTestnet.ts +10 -0
  165. package/chains/definitions/xdc.ts +6 -0
  166. package/chains/definitions/xdcTestnet.ts +6 -0
  167. package/chains/definitions/zora.ts +5 -0
  168. package/chains/definitions/zoraSepolia.ts +5 -0
  169. package/chains/index.ts +2 -0
  170. package/chains/opStack/abis.ts +458 -0
  171. package/clients/decorators/wallet.ts +5 -1
  172. package/errors/address.ts +6 -1
  173. package/errors/version.ts +1 -1
  174. package/package.json +1 -1
  175. package/utils/abi/getAbiItem.ts +3 -3
  176. package/utils/address/isAddress.ts +27 -2
  177. package/utils/address/isAddressEqual.ts +4 -2
  178. package/utils/lru.ts +20 -0
  179. package/utils/transaction/parseTransaction.ts +2 -1
  180. package/utils/transaction/serializeAccessList.ts +1 -1
@@ -335,6 +335,464 @@ export const l2OutputOracleAbi = [
335
335
  },
336
336
  ] as const
337
337
 
338
+ export const l1StandardBridgeAbi = [
339
+ { stateMutability: 'nonpayable', type: 'constructor', inputs: [] },
340
+ {
341
+ type: 'event',
342
+ anonymous: false,
343
+ inputs: [
344
+ {
345
+ name: 'localToken',
346
+ internalType: 'address',
347
+ type: 'address',
348
+ indexed: true,
349
+ },
350
+ {
351
+ name: 'remoteToken',
352
+ internalType: 'address',
353
+ type: 'address',
354
+ indexed: true,
355
+ },
356
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
357
+ { name: 'to', internalType: 'address', type: 'address', indexed: false },
358
+ {
359
+ name: 'amount',
360
+ internalType: 'uint256',
361
+ type: 'uint256',
362
+ indexed: false,
363
+ },
364
+ {
365
+ name: 'extraData',
366
+ internalType: 'bytes',
367
+ type: 'bytes',
368
+ indexed: false,
369
+ },
370
+ ],
371
+ name: 'ERC20BridgeFinalized',
372
+ },
373
+ {
374
+ type: 'event',
375
+ anonymous: false,
376
+ inputs: [
377
+ {
378
+ name: 'localToken',
379
+ internalType: 'address',
380
+ type: 'address',
381
+ indexed: true,
382
+ },
383
+ {
384
+ name: 'remoteToken',
385
+ internalType: 'address',
386
+ type: 'address',
387
+ indexed: true,
388
+ },
389
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
390
+ { name: 'to', internalType: 'address', type: 'address', indexed: false },
391
+ {
392
+ name: 'amount',
393
+ internalType: 'uint256',
394
+ type: 'uint256',
395
+ indexed: false,
396
+ },
397
+ {
398
+ name: 'extraData',
399
+ internalType: 'bytes',
400
+ type: 'bytes',
401
+ indexed: false,
402
+ },
403
+ ],
404
+ name: 'ERC20BridgeInitiated',
405
+ },
406
+ {
407
+ type: 'event',
408
+ anonymous: false,
409
+ inputs: [
410
+ {
411
+ name: 'l1Token',
412
+ internalType: 'address',
413
+ type: 'address',
414
+ indexed: true,
415
+ },
416
+ {
417
+ name: 'l2Token',
418
+ internalType: 'address',
419
+ type: 'address',
420
+ indexed: true,
421
+ },
422
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
423
+ { name: 'to', internalType: 'address', type: 'address', indexed: false },
424
+ {
425
+ name: 'amount',
426
+ internalType: 'uint256',
427
+ type: 'uint256',
428
+ indexed: false,
429
+ },
430
+ {
431
+ name: 'extraData',
432
+ internalType: 'bytes',
433
+ type: 'bytes',
434
+ indexed: false,
435
+ },
436
+ ],
437
+ name: 'ERC20DepositInitiated',
438
+ },
439
+ {
440
+ type: 'event',
441
+ anonymous: false,
442
+ inputs: [
443
+ {
444
+ name: 'l1Token',
445
+ internalType: 'address',
446
+ type: 'address',
447
+ indexed: true,
448
+ },
449
+ {
450
+ name: 'l2Token',
451
+ internalType: 'address',
452
+ type: 'address',
453
+ indexed: true,
454
+ },
455
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
456
+ { name: 'to', internalType: 'address', type: 'address', indexed: false },
457
+ {
458
+ name: 'amount',
459
+ internalType: 'uint256',
460
+ type: 'uint256',
461
+ indexed: false,
462
+ },
463
+ {
464
+ name: 'extraData',
465
+ internalType: 'bytes',
466
+ type: 'bytes',
467
+ indexed: false,
468
+ },
469
+ ],
470
+ name: 'ERC20WithdrawalFinalized',
471
+ },
472
+ {
473
+ type: 'event',
474
+ anonymous: false,
475
+ inputs: [
476
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
477
+ { name: 'to', internalType: 'address', type: 'address', indexed: true },
478
+ {
479
+ name: 'amount',
480
+ internalType: 'uint256',
481
+ type: 'uint256',
482
+ indexed: false,
483
+ },
484
+ {
485
+ name: 'extraData',
486
+ internalType: 'bytes',
487
+ type: 'bytes',
488
+ indexed: false,
489
+ },
490
+ ],
491
+ name: 'ETHBridgeFinalized',
492
+ },
493
+ {
494
+ type: 'event',
495
+ anonymous: false,
496
+ inputs: [
497
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
498
+ { name: 'to', internalType: 'address', type: 'address', indexed: true },
499
+ {
500
+ name: 'amount',
501
+ internalType: 'uint256',
502
+ type: 'uint256',
503
+ indexed: false,
504
+ },
505
+ {
506
+ name: 'extraData',
507
+ internalType: 'bytes',
508
+ type: 'bytes',
509
+ indexed: false,
510
+ },
511
+ ],
512
+ name: 'ETHBridgeInitiated',
513
+ },
514
+ {
515
+ type: 'event',
516
+ anonymous: false,
517
+ inputs: [
518
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
519
+ { name: 'to', internalType: 'address', type: 'address', indexed: true },
520
+ {
521
+ name: 'amount',
522
+ internalType: 'uint256',
523
+ type: 'uint256',
524
+ indexed: false,
525
+ },
526
+ {
527
+ name: 'extraData',
528
+ internalType: 'bytes',
529
+ type: 'bytes',
530
+ indexed: false,
531
+ },
532
+ ],
533
+ name: 'ETHDepositInitiated',
534
+ },
535
+ {
536
+ type: 'event',
537
+ anonymous: false,
538
+ inputs: [
539
+ { name: 'from', internalType: 'address', type: 'address', indexed: true },
540
+ { name: 'to', internalType: 'address', type: 'address', indexed: true },
541
+ {
542
+ name: 'amount',
543
+ internalType: 'uint256',
544
+ type: 'uint256',
545
+ indexed: false,
546
+ },
547
+ {
548
+ name: 'extraData',
549
+ internalType: 'bytes',
550
+ type: 'bytes',
551
+ indexed: false,
552
+ },
553
+ ],
554
+ name: 'ETHWithdrawalFinalized',
555
+ },
556
+ {
557
+ type: 'event',
558
+ anonymous: false,
559
+ inputs: [
560
+ { name: 'version', internalType: 'uint8', type: 'uint8', indexed: false },
561
+ ],
562
+ name: 'Initialized',
563
+ },
564
+ {
565
+ stateMutability: 'view',
566
+ type: 'function',
567
+ inputs: [],
568
+ name: 'MESSENGER',
569
+ outputs: [
570
+ {
571
+ name: '',
572
+ internalType: 'contract CrossDomainMessenger',
573
+ type: 'address',
574
+ },
575
+ ],
576
+ },
577
+ {
578
+ stateMutability: 'view',
579
+ type: 'function',
580
+ inputs: [],
581
+ name: 'OTHER_BRIDGE',
582
+ outputs: [
583
+ { name: '', internalType: 'contract StandardBridge', type: 'address' },
584
+ ],
585
+ },
586
+ {
587
+ stateMutability: 'nonpayable',
588
+ type: 'function',
589
+ inputs: [
590
+ { name: '_localToken', internalType: 'address', type: 'address' },
591
+ { name: '_remoteToken', internalType: 'address', type: 'address' },
592
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
593
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
594
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
595
+ ],
596
+ name: 'bridgeERC20',
597
+ outputs: [],
598
+ },
599
+ {
600
+ stateMutability: 'nonpayable',
601
+ type: 'function',
602
+ inputs: [
603
+ { name: '_localToken', internalType: 'address', type: 'address' },
604
+ { name: '_remoteToken', internalType: 'address', type: 'address' },
605
+ { name: '_to', internalType: 'address', type: 'address' },
606
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
607
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
608
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
609
+ ],
610
+ name: 'bridgeERC20To',
611
+ outputs: [],
612
+ },
613
+ {
614
+ stateMutability: 'payable',
615
+ type: 'function',
616
+ inputs: [
617
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
618
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
619
+ ],
620
+ name: 'bridgeETH',
621
+ outputs: [],
622
+ },
623
+ {
624
+ stateMutability: 'payable',
625
+ type: 'function',
626
+ inputs: [
627
+ { name: '_to', internalType: 'address', type: 'address' },
628
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
629
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
630
+ ],
631
+ name: 'bridgeETHTo',
632
+ outputs: [],
633
+ },
634
+ {
635
+ stateMutability: 'nonpayable',
636
+ type: 'function',
637
+ inputs: [
638
+ { name: '_l1Token', internalType: 'address', type: 'address' },
639
+ { name: '_l2Token', internalType: 'address', type: 'address' },
640
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
641
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
642
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
643
+ ],
644
+ name: 'depositERC20',
645
+ outputs: [],
646
+ },
647
+ {
648
+ stateMutability: 'nonpayable',
649
+ type: 'function',
650
+ inputs: [
651
+ { name: '_l1Token', internalType: 'address', type: 'address' },
652
+ { name: '_l2Token', internalType: 'address', type: 'address' },
653
+ { name: '_to', internalType: 'address', type: 'address' },
654
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
655
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
656
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
657
+ ],
658
+ name: 'depositERC20To',
659
+ outputs: [],
660
+ },
661
+ {
662
+ stateMutability: 'payable',
663
+ type: 'function',
664
+ inputs: [
665
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
666
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
667
+ ],
668
+ name: 'depositETH',
669
+ outputs: [],
670
+ },
671
+ {
672
+ stateMutability: 'payable',
673
+ type: 'function',
674
+ inputs: [
675
+ { name: '_to', internalType: 'address', type: 'address' },
676
+ { name: '_minGasLimit', internalType: 'uint32', type: 'uint32' },
677
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
678
+ ],
679
+ name: 'depositETHTo',
680
+ outputs: [],
681
+ },
682
+ {
683
+ stateMutability: 'view',
684
+ type: 'function',
685
+ inputs: [
686
+ { name: '', internalType: 'address', type: 'address' },
687
+ { name: '', internalType: 'address', type: 'address' },
688
+ ],
689
+ name: 'deposits',
690
+ outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
691
+ },
692
+ {
693
+ stateMutability: 'nonpayable',
694
+ type: 'function',
695
+ inputs: [
696
+ { name: '_localToken', internalType: 'address', type: 'address' },
697
+ { name: '_remoteToken', internalType: 'address', type: 'address' },
698
+ { name: '_from', internalType: 'address', type: 'address' },
699
+ { name: '_to', internalType: 'address', type: 'address' },
700
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
701
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
702
+ ],
703
+ name: 'finalizeBridgeERC20',
704
+ outputs: [],
705
+ },
706
+ {
707
+ stateMutability: 'payable',
708
+ type: 'function',
709
+ inputs: [
710
+ { name: '_from', internalType: 'address', type: 'address' },
711
+ { name: '_to', internalType: 'address', type: 'address' },
712
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
713
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
714
+ ],
715
+ name: 'finalizeBridgeETH',
716
+ outputs: [],
717
+ },
718
+ {
719
+ stateMutability: 'nonpayable',
720
+ type: 'function',
721
+ inputs: [
722
+ { name: '_l1Token', internalType: 'address', type: 'address' },
723
+ { name: '_l2Token', internalType: 'address', type: 'address' },
724
+ { name: '_from', internalType: 'address', type: 'address' },
725
+ { name: '_to', internalType: 'address', type: 'address' },
726
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
727
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
728
+ ],
729
+ name: 'finalizeERC20Withdrawal',
730
+ outputs: [],
731
+ },
732
+ {
733
+ stateMutability: 'payable',
734
+ type: 'function',
735
+ inputs: [
736
+ { name: '_from', internalType: 'address', type: 'address' },
737
+ { name: '_to', internalType: 'address', type: 'address' },
738
+ { name: '_amount', internalType: 'uint256', type: 'uint256' },
739
+ { name: '_extraData', internalType: 'bytes', type: 'bytes' },
740
+ ],
741
+ name: 'finalizeETHWithdrawal',
742
+ outputs: [],
743
+ },
744
+ {
745
+ stateMutability: 'nonpayable',
746
+ type: 'function',
747
+ inputs: [
748
+ {
749
+ name: '_messenger',
750
+ internalType: 'contract CrossDomainMessenger',
751
+ type: 'address',
752
+ },
753
+ ],
754
+ name: 'initialize',
755
+ outputs: [],
756
+ },
757
+ {
758
+ stateMutability: 'view',
759
+ type: 'function',
760
+ inputs: [],
761
+ name: 'l2TokenBridge',
762
+ outputs: [{ name: '', internalType: 'address', type: 'address' }],
763
+ },
764
+ {
765
+ stateMutability: 'view',
766
+ type: 'function',
767
+ inputs: [],
768
+ name: 'messenger',
769
+ outputs: [
770
+ {
771
+ name: '',
772
+ internalType: 'contract CrossDomainMessenger',
773
+ type: 'address',
774
+ },
775
+ ],
776
+ },
777
+ {
778
+ stateMutability: 'view',
779
+ type: 'function',
780
+ inputs: [],
781
+ name: 'otherBridge',
782
+ outputs: [
783
+ { name: '', internalType: 'contract StandardBridge', type: 'address' },
784
+ ],
785
+ },
786
+ {
787
+ stateMutability: 'view',
788
+ type: 'function',
789
+ inputs: [],
790
+ name: 'version',
791
+ outputs: [{ name: '', internalType: 'string', type: 'string' }],
792
+ },
793
+ { stateMutability: 'payable', type: 'receive' },
794
+ ] as const
795
+
338
796
  export const l2ToL1MessagePasserAbi = [
339
797
  { inputs: [], stateMutability: 'nonpayable', type: 'constructor' },
340
798
  {
@@ -663,7 +663,11 @@ export type WalletActions<
663
663
  writeContract: <
664
664
  const abi extends Abi | readonly unknown[],
665
665
  functionName extends ContractFunctionName<abi, 'payable' | 'nonpayable'>,
666
- args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,
666
+ args extends ContractFunctionArgs<
667
+ abi,
668
+ 'payable' | 'nonpayable',
669
+ functionName
670
+ >,
667
671
  TChainOverride extends Chain | undefined = undefined,
668
672
  >(
669
673
  args: WriteContractParameters<
package/errors/address.ts CHANGED
@@ -6,6 +6,11 @@ export type InvalidAddressErrorType = InvalidAddressError & {
6
6
  export class InvalidAddressError extends BaseError {
7
7
  override name = 'InvalidAddressError'
8
8
  constructor({ address }: { address: string }) {
9
- super(`Address "${address}" is invalid.`)
9
+ super(`Address "${address}" is invalid.`, {
10
+ metaMessages: [
11
+ '- Address must be a hex value of 20 bytes (40 hex characters).',
12
+ '- Address must match its checksum counterpart.',
13
+ ],
14
+ })
10
15
  }
11
16
  }
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.7.8'
1
+ export const version = '2.7.10'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.7.8",
4
+ "version": "2.7.10",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -155,7 +155,7 @@ export function isArgOfType(arg: unknown, abiParameter: AbiParameter): boolean {
155
155
  const abiParameterType = abiParameter.type
156
156
  switch (abiParameterType) {
157
157
  case 'address':
158
- return isAddress(arg as Address)
158
+ return isAddress(arg as Address, { strict: false })
159
159
  case 'bool':
160
160
  return argType === 'boolean'
161
161
  case 'function':
@@ -233,9 +233,9 @@ export function getAmbiguousTypes(
233
233
  const ambiguous = (() => {
234
234
  if (types.includes('address') && types.includes('bytes20')) return true
235
235
  if (types.includes('address') && types.includes('string'))
236
- return isAddress(args[parameterIndex] as Address)
236
+ return isAddress(args[parameterIndex] as Address, { strict: false })
237
237
  if (types.includes('address') && types.includes('bytes'))
238
- return isAddress(args[parameterIndex] as Address)
238
+ return isAddress(args[parameterIndex] as Address, { strict: false })
239
239
  return false
240
240
  })()
241
241
 
@@ -1,10 +1,35 @@
1
1
  import type { Address } from 'abitype'
2
2
  import type { ErrorType } from '../../errors/utils.js'
3
+ import { LruMap } from '../lru.js'
4
+ import { checksumAddress } from './getAddress.js'
3
5
 
4
6
  const addressRegex = /^0x[a-fA-F0-9]{40}$/
5
7
 
8
+ const isAddressCache = /*#__PURE__*/ new LruMap<boolean>(8192)
9
+
10
+ export type IsAddressOptions = {
11
+ /**
12
+ * Enables strict mode. Whether or not to compare the address against its checksum.
13
+ *
14
+ * @default true
15
+ */
16
+ strict?: boolean
17
+ }
18
+
6
19
  export type IsAddressErrorType = ErrorType
7
20
 
8
- export function isAddress(address: string): address is Address {
9
- return addressRegex.test(address)
21
+ export function isAddress(
22
+ address: string,
23
+ { strict = true }: IsAddressOptions = {},
24
+ ): address is Address {
25
+ if (isAddressCache.has(address)) return isAddressCache.get(address)!
26
+
27
+ const result = (() => {
28
+ if (!addressRegex.test(address)) return false
29
+ if (address.toLowerCase() === address) return true
30
+ if (strict) return checksumAddress(address as Address) === address
31
+ return true
32
+ })()
33
+ isAddressCache.set(address, result)
34
+ return result
10
35
  }
@@ -11,7 +11,9 @@ export type IsAddressEqualReturnType = boolean
11
11
  export type IsAddressEqualErrorType = InvalidAddressErrorType | ErrorType
12
12
 
13
13
  export function isAddressEqual(a: Address, b: Address) {
14
- if (!isAddress(a)) throw new InvalidAddressError({ address: a })
15
- if (!isAddress(b)) throw new InvalidAddressError({ address: b })
14
+ if (!isAddress(a, { strict: false }))
15
+ throw new InvalidAddressError({ address: a })
16
+ if (!isAddress(b, { strict: false }))
17
+ throw new InvalidAddressError({ address: b })
16
18
  return a.toLowerCase() === b.toLowerCase()
17
19
  }
package/utils/lru.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Map with a LRU (Least recently used) policy.
3
+ *
4
+ * @link https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU
5
+ */
6
+ export class LruMap<value = unknown> extends Map<string, value> {
7
+ maxSize: number
8
+
9
+ constructor(size: number) {
10
+ super()
11
+ this.maxSize = size
12
+ }
13
+
14
+ override set(key: string, value: value) {
15
+ super.set(key, value)
16
+ if (this.maxSize && this.size > this.maxSize)
17
+ this.delete(this.keys().next().value)
18
+ return this
19
+ }
20
+ }
@@ -326,7 +326,8 @@ export function parseAccessList(accessList_: RecursiveArray<Hex>): AccessList {
326
326
  for (let i = 0; i < accessList_.length; i++) {
327
327
  const [address, storageKeys] = accessList_[i] as [Hex, Hex[]]
328
328
 
329
- if (!isAddress(address)) throw new InvalidAddressError({ address })
329
+ if (!isAddress(address, { strict: false }))
330
+ throw new InvalidAddressError({ address })
330
331
 
331
332
  accessList.push({
332
333
  address: address,
@@ -42,7 +42,7 @@ export function serializeAccessList(
42
42
  }
43
43
  }
44
44
 
45
- if (!isAddress(address)) {
45
+ if (!isAddress(address, { strict: false })) {
46
46
  throw new InvalidAddressError({ address })
47
47
  }
48
48