@matterlabs/zksync-js 0.0.21 → 0.0.23

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 (77) hide show
  1. package/dist/adapters/ethers/client.cjs +31 -8
  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 +1194 -364
  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/deposits/context.d.ts +2 -0
  10. package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +3 -0
  11. package/dist/adapters/ethers/resources/withdrawals/context.d.ts +12 -1
  12. package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
  13. package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  14. package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
  15. package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
  16. package/dist/adapters/ethers/sdk.cjs +1166 -370
  17. package/dist/adapters/ethers/sdk.cjs.map +1 -1
  18. package/dist/adapters/ethers/sdk.d.ts +3 -1
  19. package/dist/adapters/ethers/sdk.js +8 -7
  20. package/dist/adapters/viem/client.cjs +44 -7
  21. package/dist/adapters/viem/client.cjs.map +1 -1
  22. package/dist/adapters/viem/client.d.ts +11 -0
  23. package/dist/adapters/viem/client.js +6 -5
  24. package/dist/adapters/viem/index.cjs +1237 -383
  25. package/dist/adapters/viem/index.cjs.map +1 -1
  26. package/dist/adapters/viem/index.d.ts +2 -1
  27. package/dist/adapters/viem/index.js +10 -8
  28. package/dist/adapters/viem/resources/deposits/context.d.ts +2 -0
  29. package/dist/adapters/viem/resources/deposits/services/gas.d.ts +3 -0
  30. package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
  31. package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
  32. package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
  33. package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
  34. package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
  35. package/dist/adapters/viem/sdk.cjs +1191 -385
  36. package/dist/adapters/viem/sdk.cjs.map +1 -1
  37. package/dist/adapters/viem/sdk.d.ts +3 -1
  38. package/dist/adapters/viem/sdk.js +8 -7
  39. package/dist/{chunk-UEKFQAOS.js → chunk-2DDJFHHD.js} +304 -9
  40. package/dist/{chunk-MT4X5FEO.js → chunk-3IPSDGHO.js} +19 -1
  41. package/dist/{chunk-JSBMIT4S.js → chunk-4GPIHYVF.js} +1 -1
  42. package/dist/{chunk-SBGBYZJM.js → chunk-4M7VNYGC.js} +2 -2
  43. package/dist/{chunk-CK5UFAZK.js → chunk-6WIAMFIW.js} +37 -3
  44. package/dist/chunk-JJ523MOL.js +157 -0
  45. package/dist/{chunk-7GZDTLHX.js → chunk-NVOFHV3A.js} +666 -304
  46. package/dist/{chunk-LGTYM5XP.js → chunk-OEUDZFXH.js} +1 -1
  47. package/dist/{chunk-NJK325XV.js → chunk-TUN6NH5D.js} +2 -2
  48. package/dist/chunk-UMPAKZCQ.js +19 -0
  49. package/dist/{chunk-24TE2NNJ.js → chunk-URHDNDFN.js} +24 -4
  50. package/dist/{chunk-2CGBLD5H.js → chunk-V2TDNGI5.js} +642 -288
  51. package/dist/{chunk-IDXSGCGF.js → chunk-WPCZNITC.js} +63 -50
  52. package/dist/{chunk-TYYUG5GA.js → chunk-X2JJDQ4O.js} +1 -1
  53. package/dist/core/abi.d.ts +1 -0
  54. package/dist/core/adapters/interfaces.d.ts +2 -0
  55. package/dist/core/constants.cjs +18 -0
  56. package/dist/core/constants.cjs.map +1 -1
  57. package/dist/core/constants.d.ts +17 -0
  58. package/dist/core/constants.js +1 -1
  59. package/dist/core/index.cjs +504 -7
  60. package/dist/core/index.cjs.map +1 -1
  61. package/dist/core/index.d.ts +6 -1
  62. package/dist/core/index.js +6 -4
  63. package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
  64. package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
  65. package/dist/core/internal/abis/IL2AssetRouter.d.ts +0 -14
  66. package/dist/core/resources/deposits/priority.d.ts +30 -0
  67. package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
  68. package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
  69. package/dist/core/resources/protocol/semver.d.ts +18 -0
  70. package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
  71. package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
  72. package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
  73. package/dist/core/types/flows/withdrawals.d.ts +30 -0
  74. package/dist/index.cjs +320 -7
  75. package/dist/index.cjs.map +1 -1
  76. package/dist/index.js +4 -4
  77. 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
  {
@@ -2783,13 +3075,6 @@ var IL2AssetRouterABI = [
2783
3075
  outputs: [{ name: "", type: "address", internalType: "address" }],
2784
3076
  stateMutability: "view"
2785
3077
  },
2786
- {
2787
- type: "function",
2788
- name: "l1TokenAddress",
2789
- inputs: [{ name: "_l2Token", type: "address", internalType: "address" }],
2790
- outputs: [{ name: "", type: "address", internalType: "address" }],
2791
- stateMutability: "view"
2792
- },
2793
3078
  {
2794
3079
  type: "function",
2795
3080
  name: "l2TokenAddress",
@@ -4193,6 +4478,19 @@ var IERC7786AttributesABI = [
4193
4478
  outputs: [],
4194
4479
  stateMutability: "pure"
4195
4480
  },
4481
+ {
4482
+ type: "function",
4483
+ name: "interopBundleSalt",
4484
+ inputs: [
4485
+ {
4486
+ name: "_salt",
4487
+ type: "bytes32",
4488
+ internalType: "bytes32"
4489
+ }
4490
+ ],
4491
+ outputs: [],
4492
+ stateMutability: "pure"
4493
+ },
4196
4494
  {
4197
4495
  type: "function",
4198
4496
  name: "unbundlerAddress",
@@ -6726,6 +7024,11 @@ function normalizeAddrEq(a, b) {
6726
7024
  var hexEq = (a, b) => a.toLowerCase() === b.toLowerCase();
6727
7025
  var normalizeL1Token = (token) => isAddressEq(token, FORMAL_ETH_ADDRESS) ? ETH_ADDRESS : token;
6728
7026
 
7027
+ // src/core/utils/index.ts
7028
+ function assertNever(x) {
7029
+ throw new Error("Unexpected action type: " + String(x));
7030
+ }
7031
+
6729
7032
  // src/core/errors/formatter.ts
6730
7033
  function elideMiddle(s, max = 96) {
6731
7034
  if (s.length <= max) return s;
@@ -6867,6 +7170,11 @@ function isZKsyncError(e, opts) {
6867
7170
  if (typeof envelope?.type !== "string" || typeof envelope?.message !== "string") return false;
6868
7171
  return true;
6869
7172
  }
7173
+ var OP_WITHDRAWALS = {
7174
+ finalize: {
7175
+ fetchParams: {
7176
+ decodeMessage: "withdrawals.finalize.fetchParams:decodeMessage"}}
7177
+ };
6870
7178
 
6871
7179
  // src/core/errors/factory.ts
6872
7180
  function createError(type, input) {
@@ -7342,6 +7650,175 @@ function pickWithdrawRoute(args) {
7342
7650
  return "erc20-nonbase";
7343
7651
  }
7344
7652
 
7653
+ // src/core/resources/withdrawals/protocol.ts
7654
+ var MIN_INTEROP_WITHDRAWAL_MINOR = 32;
7655
+ function protocolFromVersion(version) {
7656
+ const [, minor] = version;
7657
+ return minor >= MIN_INTEROP_WITHDRAWAL_MINOR ? "interop-bundle" : "legacy-withdrawal";
7658
+ }
7659
+ async function detectWithdrawalProtocol(probes, override) {
7660
+ if (override) {
7661
+ return { protocol: override, source: { via: "override" } };
7662
+ }
7663
+ const version = await probes.protocolVersion();
7664
+ if (version) {
7665
+ return { protocol: protocolFromVersion(version), source: { via: "protocol-version", version } };
7666
+ }
7667
+ if (await probes.hasCodeAt(L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS)) {
7668
+ return {
7669
+ protocol: "interop-bundle",
7670
+ source: { via: "code-probe", address: L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS }
7671
+ };
7672
+ }
7673
+ return {
7674
+ protocol: "legacy-withdrawal",
7675
+ source: { via: "code-probe", address: L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS }
7676
+ };
7677
+ }
7678
+
7679
+ // src/core/resources/withdrawals/status.ts
7680
+ function phaseFromReadiness(r) {
7681
+ switch (r.kind) {
7682
+ case "FINALIZED":
7683
+ return { phase: "FINALIZED" };
7684
+ case "READY":
7685
+ return { phase: "READY_TO_FINALIZE" };
7686
+ case "NOT_READY":
7687
+ return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
7688
+ case "UNFINALIZABLE":
7689
+ return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
7690
+ default:
7691
+ return assertNever(r);
7692
+ }
7693
+ }
7694
+ var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
7695
+
7696
+ // src/core/resources/withdrawals/bundle.ts
7697
+ function buildWithdrawalBundle(input) {
7698
+ const {
7699
+ assetId,
7700
+ amount,
7701
+ l1Receiver,
7702
+ l2Token,
7703
+ isBaseToken,
7704
+ l1ChainId,
7705
+ l2AssetRouter,
7706
+ salt,
7707
+ codec,
7708
+ attributes,
7709
+ transferData
7710
+ } = input;
7711
+ const burnData = transferData.encodeBridgeBurnData(amount, l1Receiver, l2Token);
7712
+ const depositData = transferData.encodeAssetRouterDepositData(assetId, burnData);
7713
+ const indirectCallMessageValue = isBaseToken ? amount : 0n;
7714
+ const starter = [
7715
+ codec.formatAddress(l2AssetRouter),
7716
+ depositData,
7717
+ [attributes.indirectCall(indirectCallMessageValue), attributes.interopCallValue(0n)]
7718
+ ];
7719
+ return {
7720
+ destinationChain: codec.formatChain(l1ChainId),
7721
+ starters: [starter],
7722
+ // No `atomicBundle` attribute: L2 -> L1 withdrawals are non-atomic and are published to L1 as a
7723
+ // `BUNDLE_IDENTIFIER`-prefixed message, which is what the L1 handler proves inclusion of.
7724
+ bundleAttributes: [attributes.interopBundleSalt(salt)],
7725
+ value: indirectCallMessageValue
7726
+ };
7727
+ }
7728
+ function withdrawalBundleSalt(input) {
7729
+ return input.hash(input.sender, BigInt(input.nonce));
7730
+ }
7731
+ function keccakHex(data) {
7732
+ return `0x${utils.bytesToHex(sha3.keccak_256(utils.hexToBytes(data.slice(2))))}`;
7733
+ }
7734
+ function stripBundleIdentifier(messageData) {
7735
+ const prefix = `0x${messageData.slice(2, 4)}`;
7736
+ if (prefix !== BUNDLE_IDENTIFIER) {
7737
+ throw createError("STATE", {
7738
+ resource: "withdrawals",
7739
+ operation: OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
7740
+ 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.",
7741
+ context: { prefix, expected: BUNDLE_IDENTIFIER }
7742
+ });
7743
+ }
7744
+ return `0x${messageData.slice(4)}`;
7745
+ }
7746
+ function parseBundleHashFromLogs(logs, interopCenter = L2_INTEROP_CENTER_ADDRESS) {
7747
+ const center = interopCenter.toLowerCase();
7748
+ for (const log of logs) {
7749
+ if (log.address?.toLowerCase() !== center) continue;
7750
+ if (log.topics?.length !== 1) continue;
7751
+ if (!log.data || (log.data.length - 2) / 64 < 3) continue;
7752
+ return `0x${log.data.slice(66, 130)}`;
7753
+ }
7754
+ return void 0;
7755
+ }
7756
+ function buildWithdrawalFinalization(input) {
7757
+ const { messageData, sourceChainId, txNumberInBatch, proof } = input;
7758
+ const bundle = stripBundleIdentifier(messageData);
7759
+ return {
7760
+ bundle,
7761
+ bundleHash: input.bundleHash ?? keccakHex(bundle),
7762
+ proof: {
7763
+ chainId: sourceChainId,
7764
+ l1BatchNumber: proof.batchNumber,
7765
+ l2MessageIndex: proof.id,
7766
+ message: {
7767
+ txNumberInBatch,
7768
+ sender: input.interopCenter ?? L2_INTEROP_CENTER_ADDRESS,
7769
+ data: messageData
7770
+ },
7771
+ proof: proof.proof
7772
+ }
7773
+ };
7774
+ }
7775
+ var BundleStatus = /* @__PURE__ */ ((BundleStatus2) => {
7776
+ BundleStatus2[BundleStatus2["Unreceived"] = 0] = "Unreceived";
7777
+ BundleStatus2[BundleStatus2["Verified"] = 1] = "Verified";
7778
+ BundleStatus2[BundleStatus2["FullyExecuted"] = 2] = "FullyExecuted";
7779
+ BundleStatus2[BundleStatus2["Unbundled"] = 3] = "Unbundled";
7780
+ return BundleStatus2;
7781
+ })(BundleStatus || {});
7782
+ var CallStatus = /* @__PURE__ */ ((CallStatus2) => {
7783
+ CallStatus2[CallStatus2["Unprocessed"] = 0] = "Unprocessed";
7784
+ CallStatus2[CallStatus2["Executed"] = 1] = "Executed";
7785
+ CallStatus2[CallStatus2["Cancelled"] = 2] = "Cancelled";
7786
+ return CallStatus2;
7787
+ })(CallStatus || {});
7788
+ function classifyWithdrawalOutcome(bundleStatus, callStatus) {
7789
+ if (bundleStatus === 2 /* FullyExecuted */) return "finalized";
7790
+ if (bundleStatus !== 3 /* Unbundled */) return "pending";
7791
+ switch (callStatus) {
7792
+ case 1 /* Executed */:
7793
+ return "finalized";
7794
+ case 2 /* Cancelled */:
7795
+ return "failed";
7796
+ default:
7797
+ return "pending";
7798
+ }
7799
+ }
7800
+ function isBundleFinalized(status) {
7801
+ return status === 2 /* FullyExecuted */;
7802
+ }
7803
+
7804
+ // src/core/resources/protocol/semver.ts
7805
+ var SEMVER_MINOR_OFFSET = 32n;
7806
+ var SEMVER_MAJOR_OFFSET = 64n;
7807
+ var U32_MASK = 0xffffffffn;
7808
+ function unpackSemver(packed) {
7809
+ const patch = Number(packed & U32_MASK);
7810
+ const minor = Number(packed >> SEMVER_MINOR_OFFSET & U32_MASK);
7811
+ const major = Number(packed >> SEMVER_MAJOR_OFFSET & U32_MASK);
7812
+ return [major, minor, patch];
7813
+ }
7814
+ function packSemver(version) {
7815
+ const [major, minor, patch] = version;
7816
+ return BigInt(major) << SEMVER_MAJOR_OFFSET | BigInt(minor) << SEMVER_MINOR_OFFSET | BigInt(patch);
7817
+ }
7818
+ function formatProtocolVersion(version) {
7819
+ return version.join(".");
7820
+ }
7821
+
7345
7822
  // src/core/utils/events.ts
7346
7823
  function extractPreferAddress(opts) {
7347
7824
  const preferAddr = typeof opts?.prefer === "object" ? opts.prefer.address : opts?.prefer === "assetRouter" ? L2_ASSET_ROUTER_ADDRESS : L1_MESSENGER_ADDRESS;
@@ -7390,34 +7867,54 @@ function messengerLogIndex(raw, opts) {
7390
7867
  return (hits[index] ?? hits[0]).i;
7391
7868
  }
7392
7869
 
7870
+ exports.BundleStatus = BundleStatus;
7871
+ exports.CallStatus = CallStatus;
7393
7872
  exports.ETH_ADDRESS = ETH_ADDRESS;
7394
7873
  exports.FORMAL_ETH_ADDRESS = FORMAL_ETH_ADDRESS;
7395
7874
  exports.L1_MESSENGER_ADDRESS = L1_MESSENGER_ADDRESS;
7396
7875
  exports.L1_SOPH_TOKEN_ADDRESS = L1_SOPH_TOKEN_ADDRESS;
7397
7876
  exports.L2_ASSET_ROUTER_ADDRESS = L2_ASSET_ROUTER_ADDRESS;
7398
7877
  exports.L2_BASE_TOKEN_ADDRESS = L2_BASE_TOKEN_ADDRESS;
7878
+ exports.L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS = L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS;
7399
7879
  exports.L2_NATIVE_TOKEN_VAULT_ADDRESS = L2_NATIVE_TOKEN_VAULT_ADDRESS;
7880
+ exports.MIN_INTEROP_WITHDRAWAL_MINOR = MIN_INTEROP_WITHDRAWAL_MINOR;
7881
+ exports.SEMVER_MAJOR_OFFSET = SEMVER_MAJOR_OFFSET;
7882
+ exports.SEMVER_MINOR_OFFSET = SEMVER_MINOR_OFFSET;
7400
7883
  exports.abi = abi_exports;
7884
+ exports.buildWithdrawalBundle = buildWithdrawalBundle;
7885
+ exports.buildWithdrawalFinalization = buildWithdrawalFinalization;
7886
+ exports.classifyWithdrawalOutcome = classifyWithdrawalOutcome;
7887
+ exports.detectWithdrawalProtocol = detectWithdrawalProtocol;
7401
7888
  exports.errors = factory_exports;
7402
7889
  exports.findL1MessageSentLog = findL1MessageSentLog;
7403
7890
  exports.formatEnvelopePretty = formatEnvelopePretty;
7891
+ exports.formatProtocolVersion = formatProtocolVersion;
7404
7892
  exports.hexEq = hexEq;
7405
7893
  exports.isAddress = isAddress;
7406
7894
  exports.isAddressEq = isAddressEq;
7895
+ exports.isBundleFinalized = isBundleFinalized;
7407
7896
  exports.isETH = isETH;
7408
7897
  exports.isHash = isHash;
7409
7898
  exports.isHash66 = isHash66;
7410
7899
  exports.isHash66Array = isHash66Array;
7411
7900
  exports.isHashArray = isHashArray;
7412
7901
  exports.isL1MessageSentLog = isL1MessageSentLog;
7902
+ exports.keccakHex = keccakHex;
7413
7903
  exports.l1MessageSentSender = l1MessageSentSender;
7414
7904
  exports.makeTransportFromEthers = makeTransportFromEthers;
7415
7905
  exports.makeTransportFromViem = makeTransportFromViem;
7416
7906
  exports.messengerLogIndex = messengerLogIndex;
7417
7907
  exports.normalizeAddrEq = normalizeAddrEq;
7418
7908
  exports.normalizeL1Token = normalizeL1Token;
7909
+ exports.packSemver = packSemver;
7910
+ exports.parseBundleHashFromLogs = parseBundleHashFromLogs;
7911
+ exports.phaseFromReadiness = phaseFromReadiness;
7419
7912
  exports.pickDepositRoute = pickDepositRoute;
7420
7913
  exports.pickWithdrawRoute = pickWithdrawRoute;
7914
+ exports.protocolFromVersion = protocolFromVersion;
7915
+ exports.stripBundleIdentifier = stripBundleIdentifier;
7916
+ exports.unpackSemver = unpackSemver;
7917
+ exports.withdrawalBundleSalt = withdrawalBundleSalt;
7421
7918
  exports.zksRpc = zks_exports;
7422
7919
  //# sourceMappingURL=index.cjs.map
7423
7920
  //# sourceMappingURL=index.cjs.map