@matterlabs/zksync-js 0.0.23 → 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/client.js +4 -4
- package/dist/adapters/ethers/index.cjs +155 -82
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +7 -7
- 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 +155 -91
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +6 -6
- package/dist/adapters/viem/client.js +4 -4
- package/dist/adapters/viem/index.cjs +182 -122
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +7 -7
- 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 +182 -135
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +6 -6
- package/dist/{chunk-4GPIHYVF.js → chunk-4ZANKNIK.js} +1 -1
- package/dist/{chunk-JJ523MOL.js → chunk-BQ2YCWV2.js} +1 -1
- package/dist/{chunk-4M7VNYGC.js → chunk-H5A6GU3D.js} +2 -2
- package/dist/{chunk-2DDJFHHD.js → chunk-JNS4XZE2.js} +1 -1
- package/dist/{chunk-WPCZNITC.js → chunk-JWN26CQ6.js} +31 -11
- package/dist/{chunk-V2TDNGI5.js → chunk-N5E4FLBF.js} +127 -74
- package/dist/{chunk-NVOFHV3A.js → chunk-NFRRRT5X.js} +155 -120
- package/dist/{chunk-URHDNDFN.js → chunk-PNTR5FTL.js} +2 -2
- package/dist/{chunk-TUN6NH5D.js → chunk-RZH7HBH3.js} +2 -2
- package/dist/{chunk-6WIAMFIW.js → chunk-YEA74D2L.js} +2 -2
- package/dist/{chunk-X2JJDQ4O.js → chunk-YGXEIOK6.js} +1 -1
- package/dist/core/index.js +3 -3
- package/dist/core/resources/deposits/gas.d.ts +11 -1
- package/dist/core/types/errors.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -329,7 +329,7 @@ var OP_DEPOSITS = {
|
|
|
329
329
|
ethNonBase: {
|
|
330
330
|
allowanceBase: "deposits.eth-nonbase:allowanceBaseToken",
|
|
331
331
|
ethBalance: "deposits.eth-nonbase:getEthBalance",
|
|
332
|
-
encodeCalldata: "deposits.eth-nonbase:
|
|
332
|
+
encodeCalldata: "deposits.eth-nonbase:encodeSecondBridgeEthDepositCalldata",
|
|
333
333
|
assertEthAsset: "deposits.eth-nonbase:assertEthAsset",
|
|
334
334
|
assertNonEthBase: "deposits.eth-nonbase:assertNonEthBase",
|
|
335
335
|
assertEthBalance: "deposits.eth-nonbase:assertEthBalance"
|
|
@@ -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;
|
|
8433
8434
|
}
|
|
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 };
|
|
8457
|
+
}
|
|
8458
|
+
return market;
|
|
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,13 +9259,27 @@ 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({
|
|
9219
9266
|
encode: (types, values) => ethers.AbiCoder.defaultAbiCoder().encode(types, values),
|
|
9220
9267
|
keccak256: (data) => ethers.keccak256(data)
|
|
9221
9268
|
});
|
|
9269
|
+
async function encodeSecondBridgeEthDepositCalldata(input) {
|
|
9270
|
+
const registeredAssetId = input.ctx.resolvedToken?.assetId;
|
|
9271
|
+
const assetId = registeredAssetId && registeredAssetId.toLowerCase() !== ZERO_ASSET_ID2 ? registeredAssetId : ntvCodec2.encodeAssetId(
|
|
9272
|
+
BigInt((await input.ctx.client.l1.getNetwork()).chainId),
|
|
9273
|
+
L2_NATIVE_TOKEN_VAULT_ADDRESS,
|
|
9274
|
+
ETH_ADDRESS
|
|
9275
|
+
);
|
|
9276
|
+
const transferData = encodeNativeTokenVaultTransferData(
|
|
9277
|
+
input.amount,
|
|
9278
|
+
input.receiver,
|
|
9279
|
+
ETH_ADDRESS
|
|
9280
|
+
);
|
|
9281
|
+
return encodeSecondBridgeDataV1(assetId, transferData);
|
|
9282
|
+
}
|
|
9222
9283
|
async function getPriorityGasModel2(input) {
|
|
9223
9284
|
try {
|
|
9224
9285
|
const l1AssetRouter = await input.ctx.contracts.l1AssetRouter();
|
|
@@ -9274,7 +9335,7 @@ function routeEthNonBase() {
|
|
|
9274
9335
|
return {
|
|
9275
9336
|
async preflight(p, ctx) {
|
|
9276
9337
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
9277
|
-
await
|
|
9338
|
+
await wrapAs5(
|
|
9278
9339
|
"VALIDATION",
|
|
9279
9340
|
OP_DEPOSITS.ethNonBase.assertEthAsset,
|
|
9280
9341
|
() => {
|
|
@@ -9284,7 +9345,7 @@ function routeEthNonBase() {
|
|
|
9284
9345
|
},
|
|
9285
9346
|
{ ctx: { token: p.token } }
|
|
9286
9347
|
);
|
|
9287
|
-
await
|
|
9348
|
+
await wrapAs5(
|
|
9288
9349
|
"VALIDATION",
|
|
9289
9350
|
OP_DEPOSITS.ethNonBase.assertNonEthBase,
|
|
9290
9351
|
() => {
|
|
@@ -9294,7 +9355,7 @@ function routeEthNonBase() {
|
|
|
9294
9355
|
},
|
|
9295
9356
|
{ ctx: { baseIsEth: ctx.baseIsEth, chainIdL2: ctx.chainIdL2 } }
|
|
9296
9357
|
);
|
|
9297
|
-
const ethBal = await
|
|
9358
|
+
const ethBal = await wrapAs5(
|
|
9298
9359
|
"RPC",
|
|
9299
9360
|
OP_DEPOSITS.ethNonBase.ethBalance,
|
|
9300
9361
|
() => ctx.client.l1.getBalance(ctx.sender),
|
|
@@ -9303,7 +9364,7 @@ function routeEthNonBase() {
|
|
|
9303
9364
|
message: "Failed to read L1 ETH balance."
|
|
9304
9365
|
}
|
|
9305
9366
|
);
|
|
9306
|
-
await
|
|
9367
|
+
await wrapAs5(
|
|
9307
9368
|
"VALIDATION",
|
|
9308
9369
|
OP_DEPOSITS.ethNonBase.assertEthBalance,
|
|
9309
9370
|
() => {
|
|
@@ -9338,12 +9399,17 @@ function routeEthNonBase() {
|
|
|
9338
9399
|
undeployedGasLimit: priorityGasModel.undeployedGasLimit
|
|
9339
9400
|
});
|
|
9340
9401
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
9341
|
-
const
|
|
9402
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
9403
|
+
const baseCost = await quoteL2BaseCost2({
|
|
9404
|
+
ctx,
|
|
9405
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
9406
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
9407
|
+
});
|
|
9342
9408
|
const mintValue = baseCost + ctx.operatorTip;
|
|
9343
9409
|
const approvals = [];
|
|
9344
9410
|
const steps = [];
|
|
9345
9411
|
const erc20Base = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
9346
|
-
const allowance = await
|
|
9412
|
+
const allowance = await wrapAs5(
|
|
9347
9413
|
"RPC",
|
|
9348
9414
|
OP_DEPOSITS.ethNonBase.allowanceBase,
|
|
9349
9415
|
() => erc20Base.allowance(ctx.sender, ctx.l1NativeTokenVault),
|
|
@@ -9369,13 +9435,13 @@ function routeEthNonBase() {
|
|
|
9369
9435
|
}
|
|
9370
9436
|
});
|
|
9371
9437
|
}
|
|
9372
|
-
const secondBridgeCalldata = await
|
|
9438
|
+
const secondBridgeCalldata = await wrapAs5(
|
|
9373
9439
|
"INTERNAL",
|
|
9374
9440
|
OP_DEPOSITS.ethNonBase.encodeCalldata,
|
|
9375
|
-
() =>
|
|
9441
|
+
() => encodeSecondBridgeEthDepositCalldata({ ctx, amount: p.amount, receiver }),
|
|
9376
9442
|
{
|
|
9377
9443
|
ctx: {
|
|
9378
|
-
where: "
|
|
9444
|
+
where: "encodeSecondBridgeEthDepositCalldata",
|
|
9379
9445
|
amount: p.amount.toString(),
|
|
9380
9446
|
to: receiver
|
|
9381
9447
|
}
|
|
@@ -9402,7 +9468,8 @@ function routeEthNonBase() {
|
|
|
9402
9468
|
data,
|
|
9403
9469
|
value: bridgehubValue,
|
|
9404
9470
|
from: ctx.sender,
|
|
9405
|
-
...ctx.gasOverrides
|
|
9471
|
+
...ctx.gasOverrides,
|
|
9472
|
+
...l1Fees
|
|
9406
9473
|
};
|
|
9407
9474
|
const l1GasParams = await quoteL1Gas2({
|
|
9408
9475
|
ctx,
|
|
@@ -9437,13 +9504,13 @@ function routeEthNonBase() {
|
|
|
9437
9504
|
}
|
|
9438
9505
|
};
|
|
9439
9506
|
}
|
|
9440
|
-
var { wrapAs:
|
|
9507
|
+
var { wrapAs: wrapAs6 } = createErrorHandlers("deposits");
|
|
9441
9508
|
var EMPTY_BYTES3 = "0x";
|
|
9442
9509
|
function routeErc20Base() {
|
|
9443
9510
|
return {
|
|
9444
9511
|
async preflight(p, ctx) {
|
|
9445
9512
|
const resolved = ctx.resolvedToken ?? (ctx.tokens ? await ctx.tokens.resolve(p.token, { chain: "l1" }) : void 0);
|
|
9446
|
-
await
|
|
9513
|
+
await wrapAs6(
|
|
9447
9514
|
"VALIDATION",
|
|
9448
9515
|
OP_DEPOSITS.base.assertErc20Asset,
|
|
9449
9516
|
() => {
|
|
@@ -9454,7 +9521,7 @@ function routeErc20Base() {
|
|
|
9454
9521
|
{ ctx: { token: p.token } }
|
|
9455
9522
|
);
|
|
9456
9523
|
const baseToken = ctx.baseTokenL1 ?? await ctx.client.baseToken(ctx.chainIdL2);
|
|
9457
|
-
await
|
|
9524
|
+
await wrapAs6(
|
|
9458
9525
|
"VALIDATION",
|
|
9459
9526
|
OP_DEPOSITS.base.assertMatchesBase,
|
|
9460
9527
|
() => {
|
|
@@ -9493,13 +9560,18 @@ function routeErc20Base() {
|
|
|
9493
9560
|
overrideGasLimit: quotedL2GasLimit
|
|
9494
9561
|
});
|
|
9495
9562
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
9496
|
-
const
|
|
9563
|
+
const l1Fees = await quoteL1Fees2({ ctx });
|
|
9564
|
+
const baseCost = await quoteL2BaseCost2({
|
|
9565
|
+
ctx,
|
|
9566
|
+
l2GasLimit: l2GasParams.gasLimit,
|
|
9567
|
+
l1GasPrice: l1Fees.maxFeePerGas
|
|
9568
|
+
});
|
|
9497
9569
|
const mintValue = baseCost + ctx.operatorTip + p.amount;
|
|
9498
9570
|
const approvals = [];
|
|
9499
9571
|
const steps = [];
|
|
9500
9572
|
{
|
|
9501
9573
|
const erc20 = new ethers.Contract(baseToken, IERC20_default, l1Signer);
|
|
9502
|
-
const allowance = await
|
|
9574
|
+
const allowance = await wrapAs6(
|
|
9503
9575
|
"RPC",
|
|
9504
9576
|
OP_DEPOSITS.base.allowance,
|
|
9505
9577
|
() => erc20.allowance(ctx.sender, ctx.l1NativeTokenVault),
|
|
@@ -9545,7 +9617,8 @@ function routeErc20Base() {
|
|
|
9545
9617
|
value: 0n,
|
|
9546
9618
|
// base token is ERC-20 ⇒ msg.value MUST be 0
|
|
9547
9619
|
from: ctx.sender,
|
|
9548
|
-
...ctx.gasOverrides
|
|
9620
|
+
...ctx.gasOverrides,
|
|
9621
|
+
...l1Fees
|
|
9549
9622
|
};
|
|
9550
9623
|
const l1GasParams = await quoteL1Gas2({
|
|
9551
9624
|
ctx,
|
|
@@ -9580,7 +9653,7 @@ function routeErc20Base() {
|
|
|
9580
9653
|
}
|
|
9581
9654
|
};
|
|
9582
9655
|
}
|
|
9583
|
-
var { wrapAs:
|
|
9656
|
+
var { wrapAs: wrapAs7 } = createErrorHandlers("tokens");
|
|
9584
9657
|
var abi = ethers.AbiCoder.defaultAbiCoder();
|
|
9585
9658
|
var ntvCodec3 = createNTVCodec({
|
|
9586
9659
|
encode: (types, values) => abi.encode(types, values),
|
|
@@ -9593,7 +9666,7 @@ function createTokensResource(client) {
|
|
|
9593
9666
|
let wethL2Promise = null;
|
|
9594
9667
|
async function getL1ChainId() {
|
|
9595
9668
|
if (!l2NtvL1ChainIdPromise) {
|
|
9596
|
-
l2NtvL1ChainIdPromise =
|
|
9669
|
+
l2NtvL1ChainIdPromise = wrapAs7("INTERNAL", "getL1ChainId", async () => {
|
|
9597
9670
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9598
9671
|
const chainId = await l2NativeTokenVault.L1_CHAIN_ID();
|
|
9599
9672
|
return chainId;
|
|
@@ -9603,7 +9676,7 @@ function createTokensResource(client) {
|
|
|
9603
9676
|
}
|
|
9604
9677
|
async function getBaseTokenAssetId() {
|
|
9605
9678
|
if (!baseTokenAssetIdPromise) {
|
|
9606
|
-
baseTokenAssetIdPromise =
|
|
9679
|
+
baseTokenAssetIdPromise = wrapAs7("INTERNAL", "baseTokenAssetId", async () => {
|
|
9607
9680
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9608
9681
|
const assetId = await l2NativeTokenVault.BASE_TOKEN_ASSET_ID();
|
|
9609
9682
|
return assetId;
|
|
@@ -9613,7 +9686,7 @@ function createTokensResource(client) {
|
|
|
9613
9686
|
}
|
|
9614
9687
|
async function getWethL1() {
|
|
9615
9688
|
if (!wethL1Promise) {
|
|
9616
|
-
wethL1Promise =
|
|
9689
|
+
wethL1Promise = wrapAs7("INTERNAL", "wethL1", async () => {
|
|
9617
9690
|
const { l1NativeTokenVault } = await client.contracts();
|
|
9618
9691
|
const weth = await l1NativeTokenVault.WETH_TOKEN();
|
|
9619
9692
|
return weth;
|
|
@@ -9623,7 +9696,7 @@ function createTokensResource(client) {
|
|
|
9623
9696
|
}
|
|
9624
9697
|
async function getWethL2() {
|
|
9625
9698
|
if (!wethL2Promise) {
|
|
9626
|
-
wethL2Promise =
|
|
9699
|
+
wethL2Promise = wrapAs7("INTERNAL", "wethL2", async () => {
|
|
9627
9700
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9628
9701
|
const weth = await l2NativeTokenVault.WETH_TOKEN();
|
|
9629
9702
|
return weth;
|
|
@@ -9632,7 +9705,7 @@ function createTokensResource(client) {
|
|
|
9632
9705
|
return wethL2Promise;
|
|
9633
9706
|
}
|
|
9634
9707
|
async function toL2Address(l1Token) {
|
|
9635
|
-
return
|
|
9708
|
+
return wrapAs7("CONTRACT", "tokens.toL2Address", async () => {
|
|
9636
9709
|
const normalized = normalizeL1Token(l1Token);
|
|
9637
9710
|
const { chainId } = await client.l2.getNetwork();
|
|
9638
9711
|
const baseToken = await client.baseToken(BigInt(chainId));
|
|
@@ -9645,7 +9718,7 @@ function createTokensResource(client) {
|
|
|
9645
9718
|
});
|
|
9646
9719
|
}
|
|
9647
9720
|
async function toL1Address(l2Token) {
|
|
9648
|
-
return
|
|
9721
|
+
return wrapAs7("CONTRACT", "tokens.toL1Address", async () => {
|
|
9649
9722
|
if (isAddressEq(l2Token, ETH_ADDRESS)) {
|
|
9650
9723
|
return ETH_ADDRESS;
|
|
9651
9724
|
}
|
|
@@ -9668,7 +9741,7 @@ function createTokensResource(client) {
|
|
|
9668
9741
|
});
|
|
9669
9742
|
}
|
|
9670
9743
|
async function assetIdOfL1(l1Token) {
|
|
9671
|
-
return
|
|
9744
|
+
return wrapAs7("CONTRACT", "tokens.assetIdOfL1", async () => {
|
|
9672
9745
|
const normalized = normalizeL1Token(l1Token);
|
|
9673
9746
|
const { l1NativeTokenVault } = await client.contracts();
|
|
9674
9747
|
const assetId = await l1NativeTokenVault.assetId(normalized);
|
|
@@ -9676,28 +9749,28 @@ function createTokensResource(client) {
|
|
|
9676
9749
|
});
|
|
9677
9750
|
}
|
|
9678
9751
|
async function assetIdOfL2(l2Token) {
|
|
9679
|
-
return
|
|
9752
|
+
return wrapAs7("CONTRACT", "tokens.assetIdOfL2", async () => {
|
|
9680
9753
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9681
9754
|
const assetId = await l2NativeTokenVault.assetId(l2Token);
|
|
9682
9755
|
return assetId;
|
|
9683
9756
|
});
|
|
9684
9757
|
}
|
|
9685
9758
|
async function l2TokenFromAssetId(assetId) {
|
|
9686
|
-
return
|
|
9759
|
+
return wrapAs7("CONTRACT", "tokens.l2TokenFromAssetId", async () => {
|
|
9687
9760
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9688
9761
|
const tokenAddr = await l2NativeTokenVault.tokenAddress(assetId);
|
|
9689
9762
|
return tokenAddr;
|
|
9690
9763
|
});
|
|
9691
9764
|
}
|
|
9692
9765
|
async function l1TokenFromAssetId(assetId) {
|
|
9693
|
-
return
|
|
9766
|
+
return wrapAs7("CONTRACT", "tokens.l1TokenFromAssetId", async () => {
|
|
9694
9767
|
const { l1NativeTokenVault } = await client.contracts();
|
|
9695
9768
|
const tokenAddr = await l1NativeTokenVault.tokenAddress(assetId);
|
|
9696
9769
|
return tokenAddr;
|
|
9697
9770
|
});
|
|
9698
9771
|
}
|
|
9699
9772
|
async function originChainId(assetId) {
|
|
9700
|
-
return
|
|
9773
|
+
return wrapAs7("CONTRACT", "tokens.originChainId", async () => {
|
|
9701
9774
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9702
9775
|
const chainId = await l2NativeTokenVault.originChainId(assetId);
|
|
9703
9776
|
return chainId;
|
|
@@ -9707,7 +9780,7 @@ function createTokensResource(client) {
|
|
|
9707
9780
|
return getBaseTokenAssetId();
|
|
9708
9781
|
}
|
|
9709
9782
|
async function isChainEthBased() {
|
|
9710
|
-
return
|
|
9783
|
+
return wrapAs7("CONTRACT", "tokens.isChainEthBased", async () => {
|
|
9711
9784
|
const baseAssetId = await getBaseTokenAssetId();
|
|
9712
9785
|
const l1ChainId = await getL1ChainId();
|
|
9713
9786
|
const ethAssetId = ntvCodec3.encodeAssetId(
|
|
@@ -9725,7 +9798,7 @@ function createTokensResource(client) {
|
|
|
9725
9798
|
return getWethL2();
|
|
9726
9799
|
}
|
|
9727
9800
|
async function computeL2BridgedAddress(args) {
|
|
9728
|
-
return
|
|
9801
|
+
return wrapAs7("CONTRACT", "tokens.computeL2BridgedAddress", async () => {
|
|
9729
9802
|
const normalized = normalizeL1Token(args.l1Token);
|
|
9730
9803
|
const { l2NativeTokenVault } = await client.contracts();
|
|
9731
9804
|
const predicted = await l2NativeTokenVault.calculateCreate2TokenAddress(
|
|
@@ -9736,7 +9809,7 @@ function createTokensResource(client) {
|
|
|
9736
9809
|
});
|
|
9737
9810
|
}
|
|
9738
9811
|
async function resolve(ref, opts) {
|
|
9739
|
-
return
|
|
9812
|
+
return wrapAs7("CONTRACT", "tokens.resolve", async () => {
|
|
9740
9813
|
let chain;
|
|
9741
9814
|
let address;
|
|
9742
9815
|
if (typeof ref === "string") {
|
|
@@ -10303,13 +10376,13 @@ function buildFeeBreakdown2(p) {
|
|
|
10303
10376
|
}
|
|
10304
10377
|
|
|
10305
10378
|
// src/adapters/ethers/resources/withdrawals/routes/eth.ts
|
|
10306
|
-
var { wrapAs:
|
|
10379
|
+
var { wrapAs: wrapAs8 } = createErrorHandlers("withdrawals");
|
|
10307
10380
|
function routeEthBase() {
|
|
10308
10381
|
return {
|
|
10309
10382
|
async build(p, ctx) {
|
|
10310
10383
|
const steps = [];
|
|
10311
10384
|
const base = await ctx.contracts.l2BaseTokenSystem();
|
|
10312
|
-
const data = await
|
|
10385
|
+
const data = await wrapAs8(
|
|
10313
10386
|
"INTERNAL",
|
|
10314
10387
|
OP_WITHDRAWALS.eth.encodeWithdraw,
|
|
10315
10388
|
() => Promise.resolve(base.interface.encodeFunctionData("withdraw", [p.to ?? ctx.sender])),
|
|
@@ -10344,7 +10417,7 @@ function routeEthBase() {
|
|
|
10344
10417
|
}
|
|
10345
10418
|
};
|
|
10346
10419
|
}
|
|
10347
|
-
var { wrapAs:
|
|
10420
|
+
var { wrapAs: wrapAs9 } = createErrorHandlers("withdrawals");
|
|
10348
10421
|
var SIG = {
|
|
10349
10422
|
withdraw: "withdraw(bytes32,bytes)"
|
|
10350
10423
|
};
|
|
@@ -10354,7 +10427,7 @@ function routeErc20NonBase2() {
|
|
|
10354
10427
|
const steps = [];
|
|
10355
10428
|
const approvals = [];
|
|
10356
10429
|
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
10357
|
-
const current = await
|
|
10430
|
+
const current = await wrapAs9(
|
|
10358
10431
|
"CONTRACT",
|
|
10359
10432
|
OP_WITHDRAWALS.erc20.allowance,
|
|
10360
10433
|
() => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
|
|
@@ -10392,7 +10465,7 @@ function routeErc20NonBase2() {
|
|
|
10392
10465
|
tx: approveTx
|
|
10393
10466
|
});
|
|
10394
10467
|
}
|
|
10395
|
-
const assetId = await
|
|
10468
|
+
const assetId = await wrapAs9(
|
|
10396
10469
|
"CONTRACT",
|
|
10397
10470
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
10398
10471
|
async () => {
|
|
@@ -10405,7 +10478,7 @@ function routeErc20NonBase2() {
|
|
|
10405
10478
|
message: "Failed to ensure token is registered in L2NativeTokenVault."
|
|
10406
10479
|
}
|
|
10407
10480
|
);
|
|
10408
|
-
const assetData = await
|
|
10481
|
+
const assetData = await wrapAs9(
|
|
10409
10482
|
"INTERNAL",
|
|
10410
10483
|
OP_WITHDRAWALS.erc20.encodeAssetData,
|
|
10411
10484
|
() => Promise.resolve(
|
|
@@ -10417,7 +10490,7 @@ function routeErc20NonBase2() {
|
|
|
10417
10490
|
}
|
|
10418
10491
|
);
|
|
10419
10492
|
const l2ar = await ctx.contracts.l2AssetRouter();
|
|
10420
|
-
const dataWithdraw = await
|
|
10493
|
+
const dataWithdraw = await wrapAs9(
|
|
10421
10494
|
"INTERNAL",
|
|
10422
10495
|
OP_WITHDRAWALS.erc20.encodeWithdraw,
|
|
10423
10496
|
() => Promise.resolve(l2ar.interface.encodeFunctionData(SIG.withdraw, [assetId, assetData])),
|
|
@@ -10574,7 +10647,7 @@ function buildWithdrawalBundle(input) {
|
|
|
10574
10647
|
}
|
|
10575
10648
|
|
|
10576
10649
|
// src/adapters/ethers/resources/withdrawals/routes/interop-bundle.ts
|
|
10577
|
-
var { wrapAs:
|
|
10650
|
+
var { wrapAs: wrapAs10 } = createErrorHandlers("withdrawals");
|
|
10578
10651
|
var attributes = createEthersAttributesResource();
|
|
10579
10652
|
function saltFor(sender, nonce) {
|
|
10580
10653
|
return ethers.keccak256(
|
|
@@ -10593,7 +10666,7 @@ function routeInteropBundle() {
|
|
|
10593
10666
|
if (isBaseToken) {
|
|
10594
10667
|
assetId = ctx.baseTokenAssetId;
|
|
10595
10668
|
} else {
|
|
10596
|
-
assetId = await
|
|
10669
|
+
assetId = await wrapAs10(
|
|
10597
10670
|
"CONTRACT",
|
|
10598
10671
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
10599
10672
|
async () => {
|
|
@@ -10606,7 +10679,7 @@ function routeInteropBundle() {
|
|
|
10606
10679
|
}
|
|
10607
10680
|
);
|
|
10608
10681
|
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
10609
|
-
const current = await
|
|
10682
|
+
const current = await wrapAs10(
|
|
10610
10683
|
"CONTRACT",
|
|
10611
10684
|
OP_WITHDRAWALS.erc20.allowance,
|
|
10612
10685
|
() => erc20.allowance(ctx.sender, ctx.l2NativeTokenVault),
|
|
@@ -10642,7 +10715,7 @@ function routeInteropBundle() {
|
|
|
10642
10715
|
});
|
|
10643
10716
|
}
|
|
10644
10717
|
}
|
|
10645
|
-
const nonce = await
|
|
10718
|
+
const nonce = await wrapAs10(
|
|
10646
10719
|
"RPC",
|
|
10647
10720
|
OP_WITHDRAWALS.prepare,
|
|
10648
10721
|
() => ctx.client.l2.getTransactionCount(ctx.sender, "pending"),
|
|
@@ -10672,7 +10745,7 @@ function routeInteropBundle() {
|
|
|
10672
10745
|
}
|
|
10673
10746
|
});
|
|
10674
10747
|
const interopCenter = await ctx.contracts.interopCenter();
|
|
10675
|
-
const data = await
|
|
10748
|
+
const data = await wrapAs10(
|
|
10676
10749
|
"INTERNAL",
|
|
10677
10750
|
OP_WITHDRAWALS.erc20.encodeWithdraw,
|
|
10678
10751
|
() => Promise.resolve(
|
|
@@ -10887,7 +10960,7 @@ function createWithdrawalProtocolService(client, override) {
|
|
|
10887
10960
|
}
|
|
10888
10961
|
|
|
10889
10962
|
// src/adapters/ethers/resources/withdrawals/services/finalization.ts
|
|
10890
|
-
var { wrapAs:
|
|
10963
|
+
var { wrapAs: wrapAs11 } = createErrorHandlers("withdrawals");
|
|
10891
10964
|
var IL1NullifierMini = [
|
|
10892
10965
|
"function isWithdrawalFinalized(uint256,uint256,uint256) view returns (bool)"
|
|
10893
10966
|
];
|
|
@@ -10897,7 +10970,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10897
10970
|
const { l1Nullifier } = await client.ensureAddresses();
|
|
10898
10971
|
if (protocol === "legacy-withdrawal") return l1Nullifier;
|
|
10899
10972
|
const nullifier = new ethers.Contract(l1Nullifier, IL1NullifierV32_default, l1);
|
|
10900
|
-
const handler = await
|
|
10973
|
+
const handler = await wrapAs11(
|
|
10901
10974
|
"CONTRACT",
|
|
10902
10975
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
10903
10976
|
() => nullifier.l1InteropHandler(),
|
|
@@ -10909,7 +10982,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10909
10982
|
return handler;
|
|
10910
10983
|
}
|
|
10911
10984
|
async function fetchMessageAndProof(l2TxHash) {
|
|
10912
|
-
const raw = await
|
|
10985
|
+
const raw = await wrapAs11(
|
|
10913
10986
|
"RPC",
|
|
10914
10987
|
OP_WITHDRAWALS.finalize.fetchParams.receipt,
|
|
10915
10988
|
() => client.zks.getReceiptWithL2ToL1(l2TxHash),
|
|
@@ -10926,7 +10999,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10926
10999
|
context: { l2TxHash }
|
|
10927
11000
|
});
|
|
10928
11001
|
}
|
|
10929
|
-
const ev = await
|
|
11002
|
+
const ev = await wrapAs11(
|
|
10930
11003
|
"INTERNAL",
|
|
10931
11004
|
OP_WITHDRAWALS.finalize.fetchParams.findMessage,
|
|
10932
11005
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
|
|
@@ -10936,7 +11009,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10936
11009
|
message: "Failed to locate L1MessageSent event in L2 receipt."
|
|
10937
11010
|
}
|
|
10938
11011
|
);
|
|
10939
|
-
const message = await
|
|
11012
|
+
const message = await wrapAs11(
|
|
10940
11013
|
"INTERNAL",
|
|
10941
11014
|
OP_WITHDRAWALS.finalize.fetchParams.decodeMessage,
|
|
10942
11015
|
() => Promise.resolve(ethers.AbiCoder.defaultAbiCoder().decode(["bytes"], ev.data)[0]),
|
|
@@ -10945,7 +11018,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10945
11018
|
message: "Failed to decode withdrawal message."
|
|
10946
11019
|
}
|
|
10947
11020
|
);
|
|
10948
|
-
const idx = await
|
|
11021
|
+
const idx = await wrapAs11(
|
|
10949
11022
|
"INTERNAL",
|
|
10950
11023
|
OP_WITHDRAWALS.finalize.fetchParams.messengerIndex,
|
|
10951
11024
|
() => Promise.resolve(messengerLogIndex(raw, { index: 0, messenger: L1_MESSENGER_ADDRESS })),
|
|
@@ -10954,7 +11027,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10954
11027
|
message: "Failed to derive messenger log index."
|
|
10955
11028
|
}
|
|
10956
11029
|
);
|
|
10957
|
-
const proof = await
|
|
11030
|
+
const proof = await wrapAs11(
|
|
10958
11031
|
"RPC",
|
|
10959
11032
|
OP_WITHDRAWALS.finalize.fetchParams.proof,
|
|
10960
11033
|
() => client.zks.getL2ToL1LogProof(l2TxHash, idx),
|
|
@@ -10963,7 +11036,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
10963
11036
|
message: "Failed to fetch L2\u2192L1 log proof."
|
|
10964
11037
|
}
|
|
10965
11038
|
);
|
|
10966
|
-
const { chainId } = await
|
|
11039
|
+
const { chainId } = await wrapAs11(
|
|
10967
11040
|
"RPC",
|
|
10968
11041
|
OP_WITHDRAWALS.finalize.fetchParams.network,
|
|
10969
11042
|
() => l2.getNetwork(),
|
|
@@ -11022,7 +11095,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11022
11095
|
const target = await finalizationTarget(finalization.protocol);
|
|
11023
11096
|
if (finalization.protocol === "legacy-withdrawal") {
|
|
11024
11097
|
const c = new ethers.Contract(target, IL1NullifierMini, l1);
|
|
11025
|
-
const done = await
|
|
11098
|
+
const done = await wrapAs11(
|
|
11026
11099
|
"RPC",
|
|
11027
11100
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
11028
11101
|
() => c.isWithdrawalFinalized(
|
|
@@ -11040,7 +11113,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11040
11113
|
const { bundleHash } = finalization.params;
|
|
11041
11114
|
const handler = new ethers.Contract(target, IInteropHandler_default, l1);
|
|
11042
11115
|
const status = Number(
|
|
11043
|
-
await
|
|
11116
|
+
await wrapAs11(
|
|
11044
11117
|
"RPC",
|
|
11045
11118
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
11046
11119
|
() => handler.bundleStatus(bundleHash),
|
|
@@ -11052,7 +11125,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11052
11125
|
);
|
|
11053
11126
|
if (status !== 3 /* Unbundled */) return classifyWithdrawalOutcome(status);
|
|
11054
11127
|
const callStatus = Number(
|
|
11055
|
-
await
|
|
11128
|
+
await wrapAs11(
|
|
11056
11129
|
"RPC",
|
|
11057
11130
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
11058
11131
|
() => handler.callStatus(bundleHash, 0),
|
|
@@ -11112,7 +11185,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11112
11185
|
async estimateFinalization(finalization) {
|
|
11113
11186
|
const target = await finalizationTarget(finalization.protocol);
|
|
11114
11187
|
const l1Signer = client.getL1Signer();
|
|
11115
|
-
const gasLimit = await
|
|
11188
|
+
const gasLimit = await wrapAs11(
|
|
11116
11189
|
"RPC",
|
|
11117
11190
|
OP_WITHDRAWALS.finalize.estimate,
|
|
11118
11191
|
() => {
|
|
@@ -11131,7 +11204,7 @@ function createFinalizationServices(client, protocolService = createWithdrawalPr
|
|
|
11131
11204
|
message: "Failed to estimate gas for withdrawal finalization."
|
|
11132
11205
|
}
|
|
11133
11206
|
);
|
|
11134
|
-
const feeData = await
|
|
11207
|
+
const feeData = await wrapAs11("RPC", OP_WITHDRAWALS.finalize.estimate, () => l1.getFeeData(), {
|
|
11135
11208
|
ctx: { where: "l1.getFeeData" },
|
|
11136
11209
|
message: "Failed to estimate fee data for withdrawal finalization."
|
|
11137
11210
|
});
|