@matterlabs/zksync-js 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +1 -2
- package/dist/adapters/ethers/client.js +4 -5
- package/dist/adapters/ethers/index.cjs +117 -28
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +6 -7
- package/dist/adapters/ethers/resources/interop/services/gas.d.ts +12 -0
- package/dist/adapters/ethers/sdk.cjs +117 -28
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +5 -6
- package/dist/adapters/viem/client.cjs +787 -3
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +6 -1
- package/dist/adapters/viem/client.js +4 -5
- package/dist/adapters/viem/index.cjs +6463 -3014
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +5 -0
- package/dist/adapters/viem/index.js +6 -7
- package/dist/adapters/viem/resources/interop/address.d.ts +18 -0
- package/dist/adapters/viem/resources/interop/attributes/resource.d.ts +6 -0
- package/dist/adapters/viem/resources/interop/context.d.ts +31 -0
- package/dist/adapters/viem/resources/interop/index.d.ts +62 -0
- package/dist/adapters/viem/resources/interop/resolvers.d.ts +4 -0
- package/dist/adapters/viem/resources/interop/routes/direct.d.ts +2 -0
- package/dist/adapters/viem/resources/interop/routes/indirect.d.ts +2 -0
- package/dist/adapters/viem/resources/interop/routes/types.d.ts +23 -0
- package/dist/adapters/viem/resources/interop/services/erc20.d.ts +25 -0
- package/dist/adapters/viem/resources/interop/services/fee.d.ts +12 -0
- package/dist/adapters/viem/resources/interop/services/finalization/bundle.d.ts +15 -0
- package/dist/adapters/viem/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
- package/dist/adapters/viem/resources/interop/services/finalization/decoders.d.ts +11 -0
- package/dist/adapters/viem/resources/interop/services/finalization/index.d.ts +13 -0
- package/dist/adapters/viem/resources/interop/services/finalization/polling.d.ts +7 -0
- package/dist/adapters/viem/resources/interop/services/finalization/status.d.ts +5 -0
- package/dist/adapters/viem/resources/interop/services/finalization/topics.d.ts +4 -0
- package/dist/adapters/viem/resources/interop/services/gas.d.ts +12 -0
- package/dist/adapters/viem/resources/interop/services/starter-data.d.ts +6 -0
- package/dist/adapters/viem/resources/interop/types.d.ts +8 -0
- package/dist/adapters/viem/sdk.cjs +6608 -3203
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +8 -1
- package/dist/adapters/viem/sdk.js +5 -5
- package/dist/{chunk-75IOOODG.js → chunk-4PZCNTQ3.js} +1142 -26
- package/dist/{chunk-5RRJDPAJ.js → chunk-65HAYKVL.js} +2 -2
- package/dist/{chunk-XKRNLFET.js → chunk-HGB3DOV2.js} +73 -376
- package/dist/{chunk-J47RI3G7.js → chunk-HVHMLAYH.js} +1 -1
- package/dist/{chunk-OTXPSNNC.js → chunk-JHRYNLZG.js} +64 -7
- package/dist/{chunk-JY62QO3W.js → chunk-JXR5V5YK.js} +419 -6
- package/dist/chunk-K2UVKMLN.js +658 -0
- package/dist/{chunk-HP3EWKJL.js → chunk-MDPX5LNW.js} +1 -1
- package/dist/{chunk-7CAVFIMW.js → chunk-MZBKM3GH.js} +2 -3
- package/dist/{chunk-XDRCN4FC.js → chunk-YIWXIP2M.js} +10 -2
- package/dist/core/index.js +2 -3
- package/dist/core/resources/deposits/chains.d.ts +1 -0
- package/dist/core/resources/deposits/gas.d.ts +7 -0
- package/dist/core/resources/deposits/priority.d.ts +4 -0
- package/dist/core/resources/interop/protocol.d.ts +3 -0
- package/dist/core/types/flows/interop.d.ts +0 -2
- package/dist/core/types/primitives.d.ts +2 -0
- package/dist/index.js +2 -3
- package/package.json +1 -1
- package/dist/chunk-DYJKK5FW.js +0 -417
- package/dist/chunk-EOBXYHTZ.js +0 -265
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export { createEthersClient as createClient, createEthersClient } from '../../chunk-
|
|
2
|
-
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-
|
|
3
|
-
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersClient as createClient, createEthersClient } from '../../chunk-MZBKM3GH.js';
|
|
2
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-HGB3DOV2.js';
|
|
3
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-65HAYKVL.js';
|
|
4
|
+
import '../../chunk-K2UVKMLN.js';
|
|
5
5
|
import '../../chunk-3HHUZXSV.js';
|
|
6
6
|
import '../../chunk-BWKWWLY4.js';
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
9
|
-
import '../../chunk-JY62QO3W.js';
|
|
7
|
+
import '../../chunk-MDPX5LNW.js';
|
|
8
|
+
import '../../chunk-JXR5V5YK.js';
|
|
10
9
|
import '../../chunk-MT4X5FEO.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TransactionRequest } from 'ethers';
|
|
2
|
+
import type { BuildCtx } from '../context';
|
|
3
|
+
/**
|
|
4
|
+
* Estimates the combined L2 gas cost for all steps in an interop plan.
|
|
5
|
+
*
|
|
6
|
+
* Fetches gas price once, then estimates gas for each step using ctx.sender as the
|
|
7
|
+
* from address. Applies the standard buffer and sums gasLimit × maxFeePerGas across
|
|
8
|
+
* all steps. Returns undefined if estimation fails for any step.
|
|
9
|
+
*/
|
|
10
|
+
export declare function quoteStepsL2Fee(steps: Array<{
|
|
11
|
+
tx: TransactionRequest;
|
|
12
|
+
}>, ctx: BuildCtx): Promise<bigint | undefined>;
|
|
@@ -5930,7 +5930,33 @@ function buildDirectRequestStruct(args) {
|
|
|
5930
5930
|
};
|
|
5931
5931
|
}
|
|
5932
5932
|
|
|
5933
|
+
// src/core/resources/deposits/chains.ts
|
|
5934
|
+
var ERAVM_CHAIN_IDS = /* @__PURE__ */ new Set([324n, 2741n, 11124n, 300n]);
|
|
5935
|
+
function isEraVmChain(chainIdL2) {
|
|
5936
|
+
return ERAVM_CHAIN_IDS.has(chainIdL2);
|
|
5937
|
+
}
|
|
5938
|
+
|
|
5933
5939
|
// src/core/resources/deposits/gas.ts
|
|
5940
|
+
var CREATE_REESTIMATE_BUFFER = 15n;
|
|
5941
|
+
var maxBigInt = (a, b) => a > b ? a : b;
|
|
5942
|
+
function applyGasBuffer(gasLimit, bufferPct = BUFFER) {
|
|
5943
|
+
return gasLimit * (100n + bufferPct) / 100n;
|
|
5944
|
+
}
|
|
5945
|
+
function resolveCreateDepositL1GasLimit(input) {
|
|
5946
|
+
const { chainIdL2, stepKey, preparedGasLimit, estimatedGasLimit } = input;
|
|
5947
|
+
if (estimatedGasLimit == null) {
|
|
5948
|
+
return preparedGasLimit;
|
|
5949
|
+
}
|
|
5950
|
+
const isEraVmBridgeStep = isEraVmChain(chainIdL2) && stepKey.startsWith("bridgehub:");
|
|
5951
|
+
const reestimatedGasLimit = applyGasBuffer(
|
|
5952
|
+
estimatedGasLimit,
|
|
5953
|
+
isEraVmBridgeStep ? BUFFER : CREATE_REESTIMATE_BUFFER
|
|
5954
|
+
);
|
|
5955
|
+
if (isEraVmBridgeStep && preparedGasLimit != null) {
|
|
5956
|
+
return maxBigInt(preparedGasLimit, reestimatedGasLimit);
|
|
5957
|
+
}
|
|
5958
|
+
return reestimatedGasLimit;
|
|
5959
|
+
}
|
|
5934
5960
|
function makeGasQuote(p) {
|
|
5935
5961
|
const maxPriorityFeePerGas = p.maxPriorityFeePerGas ?? 0n;
|
|
5936
5962
|
return {
|
|
@@ -5981,7 +6007,7 @@ async function quoteL1Gas(input) {
|
|
|
5981
6007
|
}
|
|
5982
6008
|
try {
|
|
5983
6009
|
const est = await estimator.estimateGas(tx);
|
|
5984
|
-
const buffered = BigInt(est)
|
|
6010
|
+
const buffered = applyGasBuffer(BigInt(est));
|
|
5985
6011
|
return makeGasQuote({ gasLimit: buffered, maxFeePerGas, maxPriorityFeePerGas });
|
|
5986
6012
|
} catch {
|
|
5987
6013
|
if (fallbackGasLimit != null) {
|
|
@@ -6018,7 +6044,7 @@ async function quoteL2Gas(input) {
|
|
|
6018
6044
|
const memoryOverhead = memoryBytes * TX_MEMORY_OVERHEAD_GAS;
|
|
6019
6045
|
const pubdataOverhead = pubdataBytes * pp;
|
|
6020
6046
|
let total = BigInt(execEstimate) + TX_OVERHEAD_GAS + memoryOverhead + pubdataOverhead;
|
|
6021
|
-
total = total
|
|
6047
|
+
total = applyGasBuffer(total);
|
|
6022
6048
|
return makeGasQuote({
|
|
6023
6049
|
gasLimit: total,
|
|
6024
6050
|
maxFeePerGas,
|
|
@@ -6455,18 +6481,19 @@ function buildFeeBreakdown(p) {
|
|
|
6455
6481
|
// src/core/resources/deposits/priority.ts
|
|
6456
6482
|
var PRIORITY_TX_ENCODING_STEP_BYTES = 544n;
|
|
6457
6483
|
var DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER = 6n;
|
|
6458
|
-
var
|
|
6484
|
+
var ERAVM_PRIORITY_L2_GAS_BUFFER = 30n;
|
|
6485
|
+
var maxBigInt2 = (a, b) => a > b ? a : b;
|
|
6459
6486
|
var ceilDiv = (a, b) => (a + b - 1n) / b;
|
|
6460
6487
|
function derivePriorityTxGasBreakdown(input) {
|
|
6461
6488
|
const factoryDepsCount = input.factoryDepsCount ?? 0n;
|
|
6462
|
-
const minBodyGas =
|
|
6489
|
+
const minBodyGas = maxBigInt2(
|
|
6463
6490
|
L1_TX_INTRINSIC_L2_GAS + ceilDiv(
|
|
6464
6491
|
input.encodedLength * L1_TX_DELTA_544_ENCODING_BYTES,
|
|
6465
6492
|
PRIORITY_TX_ENCODING_STEP_BYTES
|
|
6466
6493
|
) + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_L2_GAS,
|
|
6467
6494
|
L1_TX_MIN_L2_GAS_BASE
|
|
6468
6495
|
) + L1_TX_INTRINSIC_PUBDATA * input.gasPerPubdata + factoryDepsCount * L1_TX_DELTA_FACTORY_DEPS_PUBDATA * input.gasPerPubdata;
|
|
6469
|
-
const overhead =
|
|
6496
|
+
const overhead = maxBigInt2(TX_SLOT_OVERHEAD_L2_GAS, TX_MEMORY_OVERHEAD_GAS * input.encodedLength);
|
|
6470
6497
|
const derivedBodyGas = minBodyGas;
|
|
6471
6498
|
return {
|
|
6472
6499
|
encodedLength: input.encodedLength,
|
|
@@ -6481,8 +6508,12 @@ function derivePriorityTxGasBreakdown(input) {
|
|
|
6481
6508
|
function derivePriorityBodyGasEstimateCap(input) {
|
|
6482
6509
|
return input.minBodyGas * (input.multiplier ?? DEFAULT_PRIORITY_BODY_GAS_ESTIMATE_MULTIPLIER);
|
|
6483
6510
|
}
|
|
6484
|
-
|
|
6485
|
-
|
|
6511
|
+
function applyPriorityL2GasLimitBuffer(input) {
|
|
6512
|
+
if (!isEraVmChain(input.chainIdL2)) {
|
|
6513
|
+
return input.gasLimit;
|
|
6514
|
+
}
|
|
6515
|
+
return input.gasLimit * (100n + ERAVM_PRIORITY_L2_GAS_BUFFER) / 100n;
|
|
6516
|
+
}
|
|
6486
6517
|
var EMPTY_BYTES = "0x";
|
|
6487
6518
|
var ZERO_RESERVED_WORDS = [0n, 0n, 0n, 0n];
|
|
6488
6519
|
var L2_CANONICAL_TRANSACTION_TUPLE = "tuple(uint256 txType,uint256 from,uint256 to,uint256 gasLimit,uint256 gasPerPubdataByteLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas,uint256 paymaster,uint256 nonce,uint256 value,uint256[4] reserved,bytes data,bytes signature,uint256[] factoryDeps,bytes paymasterInput,bytes reservedDynamic)";
|
|
@@ -6539,7 +6570,10 @@ function routeEthDirect() {
|
|
|
6539
6570
|
l2Calldata,
|
|
6540
6571
|
gasPerPubdata: ctx.gasPerPubdata
|
|
6541
6572
|
});
|
|
6542
|
-
const quotedL2GasLimit = ctx.l2GasLimit ??
|
|
6573
|
+
const quotedL2GasLimit = ctx.l2GasLimit ?? applyPriorityL2GasLimitBuffer({
|
|
6574
|
+
chainIdL2: ctx.chainIdL2,
|
|
6575
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
6576
|
+
});
|
|
6543
6577
|
const l2GasParams = await quoteL2Gas2({
|
|
6544
6578
|
ctx,
|
|
6545
6579
|
route: "eth-base",
|
|
@@ -6642,7 +6676,10 @@ async function getPriorityGasModel(input) {
|
|
|
6642
6676
|
gasPerPubdata: input.ctx.gasPerPubdata
|
|
6643
6677
|
});
|
|
6644
6678
|
const model = {
|
|
6645
|
-
priorityFloorGasLimit:
|
|
6679
|
+
priorityFloorGasLimit: applyPriorityL2GasLimitBuffer({
|
|
6680
|
+
chainIdL2: input.ctx.chainIdL2,
|
|
6681
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
6682
|
+
})
|
|
6646
6683
|
};
|
|
6647
6684
|
if (isFirstBridge || input.ctx.resolvedToken.l2.toLowerCase() === ZERO_L2_TOKEN_ADDRESS2) {
|
|
6648
6685
|
model.undeployedGasLimit = derivePriorityBodyGasEstimateCap({
|
|
@@ -6864,7 +6901,10 @@ async function getPriorityGasModel2(input) {
|
|
|
6864
6901
|
gasPerPubdata: input.ctx.gasPerPubdata
|
|
6865
6902
|
});
|
|
6866
6903
|
const model = {
|
|
6867
|
-
priorityFloorGasLimit:
|
|
6904
|
+
priorityFloorGasLimit: applyPriorityL2GasLimitBuffer({
|
|
6905
|
+
chainIdL2: input.ctx.chainIdL2,
|
|
6906
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
6907
|
+
})
|
|
6868
6908
|
};
|
|
6869
6909
|
if (input.ctx.resolvedToken.l2.toLowerCase() === ZERO_L2_TOKEN_ADDRESS3) {
|
|
6870
6910
|
model.undeployedGasLimit = derivePriorityBodyGasEstimateCap({
|
|
@@ -7081,7 +7121,10 @@ function routeErc20Base() {
|
|
|
7081
7121
|
l2Calldata,
|
|
7082
7122
|
gasPerPubdata: ctx.gasPerPubdata
|
|
7083
7123
|
});
|
|
7084
|
-
const quotedL2GasLimit = ctx.l2GasLimit ??
|
|
7124
|
+
const quotedL2GasLimit = ctx.l2GasLimit ?? applyPriorityL2GasLimitBuffer({
|
|
7125
|
+
chainIdL2: ctx.chainIdL2,
|
|
7126
|
+
gasLimit: priorityFloorBreakdown.derivedL2GasLimit
|
|
7127
|
+
});
|
|
7085
7128
|
const l2GasParams = await quoteL2Gas2({
|
|
7086
7129
|
ctx,
|
|
7087
7130
|
route: "erc20-base",
|
|
@@ -7507,6 +7550,8 @@ function createDepositsResource(client, tokens, contracts) {
|
|
|
7507
7550
|
async () => {
|
|
7508
7551
|
const plan = await prepare(p);
|
|
7509
7552
|
const stepHashes = {};
|
|
7553
|
+
const { chainId } = await client.l2.getNetwork();
|
|
7554
|
+
const chainIdL2 = BigInt(chainId);
|
|
7510
7555
|
const managed = new ethers.NonceManager(client.signer);
|
|
7511
7556
|
const from = await managed.getAddress();
|
|
7512
7557
|
let next;
|
|
@@ -7552,8 +7597,14 @@ function createDepositsResource(client, tokens, contracts) {
|
|
|
7552
7597
|
}
|
|
7553
7598
|
if (!p.l1TxOverrides?.gasLimit) {
|
|
7554
7599
|
try {
|
|
7600
|
+
const preparedGasLimit = step.tx.gasLimit != null ? BigInt(step.tx.gasLimit.toString()) : void 0;
|
|
7555
7601
|
const est = await client.l1.estimateGas(step.tx);
|
|
7556
|
-
step.tx.gasLimit =
|
|
7602
|
+
step.tx.gasLimit = resolveCreateDepositL1GasLimit({
|
|
7603
|
+
chainIdL2,
|
|
7604
|
+
stepKey: step.key,
|
|
7605
|
+
preparedGasLimit,
|
|
7606
|
+
estimatedGasLimit: BigInt(est)
|
|
7607
|
+
});
|
|
7557
7608
|
} catch {
|
|
7558
7609
|
}
|
|
7559
7610
|
}
|
|
@@ -9172,26 +9223,30 @@ function routeDirect() {
|
|
|
9172
9223
|
}
|
|
9173
9224
|
};
|
|
9174
9225
|
}
|
|
9226
|
+
|
|
9227
|
+
// src/core/resources/interop/protocol.ts
|
|
9175
9228
|
var MIN_INTEROP_PROTOCOL = 31;
|
|
9229
|
+
function assertProtocolVersion(chainId, protocolVersion) {
|
|
9230
|
+
if (protocolVersion[1] < MIN_INTEROP_PROTOCOL) {
|
|
9231
|
+
throw createError("VALIDATION", {
|
|
9232
|
+
resource: "interop",
|
|
9233
|
+
operation: OP_INTEROP.context.protocolVersion,
|
|
9234
|
+
message: `Interop requires protocol version 31.0+. Found: ${protocolVersion[1]}.${protocolVersion[2]} for chain: ${chainId}.`,
|
|
9235
|
+
context: {
|
|
9236
|
+
chainId,
|
|
9237
|
+
requiredMinor: MIN_INTEROP_PROTOCOL,
|
|
9238
|
+
semver: protocolVersion
|
|
9239
|
+
}
|
|
9240
|
+
});
|
|
9241
|
+
}
|
|
9242
|
+
}
|
|
9243
|
+
|
|
9244
|
+
// src/adapters/ethers/resources/interop/context.ts
|
|
9176
9245
|
async function assertInteropProtocolVersion(client, srcChainId, dstChainId) {
|
|
9177
9246
|
const [srcProtocolVersion, dstProtocolVersion] = await Promise.all([
|
|
9178
9247
|
client.getProtocolVersion(srcChainId),
|
|
9179
9248
|
client.getProtocolVersion(dstChainId)
|
|
9180
9249
|
]);
|
|
9181
|
-
const assertProtocolVersion = (chainId, protocolVersion) => {
|
|
9182
|
-
if (protocolVersion[1] < MIN_INTEROP_PROTOCOL) {
|
|
9183
|
-
throw createError("VALIDATION", {
|
|
9184
|
-
resource: "interop",
|
|
9185
|
-
operation: OP_INTEROP.context.protocolVersion,
|
|
9186
|
-
message: `Interop requires protocol version 31.0+. Found: ${protocolVersion[1]}.${protocolVersion[2]} for chain: ${chainId}.`,
|
|
9187
|
-
context: {
|
|
9188
|
-
chainId,
|
|
9189
|
-
requiredMinor: MIN_INTEROP_PROTOCOL,
|
|
9190
|
-
semver: protocolVersion
|
|
9191
|
-
}
|
|
9192
|
-
});
|
|
9193
|
-
}
|
|
9194
|
-
};
|
|
9195
9250
|
assertProtocolVersion(srcChainId, srcProtocolVersion);
|
|
9196
9251
|
assertProtocolVersion(dstChainId, dstProtocolVersion);
|
|
9197
9252
|
}
|
|
@@ -9262,7 +9317,14 @@ function parseMaxBlockRangeLimit(error) {
|
|
|
9262
9317
|
async function getTxReceipt(provider, txHash) {
|
|
9263
9318
|
const receipt = await wrap3(
|
|
9264
9319
|
OP_INTEROP.svc.status.sourceReceipt,
|
|
9265
|
-
() =>
|
|
9320
|
+
async () => {
|
|
9321
|
+
try {
|
|
9322
|
+
return await provider.getTransactionReceipt(txHash);
|
|
9323
|
+
} catch (error) {
|
|
9324
|
+
if (isReceiptNotFound(error)) return null;
|
|
9325
|
+
throw error;
|
|
9326
|
+
}
|
|
9327
|
+
},
|
|
9266
9328
|
{
|
|
9267
9329
|
ctx: { where: "l2.getTransactionReceipt", l2SrcTxHash: txHash },
|
|
9268
9330
|
message: "Failed to fetch source L2 receipt for interop tx."
|
|
@@ -9792,6 +9854,31 @@ function resolveChainRef(ref) {
|
|
|
9792
9854
|
return typeof ref === "string" ? new ethers.JsonRpcProvider(ref) : ref;
|
|
9793
9855
|
}
|
|
9794
9856
|
|
|
9857
|
+
// src/adapters/ethers/resources/interop/services/gas.ts
|
|
9858
|
+
async function quoteStepsL2Fee(steps, ctx) {
|
|
9859
|
+
if (steps.length === 0) return 0n;
|
|
9860
|
+
const estimator = ethersToGasEstimator(ctx.client.l2);
|
|
9861
|
+
let maxFeePerGas;
|
|
9862
|
+
try {
|
|
9863
|
+
const fees = await estimator.estimateFeesPerGas();
|
|
9864
|
+
maxFeePerGas = fees.maxFeePerGas ?? fees.gasPrice ?? await estimator.getGasPrice();
|
|
9865
|
+
} catch {
|
|
9866
|
+
return void 0;
|
|
9867
|
+
}
|
|
9868
|
+
let total = 0n;
|
|
9869
|
+
for (const step of steps) {
|
|
9870
|
+
try {
|
|
9871
|
+
const coreTx = toCoreTx({ ...step.tx, from: ctx.sender });
|
|
9872
|
+
const est = await estimator.estimateGas(coreTx);
|
|
9873
|
+
const buffered = BigInt(est) * (100n + BUFFER) / 100n;
|
|
9874
|
+
total += buffered * maxFeePerGas;
|
|
9875
|
+
} catch {
|
|
9876
|
+
return void 0;
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9879
|
+
return total;
|
|
9880
|
+
}
|
|
9881
|
+
|
|
9795
9882
|
// src/adapters/ethers/resources/interop/index.ts
|
|
9796
9883
|
var { wrap: wrap6, toResult: toResult2 } = createErrorHandlers("interop");
|
|
9797
9884
|
var ROUTES3 = {
|
|
@@ -9848,12 +9935,14 @@ function createInteropResource(client, config, tokens, contracts, attributes) {
|
|
|
9848
9935
|
ctx: { where: `routes.${route}.build` }
|
|
9849
9936
|
}
|
|
9850
9937
|
);
|
|
9938
|
+
const l2Fee = await quoteStepsL2Fee(steps, ctx).catch(() => void 0);
|
|
9851
9939
|
const summary = {
|
|
9852
9940
|
route,
|
|
9853
9941
|
approvalsNeeded: approvals,
|
|
9854
9942
|
totalActionValue: quoteExtras.totalActionValue,
|
|
9855
9943
|
bridgedTokenTotal: quoteExtras.bridgedTokenTotal,
|
|
9856
|
-
interopFee
|
|
9944
|
+
interopFee,
|
|
9945
|
+
l2Fee
|
|
9857
9946
|
};
|
|
9858
9947
|
return { plan: { route, summary, steps }, ctx };
|
|
9859
9948
|
}
|