@matterlabs/zksync-js 0.0.20 → 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.
- package/dist/adapters/ethers/client.cjs +31 -1
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +11 -0
- package/dist/adapters/ethers/client.js +6 -5
- package/dist/adapters/ethers/index.cjs +1057 -290
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.d.ts +2 -1
- package/dist/adapters/ethers/index.js +10 -8
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +12 -1
- package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
- package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
- package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
- package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
- package/dist/adapters/ethers/sdk.cjs +1010 -274
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +3 -1
- package/dist/adapters/ethers/sdk.js +8 -7
- package/dist/adapters/viem/client.cjs +44 -0
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +11 -0
- package/dist/adapters/viem/client.js +6 -5
- package/dist/adapters/viem/index.cjs +1094 -296
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +2 -1
- package/dist/adapters/viem/index.js +10 -8
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
- package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
- package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
- package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
- package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
- package/dist/adapters/viem/sdk.cjs +1048 -295
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +3 -1
- package/dist/adapters/viem/sdk.js +8 -7
- package/dist/{chunk-SBGBYZJM.js → chunk-2D3FBCZC.js} +2 -2
- package/dist/{chunk-3HHUZXSV.js → chunk-32N6TI6K.js} +10 -2
- package/dist/{chunk-6LYAENO6.js → chunk-3SPDWWRD.js} +6 -4
- package/dist/{chunk-3T5V4HKS.js → chunk-4K4LOCQJ.js} +569 -259
- package/dist/{chunk-UEKFQAOS.js → chunk-AMRHBZIY.js} +304 -2
- package/dist/{chunk-E2XKJCI5.js → chunk-CP4SQ5PM.js} +537 -242
- package/dist/{chunk-NJK325XV.js → chunk-CPNHKNI4.js} +2 -2
- package/dist/{chunk-TYYUG5GA.js → chunk-CUBUD4J4.js} +1 -1
- package/dist/{chunk-CK5UFAZK.js → chunk-JXBLQQEN.js} +37 -3
- package/dist/{chunk-JSBMIT4S.js → chunk-KL6ZCPWJ.js} +1 -1
- package/dist/{chunk-MT4X5FEO.js → chunk-NQRYXL3K.js} +3 -1
- package/dist/{chunk-24TE2NNJ.js → chunk-PI4PF6WT.js} +24 -4
- package/dist/chunk-QUAPG3ZR.js +157 -0
- package/dist/chunk-UMPAKZCQ.js +19 -0
- package/dist/core/abi.d.ts +1 -0
- package/dist/core/constants.cjs +2 -0
- package/dist/core/constants.cjs.map +1 -1
- package/dist/core/constants.d.ts +9 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +513 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +6 -1
- package/dist/core/index.js +6 -4
- package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
- package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
- package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
- package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
- package/dist/core/resources/protocol/semver.d.ts +18 -0
- package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
- package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
- package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
- package/dist/core/resources/withdrawals/status.d.ts +5 -0
- package/dist/core/types/flows/withdrawals.d.ts +32 -2
- package/dist/core/utils/events.d.ts +2 -0
- package/dist/index.cjs +313 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- 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
|
|
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:
|
|
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
|
};
|
|
@@ -10019,6 +10356,268 @@ function routeErc20NonBase2() {
|
|
|
10019
10356
|
}
|
|
10020
10357
|
};
|
|
10021
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
|
|
10616
|
+
});
|
|
10617
|
+
return { steps, approvals, fees };
|
|
10618
|
+
}
|
|
10619
|
+
};
|
|
10620
|
+
}
|
|
10022
10621
|
|
|
10023
10622
|
// src/core/utils/events.ts
|
|
10024
10623
|
function extractPreferAddress(opts) {
|
|
@@ -10040,195 +10639,406 @@ function findL1MessageSentLog(receipt, opts) {
|
|
|
10040
10639
|
if (!chosen) {
|
|
10041
10640
|
throw new Error("No suitable L1MessageSent event found.");
|
|
10042
10641
|
}
|
|
10043
|
-
return chosen;
|
|
10642
|
+
return chosen;
|
|
10643
|
+
}
|
|
10644
|
+
function isL1MessageSentLog(log, opts) {
|
|
10645
|
+
const topic = log.topics[0].toLowerCase();
|
|
10646
|
+
const preferAddr = extractPreferAddress(opts);
|
|
10647
|
+
return log.address.toLowerCase() === preferAddr && (topic === TOPIC_L1_MESSAGE_SENT_LEG.toLowerCase() || topic === TOPIC_L1_MESSAGE_SENT_NEW.toLowerCase());
|
|
10648
|
+
}
|
|
10649
|
+
var SENDER_TOPIC = /^0x0{24}([0-9a-fA-F]{40})$/;
|
|
10650
|
+
function l1MessageSentSender(log) {
|
|
10651
|
+
const sender = SENDER_TOPIC.exec(log.topics?.[1] ?? "")?.[1];
|
|
10652
|
+
if (!sender) {
|
|
10653
|
+
throw new Error("L1MessageSent log has no valid sender topic.");
|
|
10654
|
+
}
|
|
10655
|
+
return `0x${sender.toLowerCase()}`;
|
|
10656
|
+
}
|
|
10657
|
+
|
|
10658
|
+
// src/core/resources/withdrawals/logs.ts
|
|
10659
|
+
function messengerLogIndex(raw, opts) {
|
|
10660
|
+
const index = opts?.index;
|
|
10661
|
+
const messenger = (opts?.messenger).toLowerCase();
|
|
10662
|
+
const arr = Array.isArray(raw?.l2ToL1Logs) ? raw.l2ToL1Logs : [];
|
|
10663
|
+
const hits = arr.map((lg, i) => ({ i, lg })).filter(({ lg }) => (lg?.sender ?? "").toLowerCase() === messenger);
|
|
10664
|
+
if (!hits.length) {
|
|
10665
|
+
throw new Error("No L2->L1 messenger logs found in receipt.");
|
|
10666
|
+
}
|
|
10667
|
+
return (hits[index] ?? hits[0]).i;
|
|
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
|
+
}
|
|
10044
10724
|
}
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
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
|
+
};
|
|
10049
10750
|
}
|
|
10050
10751
|
|
|
10051
|
-
// src/
|
|
10052
|
-
function
|
|
10053
|
-
|
|
10054
|
-
|
|
10055
|
-
|
|
10056
|
-
|
|
10057
|
-
|
|
10058
|
-
|
|
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
|
+
}
|
|
10059
10762
|
}
|
|
10060
|
-
|
|
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
|
+
};
|
|
10061
10792
|
}
|
|
10062
10793
|
|
|
10063
10794
|
// src/adapters/ethers/resources/withdrawals/services/finalization.ts
|
|
10064
|
-
var { wrapAs:
|
|
10795
|
+
var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
|
|
10065
10796
|
var IL1NullifierMini = [
|
|
10066
10797
|
"function isWithdrawalFinalized(uint256,uint256,uint256) view returns (bool)"
|
|
10067
10798
|
];
|
|
10068
|
-
function createFinalizationServices(client) {
|
|
10799
|
+
function createFinalizationServices(client, protocolService = createWithdrawalProtocolService(client)) {
|
|
10069
10800
|
const { l1, l2, signer } = client;
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
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
|
|
10079
10902
|
}
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
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
|
|
10088
10923
|
}
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
|
|
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
|
+
),
|
|
10094
10938
|
{
|
|
10095
|
-
ctx: {
|
|
10096
|
-
message: "Failed to
|
|
10939
|
+
ctx: { where: "isWithdrawalFinalized", params: finalization.params },
|
|
10940
|
+
message: "Failed to read finalization status."
|
|
10097
10941
|
}
|
|
10098
10942
|
);
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
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),
|
|
10103
10952
|
{
|
|
10104
|
-
ctx: { where: "
|
|
10105
|
-
message: "Failed to
|
|
10953
|
+
ctx: { where: "L1InteropHandler.bundleStatus", bundleHash },
|
|
10954
|
+
message: "Failed to read bundle status."
|
|
10106
10955
|
}
|
|
10107
|
-
)
|
|
10108
|
-
|
|
10956
|
+
)
|
|
10957
|
+
);
|
|
10958
|
+
if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
|
|
10959
|
+
const callStatus = Number(
|
|
10960
|
+
await wrapAs10(
|
|
10109
10961
|
"RPC",
|
|
10110
|
-
OP_WITHDRAWALS.finalize.
|
|
10111
|
-
() =>
|
|
10962
|
+
OP_WITHDRAWALS.finalize.isFinalized,
|
|
10963
|
+
() => handler.callStatus(bundleHash, 0),
|
|
10112
10964
|
{
|
|
10113
|
-
ctx: { where: "
|
|
10114
|
-
message: "Failed to
|
|
10965
|
+
ctx: { where: "L1InteropHandler.callStatus", bundleHash },
|
|
10966
|
+
message: "Failed to read bundle call status."
|
|
10115
10967
|
}
|
|
10116
|
-
)
|
|
10117
|
-
|
|
10118
|
-
|
|
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", {
|
|
10119
10983
|
resource: "withdrawals",
|
|
10120
|
-
operation: OP_WITHDRAWALS.finalize.fetchParams.
|
|
10121
|
-
message: "
|
|
10122
|
-
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 }
|
|
10123
10987
|
});
|
|
10124
10988
|
}
|
|
10125
|
-
|
|
10126
|
-
"INTERNAL",
|
|
10127
|
-
OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
|
|
10128
|
-
() => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
|
|
10129
|
-
{
|
|
10130
|
-
ctx: { where: "derive messenger log index", l2TxHash, receipt: raw },
|
|
10131
|
-
message: "Failed to derive messenger log index."
|
|
10132
|
-
}
|
|
10133
|
-
);
|
|
10134
|
-
const proof = await wrapAs9(
|
|
10135
|
-
"RPC",
|
|
10136
|
-
OP_WITHDRAWALS.finalize.fetchParams.proof,
|
|
10137
|
-
() => client.zks.getL2ToL1LogProof(l2TxHash, idx),
|
|
10138
|
-
{
|
|
10139
|
-
ctx: { where: "get L2\u2192L1 log proof", l2TxHash, messengerLogIndex: idx },
|
|
10140
|
-
message: "Failed to fetch L2\u2192L1 log proof."
|
|
10141
|
-
}
|
|
10142
|
-
);
|
|
10143
|
-
const { chainId } = await wrapAs9(
|
|
10144
|
-
"RPC",
|
|
10145
|
-
OP_WITHDRAWALS.finalize.fetchParams.network,
|
|
10146
|
-
() => l2.getNetwork(),
|
|
10147
|
-
{
|
|
10148
|
-
ctx: { where: "l2.getNetwork" },
|
|
10149
|
-
message: "Failed to read L2 network."
|
|
10150
|
-
}
|
|
10151
|
-
);
|
|
10152
|
-
const txIndex = Number(parsed.transactionIndex ?? 0);
|
|
10153
|
-
const params = {
|
|
10154
|
-
chainId: BigInt(chainId),
|
|
10155
|
-
l2BatchNumber: proof.batchNumber,
|
|
10156
|
-
l2MessageIndex: proof.id,
|
|
10157
|
-
l2Sender: parsed.to,
|
|
10158
|
-
l2TxNumberInBatch: txIndex,
|
|
10159
|
-
message,
|
|
10160
|
-
merkleProof: proof.proof
|
|
10161
|
-
};
|
|
10162
|
-
const { l1Nullifier } = await client.ensureAddresses();
|
|
10163
|
-
return { params, nullifier: l1Nullifier };
|
|
10989
|
+
return { params: resolved.finalization.params, nullifier: resolved.target };
|
|
10164
10990
|
},
|
|
10165
|
-
async simulateFinalizeReadiness(
|
|
10166
|
-
const
|
|
10991
|
+
async simulateFinalizeReadiness(finalization) {
|
|
10992
|
+
const target = await finalizationTarget(finalization.protocol);
|
|
10167
10993
|
const done = await (async () => {
|
|
10168
10994
|
try {
|
|
10169
|
-
|
|
10170
|
-
const isFinalized = await wrapAs9(
|
|
10171
|
-
"RPC",
|
|
10172
|
-
OP_WITHDRAWALS.finalize.readiness.isFinalized,
|
|
10173
|
-
() => cMini.isWithdrawalFinalized(
|
|
10174
|
-
params.chainId,
|
|
10175
|
-
params.l2BatchNumber,
|
|
10176
|
-
params.l2MessageIndex
|
|
10177
|
-
),
|
|
10178
|
-
{
|
|
10179
|
-
ctx: { where: "isWithdrawalFinalized", params },
|
|
10180
|
-
message: "Failed to read finalization status."
|
|
10181
|
-
}
|
|
10182
|
-
);
|
|
10183
|
-
return Boolean(isFinalized);
|
|
10995
|
+
return await isWithdrawalFinalized(finalization);
|
|
10184
10996
|
} catch {
|
|
10185
10997
|
return false;
|
|
10186
10998
|
}
|
|
10187
10999
|
})();
|
|
10188
11000
|
if (done) return { kind: "FINALIZED" };
|
|
10189
|
-
const c = new ethers.Contract(l1Nullifier, IL1Nullifier_default, l1);
|
|
10190
11001
|
try {
|
|
10191
|
-
|
|
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
|
+
}
|
|
10192
11012
|
return { kind: "READY" };
|
|
10193
11013
|
} catch (e) {
|
|
10194
11014
|
return classifyReadinessFromRevert(e);
|
|
10195
11015
|
}
|
|
10196
11016
|
},
|
|
10197
|
-
async
|
|
10198
|
-
const
|
|
10199
|
-
const
|
|
10200
|
-
|
|
10201
|
-
"RPC",
|
|
10202
|
-
OP_WITHDRAWALS.finalize.isFinalized,
|
|
10203
|
-
() => c.isWithdrawalFinalized(key.chainIdL2, key.l2BatchNumber, key.l2MessageIndex),
|
|
10204
|
-
{
|
|
10205
|
-
ctx: { where: "isWithdrawalFinalized", key },
|
|
10206
|
-
message: "Failed to read finalization status."
|
|
10207
|
-
}
|
|
10208
|
-
);
|
|
10209
|
-
},
|
|
10210
|
-
async estimateFinalization(params) {
|
|
10211
|
-
const { l1Nullifier } = await client.ensureAddresses();
|
|
10212
|
-
const signer2 = client.getL1Signer();
|
|
10213
|
-
const c = new ethers.Contract(l1Nullifier, IL1Nullifier_default, signer2);
|
|
10214
|
-
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(
|
|
10215
11021
|
"RPC",
|
|
10216
11022
|
OP_WITHDRAWALS.finalize.estimate,
|
|
10217
|
-
() =>
|
|
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
|
+
},
|
|
10218
11034
|
{
|
|
10219
|
-
ctx: {
|
|
10220
|
-
|
|
10221
|
-
chainIdL2: params.chainId,
|
|
10222
|
-
l2BatchNumber: params.l2BatchNumber,
|
|
10223
|
-
l2MessageIndex: params.l2MessageIndex,
|
|
10224
|
-
l1Nullifier
|
|
10225
|
-
},
|
|
10226
|
-
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."
|
|
10227
11037
|
}
|
|
10228
11038
|
);
|
|
10229
|
-
const feeData = await
|
|
11039
|
+
const feeData = await wrapAs10("RPC", OP_WITHDRAWALS.finalize.estimate, () => l1.getFeeData(), {
|
|
10230
11040
|
ctx: { where: "l1.getFeeData" },
|
|
10231
|
-
message: "Failed to estimate fee data for
|
|
11041
|
+
message: "Failed to estimate fee data for withdrawal finalization."
|
|
10232
11042
|
});
|
|
10233
11043
|
const maxFeePerGas = feeData.maxFeePerGas ?? feeData.gasPrice ?? // legacy-style gas price if present
|
|
10234
11044
|
(() => {
|
|
@@ -10239,33 +11049,49 @@ function createFinalizationServices(client) {
|
|
|
10239
11049
|
context: { feeData }
|
|
10240
11050
|
});
|
|
10241
11051
|
})();
|
|
10242
|
-
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? 0n;
|
|
10243
11052
|
return {
|
|
10244
11053
|
gasLimit,
|
|
10245
11054
|
maxFeePerGas,
|
|
10246
|
-
maxPriorityFeePerGas
|
|
11055
|
+
maxPriorityFeePerGas: feeData.maxPriorityFeePerGas ?? 0n
|
|
10247
11056
|
};
|
|
10248
11057
|
},
|
|
10249
|
-
async
|
|
10250
|
-
const
|
|
10251
|
-
const c = new ethers.Contract(l1Nullifier, IL1Nullifier_default, signer);
|
|
11058
|
+
async finalize(finalization) {
|
|
11059
|
+
const target = await finalizationTarget(finalization.protocol);
|
|
10252
11060
|
try {
|
|
10253
|
-
const
|
|
10254
|
-
|
|
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;
|
|
10255
11073
|
return {
|
|
10256
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
10257
11074
|
hash,
|
|
10258
11075
|
wait: async () => {
|
|
10259
11076
|
try {
|
|
10260
|
-
|
|
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;
|
|
10261
11087
|
} catch (e) {
|
|
10262
11088
|
throw toZKsyncError(
|
|
10263
11089
|
"EXECUTION",
|
|
10264
11090
|
{
|
|
10265
11091
|
resource: "withdrawals",
|
|
10266
11092
|
operation: OP_WITHDRAWALS.finalize.wait,
|
|
10267
|
-
message: "Failed while waiting for
|
|
10268
|
-
context: { txHash: hash }
|
|
11093
|
+
message: "Failed while waiting for the withdrawal finalization transaction.",
|
|
11094
|
+
context: { txHash: hash, protocol: finalization.protocol }
|
|
10269
11095
|
},
|
|
10270
11096
|
e
|
|
10271
11097
|
);
|
|
@@ -10278,13 +11104,8 @@ function createFinalizationServices(client) {
|
|
|
10278
11104
|
{
|
|
10279
11105
|
resource: "withdrawals",
|
|
10280
11106
|
operation: OP_WITHDRAWALS.finalize.send,
|
|
10281
|
-
message: "Failed to send
|
|
10282
|
-
context: {
|
|
10283
|
-
chainIdL2: params.chainId,
|
|
10284
|
-
l2BatchNumber: params.l2BatchNumber,
|
|
10285
|
-
l2MessageIndex: params.l2MessageIndex,
|
|
10286
|
-
l1Nullifier
|
|
10287
|
-
}
|
|
11107
|
+
message: "Failed to send the withdrawal finalization transaction.",
|
|
11108
|
+
context: { protocol: finalization.protocol, target }
|
|
10288
11109
|
},
|
|
10289
11110
|
e
|
|
10290
11111
|
);
|
|
@@ -10293,6 +11114,23 @@ function createFinalizationServices(client) {
|
|
|
10293
11114
|
};
|
|
10294
11115
|
}
|
|
10295
11116
|
|
|
11117
|
+
// src/core/resources/withdrawals/status.ts
|
|
11118
|
+
function phaseFromReadiness(r) {
|
|
11119
|
+
switch (r.kind) {
|
|
11120
|
+
case "FINALIZED":
|
|
11121
|
+
return { phase: "FINALIZED" };
|
|
11122
|
+
case "READY":
|
|
11123
|
+
return { phase: "READY_TO_FINALIZE" };
|
|
11124
|
+
case "NOT_READY":
|
|
11125
|
+
return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
|
|
11126
|
+
case "UNFINALIZABLE":
|
|
11127
|
+
return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
|
|
11128
|
+
default:
|
|
11129
|
+
return assertNever(r);
|
|
11130
|
+
}
|
|
11131
|
+
}
|
|
11132
|
+
var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
|
|
11133
|
+
|
|
10296
11134
|
// src/adapters/ethers/resources/withdrawals/index.ts
|
|
10297
11135
|
var ROUTES2 = {
|
|
10298
11136
|
base: routeEthBase(),
|
|
@@ -10300,15 +11138,28 @@ var ROUTES2 = {
|
|
|
10300
11138
|
"erc20-nonbase": routeErc20NonBase2()
|
|
10301
11139
|
// AssetRouter.withdraw for non-base ERC-20s
|
|
10302
11140
|
};
|
|
10303
|
-
|
|
10304
|
-
|
|
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);
|
|
10305
11154
|
const { wrap: wrap8, toResult: toResult3 } = createErrorHandlers("withdrawals");
|
|
10306
11155
|
const tokensResource = tokens ?? createTokensResource(client);
|
|
10307
11156
|
const contractsResource = contracts ?? createContractsResource(client);
|
|
10308
11157
|
async function buildPlan(p) {
|
|
10309
|
-
const
|
|
10310
|
-
await
|
|
10311
|
-
const
|
|
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);
|
|
10312
11163
|
return {
|
|
10313
11164
|
route: ctx.route,
|
|
10314
11165
|
summary: {
|
|
@@ -10452,24 +11303,22 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10452
11303
|
if (!l2Rcpt) return { phase: "L2_PENDING", l2TxHash };
|
|
10453
11304
|
let pack;
|
|
10454
11305
|
try {
|
|
10455
|
-
pack = await svc.
|
|
11306
|
+
pack = await svc.fetchFinalization(l2TxHash);
|
|
10456
11307
|
} catch {
|
|
10457
11308
|
return { phase: "PENDING", l2TxHash };
|
|
10458
11309
|
}
|
|
10459
|
-
const key =
|
|
10460
|
-
chainIdL2: pack.params.chainId,
|
|
10461
|
-
l2BatchNumber: pack.params.l2BatchNumber,
|
|
10462
|
-
l2MessageIndex: pack.params.l2MessageIndex
|
|
10463
|
-
};
|
|
11310
|
+
const key = pack.key;
|
|
10464
11311
|
try {
|
|
10465
|
-
const
|
|
10466
|
-
if (
|
|
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
|
+
}
|
|
10467
11317
|
} catch {
|
|
10468
11318
|
}
|
|
10469
|
-
const readiness = await svc.simulateFinalizeReadiness(pack.
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
return { phase: "PENDING", l2TxHash, key };
|
|
11319
|
+
const readiness = await svc.simulateFinalizeReadiness(pack.finalization);
|
|
11320
|
+
const { phase, reason } = phaseFromReadiness(readiness);
|
|
11321
|
+
return { phase, reason, l2TxHash, key };
|
|
10473
11322
|
},
|
|
10474
11323
|
{
|
|
10475
11324
|
message: "Internal error while checking withdrawal status.",
|
|
@@ -10513,6 +11362,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10513
11362
|
const deadline = opts.timeoutMs ? Date.now() + opts.timeoutMs : void 0;
|
|
10514
11363
|
while (true) {
|
|
10515
11364
|
const s = await status(l2Hash);
|
|
11365
|
+
if (s.phase === "UNFINALIZABLE") {
|
|
11366
|
+
throw createError("STATE", {
|
|
11367
|
+
resource: "withdrawals",
|
|
11368
|
+
operation: OP_WITHDRAWALS.wait,
|
|
11369
|
+
message: "Withdrawal can never be finalized.",
|
|
11370
|
+
context: { l2TxHash: l2Hash, reason: s.reason }
|
|
11371
|
+
});
|
|
11372
|
+
}
|
|
10516
11373
|
if (opts.for === "ready") {
|
|
10517
11374
|
if (s.phase === "READY_TO_FINALIZE" || s.phase === "FINALIZED") return null;
|
|
10518
11375
|
} else {
|
|
@@ -10549,7 +11406,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10549
11406
|
async () => {
|
|
10550
11407
|
const pack = await (async () => {
|
|
10551
11408
|
try {
|
|
10552
|
-
return await svc.
|
|
11409
|
+
return await svc.fetchFinalization(l2TxHash);
|
|
10553
11410
|
} catch (e) {
|
|
10554
11411
|
throw createError("STATE", {
|
|
10555
11412
|
resource: "withdrawals",
|
|
@@ -10560,21 +11417,16 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10560
11417
|
});
|
|
10561
11418
|
}
|
|
10562
11419
|
})();
|
|
10563
|
-
const {
|
|
10564
|
-
const key = {
|
|
10565
|
-
chainIdL2: params.chainId,
|
|
10566
|
-
l2BatchNumber: params.l2BatchNumber,
|
|
10567
|
-
l2MessageIndex: params.l2MessageIndex
|
|
10568
|
-
};
|
|
11420
|
+
const { finalization } = pack;
|
|
10569
11421
|
try {
|
|
10570
|
-
const
|
|
10571
|
-
if (
|
|
11422
|
+
const outcome = await svc.withdrawalOutcome(finalization);
|
|
11423
|
+
if (outcome === "finalized" || outcome === "failed") {
|
|
10572
11424
|
const statusNow = await status(l2TxHash);
|
|
10573
11425
|
return { status: statusNow };
|
|
10574
11426
|
}
|
|
10575
11427
|
} catch {
|
|
10576
11428
|
}
|
|
10577
|
-
const readiness = await svc.simulateFinalizeReadiness(
|
|
11429
|
+
const readiness = await svc.simulateFinalizeReadiness(finalization);
|
|
10578
11430
|
if (readiness.kind === "FINALIZED") {
|
|
10579
11431
|
const statusNow = await status(l2TxHash);
|
|
10580
11432
|
return { status: statusNow };
|
|
@@ -10588,7 +11440,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10588
11440
|
});
|
|
10589
11441
|
}
|
|
10590
11442
|
try {
|
|
10591
|
-
const tx = await svc.
|
|
11443
|
+
const tx = await svc.finalize(finalization);
|
|
10592
11444
|
finalizeCache.set(l2TxHash, tx.hash);
|
|
10593
11445
|
const rcpt = await tx.wait();
|
|
10594
11446
|
const statusNow = await status(l2TxHash);
|
|
@@ -10597,7 +11449,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10597
11449
|
const statusNow = await status(l2TxHash);
|
|
10598
11450
|
if (statusNow.phase === "FINALIZED") return { status: statusNow };
|
|
10599
11451
|
try {
|
|
10600
|
-
const again = await svc.simulateFinalizeReadiness(
|
|
11452
|
+
const again = await svc.simulateFinalizeReadiness(finalization);
|
|
10601
11453
|
if (again.kind === "NOT_READY") {
|
|
10602
11454
|
throw createError("STATE", {
|
|
10603
11455
|
resource: "withdrawals",
|
|
@@ -10656,74 +11508,6 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10656
11508
|
};
|
|
10657
11509
|
}
|
|
10658
11510
|
|
|
10659
|
-
// src/core/resources/interop/attributes/call.ts
|
|
10660
|
-
function createCallAttributes(codec) {
|
|
10661
|
-
const indirectCall = (messageValue) => codec.encode("indirectCall", [messageValue]);
|
|
10662
|
-
const interopCallValue = (bridgedAmount) => codec.encode("interopCallValue", [bridgedAmount]);
|
|
10663
|
-
return {
|
|
10664
|
-
indirectCall,
|
|
10665
|
-
interopCallValue
|
|
10666
|
-
};
|
|
10667
|
-
}
|
|
10668
|
-
|
|
10669
|
-
// src/core/resources/interop/attributes/bundle.ts
|
|
10670
|
-
function createBundleAttributes(codec) {
|
|
10671
|
-
const executionAddress = (executor) => codec.encode("executionAddress", [executor]);
|
|
10672
|
-
const unbundlerAddress = (addr) => codec.encode("unbundlerAddress", [addr]);
|
|
10673
|
-
const useFixedFee = (enabled) => codec.encode("useFixedFee", [enabled]);
|
|
10674
|
-
return {
|
|
10675
|
-
executionAddress,
|
|
10676
|
-
unbundlerAddress,
|
|
10677
|
-
useFixedFee
|
|
10678
|
-
};
|
|
10679
|
-
}
|
|
10680
|
-
|
|
10681
|
-
// src/core/resources/interop/attributes/resource.ts
|
|
10682
|
-
function createAttributesResource(codec) {
|
|
10683
|
-
return {
|
|
10684
|
-
call: createCallAttributes(codec),
|
|
10685
|
-
bundle: createBundleAttributes(codec)
|
|
10686
|
-
};
|
|
10687
|
-
}
|
|
10688
|
-
|
|
10689
|
-
// src/adapters/ethers/resources/interop/attributes/resource.ts
|
|
10690
|
-
function getInteropAttributes(params, ctx) {
|
|
10691
|
-
const bundleAttributes = [];
|
|
10692
|
-
if (params.execution?.only) {
|
|
10693
|
-
bundleAttributes.push(ctx.attributes.bundle.executionAddress(params.execution.only));
|
|
10694
|
-
}
|
|
10695
|
-
if (params.unbundling?.by) {
|
|
10696
|
-
bundleAttributes.push(ctx.attributes.bundle.unbundlerAddress(params.unbundling.by));
|
|
10697
|
-
}
|
|
10698
|
-
bundleAttributes.push(ctx.attributes.bundle.useFixedFee(params.fee?.useFixed ?? false));
|
|
10699
|
-
const callAttributes = params.actions.map((action) => {
|
|
10700
|
-
switch (action.type) {
|
|
10701
|
-
case "sendNative": {
|
|
10702
|
-
const baseMatches = ctx.baseTokens.src.toLowerCase() === ctx.baseTokens.dst.toLowerCase();
|
|
10703
|
-
if (baseMatches) {
|
|
10704
|
-
return [ctx.attributes.call.interopCallValue(action.amount)];
|
|
10705
|
-
}
|
|
10706
|
-
return [ctx.attributes.call.indirectCall(action.amount)];
|
|
10707
|
-
}
|
|
10708
|
-
case "call":
|
|
10709
|
-
if (action.value && action.value > 0n) {
|
|
10710
|
-
return [ctx.attributes.call.interopCallValue(action.value)];
|
|
10711
|
-
}
|
|
10712
|
-
return [];
|
|
10713
|
-
case "sendErc20":
|
|
10714
|
-
return [ctx.attributes.call.indirectCall(0n)];
|
|
10715
|
-
default:
|
|
10716
|
-
assertNever(action);
|
|
10717
|
-
}
|
|
10718
|
-
});
|
|
10719
|
-
return { bundleAttributes, callAttributes };
|
|
10720
|
-
}
|
|
10721
|
-
function createEthersAttributesResource(opts = {}) {
|
|
10722
|
-
const iface = opts.iface ?? new ethers.Interface(IERC7786Attributes_default);
|
|
10723
|
-
const encode2 = (fn, args) => iface.encodeFunctionData(fn, args);
|
|
10724
|
-
return createAttributesResource({ encode: encode2 });
|
|
10725
|
-
}
|
|
10726
|
-
|
|
10727
11511
|
// src/core/types/flows/interop.ts
|
|
10728
11512
|
function isInteropMessageProof(obj) {
|
|
10729
11513
|
if (typeof obj !== "object" || obj === null) return false;
|
|
@@ -10900,24 +11684,6 @@ function buildIndirectBundle(params, ctx, attrs, starterData, interopFeeInfo) {
|
|
|
10900
11684
|
}
|
|
10901
11685
|
};
|
|
10902
11686
|
}
|
|
10903
|
-
var PREFIX_EVM_CHAIN = ethers.getBytes("0x00010000");
|
|
10904
|
-
var PREFIX_EVM_ADDRESS = ethers.getBytes("0x000100000014");
|
|
10905
|
-
function formatInteropEvmChain(chainId) {
|
|
10906
|
-
const chainRef = ethers.toBeArray(chainId);
|
|
10907
|
-
const chainRefLength = ethers.getBytes(ethers.toBeHex(chainRef.length, 1));
|
|
10908
|
-
const payload = ethers.concat([PREFIX_EVM_CHAIN, chainRefLength, chainRef, new Uint8Array([0])]);
|
|
10909
|
-
return ethers.hexlify(payload);
|
|
10910
|
-
}
|
|
10911
|
-
function formatInteropEvmAddress(address) {
|
|
10912
|
-
const normalized = ethers.getAddress(address);
|
|
10913
|
-
const addrBytes = ethers.getBytes(normalized);
|
|
10914
|
-
const payload = ethers.concat([PREFIX_EVM_ADDRESS, addrBytes]);
|
|
10915
|
-
return ethers.hexlify(payload);
|
|
10916
|
-
}
|
|
10917
|
-
var interopCodec = {
|
|
10918
|
-
formatChain: formatInteropEvmChain,
|
|
10919
|
-
formatAddress: formatInteropEvmAddress
|
|
10920
|
-
};
|
|
10921
11687
|
function getErc20Tokens(params) {
|
|
10922
11688
|
const erc20Tokens = /* @__PURE__ */ new Map();
|
|
10923
11689
|
for (const action of params.actions) {
|
|
@@ -11073,7 +11839,7 @@ function routeIndirect() {
|
|
|
11073
11839
|
resolveErc20AssetIds(erc20Tokens, ctx),
|
|
11074
11840
|
buildFeeInfo(params, ctx, params.actions.length)
|
|
11075
11841
|
]);
|
|
11076
|
-
const
|
|
11842
|
+
const attributes2 = getInteropAttributes(params, ctx);
|
|
11077
11843
|
const starterData = await getStarterData(params, ctx, erc20AssetIds);
|
|
11078
11844
|
const bundle = buildIndirectBundle(
|
|
11079
11845
|
params,
|
|
@@ -11084,7 +11850,7 @@ function routeIndirect() {
|
|
|
11084
11850
|
l2NativeTokenVault: ctx.l2NativeTokenVault,
|
|
11085
11851
|
codec: interopCodec
|
|
11086
11852
|
},
|
|
11087
|
-
|
|
11853
|
+
attributes2,
|
|
11088
11854
|
starterData,
|
|
11089
11855
|
feeInfo
|
|
11090
11856
|
);
|
|
@@ -11207,7 +11973,7 @@ async function assertInteropProtocolVersion(client, srcChainId, dstChainId) {
|
|
|
11207
11973
|
assertProtocolVersion(srcChainId, srcProtocolVersion);
|
|
11208
11974
|
assertProtocolVersion(dstChainId, dstProtocolVersion);
|
|
11209
11975
|
}
|
|
11210
|
-
async function commonCtx3(dstProvider, params, client, tokens, contracts,
|
|
11976
|
+
async function commonCtx3(dstProvider, params, client, tokens, contracts, attributes2) {
|
|
11211
11977
|
const sender = await client.signer.getAddress();
|
|
11212
11978
|
const chainId = (await client.l2.getNetwork()).chainId;
|
|
11213
11979
|
const dstChainId = (await dstProvider.getNetwork()).chainId;
|
|
@@ -11244,7 +12010,7 @@ async function commonCtx3(dstProvider, params, client, tokens, contracts, attrib
|
|
|
11244
12010
|
l2NativeTokenVault,
|
|
11245
12011
|
baseTokens: { src: srcBaseToken, dst: dstBaseToken, matches: baseMatches },
|
|
11246
12012
|
ifaces: { interopCenter: interopCenterIface, interopHandler: interopHandlerIface },
|
|
11247
|
-
attributes,
|
|
12013
|
+
attributes: attributes2,
|
|
11248
12014
|
gasOverrides: params.txOverrides ? toGasOverrides(params.txOverrides) : void 0
|
|
11249
12015
|
};
|
|
11250
12016
|
}
|
|
@@ -11900,7 +12666,7 @@ var ROUTES3 = {
|
|
|
11900
12666
|
direct: routeDirect(),
|
|
11901
12667
|
indirect: routeIndirect()
|
|
11902
12668
|
};
|
|
11903
|
-
function createInteropResource(client, config, tokens, contracts,
|
|
12669
|
+
function createInteropResource(client, config, tokens, contracts, attributes2) {
|
|
11904
12670
|
let gwProviderCache;
|
|
11905
12671
|
function requireConfig() {
|
|
11906
12672
|
if (!config)
|
|
@@ -11918,7 +12684,7 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
11918
12684
|
const svc = createInteropFinalizationServices(client);
|
|
11919
12685
|
const tokensResource = tokens ?? createTokensResource(client);
|
|
11920
12686
|
const contractsResource = contracts ?? createContractsResource(client);
|
|
11921
|
-
const attributesResource =
|
|
12687
|
+
const attributesResource = attributes2 ?? createEthersAttributesResource();
|
|
11922
12688
|
async function buildPlanWithCtx(dstProvider, params) {
|
|
11923
12689
|
const ctx = await commonCtx3(
|
|
11924
12690
|
dstProvider,
|
|
@@ -12131,7 +12897,7 @@ function createEthersSdk(client, options) {
|
|
|
12131
12897
|
const interop = createInteropResource(client, options?.interop, tokens, contracts);
|
|
12132
12898
|
return {
|
|
12133
12899
|
deposits: createDepositsResource(client, tokens, contracts),
|
|
12134
|
-
withdrawals: createWithdrawalsResource(client, tokens, contracts),
|
|
12900
|
+
withdrawals: createWithdrawalsResource(client, tokens, contracts, options?.withdrawals),
|
|
12135
12901
|
tokens,
|
|
12136
12902
|
contracts,
|
|
12137
12903
|
interop
|
|
@@ -12149,6 +12915,7 @@ exports.createFinalizationServices = createFinalizationServices;
|
|
|
12149
12915
|
exports.createInteropFinalizationServices = createInteropFinalizationServices;
|
|
12150
12916
|
exports.createInteropResource = createInteropResource;
|
|
12151
12917
|
exports.createTokensResource = createTokensResource;
|
|
12918
|
+
exports.createWithdrawalProtocolService = createWithdrawalProtocolService;
|
|
12152
12919
|
exports.createWithdrawalsResource = createWithdrawalsResource;
|
|
12153
12920
|
exports.decodeRevert = decodeRevert;
|
|
12154
12921
|
exports.encodeNativeTokenVaultTransferData = encodeNativeTokenVaultTransferData;
|