@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
|
@@ -6231,6 +6231,7 @@ function isEraVmChain(chainIdL2) {
|
|
|
6231
6231
|
|
|
6232
6232
|
// src/core/resources/deposits/gas.ts
|
|
6233
6233
|
var CREATE_REESTIMATE_BUFFER = 15n;
|
|
6234
|
+
var ZERO_FEES = { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
|
|
6234
6235
|
var maxBigInt = (a, b) => a > b ? a : b;
|
|
6235
6236
|
function applyGasBuffer(gasLimit, bufferPct = BUFFER) {
|
|
6236
6237
|
return gasLimit * (100n + bufferPct) / 100n;
|
|
@@ -6281,15 +6282,39 @@ async function fetchFees(estimator) {
|
|
|
6281
6282
|
const gp = await estimator.getGasPrice();
|
|
6282
6283
|
return { maxFeePerGas: gp, maxPriorityFeePerGas: 0n };
|
|
6283
6284
|
} catch {
|
|
6284
|
-
return
|
|
6285
|
+
return void 0;
|
|
6286
|
+
}
|
|
6287
|
+
}
|
|
6288
|
+
async function quoteL1Fees(input) {
|
|
6289
|
+
const { estimator, overrides } = input;
|
|
6290
|
+
const maxFeeOverride = overrides?.maxFeePerGas;
|
|
6291
|
+
const tipOverride = overrides?.maxPriorityFeePerGas;
|
|
6292
|
+
if (maxFeeOverride != null && tipOverride != null) {
|
|
6293
|
+
return { maxFeePerGas: maxFeeOverride, maxPriorityFeePerGas: tipOverride };
|
|
6294
|
+
}
|
|
6295
|
+
const market = await fetchFees(estimator);
|
|
6296
|
+
if (maxFeeOverride != null) {
|
|
6297
|
+
const tip = market?.maxPriorityFeePerGas ?? 0n;
|
|
6298
|
+
return {
|
|
6299
|
+
maxFeePerGas: maxFeeOverride,
|
|
6300
|
+
maxPriorityFeePerGas: tip < maxFeeOverride ? tip : maxFeeOverride
|
|
6301
|
+
};
|
|
6302
|
+
}
|
|
6303
|
+
if (market == null) {
|
|
6304
|
+
throw new Error("Could not fetch L1 gas price for Bridgehub base cost calculation.");
|
|
6305
|
+
}
|
|
6306
|
+
if (tipOverride != null) {
|
|
6307
|
+
const headroom = market.maxFeePerGas > market.maxPriorityFeePerGas ? market.maxFeePerGas - market.maxPriorityFeePerGas : 0n;
|
|
6308
|
+
return { maxFeePerGas: headroom + tipOverride, maxPriorityFeePerGas: tipOverride };
|
|
6285
6309
|
}
|
|
6310
|
+
return market;
|
|
6286
6311
|
}
|
|
6287
6312
|
async function quoteL1Gas(input) {
|
|
6288
6313
|
const { estimator, tx, overrides, fallbackGasLimit } = input;
|
|
6289
6314
|
let market;
|
|
6290
6315
|
const getMarket = async () => {
|
|
6291
6316
|
if (market) return market;
|
|
6292
|
-
market = await fetchFees(estimator);
|
|
6317
|
+
market = await fetchFees(estimator) ?? ZERO_FEES;
|
|
6293
6318
|
return market;
|
|
6294
6319
|
};
|
|
6295
6320
|
const maxFeePerGas = overrides?.maxFeePerGas ?? (tx.maxFeePerGas != null ? BigInt(tx.maxFeePerGas) : (await getMarket()).maxFeePerGas);
|
|
@@ -6311,7 +6336,7 @@ async function quoteL1Gas(input) {
|
|
|
6311
6336
|
}
|
|
6312
6337
|
async function quoteL2Gas(input) {
|
|
6313
6338
|
const { estimator, route, tx, gasPerPubdata, l2GasLimit, overrideGasLimit, stateOverrides } = input;
|
|
6314
|
-
const market = await fetchFees(estimator);
|
|
6339
|
+
const market = await fetchFees(estimator) ?? ZERO_FEES;
|
|
6315
6340
|
const maxFeePerGas = market.maxFeePerGas || market.maxPriorityFeePerGas || 0n;
|
|
6316
6341
|
const txGasLimit = tx?.gasLimit != null ? BigInt(tx.gasLimit) : void 0;
|
|
6317
6342
|
const explicit = overrideGasLimit ?? txGasLimit;
|
|
@@ -6352,12 +6377,7 @@ async function quoteL2Gas(input) {
|
|
|
6352
6377
|
}
|
|
6353
6378
|
}
|
|
6354
6379
|
async function quoteL2BaseCost(input) {
|
|
6355
|
-
const { estimator, encode: encode2, bridgehub, chainIdL2, l2GasLimit, gasPerPubdata } = input;
|
|
6356
|
-
const market = await fetchFees(estimator);
|
|
6357
|
-
const l1GasPrice = market.maxFeePerGas || market.maxPriorityFeePerGas || 0n;
|
|
6358
|
-
if (l1GasPrice === 0n) {
|
|
6359
|
-
throw new Error("Could not fetch L1 gas price for Bridgehub base cost calculation.");
|
|
6360
|
-
}
|
|
6380
|
+
const { estimator, encode: encode2, bridgehub, chainIdL2, l2GasLimit, gasPerPubdata, l1GasPrice } = input;
|
|
6361
6381
|
const data = encode2(IBridgehub_default, "l2TransactionBaseCost", [
|
|
6362
6382
|
chainIdL2,
|
|
6363
6383
|
l1GasPrice,
|
|
@@ -6379,8 +6399,9 @@ function toCoreTx(tx) {
|
|
|
6379
6399
|
data: tx.data,
|
|
6380
6400
|
value: tx.value ? BigInt(tx.value) : void 0,
|
|
6381
6401
|
gasLimit: tx.gasLimit ? BigInt(tx.gasLimit) : void 0,
|
|
6382
|
-
|
|
6383
|
-
|
|
6402
|
+
// zero fees are explicit on zero-base-fee chains; dropping them would re-fetch the market tip
|
|
6403
|
+
maxFeePerGas: tx.maxFeePerGas != null ? BigInt(tx.maxFeePerGas) : void 0,
|
|
6404
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas != null ? BigInt(tx.maxPriorityFeePerGas) : void 0
|
|
6384
6405
|
};
|
|
6385
6406
|
}
|
|
6386
6407
|
function ethersToGasEstimator(provider) {
|
|
@@ -6473,7 +6494,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
6473
6494
|
function wrap7(operation, fn, opts) {
|
|
6474
6495
|
return run("INTERNAL", operation, fn, opts);
|
|
6475
6496
|
}
|
|
6476
|
-
function
|
|
6497
|
+
function wrapAs11(kind, operation, fn, opts) {
|
|
6477
6498
|
return run(kind, operation, fn, opts);
|
|
6478
6499
|
}
|
|
6479
6500
|
async function toResult3(operation, fn, opts) {
|
|
@@ -6494,7 +6515,7 @@ function createErrorOps(decodeRevert2) {
|
|
|
6494
6515
|
return { ok: false, error: shaped };
|
|
6495
6516
|
}
|
|
6496
6517
|
}
|
|
6497
|
-
return { wrap: wrap7, wrapAs:
|
|
6518
|
+
return { wrap: wrap7, wrapAs: wrapAs11, toResult: toResult3 };
|
|
6498
6519
|
}
|
|
6499
6520
|
return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
|
|
6500
6521
|
}
|
|
@@ -6638,7 +6659,7 @@ var encode = (abi2, fn, args) => {
|
|
|
6638
6659
|
return new ethers.Interface(abi2).encodeFunctionData(fn, args);
|
|
6639
6660
|
};
|
|
6640
6661
|
async function quoteL2BaseCost2(input) {
|
|
6641
|
-
const { ctx, l2GasLimit } = input;
|
|
6662
|
+
const { ctx, l2GasLimit, l1GasPrice } = input;
|
|
6642
6663
|
const estimator = ethersToGasEstimator(ctx.client.l1);
|
|
6643
6664
|
return wrapAs(
|
|
6644
6665
|
"RPC",
|
|
@@ -6649,7 +6670,8 @@ async function quoteL2BaseCost2(input) {
|
|
|
6649
6670
|
bridgehub: ctx.bridgehub,
|
|
6650
6671
|
chainIdL2: ctx.chainIdL2,
|
|
6651
6672
|
l2GasLimit,
|
|
6652
|
-
gasPerPubdata: ctx.gasPerPubdata
|
|
6673
|
+
gasPerPubdata: ctx.gasPerPubdata,
|
|
6674
|
+
l1GasPrice
|
|
6653
6675
|
}),
|
|
6654
6676
|
{ ctx: { chainIdL2: ctx.chainIdL2 } }
|
|
6655
6677
|
);
|
|
@@ -6718,6 +6740,7 @@ function resolveRegisteredTokenPriorityL2GasLimit(input) {
|
|
|
6718
6740
|
}
|
|
6719
6741
|
|
|
6720
6742
|
// src/adapters/ethers/resources/deposits/services/gas.ts
|
|
6743
|
+
var { wrapAs: wrapAs2 } = createErrorHandlers("deposits");
|
|
6721
6744
|
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
6722
6745
|
var ZERO_L2_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
6723
6746
|
async function estimatePriorityTxL2Gas(ctx, leg) {
|
|
@@ -6728,6 +6751,18 @@ async function estimatePriorityTxL2Gas(ctx, leg) {
|
|
|
6728
6751
|
return void 0;
|
|
6729
6752
|
}
|
|
6730
6753
|
}
|
|
6754
|
+
async function quoteL1Fees2(input) {
|
|
6755
|
+
const { ctx } = input;
|
|
6756
|
+
return wrapAs2(
|
|
6757
|
+
"RPC",
|
|
6758
|
+
"deposits.fees.l1",
|
|
6759
|
+
() => quoteL1Fees({
|
|
6760
|
+
estimator: ethersToGasEstimator(ctx.client.l1),
|
|
6761
|
+
overrides: ctx.gasOverrides
|
|
6762
|
+
}),
|
|
6763
|
+
{ ctx: { chainIdL2: ctx.chainIdL2 } }
|
|
6764
|
+
);
|
|
6765
|
+
}
|
|
6731
6766
|
async function quoteL1Gas2(input) {
|
|
6732
6767
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
6733
6768
|
const estimator = ethersToGasEstimator(ctx.client.l1);
|
|
@@ -6927,7 +6962,12 @@ function routeEthDirect() {
|
|
|
6927
6962
|
if (!l2GasParams) {
|
|
6928
6963
|
throw new Error("Failed to estimate L2 gas for deposit.");
|
|
6929
6964
|
}
|
|
6930
|
-
const
|
|
6965
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
6966
|
+
const baseCost = await quoteL2BaseCost2({
|
|
6967
|
+
ctx,
|
|
6968
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
6969
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
6970
|
+
});
|
|
6931
6971
|
const mintValue = baseCost + ctx.operatorTip + l2Value;
|
|
6932
6972
|
const req = buildDirectRequestStruct({
|
|
6933
6973
|
chainId: ctx.chainIdL2,
|
|
@@ -6944,7 +6984,8 @@ function routeEthDirect() {
|
|
|
6944
6984
|
data,
|
|
6945
6985
|
value: mintValue,
|
|
6946
6986
|
from: ctx.sender,
|
|
6947
|
-
...ctx.gasOverrides
|
|
6987
|
+
...ctx.gasOverrides,
|
|
6988
|
+
...l1Fees
|
|
6948
6989
|
};
|
|
6949
6990
|
const l1GasParams = await quoteL1Gas2({
|
|
6950
6991
|
ctx,
|
|
@@ -6999,7 +7040,7 @@ function createNTVCodec(deps) {
|
|
|
6999
7040
|
}
|
|
7000
7041
|
|
|
7001
7042
|
// src/adapters/ethers/resources/deposits/routes/erc20-nonbase.ts
|
|
7002
|
-
var { wrapAs:
|
|
7043
|
+
var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
|
|
7003
7044
|
var ZERO_L2_TOKEN_ADDRESS2 = "0x0000000000000000000000000000000000000000";
|
|
7004
7045
|
var ZERO_ASSET_ID = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
7005
7046
|
var ntvCodec = createNTVCodec({
|
|
@@ -7082,7 +7123,7 @@ function routeErc20NonBase() {
|
|
|
7082
7123
|
async preflight(p, ctx) {
|
|
7083
7124
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
7084
7125
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
7085
|
-
await
|
|
7126
|
+
await wrapAs3(
|
|
7086
7127
|
"VALIDATION",
|
|
7087
7128
|
OP_DEPOSITS.nonbase.assertNonBaseToken,
|
|
7088
7129
|
() => {
|
|
@@ -7098,7 +7139,7 @@ function routeErc20NonBase() {
|
|
|
7098
7139
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
7099
7140
|
const baseIsEth = ctx.baseIsEth ?? isETH(baseToken);
|
|
7100
7141
|
const receiver = p.to ?? ctx.sender;
|
|
7101
|
-
const secondBridgeCalldata = await
|
|
7142
|
+
const secondBridgeCalldata = await wrapAs3(
|
|
7102
7143
|
"INTERNAL",
|
|
7103
7144
|
OP_DEPOSITS.nonbase.encodeCalldata,
|
|
7104
7145
|
() => encodeSecondBridgeErc20DepositCalldata({
|
|
@@ -7132,14 +7173,19 @@ function routeErc20NonBase() {
|
|
|
7132
7173
|
}
|
|
7133
7174
|
});
|
|
7134
7175
|
if (!l2GasParams) throw new Error("Failed to establish L2 gas parameters.");
|
|
7135
|
-
const
|
|
7176
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
7177
|
+
const baseCost = await quoteL2BaseCost2({
|
|
7178
|
+
ctx,
|
|
7179
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
7180
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
7181
|
+
});
|
|
7136
7182
|
const mintValue = baseCost + ctx.operatorTip;
|
|
7137
7183
|
const approvals = [];
|
|
7138
7184
|
const steps = [];
|
|
7139
7185
|
const assetRouter = ctx.l1AssetRouter;
|
|
7140
7186
|
const nativeTokenVault = ctx.l1NativeTokenVault;
|
|
7141
7187
|
const erc20Deposit = new ethers.Contract(p.token, IERC20_default, l1Signer);
|
|
7142
|
-
const allowanceToken = await
|
|
7188
|
+
const allowanceToken = await wrapAs3(
|
|
7143
7189
|
"RPC",
|
|
7144
7190
|
OP_DEPOSITS.nonbase.allowanceToken,
|
|
7145
7191
|
() => erc20Deposit.allowance(ctx.sender, nativeTokenVault),
|
|
@@ -7167,7 +7213,7 @@ function routeErc20NonBase() {
|
|
|
7167
7213
|
}
|
|
7168
7214
|
if (!baseIsEth) {
|
|
7169
7215
|
const erc20Base = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
7170
|
-
const allowanceBase = await
|
|
7216
|
+
const allowanceBase = await wrapAs3(
|
|
7171
7217
|
"RPC",
|
|
7172
7218
|
OP_DEPOSITS.nonbase.allowanceBase,
|
|
7173
7219
|
() => erc20Base.allowance(ctx.sender, nativeTokenVault),
|
|
@@ -7215,7 +7261,8 @@ function routeErc20NonBase() {
|
|
|
7215
7261
|
data,
|
|
7216
7262
|
value: txValue,
|
|
7217
7263
|
from: ctx.sender,
|
|
7218
|
-
...ctx.gasOverrides
|
|
7264
|
+
...ctx.gasOverrides,
|
|
7265
|
+
...l1Fees
|
|
7219
7266
|
};
|
|
7220
7267
|
const l1GasParams = await quoteL1Gas2({
|
|
7221
7268
|
ctx,
|
|
@@ -7250,7 +7297,7 @@ function routeErc20NonBase() {
|
|
|
7250
7297
|
}
|
|
7251
7298
|
};
|
|
7252
7299
|
}
|
|
7253
|
-
var { wrapAs:
|
|
7300
|
+
var { wrapAs: wrapAs4 } = createErrorHandlers("deposits");
|
|
7254
7301
|
var ZERO_L2_TOKEN_ADDRESS3 = "0x0000000000000000000000000000000000000000";
|
|
7255
7302
|
var ZERO_ASSET_ID2 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
7256
7303
|
var ntvCodec2 = createNTVCodec({
|
|
@@ -7326,7 +7373,7 @@ function routeEthNonBase() {
|
|
|
7326
7373
|
return {
|
|
7327
7374
|
async preflight(p, ctx) {
|
|
7328
7375
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
7329
|
-
await
|
|
7376
|
+
await wrapAs4(
|
|
7330
7377
|
"VALIDATION",
|
|
7331
7378
|
OP_DEPOSITS.ethNonBase.assertEthAsset,
|
|
7332
7379
|
() => {
|
|
@@ -7336,7 +7383,7 @@ function routeEthNonBase() {
|
|
|
7336
7383
|
},
|
|
7337
7384
|
{ ctx: { token: p.token } }
|
|
7338
7385
|
);
|
|
7339
|
-
await
|
|
7386
|
+
await wrapAs4(
|
|
7340
7387
|
"VALIDATION",
|
|
7341
7388
|
OP_DEPOSITS.ethNonBase.assertNonEthBase,
|
|
7342
7389
|
() => {
|
|
@@ -7346,7 +7393,7 @@ function routeEthNonBase() {
|
|
|
7346
7393
|
},
|
|
7347
7394
|
{ ctx: { baseIsEth: ctx.baseIsEth, chainIdL2: ctx.chainIdL2 } }
|
|
7348
7395
|
);
|
|
7349
|
-
const ethBal = await
|
|
7396
|
+
const ethBal = await wrapAs4(
|
|
7350
7397
|
"RPC",
|
|
7351
7398
|
OP_DEPOSITS.ethNonBase.ethBalance,
|
|
7352
7399
|
() => ctx.client.l1.getBalance(ctx.sender),
|
|
@@ -7355,7 +7402,7 @@ function routeEthNonBase() {
|
|
|
7355
7402
|
message: "Failed to read L1 ETH balance."
|
|
7356
7403
|
}
|
|
7357
7404
|
);
|
|
7358
|
-
await
|
|
7405
|
+
await wrapAs4(
|
|
7359
7406
|
"VALIDATION",
|
|
7360
7407
|
OP_DEPOSITS.ethNonBase.assertEthBalance,
|
|
7361
7408
|
() => {
|
|
@@ -7390,12 +7437,17 @@ function routeEthNonBase() {
|
|
|
7390
7437
|
undeployedGasLimit: priorityGasModel.undeployedGasLimit
|
|
7391
7438
|
});
|
|
7392
7439
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
7393
|
-
const
|
|
7440
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
7441
|
+
const baseCost = await quoteL2BaseCost2({
|
|
7442
|
+
ctx,
|
|
7443
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
7444
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
7445
|
+
});
|
|
7394
7446
|
const mintValue = baseCost + ctx.operatorTip;
|
|
7395
7447
|
const approvals = [];
|
|
7396
7448
|
const steps = [];
|
|
7397
7449
|
const erc20Base = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
7398
|
-
const allowance = await
|
|
7450
|
+
const allowance = await wrapAs4(
|
|
7399
7451
|
"RPC",
|
|
7400
7452
|
OP_DEPOSITS.ethNonBase.allowanceBase,
|
|
7401
7453
|
() => erc20Base.allowance(ctx.sender, ctx.l1NativeTokenVault),
|
|
@@ -7421,7 +7473,7 @@ function routeEthNonBase() {
|
|
|
7421
7473
|
}
|
|
7422
7474
|
});
|
|
7423
7475
|
}
|
|
7424
|
-
const secondBridgeCalldata = await
|
|
7476
|
+
const secondBridgeCalldata = await wrapAs4(
|
|
7425
7477
|
"INTERNAL",
|
|
7426
7478
|
OP_DEPOSITS.ethNonBase.encodeCalldata,
|
|
7427
7479
|
() => encodeSecondBridgeEthDepositCalldata({ ctx, amount: p.amount, receiver }),
|
|
@@ -7454,7 +7506,8 @@ function routeEthNonBase() {
|
|
|
7454
7506
|
data,
|
|
7455
7507
|
value: bridgehubValue,
|
|
7456
7508
|
from: ctx.sender,
|
|
7457
|
-
...ctx.gasOverrides
|
|
7509
|
+
...ctx.gasOverrides,
|
|
7510
|
+
...l1Fees
|
|
7458
7511
|
};
|
|
7459
7512
|
const l1GasParams = await quoteL1Gas2({
|
|
7460
7513
|
ctx,
|
|
@@ -7489,13 +7542,13 @@ function routeEthNonBase() {
|
|
|
7489
7542
|
}
|
|
7490
7543
|
};
|
|
7491
7544
|
}
|
|
7492
|
-
var { wrapAs:
|
|
7545
|
+
var { wrapAs: wrapAs5 } = createErrorHandlers("deposits");
|
|
7493
7546
|
var EMPTY_BYTES3 = "0x";
|
|
7494
7547
|
function routeErc20Base() {
|
|
7495
7548
|
return {
|
|
7496
7549
|
async preflight(p, ctx) {
|
|
7497
7550
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
7498
|
-
await
|
|
7551
|
+
await wrapAs5(
|
|
7499
7552
|
"VALIDATION",
|
|
7500
7553
|
OP_DEPOSITS.base.assertErc20Asset,
|
|
7501
7554
|
() => {
|
|
@@ -7506,7 +7559,7 @@ function routeErc20Base() {
|
|
|
7506
7559
|
{ ctx: { token: p.token } }
|
|
7507
7560
|
);
|
|
7508
7561
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
7509
|
-
await
|
|
7562
|
+
await wrapAs5(
|
|
7510
7563
|
"VALIDATION",
|
|
7511
7564
|
OP_DEPOSITS.base.assertMatchesBase,
|
|
7512
7565
|
() => {
|
|
@@ -7545,13 +7598,18 @@ function routeErc20Base() {
|
|
|
7545
7598
|
overrideGasLimit: quotedL2GasLimit
|
|
7546
7599
|
});
|
|
7547
7600
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
7548
|
-
const
|
|
7601
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
7602
|
+
const baseCost = await quoteL2BaseCost2({
|
|
7603
|
+
ctx,
|
|
7604
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
7605
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
7606
|
+
});
|
|
7549
7607
|
const mintValue = baseCost + ctx.operatorTip + p.amount;
|
|
7550
7608
|
const approvals = [];
|
|
7551
7609
|
const steps = [];
|
|
7552
7610
|
{
|
|
7553
7611
|
const erc20 = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
7554
|
-
const allowance = await
|
|
7612
|
+
const allowance = await wrapAs5(
|
|
7555
7613
|
"RPC",
|
|
7556
7614
|
OP_DEPOSITS.base.allowance,
|
|
7557
7615
|
() => erc20.allowance(ctx.sender, ctx.l1NativeTokenVault),
|
|
@@ -7597,7 +7655,8 @@ function routeErc20Base() {
|
|
|
7597
7655
|
value: 0n,
|
|
7598
7656
|
// base token is ERC-20 ⇒ msg.value MUST be 0
|
|
7599
7657
|
from: ctx.sender,
|
|
7600
|
-
...ctx.gasOverrides
|
|
7658
|
+
...ctx.gasOverrides,
|
|
7659
|
+
...l1Fees
|
|
7601
7660
|
};
|
|
7602
7661
|
const l1GasParams = await quoteL1Gas2({
|
|
7603
7662
|
ctx,
|
|
@@ -7632,7 +7691,7 @@ function routeErc20Base() {
|
|
|
7632
7691
|
}
|
|
7633
7692
|
};
|
|
7634
7693
|
}
|
|
7635
|
-
var { wrapAs:
|
|
7694
|
+
var { wrapAs: wrapAs6 } = createErrorHandlers("tokens");
|
|
7636
7695
|
var abi = ethers.AbiCoder.defaultAbiCoder();
|
|
7637
7696
|
var ntvCodec3 = createNTVCodec({
|
|
7638
7697
|
encode: (types, values) => abi.encode(types, values),
|
|
@@ -7645,7 +7704,7 @@ function createTokensResource(client) {
|
|
|
7645
7704
|
let wethL2Promise = null;
|
|
7646
7705
|
async function getL1ChainId() {
|
|
7647
7706
|
if (!l2NtvL1ChainIdPromise) {
|
|
7648
|
-
l2NtvL1ChainIdPromise =
|
|
7707
|
+
l2NtvL1ChainIdPromise = wrapAs6("INTERNAL", "getL1ChainId", async () => {
|
|
7649
7708
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7650
7709
|
const chainId = await l2NativeTokenVault.L1_CHAIN_ID();
|
|
7651
7710
|
return chainId;
|
|
@@ -7655,7 +7714,7 @@ function createTokensResource(client) {
|
|
|
7655
7714
|
}
|
|
7656
7715
|
async function getBaseTokenAssetId() {
|
|
7657
7716
|
if (!baseTokenAssetIdPromise) {
|
|
7658
|
-
baseTokenAssetIdPromise =
|
|
7717
|
+
baseTokenAssetIdPromise = wrapAs6("INTERNAL", "baseTokenAssetId", async () => {
|
|
7659
7718
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7660
7719
|
const assetId = await l2NativeTokenVault.BASE_TOKEN_ASSET_ID();
|
|
7661
7720
|
return assetId;
|
|
@@ -7665,7 +7724,7 @@ function createTokensResource(client) {
|
|
|
7665
7724
|
}
|
|
7666
7725
|
async function getWethL1() {
|
|
7667
7726
|
if (!wethL1Promise) {
|
|
7668
|
-
wethL1Promise =
|
|
7727
|
+
wethL1Promise = wrapAs6("INTERNAL", "wethL1", async () => {
|
|
7669
7728
|
const { l1NativeTokenVault } = await client.contracts();
|
|
7670
7729
|
const weth = await l1NativeTokenVault.WETH_TOKEN();
|
|
7671
7730
|
return weth;
|
|
@@ -7675,7 +7734,7 @@ function createTokensResource(client) {
|
|
|
7675
7734
|
}
|
|
7676
7735
|
async function getWethL2() {
|
|
7677
7736
|
if (!wethL2Promise) {
|
|
7678
|
-
wethL2Promise =
|
|
7737
|
+
wethL2Promise = wrapAs6("INTERNAL", "wethL2", async () => {
|
|
7679
7738
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7680
7739
|
const weth = await l2NativeTokenVault.WETH_TOKEN();
|
|
7681
7740
|
return weth;
|
|
@@ -7684,7 +7743,7 @@ function createTokensResource(client) {
|
|
|
7684
7743
|
return wethL2Promise;
|
|
7685
7744
|
}
|
|
7686
7745
|
async function toL2Address(l1Token) {
|
|
7687
|
-
return
|
|
7746
|
+
return wrapAs6("CONTRACT", "tokens.toL2Address", async () => {
|
|
7688
7747
|
const normalized = normalizeL1Token(l1Token);
|
|
7689
7748
|
const { chainId } = await client.l2.getNetwork();
|
|
7690
7749
|
const baseToken = await client.baseToken(BigInt(chainId));
|
|
@@ -7697,7 +7756,7 @@ function createTokensResource(client) {
|
|
|
7697
7756
|
});
|
|
7698
7757
|
}
|
|
7699
7758
|
async function toL1Address(l2Token) {
|
|
7700
|
-
return
|
|
7759
|
+
return wrapAs6("CONTRACT", "tokens.toL1Address", async () => {
|
|
7701
7760
|
if (isAddressEq(l2Token, ETH_ADDRESS)) {
|
|
7702
7761
|
return ETH_ADDRESS;
|
|
7703
7762
|
}
|
|
@@ -7720,7 +7779,7 @@ function createTokensResource(client) {
|
|
|
7720
7779
|
});
|
|
7721
7780
|
}
|
|
7722
7781
|
async function assetIdOfL1(l1Token) {
|
|
7723
|
-
return
|
|
7782
|
+
return wrapAs6("CONTRACT", "tokens.assetIdOfL1", async () => {
|
|
7724
7783
|
const normalized = normalizeL1Token(l1Token);
|
|
7725
7784
|
const { l1NativeTokenVault } = await client.contracts();
|
|
7726
7785
|
const assetId = await l1NativeTokenVault.assetId(normalized);
|
|
@@ -7728,28 +7787,28 @@ function createTokensResource(client) {
|
|
|
7728
7787
|
});
|
|
7729
7788
|
}
|
|
7730
7789
|
async function assetIdOfL2(l2Token) {
|
|
7731
|
-
return
|
|
7790
|
+
return wrapAs6("CONTRACT", "tokens.assetIdOfL2", async () => {
|
|
7732
7791
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7733
7792
|
const assetId = await l2NativeTokenVault.assetId(l2Token);
|
|
7734
7793
|
return assetId;
|
|
7735
7794
|
});
|
|
7736
7795
|
}
|
|
7737
7796
|
async function l2TokenFromAssetId(assetId) {
|
|
7738
|
-
return
|
|
7797
|
+
return wrapAs6("CONTRACT", "tokens.l2TokenFromAssetId", async () => {
|
|
7739
7798
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7740
7799
|
const tokenAddr = await l2NativeTokenVault.tokenAddress(assetId);
|
|
7741
7800
|
return tokenAddr;
|
|
7742
7801
|
});
|
|
7743
7802
|
}
|
|
7744
7803
|
async function l1TokenFromAssetId(assetId) {
|
|
7745
|
-
return
|
|
7804
|
+
return wrapAs6("CONTRACT", "tokens.l1TokenFromAssetId", async () => {
|
|
7746
7805
|
const { l1NativeTokenVault } = await client.contracts();
|
|
7747
7806
|
const tokenAddr = await l1NativeTokenVault.tokenAddress(assetId);
|
|
7748
7807
|
return tokenAddr;
|
|
7749
7808
|
});
|
|
7750
7809
|
}
|
|
7751
7810
|
async function originChainId(assetId) {
|
|
7752
|
-
return
|
|
7811
|
+
return wrapAs6("CONTRACT", "tokens.originChainId", async () => {
|
|
7753
7812
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7754
7813
|
const chainId = await l2NativeTokenVault.originChainId(assetId);
|
|
7755
7814
|
return chainId;
|
|
@@ -7759,7 +7818,7 @@ function createTokensResource(client) {
|
|
|
7759
7818
|
return getBaseTokenAssetId();
|
|
7760
7819
|
}
|
|
7761
7820
|
async function isChainEthBased() {
|
|
7762
|
-
return
|
|
7821
|
+
return wrapAs6("CONTRACT", "tokens.isChainEthBased", async () => {
|
|
7763
7822
|
const baseAssetId = await getBaseTokenAssetId();
|
|
7764
7823
|
const l1ChainId = await getL1ChainId();
|
|
7765
7824
|
const ethAssetId = ntvCodec3.encodeAssetId(
|
|
@@ -7777,7 +7836,7 @@ function createTokensResource(client) {
|
|
|
7777
7836
|
return getWethL2();
|
|
7778
7837
|
}
|
|
7779
7838
|
async function computeL2BridgedAddress(args) {
|
|
7780
|
-
return
|
|
7839
|
+
return wrapAs6("CONTRACT", "tokens.computeL2BridgedAddress", async () => {
|
|
7781
7840
|
const normalized = normalizeL1Token(args.l1Token);
|
|
7782
7841
|
const { l2NativeTokenVault } = await client.contracts();
|
|
7783
7842
|
const predicted = await l2NativeTokenVault.calculateCreate2TokenAddress(
|
|
@@ -7788,7 +7847,7 @@ function createTokensResource(client) {
|
|
|
7788
7847
|
});
|
|
7789
7848
|
}
|
|
7790
7849
|
async function resolve(ref, opts) {
|
|
7791
|
-
return
|
|
7850
|
+
return wrapAs6("CONTRACT", "tokens.resolve", async () => {
|
|
7792
7851
|
let chain;
|
|
7793
7852
|
let address;
|
|
7794
7853
|
if (typeof ref === "string") {
|
|
@@ -8355,13 +8414,13 @@ function buildFeeBreakdown2(p) {
|
|
|
8355
8414
|
}
|
|
8356
8415
|
|
|
8357
8416
|
// src/adapters/ethers/resources/withdrawals/routes/eth.ts
|
|
8358
|
-
var { wrapAs:
|
|
8417
|
+
var { wrapAs: wrapAs7 } = createErrorHandlers("withdrawals");
|
|
8359
8418
|
function routeEthBase() {
|
|
8360
8419
|
return {
|
|
8361
8420
|
async build(p, ctx) {
|
|
8362
8421
|
const steps = [];
|
|
8363
8422
|
const base = await ctx.contracts.l2BaseTokenSystem();
|
|
8364
|
-
const data = await
|
|
8423
|
+
const data = await wrapAs7(
|
|
8365
8424
|
"INTERNAL",
|
|
8366
8425
|
OP_WITHDRAWALS.eth.encodeWithdraw,
|
|
8367
8426
|
() => Promise.resolve(base.interface.encodeFunctionData("withdraw", [p.to ?? ctx.sender])),
|
|
@@ -8396,7 +8455,7 @@ function routeEthBase() {
|
|
|
8396
8455
|
}
|
|
8397
8456
|
};
|
|
8398
8457
|
}
|
|
8399
|
-
var { wrapAs:
|
|
8458
|
+
var { wrapAs: wrapAs8 } = createErrorHandlers("withdrawals");
|
|
8400
8459
|
var SIG = {
|
|
8401
8460
|
withdraw: "withdraw(bytes32,bytes)"
|
|
8402
8461
|
};
|
|
@@ -8406,7 +8465,7 @@ function routeErc20NonBase2() {
|
|
|
8406
8465
|
const steps = [];
|
|
8407
8466
|
const approvals = [];
|
|
8408
8467
|
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
8409
|
-
const current = await
|
|
8468
|
+
const current = await wrapAs8(
|
|
8410
8469
|
"CONTRACT",
|
|
8411
8470
|
OP_WITHDRAWALS.erc20.allowance,
|
|
8412
8471
|
() => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
|
|
@@ -8444,7 +8503,7 @@ function routeErc20NonBase2() {
|
|
|
8444
8503
|
tx: approveTx
|
|
8445
8504
|
});
|
|
8446
8505
|
}
|
|
8447
|
-
const assetId = await
|
|
8506
|
+
const assetId = await wrapAs8(
|
|
8448
8507
|
"CONTRACT",
|
|
8449
8508
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
8450
8509
|
async () => {
|
|
@@ -8457,7 +8516,7 @@ function routeErc20NonBase2() {
|
|
|
8457
8516
|
message: "Failed to ensure token is registered in L2NativeTokenVault."
|
|
8458
8517
|
}
|
|
8459
8518
|
);
|
|
8460
|
-
const assetData = await
|
|
8519
|
+
const assetData = await wrapAs8(
|
|
8461
8520
|
"INTERNAL",
|
|
8462
8521
|
OP_WITHDRAWALS.erc20.encodeAssetData,
|
|
8463
8522
|
() => Promise.resolve(
|
|
@@ -8469,7 +8528,7 @@ function routeErc20NonBase2() {
|
|
|
8469
8528
|
}
|
|
8470
8529
|
);
|
|
8471
8530
|
const l2ar = await ctx.contracts.l2AssetRouter();
|
|
8472
|
-
const dataWithdraw = await
|
|
8531
|
+
const dataWithdraw = await wrapAs8(
|
|
8473
8532
|
"INTERNAL",
|
|
8474
8533
|
OP_WITHDRAWALS.erc20.encodeWithdraw,
|
|
8475
8534
|
() => Promise.resolve(l2ar.interface.encodeFunctionData(SIG.withdraw, [assetId, assetData])),
|
|
@@ -8626,7 +8685,7 @@ function buildWithdrawalBundle(input) {
|
|
|
8626
8685
|
}
|
|
8627
8686
|
|
|
8628
8687
|
// src/adapters/ethers/resources/withdrawals/routes/interop-bundle.ts
|
|
8629
|
-
var { wrapAs:
|
|
8688
|
+
var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
|
|
8630
8689
|
var attributes = createEthersAttributesResource();
|
|
8631
8690
|
function saltFor(sender, nonce) {
|
|
8632
8691
|
return ethers.keccak256(
|
|
@@ -8645,7 +8704,7 @@ function routeInteropBundle() {
|
|
|
8645
8704
|
if (isBaseToken) {
|
|
8646
8705
|
assetId = ctx.baseTokenAssetId;
|
|
8647
8706
|
} else {
|
|
8648
|
-
assetId = await
|
|
8707
|
+
assetId = await wrapAs9(
|
|
8649
8708
|
"CONTRACT",
|
|
8650
8709
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
8651
8710
|
async () => {
|
|
@@ -8658,7 +8717,7 @@ function routeInteropBundle() {
|
|
|
8658
8717
|
}
|
|
8659
8718
|
);
|
|
8660
8719
|
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
8661
|
-
const current = await
|
|
8720
|
+
const current = await wrapAs9(
|
|
8662
8721
|
"CONTRACT",
|
|
8663
8722
|
OP_WITHDRAWALS.erc20.allowance,
|
|
8664
8723
|
() => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
|
|
@@ -8694,7 +8753,7 @@ function routeInteropBundle() {
|
|
|
8694
8753
|
});
|
|
8695
8754
|
}
|
|
8696
8755
|
}
|
|
8697
|
-
const nonce = await
|
|
8756
|
+
const nonce = await wrapAs9(
|
|
8698
8757
|
"RPC",
|
|
8699
8758
|
OP_WITHDRAWALS.prepare,
|
|
8700
8759
|
() => ctx.client.l2.getTransactionCount(ctx.sender, "pending"),
|
|
@@ -8724,7 +8783,7 @@ function routeInteropBundle() {
|
|
|
8724
8783
|
}
|
|
8725
8784
|
});
|
|
8726
8785
|
const interopCenter = await ctx.contracts.interopCenter();
|
|
8727
|
-
const data = await
|
|
8786
|
+
const data = await wrapAs9(
|
|
8728
8787
|
"INTERNAL",
|
|
8729
8788
|
OP_WITHDRAWALS.erc20.encodeWithdraw,
|
|
8730
8789
|
() => Promise.resolve(
|
|
@@ -8939,7 +8998,7 @@ function createWithdrawalProtocolService(client, override) {
|
|
|
8939
8998
|
}
|
|
8940
8999
|
|
|
8941
9000
|
// src/adapters/ethers/resources/withdrawals/services/finalization.ts
|
|
8942
|
-
var { wrapAs:
|
|
9001
|
+
var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
|
|
8943
9002
|
var IL1NullifierMini = [
|
|
8944
9003
|
"function isWithdrawalFinalized(uint256,uint256,uint256) view returns (bool)"
|
|
8945
9004
|
];
|
|
@@ -8949,7 +9008,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
8949
9008
|
const { l1Nullifier } = await client.ensureAddresses();
|
|
8950
9009
|
if (protocol === "legacy-withdrawal") return l1Nullifier;
|
|
8951
9010
|
const nullifier = new ethers.Contract(l1Nullifier, IL1NullifierV32_default, l1);
|
|
8952
|
-
const handler = await
|
|
9011
|
+
const handler = await wrapAs10(
|
|
8953
9012
|
"CONTRACT",
|
|
8954
9013
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
8955
9014
|
() => nullifier.l1InteropHandler(),
|
|
@@ -8961,7 +9020,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
8961
9020
|
return handler;
|
|
8962
9021
|
}
|
|
8963
9022
|
async function fetchMessageAndProof(l2TxHash) {
|
|
8964
|
-
const raw = await
|
|
9023
|
+
const raw = await wrapAs10(
|
|
8965
9024
|
"RPC",
|
|
8966
9025
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
8967
9026
|
() => client.zks.getReceiptWithL2ToL1(l2TxHash),
|
|
@@ -8978,7 +9037,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
8978
9037
|
context: { l2TxHash }
|
|
8979
9038
|
});
|
|
8980
9039
|
}
|
|
8981
|
-
const ev = await
|
|
9040
|
+
const ev = await wrapAs10(
|
|
8982
9041
|
"INTERNAL",
|
|
8983
9042
|
OP_WITHDRAWALS.finalize.fetchParams.findMessage,
|
|
8984
9043
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
@@ -8988,7 +9047,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
8988
9047
|
message: "Failed to locate L1MessageSent event in L2 receipt."
|
|
8989
9048
|
}
|
|
8990
9049
|
);
|
|
8991
|
-
const message = await
|
|
9050
|
+
const message = await wrapAs10(
|
|
8992
9051
|
"INTERNAL",
|
|
8993
9052
|
OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
|
|
8994
9053
|
() => Promise.resolve(ethers.AbiCoder.defaultAbiCoder().decode(["bytes"], ev.data)[0]),
|
|
@@ -8997,7 +9056,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
8997
9056
|
message: "Failed to decode withdrawal message."
|
|
8998
9057
|
}
|
|
8999
9058
|
);
|
|
9000
|
-
const idx = await
|
|
9059
|
+
const idx = await wrapAs10(
|
|
9001
9060
|
"INTERNAL",
|
|
9002
9061
|
OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
|
|
9003
9062
|
() => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
|
|
@@ -9006,7 +9065,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9006
9065
|
message: "Failed to derive messenger log index."
|
|
9007
9066
|
}
|
|
9008
9067
|
);
|
|
9009
|
-
const proof = await
|
|
9068
|
+
const proof = await wrapAs10(
|
|
9010
9069
|
"RPC",
|
|
9011
9070
|
OP_WITHDRAWALS.finalize.fetchParams.proof,
|
|
9012
9071
|
() => client.zks.getL2ToL1LogProof(l2TxHash, idx),
|
|
@@ -9015,7 +9074,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9015
9074
|
message: "Failed to fetch L2\u2192L1 log proof."
|
|
9016
9075
|
}
|
|
9017
9076
|
);
|
|
9018
|
-
const { chainId } = await
|
|
9077
|
+
const { chainId } = await wrapAs10(
|
|
9019
9078
|
"RPC",
|
|
9020
9079
|
OP_WITHDRAWALS.finalize.fetchParams.network,
|
|
9021
9080
|
() => l2.getNetwork(),
|
|
@@ -9074,7 +9133,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9074
9133
|
const target = await finalizationTarget(finalization.protocol);
|
|
9075
9134
|
if (finalization.protocol === "legacy-withdrawal") {
|
|
9076
9135
|
const c = new ethers.Contract(target, IL1NullifierMini, l1);
|
|
9077
|
-
const done = await
|
|
9136
|
+
const done = await wrapAs10(
|
|
9078
9137
|
"RPC",
|
|
9079
9138
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
9080
9139
|
() => c.isWithdrawalFinalized(
|
|
@@ -9092,7 +9151,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9092
9151
|
const { bundleHash } = finalization.params;
|
|
9093
9152
|
const handler = new ethers.Contract(target, IInteropHandler_default, l1);
|
|
9094
9153
|
const status = Number(
|
|
9095
|
-
await
|
|
9154
|
+
await wrapAs10(
|
|
9096
9155
|
"RPC",
|
|
9097
9156
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
9098
9157
|
() => handler.bundleStatus(bundleHash),
|
|
@@ -9104,7 +9163,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9104
9163
|
);
|
|
9105
9164
|
if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
|
|
9106
9165
|
const callStatus = Number(
|
|
9107
|
-
await
|
|
9166
|
+
await wrapAs10(
|
|
9108
9167
|
"RPC",
|
|
9109
9168
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
9110
9169
|
() => handler.callStatus(bundleHash, 0),
|
|
@@ -9164,7 +9223,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9164
9223
|
async estimateFinalization(finalization) {
|
|
9165
9224
|
const target = await finalizationTarget(finalization.protocol);
|
|
9166
9225
|
const l1Signer = client.getL1Signer();
|
|
9167
|
-
const gasLimit = await
|
|
9226
|
+
const gasLimit = await wrapAs10(
|
|
9168
9227
|
"RPC",
|
|
9169
9228
|
OP_WITHDRAWALS.finalize.estimate,
|
|
9170
9229
|
() => {
|
|
@@ -9183,7 +9242,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
9183
9242
|
message: "Failed to estimate gas for withdrawal finalization."
|
|
9184
9243
|
}
|
|
9185
9244
|
);
|
|
9186
|
-
const feeData = await
|
|
9245
|
+
const feeData = await wrapAs10("RPC", OP_WITHDRAWALS.finalize.estimate, () => l1.getFeeData(), {
|
|
9187
9246
|
ctx: { where: "l1.getFeeData" },
|
|
9188
9247
|
message: "Failed to estimate fee data for withdrawal finalization."
|
|
9189
9248
|
});
|