@matterlabs/zksync-js 0.0.8 → 0.0.9

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 (74) hide show
  1. package/dist/adapters/ethers/client.cjs +1640 -236
  2. package/dist/adapters/ethers/client.cjs.map +1 -1
  3. package/dist/adapters/ethers/client.d.ts +11 -0
  4. package/dist/adapters/ethers/client.js +5 -5
  5. package/dist/adapters/ethers/index.cjs +4395 -1525
  6. package/dist/adapters/ethers/index.cjs.map +1 -1
  7. package/dist/adapters/ethers/index.d.ts +4 -0
  8. package/dist/adapters/ethers/index.js +8 -8
  9. package/dist/adapters/ethers/resources/contracts/types.d.ts +15 -0
  10. package/dist/adapters/ethers/resources/deposits/context.d.ts +3 -3
  11. package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +2 -2
  12. package/dist/adapters/ethers/resources/deposits/services/verification.d.ts +1 -1
  13. package/dist/adapters/ethers/resources/interop/address.d.ts +18 -0
  14. package/dist/adapters/ethers/resources/interop/attributes/resource.d.ts +9 -0
  15. package/dist/adapters/ethers/resources/interop/context.d.ts +36 -0
  16. package/dist/adapters/ethers/resources/interop/index.d.ts +63 -0
  17. package/dist/adapters/ethers/resources/interop/resolvers.d.ts +9 -0
  18. package/dist/adapters/ethers/resources/interop/routes/direct.d.ts +2 -0
  19. package/dist/adapters/ethers/resources/interop/routes/indirect.d.ts +2 -0
  20. package/dist/adapters/ethers/resources/interop/routes/types.d.ts +13 -0
  21. package/dist/adapters/ethers/resources/interop/services/erc20.d.ts +15 -0
  22. package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +15 -0
  23. package/dist/adapters/ethers/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
  24. package/dist/adapters/ethers/resources/interop/services/finalization/decoders.d.ts +12 -0
  25. package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +13 -0
  26. package/dist/adapters/ethers/resources/interop/services/finalization/polling.d.ts +7 -0
  27. package/dist/adapters/ethers/resources/interop/services/finalization/status.d.ts +5 -0
  28. package/dist/adapters/ethers/resources/interop/services/finalization/topics.d.ts +6 -0
  29. package/dist/adapters/ethers/resources/interop/services/starter-data.d.ts +6 -0
  30. package/dist/adapters/ethers/resources/interop/types.d.ts +16 -0
  31. package/dist/adapters/ethers/resources/withdrawals/context.d.ts +2 -2
  32. package/dist/adapters/ethers/sdk.cjs +3357 -917
  33. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  34. package/dist/adapters/ethers/sdk.d.ts +10 -8
  35. package/dist/adapters/ethers/sdk.js +6 -6
  36. package/dist/adapters/viem/client.cjs +685 -31
  37. package/dist/adapters/viem/client.cjs.map +1 -1
  38. package/dist/adapters/viem/client.js +5 -3
  39. package/dist/adapters/viem/index.cjs +282 -203
  40. package/dist/adapters/viem/index.cjs.map +1 -1
  41. package/dist/adapters/viem/index.d.ts +1 -0
  42. package/dist/adapters/viem/index.js +8 -7
  43. package/dist/adapters/viem/resources/deposits/context.d.ts +3 -3
  44. package/dist/adapters/viem/resources/deposits/services/gas.d.ts +2 -2
  45. package/dist/adapters/viem/resources/deposits/services/verification.d.ts +1 -1
  46. package/dist/adapters/viem/resources/withdrawals/context.d.ts +2 -2
  47. package/dist/adapters/viem/sdk.cjs +39 -58
  48. package/dist/adapters/viem/sdk.cjs.map +1 -1
  49. package/dist/adapters/viem/sdk.js +5 -5
  50. package/dist/{chunk-LNIEQ7AN.js → chunk-5AG6B7UX.js} +36 -60
  51. package/dist/{chunk-NODVRI3E.js → chunk-AIFHAPJC.js} +8 -2
  52. package/dist/{chunk-3GFCAGGI.js → chunk-FBKBF7YM.js} +1533 -1434
  53. package/dist/{chunk-L343N56B.js → chunk-IYEDEUXG.js} +1 -1
  54. package/dist/chunk-JNWHQJU3.js +209 -0
  55. package/dist/{chunk-ODMBZ2VX.js → chunk-KLNFDFLA.js} +42 -31
  56. package/dist/{chunk-NVULC4JB.js → chunk-QDJOEVGJ.js} +2 -2
  57. package/dist/{chunk-63DNJXS3.js → chunk-RRKVUW3G.js} +1375 -75
  58. package/dist/{chunk-5V2JRM5J.js → chunk-SRPKTXIF.js} +1 -1
  59. package/dist/{chunk-SHQQI3UD.js → chunk-UIXU35ZU.js} +1 -1
  60. package/dist/{chunk-QZVYN3YA.js → chunk-ZVHFVUDE.js} +2 -37
  61. package/dist/core/index.cjs +3 -2
  62. package/dist/core/index.cjs.map +1 -1
  63. package/dist/core/index.js +4 -4
  64. package/dist/core/resources/interop/attributes/types.d.ts +0 -2
  65. package/dist/core/resources/interop/finalization.d.ts +0 -1
  66. package/dist/core/types/errors.d.ts +15 -5
  67. package/dist/core/types/fees.d.ts +9 -0
  68. package/dist/core/types/flows/interop.d.ts +12 -36
  69. package/dist/core/types/primitives.d.ts +1 -0
  70. package/dist/index.cjs +3 -2
  71. package/dist/index.cjs.map +1 -1
  72. package/dist/index.js +4 -4
  73. package/package.json +1 -1
  74. package/dist/chunk-FGXRG2JS.js +0 -142
@@ -3,6 +3,7 @@
3
3
  var viem = require('viem');
4
4
  var sha3 = require('@noble/hashes/sha3');
5
5
  var utils = require('@noble/hashes/utils');
6
+ var ethers = require('ethers');
6
7
 
7
8
  // src/adapters/viem/client.ts
8
9
 
@@ -149,13 +150,16 @@ if (kInspect) {
149
150
  enumerable: false
150
151
  });
151
152
  }
152
- function isZKsyncError(e) {
153
+ function isZKsyncError(e, opts) {
153
154
  if (!e || typeof e !== "object") return false;
154
155
  const maybe = e;
155
156
  if (!("envelope" in maybe)) return false;
156
157
  const envelope = maybe.envelope;
157
- return typeof envelope?.type === "string" && typeof envelope?.message === "string";
158
+ if (typeof envelope?.type !== "string" || typeof envelope?.message !== "string") return false;
159
+ return true;
158
160
  }
161
+ var OP_CLIENT = {
162
+ ensureAddresses: "client.ensureAddresses"};
159
163
 
160
164
  // src/core/errors/factory.ts
161
165
  function createError(type, input) {
@@ -4578,7 +4582,648 @@ var IBaseTokenABI = [
4578
4582
  ];
4579
4583
  var IBaseToken_default = IBaseTokenABI;
4580
4584
 
4585
+ // src/core/internal/abis/IERC20.ts
4586
+ var IERC20ABI = [
4587
+ {
4588
+ type: "constructor",
4589
+ inputs: [
4590
+ { name: "_name", type: "string", internalType: "string" },
4591
+ { name: "_symbol", type: "string", internalType: "string" },
4592
+ { name: "_decimals", type: "uint8", internalType: "uint8" }
4593
+ ],
4594
+ stateMutability: "nonpayable"
4595
+ },
4596
+ {
4597
+ type: "function",
4598
+ name: "allowance",
4599
+ inputs: [
4600
+ { name: "", type: "address", internalType: "address" },
4601
+ { name: "", type: "address", internalType: "address" }
4602
+ ],
4603
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
4604
+ stateMutability: "view"
4605
+ },
4606
+ {
4607
+ type: "function",
4608
+ name: "approve",
4609
+ inputs: [
4610
+ { name: "spender", type: "address", internalType: "address" },
4611
+ { name: "amount", type: "uint256", internalType: "uint256" }
4612
+ ],
4613
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4614
+ stateMutability: "nonpayable"
4615
+ },
4616
+ {
4617
+ type: "function",
4618
+ name: "balanceOf",
4619
+ inputs: [{ name: "", type: "address", internalType: "address" }],
4620
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
4621
+ stateMutability: "view"
4622
+ },
4623
+ {
4624
+ type: "function",
4625
+ name: "decimals",
4626
+ inputs: [],
4627
+ outputs: [{ name: "", type: "uint8", internalType: "uint8" }],
4628
+ stateMutability: "view"
4629
+ },
4630
+ {
4631
+ type: "function",
4632
+ name: "mint",
4633
+ inputs: [
4634
+ { name: "to", type: "address", internalType: "address" },
4635
+ { name: "amount", type: "uint256", internalType: "uint256" }
4636
+ ],
4637
+ outputs: [],
4638
+ stateMutability: "nonpayable"
4639
+ },
4640
+ {
4641
+ type: "function",
4642
+ name: "name",
4643
+ inputs: [],
4644
+ outputs: [{ name: "", type: "string", internalType: "string" }],
4645
+ stateMutability: "view"
4646
+ },
4647
+ {
4648
+ type: "function",
4649
+ name: "owner",
4650
+ inputs: [],
4651
+ outputs: [{ name: "", type: "address", internalType: "address" }],
4652
+ stateMutability: "view"
4653
+ },
4654
+ {
4655
+ type: "function",
4656
+ name: "symbol",
4657
+ inputs: [],
4658
+ outputs: [{ name: "", type: "string", internalType: "string" }],
4659
+ stateMutability: "view"
4660
+ },
4661
+ {
4662
+ type: "function",
4663
+ name: "totalSupply",
4664
+ inputs: [],
4665
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
4666
+ stateMutability: "view"
4667
+ },
4668
+ {
4669
+ type: "function",
4670
+ name: "transfer",
4671
+ inputs: [
4672
+ { name: "to", type: "address", internalType: "address" },
4673
+ { name: "amount", type: "uint256", internalType: "uint256" }
4674
+ ],
4675
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4676
+ stateMutability: "nonpayable"
4677
+ },
4678
+ {
4679
+ type: "function",
4680
+ name: "transferFrom",
4681
+ inputs: [
4682
+ { name: "from", type: "address", internalType: "address" },
4683
+ { name: "to", type: "address", internalType: "address" },
4684
+ { name: "amount", type: "uint256", internalType: "uint256" }
4685
+ ],
4686
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4687
+ stateMutability: "nonpayable"
4688
+ },
4689
+ {
4690
+ type: "event",
4691
+ name: "Approval",
4692
+ inputs: [
4693
+ { name: "owner", type: "address", indexed: true, internalType: "address" },
4694
+ { name: "spender", type: "address", indexed: true, internalType: "address" },
4695
+ { name: "value", type: "uint256", indexed: false, internalType: "uint256" }
4696
+ ],
4697
+ anonymous: false
4698
+ },
4699
+ {
4700
+ type: "event",
4701
+ name: "Transfer",
4702
+ inputs: [
4703
+ { name: "from", type: "address", indexed: true, internalType: "address" },
4704
+ { name: "to", type: "address", indexed: true, internalType: "address" },
4705
+ { name: "value", type: "uint256", indexed: false, internalType: "uint256" }
4706
+ ],
4707
+ anonymous: false
4708
+ },
4709
+ { type: "error", name: "InsufficientAllowance", inputs: [] },
4710
+ { type: "error", name: "InsufficientBalance", inputs: [] },
4711
+ { type: "error", name: "NotOwner", inputs: [] }
4712
+ ];
4713
+ var IERC20_default = IERC20ABI;
4714
+
4715
+ // src/core/internal/abis/Mailbox.ts
4716
+ var MailboxABI = [
4717
+ {
4718
+ type: "constructor",
4719
+ inputs: [
4720
+ { name: "_eraChainId", type: "uint256", internalType: "uint256" },
4721
+ { name: "_l1ChainId", type: "uint256", internalType: "uint256" }
4722
+ ],
4723
+ stateMutability: "nonpayable"
4724
+ },
4725
+ {
4726
+ type: "function",
4727
+ name: "bridgehubRequestL2Transaction",
4728
+ inputs: [
4729
+ {
4730
+ name: "_request",
4731
+ type: "tuple",
4732
+ internalType: "struct BridgehubL2TransactionRequest",
4733
+ components: [
4734
+ { name: "sender", type: "address", internalType: "address" },
4735
+ { name: "contractL2", type: "address", internalType: "address" },
4736
+ { name: "mintValue", type: "uint256", internalType: "uint256" },
4737
+ { name: "l2Value", type: "uint256", internalType: "uint256" },
4738
+ { name: "l2Calldata", type: "bytes", internalType: "bytes" },
4739
+ { name: "l2GasLimit", type: "uint256", internalType: "uint256" },
4740
+ { name: "l2GasPerPubdataByteLimit", type: "uint256", internalType: "uint256" },
4741
+ { name: "factoryDeps", type: "bytes[]", internalType: "bytes[]" },
4742
+ { name: "refundRecipient", type: "address", internalType: "address" }
4743
+ ]
4744
+ }
4745
+ ],
4746
+ outputs: [{ name: "canonicalTxHash", type: "bytes32", internalType: "bytes32" }],
4747
+ stateMutability: "nonpayable"
4748
+ },
4749
+ {
4750
+ type: "function",
4751
+ name: "bridgehubRequestL2TransactionOnGateway",
4752
+ inputs: [
4753
+ { name: "_canonicalTxHash", type: "bytes32", internalType: "bytes32" },
4754
+ { name: "_expirationTimestamp", type: "uint64", internalType: "uint64" }
4755
+ ],
4756
+ outputs: [],
4757
+ stateMutability: "nonpayable"
4758
+ },
4759
+ {
4760
+ type: "function",
4761
+ name: "finalizeEthWithdrawal",
4762
+ inputs: [
4763
+ { name: "_l2BatchNumber", type: "uint256", internalType: "uint256" },
4764
+ { name: "_l2MessageIndex", type: "uint256", internalType: "uint256" },
4765
+ { name: "_l2TxNumberInBatch", type: "uint16", internalType: "uint16" },
4766
+ { name: "_message", type: "bytes", internalType: "bytes" },
4767
+ { name: "_merkleProof", type: "bytes32[]", internalType: "bytes32[]" }
4768
+ ],
4769
+ outputs: [],
4770
+ stateMutability: "nonpayable"
4771
+ },
4772
+ {
4773
+ type: "function",
4774
+ name: "getName",
4775
+ inputs: [],
4776
+ outputs: [{ name: "", type: "string", internalType: "string" }],
4777
+ stateMutability: "view"
4778
+ },
4779
+ {
4780
+ type: "function",
4781
+ name: "l2TransactionBaseCost",
4782
+ inputs: [
4783
+ { name: "_gasPrice", type: "uint256", internalType: "uint256" },
4784
+ { name: "_l2GasLimit", type: "uint256", internalType: "uint256" },
4785
+ { name: "_l2GasPerPubdataByteLimit", type: "uint256", internalType: "uint256" }
4786
+ ],
4787
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
4788
+ stateMutability: "view"
4789
+ },
4790
+ {
4791
+ type: "function",
4792
+ name: "proveL1ToL2TransactionStatus",
4793
+ inputs: [
4794
+ { name: "_l2TxHash", type: "bytes32", internalType: "bytes32" },
4795
+ { name: "_l2BatchNumber", type: "uint256", internalType: "uint256" },
4796
+ { name: "_l2MessageIndex", type: "uint256", internalType: "uint256" },
4797
+ { name: "_l2TxNumberInBatch", type: "uint16", internalType: "uint16" },
4798
+ { name: "_merkleProof", type: "bytes32[]", internalType: "bytes32[]" },
4799
+ { name: "_status", type: "uint8", internalType: "enum TxStatus" }
4800
+ ],
4801
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4802
+ stateMutability: "view"
4803
+ },
4804
+ {
4805
+ type: "function",
4806
+ name: "proveL2LeafInclusion",
4807
+ inputs: [
4808
+ { name: "_batchNumber", type: "uint256", internalType: "uint256" },
4809
+ { name: "_leafProofMask", type: "uint256", internalType: "uint256" },
4810
+ { name: "_leaf", type: "bytes32", internalType: "bytes32" },
4811
+ { name: "_proof", type: "bytes32[]", internalType: "bytes32[]" }
4812
+ ],
4813
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4814
+ stateMutability: "view"
4815
+ },
4816
+ {
4817
+ type: "function",
4818
+ name: "proveL2LeafInclusionShared",
4819
+ inputs: [
4820
+ { name: "_chainId", type: "uint256", internalType: "uint256" },
4821
+ { name: "_blockOrBatchNumber", type: "uint256", internalType: "uint256" },
4822
+ { name: "_leafProofMask", type: "uint256", internalType: "uint256" },
4823
+ { name: "_leaf", type: "bytes32", internalType: "bytes32" },
4824
+ { name: "_proof", type: "bytes32[]", internalType: "bytes32[]" }
4825
+ ],
4826
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4827
+ stateMutability: "view"
4828
+ },
4829
+ {
4830
+ type: "function",
4831
+ name: "proveL2LogInclusion",
4832
+ inputs: [
4833
+ { name: "_batchNumber", type: "uint256", internalType: "uint256" },
4834
+ { name: "_index", type: "uint256", internalType: "uint256" },
4835
+ {
4836
+ name: "_log",
4837
+ type: "tuple",
4838
+ internalType: "struct L2Log",
4839
+ components: [
4840
+ { name: "l2ShardId", type: "uint8", internalType: "uint8" },
4841
+ { name: "isService", type: "bool", internalType: "bool" },
4842
+ { name: "txNumberInBatch", type: "uint16", internalType: "uint16" },
4843
+ { name: "sender", type: "address", internalType: "address" },
4844
+ { name: "key", type: "bytes32", internalType: "bytes32" },
4845
+ { name: "value", type: "bytes32", internalType: "bytes32" }
4846
+ ]
4847
+ },
4848
+ { name: "_proof", type: "bytes32[]", internalType: "bytes32[]" }
4849
+ ],
4850
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4851
+ stateMutability: "view"
4852
+ },
4853
+ {
4854
+ type: "function",
4855
+ name: "proveL2LogInclusionShared",
4856
+ inputs: [
4857
+ { name: "_chainId", type: "uint256", internalType: "uint256" },
4858
+ { name: "_blockOrBatchNumber", type: "uint256", internalType: "uint256" },
4859
+ { name: "_index", type: "uint256", internalType: "uint256" },
4860
+ {
4861
+ name: "_log",
4862
+ type: "tuple",
4863
+ internalType: "struct L2Log",
4864
+ components: [
4865
+ { name: "l2ShardId", type: "uint8", internalType: "uint8" },
4866
+ { name: "isService", type: "bool", internalType: "bool" },
4867
+ { name: "txNumberInBatch", type: "uint16", internalType: "uint16" },
4868
+ { name: "sender", type: "address", internalType: "address" },
4869
+ { name: "key", type: "bytes32", internalType: "bytes32" },
4870
+ { name: "value", type: "bytes32", internalType: "bytes32" }
4871
+ ]
4872
+ },
4873
+ { name: "_proof", type: "bytes32[]", internalType: "bytes32[]" }
4874
+ ],
4875
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4876
+ stateMutability: "view"
4877
+ },
4878
+ {
4879
+ type: "function",
4880
+ name: "proveL2MessageInclusion",
4881
+ inputs: [
4882
+ { name: "_batchNumber", type: "uint256", internalType: "uint256" },
4883
+ { name: "_index", type: "uint256", internalType: "uint256" },
4884
+ {
4885
+ name: "_message",
4886
+ type: "tuple",
4887
+ internalType: "struct L2Message",
4888
+ components: [
4889
+ { name: "txNumberInBatch", type: "uint16", internalType: "uint16" },
4890
+ { name: "sender", type: "address", internalType: "address" },
4891
+ { name: "data", type: "bytes", internalType: "bytes" }
4892
+ ]
4893
+ },
4894
+ { name: "_proof", type: "bytes32[]", internalType: "bytes32[]" }
4895
+ ],
4896
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4897
+ stateMutability: "view"
4898
+ },
4899
+ {
4900
+ type: "function",
4901
+ name: "proveL2MessageInclusionShared",
4902
+ inputs: [
4903
+ { name: "_chainId", type: "uint256", internalType: "uint256" },
4904
+ { name: "_blockOrBatchNumber", type: "uint256", internalType: "uint256" },
4905
+ { name: "_index", type: "uint256", internalType: "uint256" },
4906
+ {
4907
+ name: "_message",
4908
+ type: "tuple",
4909
+ internalType: "struct L2Message",
4910
+ components: [
4911
+ { name: "txNumberInBatch", type: "uint16", internalType: "uint16" },
4912
+ { name: "sender", type: "address", internalType: "address" },
4913
+ { name: "data", type: "bytes", internalType: "bytes" }
4914
+ ]
4915
+ },
4916
+ { name: "_proof", type: "bytes32[]", internalType: "bytes32[]" }
4917
+ ],
4918
+ outputs: [{ name: "", type: "bool", internalType: "bool" }],
4919
+ stateMutability: "view"
4920
+ },
4921
+ {
4922
+ type: "function",
4923
+ name: "requestL2ServiceTransaction",
4924
+ inputs: [
4925
+ { name: "_contractL2", type: "address", internalType: "address" },
4926
+ { name: "_l2Calldata", type: "bytes", internalType: "bytes" }
4927
+ ],
4928
+ outputs: [{ name: "canonicalTxHash", type: "bytes32", internalType: "bytes32" }],
4929
+ stateMutability: "nonpayable"
4930
+ },
4931
+ {
4932
+ type: "function",
4933
+ name: "requestL2Transaction",
4934
+ inputs: [
4935
+ { name: "_contractL2", type: "address", internalType: "address" },
4936
+ { name: "_l2Value", type: "uint256", internalType: "uint256" },
4937
+ { name: "_calldata", type: "bytes", internalType: "bytes" },
4938
+ { name: "_l2GasLimit", type: "uint256", internalType: "uint256" },
4939
+ { name: "_l2GasPerPubdataByteLimit", type: "uint256", internalType: "uint256" },
4940
+ { name: "_factoryDeps", type: "bytes[]", internalType: "bytes[]" },
4941
+ { name: "_refundRecipient", type: "address", internalType: "address" }
4942
+ ],
4943
+ outputs: [{ name: "canonicalTxHash", type: "bytes32", internalType: "bytes32" }],
4944
+ stateMutability: "payable"
4945
+ },
4946
+ {
4947
+ type: "function",
4948
+ name: "requestL2TransactionToGatewayMailbox",
4949
+ inputs: [
4950
+ { name: "_chainId", type: "uint256", internalType: "uint256" },
4951
+ { name: "_canonicalTxHash", type: "bytes32", internalType: "bytes32" },
4952
+ { name: "_expirationTimestamp", type: "uint64", internalType: "uint64" }
4953
+ ],
4954
+ outputs: [{ name: "canonicalTxHash", type: "bytes32", internalType: "bytes32" }],
4955
+ stateMutability: "nonpayable"
4956
+ },
4957
+ {
4958
+ type: "event",
4959
+ name: "NewPriorityRequest",
4960
+ inputs: [
4961
+ { name: "txId", type: "uint256", indexed: false, internalType: "uint256" },
4962
+ { name: "txHash", type: "bytes32", indexed: false, internalType: "bytes32" },
4963
+ {
4964
+ name: "expirationTimestamp",
4965
+ type: "uint64",
4966
+ indexed: false,
4967
+ internalType: "uint64"
4968
+ },
4969
+ {
4970
+ name: "transaction",
4971
+ type: "tuple",
4972
+ indexed: false,
4973
+ internalType: "struct L2CanonicalTransaction",
4974
+ components: [
4975
+ { name: "txType", type: "uint256", internalType: "uint256" },
4976
+ { name: "from", type: "uint256", internalType: "uint256" },
4977
+ { name: "to", type: "uint256", internalType: "uint256" },
4978
+ { name: "gasLimit", type: "uint256", internalType: "uint256" },
4979
+ { name: "gasPerPubdataByteLimit", type: "uint256", internalType: "uint256" },
4980
+ { name: "maxFeePerGas", type: "uint256", internalType: "uint256" },
4981
+ { name: "maxPriorityFeePerGas", type: "uint256", internalType: "uint256" },
4982
+ { name: "paymaster", type: "uint256", internalType: "uint256" },
4983
+ { name: "nonce", type: "uint256", internalType: "uint256" },
4984
+ { name: "value", type: "uint256", internalType: "uint256" },
4985
+ { name: "reserved", type: "uint256[4]", internalType: "uint256[4]" },
4986
+ { name: "data", type: "bytes", internalType: "bytes" },
4987
+ { name: "signature", type: "bytes", internalType: "bytes" },
4988
+ { name: "factoryDeps", type: "uint256[]", internalType: "uint256[]" },
4989
+ { name: "paymasterInput", type: "bytes", internalType: "bytes" },
4990
+ { name: "reservedDynamic", type: "bytes", internalType: "bytes" }
4991
+ ]
4992
+ },
4993
+ { name: "factoryDeps", type: "bytes[]", indexed: false, internalType: "bytes[]" }
4994
+ ],
4995
+ anonymous: false
4996
+ },
4997
+ {
4998
+ type: "event",
4999
+ name: "NewPriorityRequestId",
5000
+ inputs: [
5001
+ { name: "txId", type: "uint256", indexed: true, internalType: "uint256" },
5002
+ { name: "txHash", type: "bytes32", indexed: true, internalType: "bytes32" }
5003
+ ],
5004
+ anonymous: false
5005
+ },
5006
+ {
5007
+ type: "event",
5008
+ name: "NewRelayedPriorityTransaction",
5009
+ inputs: [
5010
+ { name: "txId", type: "uint256", indexed: false, internalType: "uint256" },
5011
+ { name: "txHash", type: "bytes32", indexed: false, internalType: "bytes32" },
5012
+ {
5013
+ name: "expirationTimestamp",
5014
+ type: "uint64",
5015
+ indexed: false,
5016
+ internalType: "uint64"
5017
+ }
5018
+ ],
5019
+ anonymous: false
5020
+ },
5021
+ { type: "error", name: "BaseTokenGasPriceDenominatorNotSet", inputs: [] },
5022
+ {
5023
+ type: "error",
5024
+ name: "BatchNotExecuted",
5025
+ inputs: [{ name: "batchNumber", type: "uint256", internalType: "uint256" }]
5026
+ },
5027
+ { type: "error", name: "GasPerPubdataMismatch", inputs: [] },
5028
+ { type: "error", name: "HashedLogIsDefault", inputs: [] },
5029
+ { type: "error", name: "InvalidChainId", inputs: [] },
5030
+ { type: "error", name: "InvalidProofLengthForFinalNode", inputs: [] },
5031
+ {
5032
+ type: "error",
5033
+ name: "LengthIsNotDivisibleBy32",
5034
+ inputs: [{ name: "length", type: "uint256", internalType: "uint256" }]
5035
+ },
5036
+ { type: "error", name: "LocalRootIsZero", inputs: [] },
5037
+ { type: "error", name: "LocalRootMustBeZero", inputs: [] },
5038
+ {
5039
+ type: "error",
5040
+ name: "MalformedBytecode",
5041
+ inputs: [{ name: "", type: "uint8", internalType: "enum BytecodeError" }]
5042
+ },
5043
+ { type: "error", name: "MerkleIndexOutOfBounds", inputs: [] },
5044
+ { type: "error", name: "MerklePathEmpty", inputs: [] },
5045
+ { type: "error", name: "MerklePathOutOfBounds", inputs: [] },
5046
+ {
5047
+ type: "error",
5048
+ name: "MsgValueTooLow",
5049
+ inputs: [
5050
+ { name: "required", type: "uint256", internalType: "uint256" },
5051
+ { name: "provided", type: "uint256", internalType: "uint256" }
5052
+ ]
5053
+ },
5054
+ { type: "error", name: "NotHyperchain", inputs: [] },
5055
+ { type: "error", name: "NotInitializedReentrancyGuard", inputs: [] },
5056
+ {
5057
+ type: "error",
5058
+ name: "NotL1",
5059
+ inputs: [{ name: "blockChainId", type: "uint256", internalType: "uint256" }]
5060
+ },
5061
+ { type: "error", name: "NotSettlementLayer", inputs: [] },
5062
+ { type: "error", name: "OnlyEraSupported", inputs: [] },
5063
+ {
5064
+ type: "error",
5065
+ name: "PubdataGreaterThanLimit",
5066
+ inputs: [
5067
+ { name: "limit", type: "uint256", internalType: "uint256" },
5068
+ { name: "length", type: "uint256", internalType: "uint256" }
5069
+ ]
5070
+ },
5071
+ { type: "error", name: "Reentrancy", inputs: [] },
5072
+ { type: "error", name: "TooManyFactoryDeps", inputs: [] },
5073
+ { type: "error", name: "TooMuchGas", inputs: [] },
5074
+ { type: "error", name: "TransactionNotAllowed", inputs: [] },
5075
+ { type: "error", name: "TxnBodyGasLimitNotEnoughGas", inputs: [] },
5076
+ {
5077
+ type: "error",
5078
+ name: "Unauthorized",
5079
+ inputs: [{ name: "caller", type: "address", internalType: "address" }]
5080
+ },
5081
+ {
5082
+ type: "error",
5083
+ name: "UnsupportedProofMetadataVersion",
5084
+ inputs: [{ name: "metadataVersion", type: "uint256", internalType: "uint256" }]
5085
+ },
5086
+ { type: "error", name: "ValidateTxnNotEnoughGas", inputs: [] },
5087
+ { type: "error", name: "ZeroGasPriceL1TxZKSyncOS", inputs: [] }
5088
+ ];
5089
+ var Mailbox_default = MailboxABI;
5090
+
5091
+ // src/core/errors/error-ops.ts
5092
+ function resolveMessage(op, msg) {
5093
+ if (!msg) return `Error during ${op}.`;
5094
+ return typeof msg === "function" ? msg() : msg;
5095
+ }
5096
+ function createErrorOps(decodeRevert2) {
5097
+ function toZKsyncError2(type, base, err) {
5098
+ if (isZKsyncError(err)) return err;
5099
+ const revert = decodeRevert2 ? decodeRevert2(err) : void 0;
5100
+ return createError(type, { ...base, ...revert ? { revert } : {}, cause: shapeCause(err) });
5101
+ }
5102
+ function createErrorHandlers2(resource) {
5103
+ async function run(kind, operation, fn, opts) {
5104
+ try {
5105
+ return await fn();
5106
+ } catch (e) {
5107
+ if (isZKsyncError(e)) throw e;
5108
+ const message = resolveMessage(operation, opts?.message);
5109
+ throw toZKsyncError2(kind, { resource, operation, context: opts?.ctx ?? {}, message }, e);
5110
+ }
5111
+ }
5112
+ function wrap2(operation, fn, opts) {
5113
+ return run("INTERNAL", operation, fn, opts);
5114
+ }
5115
+ function wrapAs(kind, operation, fn, opts) {
5116
+ return run(kind, operation, fn, opts);
5117
+ }
5118
+ async function toResult(operation, fn, opts) {
5119
+ try {
5120
+ const value = await wrap2(operation, fn, opts);
5121
+ return { ok: true, value };
5122
+ } catch (e) {
5123
+ const shaped = isZKsyncError(e) ? e : toZKsyncError2(
5124
+ "INTERNAL",
5125
+ {
5126
+ resource,
5127
+ operation,
5128
+ context: opts?.ctx ?? {},
5129
+ message: resolveMessage(operation, opts?.message)
5130
+ },
5131
+ e
5132
+ );
5133
+ return { ok: false, error: shaped };
5134
+ }
5135
+ }
5136
+ return { wrap: wrap2, wrapAs, toResult };
5137
+ }
5138
+ return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
5139
+ }
5140
+ var ERROR_IFACES = [];
5141
+ var IFACE_ERROR_STRING = new ethers.Interface(["error Error(string)"]);
5142
+ var IFACE_PANIC = new ethers.Interface(["error Panic(uint256)"]);
5143
+ (function bootstrapDefaultIfaces() {
5144
+ try {
5145
+ ERROR_IFACES.push({
5146
+ name: "IL1Nullifier",
5147
+ iface: new ethers.Interface(IL1Nullifier_default)
5148
+ });
5149
+ } catch {
5150
+ }
5151
+ try {
5152
+ ERROR_IFACES.push({ name: "IERC20", iface: new ethers.Interface(IERC20_default) });
5153
+ } catch {
5154
+ }
5155
+ try {
5156
+ ERROR_IFACES.push({
5157
+ name: "IL1NativeTokenVault",
5158
+ iface: new ethers.Interface(L1NativeTokenVault_default)
5159
+ });
5160
+ } catch {
5161
+ }
5162
+ try {
5163
+ ERROR_IFACES.push({
5164
+ name: "IL2NativeTokenVault",
5165
+ iface: new ethers.Interface(L2NativeTokenVault_default)
5166
+ });
5167
+ } catch {
5168
+ }
5169
+ try {
5170
+ ERROR_IFACES.push({ name: "Mailbox", iface: new ethers.Interface(Mailbox_default) });
5171
+ } catch {
5172
+ }
5173
+ })();
5174
+ function extractRevertData(e) {
5175
+ const maybe = (
5176
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5177
+ e?.data?.data ?? e?.error?.data ?? e?.data ?? e?.error?.error?.data ?? e?.info?.error?.data
5178
+ );
5179
+ if (typeof maybe === "string" && maybe.startsWith("0x") && maybe.length >= 10) {
5180
+ return maybe;
5181
+ }
5182
+ return void 0;
5183
+ }
5184
+ function decodeRevert(e) {
5185
+ const data = extractRevertData(e);
5186
+ if (!data) return;
5187
+ const selector = `0x${data.slice(2, 10)}`;
5188
+ try {
5189
+ const parsed = IFACE_ERROR_STRING.parseError(data);
5190
+ if (parsed?.name === "Error") {
5191
+ const args = parsed.args ? Array.from(parsed.args) : void 0;
5192
+ return { selector, name: "Error", args };
5193
+ }
5194
+ } catch {
5195
+ }
5196
+ try {
5197
+ const parsed = IFACE_PANIC.parseError(data);
5198
+ if (parsed?.name === "Panic") {
5199
+ const args = parsed.args ? Array.from(parsed.args) : void 0;
5200
+ return { selector, name: "Panic", args };
5201
+ }
5202
+ } catch {
5203
+ }
5204
+ for (const { name, iface } of ERROR_IFACES) {
5205
+ try {
5206
+ const parsed = iface.parseError(data);
5207
+ if (parsed) {
5208
+ const args = parsed.args ? Array.from(parsed.args) : void 0;
5209
+ return {
5210
+ selector,
5211
+ name: parsed.name,
5212
+ args,
5213
+ contract: name
5214
+ };
5215
+ }
5216
+ } catch {
5217
+ }
5218
+ }
5219
+ return { selector };
5220
+ }
5221
+
5222
+ // src/adapters/ethers/errors/error-ops.ts
5223
+ var { createErrorHandlers } = createErrorOps(decodeRevert);
5224
+
4581
5225
  // src/adapters/viem/client.ts
5226
+ var { wrap } = createErrorHandlers("client");
4582
5227
  function createViemClient(args) {
4583
5228
  const { l1, l2, l1Wallet, l2Wallet } = args;
4584
5229
  if (!l1Wallet.account) {
@@ -4590,35 +5235,44 @@ function createViemClient(args) {
4590
5235
  let cCache;
4591
5236
  async function ensureAddresses() {
4592
5237
  if (addrCache) return addrCache;
4593
- const bridgehub = args.overrides?.bridgehub ?? await zks.getBridgehubAddress();
4594
- const l1AssetRouter = args.overrides?.l1AssetRouter ?? await l1.readContract({
4595
- address: bridgehub,
4596
- abi: IBridgehub_default,
4597
- functionName: "assetRouter"
4598
- });
4599
- const l1Nullifier = args.overrides?.l1Nullifier ?? await l1.readContract({
4600
- address: l1AssetRouter,
4601
- abi: IL1AssetRouter_default,
4602
- functionName: "L1_NULLIFIER"
4603
- });
4604
- const l1NativeTokenVault = args.overrides?.l1NativeTokenVault ?? await l1.readContract({
4605
- address: l1Nullifier,
4606
- abi: IL1Nullifier_default,
4607
- functionName: "l1NativeTokenVault"
4608
- });
4609
- const l2AssetRouter = args.overrides?.l2AssetRouter ?? L2_ASSET_ROUTER_ADDRESS;
4610
- const l2NativeTokenVault = args.overrides?.l2NativeTokenVault ?? L2_NATIVE_TOKEN_VAULT_ADDRESS;
4611
- const l2BaseTokenSystem = args.overrides?.l2BaseTokenSystem ?? L2_BASE_TOKEN_ADDRESS;
4612
- addrCache = {
4613
- bridgehub,
4614
- l1AssetRouter,
4615
- l1Nullifier,
4616
- l1NativeTokenVault,
4617
- l2AssetRouter,
4618
- l2NativeTokenVault,
4619
- l2BaseTokenSystem
4620
- };
4621
- return addrCache;
5238
+ return await wrap(
5239
+ OP_CLIENT.ensureAddresses,
5240
+ async () => {
5241
+ const bridgehub = args.overrides?.bridgehub ?? await zks.getBridgehubAddress();
5242
+ const l1AssetRouter = args.overrides?.l1AssetRouter ?? await l1.readContract({
5243
+ address: bridgehub,
5244
+ abi: IBridgehub_default,
5245
+ functionName: "assetRouter"
5246
+ });
5247
+ const l1Nullifier = args.overrides?.l1Nullifier ?? await l1.readContract({
5248
+ address: l1AssetRouter,
5249
+ abi: IL1AssetRouter_default,
5250
+ functionName: "L1_NULLIFIER"
5251
+ });
5252
+ const l1NativeTokenVault = args.overrides?.l1NativeTokenVault ?? await l1.readContract({
5253
+ address: l1Nullifier,
5254
+ abi: IL1Nullifier_default,
5255
+ functionName: "l1NativeTokenVault"
5256
+ });
5257
+ const l2AssetRouter = args.overrides?.l2AssetRouter ?? L2_ASSET_ROUTER_ADDRESS;
5258
+ const l2NativeTokenVault = args.overrides?.l2NativeTokenVault ?? L2_NATIVE_TOKEN_VAULT_ADDRESS;
5259
+ const l2BaseTokenSystem = args.overrides?.l2BaseTokenSystem ?? L2_BASE_TOKEN_ADDRESS;
5260
+ addrCache = {
5261
+ bridgehub,
5262
+ l1AssetRouter,
5263
+ l1Nullifier,
5264
+ l1NativeTokenVault,
5265
+ l2AssetRouter,
5266
+ l2NativeTokenVault,
5267
+ l2BaseTokenSystem
5268
+ };
5269
+ return addrCache;
5270
+ },
5271
+ {
5272
+ ctx: { where: "ensureAddresses" },
5273
+ message: "Failed to ensure contract addresses."
5274
+ }
5275
+ );
4622
5276
  }
4623
5277
  async function contracts() {
4624
5278
  if (cCache) return cCache;