@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
@@ -37,6 +37,7 @@ var L2_BASE_TOKEN_ADDRESS = "0x000000000000000000000000000000000000800A";
37
37
  var L2_INTEROP_CENTER_ADDRESS = "0x000000000000000000000000000000000001000d";
38
38
  var L2_INTEROP_HANDLER_ADDRESS = "0x000000000000000000000000000000000001000e";
39
39
  var L2_INTEROP_ROOT_STORAGE_ADDRESS = "0x0000000000000000000000000000000000010008";
40
+ var L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS = "0x0000000000000000000000000000000000010015";
40
41
  var L2_MESSAGE_VERIFICATION_ADDRESS = "0x0000000000000000000000000000000000010009";
41
42
  var BUNDLE_IDENTIFIER = "0x01";
42
43
  var TOPIC_L1_MESSAGE_SENT_NEW = k256hex("L1MessageSent(uint256,bytes32,bytes)");
@@ -3490,6 +3491,294 @@ var IL1NullifierABI = [
3490
3491
  ];
3491
3492
  var IL1Nullifier_default = IL1NullifierABI;
3492
3493
 
3494
+ // src/core/internal/abis/IL1NullifierV32.ts
3495
+ var IL1NullifierV32ABI = [
3496
+ {
3497
+ anonymous: false,
3498
+ inputs: [
3499
+ {
3500
+ indexed: true,
3501
+ internalType: "uint256",
3502
+ name: "chainId",
3503
+ type: "uint256"
3504
+ },
3505
+ {
3506
+ indexed: true,
3507
+ internalType: "bytes32",
3508
+ name: "txDataHash",
3509
+ type: "bytes32"
3510
+ },
3511
+ {
3512
+ indexed: true,
3513
+ internalType: "bytes32",
3514
+ name: "l2DepositTxHash",
3515
+ type: "bytes32"
3516
+ }
3517
+ ],
3518
+ name: "BridgehubDepositFinalized",
3519
+ type: "event"
3520
+ },
3521
+ {
3522
+ inputs: [],
3523
+ name: "BRIDGE_HUB",
3524
+ outputs: [
3525
+ {
3526
+ internalType: "contract IL1Bridgehub",
3527
+ name: "",
3528
+ type: "address"
3529
+ }
3530
+ ],
3531
+ stateMutability: "view",
3532
+ type: "function"
3533
+ },
3534
+ {
3535
+ inputs: [],
3536
+ name: "l1AssetRouter",
3537
+ outputs: [
3538
+ {
3539
+ internalType: "contract IL1AssetRouter",
3540
+ name: "",
3541
+ type: "address"
3542
+ }
3543
+ ],
3544
+ stateMutability: "view",
3545
+ type: "function"
3546
+ },
3547
+ {
3548
+ // The contract that took over withdrawal finalization from the nullifier's own (removed)
3549
+ // `finalizeDeposit`.
3550
+ inputs: [],
3551
+ name: "l1InteropHandler",
3552
+ outputs: [
3553
+ {
3554
+ internalType: "address",
3555
+ name: "",
3556
+ type: "address"
3557
+ }
3558
+ ],
3559
+ stateMutability: "view",
3560
+ type: "function"
3561
+ },
3562
+ {
3563
+ inputs: [],
3564
+ name: "l1NativeTokenVault",
3565
+ outputs: [
3566
+ {
3567
+ internalType: "contract IL1NativeTokenVault",
3568
+ name: "",
3569
+ type: "address"
3570
+ }
3571
+ ],
3572
+ stateMutability: "view",
3573
+ type: "function"
3574
+ },
3575
+ {
3576
+ inputs: [
3577
+ {
3578
+ internalType: "uint256",
3579
+ name: "_chainId",
3580
+ type: "uint256"
3581
+ },
3582
+ {
3583
+ internalType: "bytes32",
3584
+ name: "_l2TxHash",
3585
+ type: "bytes32"
3586
+ }
3587
+ ],
3588
+ name: "depositHappened",
3589
+ outputs: [
3590
+ {
3591
+ internalType: "bytes32",
3592
+ name: "",
3593
+ type: "bytes32"
3594
+ }
3595
+ ],
3596
+ stateMutability: "view",
3597
+ type: "function"
3598
+ },
3599
+ {
3600
+ inputs: [
3601
+ {
3602
+ internalType: "uint256",
3603
+ name: "_chainId",
3604
+ type: "uint256"
3605
+ },
3606
+ {
3607
+ internalType: "bytes32",
3608
+ name: "_txDataHash",
3609
+ type: "bytes32"
3610
+ },
3611
+ {
3612
+ internalType: "bytes32",
3613
+ name: "_txHash",
3614
+ type: "bytes32"
3615
+ }
3616
+ ],
3617
+ name: "bridgehubConfirmL2TransactionForwarded",
3618
+ outputs: [],
3619
+ stateMutability: "nonpayable",
3620
+ type: "function"
3621
+ },
3622
+ {
3623
+ inputs: [
3624
+ {
3625
+ components: [
3626
+ {
3627
+ internalType: "uint256",
3628
+ name: "_chainId",
3629
+ type: "uint256"
3630
+ },
3631
+ {
3632
+ internalType: "address",
3633
+ name: "_depositSender",
3634
+ type: "address"
3635
+ },
3636
+ {
3637
+ internalType: "uint16",
3638
+ name: "_l2TxNumberInBatch",
3639
+ type: "uint16"
3640
+ },
3641
+ {
3642
+ internalType: "enum TxStatus",
3643
+ name: "_txStatus",
3644
+ type: "uint8"
3645
+ },
3646
+ {
3647
+ internalType: "bytes32",
3648
+ name: "_assetId",
3649
+ type: "bytes32"
3650
+ },
3651
+ {
3652
+ internalType: "bytes",
3653
+ name: "_assetData",
3654
+ type: "bytes"
3655
+ },
3656
+ {
3657
+ internalType: "bytes32",
3658
+ name: "_l2TxHash",
3659
+ type: "bytes32"
3660
+ },
3661
+ {
3662
+ internalType: "uint256",
3663
+ name: "_l2BatchNumber",
3664
+ type: "uint256"
3665
+ },
3666
+ {
3667
+ internalType: "uint256",
3668
+ name: "_l2MessageIndex",
3669
+ type: "uint256"
3670
+ },
3671
+ {
3672
+ internalType: "bytes32[]",
3673
+ name: "_merkleProof",
3674
+ type: "bytes32[]"
3675
+ }
3676
+ ],
3677
+ internalType: "struct ConfirmTransferResultData",
3678
+ name: "_confirmTransferResultData",
3679
+ type: "tuple"
3680
+ }
3681
+ ],
3682
+ name: "bridgeConfirmTransferResult",
3683
+ outputs: [],
3684
+ stateMutability: "nonpayable",
3685
+ type: "function"
3686
+ },
3687
+ {
3688
+ inputs: [
3689
+ {
3690
+ internalType: "uint256",
3691
+ name: "_chainId",
3692
+ type: "uint256"
3693
+ },
3694
+ {
3695
+ internalType: "address",
3696
+ name: "_depositSender",
3697
+ type: "address"
3698
+ },
3699
+ {
3700
+ internalType: "bytes32",
3701
+ name: "_assetId",
3702
+ type: "bytes32"
3703
+ },
3704
+ {
3705
+ internalType: "bytes",
3706
+ name: "_assetData",
3707
+ type: "bytes"
3708
+ },
3709
+ {
3710
+ internalType: "bytes32",
3711
+ name: "_l2TxHash",
3712
+ type: "bytes32"
3713
+ },
3714
+ {
3715
+ internalType: "uint256",
3716
+ name: "_l2BatchNumber",
3717
+ type: "uint256"
3718
+ },
3719
+ {
3720
+ internalType: "uint256",
3721
+ name: "_l2MessageIndex",
3722
+ type: "uint256"
3723
+ },
3724
+ {
3725
+ internalType: "uint16",
3726
+ name: "_l2TxNumberInBatch",
3727
+ type: "uint16"
3728
+ },
3729
+ {
3730
+ internalType: "bytes32[]",
3731
+ name: "_merkleProof",
3732
+ type: "bytes32[]"
3733
+ }
3734
+ ],
3735
+ name: "bridgeRecoverFailedTransfer",
3736
+ outputs: [],
3737
+ stateMutability: "nonpayable",
3738
+ type: "function"
3739
+ },
3740
+ {
3741
+ inputs: [
3742
+ {
3743
+ internalType: "contract IL1NativeTokenVault",
3744
+ name: "_nativeTokenVault",
3745
+ type: "address"
3746
+ }
3747
+ ],
3748
+ name: "setL1NativeTokenVault",
3749
+ outputs: [],
3750
+ stateMutability: "nonpayable",
3751
+ type: "function"
3752
+ },
3753
+ {
3754
+ inputs: [
3755
+ {
3756
+ internalType: "address",
3757
+ name: "_l1AssetRouter",
3758
+ type: "address"
3759
+ }
3760
+ ],
3761
+ name: "setL1AssetRouter",
3762
+ outputs: [],
3763
+ stateMutability: "nonpayable",
3764
+ type: "function"
3765
+ },
3766
+ {
3767
+ inputs: [
3768
+ {
3769
+ internalType: "address",
3770
+ name: "_l1InteropHandler",
3771
+ type: "address"
3772
+ }
3773
+ ],
3774
+ name: "setL1InteropHandler",
3775
+ outputs: [],
3776
+ stateMutability: "nonpayable",
3777
+ type: "function"
3778
+ }
3779
+ ];
3780
+ var IL1NullifierV32_default = IL1NullifierV32ABI;
3781
+
3493
3782
  // src/core/internal/abis/IL2AssetRouter.ts
3494
3783
  var IL2AssetRouterABI = [
3495
3784
  {
@@ -5023,6 +5312,19 @@ var IERC7786AttributesABI = [
5023
5312
  outputs: [],
5024
5313
  stateMutability: "pure"
5025
5314
  },
5315
+ {
5316
+ type: "function",
5317
+ name: "interopBundleSalt",
5318
+ inputs: [
5319
+ {
5320
+ name: "_salt",
5321
+ type: "bytes32",
5322
+ internalType: "bytes32"
5323
+ }
5324
+ ],
5325
+ outputs: [],
5326
+ stateMutability: "pure"
5327
+ },
5026
5328
  {
5027
5329
  type: "function",
5028
5330
  name: "unbundlerAddress",
@@ -7537,7 +7839,7 @@ function createErrorOps(decodeRevert2) {
7537
7839
  function wrap8(operation, fn, opts) {
7538
7840
  return run("INTERNAL", operation, fn, opts);
7539
7841
  }
7540
- function wrapAs10(kind, operation, fn, opts) {
7842
+ function wrapAs11(kind, operation, fn, opts) {
7541
7843
  return run(kind, operation, fn, opts);
7542
7844
  }
7543
7845
  async function toResult3(operation, fn, opts) {
@@ -7558,7 +7860,7 @@ function createErrorOps(decodeRevert2) {
7558
7860
  return { ok: false, error: shaped };
7559
7861
  }
7560
7862
  }
7561
- return { wrap: wrap8, wrapAs: wrapAs10, toResult: toResult3 };
7863
+ return { wrap: wrap8, wrapAs: wrapAs11, toResult: toResult3 };
7562
7864
  }
7563
7865
  return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
7564
7866
  }
@@ -7702,10 +8004,24 @@ function classifyReadinessFromRevert(e) {
7702
8004
  // src/adapters/ethers/errors/error-ops.ts
7703
8005
  var { toZKsyncError, createErrorHandlers } = createErrorOps(decodeRevert);
7704
8006
 
8007
+ // src/core/resources/protocol/semver.ts
8008
+ var SEMVER_MINOR_OFFSET = 32n;
8009
+ var SEMVER_MAJOR_OFFSET = 64n;
8010
+ var U32_MASK = 0xffffffffn;
8011
+ function unpackSemver(packed) {
8012
+ const patch = Number(packed & U32_MASK);
8013
+ const minor = Number(packed >> SEMVER_MINOR_OFFSET & U32_MASK);
8014
+ const major = Number(packed >> SEMVER_MAJOR_OFFSET & U32_MASK);
8015
+ return [major, minor, patch];
8016
+ }
8017
+
7705
8018
  // src/adapters/ethers/client.ts
7706
8019
  var { wrapAs, wrap } = createErrorHandlers("client");
7707
8020
  var ChainTypeManagerABI = [
7708
- "function getSemverProtocolVersion() view returns (uint32,uint32,uint32)"
8021
+ "function getSemverProtocolVersion() view returns (uint32,uint32,uint32)",
8022
+ // Per-chain version. `getSemverProtocolVersion` reports the CTM's own (latest) version, which
8023
+ // runs ahead of individual chains mid-upgrade — so capability gating must use this one.
8024
+ "function getProtocolVersion(uint256 _chainId) view returns (uint256)"
7709
8025
  ];
7710
8026
  function createEthersClient(args) {
7711
8027
  const { l1, l2, signer } = args;
@@ -7864,6 +8180,21 @@ function createEthersClient(args) {
7864
8180
  );
7865
8181
  return semver;
7866
8182
  }
8183
+ async function getChainProtocolVersion(chainId) {
8184
+ try {
8185
+ const targetChainId = chainId ?? (await l2.getNetwork()).chainId;
8186
+ const { bridgehub } = await ensureAddresses();
8187
+ const bh = new ethers.Contract(bridgehub, IBridgehub_default, l1);
8188
+ const chainTypeManager = await bh.chainTypeManager(targetChainId);
8189
+ if (chainTypeManager.toLowerCase() === FORMAL_ETH_ADDRESS) return void 0;
8190
+ const ctm = new ethers.Contract(chainTypeManager, ChainTypeManagerABI, l1);
8191
+ const packed = await ctm.getProtocolVersion(targetChainId);
8192
+ if (packed === 0n) return void 0;
8193
+ return unpackSemver(packed);
8194
+ } catch {
8195
+ return void 0;
8196
+ }
8197
+ }
7867
8198
  function signerFor(target) {
7868
8199
  if (target === "l1") {
7869
8200
  return boundSigner.provider === l1 ? boundSigner : boundSigner.connect(l1);
@@ -7888,6 +8219,7 @@ function createEthersClient(args) {
7888
8219
  refresh,
7889
8220
  baseToken,
7890
8221
  getProtocolVersion,
8222
+ getChainProtocolVersion,
7891
8223
  signerFor
7892
8224
  };
7893
8225
  return client;
@@ -9744,7 +10076,7 @@ function pickWithdrawRoute(args) {
9744
10076
  }
9745
10077
 
9746
10078
  // src/adapters/ethers/resources/withdrawals/context.ts
9747
- async function commonCtx2(p, client, tokens, contracts) {
10079
+ async function commonCtx2(p, client, tokens, contracts, protocol) {
9748
10080
  const sender = await client.signer.getAddress();
9749
10081
  const {
9750
10082
  bridgehub,
@@ -9752,10 +10084,12 @@ async function commonCtx2(p, client, tokens, contracts) {
9752
10084
  l1Nullifier,
9753
10085
  l2AssetRouter,
9754
10086
  l2NativeTokenVault,
9755
- l2BaseTokenSystem
10087
+ l2BaseTokenSystem,
10088
+ interopCenter
9756
10089
  } = await contracts.addresses();
9757
10090
  const { chainId } = await client.l2.getNetwork();
9758
10091
  const chainIdL2 = BigInt(chainId);
10092
+ const l1ChainId = BigInt((await client.l1.getNetwork()).chainId);
9759
10093
  const resolvedToken = await tokens.resolve(p.token, { chain: "l2" });
9760
10094
  const baseTokenAssetId = resolvedToken.baseTokenAssetId;
9761
10095
  const baseTokenL1 = await tokens.l1TokenFromAssetId(baseTokenAssetId);
@@ -9777,6 +10111,9 @@ async function commonCtx2(p, client, tokens, contracts) {
9777
10111
  l2AssetRouter,
9778
10112
  l2NativeTokenVault,
9779
10113
  l2BaseTokenSystem,
10114
+ interopCenter,
10115
+ protocol,
10116
+ l1ChainId,
9780
10117
  baseIsEth,
9781
10118
  gasOverrides: p.l2TxOverrides ? toGasOverrides(p.l2TxOverrides) : void 0
9782
10119
  };
@@ -10013,7 +10350,269 @@ function routeErc20NonBase2() {
10013
10350
  });
10014
10351
  const fees = buildFeeBreakdown2({
10015
10352
  feeToken: ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2),
10016
- l2Gas: withdrawGas
10353
+ l2Gas: withdrawGas
10354
+ });
10355
+ return { steps, approvals, fees };
10356
+ }
10357
+ };
10358
+ }
10359
+ var PREFIX_EVM_CHAIN = ethers.getBytes("0x00010000");
10360
+ var PREFIX_EVM_ADDRESS = ethers.getBytes("0x000100000014");
10361
+ function formatInteropEvmChain(chainId) {
10362
+ const chainRef = ethers.toBeArray(chainId);
10363
+ const chainRefLength = ethers.getBytes(ethers.toBeHex(chainRef.length, 1));
10364
+ const payload = ethers.concat([PREFIX_EVM_CHAIN, chainRefLength, chainRef, new Uint8Array([0])]);
10365
+ return ethers.hexlify(payload);
10366
+ }
10367
+ function formatInteropEvmAddress(address) {
10368
+ const normalized = ethers.getAddress(address);
10369
+ const addrBytes = ethers.getBytes(normalized);
10370
+ const payload = ethers.concat([PREFIX_EVM_ADDRESS, addrBytes]);
10371
+ return ethers.hexlify(payload);
10372
+ }
10373
+ var interopCodec = {
10374
+ formatChain: formatInteropEvmChain,
10375
+ formatAddress: formatInteropEvmAddress
10376
+ };
10377
+
10378
+ // src/core/resources/interop/attributes/call.ts
10379
+ function createCallAttributes(codec) {
10380
+ const indirectCall = (messageValue) => codec.encode("indirectCall", [messageValue]);
10381
+ const interopCallValue = (bridgedAmount) => codec.encode("interopCallValue", [bridgedAmount]);
10382
+ return {
10383
+ indirectCall,
10384
+ interopCallValue
10385
+ };
10386
+ }
10387
+
10388
+ // src/core/resources/interop/attributes/bundle.ts
10389
+ function createBundleAttributes(codec) {
10390
+ const executionAddress = (executor) => codec.encode("executionAddress", [executor]);
10391
+ const unbundlerAddress = (addr) => codec.encode("unbundlerAddress", [addr]);
10392
+ const useFixedFee = (enabled) => codec.encode("useFixedFee", [enabled]);
10393
+ const interopBundleSalt = (salt) => codec.encode("interopBundleSalt", [salt]);
10394
+ return {
10395
+ executionAddress,
10396
+ unbundlerAddress,
10397
+ useFixedFee,
10398
+ interopBundleSalt
10399
+ };
10400
+ }
10401
+
10402
+ // src/core/resources/interop/attributes/resource.ts
10403
+ function createAttributesResource(codec) {
10404
+ return {
10405
+ call: createCallAttributes(codec),
10406
+ bundle: createBundleAttributes(codec)
10407
+ };
10408
+ }
10409
+
10410
+ // src/adapters/ethers/resources/interop/attributes/resource.ts
10411
+ function getInteropAttributes(params, ctx) {
10412
+ const bundleAttributes = [];
10413
+ if (params.execution?.only) {
10414
+ bundleAttributes.push(ctx.attributes.bundle.executionAddress(params.execution.only));
10415
+ }
10416
+ if (params.unbundling?.by) {
10417
+ bundleAttributes.push(ctx.attributes.bundle.unbundlerAddress(params.unbundling.by));
10418
+ }
10419
+ bundleAttributes.push(ctx.attributes.bundle.useFixedFee(params.fee?.useFixed ?? false));
10420
+ const callAttributes = params.actions.map((action) => {
10421
+ switch (action.type) {
10422
+ case "sendNative": {
10423
+ const baseMatches = ctx.baseTokens.src.toLowerCase() === ctx.baseTokens.dst.toLowerCase();
10424
+ if (baseMatches) {
10425
+ return [ctx.attributes.call.interopCallValue(action.amount)];
10426
+ }
10427
+ return [ctx.attributes.call.indirectCall(action.amount)];
10428
+ }
10429
+ case "call":
10430
+ if (action.value && action.value > 0n) {
10431
+ return [ctx.attributes.call.interopCallValue(action.value)];
10432
+ }
10433
+ return [];
10434
+ case "sendErc20":
10435
+ return [ctx.attributes.call.indirectCall(0n)];
10436
+ default:
10437
+ assertNever(action);
10438
+ }
10439
+ });
10440
+ return { bundleAttributes, callAttributes };
10441
+ }
10442
+ function createEthersAttributesResource(opts = {}) {
10443
+ const iface = opts.iface ?? new ethers.Interface(IERC7786Attributes_default);
10444
+ const encode2 = (fn, args) => iface.encodeFunctionData(fn, args);
10445
+ return createAttributesResource({ encode: encode2 });
10446
+ }
10447
+
10448
+ // src/core/resources/withdrawals/bundle.ts
10449
+ function buildWithdrawalBundle(input) {
10450
+ const {
10451
+ assetId,
10452
+ amount,
10453
+ l1Receiver,
10454
+ l2Token,
10455
+ isBaseToken,
10456
+ l1ChainId,
10457
+ l2AssetRouter,
10458
+ salt,
10459
+ codec,
10460
+ attributes: attributes2,
10461
+ transferData
10462
+ } = input;
10463
+ const burnData = transferData.encodeBridgeBurnData(amount, l1Receiver, l2Token);
10464
+ const depositData = transferData.encodeAssetRouterDepositData(assetId, burnData);
10465
+ const indirectCallMessageValue = isBaseToken ? amount : 0n;
10466
+ const starter = [
10467
+ codec.formatAddress(l2AssetRouter),
10468
+ depositData,
10469
+ [attributes2.indirectCall(indirectCallMessageValue), attributes2.interopCallValue(0n)]
10470
+ ];
10471
+ return {
10472
+ destinationChain: codec.formatChain(l1ChainId),
10473
+ starters: [starter],
10474
+ // No `atomicBundle` attribute: L2 -> L1 withdrawals are non-atomic and are published to L1 as a
10475
+ // `BUNDLE_IDENTIFIER`-prefixed message, which is what the L1 handler proves inclusion of.
10476
+ bundleAttributes: [attributes2.interopBundleSalt(salt)],
10477
+ value: indirectCallMessageValue
10478
+ };
10479
+ }
10480
+
10481
+ // src/adapters/ethers/resources/withdrawals/routes/interop-bundle.ts
10482
+ var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
10483
+ var attributes = createEthersAttributesResource();
10484
+ function saltFor(sender, nonce) {
10485
+ return ethers.keccak256(
10486
+ ethers.AbiCoder.defaultAbiCoder().encode(["address", "uint256"], [sender, BigInt(nonce)])
10487
+ );
10488
+ }
10489
+ function routeInteropBundle() {
10490
+ return {
10491
+ async build(p, ctx) {
10492
+ const steps = [];
10493
+ const approvals = [];
10494
+ const isBaseToken = ctx.route === "base";
10495
+ const l1Receiver = p.to ?? ctx.sender;
10496
+ let assetId;
10497
+ let allowanceSufficient = true;
10498
+ if (isBaseToken) {
10499
+ assetId = ctx.baseTokenAssetId;
10500
+ } else {
10501
+ assetId = await wrapAs9(
10502
+ "CONTRACT",
10503
+ OP_WITHDRAWALS.erc20.ensureRegistered,
10504
+ async () => {
10505
+ const ntv = await ctx.contracts.l2NativeTokenVault();
10506
+ return await ntv.getFunction("ensureTokenIsRegistered").staticCall(p.token);
10507
+ },
10508
+ {
10509
+ ctx: { where: "L2NativeTokenVault.ensureTokenIsRegistered", token: p.token },
10510
+ message: "Failed to ensure token is registered in L2NativeTokenVault."
10511
+ }
10512
+ );
10513
+ const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
10514
+ const current = await wrapAs9(
10515
+ "CONTRACT",
10516
+ OP_WITHDRAWALS.erc20.allowance,
10517
+ () => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
10518
+ {
10519
+ ctx: {
10520
+ where: "erc20.allowance",
10521
+ chain: "L2",
10522
+ token: p.token,
10523
+ spender: ctx.l2NativeTokenVault
10524
+ },
10525
+ message: "Failed to read L2 ERC-20 allowance."
10526
+ }
10527
+ );
10528
+ allowanceSufficient = current >= p.amount;
10529
+ if (!allowanceSufficient) {
10530
+ approvals.push({ token: p.token, spender: ctx.l2NativeTokenVault, amount: p.amount });
10531
+ const approveTx = {
10532
+ to: p.token,
10533
+ data: erc20.interface.encodeFunctionData("approve", [ctx.l2NativeTokenVault, p.amount]),
10534
+ from: ctx.sender
10535
+ };
10536
+ const approveGas = await quoteL2Gas4({ ctx, tx: approveTx });
10537
+ if (approveGas) {
10538
+ approveTx.gasLimit = approveGas.gasLimit;
10539
+ approveTx.maxFeePerGas = approveGas.maxFeePerGas;
10540
+ approveTx.maxPriorityFeePerGas = approveGas.maxPriorityFeePerGas;
10541
+ }
10542
+ steps.push({
10543
+ key: `approve:l2:${p.token}:${ctx.l2NativeTokenVault}`,
10544
+ kind: "approve:l2",
10545
+ description: `Approve ${p.amount} to NativeTokenVault`,
10546
+ tx: approveTx
10547
+ });
10548
+ }
10549
+ }
10550
+ const nonce = await wrapAs9(
10551
+ "RPC",
10552
+ OP_WITHDRAWALS.prepare,
10553
+ () => ctx.client.l2.getTransactionCount(ctx.sender, "pending"),
10554
+ {
10555
+ ctx: { where: "l2.getTransactionCount", sender: ctx.sender },
10556
+ message: "Failed to read L2 nonce for the interop bundle salt."
10557
+ }
10558
+ );
10559
+ const bundle = buildWithdrawalBundle({
10560
+ assetId,
10561
+ amount: p.amount,
10562
+ l1Receiver,
10563
+ l2Token: isBaseToken ? FORMAL_ETH_ADDRESS : p.token,
10564
+ isBaseToken,
10565
+ l1ChainId: ctx.l1ChainId,
10566
+ l2AssetRouter: ctx.l2AssetRouter,
10567
+ salt: saltFor(ctx.sender, nonce),
10568
+ codec: interopCodec,
10569
+ attributes: {
10570
+ indirectCall: attributes.call.indirectCall,
10571
+ interopCallValue: attributes.call.interopCallValue,
10572
+ interopBundleSalt: attributes.bundle.interopBundleSalt
10573
+ },
10574
+ transferData: {
10575
+ encodeBridgeBurnData: (amount, receiver, token) => encodeNativeTokenVaultTransferData(amount, receiver, token),
10576
+ encodeAssetRouterDepositData: (id, data2) => encodeSecondBridgeDataV1(id, data2)
10577
+ }
10578
+ });
10579
+ const interopCenter = await ctx.contracts.interopCenter();
10580
+ const data = await wrapAs9(
10581
+ "INTERNAL",
10582
+ OP_WITHDRAWALS.erc20.encodeWithdraw,
10583
+ () => Promise.resolve(
10584
+ interopCenter.interface.encodeFunctionData("sendBundle", [
10585
+ bundle.destinationChain,
10586
+ bundle.starters,
10587
+ bundle.bundleAttributes
10588
+ ])
10589
+ ),
10590
+ {
10591
+ ctx: { where: "InteropCenter.sendBundle", assetId },
10592
+ message: "Failed to encode sendBundle calldata."
10593
+ }
10594
+ );
10595
+ const sendTx = {
10596
+ to: ctx.interopCenter,
10597
+ data,
10598
+ from: ctx.sender,
10599
+ value: bundle.value
10600
+ };
10601
+ const sendGas = allowanceSufficient ? await quoteL2Gas4({ ctx, tx: sendTx }) : void 0;
10602
+ if (sendGas) {
10603
+ sendTx.gasLimit = sendGas.gasLimit;
10604
+ sendTx.maxFeePerGas = sendGas.maxFeePerGas;
10605
+ sendTx.maxPriorityFeePerGas = sendGas.maxPriorityFeePerGas;
10606
+ }
10607
+ steps.push({
10608
+ key: "interop-center:send-bundle",
10609
+ kind: "interop-center:send-bundle",
10610
+ description: "Burn on L2 & send L2\u2192L1 withdrawal bundle",
10611
+ tx: sendTx
10612
+ });
10613
+ const fees = buildFeeBreakdown2({
10614
+ feeToken: ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2),
10615
+ l2Gas: sendGas
10017
10616
  });
10018
10617
  return { steps, approvals, fees };
10019
10618
  }
@@ -10067,176 +10666,379 @@ function messengerLogIndex(raw, opts) {
10067
10666
  }
10068
10667
  return (hits[index] ?? hits[0]).i;
10069
10668
  }
10669
+ function keccakHex(data) {
10670
+ return `0x${utils.bytesToHex(sha3.keccak_256(utils.hexToBytes(data.slice(2))))}`;
10671
+ }
10672
+ function stripBundleIdentifier(messageData) {
10673
+ const prefix = `0x${messageData.slice(2, 4)}`;
10674
+ if (prefix !== BUNDLE_IDENTIFIER) {
10675
+ throw createError("STATE", {
10676
+ resource: "withdrawals",
10677
+ operation: OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
10678
+ 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.",
10679
+ context: { prefix, expected: BUNDLE_IDENTIFIER }
10680
+ });
10681
+ }
10682
+ return `0x${messageData.slice(4)}`;
10683
+ }
10684
+ function parseBundleHashFromLogs(logs, interopCenter = L2_INTEROP_CENTER_ADDRESS) {
10685
+ const center = interopCenter.toLowerCase();
10686
+ for (const log of logs) {
10687
+ if (log.address?.toLowerCase() !== center) continue;
10688
+ if (log.topics?.length !== 1) continue;
10689
+ if (!log.data || (log.data.length - 2) / 64 < 3) continue;
10690
+ return `0x${log.data.slice(66, 130)}`;
10691
+ }
10692
+ return void 0;
10693
+ }
10694
+ function buildWithdrawalFinalization(input) {
10695
+ const { messageData, sourceChainId, txNumberInBatch, proof } = input;
10696
+ const bundle = stripBundleIdentifier(messageData);
10697
+ return {
10698
+ bundle,
10699
+ bundleHash: input.bundleHash ?? keccakHex(bundle),
10700
+ proof: {
10701
+ chainId: sourceChainId,
10702
+ l1BatchNumber: proof.batchNumber,
10703
+ l2MessageIndex: proof.id,
10704
+ message: {
10705
+ txNumberInBatch,
10706
+ sender: input.interopCenter ?? L2_INTEROP_CENTER_ADDRESS,
10707
+ data: messageData
10708
+ },
10709
+ proof: proof.proof
10710
+ }
10711
+ };
10712
+ }
10713
+ function classifyWithdrawalOutcome(bundleStatus, callStatus) {
10714
+ if (bundleStatus === 2 /* FullyExecuted */) return "finalized";
10715
+ if (bundleStatus !== 3 /* Unbundled */) return "pending";
10716
+ switch (callStatus) {
10717
+ case 1 /* Executed */:
10718
+ return "finalized";
10719
+ case 2 /* Cancelled */:
10720
+ return "failed";
10721
+ default:
10722
+ return "pending";
10723
+ }
10724
+ }
10725
+
10726
+ // src/core/resources/withdrawals/protocol.ts
10727
+ var MIN_INTEROP_WITHDRAWAL_MINOR = 32;
10728
+ function protocolFromVersion(version) {
10729
+ const [, minor] = version;
10730
+ return minor >= MIN_INTEROP_WITHDRAWAL_MINOR ? "interop-bundle" : "legacy-withdrawal";
10731
+ }
10732
+ async function detectWithdrawalProtocol(probes, override) {
10733
+ if (override) {
10734
+ return { protocol: override, source: { via: "override" } };
10735
+ }
10736
+ const version = await probes.protocolVersion();
10737
+ if (version) {
10738
+ return { protocol: protocolFromVersion(version), source: { via: "protocol-version", version } };
10739
+ }
10740
+ if (await probes.hasCodeAt(L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS)) {
10741
+ return {
10742
+ protocol: "interop-bundle",
10743
+ source: { via: "code-probe", address: L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS }
10744
+ };
10745
+ }
10746
+ return {
10747
+ protocol: "legacy-withdrawal",
10748
+ source: { via: "code-probe", address: L2_INTEROP_ATTRIBUTE_PARSER_ADDRESS }
10749
+ };
10750
+ }
10751
+
10752
+ // src/adapters/ethers/resources/withdrawals/services/protocol.ts
10753
+ function createWithdrawalProtocolService(client, override) {
10754
+ let cached;
10755
+ async function hasCodeAt(address) {
10756
+ try {
10757
+ const code = await client.l2.getCode(address);
10758
+ return !!code && code !== "0x";
10759
+ } catch {
10760
+ return false;
10761
+ }
10762
+ }
10763
+ async function protocolVersion() {
10764
+ try {
10765
+ return await client.getChainProtocolVersion();
10766
+ } catch {
10767
+ return void 0;
10768
+ }
10769
+ }
10770
+ function detect() {
10771
+ cached ??= detectWithdrawalProtocol(
10772
+ {
10773
+ protocolVersion,
10774
+ hasCodeAt
10775
+ },
10776
+ override
10777
+ ).catch((e) => {
10778
+ cached = void 0;
10779
+ throw e;
10780
+ });
10781
+ return cached;
10782
+ }
10783
+ return {
10784
+ detect,
10785
+ async protocol() {
10786
+ return (await detect()).protocol;
10787
+ },
10788
+ refresh() {
10789
+ cached = void 0;
10790
+ }
10791
+ };
10792
+ }
10070
10793
 
10071
10794
  // src/adapters/ethers/resources/withdrawals/services/finalization.ts
10072
- var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
10795
+ var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
10073
10796
  var IL1NullifierMini = [
10074
10797
  "function isWithdrawalFinalized(uint256,uint256,uint256) view returns (bool)"
10075
10798
  ];
10076
- function createFinalizationServices(client) {
10799
+ function createFinalizationServices(client, protocolService = createWithdrawalProtocolService(client)) {
10077
10800
  const { l1, l2, signer } = client;
10078
- return {
10079
- async fetchFinalizeDepositParams(l2TxHash) {
10080
- const parsed = await wrapAs9(
10081
- "RPC",
10082
- OP_WITHDRAWALS.finalize.fetchParams.receipt,
10083
- () => client.zks.getReceiptWithL2ToL1(l2TxHash),
10084
- {
10085
- ctx: { where: "getReceiptWithL2ToL1", l2TxHash },
10086
- message: "Failed to fetch L2 receipt (with L2\u2192L1 logs)."
10801
+ async function finalizationTarget(protocol) {
10802
+ const { l1Nullifier } = await client.ensureAddresses();
10803
+ if (protocol === "legacy-withdrawal") return l1Nullifier;
10804
+ const nullifier = new ethers.Contract(l1Nullifier, IL1NullifierV32_default, l1);
10805
+ const handler = await wrapAs10(
10806
+ "CONTRACT",
10807
+ OP_WITHDRAWALS.finalize.fetchParams.receipt,
10808
+ () => nullifier.l1InteropHandler(),
10809
+ {
10810
+ ctx: { where: "L1Nullifier.l1InteropHandler", l1Nullifier },
10811
+ message: "Failed to resolve the L1 interop handler. The chain reports protocol v32+, but its L1Nullifier does not expose `l1InteropHandler()`."
10812
+ }
10813
+ );
10814
+ return handler;
10815
+ }
10816
+ async function fetchMessageAndProof(l2TxHash) {
10817
+ const raw = await wrapAs10(
10818
+ "RPC",
10819
+ OP_WITHDRAWALS.finalize.fetchParams.receipt,
10820
+ () => client.zks.getReceiptWithL2ToL1(l2TxHash),
10821
+ {
10822
+ ctx: { where: "getReceiptWithL2ToL1", l2TxHash },
10823
+ message: "Failed to fetch L2 receipt (with L2\u2192L1 logs)."
10824
+ }
10825
+ );
10826
+ if (!raw) {
10827
+ throw createError("STATE", {
10828
+ resource: "withdrawals",
10829
+ operation: OP_WITHDRAWALS.finalize.fetchParams.receipt,
10830
+ message: "L2 receipt not found.",
10831
+ context: { l2TxHash }
10832
+ });
10833
+ }
10834
+ const ev = await wrapAs10(
10835
+ "INTERNAL",
10836
+ OP_WITHDRAWALS.finalize.fetchParams.findMessage,
10837
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
10838
+ () => Promise.resolve(findL1MessageSentLog(raw, { index: 0 })),
10839
+ {
10840
+ ctx: { l2TxHash, index: 0 },
10841
+ message: "Failed to locate L1MessageSent event in L2 receipt."
10842
+ }
10843
+ );
10844
+ const message = await wrapAs10(
10845
+ "INTERNAL",
10846
+ OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
10847
+ () => Promise.resolve(ethers.AbiCoder.defaultAbiCoder().decode(["bytes"], ev.data)[0]),
10848
+ {
10849
+ ctx: { where: "decode L1MessageSent", data: ev.data },
10850
+ message: "Failed to decode withdrawal message."
10851
+ }
10852
+ );
10853
+ const idx = await wrapAs10(
10854
+ "INTERNAL",
10855
+ OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
10856
+ () => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
10857
+ {
10858
+ ctx: { where: "derive messenger log index", l2TxHash, receipt: raw },
10859
+ message: "Failed to derive messenger log index."
10860
+ }
10861
+ );
10862
+ const proof = await wrapAs10(
10863
+ "RPC",
10864
+ OP_WITHDRAWALS.finalize.fetchParams.proof,
10865
+ () => client.zks.getL2ToL1LogProof(l2TxHash, idx),
10866
+ {
10867
+ ctx: { where: "get L2\u2192L1 log proof", l2TxHash, messengerLogIndex: idx },
10868
+ message: "Failed to fetch L2\u2192L1 log proof."
10869
+ }
10870
+ );
10871
+ const { chainId } = await wrapAs10(
10872
+ "RPC",
10873
+ OP_WITHDRAWALS.finalize.fetchParams.network,
10874
+ () => l2.getNetwork(),
10875
+ { ctx: { where: "l2.getNetwork" }, message: "Failed to read L2 network." }
10876
+ );
10877
+ const txNumberInBatch = Number(raw.transactionIndex ?? 0);
10878
+ const l2Sender = l1MessageSentSender(ev);
10879
+ return { raw, message, proof, chainId: BigInt(chainId), txNumberInBatch, l2Sender };
10880
+ }
10881
+ async function fetchFinalization(l2TxHash) {
10882
+ const protocol = await protocolService.protocol();
10883
+ const { raw, message, proof, chainId, txNumberInBatch, l2Sender } = await fetchMessageAndProof(l2TxHash);
10884
+ const target = await finalizationTarget(protocol);
10885
+ if (protocol === "legacy-withdrawal") {
10886
+ const params2 = {
10887
+ chainId,
10888
+ l2BatchNumber: proof.batchNumber,
10889
+ l2MessageIndex: proof.id,
10890
+ l2Sender,
10891
+ l2TxNumberInBatch: txNumberInBatch,
10892
+ message,
10893
+ merkleProof: proof.proof
10894
+ };
10895
+ return {
10896
+ target,
10897
+ finalization: { protocol, params: params2 },
10898
+ key: {
10899
+ chainIdL2: chainId,
10900
+ l2BatchNumber: proof.batchNumber,
10901
+ l2MessageIndex: proof.id
10087
10902
  }
10088
- );
10089
- if (!parsed) {
10090
- throw createError("STATE", {
10091
- resource: "withdrawals",
10092
- operation: OP_WITHDRAWALS.finalize.fetchParams.receipt,
10093
- message: "L2 receipt not found.",
10094
- context: { l2TxHash }
10095
- });
10903
+ };
10904
+ }
10905
+ const { interopCenter } = await client.ensureAddresses();
10906
+ const params = buildWithdrawalFinalization({
10907
+ messageData: message,
10908
+ sourceChainId: chainId,
10909
+ txNumberInBatch,
10910
+ proof: { batchNumber: proof.batchNumber, id: proof.id, proof: proof.proof },
10911
+ // Prefer the hash the InteropCenter emitted over recomputing it.
10912
+ bundleHash: parseBundleHashFromLogs(raw.logs ?? [], interopCenter),
10913
+ interopCenter
10914
+ });
10915
+ return {
10916
+ target,
10917
+ finalization: { protocol, params },
10918
+ key: {
10919
+ chainIdL2: chainId,
10920
+ l2BatchNumber: proof.batchNumber,
10921
+ l2MessageIndex: proof.id,
10922
+ bundleHash: params.bundleHash
10096
10923
  }
10097
- const ev = await wrapAs9(
10098
- "INTERNAL",
10099
- OP_WITHDRAWALS.finalize.fetchParams.findMessage,
10100
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
10101
- () => Promise.resolve(findL1MessageSentLog(parsed, { index: 0 })),
10924
+ };
10925
+ }
10926
+ async function withdrawalOutcome(finalization) {
10927
+ const target = await finalizationTarget(finalization.protocol);
10928
+ if (finalization.protocol === "legacy-withdrawal") {
10929
+ const c = new ethers.Contract(target, IL1NullifierMini, l1);
10930
+ const done = await wrapAs10(
10931
+ "RPC",
10932
+ OP_WITHDRAWALS.finalize.isFinalized,
10933
+ () => c.isWithdrawalFinalized(
10934
+ finalization.params.chainId,
10935
+ finalization.params.l2BatchNumber,
10936
+ finalization.params.l2MessageIndex
10937
+ ),
10102
10938
  {
10103
- ctx: { l2TxHash, index: 0 },
10104
- message: "Failed to locate L1MessageSent event in L2 receipt."
10939
+ ctx: { where: "isWithdrawalFinalized", params: finalization.params },
10940
+ message: "Failed to read finalization status."
10105
10941
  }
10106
10942
  );
10107
- const message = await wrapAs9(
10108
- "INTERNAL",
10109
- OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
10110
- () => Promise.resolve(ethers.AbiCoder.defaultAbiCoder().decode(["bytes"], ev.data)[0]),
10943
+ return done ? "finalized" : "pending";
10944
+ }
10945
+ const { bundleHash } = finalization.params;
10946
+ const handler = new ethers.Contract(target, IInteropHandler_default, l1);
10947
+ const status = Number(
10948
+ await wrapAs10(
10949
+ "RPC",
10950
+ OP_WITHDRAWALS.finalize.isFinalized,
10951
+ () => handler.bundleStatus(bundleHash),
10111
10952
  {
10112
- ctx: { where: "decode L1MessageSent", data: ev.data },
10113
- message: "Failed to decode withdrawal message."
10953
+ ctx: { where: "L1InteropHandler.bundleStatus", bundleHash },
10954
+ message: "Failed to read bundle status."
10114
10955
  }
10115
- );
10116
- const raw = await wrapAs9(
10956
+ )
10957
+ );
10958
+ if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
10959
+ const callStatus = Number(
10960
+ await wrapAs10(
10117
10961
  "RPC",
10118
- OP_WITHDRAWALS.finalize.fetchParams.rawReceipt,
10119
- () => client.zks.getReceiptWithL2ToL1(l2TxHash),
10962
+ OP_WITHDRAWALS.finalize.isFinalized,
10963
+ () => handler.callStatus(bundleHash, 0),
10120
10964
  {
10121
- ctx: { where: "getReceiptWithL2ToL1 (raw)", l2TxHash },
10122
- message: "Failed to fetch raw L2 receipt."
10965
+ ctx: { where: "L1InteropHandler.callStatus", bundleHash },
10966
+ message: "Failed to read bundle call status."
10123
10967
  }
10124
- );
10125
- if (!raw) {
10126
- throw createError("STATE", {
10968
+ )
10969
+ );
10970
+ return classifyWithdrawalOutcome(status, callStatus);
10971
+ }
10972
+ async function isWithdrawalFinalized(finalization) {
10973
+ return await withdrawalOutcome(finalization) === "finalized";
10974
+ }
10975
+ return {
10976
+ fetchFinalization,
10977
+ isWithdrawalFinalized,
10978
+ withdrawalOutcome,
10979
+ async fetchFinalizeDepositParams(l2TxHash) {
10980
+ const resolved = await fetchFinalization(l2TxHash);
10981
+ if (resolved.finalization.protocol !== "legacy-withdrawal") {
10982
+ throw createError("VALIDATION", {
10127
10983
  resource: "withdrawals",
10128
- operation: OP_WITHDRAWALS.finalize.fetchParams.rawReceipt,
10129
- message: "Raw L2 receipt not found.",
10130
- context: { l2TxHash }
10984
+ operation: OP_WITHDRAWALS.finalize.fetchParams.receipt,
10985
+ message: "This chain finalizes withdrawals through the L1 interop handler; `finalizeDeposit` params do not exist. Use `fetchFinalization` instead.",
10986
+ context: { l2TxHash, protocol: resolved.finalization.protocol }
10131
10987
  });
10132
10988
  }
10133
- const idx = await wrapAs9(
10134
- "INTERNAL",
10135
- OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
10136
- () => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
10137
- {
10138
- ctx: { where: "derive messenger log index", l2TxHash, receipt: raw },
10139
- message: "Failed to derive messenger log index."
10140
- }
10141
- );
10142
- const proof = await wrapAs9(
10143
- "RPC",
10144
- OP_WITHDRAWALS.finalize.fetchParams.proof,
10145
- () => client.zks.getL2ToL1LogProof(l2TxHash, idx),
10146
- {
10147
- ctx: { where: "get L2\u2192L1 log proof", l2TxHash, messengerLogIndex: idx },
10148
- message: "Failed to fetch L2\u2192L1 log proof."
10149
- }
10150
- );
10151
- const { chainId } = await wrapAs9(
10152
- "RPC",
10153
- OP_WITHDRAWALS.finalize.fetchParams.network,
10154
- () => l2.getNetwork(),
10155
- {
10156
- ctx: { where: "l2.getNetwork" },
10157
- message: "Failed to read L2 network."
10158
- }
10159
- );
10160
- const txIndex = Number(parsed.transactionIndex ?? 0);
10161
- const params = {
10162
- chainId: BigInt(chainId),
10163
- l2BatchNumber: proof.batchNumber,
10164
- l2MessageIndex: proof.id,
10165
- l2Sender: l1MessageSentSender(ev),
10166
- l2TxNumberInBatch: txIndex,
10167
- message,
10168
- merkleProof: proof.proof
10169
- };
10170
- const { l1Nullifier } = await client.ensureAddresses();
10171
- return { params, nullifier: l1Nullifier };
10989
+ return { params: resolved.finalization.params, nullifier: resolved.target };
10172
10990
  },
10173
- async simulateFinalizeReadiness(params) {
10174
- const { l1Nullifier } = await client.ensureAddresses();
10991
+ async simulateFinalizeReadiness(finalization) {
10992
+ const target = await finalizationTarget(finalization.protocol);
10175
10993
  const done = await (async () => {
10176
10994
  try {
10177
- const cMini = new ethers.Contract(l1Nullifier, IL1NullifierMini, l1);
10178
- const isFinalized = await wrapAs9(
10179
- "RPC",
10180
- OP_WITHDRAWALS.finalize.readiness.isFinalized,
10181
- () => cMini.isWithdrawalFinalized(
10182
- params.chainId,
10183
- params.l2BatchNumber,
10184
- params.l2MessageIndex
10185
- ),
10186
- {
10187
- ctx: { where: "isWithdrawalFinalized", params },
10188
- message: "Failed to read finalization status."
10189
- }
10190
- );
10191
- return Boolean(isFinalized);
10995
+ return await isWithdrawalFinalized(finalization);
10192
10996
  } catch {
10193
10997
  return false;
10194
10998
  }
10195
10999
  })();
10196
11000
  if (done) return { kind: "FINALIZED" };
10197
- const c = new ethers.Contract(l1Nullifier, IL1Nullifier_default, l1);
10198
11001
  try {
10199
- await c.finalizeDeposit.staticCall(params);
11002
+ if (finalization.protocol === "legacy-withdrawal") {
11003
+ const c = new ethers.Contract(target, IL1Nullifier_default, l1);
11004
+ await c.finalizeDeposit.staticCall(finalization.params);
11005
+ } else {
11006
+ const handler = new ethers.Contract(target, IInteropHandler_default, l1);
11007
+ await handler.executeBundle.staticCall(
11008
+ finalization.params.bundle,
11009
+ finalization.params.proof
11010
+ );
11011
+ }
10200
11012
  return { kind: "READY" };
10201
11013
  } catch (e) {
10202
11014
  return classifyReadinessFromRevert(e);
10203
11015
  }
10204
11016
  },
10205
- async isWithdrawalFinalized(key) {
10206
- const { l1Nullifier } = await client.ensureAddresses();
10207
- const c = new ethers.Contract(l1Nullifier, IL1NullifierMini, l1);
10208
- return await wrapAs9(
10209
- "RPC",
10210
- OP_WITHDRAWALS.finalize.isFinalized,
10211
- () => c.isWithdrawalFinalized(key.chainIdL2, key.l2BatchNumber, key.l2MessageIndex),
10212
- {
10213
- ctx: { where: "isWithdrawalFinalized", key },
10214
- message: "Failed to read finalization status."
10215
- }
10216
- );
10217
- },
10218
- async estimateFinalization(params) {
10219
- const { l1Nullifier } = await client.ensureAddresses();
10220
- const signer2 = client.getL1Signer();
10221
- const c = new ethers.Contract(l1Nullifier, IL1Nullifier_default, signer2);
10222
- const gasLimit = await wrapAs9(
11017
+ async estimateFinalization(finalization) {
11018
+ const target = await finalizationTarget(finalization.protocol);
11019
+ const l1Signer = client.getL1Signer();
11020
+ const gasLimit = await wrapAs10(
10223
11021
  "RPC",
10224
11022
  OP_WITHDRAWALS.finalize.estimate,
10225
- () => c.finalizeDeposit.estimateGas(params),
11023
+ () => {
11024
+ if (finalization.protocol === "legacy-withdrawal") {
11025
+ const c = new ethers.Contract(target, IL1Nullifier_default, l1Signer);
11026
+ return c.finalizeDeposit.estimateGas(finalization.params);
11027
+ }
11028
+ const handler = new ethers.Contract(target, IInteropHandler_default, l1Signer);
11029
+ return handler.executeBundle.estimateGas(
11030
+ finalization.params.bundle,
11031
+ finalization.params.proof
11032
+ );
11033
+ },
10226
11034
  {
10227
- ctx: {
10228
- where: "estimateGas(finalizeDeposit)",
10229
- chainIdL2: params.chainId,
10230
- l2BatchNumber: params.l2BatchNumber,
10231
- l2MessageIndex: params.l2MessageIndex,
10232
- l1Nullifier
10233
- },
10234
- message: "Failed to estimate gas for finalizeDeposit."
11035
+ ctx: { where: "estimateGas(finalize)", protocol: finalization.protocol, target },
11036
+ message: "Failed to estimate gas for withdrawal finalization."
10235
11037
  }
10236
11038
  );
10237
- const feeData = await wrapAs9("RPC", OP_WITHDRAWALS.finalize.estimate, () => l1.getFeeData(), {
11039
+ const feeData = await wrapAs10("RPC", OP_WITHDRAWALS.finalize.estimate, () => l1.getFeeData(), {
10238
11040
  ctx: { where: "l1.getFeeData" },
10239
- message: "Failed to estimate fee data for finalizeDeposit."
11041
+ message: "Failed to estimate fee data for withdrawal finalization."
10240
11042
  });
10241
11043
  const maxFeePerGas = feeData.maxFeePerGas ?? feeData.gasPrice ?? // legacy-style gas price if present
10242
11044
  (() => {
@@ -10247,33 +11049,49 @@ function createFinalizationServices(client) {
10247
11049
  context: { feeData }
10248
11050
  });
10249
11051
  })();
10250
- const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
10251
11052
  return {
10252
11053
  gasLimit,
10253
11054
  maxFeePerGas,
10254
- maxPriorityFeePerGas
11055
+ maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ?? 0n
10255
11056
  };
10256
11057
  },
10257
- async finalizeDeposit(params) {
10258
- const { l1Nullifier } = await client.ensureAddresses();
10259
- const c = new ethers.Contract(l1Nullifier, IL1Nullifier_default, signer);
11058
+ async finalize(finalization) {
11059
+ const target = await finalizationTarget(finalization.protocol);
10260
11060
  try {
10261
- const receipt = await c.finalizeDeposit(params);
10262
- const hash = receipt.hash;
11061
+ const sent = await (async () => {
11062
+ if (finalization.protocol === "legacy-withdrawal") {
11063
+ const c = new ethers.Contract(target, IL1Nullifier_default, signer);
11064
+ return await c.finalizeDeposit(finalization.params);
11065
+ }
11066
+ const handler = new ethers.Contract(target, IInteropHandler_default, signer);
11067
+ return await handler.executeBundle(
11068
+ finalization.params.bundle,
11069
+ finalization.params.proof
11070
+ );
11071
+ })();
11072
+ const hash = sent.hash;
10263
11073
  return {
10264
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
10265
11074
  hash,
10266
11075
  wait: async () => {
10267
11076
  try {
10268
- return await receipt.wait();
11077
+ const receipt = await sent.wait();
11078
+ if (!receipt) {
11079
+ throw createError("EXECUTION", {
11080
+ resource: "withdrawals",
11081
+ operation: OP_WITHDRAWALS.finalize.wait,
11082
+ message: "Withdrawal finalization transaction produced no receipt.",
11083
+ context: { txHash: hash, protocol: finalization.protocol }
11084
+ });
11085
+ }
11086
+ return receipt;
10269
11087
  } catch (e) {
10270
11088
  throw toZKsyncError(
10271
11089
  "EXECUTION",
10272
11090
  {
10273
11091
  resource: "withdrawals",
10274
11092
  operation: OP_WITHDRAWALS.finalize.wait,
10275
- message: "Failed while waiting for finalizeDeposit transaction.",
10276
- context: { txHash: hash }
11093
+ message: "Failed while waiting for the withdrawal finalization transaction.",
11094
+ context: { txHash: hash, protocol: finalization.protocol }
10277
11095
  },
10278
11096
  e
10279
11097
  );
@@ -10286,13 +11104,8 @@ function createFinalizationServices(client) {
10286
11104
  {
10287
11105
  resource: "withdrawals",
10288
11106
  operation: OP_WITHDRAWALS.finalize.send,
10289
- message: "Failed to send finalizeDeposit transaction.",
10290
- context: {
10291
- chainIdL2: params.chainId,
10292
- l2BatchNumber: params.l2BatchNumber,
10293
- l2MessageIndex: params.l2MessageIndex,
10294
- l1Nullifier
10295
- }
11107
+ message: "Failed to send the withdrawal finalization transaction.",
11108
+ context: { protocol: finalization.protocol, target }
10296
11109
  },
10297
11110
  e
10298
11111
  );
@@ -10325,15 +11138,28 @@ var ROUTES2 = {
10325
11138
  "erc20-nonbase": routeErc20NonBase2()
10326
11139
  // AssetRouter.withdraw for non-base ERC-20s
10327
11140
  };
10328
- function createWithdrawalsResource(client, tokens, contracts) {
10329
- const svc = createFinalizationServices(client);
11141
+ var INTEROP_ROUTES = {
11142
+ base: routeInteropBundle(),
11143
+ "erc20-nonbase": routeInteropBundle()
11144
+ };
11145
+ function routeStrategy(protocol, route) {
11146
+ return protocol === "interop-bundle" ? INTEROP_ROUTES[route] : ROUTES2[route];
11147
+ }
11148
+ function createWithdrawalsResource(client, tokens, contracts, options) {
11149
+ const protocolService = createWithdrawalProtocolService(
11150
+ client,
11151
+ options?.protocol
11152
+ );
11153
+ const svc = createFinalizationServices(client, protocolService);
10330
11154
  const { wrap: wrap8, toResult: toResult3 } = createErrorHandlers("withdrawals");
10331
11155
  const tokensResource = tokens ?? createTokensResource(client);
10332
11156
  const contractsResource = contracts ?? createContractsResource(client);
10333
11157
  async function buildPlan(p) {
10334
- const ctx = await commonCtx2(p, client, tokensResource, contractsResource);
10335
- await ROUTES2[ctx.route].preflight?.(p, ctx);
10336
- const { steps, approvals, fees } = await ROUTES2[ctx.route].build(p, ctx);
11158
+ const protocol = await protocolService.protocol();
11159
+ const ctx = await commonCtx2(p, client, tokensResource, contractsResource, protocol);
11160
+ const strategy = routeStrategy(protocol, ctx.route);
11161
+ await strategy.preflight?.(p, ctx);
11162
+ const { steps, approvals, fees } = await strategy.build(p, ctx);
10337
11163
  return {
10338
11164
  route: ctx.route,
10339
11165
  summary: {
@@ -10477,21 +11303,20 @@ function createWithdrawalsResource(client, tokens, contracts) {
10477
11303
  if (!l2Rcpt) return { phase: "L2_PENDING", l2TxHash };
10478
11304
  let pack;
10479
11305
  try {
10480
- pack = await svc.fetchFinalizeDepositParams(l2TxHash);
11306
+ pack = await svc.fetchFinalization(l2TxHash);
10481
11307
  } catch {
10482
11308
  return { phase: "PENDING", l2TxHash };
10483
11309
  }
10484
- const key = {
10485
- chainIdL2: pack.params.chainId,
10486
- l2BatchNumber: pack.params.l2BatchNumber,
10487
- l2MessageIndex: pack.params.l2MessageIndex
10488
- };
11310
+ const key = pack.key;
10489
11311
  try {
10490
- const done = await svc.isWithdrawalFinalized(key);
10491
- if (done) return { phase: "FINALIZED", l2TxHash, key };
11312
+ const outcome = await svc.withdrawalOutcome(pack.finalization);
11313
+ if (outcome === "finalized") return { phase: "FINALIZED", l2TxHash, key };
11314
+ if (outcome === "failed") {
11315
+ return { phase: "UNFINALIZABLE", l2TxHash, key, reason: "bundle-cancelled" };
11316
+ }
10492
11317
  } catch {
10493
11318
  }
10494
- const readiness = await svc.simulateFinalizeReadiness(pack.params);
11319
+ const readiness = await svc.simulateFinalizeReadiness(pack.finalization);
10495
11320
  const { phase, reason } = phaseFromReadiness(readiness);
10496
11321
  return { phase, reason, l2TxHash, key };
10497
11322
  },
@@ -10581,7 +11406,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
10581
11406
  async () => {
10582
11407
  const pack = await (async () => {
10583
11408
  try {
10584
- return await svc.fetchFinalizeDepositParams(l2TxHash);
11409
+ return await svc.fetchFinalization(l2TxHash);
10585
11410
  } catch (e) {
10586
11411
  throw createError("STATE", {
10587
11412
  resource: "withdrawals",
@@ -10592,21 +11417,16 @@ function createWithdrawalsResource(client, tokens, contracts) {
10592
11417
  });
10593
11418
  }
10594
11419
  })();
10595
- const { params } = pack;
10596
- const key = {
10597
- chainIdL2: params.chainId,
10598
- l2BatchNumber: params.l2BatchNumber,
10599
- l2MessageIndex: params.l2MessageIndex
10600
- };
11420
+ const { finalization } = pack;
10601
11421
  try {
10602
- const done = await svc.isWithdrawalFinalized(key);
10603
- if (done) {
11422
+ const outcome = await svc.withdrawalOutcome(finalization);
11423
+ if (outcome === "finalized" || outcome === "failed") {
10604
11424
  const statusNow = await status(l2TxHash);
10605
11425
  return { status: statusNow };
10606
11426
  }
10607
11427
  } catch {
10608
11428
  }
10609
- const readiness = await svc.simulateFinalizeReadiness(params);
11429
+ const readiness = await svc.simulateFinalizeReadiness(finalization);
10610
11430
  if (readiness.kind === "FINALIZED") {
10611
11431
  const statusNow = await status(l2TxHash);
10612
11432
  return { status: statusNow };
@@ -10620,7 +11440,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
10620
11440
  });
10621
11441
  }
10622
11442
  try {
10623
- const tx = await svc.finalizeDeposit(params);
11443
+ const tx = await svc.finalize(finalization);
10624
11444
  finalizeCache.set(l2TxHash, tx.hash);
10625
11445
  const rcpt = await tx.wait();
10626
11446
  const statusNow = await status(l2TxHash);
@@ -10629,7 +11449,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
10629
11449
  const statusNow = await status(l2TxHash);
10630
11450
  if (statusNow.phase === "FINALIZED") return { status: statusNow };
10631
11451
  try {
10632
- const again = await svc.simulateFinalizeReadiness(params);
11452
+ const again = await svc.simulateFinalizeReadiness(finalization);
10633
11453
  if (again.kind === "NOT_READY") {
10634
11454
  throw createError("STATE", {
10635
11455
  resource: "withdrawals",
@@ -10688,74 +11508,6 @@ function createWithdrawalsResource(client, tokens, contracts) {
10688
11508
  };
10689
11509
  }
10690
11510
 
10691
- // src/core/resources/interop/attributes/call.ts
10692
- function createCallAttributes(codec) {
10693
- const indirectCall = (messageValue) => codec.encode("indirectCall", [messageValue]);
10694
- const interopCallValue = (bridgedAmount) => codec.encode("interopCallValue", [bridgedAmount]);
10695
- return {
10696
- indirectCall,
10697
- interopCallValue
10698
- };
10699
- }
10700
-
10701
- // src/core/resources/interop/attributes/bundle.ts
10702
- function createBundleAttributes(codec) {
10703
- const executionAddress = (executor) => codec.encode("executionAddress", [executor]);
10704
- const unbundlerAddress = (addr) => codec.encode("unbundlerAddress", [addr]);
10705
- const useFixedFee = (enabled) => codec.encode("useFixedFee", [enabled]);
10706
- return {
10707
- executionAddress,
10708
- unbundlerAddress,
10709
- useFixedFee
10710
- };
10711
- }
10712
-
10713
- // src/core/resources/interop/attributes/resource.ts
10714
- function createAttributesResource(codec) {
10715
- return {
10716
- call: createCallAttributes(codec),
10717
- bundle: createBundleAttributes(codec)
10718
- };
10719
- }
10720
-
10721
- // src/adapters/ethers/resources/interop/attributes/resource.ts
10722
- function getInteropAttributes(params, ctx) {
10723
- const bundleAttributes = [];
10724
- if (params.execution?.only) {
10725
- bundleAttributes.push(ctx.attributes.bundle.executionAddress(params.execution.only));
10726
- }
10727
- if (params.unbundling?.by) {
10728
- bundleAttributes.push(ctx.attributes.bundle.unbundlerAddress(params.unbundling.by));
10729
- }
10730
- bundleAttributes.push(ctx.attributes.bundle.useFixedFee(params.fee?.useFixed ?? false));
10731
- const callAttributes = params.actions.map((action) => {
10732
- switch (action.type) {
10733
- case "sendNative": {
10734
- const baseMatches = ctx.baseTokens.src.toLowerCase() === ctx.baseTokens.dst.toLowerCase();
10735
- if (baseMatches) {
10736
- return [ctx.attributes.call.interopCallValue(action.amount)];
10737
- }
10738
- return [ctx.attributes.call.indirectCall(action.amount)];
10739
- }
10740
- case "call":
10741
- if (action.value && action.value > 0n) {
10742
- return [ctx.attributes.call.interopCallValue(action.value)];
10743
- }
10744
- return [];
10745
- case "sendErc20":
10746
- return [ctx.attributes.call.indirectCall(0n)];
10747
- default:
10748
- assertNever(action);
10749
- }
10750
- });
10751
- return { bundleAttributes, callAttributes };
10752
- }
10753
- function createEthersAttributesResource(opts = {}) {
10754
- const iface = opts.iface ?? new ethers.Interface(IERC7786Attributes_default);
10755
- const encode2 = (fn, args) => iface.encodeFunctionData(fn, args);
10756
- return createAttributesResource({ encode: encode2 });
10757
- }
10758
-
10759
11511
  // src/core/types/flows/interop.ts
10760
11512
  function isInteropMessageProof(obj) {
10761
11513
  if (typeof obj !== "object" || obj === null) return false;
@@ -10932,24 +11684,6 @@ function buildIndirectBundle(params, ctx, attrs, starterData, interopFeeInfo) {
10932
11684
  }
10933
11685
  };
10934
11686
  }
10935
- var PREFIX_EVM_CHAIN = ethers.getBytes("0x00010000");
10936
- var PREFIX_EVM_ADDRESS = ethers.getBytes("0x000100000014");
10937
- function formatInteropEvmChain(chainId) {
10938
- const chainRef = ethers.toBeArray(chainId);
10939
- const chainRefLength = ethers.getBytes(ethers.toBeHex(chainRef.length, 1));
10940
- const payload = ethers.concat([PREFIX_EVM_CHAIN, chainRefLength, chainRef, new Uint8Array([0])]);
10941
- return ethers.hexlify(payload);
10942
- }
10943
- function formatInteropEvmAddress(address) {
10944
- const normalized = ethers.getAddress(address);
10945
- const addrBytes = ethers.getBytes(normalized);
10946
- const payload = ethers.concat([PREFIX_EVM_ADDRESS, addrBytes]);
10947
- return ethers.hexlify(payload);
10948
- }
10949
- var interopCodec = {
10950
- formatChain: formatInteropEvmChain,
10951
- formatAddress: formatInteropEvmAddress
10952
- };
10953
11687
  function getErc20Tokens(params) {
10954
11688
  const erc20Tokens = /* @__PURE__ */ new Map();
10955
11689
  for (const action of params.actions) {
@@ -11105,7 +11839,7 @@ function routeIndirect() {
11105
11839
  resolveErc20AssetIds(erc20Tokens, ctx),
11106
11840
  buildFeeInfo(params, ctx, params.actions.length)
11107
11841
  ]);
11108
- const attributes = getInteropAttributes(params, ctx);
11842
+ const attributes2 = getInteropAttributes(params, ctx);
11109
11843
  const starterData = await getStarterData(params, ctx, erc20AssetIds);
11110
11844
  const bundle = buildIndirectBundle(
11111
11845
  params,
@@ -11116,7 +11850,7 @@ function routeIndirect() {
11116
11850
  l2NativeTokenVault: ctx.l2NativeTokenVault,
11117
11851
  codec: interopCodec
11118
11852
  },
11119
- attributes,
11853
+ attributes2,
11120
11854
  starterData,
11121
11855
  feeInfo
11122
11856
  );
@@ -11239,7 +11973,7 @@ async function assertInteropProtocolVersion(client, srcChainId, dstChainId) {
11239
11973
  assertProtocolVersion(srcChainId, srcProtocolVersion);
11240
11974
  assertProtocolVersion(dstChainId, dstProtocolVersion);
11241
11975
  }
11242
- async function commonCtx3(dstProvider, params, client, tokens, contracts, attributes) {
11976
+ async function commonCtx3(dstProvider, params, client, tokens, contracts, attributes2) {
11243
11977
  const sender = await client.signer.getAddress();
11244
11978
  const chainId = (await client.l2.getNetwork()).chainId;
11245
11979
  const dstChainId = (await dstProvider.getNetwork()).chainId;
@@ -11276,7 +12010,7 @@ async function commonCtx3(dstProvider, params, client, tokens, contracts, attrib
11276
12010
  l2NativeTokenVault,
11277
12011
  baseTokens: { src: srcBaseToken, dst: dstBaseToken, matches: baseMatches },
11278
12012
  ifaces: { interopCenter: interopCenterIface, interopHandler: interopHandlerIface },
11279
- attributes,
12013
+ attributes: attributes2,
11280
12014
  gasOverrides: params.txOverrides ? toGasOverrides(params.txOverrides) : void 0
11281
12015
  };
11282
12016
  }
@@ -11932,7 +12666,7 @@ var ROUTES3 = {
11932
12666
  direct: routeDirect(),
11933
12667
  indirect: routeIndirect()
11934
12668
  };
11935
- function createInteropResource(client, config, tokens, contracts, attributes) {
12669
+ function createInteropResource(client, config, tokens, contracts, attributes2) {
11936
12670
  let gwProviderCache;
11937
12671
  function requireConfig() {
11938
12672
  if (!config)
@@ -11950,7 +12684,7 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
11950
12684
  const svc = createInteropFinalizationServices(client);
11951
12685
  const tokensResource = tokens ?? createTokensResource(client);
11952
12686
  const contractsResource = contracts ?? createContractsResource(client);
11953
- const attributesResource = attributes ?? createEthersAttributesResource();
12687
+ const attributesResource = attributes2 ?? createEthersAttributesResource();
11954
12688
  async function buildPlanWithCtx(dstProvider, params) {
11955
12689
  const ctx = await commonCtx3(
11956
12690
  dstProvider,
@@ -12163,7 +12897,7 @@ function createEthersSdk(client, options) {
12163
12897
  const interop = createInteropResource(client, options?.interop, tokens, contracts);
12164
12898
  return {
12165
12899
  deposits: createDepositsResource(client, tokens, contracts),
12166
- withdrawals: createWithdrawalsResource(client, tokens, contracts),
12900
+ withdrawals: createWithdrawalsResource(client, tokens, contracts, options?.withdrawals),
12167
12901
  tokens,
12168
12902
  contracts,
12169
12903
  interop
@@ -12181,6 +12915,7 @@ exports.createFinalizationServices = createFinalizationServices;
12181
12915
  exports.createInteropFinalizationServices = createInteropFinalizationServices;
12182
12916
  exports.createInteropResource = createInteropResource;
12183
12917
  exports.createTokensResource = createTokensResource;
12918
+ exports.createWithdrawalProtocolService = createWithdrawalProtocolService;
12184
12919
  exports.createWithdrawalsResource = createWithdrawalsResource;
12185
12920
  exports.decodeRevert = decodeRevert;
12186
12921
  exports.encodeNativeTokenVaultTransferData = encodeNativeTokenVaultTransferData;