@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
|
@@ -7840,7 +7840,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
7840
7840
|
function wrap8(operation, fn, opts) {
|
|
7841
7841
|
return run("INTERNAL", operation, fn, opts);
|
|
7842
7842
|
}
|
|
7843
|
-
function
|
|
7843
|
+
function wrapAs12(kind, operation, fn, opts) {
|
|
7844
7844
|
return run(kind, operation, fn, opts);
|
|
7845
7845
|
}
|
|
7846
7846
|
async function toResult3(operation, fn, opts) {
|
|
@@ -7861,7 +7861,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
7861
7861
|
return { ok: false, error: shaped };
|
|
7862
7862
|
}
|
|
7863
7863
|
}
|
|
7864
|
-
return { wrap: wrap8, wrapAs:
|
|
7864
|
+
return { wrap: wrap8, wrapAs: wrapAs12, toResult: toResult3 };
|
|
7865
7865
|
}
|
|
7866
7866
|
return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
|
|
7867
7867
|
}
|
|
@@ -8379,6 +8379,7 @@ function isEraVmChain(chainIdL2) {
|
|
|
8379
8379
|
|
|
8380
8380
|
// src/core/resources/deposits/gas.ts
|
|
8381
8381
|
var CREATE_REESTIMATE_BUFFER = 15n;
|
|
8382
|
+
var ZERO_FEES = { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
|
|
8382
8383
|
var maxBigInt = (a, b) => a > b ? a : b;
|
|
8383
8384
|
function applyGasBuffer(gasLimit, bufferPct = BUFFER) {
|
|
8384
8385
|
return gasLimit * (100n + bufferPct) / 100n;
|
|
@@ -8429,15 +8430,39 @@ async function fetchFees(estimator) {
|
|
|
8429
8430
|
const gp = await estimator.getGasPrice();
|
|
8430
8431
|
return { maxFeePerGas: gp, maxPriorityFeePerGas: 0n };
|
|
8431
8432
|
} catch {
|
|
8432
|
-
return
|
|
8433
|
+
return void 0;
|
|
8434
|
+
}
|
|
8435
|
+
}
|
|
8436
|
+
async function quoteL1Fees(input) {
|
|
8437
|
+
const { estimator, overrides } = input;
|
|
8438
|
+
const maxFeeOverride = overrides?.maxFeePerGas;
|
|
8439
|
+
const tipOverride = overrides?.maxPriorityFeePerGas;
|
|
8440
|
+
if (maxFeeOverride != null && tipOverride != null) {
|
|
8441
|
+
return { maxFeePerGas: maxFeeOverride, maxPriorityFeePerGas: tipOverride };
|
|
8442
|
+
}
|
|
8443
|
+
const market = await fetchFees(estimator);
|
|
8444
|
+
if (maxFeeOverride != null) {
|
|
8445
|
+
const tip = market?.maxPriorityFeePerGas ?? 0n;
|
|
8446
|
+
return {
|
|
8447
|
+
maxFeePerGas: maxFeeOverride,
|
|
8448
|
+
maxPriorityFeePerGas: tip < maxFeeOverride ? tip : maxFeeOverride
|
|
8449
|
+
};
|
|
8450
|
+
}
|
|
8451
|
+
if (market == null) {
|
|
8452
|
+
throw new Error("Could not fetch L1 gas price for Bridgehub base cost calculation.");
|
|
8453
|
+
}
|
|
8454
|
+
if (tipOverride != null) {
|
|
8455
|
+
const headroom = market.maxFeePerGas > market.maxPriorityFeePerGas ? market.maxFeePerGas - market.maxPriorityFeePerGas : 0n;
|
|
8456
|
+
return { maxFeePerGas: headroom + tipOverride, maxPriorityFeePerGas: tipOverride };
|
|
8433
8457
|
}
|
|
8458
|
+
return market;
|
|
8434
8459
|
}
|
|
8435
8460
|
async function quoteL1Gas(input) {
|
|
8436
8461
|
const { estimator, tx, overrides, fallbackGasLimit } = input;
|
|
8437
8462
|
let market;
|
|
8438
8463
|
const getMarket = async () => {
|
|
8439
8464
|
if (market) return market;
|
|
8440
|
-
market = await fetchFees(estimator);
|
|
8465
|
+
market = await fetchFees(estimator) ?? ZERO_FEES;
|
|
8441
8466
|
return market;
|
|
8442
8467
|
};
|
|
8443
8468
|
const maxFeePerGas = overrides?.maxFeePerGas ?? (tx.maxFeePerGas != null ? BigInt(tx.maxFeePerGas) : (await getMarket()).maxFeePerGas);
|
|
@@ -8459,7 +8484,7 @@ async function quoteL1Gas(input) {
|
|
|
8459
8484
|
}
|
|
8460
8485
|
async function quoteL2Gas(input) {
|
|
8461
8486
|
const { estimator, route, tx, gasPerPubdata, l2GasLimit, overrideGasLimit, stateOverrides } = input;
|
|
8462
|
-
const market = await fetchFees(estimator);
|
|
8487
|
+
const market = await fetchFees(estimator) ?? ZERO_FEES;
|
|
8463
8488
|
const maxFeePerGas = market.maxFeePerGas || market.maxPriorityFeePerGas || 0n;
|
|
8464
8489
|
const txGasLimit = tx?.gasLimit != null ? BigInt(tx.gasLimit) : void 0;
|
|
8465
8490
|
const explicit = overrideGasLimit ?? txGasLimit;
|
|
@@ -8500,12 +8525,7 @@ async function quoteL2Gas(input) {
|
|
|
8500
8525
|
}
|
|
8501
8526
|
}
|
|
8502
8527
|
async function quoteL2BaseCost(input) {
|
|
8503
|
-
const { estimator, encode: encode2, bridgehub, chainIdL2, l2GasLimit, gasPerPubdata } = input;
|
|
8504
|
-
const market = await fetchFees(estimator);
|
|
8505
|
-
const l1GasPrice = market.maxFeePerGas || market.maxPriorityFeePerGas || 0n;
|
|
8506
|
-
if (l1GasPrice === 0n) {
|
|
8507
|
-
throw new Error("Could not fetch L1 gas price for Bridgehub base cost calculation.");
|
|
8508
|
-
}
|
|
8528
|
+
const { estimator, encode: encode2, bridgehub, chainIdL2, l2GasLimit, gasPerPubdata, l1GasPrice } = input;
|
|
8509
8529
|
const data = encode2(IBridgehub_default, "l2TransactionBaseCost", [
|
|
8510
8530
|
chainIdL2,
|
|
8511
8531
|
l1GasPrice,
|
|
@@ -8527,8 +8547,9 @@ function toCoreTx(tx) {
|
|
|
8527
8547
|
data: tx.data,
|
|
8528
8548
|
value: tx.value ? BigInt(tx.value) : void 0,
|
|
8529
8549
|
gasLimit: tx.gasLimit ? BigInt(tx.gasLimit) : void 0,
|
|
8530
|
-
|
|
8531
|
-
|
|
8550
|
+
// zero fees are explicit on zero-base-fee chains; dropping them would re-fetch the market tip
|
|
8551
|
+
maxFeePerGas: tx.maxFeePerGas != null ? BigInt(tx.maxFeePerGas) : void 0,
|
|
8552
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas != null ? BigInt(tx.maxPriorityFeePerGas) : void 0
|
|
8532
8553
|
};
|
|
8533
8554
|
}
|
|
8534
8555
|
function ethersToGasEstimator(provider) {
|
|
@@ -8603,7 +8624,7 @@ var encode = (abi2, fn, args) => {
|
|
|
8603
8624
|
return new ethers.Interface(abi2).encodeFunctionData(fn, args);
|
|
8604
8625
|
};
|
|
8605
8626
|
async function quoteL2BaseCost2(input) {
|
|
8606
|
-
const { ctx, l2GasLimit } = input;
|
|
8627
|
+
const { ctx, l2GasLimit, l1GasPrice } = input;
|
|
8607
8628
|
const estimator = ethersToGasEstimator(ctx.client.l1);
|
|
8608
8629
|
return wrapAs2(
|
|
8609
8630
|
"RPC",
|
|
@@ -8614,7 +8635,8 @@ async function quoteL2BaseCost2(input) {
|
|
|
8614
8635
|
bridgehub: ctx.bridgehub,
|
|
8615
8636
|
chainIdL2: ctx.chainIdL2,
|
|
8616
8637
|
l2GasLimit,
|
|
8617
|
-
gasPerPubdata: ctx.gasPerPubdata
|
|
8638
|
+
gasPerPubdata: ctx.gasPerPubdata,
|
|
8639
|
+
l1GasPrice
|
|
8618
8640
|
}),
|
|
8619
8641
|
{ ctx: { chainIdL2: ctx.chainIdL2 } }
|
|
8620
8642
|
);
|
|
@@ -8683,6 +8705,7 @@ function resolveRegisteredTokenPriorityL2GasLimit(input) {
|
|
|
8683
8705
|
}
|
|
8684
8706
|
|
|
8685
8707
|
// src/adapters/ethers/resources/deposits/services/gas.ts
|
|
8708
|
+
var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
|
|
8686
8709
|
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
8687
8710
|
var ZERO_L2_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
8688
8711
|
async function estimatePriorityTxL2Gas(ctx, leg) {
|
|
@@ -8693,6 +8716,18 @@ async function estimatePriorityTxL2Gas(ctx, leg) {
|
|
|
8693
8716
|
return void 0;
|
|
8694
8717
|
}
|
|
8695
8718
|
}
|
|
8719
|
+
async function quoteL1Fees2(input) {
|
|
8720
|
+
const { ctx } = input;
|
|
8721
|
+
return wrapAs3(
|
|
8722
|
+
"RPC",
|
|
8723
|
+
"deposits.fees.l1",
|
|
8724
|
+
() => quoteL1Fees({
|
|
8725
|
+
estimator: ethersToGasEstimator(ctx.client.l1),
|
|
8726
|
+
overrides: ctx.gasOverrides
|
|
8727
|
+
}),
|
|
8728
|
+
{ ctx: { chainIdL2: ctx.chainIdL2 } }
|
|
8729
|
+
);
|
|
8730
|
+
}
|
|
8696
8731
|
async function quoteL1Gas2(input) {
|
|
8697
8732
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
8698
8733
|
const estimator = ethersToGasEstimator(ctx.client.l1);
|
|
@@ -8892,7 +8927,12 @@ function routeEthDirect() {
|
|
|
8892
8927
|
if (!l2GasParams) {
|
|
8893
8928
|
throw new Error("Failed to estimate L2 gas for deposit.");
|
|
8894
8929
|
}
|
|
8895
|
-
const
|
|
8930
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
8931
|
+
const baseCost = await quoteL2BaseCost2({
|
|
8932
|
+
ctx,
|
|
8933
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
8934
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
8935
|
+
});
|
|
8896
8936
|
const mintValue = baseCost + ctx.operatorTip + l2Value;
|
|
8897
8937
|
const req = buildDirectRequestStruct({
|
|
8898
8938
|
chainId: ctx.chainIdL2,
|
|
@@ -8909,7 +8949,8 @@ function routeEthDirect() {
|
|
|
8909
8949
|
data,
|
|
8910
8950
|
value: mintValue,
|
|
8911
8951
|
from: ctx.sender,
|
|
8912
|
-
...ctx.gasOverrides
|
|
8952
|
+
...ctx.gasOverrides,
|
|
8953
|
+
...l1Fees
|
|
8913
8954
|
};
|
|
8914
8955
|
const l1GasParams = await quoteL1Gas2({
|
|
8915
8956
|
ctx,
|
|
@@ -8961,7 +9002,7 @@ function createNTVCodec(deps) {
|
|
|
8961
9002
|
}
|
|
8962
9003
|
|
|
8963
9004
|
// src/adapters/ethers/resources/deposits/routes/erc20-nonbase.ts
|
|
8964
|
-
var { wrapAs:
|
|
9005
|
+
var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
|
|
8965
9006
|
var ZERO_L2_TOKEN_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
8966
9007
|
var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
8967
9008
|
var ntvCodec = createNTVCodec({
|
|
@@ -9044,7 +9085,7 @@ function routeErc20NonBase() {
|
|
|
9044
9085
|
async preflight(p, ctx) {
|
|
9045
9086
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
9046
9087
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
9047
|
-
await
|
|
9088
|
+
await wrapAs4(
|
|
9048
9089
|
"VALIDATION",
|
|
9049
9090
|
OP_DEPOSITS.nonbase.assertNonBaseToken,
|
|
9050
9091
|
() => {
|
|
@@ -9060,7 +9101,7 @@ function routeErc20NonBase() {
|
|
|
9060
9101
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
9061
9102
|
const baseIsEth = ctx.baseIsEth ?? isETH(baseToken);
|
|
9062
9103
|
const receiver = p.to ?? ctx.sender;
|
|
9063
|
-
const secondBridgeCalldata = await
|
|
9104
|
+
const secondBridgeCalldata = await wrapAs4(
|
|
9064
9105
|
"INTERNAL",
|
|
9065
9106
|
OP_DEPOSITS.nonbase.encodeCalldata,
|
|
9066
9107
|
() => encodeSecondBridgeErc20DepositCalldata({
|
|
@@ -9094,14 +9135,19 @@ function routeErc20NonBase() {
|
|
|
9094
9135
|
}
|
|
9095
9136
|
});
|
|
9096
9137
|
if (!l2GasParams) throw new Error("Failed to establish L2 gas parameters.");
|
|
9097
|
-
const
|
|
9138
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
9139
|
+
const baseCost = await quoteL2BaseCost2({
|
|
9140
|
+
ctx,
|
|
9141
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
9142
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
9143
|
+
});
|
|
9098
9144
|
const mintValue = baseCost + ctx.operatorTip;
|
|
9099
9145
|
const approvals = [];
|
|
9100
9146
|
const steps = [];
|
|
9101
9147
|
const assetRouter = ctx.l1AssetRouter;
|
|
9102
9148
|
const nativeTokenVault = ctx.l1NativeTokenVault;
|
|
9103
9149
|
const erc20Deposit = new ethers.Contract(p.token, IERC20_default, l1Signer);
|
|
9104
|
-
const allowanceToken = await
|
|
9150
|
+
const allowanceToken = await wrapAs4(
|
|
9105
9151
|
"RPC",
|
|
9106
9152
|
OP_DEPOSITS.nonbase.allowanceToken,
|
|
9107
9153
|
() => erc20Deposit.allowance(ctx.sender, nativeTokenVault),
|
|
@@ -9129,7 +9175,7 @@ function routeErc20NonBase() {
|
|
|
9129
9175
|
}
|
|
9130
9176
|
if (!baseIsEth) {
|
|
9131
9177
|
const erc20Base = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
9132
|
-
const allowanceBase = await
|
|
9178
|
+
const allowanceBase = await wrapAs4(
|
|
9133
9179
|
"RPC",
|
|
9134
9180
|
OP_DEPOSITS.nonbase.allowanceBase,
|
|
9135
9181
|
() => erc20Base.allowance(ctx.sender, nativeTokenVault),
|
|
@@ -9177,7 +9223,8 @@ function routeErc20NonBase() {
|
|
|
9177
9223
|
data,
|
|
9178
9224
|
value: txValue,
|
|
9179
9225
|
from: ctx.sender,
|
|
9180
|
-
...ctx.gasOverrides
|
|
9226
|
+
...ctx.gasOverrides,
|
|
9227
|
+
...l1Fees
|
|
9181
9228
|
};
|
|
9182
9229
|
const l1GasParams = await quoteL1Gas2({
|
|
9183
9230
|
ctx,
|
|
@@ -9212,7 +9259,7 @@ function routeErc20NonBase() {
|
|
|
9212
9259
|
}
|
|
9213
9260
|
};
|
|
9214
9261
|
}
|
|
9215
|
-
var { wrapAs:
|
|
9262
|
+
var { wrapAs: wrapAs5 } = createErrorHandlers("deposits");
|
|
9216
9263
|
var ZERO_L2_TOKEN_ADDRESS3 = "0x0000000000000000000000000000000000000000";
|
|
9217
9264
|
var ZERO_ASSET_ID2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
9218
9265
|
var ntvCodec2 = createNTVCodec({
|
|
@@ -9288,7 +9335,7 @@ function routeEthNonBase() {
|
|
|
9288
9335
|
return {
|
|
9289
9336
|
async preflight(p, ctx) {
|
|
9290
9337
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
9291
|
-
await
|
|
9338
|
+
await wrapAs5(
|
|
9292
9339
|
"VALIDATION",
|
|
9293
9340
|
OP_DEPOSITS.ethNonBase.assertEthAsset,
|
|
9294
9341
|
() => {
|
|
@@ -9298,7 +9345,7 @@ function routeEthNonBase() {
|
|
|
9298
9345
|
},
|
|
9299
9346
|
{ ctx: { token: p.token } }
|
|
9300
9347
|
);
|
|
9301
|
-
await
|
|
9348
|
+
await wrapAs5(
|
|
9302
9349
|
"VALIDATION",
|
|
9303
9350
|
OP_DEPOSITS.ethNonBase.assertNonEthBase,
|
|
9304
9351
|
() => {
|
|
@@ -9308,7 +9355,7 @@ function routeEthNonBase() {
|
|
|
9308
9355
|
},
|
|
9309
9356
|
{ ctx: { baseIsEth: ctx.baseIsEth, chainIdL2: ctx.chainIdL2 } }
|
|
9310
9357
|
);
|
|
9311
|
-
const ethBal = await
|
|
9358
|
+
const ethBal = await wrapAs5(
|
|
9312
9359
|
"RPC",
|
|
9313
9360
|
OP_DEPOSITS.ethNonBase.ethBalance,
|
|
9314
9361
|
() => ctx.client.l1.getBalance(ctx.sender),
|
|
@@ -9317,7 +9364,7 @@ function routeEthNonBase() {
|
|
|
9317
9364
|
message: "Failed to read L1 ETH balance."
|
|
9318
9365
|
}
|
|
9319
9366
|
);
|
|
9320
|
-
await
|
|
9367
|
+
await wrapAs5(
|
|
9321
9368
|
"VALIDATION",
|
|
9322
9369
|
OP_DEPOSITS.ethNonBase.assertEthBalance,
|
|
9323
9370
|
() => {
|
|
@@ -9352,12 +9399,17 @@ function routeEthNonBase() {
|
|
|
9352
9399
|
undeployedGasLimit: priorityGasModel.undeployedGasLimit
|
|
9353
9400
|
});
|
|
9354
9401
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
9355
|
-
const
|
|
9402
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
9403
|
+
const baseCost = await quoteL2BaseCost2({
|
|
9404
|
+
ctx,
|
|
9405
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
9406
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
9407
|
+
});
|
|
9356
9408
|
const mintValue = baseCost + ctx.operatorTip;
|
|
9357
9409
|
const approvals = [];
|
|
9358
9410
|
const steps = [];
|
|
9359
9411
|
const erc20Base = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
9360
|
-
const allowance = await
|
|
9412
|
+
const allowance = await wrapAs5(
|
|
9361
9413
|
"RPC",
|
|
9362
9414
|
OP_DEPOSITS.ethNonBase.allowanceBase,
|
|
9363
9415
|
() => erc20Base.allowance(ctx.sender, ctx.l1NativeTokenVault),
|
|
@@ -9383,7 +9435,7 @@ function routeEthNonBase() {
|
|
|
9383
9435
|
}
|
|
9384
9436
|
});
|
|
9385
9437
|
}
|
|
9386
|
-
const secondBridgeCalldata = await
|
|
9438
|
+
const secondBridgeCalldata = await wrapAs5(
|
|
9387
9439
|
"INTERNAL",
|
|
9388
9440
|
OP_DEPOSITS.ethNonBase.encodeCalldata,
|
|
9389
9441
|
() => encodeSecondBridgeEthDepositCalldata({ ctx, amount: p.amount, receiver }),
|
|
@@ -9416,7 +9468,8 @@ function routeEthNonBase() {
|
|
|
9416
9468
|
data,
|
|
9417
9469
|
value: bridgehubValue,
|
|
9418
9470
|
from: ctx.sender,
|
|
9419
|
-
...ctx.gasOverrides
|
|
9471
|
+
...ctx.gasOverrides,
|
|
9472
|
+
...l1Fees
|
|
9420
9473
|
};
|
|
9421
9474
|
const l1GasParams = await quoteL1Gas2({
|
|
9422
9475
|
ctx,
|
|
@@ -9451,13 +9504,13 @@ function routeEthNonBase() {
|
|
|
9451
9504
|
}
|
|
9452
9505
|
};
|
|
9453
9506
|
}
|
|
9454
|
-
var { wrapAs:
|
|
9507
|
+
var { wrapAs: wrapAs6 } = createErrorHandlers("deposits");
|
|
9455
9508
|
var EMPTY_BYTES3 = "0x";
|
|
9456
9509
|
function routeErc20Base() {
|
|
9457
9510
|
return {
|
|
9458
9511
|
async preflight(p, ctx) {
|
|
9459
9512
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
9460
|
-
await
|
|
9513
|
+
await wrapAs6(
|
|
9461
9514
|
"VALIDATION",
|
|
9462
9515
|
OP_DEPOSITS.base.assertErc20Asset,
|
|
9463
9516
|
() => {
|
|
@@ -9468,7 +9521,7 @@ function routeErc20Base() {
|
|
|
9468
9521
|
{ ctx: { token: p.token } }
|
|
9469
9522
|
);
|
|
9470
9523
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
9471
|
-
await
|
|
9524
|
+
await wrapAs6(
|
|
9472
9525
|
"VALIDATION",
|
|
9473
9526
|
OP_DEPOSITS.base.assertMatchesBase,
|
|
9474
9527
|
() => {
|
|
@@ -9507,13 +9560,18 @@ function routeErc20Base() {
|
|
|
9507
9560
|
overrideGasLimit: quotedL2GasLimit
|
|
9508
9561
|
});
|
|
9509
9562
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
9510
|
-
const
|
|
9563
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
9564
|
+
const baseCost = await quoteL2BaseCost2({
|
|
9565
|
+
ctx,
|
|
9566
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
9567
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
9568
|
+
});
|
|
9511
9569
|
const mintValue = baseCost + ctx.operatorTip + p.amount;
|
|
9512
9570
|
const approvals = [];
|
|
9513
9571
|
const steps = [];
|
|
9514
9572
|
{
|
|
9515
9573
|
const erc20 = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
9516
|
-
const allowance = await
|
|
9574
|
+
const allowance = await wrapAs6(
|
|
9517
9575
|
"RPC",
|
|
9518
9576
|
OP_DEPOSITS.base.allowance,
|
|
9519
9577
|
() => erc20.allowance(ctx.sender, ctx.l1NativeTokenVault),
|
|
@@ -9559,7 +9617,8 @@ function routeErc20Base() {
|
|
|
9559
9617
|
value: 0n,
|
|
9560
9618
|
// base token is ERC-20 ⇒ msg.value MUST be 0
|
|
9561
9619
|
from: ctx.sender,
|
|
9562
|
-
...ctx.gasOverrides
|
|
9620
|
+
...ctx.gasOverrides,
|
|
9621
|
+
...l1Fees
|
|
9563
9622
|
};
|
|
9564
9623
|
const l1GasParams = await quoteL1Gas2({
|
|
9565
9624
|
ctx,
|
|
@@ -9594,7 +9653,7 @@ function routeErc20Base() {
|
|
|
9594
9653
|
}
|
|
9595
9654
|
};
|
|
9596
9655
|
}
|
|
9597
|
-
var { wrapAs:
|
|
9656
|
+
var { wrapAs: wrapAs7 } = createErrorHandlers("tokens");
|
|
9598
9657
|
var abi = ethers.AbiCoder.defaultAbiCoder();
|
|
9599
9658
|
var ntvCodec3 = createNTVCodec({
|
|
9600
9659
|
encode: (types, values) => abi.encode(types, values),
|
|
@@ -9607,7 +9666,7 @@ function createTokensResource(client) {
|
|
|
9607
9666
|
let wethL2Promise = null;
|
|
9608
9667
|
async function getL1ChainId() {
|
|
9609
9668
|
if (!l2NtvL1ChainIdPromise) {
|
|
9610
|
-
l2NtvL1ChainIdPromise =
|
|
9669
|
+
l2NtvL1ChainIdPromise = wrapAs7("INTERNAL", "getL1ChainId", async () => {
|
|
9611
9670
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9612
9671
|
const chainId = await l2NativeTokenVault.L1_CHAIN_ID();
|
|
9613
9672
|
return chainId;
|
|
@@ -9617,7 +9676,7 @@ function createTokensResource(client) {
|
|
|
9617
9676
|
}
|
|
9618
9677
|
async function getBaseTokenAssetId() {
|
|
9619
9678
|
if (!baseTokenAssetIdPromise) {
|
|
9620
|
-
baseTokenAssetIdPromise =
|
|
9679
|
+
baseTokenAssetIdPromise = wrapAs7("INTERNAL", "baseTokenAssetId", async () => {
|
|
9621
9680
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9622
9681
|
const assetId = await l2NativeTokenVault.BASE_TOKEN_ASSET_ID();
|
|
9623
9682
|
return assetId;
|
|
@@ -9627,7 +9686,7 @@ function createTokensResource(client) {
|
|
|
9627
9686
|
}
|
|
9628
9687
|
async function getWethL1() {
|
|
9629
9688
|
if (!wethL1Promise) {
|
|
9630
|
-
wethL1Promise =
|
|
9689
|
+
wethL1Promise = wrapAs7("INTERNAL", "wethL1", async () => {
|
|
9631
9690
|
const { l1NativeTokenVault } = await client.contracts();
|
|
9632
9691
|
const weth = await l1NativeTokenVault.WETH_TOKEN();
|
|
9633
9692
|
return weth;
|
|
@@ -9637,7 +9696,7 @@ function createTokensResource(client) {
|
|
|
9637
9696
|
}
|
|
9638
9697
|
async function getWethL2() {
|
|
9639
9698
|
if (!wethL2Promise) {
|
|
9640
|
-
wethL2Promise =
|
|
9699
|
+
wethL2Promise = wrapAs7("INTERNAL", "wethL2", async () => {
|
|
9641
9700
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9642
9701
|
const weth = await l2NativeTokenVault.WETH_TOKEN();
|
|
9643
9702
|
return weth;
|
|
@@ -9646,7 +9705,7 @@ function createTokensResource(client) {
|
|
|
9646
9705
|
return wethL2Promise;
|
|
9647
9706
|
}
|
|
9648
9707
|
async function toL2Address(l1Token) {
|
|
9649
|
-
return
|
|
9708
|
+
return wrapAs7("CONTRACT", "tokens.toL2Address", async () => {
|
|
9650
9709
|
const normalized = normalizeL1Token(l1Token);
|
|
9651
9710
|
const { chainId } = await client.l2.getNetwork();
|
|
9652
9711
|
const baseToken = await client.baseToken(BigInt(chainId));
|
|
@@ -9659,7 +9718,7 @@ function createTokensResource(client) {
|
|
|
9659
9718
|
});
|
|
9660
9719
|
}
|
|
9661
9720
|
async function toL1Address(l2Token) {
|
|
9662
|
-
return
|
|
9721
|
+
return wrapAs7("CONTRACT", "tokens.toL1Address", async () => {
|
|
9663
9722
|
if (isAddressEq(l2Token, ETH_ADDRESS)) {
|
|
9664
9723
|
return ETH_ADDRESS;
|
|
9665
9724
|
}
|
|
@@ -9682,7 +9741,7 @@ function createTokensResource(client) {
|
|
|
9682
9741
|
});
|
|
9683
9742
|
}
|
|
9684
9743
|
async function assetIdOfL1(l1Token) {
|
|
9685
|
-
return
|
|
9744
|
+
return wrapAs7("CONTRACT", "tokens.assetIdOfL1", async () => {
|
|
9686
9745
|
const normalized = normalizeL1Token(l1Token);
|
|
9687
9746
|
const { l1NativeTokenVault } = await client.contracts();
|
|
9688
9747
|
const assetId = await l1NativeTokenVault.assetId(normalized);
|
|
@@ -9690,28 +9749,28 @@ function createTokensResource(client) {
|
|
|
9690
9749
|
});
|
|
9691
9750
|
}
|
|
9692
9751
|
async function assetIdOfL2(l2Token) {
|
|
9693
|
-
return
|
|
9752
|
+
return wrapAs7("CONTRACT", "tokens.assetIdOfL2", async () => {
|
|
9694
9753
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9695
9754
|
const assetId = await l2NativeTokenVault.assetId(l2Token);
|
|
9696
9755
|
return assetId;
|
|
9697
9756
|
});
|
|
9698
9757
|
}
|
|
9699
9758
|
async function l2TokenFromAssetId(assetId) {
|
|
9700
|
-
return
|
|
9759
|
+
return wrapAs7("CONTRACT", "tokens.l2TokenFromAssetId", async () => {
|
|
9701
9760
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9702
9761
|
const tokenAddr = await l2NativeTokenVault.tokenAddress(assetId);
|
|
9703
9762
|
return tokenAddr;
|
|
9704
9763
|
});
|
|
9705
9764
|
}
|
|
9706
9765
|
async function l1TokenFromAssetId(assetId) {
|
|
9707
|
-
return
|
|
9766
|
+
return wrapAs7("CONTRACT", "tokens.l1TokenFromAssetId", async () => {
|
|
9708
9767
|
const { l1NativeTokenVault } = await client.contracts();
|
|
9709
9768
|
const tokenAddr = await l1NativeTokenVault.tokenAddress(assetId);
|
|
9710
9769
|
return tokenAddr;
|
|
9711
9770
|
});
|
|
9712
9771
|
}
|
|
9713
9772
|
async function originChainId(assetId) {
|
|
9714
|
-
return
|
|
9773
|
+
return wrapAs7("CONTRACT", "tokens.originChainId", async () => {
|
|
9715
9774
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9716
9775
|
const chainId = await l2NativeTokenVault.originChainId(assetId);
|
|
9717
9776
|
return chainId;
|
|
@@ -9721,7 +9780,7 @@ function createTokensResource(client) {
|
|
|
9721
9780
|
return getBaseTokenAssetId();
|
|
9722
9781
|
}
|
|
9723
9782
|
async function isChainEthBased() {
|
|
9724
|
-
return
|
|
9783
|
+
return wrapAs7("CONTRACT", "tokens.isChainEthBased", async () => {
|
|
9725
9784
|
const baseAssetId = await getBaseTokenAssetId();
|
|
9726
9785
|
const l1ChainId = await getL1ChainId();
|
|
9727
9786
|
const ethAssetId = ntvCodec3.encodeAssetId(
|
|
@@ -9739,7 +9798,7 @@ function createTokensResource(client) {
|
|
|
9739
9798
|
return getWethL2();
|
|
9740
9799
|
}
|
|
9741
9800
|
async function computeL2BridgedAddress(args) {
|
|
9742
|
-
return
|
|
9801
|
+
return wrapAs7("CONTRACT", "tokens.computeL2BridgedAddress", async () => {
|
|
9743
9802
|
const normalized = normalizeL1Token(args.l1Token);
|
|
9744
9803
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9745
9804
|
const predicted = await l2NativeTokenVault.calculateCreate2TokenAddress(
|
|
@@ -9750,7 +9809,7 @@ function createTokensResource(client) {
|
|
|
9750
9809
|
});
|
|
9751
9810
|
}
|
|
9752
9811
|
async function resolve(ref, opts) {
|
|
9753
|
-
return
|
|
9812
|
+
return wrapAs7("CONTRACT", "tokens.resolve", async () => {
|
|
9754
9813
|
let chain;
|
|
9755
9814
|
let address;
|
|
9756
9815
|
if (typeof ref === "string") {
|
|
@@ -10317,13 +10376,13 @@ function buildFeeBreakdown2(p) {
|
|
|
10317
10376
|
}
|
|
10318
10377
|
|
|
10319
10378
|
// src/adapters/ethers/resources/withdrawals/routes/eth.ts
|
|
10320
|
-
var { wrapAs:
|
|
10379
|
+
var { wrapAs: wrapAs8 } = createErrorHandlers("withdrawals");
|
|
10321
10380
|
function routeEthBase() {
|
|
10322
10381
|
return {
|
|
10323
10382
|
async build(p, ctx) {
|
|
10324
10383
|
const steps = [];
|
|
10325
10384
|
const base = await ctx.contracts.l2BaseTokenSystem();
|
|
10326
|
-
const data = await
|
|
10385
|
+
const data = await wrapAs8(
|
|
10327
10386
|
"INTERNAL",
|
|
10328
10387
|
OP_WITHDRAWALS.eth.encodeWithdraw,
|
|
10329
10388
|
() => Promise.resolve(base.interface.encodeFunctionData("withdraw", [p.to ?? ctx.sender])),
|
|
@@ -10358,7 +10417,7 @@ function routeEthBase() {
|
|
|
10358
10417
|
}
|
|
10359
10418
|
};
|
|
10360
10419
|
}
|
|
10361
|
-
var { wrapAs:
|
|
10420
|
+
var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
|
|
10362
10421
|
var SIG = {
|
|
10363
10422
|
withdraw: "withdraw(bytes32,bytes)"
|
|
10364
10423
|
};
|
|
@@ -10368,7 +10427,7 @@ function routeErc20NonBase2() {
|
|
|
10368
10427
|
const steps = [];
|
|
10369
10428
|
const approvals = [];
|
|
10370
10429
|
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
10371
|
-
const current = await
|
|
10430
|
+
const current = await wrapAs9(
|
|
10372
10431
|
"CONTRACT",
|
|
10373
10432
|
OP_WITHDRAWALS.erc20.allowance,
|
|
10374
10433
|
() => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
|
|
@@ -10406,7 +10465,7 @@ function routeErc20NonBase2() {
|
|
|
10406
10465
|
tx: approveTx
|
|
10407
10466
|
});
|
|
10408
10467
|
}
|
|
10409
|
-
const assetId = await
|
|
10468
|
+
const assetId = await wrapAs9(
|
|
10410
10469
|
"CONTRACT",
|
|
10411
10470
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
10412
10471
|
async () => {
|
|
@@ -10419,7 +10478,7 @@ function routeErc20NonBase2() {
|
|
|
10419
10478
|
message: "Failed to ensure token is registered in L2NativeTokenVault."
|
|
10420
10479
|
}
|
|
10421
10480
|
);
|
|
10422
|
-
const assetData = await
|
|
10481
|
+
const assetData = await wrapAs9(
|
|
10423
10482
|
"INTERNAL",
|
|
10424
10483
|
OP_WITHDRAWALS.erc20.encodeAssetData,
|
|
10425
10484
|
() => Promise.resolve(
|
|
@@ -10431,7 +10490,7 @@ function routeErc20NonBase2() {
|
|
|
10431
10490
|
}
|
|
10432
10491
|
);
|
|
10433
10492
|
const l2ar = await ctx.contracts.l2AssetRouter();
|
|
10434
|
-
const dataWithdraw = await
|
|
10493
|
+
const dataWithdraw = await wrapAs9(
|
|
10435
10494
|
"INTERNAL",
|
|
10436
10495
|
OP_WITHDRAWALS.erc20.encodeWithdraw,
|
|
10437
10496
|
() => Promise.resolve(l2ar.interface.encodeFunctionData(SIG.withdraw, [assetId, assetData])),
|
|
@@ -10588,7 +10647,7 @@ function buildWithdrawalBundle(input) {
|
|
|
10588
10647
|
}
|
|
10589
10648
|
|
|
10590
10649
|
// src/adapters/ethers/resources/withdrawals/routes/interop-bundle.ts
|
|
10591
|
-
var { wrapAs:
|
|
10650
|
+
var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
|
|
10592
10651
|
var attributes = createEthersAttributesResource();
|
|
10593
10652
|
function saltFor(sender, nonce) {
|
|
10594
10653
|
return ethers.keccak256(
|
|
@@ -10607,7 +10666,7 @@ function routeInteropBundle() {
|
|
|
10607
10666
|
if (isBaseToken) {
|
|
10608
10667
|
assetId = ctx.baseTokenAssetId;
|
|
10609
10668
|
} else {
|
|
10610
|
-
assetId = await
|
|
10669
|
+
assetId = await wrapAs10(
|
|
10611
10670
|
"CONTRACT",
|
|
10612
10671
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
10613
10672
|
async () => {
|
|
@@ -10620,7 +10679,7 @@ function routeInteropBundle() {
|
|
|
10620
10679
|
}
|
|
10621
10680
|
);
|
|
10622
10681
|
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
10623
|
-
const current = await
|
|
10682
|
+
const current = await wrapAs10(
|
|
10624
10683
|
"CONTRACT",
|
|
10625
10684
|
OP_WITHDRAWALS.erc20.allowance,
|
|
10626
10685
|
() => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
|
|
@@ -10656,7 +10715,7 @@ function routeInteropBundle() {
|
|
|
10656
10715
|
});
|
|
10657
10716
|
}
|
|
10658
10717
|
}
|
|
10659
|
-
const nonce = await
|
|
10718
|
+
const nonce = await wrapAs10(
|
|
10660
10719
|
"RPC",
|
|
10661
10720
|
OP_WITHDRAWALS.prepare,
|
|
10662
10721
|
() => ctx.client.l2.getTransactionCount(ctx.sender, "pending"),
|
|
@@ -10686,7 +10745,7 @@ function routeInteropBundle() {
|
|
|
10686
10745
|
}
|
|
10687
10746
|
});
|
|
10688
10747
|
const interopCenter = await ctx.contracts.interopCenter();
|
|
10689
|
-
const data = await
|
|
10748
|
+
const data = await wrapAs10(
|
|
10690
10749
|
"INTERNAL",
|
|
10691
10750
|
OP_WITHDRAWALS.erc20.encodeWithdraw,
|
|
10692
10751
|
() => Promise.resolve(
|
|
@@ -10901,7 +10960,7 @@ function createWithdrawalProtocolService(client, override) {
|
|
|
10901
10960
|
}
|
|
10902
10961
|
|
|
10903
10962
|
// src/adapters/ethers/resources/withdrawals/services/finalization.ts
|
|
10904
|
-
var { wrapAs:
|
|
10963
|
+
var { wrapAs: wrapAs11 } = createErrorHandlers("withdrawals");
|
|
10905
10964
|
var IL1NullifierMini = [
|
|
10906
10965
|
"function isWithdrawalFinalized(uint256,uint256,uint256) view returns (bool)"
|
|
10907
10966
|
];
|
|
@@ -10911,7 +10970,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10911
10970
|
const { l1Nullifier } = await client.ensureAddresses();
|
|
10912
10971
|
if (protocol === "legacy-withdrawal") return l1Nullifier;
|
|
10913
10972
|
const nullifier = new ethers.Contract(l1Nullifier, IL1NullifierV32_default, l1);
|
|
10914
|
-
const handler = await
|
|
10973
|
+
const handler = await wrapAs11(
|
|
10915
10974
|
"CONTRACT",
|
|
10916
10975
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
10917
10976
|
() => nullifier.l1InteropHandler(),
|
|
@@ -10923,7 +10982,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10923
10982
|
return handler;
|
|
10924
10983
|
}
|
|
10925
10984
|
async function fetchMessageAndProof(l2TxHash) {
|
|
10926
|
-
const raw = await
|
|
10985
|
+
const raw = await wrapAs11(
|
|
10927
10986
|
"RPC",
|
|
10928
10987
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
10929
10988
|
() => client.zks.getReceiptWithL2ToL1(l2TxHash),
|
|
@@ -10940,7 +10999,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10940
10999
|
context: { l2TxHash }
|
|
10941
11000
|
});
|
|
10942
11001
|
}
|
|
10943
|
-
const ev = await
|
|
11002
|
+
const ev = await wrapAs11(
|
|
10944
11003
|
"INTERNAL",
|
|
10945
11004
|
OP_WITHDRAWALS.finalize.fetchParams.findMessage,
|
|
10946
11005
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
@@ -10950,7 +11009,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10950
11009
|
message: "Failed to locate L1MessageSent event in L2 receipt."
|
|
10951
11010
|
}
|
|
10952
11011
|
);
|
|
10953
|
-
const message = await
|
|
11012
|
+
const message = await wrapAs11(
|
|
10954
11013
|
"INTERNAL",
|
|
10955
11014
|
OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
|
|
10956
11015
|
() => Promise.resolve(ethers.AbiCoder.defaultAbiCoder().decode(["bytes"], ev.data)[0]),
|
|
@@ -10959,7 +11018,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10959
11018
|
message: "Failed to decode withdrawal message."
|
|
10960
11019
|
}
|
|
10961
11020
|
);
|
|
10962
|
-
const idx = await
|
|
11021
|
+
const idx = await wrapAs11(
|
|
10963
11022
|
"INTERNAL",
|
|
10964
11023
|
OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
|
|
10965
11024
|
() => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
|
|
@@ -10968,7 +11027,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10968
11027
|
message: "Failed to derive messenger log index."
|
|
10969
11028
|
}
|
|
10970
11029
|
);
|
|
10971
|
-
const proof = await
|
|
11030
|
+
const proof = await wrapAs11(
|
|
10972
11031
|
"RPC",
|
|
10973
11032
|
OP_WITHDRAWALS.finalize.fetchParams.proof,
|
|
10974
11033
|
() => client.zks.getL2ToL1LogProof(l2TxHash, idx),
|
|
@@ -10977,7 +11036,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10977
11036
|
message: "Failed to fetch L2\u2192L1 log proof."
|
|
10978
11037
|
}
|
|
10979
11038
|
);
|
|
10980
|
-
const { chainId } = await
|
|
11039
|
+
const { chainId } = await wrapAs11(
|
|
10981
11040
|
"RPC",
|
|
10982
11041
|
OP_WITHDRAWALS.finalize.fetchParams.network,
|
|
10983
11042
|
() => l2.getNetwork(),
|
|
@@ -11036,7 +11095,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11036
11095
|
const target = await finalizationTarget(finalization.protocol);
|
|
11037
11096
|
if (finalization.protocol === "legacy-withdrawal") {
|
|
11038
11097
|
const c = new ethers.Contract(target, IL1NullifierMini, l1);
|
|
11039
|
-
const done = await
|
|
11098
|
+
const done = await wrapAs11(
|
|
11040
11099
|
"RPC",
|
|
11041
11100
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
11042
11101
|
() => c.isWithdrawalFinalized(
|
|
@@ -11054,7 +11113,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11054
11113
|
const { bundleHash } = finalization.params;
|
|
11055
11114
|
const handler = new ethers.Contract(target, IInteropHandler_default, l1);
|
|
11056
11115
|
const status = Number(
|
|
11057
|
-
await
|
|
11116
|
+
await wrapAs11(
|
|
11058
11117
|
"RPC",
|
|
11059
11118
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
11060
11119
|
() => handler.bundleStatus(bundleHash),
|
|
@@ -11066,7 +11125,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11066
11125
|
);
|
|
11067
11126
|
if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
|
|
11068
11127
|
const callStatus = Number(
|
|
11069
|
-
await
|
|
11128
|
+
await wrapAs11(
|
|
11070
11129
|
"RPC",
|
|
11071
11130
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
11072
11131
|
() => handler.callStatus(bundleHash, 0),
|
|
@@ -11126,7 +11185,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11126
11185
|
async estimateFinalization(finalization) {
|
|
11127
11186
|
const target = await finalizationTarget(finalization.protocol);
|
|
11128
11187
|
const l1Signer = client.getL1Signer();
|
|
11129
|
-
const gasLimit = await
|
|
11188
|
+
const gasLimit = await wrapAs11(
|
|
11130
11189
|
"RPC",
|
|
11131
11190
|
OP_WITHDRAWALS.finalize.estimate,
|
|
11132
11191
|
() => {
|
|
@@ -11145,7 +11204,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11145
11204
|
message: "Failed to estimate gas for withdrawal finalization."
|
|
11146
11205
|
}
|
|
11147
11206
|
);
|
|
11148
|
-
const feeData = await
|
|
11207
|
+
const feeData = await wrapAs11("RPC", OP_WITHDRAWALS.finalize.estimate, () => l1.getFeeData(), {
|
|
11149
11208
|
ctx: { where: "l1.getFeeData" },
|
|
11150
11209
|
message: "Failed to estimate fee data for withdrawal finalization."
|
|
11151
11210
|
});
|