@matterlabs/zksync-js 0.0.24 → 0.0.25
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/index.cjs +138 -79
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +2 -2
- package/dist/adapters/ethers/resources/deposits/services/fee.d.ts +1 -0
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +9 -2
- package/dist/adapters/ethers/sdk.cjs +138 -79
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +2 -2
- package/dist/adapters/viem/index.cjs +165 -119
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +2 -2
- package/dist/adapters/viem/resources/deposits/services/fee.d.ts +1 -0
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +9 -2
- package/dist/adapters/viem/sdk.cjs +165 -119
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +2 -2
- package/dist/{chunk-5S63J6DW.js → chunk-JWN26CQ6.js} +30 -10
- package/dist/{chunk-B6P24GL5.js → chunk-N5E4FLBF.js} +108 -69
- package/dist/{chunk-QMMFUWRV.js → chunk-NFRRRT5X.js} +136 -115
- package/dist/core/resources/deposits/gas.d.ts +11 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createNTVCodec, createAttributesResource, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, pickInteropRoute, ZERO_HASH, toGasOverrides, clampPriorityL2GasLimit, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Gas, applyL1ToL2Alias, derivePriorityBodyGasEstimateCap, assertProtocolVersion, resolveRegisteredTokenPriorityL2GasLimit, quoteL2Gas2 } from './chunk-
|
|
1
|
+
import { createNTVCodec, createAttributesResource, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, pickInteropRoute, ZERO_HASH, toGasOverrides, clampPriorityL2GasLimit, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Fees, quoteL1Gas, applyL1ToL2Alias, derivePriorityBodyGasEstimateCap, assertProtocolVersion, resolveRegisteredTokenPriorityL2GasLimit, quoteL2Gas2 } from './chunk-JWN26CQ6.js';
|
|
2
2
|
import { detectWithdrawalProtocol, buildWithdrawalFinalization, parseBundleHashFromLogs, classifyWithdrawalOutcome, phaseFromReadiness, buildWithdrawalBundle } from './chunk-BQ2YCWV2.js';
|
|
3
3
|
import { findL1MessageSentLog, messengerLogIndex, l1MessageSentSender, pickWithdrawRoute } from './chunk-OEUDZFXH.js';
|
|
4
4
|
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-H5A6GU3D.js';
|
|
@@ -195,6 +195,7 @@ function viemToGasEstimator(client) {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// src/adapters/viem/resources/deposits/services/gas.ts
|
|
198
|
+
var { wrapAs } = createErrorHandlers("deposits");
|
|
198
199
|
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
199
200
|
async function estimatePriorityTxL2Gas(ctx, leg) {
|
|
200
201
|
if (!leg) return void 0;
|
|
@@ -204,6 +205,18 @@ async function estimatePriorityTxL2Gas(ctx, leg) {
|
|
|
204
205
|
return void 0;
|
|
205
206
|
}
|
|
206
207
|
}
|
|
208
|
+
async function quoteL1Fees2(input) {
|
|
209
|
+
const { ctx } = input;
|
|
210
|
+
return wrapAs(
|
|
211
|
+
"RPC",
|
|
212
|
+
"deposits.fees.l1",
|
|
213
|
+
() => quoteL1Fees({
|
|
214
|
+
estimator: viemToGasEstimator(ctx.client.l1),
|
|
215
|
+
overrides: ctx.gasOverrides
|
|
216
|
+
}),
|
|
217
|
+
{ ctx: { chainIdL2: ctx.chainIdL2 } }
|
|
218
|
+
);
|
|
219
|
+
}
|
|
207
220
|
async function quoteL1Gas2(input) {
|
|
208
221
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
209
222
|
const estimator = viemToGasEstimator(ctx.client.l1);
|
|
@@ -306,13 +319,10 @@ async function determineEthNonBaseL2Gas(input) {
|
|
|
306
319
|
}
|
|
307
320
|
|
|
308
321
|
// src/adapters/viem/resources/deposits/services/fee.ts
|
|
309
|
-
var { wrapAs } = createErrorHandlers("deposits");
|
|
322
|
+
var { wrapAs: wrapAs2 } = createErrorHandlers("deposits");
|
|
310
323
|
async function quoteL2BaseCost(input) {
|
|
311
|
-
const { ctx, l2GasLimit } = input;
|
|
312
|
-
|
|
313
|
-
const fees = await estimator.estimateFeesPerGas();
|
|
314
|
-
const gasPrice = fees.maxFeePerGas ?? fees.gasPrice ?? await estimator.getGasPrice();
|
|
315
|
-
return wrapAs(
|
|
324
|
+
const { ctx, l2GasLimit, l1GasPrice } = input;
|
|
325
|
+
return wrapAs2(
|
|
316
326
|
"RPC",
|
|
317
327
|
"deposits.fees.l2BaseCost",
|
|
318
328
|
async () => {
|
|
@@ -320,7 +330,7 @@ async function quoteL2BaseCost(input) {
|
|
|
320
330
|
address: ctx.bridgehub,
|
|
321
331
|
abi: IBridgehub_default,
|
|
322
332
|
functionName: "l2TransactionBaseCost",
|
|
323
|
-
args: [ctx.chainIdL2,
|
|
333
|
+
args: [ctx.chainIdL2, l1GasPrice, l2GasLimit, ctx.gasPerPubdata]
|
|
324
334
|
});
|
|
325
335
|
},
|
|
326
336
|
{ ctx: { chainIdL2: ctx.chainIdL2 } }
|
|
@@ -387,7 +397,7 @@ function getPriorityTxGasBreakdown(input) {
|
|
|
387
397
|
}
|
|
388
398
|
|
|
389
399
|
// src/adapters/viem/resources/deposits/routes/eth.ts
|
|
390
|
-
var { wrapAs:
|
|
400
|
+
var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
|
|
391
401
|
var EMPTY_BYTES2 = "0x";
|
|
392
402
|
function routeEthDirect() {
|
|
393
403
|
return {
|
|
@@ -418,7 +428,12 @@ function routeEthDirect() {
|
|
|
418
428
|
if (!l2GasParams) {
|
|
419
429
|
throw new Error("Failed to estimate L2 gas for deposit.");
|
|
420
430
|
}
|
|
421
|
-
const
|
|
431
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
432
|
+
const baseCost = await quoteL2BaseCost({
|
|
433
|
+
ctx,
|
|
434
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
435
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
436
|
+
});
|
|
422
437
|
const mintValue = baseCost + ctx.operatorTip + l2Value;
|
|
423
438
|
const req = buildDirectRequestStruct({
|
|
424
439
|
chainId: ctx.chainIdL2,
|
|
@@ -429,7 +444,7 @@ function routeEthDirect() {
|
|
|
429
444
|
l2Contract,
|
|
430
445
|
l2Value
|
|
431
446
|
});
|
|
432
|
-
const sim = await
|
|
447
|
+
const sim = await wrapAs3(
|
|
433
448
|
"RPC",
|
|
434
449
|
OP_DEPOSITS.eth.estGas,
|
|
435
450
|
() => ctx.client.l1.simulateContract({
|
|
@@ -455,22 +470,19 @@ function routeEthDirect() {
|
|
|
455
470
|
data,
|
|
456
471
|
value: mintValue,
|
|
457
472
|
from: ctx.sender,
|
|
458
|
-
...ctx.gasOverrides
|
|
473
|
+
...ctx.gasOverrides,
|
|
474
|
+
...l1Fees
|
|
459
475
|
};
|
|
460
476
|
const l1Gas = await quoteL1Gas2({
|
|
461
477
|
ctx,
|
|
462
478
|
tx: l1TxCandidate,
|
|
463
479
|
overrides: ctx.gasOverrides
|
|
464
480
|
});
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
maxFeePerGas: l1Gas.maxFeePerGas,
|
|
471
|
-
maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
|
|
472
|
-
};
|
|
473
|
-
}
|
|
481
|
+
const bridgeTx = {
|
|
482
|
+
...sim.request,
|
|
483
|
+
...l1Fees,
|
|
484
|
+
...l1Gas ? { gas: l1Gas.gasLimit } : {}
|
|
485
|
+
};
|
|
474
486
|
const steps = [
|
|
475
487
|
{
|
|
476
488
|
key: "bridgehub:direct",
|
|
@@ -544,7 +556,7 @@ async function buildApprovalRequest({
|
|
|
544
556
|
}
|
|
545
557
|
|
|
546
558
|
// src/adapters/viem/resources/deposits/routes/erc20-nonbase.ts
|
|
547
|
-
var { wrapAs:
|
|
559
|
+
var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
|
|
548
560
|
var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
549
561
|
var ntvCodec = createNTVCodec({
|
|
550
562
|
encode: (types, values) => encodeAbiParameters(
|
|
@@ -635,7 +647,7 @@ function routeErc20NonBase() {
|
|
|
635
647
|
return {
|
|
636
648
|
// TODO: do we even need these validations?
|
|
637
649
|
async preflight(p, ctx) {
|
|
638
|
-
await
|
|
650
|
+
await wrapAs4(
|
|
639
651
|
"VALIDATION",
|
|
640
652
|
OP_DEPOSITS.nonbase.assertNotEthAsset,
|
|
641
653
|
() => {
|
|
@@ -646,7 +658,7 @@ function routeErc20NonBase() {
|
|
|
646
658
|
{ ctx: { token: p.token } }
|
|
647
659
|
);
|
|
648
660
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
649
|
-
await
|
|
661
|
+
await wrapAs4(
|
|
650
662
|
"VALIDATION",
|
|
651
663
|
OP_DEPOSITS.nonbase.assertNonBaseToken,
|
|
652
664
|
() => {
|
|
@@ -663,7 +675,7 @@ function routeErc20NonBase() {
|
|
|
663
675
|
const assetRouter = ctx.l1AssetRouter;
|
|
664
676
|
const nativeTokenVault = ctx.l1NativeTokenVault;
|
|
665
677
|
const receiver = p.to ?? ctx.sender;
|
|
666
|
-
const secondBridgeCalldata = await
|
|
678
|
+
const secondBridgeCalldata = await wrapAs4(
|
|
667
679
|
"INTERNAL",
|
|
668
680
|
OP_DEPOSITS.nonbase.encodeCalldata,
|
|
669
681
|
() => encodeSecondBridgeErc20DepositCalldata({
|
|
@@ -701,11 +713,16 @@ function routeErc20NonBase() {
|
|
|
701
713
|
}
|
|
702
714
|
});
|
|
703
715
|
if (!l2Gas) throw new Error("Failed to establish L2 gas parameters.");
|
|
704
|
-
const
|
|
716
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
717
|
+
const l2BaseCost = await quoteL2BaseCost({
|
|
718
|
+
ctx,
|
|
719
|
+
l2GasLimit: l2Gas.gasLimit,
|
|
720
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
721
|
+
});
|
|
705
722
|
const mintValue = l2BaseCost + ctx.operatorTip;
|
|
706
723
|
const approvals = [];
|
|
707
724
|
const steps = [];
|
|
708
|
-
const depositAllowance = await
|
|
725
|
+
const depositAllowance = await wrapAs4(
|
|
709
726
|
"CONTRACT",
|
|
710
727
|
OP_DEPOSITS.nonbase.allowanceToken,
|
|
711
728
|
() => ctx.client.l1.readContract({
|
|
@@ -720,7 +737,7 @@ function routeErc20NonBase() {
|
|
|
720
737
|
}
|
|
721
738
|
);
|
|
722
739
|
if (depositAllowance < p.amount) {
|
|
723
|
-
const approveTx = await
|
|
740
|
+
const approveTx = await wrapAs4(
|
|
724
741
|
"CONTRACT",
|
|
725
742
|
OP_DEPOSITS.nonbase.estGas,
|
|
726
743
|
() => buildApprovalRequest({
|
|
@@ -743,7 +760,7 @@ function routeErc20NonBase() {
|
|
|
743
760
|
});
|
|
744
761
|
}
|
|
745
762
|
if (!baseIsEth) {
|
|
746
|
-
const baseAllowance = await
|
|
763
|
+
const baseAllowance = await wrapAs4(
|
|
747
764
|
"CONTRACT",
|
|
748
765
|
OP_DEPOSITS.nonbase.allowanceBase,
|
|
749
766
|
() => ctx.client.l1.readContract({
|
|
@@ -758,7 +775,7 @@ function routeErc20NonBase() {
|
|
|
758
775
|
}
|
|
759
776
|
);
|
|
760
777
|
if (baseAllowance < mintValue) {
|
|
761
|
-
const approveBaseTx = await
|
|
778
|
+
const approveBaseTx = await wrapAs4(
|
|
762
779
|
"CONTRACT",
|
|
763
780
|
OP_DEPOSITS.nonbase.estGas,
|
|
764
781
|
() => buildApprovalRequest({
|
|
@@ -803,7 +820,8 @@ function routeErc20NonBase() {
|
|
|
803
820
|
data: calldata,
|
|
804
821
|
value: msgValue,
|
|
805
822
|
from: ctx.sender,
|
|
806
|
-
...ctx.gasOverrides
|
|
823
|
+
...ctx.gasOverrides,
|
|
824
|
+
...l1Fees
|
|
807
825
|
};
|
|
808
826
|
const l1Gas = await quoteL1Gas2({
|
|
809
827
|
ctx,
|
|
@@ -823,7 +841,7 @@ function routeErc20NonBase() {
|
|
|
823
841
|
account: ctx.client.account
|
|
824
842
|
};
|
|
825
843
|
} else {
|
|
826
|
-
const sim = await
|
|
844
|
+
const sim = await wrapAs4(
|
|
827
845
|
"CONTRACT",
|
|
828
846
|
OP_DEPOSITS.nonbase.estGas,
|
|
829
847
|
() => ctx.client.l1.simulateContract({
|
|
@@ -841,14 +859,11 @@ function routeErc20NonBase() {
|
|
|
841
859
|
);
|
|
842
860
|
bridgeTx = { ...sim.request };
|
|
843
861
|
}
|
|
844
|
-
|
|
845
|
-
bridgeTx
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
|
|
850
|
-
};
|
|
851
|
-
}
|
|
862
|
+
bridgeTx = {
|
|
863
|
+
...bridgeTx,
|
|
864
|
+
...l1Fees,
|
|
865
|
+
...l1Gas ? { gas: l1Gas.gasLimit } : {}
|
|
866
|
+
};
|
|
852
867
|
steps.push({
|
|
853
868
|
key: "bridgehub:two-bridges:erc20-nonbase",
|
|
854
869
|
kind: "bridgehub:two-bridges",
|
|
@@ -871,7 +886,7 @@ function routeErc20NonBase() {
|
|
|
871
886
|
}
|
|
872
887
|
};
|
|
873
888
|
}
|
|
874
|
-
var { wrapAs:
|
|
889
|
+
var { wrapAs: wrapAs5 } = createErrorHandlers("deposits");
|
|
875
890
|
var ZERO_ASSET_ID2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
876
891
|
var ntvCodec2 = createNTVCodec({
|
|
877
892
|
encode: (types, values) => encodeAbiParameters(
|
|
@@ -955,7 +970,7 @@ function routeEthNonBase() {
|
|
|
955
970
|
return {
|
|
956
971
|
// TODO: do we even need these validations?
|
|
957
972
|
async preflight(p, ctx) {
|
|
958
|
-
await
|
|
973
|
+
await wrapAs5(
|
|
959
974
|
"VALIDATION",
|
|
960
975
|
OP_DEPOSITS.ethNonBase.assertEthAsset,
|
|
961
976
|
() => {
|
|
@@ -965,7 +980,7 @@ function routeEthNonBase() {
|
|
|
965
980
|
},
|
|
966
981
|
{ ctx: { token: p.token } }
|
|
967
982
|
);
|
|
968
|
-
await
|
|
983
|
+
await wrapAs5(
|
|
969
984
|
"VALIDATION",
|
|
970
985
|
OP_DEPOSITS.ethNonBase.assertNonEthBase,
|
|
971
986
|
() => {
|
|
@@ -975,7 +990,7 @@ function routeEthNonBase() {
|
|
|
975
990
|
},
|
|
976
991
|
{ ctx: { baseIsEth: ctx.baseIsEth, chainIdL2: ctx.chainIdL2 } }
|
|
977
992
|
);
|
|
978
|
-
const ethBal = await
|
|
993
|
+
const ethBal = await wrapAs5(
|
|
979
994
|
"RPC",
|
|
980
995
|
OP_DEPOSITS.ethNonBase.ethBalance,
|
|
981
996
|
() => ctx.client.l1.getBalance({ address: ctx.sender }),
|
|
@@ -984,7 +999,7 @@ function routeEthNonBase() {
|
|
|
984
999
|
message: "Failed to read L1 ETH balance."
|
|
985
1000
|
}
|
|
986
1001
|
);
|
|
987
|
-
await
|
|
1002
|
+
await wrapAs5(
|
|
988
1003
|
"VALIDATION",
|
|
989
1004
|
OP_DEPOSITS.ethNonBase.assertEthBalance,
|
|
990
1005
|
() => {
|
|
@@ -1017,11 +1032,16 @@ function routeEthNonBase() {
|
|
|
1017
1032
|
undeployedGasLimit: priorityGasModel.undeployedGasLimit
|
|
1018
1033
|
});
|
|
1019
1034
|
if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
|
|
1020
|
-
const
|
|
1035
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
1036
|
+
const l2BaseCost = await quoteL2BaseCost({
|
|
1037
|
+
ctx,
|
|
1038
|
+
l2GasLimit: l2Gas.gasLimit,
|
|
1039
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
1040
|
+
});
|
|
1021
1041
|
const mintValue = l2BaseCost + ctx.operatorTip;
|
|
1022
1042
|
const approvals = [];
|
|
1023
1043
|
const steps = [];
|
|
1024
|
-
const allowance = await
|
|
1044
|
+
const allowance = await wrapAs5(
|
|
1025
1045
|
"CONTRACT",
|
|
1026
1046
|
OP_DEPOSITS.ethNonBase.allowanceBase,
|
|
1027
1047
|
() => ctx.client.l1.readContract({
|
|
@@ -1037,7 +1057,7 @@ function routeEthNonBase() {
|
|
|
1037
1057
|
);
|
|
1038
1058
|
const needsApprove = allowance < mintValue;
|
|
1039
1059
|
if (needsApprove) {
|
|
1040
|
-
const approveTx = await
|
|
1060
|
+
const approveTx = await wrapAs5(
|
|
1041
1061
|
"CONTRACT",
|
|
1042
1062
|
OP_DEPOSITS.ethNonBase.estGas,
|
|
1043
1063
|
() => buildApprovalRequest({
|
|
@@ -1059,7 +1079,7 @@ function routeEthNonBase() {
|
|
|
1059
1079
|
tx: approveTx
|
|
1060
1080
|
});
|
|
1061
1081
|
}
|
|
1062
|
-
const secondBridgeCalldata = await
|
|
1082
|
+
const secondBridgeCalldata = await wrapAs5(
|
|
1063
1083
|
"INTERNAL",
|
|
1064
1084
|
OP_DEPOSITS.ethNonBase.encodeCalldata,
|
|
1065
1085
|
() => encodeSecondBridgeEthDepositCalldata({ ctx, amount: p.amount, receiver }),
|
|
@@ -1101,7 +1121,7 @@ function routeEthNonBase() {
|
|
|
1101
1121
|
args: [requestStruct]
|
|
1102
1122
|
});
|
|
1103
1123
|
} else {
|
|
1104
|
-
const sim = await
|
|
1124
|
+
const sim = await wrapAs5(
|
|
1105
1125
|
"CONTRACT",
|
|
1106
1126
|
OP_DEPOSITS.ethNonBase.estGas,
|
|
1107
1127
|
() => ctx.client.l1.simulateContract({
|
|
@@ -1129,7 +1149,8 @@ function routeEthNonBase() {
|
|
|
1129
1149
|
data: calldata,
|
|
1130
1150
|
value: bridgehubValue,
|
|
1131
1151
|
from: ctx.sender,
|
|
1132
|
-
...ctx.gasOverrides
|
|
1152
|
+
...ctx.gasOverrides,
|
|
1153
|
+
...l1Fees
|
|
1133
1154
|
};
|
|
1134
1155
|
const l1Gas = await quoteL1Gas2({
|
|
1135
1156
|
ctx,
|
|
@@ -1137,14 +1158,11 @@ function routeEthNonBase() {
|
|
|
1137
1158
|
overrides: ctx.gasOverrides,
|
|
1138
1159
|
fallbackGasLimit: SAFE_L1_BRIDGE_GAS
|
|
1139
1160
|
});
|
|
1140
|
-
|
|
1141
|
-
bridgeTx
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
|
|
1146
|
-
};
|
|
1147
|
-
}
|
|
1161
|
+
bridgeTx = {
|
|
1162
|
+
...bridgeTx,
|
|
1163
|
+
...l1Fees,
|
|
1164
|
+
...l1Gas ? { gas: l1Gas.gasLimit } : {}
|
|
1165
|
+
};
|
|
1148
1166
|
steps.push({
|
|
1149
1167
|
key: "bridgehub:two-bridges:eth-nonbase",
|
|
1150
1168
|
kind: "bridgehub:two-bridges",
|
|
@@ -1167,12 +1185,12 @@ function routeEthNonBase() {
|
|
|
1167
1185
|
}
|
|
1168
1186
|
};
|
|
1169
1187
|
}
|
|
1170
|
-
var { wrapAs:
|
|
1188
|
+
var { wrapAs: wrapAs6 } = createErrorHandlers("deposits");
|
|
1171
1189
|
var EMPTY_BYTES3 = "0x";
|
|
1172
1190
|
function routeErc20Base() {
|
|
1173
1191
|
return {
|
|
1174
1192
|
async preflight(p, ctx) {
|
|
1175
|
-
await
|
|
1193
|
+
await wrapAs6(
|
|
1176
1194
|
"VALIDATION",
|
|
1177
1195
|
OP_DEPOSITS.base.assertErc20Asset,
|
|
1178
1196
|
() => {
|
|
@@ -1183,7 +1201,7 @@ function routeErc20Base() {
|
|
|
1183
1201
|
{ ctx: { token: p.token } }
|
|
1184
1202
|
);
|
|
1185
1203
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
1186
|
-
await
|
|
1204
|
+
await wrapAs6(
|
|
1187
1205
|
"VALIDATION",
|
|
1188
1206
|
OP_DEPOSITS.base.assertMatchesBase,
|
|
1189
1207
|
() => {
|
|
@@ -1220,11 +1238,16 @@ function routeErc20Base() {
|
|
|
1220
1238
|
overrideGasLimit: quotedL2GasLimit
|
|
1221
1239
|
});
|
|
1222
1240
|
if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
|
|
1223
|
-
const
|
|
1241
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
1242
|
+
const l2BaseCost = await quoteL2BaseCost({
|
|
1243
|
+
ctx,
|
|
1244
|
+
l2GasLimit: l2Gas.gasLimit,
|
|
1245
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
1246
|
+
});
|
|
1224
1247
|
const mintValue = l2BaseCost + ctx.operatorTip + p.amount;
|
|
1225
1248
|
const approvals = [];
|
|
1226
1249
|
const steps = [];
|
|
1227
|
-
const allowance = await
|
|
1250
|
+
const allowance = await wrapAs6(
|
|
1228
1251
|
"CONTRACT",
|
|
1229
1252
|
OP_DEPOSITS.base.allowance,
|
|
1230
1253
|
() => ctx.client.l1.readContract({
|
|
@@ -1240,7 +1263,7 @@ function routeErc20Base() {
|
|
|
1240
1263
|
);
|
|
1241
1264
|
const needsApprove = allowance < mintValue;
|
|
1242
1265
|
if (needsApprove) {
|
|
1243
|
-
const approveTx = await
|
|
1266
|
+
const approveTx = await wrapAs6(
|
|
1244
1267
|
"CONTRACT",
|
|
1245
1268
|
OP_DEPOSITS.base.estGas,
|
|
1246
1269
|
() => buildApprovalRequest({
|
|
@@ -1289,7 +1312,7 @@ function routeErc20Base() {
|
|
|
1289
1312
|
args: [req]
|
|
1290
1313
|
});
|
|
1291
1314
|
} else {
|
|
1292
|
-
const sim = await
|
|
1315
|
+
const sim = await wrapAs6(
|
|
1293
1316
|
"RPC",
|
|
1294
1317
|
OP_DEPOSITS.base.estGas,
|
|
1295
1318
|
() => ctx.client.l1.simulateContract({
|
|
@@ -1317,7 +1340,8 @@ function routeErc20Base() {
|
|
|
1317
1340
|
data: calldata,
|
|
1318
1341
|
value: 0n,
|
|
1319
1342
|
from: ctx.sender,
|
|
1320
|
-
...ctx.gasOverrides
|
|
1343
|
+
...ctx.gasOverrides,
|
|
1344
|
+
...l1Fees
|
|
1321
1345
|
};
|
|
1322
1346
|
const l1Gas = await quoteL1Gas2({
|
|
1323
1347
|
ctx,
|
|
@@ -1325,14 +1349,11 @@ function routeErc20Base() {
|
|
|
1325
1349
|
overrides: ctx.gasOverrides,
|
|
1326
1350
|
fallbackGasLimit: SAFE_L1_BRIDGE_GAS
|
|
1327
1351
|
});
|
|
1328
|
-
|
|
1329
|
-
bridgeTx
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
maxPriorityFeePerGas: l1Gas.maxPriorityFeePerGas
|
|
1334
|
-
};
|
|
1335
|
-
}
|
|
1352
|
+
bridgeTx = {
|
|
1353
|
+
...bridgeTx,
|
|
1354
|
+
...l1Fees,
|
|
1355
|
+
...l1Gas ? { gas: l1Gas.gasLimit } : {}
|
|
1356
|
+
};
|
|
1336
1357
|
steps.push({
|
|
1337
1358
|
key: "bridgehub:direct:erc20-base",
|
|
1338
1359
|
kind: "bridgehub:direct",
|
|
@@ -1430,7 +1451,7 @@ async function waitForL2ExecutionFromL1Tx(l1, l2, l1TxHash) {
|
|
|
1430
1451
|
}
|
|
1431
1452
|
return { l2Receipt, l2TxHash };
|
|
1432
1453
|
}
|
|
1433
|
-
var { wrapAs:
|
|
1454
|
+
var { wrapAs: wrapAs7 } = createErrorHandlers("tokens");
|
|
1434
1455
|
var ntvCodec3 = createNTVCodec({
|
|
1435
1456
|
encode: (types, values) => encodeAbiParameters(
|
|
1436
1457
|
types.map((t, i) => ({ type: t, name: `arg${i}` })),
|
|
@@ -1445,7 +1466,7 @@ function createTokensResource(client) {
|
|
|
1445
1466
|
let wethL2Promise = null;
|
|
1446
1467
|
async function getL1ChainId() {
|
|
1447
1468
|
if (!l2NtvL1ChainIdPromise) {
|
|
1448
|
-
l2NtvL1ChainIdPromise =
|
|
1469
|
+
l2NtvL1ChainIdPromise = wrapAs7("INTERNAL", "getL1ChainId", async () => {
|
|
1449
1470
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1450
1471
|
return await l2NativeTokenVault.read.L1_CHAIN_ID();
|
|
1451
1472
|
});
|
|
@@ -1454,7 +1475,7 @@ function createTokensResource(client) {
|
|
|
1454
1475
|
}
|
|
1455
1476
|
async function getBaseTokenAssetId() {
|
|
1456
1477
|
if (!baseTokenAssetIdPromise) {
|
|
1457
|
-
baseTokenAssetIdPromise =
|
|
1478
|
+
baseTokenAssetIdPromise = wrapAs7("INTERNAL", "baseTokenAssetId", async () => {
|
|
1458
1479
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1459
1480
|
const assetId = await l2NativeTokenVault.read.BASE_TOKEN_ASSET_ID();
|
|
1460
1481
|
return assetId;
|
|
@@ -1464,7 +1485,7 @@ function createTokensResource(client) {
|
|
|
1464
1485
|
}
|
|
1465
1486
|
async function getWethL1() {
|
|
1466
1487
|
if (!wethL1Promise) {
|
|
1467
|
-
wethL1Promise =
|
|
1488
|
+
wethL1Promise = wrapAs7("INTERNAL", "wethL1", async () => {
|
|
1468
1489
|
const { l1NativeTokenVault } = await client.contracts();
|
|
1469
1490
|
const weth = await l1NativeTokenVault.read.WETH_TOKEN();
|
|
1470
1491
|
return weth;
|
|
@@ -1474,7 +1495,7 @@ function createTokensResource(client) {
|
|
|
1474
1495
|
}
|
|
1475
1496
|
async function getWethL2() {
|
|
1476
1497
|
if (!wethL2Promise) {
|
|
1477
|
-
wethL2Promise =
|
|
1498
|
+
wethL2Promise = wrapAs7("INTERNAL", "wethL2", async () => {
|
|
1478
1499
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1479
1500
|
const weth = await l2NativeTokenVault.read.WETH_TOKEN();
|
|
1480
1501
|
return weth;
|
|
@@ -1483,7 +1504,7 @@ function createTokensResource(client) {
|
|
|
1483
1504
|
return wethL2Promise;
|
|
1484
1505
|
}
|
|
1485
1506
|
async function toL2Address(l1Token) {
|
|
1486
|
-
return
|
|
1507
|
+
return wrapAs7("CONTRACT", "tokens.toL2Address", async () => {
|
|
1487
1508
|
const normalized = normalizeL1Token(l1Token);
|
|
1488
1509
|
const chainId = BigInt(await client.l2.getChainId());
|
|
1489
1510
|
const baseToken = await client.baseToken(chainId);
|
|
@@ -1496,7 +1517,7 @@ function createTokensResource(client) {
|
|
|
1496
1517
|
});
|
|
1497
1518
|
}
|
|
1498
1519
|
async function toL1Address(l2Token) {
|
|
1499
|
-
return
|
|
1520
|
+
return wrapAs7("CONTRACT", "tokens.toL1Address", async () => {
|
|
1500
1521
|
if (isAddressEq(l2Token, ETH_ADDRESS)) return ETH_ADDRESS;
|
|
1501
1522
|
if (isAddressEq(l2Token, L2_BASE_TOKEN_ADDRESS)) {
|
|
1502
1523
|
const chainId = BigInt(await client.l2.getChainId());
|
|
@@ -1517,32 +1538,32 @@ function createTokensResource(client) {
|
|
|
1517
1538
|
});
|
|
1518
1539
|
}
|
|
1519
1540
|
async function assetIdOfL1(l1Token) {
|
|
1520
|
-
return
|
|
1541
|
+
return wrapAs7("CONTRACT", "tokens.assetIdOfL1", async () => {
|
|
1521
1542
|
const normalized = normalizeL1Token(l1Token);
|
|
1522
1543
|
const { l1NativeTokenVault } = await client.contracts();
|
|
1523
1544
|
return await l1NativeTokenVault.read.assetId([normalized]);
|
|
1524
1545
|
});
|
|
1525
1546
|
}
|
|
1526
1547
|
async function assetIdOfL2(l2Token) {
|
|
1527
|
-
return
|
|
1548
|
+
return wrapAs7("CONTRACT", "tokens.assetIdOfL2", async () => {
|
|
1528
1549
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1529
1550
|
return await l2NativeTokenVault.read.assetId([l2Token]);
|
|
1530
1551
|
});
|
|
1531
1552
|
}
|
|
1532
1553
|
async function l2TokenFromAssetId(assetId) {
|
|
1533
|
-
return
|
|
1554
|
+
return wrapAs7("CONTRACT", "tokens.l2TokenFromAssetId", async () => {
|
|
1534
1555
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1535
1556
|
return await l2NativeTokenVault.read.tokenAddress([assetId]);
|
|
1536
1557
|
});
|
|
1537
1558
|
}
|
|
1538
1559
|
async function l1TokenFromAssetId(assetId) {
|
|
1539
|
-
return
|
|
1560
|
+
return wrapAs7("CONTRACT", "tokens.l1TokenFromAssetId", async () => {
|
|
1540
1561
|
const { l1NativeTokenVault } = await client.contracts();
|
|
1541
1562
|
return await l1NativeTokenVault.read.tokenAddress([assetId]);
|
|
1542
1563
|
});
|
|
1543
1564
|
}
|
|
1544
1565
|
async function originChainId(assetId) {
|
|
1545
|
-
return
|
|
1566
|
+
return wrapAs7("CONTRACT", "tokens.originChainId", async () => {
|
|
1546
1567
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1547
1568
|
return await l2NativeTokenVault.read.originChainId([assetId]);
|
|
1548
1569
|
});
|
|
@@ -1551,7 +1572,7 @@ function createTokensResource(client) {
|
|
|
1551
1572
|
return getBaseTokenAssetId();
|
|
1552
1573
|
}
|
|
1553
1574
|
async function isChainEthBased() {
|
|
1554
|
-
return
|
|
1575
|
+
return wrapAs7("CONTRACT", "tokens.isChainEthBased", async () => {
|
|
1555
1576
|
const baseAssetId = await getBaseTokenAssetId();
|
|
1556
1577
|
const l1ChainId = await getL1ChainId();
|
|
1557
1578
|
const ethAssetId = ntvCodec3.encodeAssetId(
|
|
@@ -1569,7 +1590,7 @@ function createTokensResource(client) {
|
|
|
1569
1590
|
return getWethL2();
|
|
1570
1591
|
}
|
|
1571
1592
|
async function computeL2BridgedAddress(args) {
|
|
1572
|
-
return
|
|
1593
|
+
return wrapAs7("CONTRACT", "tokens.computeL2BridgedAddress", async () => {
|
|
1573
1594
|
const normalized = normalizeL1Token(args.l1Token);
|
|
1574
1595
|
const { l2NativeTokenVault } = await client.contracts();
|
|
1575
1596
|
const predicted = await l2NativeTokenVault.read.calculateCreate2TokenAddress([
|
|
@@ -1580,7 +1601,7 @@ function createTokensResource(client) {
|
|
|
1580
1601
|
});
|
|
1581
1602
|
}
|
|
1582
1603
|
async function resolve(ref, opts) {
|
|
1583
|
-
return
|
|
1604
|
+
return wrapAs7("CONTRACT", "tokens.resolve", async () => {
|
|
1584
1605
|
let chain;
|
|
1585
1606
|
let address;
|
|
1586
1607
|
if (typeof ref === "string") {
|
|
@@ -2094,12 +2115,12 @@ function buildFeeBreakdown2(p) {
|
|
|
2094
2115
|
}
|
|
2095
2116
|
|
|
2096
2117
|
// src/adapters/viem/resources/withdrawals/routes/eth.ts
|
|
2097
|
-
var { wrapAs:
|
|
2118
|
+
var { wrapAs: wrapAs8 } = createErrorHandlers("withdrawals");
|
|
2098
2119
|
function routeEthBase() {
|
|
2099
2120
|
return {
|
|
2100
2121
|
async build(p, ctx) {
|
|
2101
2122
|
const steps = [];
|
|
2102
|
-
const data = await
|
|
2123
|
+
const data = await wrapAs8(
|
|
2103
2124
|
"INTERNAL",
|
|
2104
2125
|
OP_WITHDRAWALS.eth.encodeWithdraw,
|
|
2105
2126
|
() => Promise.resolve(
|
|
@@ -2149,14 +2170,14 @@ function routeEthBase() {
|
|
|
2149
2170
|
}
|
|
2150
2171
|
};
|
|
2151
2172
|
}
|
|
2152
|
-
var { wrapAs:
|
|
2173
|
+
var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
|
|
2153
2174
|
function routeErc20NonBase2() {
|
|
2154
2175
|
return {
|
|
2155
2176
|
// TODO: add preflight validations here
|
|
2156
2177
|
async build(p, ctx) {
|
|
2157
2178
|
const steps = [];
|
|
2158
2179
|
const approvals = [];
|
|
2159
|
-
const current = await
|
|
2180
|
+
const current = await wrapAs9(
|
|
2160
2181
|
"CONTRACT",
|
|
2161
2182
|
OP_WITHDRAWALS.erc20.allowance,
|
|
2162
2183
|
() => ctx.client.l2.readContract({
|
|
@@ -2195,7 +2216,7 @@ function routeErc20NonBase2() {
|
|
|
2195
2216
|
approveTxCandidate.maxFeePerGas = approveGas.maxFeePerGas;
|
|
2196
2217
|
approveTxCandidate.maxPriorityFeePerGas = approveGas.maxPriorityFeePerGas;
|
|
2197
2218
|
}
|
|
2198
|
-
const approveSim = await
|
|
2219
|
+
const approveSim = await wrapAs9(
|
|
2199
2220
|
"CONTRACT",
|
|
2200
2221
|
OP_WITHDRAWALS.erc20.estGas,
|
|
2201
2222
|
() => ctx.client.l2.simulateContract({
|
|
@@ -2222,7 +2243,7 @@ function routeErc20NonBase2() {
|
|
|
2222
2243
|
tx: approveTx
|
|
2223
2244
|
});
|
|
2224
2245
|
}
|
|
2225
|
-
const assetId = (await
|
|
2246
|
+
const assetId = (await wrapAs9(
|
|
2226
2247
|
"CONTRACT",
|
|
2227
2248
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
2228
2249
|
() => ctx.client.l2.simulateContract({
|
|
@@ -2273,7 +2294,7 @@ function routeErc20NonBase2() {
|
|
|
2273
2294
|
...withdrawGas
|
|
2274
2295
|
};
|
|
2275
2296
|
} else {
|
|
2276
|
-
const sim = await
|
|
2297
|
+
const sim = await wrapAs9(
|
|
2277
2298
|
"CONTRACT",
|
|
2278
2299
|
OP_WITHDRAWALS.erc20.estGas,
|
|
2279
2300
|
() => ctx.client.l2.simulateContract({
|
|
@@ -2368,7 +2389,7 @@ function createViemAttributesResource() {
|
|
|
2368
2389
|
}
|
|
2369
2390
|
|
|
2370
2391
|
// src/adapters/viem/resources/withdrawals/routes/interop-bundle.ts
|
|
2371
|
-
var { wrapAs:
|
|
2392
|
+
var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
|
|
2372
2393
|
var attributes = createViemAttributesResource();
|
|
2373
2394
|
function saltFor(sender, nonce) {
|
|
2374
2395
|
return keccak256(
|
|
@@ -2393,7 +2414,7 @@ function routeInteropBundle() {
|
|
|
2393
2414
|
if (isBaseToken) {
|
|
2394
2415
|
assetId = ctx.baseTokenAssetId;
|
|
2395
2416
|
} else {
|
|
2396
|
-
assetId = (await
|
|
2417
|
+
assetId = (await wrapAs10(
|
|
2397
2418
|
"CONTRACT",
|
|
2398
2419
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
2399
2420
|
() => ctx.client.l2.simulateContract({
|
|
@@ -2408,7 +2429,7 @@ function routeInteropBundle() {
|
|
|
2408
2429
|
message: "Failed to ensure token is registered in L2NativeTokenVault."
|
|
2409
2430
|
}
|
|
2410
2431
|
)).result;
|
|
2411
|
-
const current = await
|
|
2432
|
+
const current = await wrapAs10(
|
|
2412
2433
|
"CONTRACT",
|
|
2413
2434
|
OP_WITHDRAWALS.erc20.allowance,
|
|
2414
2435
|
() => ctx.client.l2.readContract({
|
|
@@ -2457,7 +2478,7 @@ function routeInteropBundle() {
|
|
|
2457
2478
|
});
|
|
2458
2479
|
}
|
|
2459
2480
|
}
|
|
2460
|
-
const nonce = await
|
|
2481
|
+
const nonce = await wrapAs10(
|
|
2461
2482
|
"RPC",
|
|
2462
2483
|
OP_WITHDRAWALS.prepare,
|
|
2463
2484
|
() => ctx.client.l2.getTransactionCount({ address: ctx.sender, blockTag: "pending" }),
|
|
@@ -2563,7 +2584,7 @@ function createWithdrawalProtocolService(client, override) {
|
|
|
2563
2584
|
}
|
|
2564
2585
|
};
|
|
2565
2586
|
}
|
|
2566
|
-
var { wrapAs:
|
|
2587
|
+
var { wrapAs: wrapAs11 } = createErrorHandlers("withdrawals");
|
|
2567
2588
|
var IL1NullifierMini = [
|
|
2568
2589
|
{
|
|
2569
2590
|
type: "function",
|
|
@@ -2581,7 +2602,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2581
2602
|
async function finalizationTarget(protocol) {
|
|
2582
2603
|
const { l1Nullifier } = await client.ensureAddresses();
|
|
2583
2604
|
if (protocol === "legacy-withdrawal") return l1Nullifier;
|
|
2584
|
-
return await
|
|
2605
|
+
return await wrapAs11(
|
|
2585
2606
|
"CONTRACT",
|
|
2586
2607
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
2587
2608
|
() => client.l1.readContract({
|
|
@@ -2596,7 +2617,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2596
2617
|
);
|
|
2597
2618
|
}
|
|
2598
2619
|
async function fetchMessageAndProof(l2TxHash) {
|
|
2599
|
-
const raw = await
|
|
2620
|
+
const raw = await wrapAs11(
|
|
2600
2621
|
"RPC",
|
|
2601
2622
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
2602
2623
|
() => client.zks.getReceiptWithL2ToL1(l2TxHash),
|
|
@@ -2613,7 +2634,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2613
2634
|
context: { l2TxHash }
|
|
2614
2635
|
});
|
|
2615
2636
|
}
|
|
2616
|
-
const ev = await
|
|
2637
|
+
const ev = await wrapAs11(
|
|
2617
2638
|
"INTERNAL",
|
|
2618
2639
|
OP_WITHDRAWALS.finalize.fetchParams.findMessage,
|
|
2619
2640
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
@@ -2623,7 +2644,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2623
2644
|
message: "Failed to locate L1MessageSent event in L2 receipt."
|
|
2624
2645
|
}
|
|
2625
2646
|
);
|
|
2626
|
-
const message = await
|
|
2647
|
+
const message = await wrapAs11(
|
|
2627
2648
|
"INTERNAL",
|
|
2628
2649
|
OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
|
|
2629
2650
|
() => {
|
|
@@ -2635,7 +2656,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2635
2656
|
message: "Failed to decode withdrawal message."
|
|
2636
2657
|
}
|
|
2637
2658
|
);
|
|
2638
|
-
const idx = await
|
|
2659
|
+
const idx = await wrapAs11(
|
|
2639
2660
|
"INTERNAL",
|
|
2640
2661
|
OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
|
|
2641
2662
|
() => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
|
|
@@ -2644,7 +2665,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2644
2665
|
message: "Failed to derive messenger log index."
|
|
2645
2666
|
}
|
|
2646
2667
|
);
|
|
2647
|
-
const proof = await
|
|
2668
|
+
const proof = await wrapAs11(
|
|
2648
2669
|
"RPC",
|
|
2649
2670
|
OP_WITHDRAWALS.finalize.fetchParams.proof,
|
|
2650
2671
|
() => client.zks.getL2ToL1LogProof(l2TxHash, idx),
|
|
@@ -2653,7 +2674,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2653
2674
|
message: "Failed to fetch L2\u2192L1 log proof."
|
|
2654
2675
|
}
|
|
2655
2676
|
);
|
|
2656
|
-
const chainId = await
|
|
2677
|
+
const chainId = await wrapAs11(
|
|
2657
2678
|
"RPC",
|
|
2658
2679
|
OP_WITHDRAWALS.finalize.fetchParams.network,
|
|
2659
2680
|
() => client.l2.getChainId(),
|
|
@@ -2711,7 +2732,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2711
2732
|
async function withdrawalOutcome(finalization) {
|
|
2712
2733
|
const target = await finalizationTarget(finalization.protocol);
|
|
2713
2734
|
if (finalization.protocol === "legacy-withdrawal") {
|
|
2714
|
-
const done = await
|
|
2735
|
+
const done = await wrapAs11(
|
|
2715
2736
|
"RPC",
|
|
2716
2737
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
2717
2738
|
() => client.l1.readContract({
|
|
@@ -2733,7 +2754,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2733
2754
|
}
|
|
2734
2755
|
const { bundleHash } = finalization.params;
|
|
2735
2756
|
const status = Number(
|
|
2736
|
-
await
|
|
2757
|
+
await wrapAs11(
|
|
2737
2758
|
"RPC",
|
|
2738
2759
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
2739
2760
|
() => client.l1.readContract({
|
|
@@ -2750,7 +2771,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2750
2771
|
);
|
|
2751
2772
|
if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
|
|
2752
2773
|
const callStatus = Number(
|
|
2753
|
-
await
|
|
2774
|
+
await wrapAs11(
|
|
2754
2775
|
"RPC",
|
|
2755
2776
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
2756
2777
|
() => client.l1.readContract({
|
|
@@ -2821,7 +2842,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2821
2842
|
},
|
|
2822
2843
|
async estimateFinalization(finalization) {
|
|
2823
2844
|
const target = await finalizationTarget(finalization.protocol);
|
|
2824
|
-
const gasLimit = await
|
|
2845
|
+
const gasLimit = await wrapAs11(
|
|
2825
2846
|
"RPC",
|
|
2826
2847
|
OP_WITHDRAWALS.finalize.estimate,
|
|
2827
2848
|
() => finalization.protocol === "legacy-withdrawal" ? client.l1.estimateContractGas({
|
|
@@ -2849,7 +2870,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2849
2870
|
let maxFeePerGas;
|
|
2850
2871
|
let maxPriorityFeePerGas;
|
|
2851
2872
|
try {
|
|
2852
|
-
const fee = await
|
|
2873
|
+
const fee = await wrapAs11(
|
|
2853
2874
|
"RPC",
|
|
2854
2875
|
OP_WITHDRAWALS.finalize.estimate,
|
|
2855
2876
|
() => client.l1.estimateFeesPerGas(),
|
|
@@ -2868,7 +2889,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
2868
2889
|
})();
|
|
2869
2890
|
maxPriorityFeePerGas = fee.maxPriorityFeePerGas ?? 0n;
|
|
2870
2891
|
} catch {
|
|
2871
|
-
const gasPrice = await
|
|
2892
|
+
const gasPrice = await wrapAs11(
|
|
2872
2893
|
"RPC",
|
|
2873
2894
|
OP_WITHDRAWALS.finalize.estimate,
|
|
2874
2895
|
() => client.l1.getGasPrice(),
|