@matterlabs/zksync-js 0.0.21 → 0.0.22

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 (70) hide show
  1. package/dist/adapters/ethers/client.cjs +31 -1
  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 +6 -5
  5. package/dist/adapters/ethers/index.cjs +1009 -274
  6. package/dist/adapters/ethers/index.cjs.map +1 -1
  7. package/dist/adapters/ethers/index.d.ts +2 -1
  8. package/dist/adapters/ethers/index.js +10 -8
  9. package/dist/adapters/ethers/resources/withdrawals/context.d.ts +12 -1
  10. package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
  11. package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  12. package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
  13. package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
  14. package/dist/adapters/ethers/sdk.cjs +976 -272
  15. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  16. package/dist/adapters/ethers/sdk.d.ts +3 -1
  17. package/dist/adapters/ethers/sdk.js +8 -7
  18. package/dist/adapters/viem/client.cjs +44 -0
  19. package/dist/adapters/viem/client.cjs.map +1 -1
  20. package/dist/adapters/viem/client.d.ts +11 -0
  21. package/dist/adapters/viem/client.js +6 -5
  22. package/dist/adapters/viem/index.cjs +1060 -294
  23. package/dist/adapters/viem/index.cjs.map +1 -1
  24. package/dist/adapters/viem/index.d.ts +2 -1
  25. package/dist/adapters/viem/index.js +10 -8
  26. package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
  27. package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
  28. package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  29. package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
  30. package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
  31. package/dist/adapters/viem/sdk.cjs +1014 -293
  32. package/dist/adapters/viem/sdk.cjs.map +1 -1
  33. package/dist/adapters/viem/sdk.d.ts +3 -1
  34. package/dist/adapters/viem/sdk.js +8 -7
  35. package/dist/{chunk-SBGBYZJM.js → chunk-2D3FBCZC.js} +2 -2
  36. package/dist/{chunk-LGTYM5XP.js → chunk-32N6TI6K.js} +1 -1
  37. package/dist/{chunk-IDXSGCGF.js → chunk-3SPDWWRD.js} +7 -22
  38. package/dist/{chunk-7GZDTLHX.js → chunk-4K4LOCQJ.js} +559 -256
  39. package/dist/{chunk-UEKFQAOS.js → chunk-AMRHBZIY.js} +304 -2
  40. package/dist/{chunk-2CGBLD5H.js → chunk-CP4SQ5PM.js} +527 -239
  41. package/dist/{chunk-NJK325XV.js → chunk-CPNHKNI4.js} +2 -2
  42. package/dist/{chunk-TYYUG5GA.js → chunk-CUBUD4J4.js} +1 -1
  43. package/dist/{chunk-CK5UFAZK.js → chunk-JXBLQQEN.js} +37 -3
  44. package/dist/{chunk-JSBMIT4S.js → chunk-KL6ZCPWJ.js} +1 -1
  45. package/dist/{chunk-MT4X5FEO.js → chunk-NQRYXL3K.js} +3 -1
  46. package/dist/{chunk-24TE2NNJ.js → chunk-PI4PF6WT.js} +24 -4
  47. package/dist/chunk-QUAPG3ZR.js +157 -0
  48. package/dist/chunk-UMPAKZCQ.js +19 -0
  49. package/dist/core/abi.d.ts +1 -0
  50. package/dist/core/constants.cjs +2 -0
  51. package/dist/core/constants.cjs.map +1 -1
  52. package/dist/core/constants.d.ts +9 -0
  53. package/dist/core/constants.js +1 -1
  54. package/dist/core/index.cjs +504 -0
  55. package/dist/core/index.cjs.map +1 -1
  56. package/dist/core/index.d.ts +6 -1
  57. package/dist/core/index.js +6 -4
  58. package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
  59. package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
  60. package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
  61. package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
  62. package/dist/core/resources/protocol/semver.d.ts +18 -0
  63. package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
  64. package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
  65. package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
  66. package/dist/core/types/flows/withdrawals.d.ts +30 -0
  67. package/dist/index.cjs +304 -0
  68. package/dist/index.cjs.map +1 -1
  69. package/dist/index.js +4 -4
  70. package/package.json +1 -1
@@ -15,7 +15,10 @@ var L2_ASSET_ROUTER_ADDRESS = "0x0000000000000000000000000000000000010003";
15
15
  var L2_NATIVE_TOKEN_VAULT_ADDRESS = "0x0000000000000000000000000000000000010004";
16
16
  var L1_MESSENGER_ADDRESS = "0x0000000000000000000000000000000000008008";
17
17
  var L2_BASE_TOKEN_ADDRESS = "0x000000000000000000000000000000000000800A";
18
+ var L2_INTEROP_CENTER_ADDRESS = "0x000000000000000000000000000000000001000d";
19
+ var L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS = "0x0000000000000000000000000000000000010015";
18
20
  var L1_SOPH_TOKEN_ADDRESS = "0xa9544a49d4aEa4c8E074431c89C79fA9592049d8";
21
+ var BUNDLE_IDENTIFIER = "0x01";
19
22
  var TOPIC_L1_MESSAGE_SENT_NEW = k256hex("L1MessageSent(uint256,bytes32,bytes)");
20
23
  var TOPIC_L1_MESSAGE_SENT_LEG = k256hex("L1MessageSent(address,bytes32,bytes)");
21
24
 
@@ -33,6 +36,7 @@ __export(abi_exports, {
33
36
  IL1AssetRouterABI: () => IL1AssetRouter_default,
34
37
  IL1ContractErrorsABI: () => IL1ContractErrors_default,
35
38
  IL1NullifierABI: () => IL1Nullifier_default,
39
+ IL1NullifierV32ABI: () => IL1NullifierV32_default,
36
40
  IL2AssetRouterABI: () => IL2AssetRouter_default,
37
41
  L1NativeTokenVaultABI: () => L1NativeTokenVault_default,
38
42
  L2MessageVerificationABI: () => L2MessageVerification_default,
@@ -2660,6 +2664,294 @@ var IL1NullifierABI = [
2660
2664
  ];
2661
2665
  var IL1Nullifier_default = IL1NullifierABI;
2662
2666
 
2667
+ // src/core/internal/abis/IL1NullifierV32.ts
2668
+ var IL1NullifierV32ABI = [
2669
+ {
2670
+ anonymous: false,
2671
+ inputs: [
2672
+ {
2673
+ indexed: true,
2674
+ internalType: "uint256",
2675
+ name: "chainId",
2676
+ type: "uint256"
2677
+ },
2678
+ {
2679
+ indexed: true,
2680
+ internalType: "bytes32",
2681
+ name: "txDataHash",
2682
+ type: "bytes32"
2683
+ },
2684
+ {
2685
+ indexed: true,
2686
+ internalType: "bytes32",
2687
+ name: "l2DepositTxHash",
2688
+ type: "bytes32"
2689
+ }
2690
+ ],
2691
+ name: "BridgehubDepositFinalized",
2692
+ type: "event"
2693
+ },
2694
+ {
2695
+ inputs: [],
2696
+ name: "BRIDGE_HUB",
2697
+ outputs: [
2698
+ {
2699
+ internalType: "contract IL1Bridgehub",
2700
+ name: "",
2701
+ type: "address"
2702
+ }
2703
+ ],
2704
+ stateMutability: "view",
2705
+ type: "function"
2706
+ },
2707
+ {
2708
+ inputs: [],
2709
+ name: "l1AssetRouter",
2710
+ outputs: [
2711
+ {
2712
+ internalType: "contract IL1AssetRouter",
2713
+ name: "",
2714
+ type: "address"
2715
+ }
2716
+ ],
2717
+ stateMutability: "view",
2718
+ type: "function"
2719
+ },
2720
+ {
2721
+ // The contract that took over withdrawal finalization from the nullifier's own (removed)
2722
+ // `finalizeDeposit`.
2723
+ inputs: [],
2724
+ name: "l1InteropHandler",
2725
+ outputs: [
2726
+ {
2727
+ internalType: "address",
2728
+ name: "",
2729
+ type: "address"
2730
+ }
2731
+ ],
2732
+ stateMutability: "view",
2733
+ type: "function"
2734
+ },
2735
+ {
2736
+ inputs: [],
2737
+ name: "l1NativeTokenVault",
2738
+ outputs: [
2739
+ {
2740
+ internalType: "contract IL1NativeTokenVault",
2741
+ name: "",
2742
+ type: "address"
2743
+ }
2744
+ ],
2745
+ stateMutability: "view",
2746
+ type: "function"
2747
+ },
2748
+ {
2749
+ inputs: [
2750
+ {
2751
+ internalType: "uint256",
2752
+ name: "_chainId",
2753
+ type: "uint256"
2754
+ },
2755
+ {
2756
+ internalType: "bytes32",
2757
+ name: "_l2TxHash",
2758
+ type: "bytes32"
2759
+ }
2760
+ ],
2761
+ name: "depositHappened",
2762
+ outputs: [
2763
+ {
2764
+ internalType: "bytes32",
2765
+ name: "",
2766
+ type: "bytes32"
2767
+ }
2768
+ ],
2769
+ stateMutability: "view",
2770
+ type: "function"
2771
+ },
2772
+ {
2773
+ inputs: [
2774
+ {
2775
+ internalType: "uint256",
2776
+ name: "_chainId",
2777
+ type: "uint256"
2778
+ },
2779
+ {
2780
+ internalType: "bytes32",
2781
+ name: "_txDataHash",
2782
+ type: "bytes32"
2783
+ },
2784
+ {
2785
+ internalType: "bytes32",
2786
+ name: "_txHash",
2787
+ type: "bytes32"
2788
+ }
2789
+ ],
2790
+ name: "bridgehubConfirmL2TransactionForwarded",
2791
+ outputs: [],
2792
+ stateMutability: "nonpayable",
2793
+ type: "function"
2794
+ },
2795
+ {
2796
+ inputs: [
2797
+ {
2798
+ components: [
2799
+ {
2800
+ internalType: "uint256",
2801
+ name: "_chainId",
2802
+ type: "uint256"
2803
+ },
2804
+ {
2805
+ internalType: "address",
2806
+ name: "_depositSender",
2807
+ type: "address"
2808
+ },
2809
+ {
2810
+ internalType: "uint16",
2811
+ name: "_l2TxNumberInBatch",
2812
+ type: "uint16"
2813
+ },
2814
+ {
2815
+ internalType: "enum TxStatus",
2816
+ name: "_txStatus",
2817
+ type: "uint8"
2818
+ },
2819
+ {
2820
+ internalType: "bytes32",
2821
+ name: "_assetId",
2822
+ type: "bytes32"
2823
+ },
2824
+ {
2825
+ internalType: "bytes",
2826
+ name: "_assetData",
2827
+ type: "bytes"
2828
+ },
2829
+ {
2830
+ internalType: "bytes32",
2831
+ name: "_l2TxHash",
2832
+ type: "bytes32"
2833
+ },
2834
+ {
2835
+ internalType: "uint256",
2836
+ name: "_l2BatchNumber",
2837
+ type: "uint256"
2838
+ },
2839
+ {
2840
+ internalType: "uint256",
2841
+ name: "_l2MessageIndex",
2842
+ type: "uint256"
2843
+ },
2844
+ {
2845
+ internalType: "bytes32[]",
2846
+ name: "_merkleProof",
2847
+ type: "bytes32[]"
2848
+ }
2849
+ ],
2850
+ internalType: "struct ConfirmTransferResultData",
2851
+ name: "_confirmTransferResultData",
2852
+ type: "tuple"
2853
+ }
2854
+ ],
2855
+ name: "bridgeConfirmTransferResult",
2856
+ outputs: [],
2857
+ stateMutability: "nonpayable",
2858
+ type: "function"
2859
+ },
2860
+ {
2861
+ inputs: [
2862
+ {
2863
+ internalType: "uint256",
2864
+ name: "_chainId",
2865
+ type: "uint256"
2866
+ },
2867
+ {
2868
+ internalType: "address",
2869
+ name: "_depositSender",
2870
+ type: "address"
2871
+ },
2872
+ {
2873
+ internalType: "bytes32",
2874
+ name: "_assetId",
2875
+ type: "bytes32"
2876
+ },
2877
+ {
2878
+ internalType: "bytes",
2879
+ name: "_assetData",
2880
+ type: "bytes"
2881
+ },
2882
+ {
2883
+ internalType: "bytes32",
2884
+ name: "_l2TxHash",
2885
+ type: "bytes32"
2886
+ },
2887
+ {
2888
+ internalType: "uint256",
2889
+ name: "_l2BatchNumber",
2890
+ type: "uint256"
2891
+ },
2892
+ {
2893
+ internalType: "uint256",
2894
+ name: "_l2MessageIndex",
2895
+ type: "uint256"
2896
+ },
2897
+ {
2898
+ internalType: "uint16",
2899
+ name: "_l2TxNumberInBatch",
2900
+ type: "uint16"
2901
+ },
2902
+ {
2903
+ internalType: "bytes32[]",
2904
+ name: "_merkleProof",
2905
+ type: "bytes32[]"
2906
+ }
2907
+ ],
2908
+ name: "bridgeRecoverFailedTransfer",
2909
+ outputs: [],
2910
+ stateMutability: "nonpayable",
2911
+ type: "function"
2912
+ },
2913
+ {
2914
+ inputs: [
2915
+ {
2916
+ internalType: "contract IL1NativeTokenVault",
2917
+ name: "_nativeTokenVault",
2918
+ type: "address"
2919
+ }
2920
+ ],
2921
+ name: "setL1NativeTokenVault",
2922
+ outputs: [],
2923
+ stateMutability: "nonpayable",
2924
+ type: "function"
2925
+ },
2926
+ {
2927
+ inputs: [
2928
+ {
2929
+ internalType: "address",
2930
+ name: "_l1AssetRouter",
2931
+ type: "address"
2932
+ }
2933
+ ],
2934
+ name: "setL1AssetRouter",
2935
+ outputs: [],
2936
+ stateMutability: "nonpayable",
2937
+ type: "function"
2938
+ },
2939
+ {
2940
+ inputs: [
2941
+ {
2942
+ internalType: "address",
2943
+ name: "_l1InteropHandler",
2944
+ type: "address"
2945
+ }
2946
+ ],
2947
+ name: "setL1InteropHandler",
2948
+ outputs: [],
2949
+ stateMutability: "nonpayable",
2950
+ type: "function"
2951
+ }
2952
+ ];
2953
+ var IL1NullifierV32_default = IL1NullifierV32ABI;
2954
+
2663
2955
  // src/core/internal/abis/IL2AssetRouter.ts
2664
2956
  var IL2AssetRouterABI = [
2665
2957
  {
@@ -4193,6 +4485,19 @@ var IERC7786AttributesABI = [
4193
4485
  outputs: [],
4194
4486
  stateMutability: "pure"
4195
4487
  },
4488
+ {
4489
+ type: "function",
4490
+ name: "interopBundleSalt",
4491
+ inputs: [
4492
+ {
4493
+ name: "_salt",
4494
+ type: "bytes32",
4495
+ internalType: "bytes32"
4496
+ }
4497
+ ],
4498
+ outputs: [],
4499
+ stateMutability: "pure"
4500
+ },
4196
4501
  {
4197
4502
  type: "function",
4198
4503
  name: "unbundlerAddress",
@@ -6726,6 +7031,11 @@ function normalizeAddrEq(a, b) {
6726
7031
  var hexEq = (a, b) => a.toLowerCase() === b.toLowerCase();
6727
7032
  var normalizeL1Token = (token) => isAddressEq(token, FORMAL_ETH_ADDRESS) ? ETH_ADDRESS : token;
6728
7033
 
7034
+ // src/core/utils/index.ts
7035
+ function assertNever(x) {
7036
+ throw new Error("Unexpected action type: " + String(x));
7037
+ }
7038
+
6729
7039
  // src/core/errors/formatter.ts
6730
7040
  function elideMiddle(s, max = 96) {
6731
7041
  if (s.length <= max) return s;
@@ -6867,6 +7177,11 @@ function isZKsyncError(e, opts) {
6867
7177
  if (typeof envelope?.type !== "string" || typeof envelope?.message !== "string") return false;
6868
7178
  return true;
6869
7179
  }
7180
+ var OP_WITHDRAWALS = {
7181
+ finalize: {
7182
+ fetchParams: {
7183
+ decodeMessage: "withdrawals.finalize.fetchParams:decodeMessage"}}
7184
+ };
6870
7185
 
6871
7186
  // src/core/errors/factory.ts
6872
7187
  function createError(type, input) {
@@ -7342,6 +7657,175 @@ function pickWithdrawRoute(args) {
7342
7657
  return "erc20-nonbase";
7343
7658
  }
7344
7659
 
7660
+ // src/core/resources/withdrawals/protocol.ts
7661
+ var MIN_INTEROP_WITHDRAWAL_MINOR = 32;
7662
+ function protocolFromVersion(version) {
7663
+ const [, minor] = version;
7664
+ return minor >= MIN_INTEROP_WITHDRAWAL_MINOR ? "interop-bundle" : "legacy-withdrawal";
7665
+ }
7666
+ async function detectWithdrawalProtocol(probes, override) {
7667
+ if (override) {
7668
+ return { protocol: override, source: { via: "override" } };
7669
+ }
7670
+ const version = await probes.protocolVersion();
7671
+ if (version) {
7672
+ return { protocol: protocolFromVersion(version), source: { via: "protocol-version", version } };
7673
+ }
7674
+ if (await probes.hasCodeAt(L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS)) {
7675
+ return {
7676
+ protocol: "interop-bundle",
7677
+ source: { via: "code-probe", address: L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS }
7678
+ };
7679
+ }
7680
+ return {
7681
+ protocol: "legacy-withdrawal",
7682
+ source: { via: "code-probe", address: L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS }
7683
+ };
7684
+ }
7685
+
7686
+ // src/core/resources/withdrawals/status.ts
7687
+ function phaseFromReadiness(r) {
7688
+ switch (r.kind) {
7689
+ case "FINALIZED":
7690
+ return { phase: "FINALIZED" };
7691
+ case "READY":
7692
+ return { phase: "READY_TO_FINALIZE" };
7693
+ case "NOT_READY":
7694
+ return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
7695
+ case "UNFINALIZABLE":
7696
+ return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
7697
+ default:
7698
+ return assertNever(r);
7699
+ }
7700
+ }
7701
+ var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
7702
+
7703
+ // src/core/resources/withdrawals/bundle.ts
7704
+ function buildWithdrawalBundle(input) {
7705
+ const {
7706
+ assetId,
7707
+ amount,
7708
+ l1Receiver,
7709
+ l2Token,
7710
+ isBaseToken,
7711
+ l1ChainId,
7712
+ l2AssetRouter,
7713
+ salt,
7714
+ codec,
7715
+ attributes,
7716
+ transferData
7717
+ } = input;
7718
+ const burnData = transferData.encodeBridgeBurnData(amount, l1Receiver, l2Token);
7719
+ const depositData = transferData.encodeAssetRouterDepositData(assetId, burnData);
7720
+ const indirectCallMessageValue = isBaseToken ? amount : 0n;
7721
+ const starter = [
7722
+ codec.formatAddress(l2AssetRouter),
7723
+ depositData,
7724
+ [attributes.indirectCall(indirectCallMessageValue), attributes.interopCallValue(0n)]
7725
+ ];
7726
+ return {
7727
+ destinationChain: codec.formatChain(l1ChainId),
7728
+ starters: [starter],
7729
+ // No `atomicBundle` attribute: L2 -> L1 withdrawals are non-atomic and are published to L1 as a
7730
+ // `BUNDLE_IDENTIFIER`-prefixed message, which is what the L1 handler proves inclusion of.
7731
+ bundleAttributes: [attributes.interopBundleSalt(salt)],
7732
+ value: indirectCallMessageValue
7733
+ };
7734
+ }
7735
+ function withdrawalBundleSalt(input) {
7736
+ return input.hash(input.sender, BigInt(input.nonce));
7737
+ }
7738
+ function keccakHex(data) {
7739
+ return `0x${utils.bytesToHex(sha3.keccak_256(utils.hexToBytes(data.slice(2))))}`;
7740
+ }
7741
+ function stripBundleIdentifier(messageData) {
7742
+ const prefix = `0x${messageData.slice(2, 4)}`;
7743
+ if (prefix !== BUNDLE_IDENTIFIER) {
7744
+ throw createError("STATE", {
7745
+ resource: "withdrawals",
7746
+ operation: OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
7747
+ message: "L2\u2192L1 message is not an interop bundle. This withdrawal was most likely initiated before the chain upgraded to protocol v32 and cannot be finalized through the interop handler.",
7748
+ context: { prefix, expected: BUNDLE_IDENTIFIER }
7749
+ });
7750
+ }
7751
+ return `0x${messageData.slice(4)}`;
7752
+ }
7753
+ function parseBundleHashFromLogs(logs, interopCenter = L2_INTEROP_CENTER_ADDRESS) {
7754
+ const center = interopCenter.toLowerCase();
7755
+ for (const log of logs) {
7756
+ if (log.address?.toLowerCase() !== center) continue;
7757
+ if (log.topics?.length !== 1) continue;
7758
+ if (!log.data || (log.data.length - 2) / 64 < 3) continue;
7759
+ return `0x${log.data.slice(66, 130)}`;
7760
+ }
7761
+ return void 0;
7762
+ }
7763
+ function buildWithdrawalFinalization(input) {
7764
+ const { messageData, sourceChainId, txNumberInBatch, proof } = input;
7765
+ const bundle = stripBundleIdentifier(messageData);
7766
+ return {
7767
+ bundle,
7768
+ bundleHash: input.bundleHash ?? keccakHex(bundle),
7769
+ proof: {
7770
+ chainId: sourceChainId,
7771
+ l1BatchNumber: proof.batchNumber,
7772
+ l2MessageIndex: proof.id,
7773
+ message: {
7774
+ txNumberInBatch,
7775
+ sender: input.interopCenter ?? L2_INTEROP_CENTER_ADDRESS,
7776
+ data: messageData
7777
+ },
7778
+ proof: proof.proof
7779
+ }
7780
+ };
7781
+ }
7782
+ var BundleStatus = /* @__PURE__ */ ((BundleStatus2) => {
7783
+ BundleStatus2[BundleStatus2["Unreceived"] = 0] = "Unreceived";
7784
+ BundleStatus2[BundleStatus2["Verified"] = 1] = "Verified";
7785
+ BundleStatus2[BundleStatus2["FullyExecuted"] = 2] = "FullyExecuted";
7786
+ BundleStatus2[BundleStatus2["Unbundled"] = 3] = "Unbundled";
7787
+ return BundleStatus2;
7788
+ })(BundleStatus || {});
7789
+ var CallStatus = /* @__PURE__ */ ((CallStatus2) => {
7790
+ CallStatus2[CallStatus2["Unprocessed"] = 0] = "Unprocessed";
7791
+ CallStatus2[CallStatus2["Executed"] = 1] = "Executed";
7792
+ CallStatus2[CallStatus2["Cancelled"] = 2] = "Cancelled";
7793
+ return CallStatus2;
7794
+ })(CallStatus || {});
7795
+ function classifyWithdrawalOutcome(bundleStatus, callStatus) {
7796
+ if (bundleStatus === 2 /* FullyExecuted */) return "finalized";
7797
+ if (bundleStatus !== 3 /* Unbundled */) return "pending";
7798
+ switch (callStatus) {
7799
+ case 1 /* Executed */:
7800
+ return "finalized";
7801
+ case 2 /* Cancelled */:
7802
+ return "failed";
7803
+ default:
7804
+ return "pending";
7805
+ }
7806
+ }
7807
+ function isBundleFinalized(status) {
7808
+ return status === 2 /* FullyExecuted */;
7809
+ }
7810
+
7811
+ // src/core/resources/protocol/semver.ts
7812
+ var SEMVER_MINOR_OFFSET = 32n;
7813
+ var SEMVER_MAJOR_OFFSET = 64n;
7814
+ var U32_MASK = 0xffffffffn;
7815
+ function unpackSemver(packed) {
7816
+ const patch = Number(packed & U32_MASK);
7817
+ const minor = Number(packed >> SEMVER_MINOR_OFFSET & U32_MASK);
7818
+ const major = Number(packed >> SEMVER_MAJOR_OFFSET & U32_MASK);
7819
+ return [major, minor, patch];
7820
+ }
7821
+ function packSemver(version) {
7822
+ const [major, minor, patch] = version;
7823
+ return BigInt(major) << SEMVER_MAJOR_OFFSET | BigInt(minor) << SEMVER_MINOR_OFFSET | BigInt(patch);
7824
+ }
7825
+ function formatProtocolVersion(version) {
7826
+ return version.join(".");
7827
+ }
7828
+
7345
7829
  // src/core/utils/events.ts
7346
7830
  function extractPreferAddress(opts) {
7347
7831
  const preferAddr = typeof opts?.prefer === "object" ? opts.prefer.address : opts?.prefer === "assetRouter" ? L2_ASSET_ROUTER_ADDRESS : L1_MESSENGER_ADDRESS;
@@ -7390,34 +7874,54 @@ function messengerLogIndex(raw, opts) {
7390
7874
  return (hits[index] ?? hits[0]).i;
7391
7875
  }
7392
7876
 
7877
+ exports.BundleStatus = BundleStatus;
7878
+ exports.CallStatus = CallStatus;
7393
7879
  exports.ETH_ADDRESS = ETH_ADDRESS;
7394
7880
  exports.FORMAL_ETH_ADDRESS = FORMAL_ETH_ADDRESS;
7395
7881
  exports.L1_MESSENGER_ADDRESS = L1_MESSENGER_ADDRESS;
7396
7882
  exports.L1_SOPH_TOKEN_ADDRESS = L1_SOPH_TOKEN_ADDRESS;
7397
7883
  exports.L2_ASSET_ROUTER_ADDRESS = L2_ASSET_ROUTER_ADDRESS;
7398
7884
  exports.L2_BASE_TOKEN_ADDRESS = L2_BASE_TOKEN_ADDRESS;
7885
+ exports.L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS = L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS;
7399
7886
  exports.L2_NATIVE_TOKEN_VAULT_ADDRESS = L2_NATIVE_TOKEN_VAULT_ADDRESS;
7887
+ exports.MIN_INTEROP_WITHDRAWAL_MINOR = MIN_INTEROP_WITHDRAWAL_MINOR;
7888
+ exports.SEMVER_MAJOR_OFFSET = SEMVER_MAJOR_OFFSET;
7889
+ exports.SEMVER_MINOR_OFFSET = SEMVER_MINOR_OFFSET;
7400
7890
  exports.abi = abi_exports;
7891
+ exports.buildWithdrawalBundle = buildWithdrawalBundle;
7892
+ exports.buildWithdrawalFinalization = buildWithdrawalFinalization;
7893
+ exports.classifyWithdrawalOutcome = classifyWithdrawalOutcome;
7894
+ exports.detectWithdrawalProtocol = detectWithdrawalProtocol;
7401
7895
  exports.errors = factory_exports;
7402
7896
  exports.findL1MessageSentLog = findL1MessageSentLog;
7403
7897
  exports.formatEnvelopePretty = formatEnvelopePretty;
7898
+ exports.formatProtocolVersion = formatProtocolVersion;
7404
7899
  exports.hexEq = hexEq;
7405
7900
  exports.isAddress = isAddress;
7406
7901
  exports.isAddressEq = isAddressEq;
7902
+ exports.isBundleFinalized = isBundleFinalized;
7407
7903
  exports.isETH = isETH;
7408
7904
  exports.isHash = isHash;
7409
7905
  exports.isHash66 = isHash66;
7410
7906
  exports.isHash66Array = isHash66Array;
7411
7907
  exports.isHashArray = isHashArray;
7412
7908
  exports.isL1MessageSentLog = isL1MessageSentLog;
7909
+ exports.keccakHex = keccakHex;
7413
7910
  exports.l1MessageSentSender = l1MessageSentSender;
7414
7911
  exports.makeTransportFromEthers = makeTransportFromEthers;
7415
7912
  exports.makeTransportFromViem = makeTransportFromViem;
7416
7913
  exports.messengerLogIndex = messengerLogIndex;
7417
7914
  exports.normalizeAddrEq = normalizeAddrEq;
7418
7915
  exports.normalizeL1Token = normalizeL1Token;
7916
+ exports.packSemver = packSemver;
7917
+ exports.parseBundleHashFromLogs = parseBundleHashFromLogs;
7918
+ exports.phaseFromReadiness = phaseFromReadiness;
7419
7919
  exports.pickDepositRoute = pickDepositRoute;
7420
7920
  exports.pickWithdrawRoute = pickWithdrawRoute;
7921
+ exports.protocolFromVersion = protocolFromVersion;
7922
+ exports.stripBundleIdentifier = stripBundleIdentifier;
7923
+ exports.unpackSemver = unpackSemver;
7924
+ exports.withdrawalBundleSalt = withdrawalBundleSalt;
7421
7925
  exports.zksRpc = zks_exports;
7422
7926
  //# sourceMappingURL=index.cjs.map
7423
7927
  //# sourceMappingURL=index.cjs.map