@matterlabs/zksync-js 0.0.11 → 0.0.13
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/README.md +13 -0
- package/dist/adapters/ethers/client.cjs +722 -4
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.js +6 -6
- package/dist/adapters/ethers/index.cjs +774 -45
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +9 -9
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +4 -4
- package/dist/adapters/ethers/sdk.cjs +772 -41
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +7 -7
- package/dist/adapters/viem/client.cjs +2 -4
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.js +6 -6
- package/dist/adapters/viem/index.cjs +38 -33
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +9 -9
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +4 -4
- package/dist/adapters/viem/sdk.cjs +36 -29
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +7 -7
- package/dist/{chunk-EWBYKU4G.js → chunk-2RIARDXZ.js} +4 -4
- package/dist/{chunk-USXSAFYA.js → chunk-4S4XDA4N.js} +4 -6
- package/dist/{chunk-H3BPVVMN.js → chunk-53MC5BR2.js} +1 -1
- package/dist/{chunk-IQVH7YZT.js → chunk-5L6EYUJB.js} +2 -2
- package/dist/{chunk-QUI3J42E.js → chunk-5R7L5NM5.js} +2 -2
- package/dist/{chunk-ZVHFVUDE.js → chunk-E3KP7XCG.js} +1 -1
- package/dist/{chunk-CCUAGJ6K.js → chunk-EDWBCPO3.js} +40 -33
- package/dist/{chunk-6IT5PEEN.js → chunk-HI64OOAR.js} +1 -1
- package/dist/{chunk-TL26ZONW.js → chunk-JHO2UQ5F.js} +56 -45
- package/dist/{chunk-C3AGOEHR.js → chunk-QQ2OR434.js} +1 -1
- package/dist/{chunk-FXSFLZ6D.js → chunk-R5WRFPK2.js} +4 -4
- package/dist/{chunk-QFEYV4O3.js → chunk-RI73VJSH.js} +716 -2
- package/dist/{chunk-N4PR5SVB.js → chunk-UDBRUBEK.js} +10 -2
- package/dist/core/abi.d.ts +2 -0
- package/dist/core/constants.cjs +1 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +716 -4
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +5 -5
- package/dist/core/internal/abis/IInteropErrors.d.ts +197 -0
- package/dist/core/internal/abis/IL1ContractErrors.d.ts +1021 -0
- package/dist/core/rpc/types.d.ts +1 -1
- package/dist/index.cjs +717 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createViemSdk } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
1
|
+
export { createViemSdk } from '../../chunk-EDWBCPO3.js';
|
|
2
|
+
import '../../chunk-5L6EYUJB.js';
|
|
3
|
+
import '../../chunk-E3KP7XCG.js';
|
|
4
|
+
import '../../chunk-5R7L5NM5.js';
|
|
5
|
+
import '../../chunk-53MC5BR2.js';
|
|
6
|
+
import '../../chunk-RI73VJSH.js';
|
|
7
|
+
import '../../chunk-QQ2OR434.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createErrorHandlers } from './chunk-
|
|
2
|
-
import { createZksRpc, makeTransportFromViem } from './chunk-
|
|
3
|
-
import { OP_CLIENT, IBridgehub_default, IL1AssetRouter_default, IL1Nullifier_default, IBaseToken_default, L2NativeTokenVault_default, IL2AssetRouter_default, L1NativeTokenVault_default } from './chunk-
|
|
4
|
-
import { L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_BASE_TOKEN_ADDRESS } from './chunk-
|
|
1
|
+
import { createErrorHandlers } from './chunk-5R7L5NM5.js';
|
|
2
|
+
import { createZksRpc, makeTransportFromViem } from './chunk-4S4XDA4N.js';
|
|
3
|
+
import { OP_CLIENT, IBridgehub_default, IL1AssetRouter_default, IL1Nullifier_default, IBaseToken_default, L2NativeTokenVault_default, IL2AssetRouter_default, L1NativeTokenVault_default } from './chunk-RI73VJSH.js';
|
|
4
|
+
import { L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_BASE_TOKEN_ADDRESS } from './chunk-QQ2OR434.js';
|
|
5
5
|
import { getContract, createWalletClient } from 'viem';
|
|
6
6
|
|
|
7
7
|
// src/adapters/viem/rpc.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createError, isBigint, isNumber, isZKsyncError, shapeCause } from './chunk-
|
|
2
|
-
import { __export } from './chunk-
|
|
1
|
+
import { createError, isBigint, isNumber, isZKsyncError, shapeCause } from './chunk-RI73VJSH.js';
|
|
2
|
+
import { __export } from './chunk-QQ2OR434.js';
|
|
3
3
|
|
|
4
4
|
// src/core/rpc/zks.ts
|
|
5
5
|
var zks_exports = {};
|
|
@@ -87,8 +87,8 @@ function ensureHex(value, field, context) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
function ensureNumber(value, field, opts) {
|
|
90
|
-
const operation = opts?.operation
|
|
91
|
-
const messagePrefix = opts?.messagePrefix
|
|
90
|
+
const operation = opts?.operation;
|
|
91
|
+
const messagePrefix = opts?.messagePrefix;
|
|
92
92
|
if (isNumber(value)) return value;
|
|
93
93
|
if (isBigint(value)) return Number(value);
|
|
94
94
|
if (typeof value === "string" && value.trim() !== "") {
|
|
@@ -226,7 +226,6 @@ function normalizeGenesis(raw) {
|
|
|
226
226
|
context: { valueType: typeof contractsRaw }
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
|
-
const executionVersion = ensureNumber(record["execution_version"], "execution_version");
|
|
230
229
|
const genesisRoot = ensureHex(record["genesis_root"], "genesis_root", {});
|
|
231
230
|
const initialContracts = contractsRaw.map(
|
|
232
231
|
(entry, index) => normalizeContractTuple(entry, index)
|
|
@@ -235,7 +234,6 @@ function normalizeGenesis(raw) {
|
|
|
235
234
|
return {
|
|
236
235
|
initialContracts,
|
|
237
236
|
additionalStorage,
|
|
238
|
-
executionVersion,
|
|
239
237
|
genesisRoot
|
|
240
238
|
};
|
|
241
239
|
} catch (e) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IBridgehub_default } from './chunk-
|
|
2
|
-
import { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, TX_MEMORY_OVERHEAD_GAS, TX_OVERHEAD_GAS } from './chunk-
|
|
1
|
+
import { IBridgehub_default } from './chunk-RI73VJSH.js';
|
|
2
|
+
import { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, TX_MEMORY_OVERHEAD_GAS, TX_OVERHEAD_GAS } from './chunk-QQ2OR434.js';
|
|
3
3
|
|
|
4
4
|
// src/core/codec/ntv.ts
|
|
5
5
|
function createNTVCodec(deps) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createErrorOps, REVERT_TO_READINESS } from './chunk-
|
|
2
|
-
import { IL1Nullifier_default, IERC20_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default } from './chunk-
|
|
1
|
+
import { createErrorOps, REVERT_TO_READINESS } from './chunk-53MC5BR2.js';
|
|
2
|
+
import { IL1Nullifier_default, IERC20_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default } from './chunk-RI73VJSH.js';
|
|
3
3
|
import { decodeErrorResult } from 'viem';
|
|
4
4
|
|
|
5
5
|
var ERROR_ABIS = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L2_BASE_TOKEN_ADDRESS, TOPIC_L1_MESSAGE_SENT_NEW, TOPIC_L1_MESSAGE_SENT_LEG, L1_MESSENGER_ADDRESS, ETH_ADDRESS, L2_ASSET_ROUTER_ADDRESS } from './chunk-
|
|
1
|
+
import { L2_BASE_TOKEN_ADDRESS, TOPIC_L1_MESSAGE_SENT_NEW, TOPIC_L1_MESSAGE_SENT_LEG, L1_MESSENGER_ADDRESS, ETH_ADDRESS, L2_ASSET_ROUTER_ADDRESS } from './chunk-QQ2OR434.js';
|
|
2
2
|
|
|
3
3
|
// src/core/resources/withdrawals/route.ts
|
|
4
4
|
function normalizeTokenForRouting(token) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createNTVCodec, toGasOverrides, buildFeeBreakdown, quoteL2Gas, quoteL1Gas, quoteL2Gas2 } from './chunk-
|
|
2
|
-
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-
|
|
3
|
-
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-
|
|
4
|
-
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, IBridgehub_default, isETH, normalizeAddrEq, L2NativeTokenVault_default, IL2AssetRouter_default, IBaseToken_default } from './chunk-
|
|
5
|
-
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS,
|
|
1
|
+
import { createNTVCodec, toGasOverrides, buildFeeBreakdown, quoteL2Gas, quoteL1Gas, quoteL2Gas2 } from './chunk-5L6EYUJB.js';
|
|
2
|
+
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-E3KP7XCG.js';
|
|
3
|
+
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-5R7L5NM5.js';
|
|
4
|
+
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, IBridgehub_default, isETH, normalizeAddrEq, L2NativeTokenVault_default, IL2AssetRouter_default, IBaseToken_default } from './chunk-RI73VJSH.js';
|
|
5
|
+
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, SAFE_L1_BRIDGE_GAS, FORMAL_ETH_ADDRESS } from './chunk-QQ2OR434.js';
|
|
6
6
|
import { keccak256, encodeAbiParameters, concat, decodeEventLog, decodeAbiParameters, encodeFunctionData, zeroAddress } from 'viem';
|
|
7
7
|
|
|
8
8
|
// src/adapters/viem/resources/deposits/context.ts
|
|
@@ -179,6 +179,7 @@ function viemToGasEstimator(client) {
|
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// src/adapters/viem/resources/deposits/services/gas.ts
|
|
182
|
+
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
182
183
|
async function quoteL1Gas2(input) {
|
|
183
184
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
184
185
|
const estimator = viemToGasEstimator(ctx.client.l1);
|
|
@@ -203,24 +204,24 @@ async function quoteL2Gas3(input) {
|
|
|
203
204
|
stateOverrides: input.stateOverrides
|
|
204
205
|
});
|
|
205
206
|
}
|
|
206
|
-
async function
|
|
207
|
-
const { ctx, l1Token } = input;
|
|
208
|
-
const
|
|
207
|
+
async function determineNonBaseL2Gas(input) {
|
|
208
|
+
const { ctx, l1Token, route } = input;
|
|
209
|
+
const fallbackQuote = () => quoteL2Gas3({
|
|
210
|
+
ctx,
|
|
211
|
+
route,
|
|
212
|
+
overrideGasLimit: DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT
|
|
213
|
+
});
|
|
209
214
|
if (ctx.l2GasLimit != null) {
|
|
210
215
|
return quoteL2Gas3({
|
|
211
216
|
ctx,
|
|
212
|
-
route
|
|
217
|
+
route,
|
|
213
218
|
overrideGasLimit: ctx.l2GasLimit
|
|
214
219
|
});
|
|
215
220
|
}
|
|
216
221
|
try {
|
|
217
|
-
const l2TokenAddress = ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).read.l2TokenAddress([l1Token]);
|
|
222
|
+
const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).read.l2TokenAddress([l1Token]));
|
|
218
223
|
if (l2TokenAddress === zeroAddress) {
|
|
219
|
-
return
|
|
220
|
-
ctx,
|
|
221
|
-
route: "erc20-nonbase",
|
|
222
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
223
|
-
});
|
|
224
|
+
return fallbackQuote();
|
|
224
225
|
}
|
|
225
226
|
const modelTx = {
|
|
226
227
|
to: input.modelTx?.to ?? ctx.sender,
|
|
@@ -230,26 +231,34 @@ async function determineErc20L2Gas(input) {
|
|
|
230
231
|
};
|
|
231
232
|
const gas = await quoteL2Gas3({
|
|
232
233
|
ctx,
|
|
233
|
-
route
|
|
234
|
+
route,
|
|
234
235
|
l2TxForModeling: modelTx
|
|
235
236
|
});
|
|
236
|
-
if (!gas) {
|
|
237
|
-
return
|
|
238
|
-
ctx,
|
|
239
|
-
route: "erc20-nonbase",
|
|
240
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
241
|
-
});
|
|
237
|
+
if (!gas || gas.gasLimit === 0n) {
|
|
238
|
+
return fallbackQuote();
|
|
242
239
|
}
|
|
243
240
|
return gas;
|
|
244
241
|
} catch (err) {
|
|
245
|
-
console.warn("Failed to determine
|
|
246
|
-
return
|
|
247
|
-
ctx,
|
|
248
|
-
route: "erc20-nonbase",
|
|
249
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
250
|
-
});
|
|
242
|
+
console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
|
|
243
|
+
return fallbackQuote();
|
|
251
244
|
}
|
|
252
245
|
}
|
|
246
|
+
async function determineErc20L2Gas(input) {
|
|
247
|
+
return determineNonBaseL2Gas({
|
|
248
|
+
...input,
|
|
249
|
+
route: "erc20-nonbase",
|
|
250
|
+
knownL2Token: input.ctx.resolvedToken?.l2
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
async function determineEthNonBaseL2Gas(input) {
|
|
254
|
+
return determineNonBaseL2Gas({
|
|
255
|
+
ctx: input.ctx,
|
|
256
|
+
route: "eth-nonbase",
|
|
257
|
+
l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
|
|
258
|
+
knownL2Token: input.ctx.resolvedToken?.l2,
|
|
259
|
+
modelTx: input.modelTx
|
|
260
|
+
});
|
|
261
|
+
}
|
|
253
262
|
|
|
254
263
|
// src/adapters/viem/resources/deposits/services/fee.ts
|
|
255
264
|
var { wrapAs } = createErrorHandlers("deposits");
|
|
@@ -648,11 +657,9 @@ function routeEthNonBase() {
|
|
|
648
657
|
data: "0x",
|
|
649
658
|
value: 0n
|
|
650
659
|
};
|
|
651
|
-
const l2Gas = await
|
|
660
|
+
const l2Gas = await determineEthNonBaseL2Gas({
|
|
652
661
|
ctx,
|
|
653
|
-
|
|
654
|
-
l2TxForModeling: l2TxModel,
|
|
655
|
-
overrideGasLimit: ctx.l2GasLimit
|
|
662
|
+
modelTx: l2TxModel
|
|
656
663
|
});
|
|
657
664
|
if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
|
|
658
665
|
const l2BaseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2Gas.gasLimit });
|
|
@@ -2018,7 +2025,7 @@ function createFinalizationServices(client) {
|
|
|
2018
2025
|
chainId: BigInt(chainId),
|
|
2019
2026
|
l2BatchNumber: proof.batchNumber,
|
|
2020
2027
|
l2MessageIndex: proof.id,
|
|
2021
|
-
l2Sender:
|
|
2028
|
+
l2Sender: parsed.to,
|
|
2022
2029
|
l2TxNumberInBatch: txIndex,
|
|
2023
2030
|
message,
|
|
2024
2031
|
merkleProof: proof.proof
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-
|
|
2
|
-
import { createNTVCodec, toGasOverrides, buildFeeBreakdown, quoteL2Gas, quoteL2BaseCost, quoteL1Gas, quoteL2Gas2 } from './chunk-
|
|
3
|
-
import { findL1MessageSentLog, messengerLogIndex, isL1MessageSentLog, pickWithdrawRoute } from './chunk-
|
|
4
|
-
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, OP_INTEROP, IInteropHandler_default, IERC7786Attributes_default, isBigint, isHash, IInteropCenter_default, sleep, isETH, normalizeAddrEq, isNumber, isAddress, isHash66Array, IInteropRootStorage_default, L2NativeTokenVault_default, assertNever } from './chunk-
|
|
5
|
-
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS,
|
|
1
|
+
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-UDBRUBEK.js';
|
|
2
|
+
import { createNTVCodec, toGasOverrides, buildFeeBreakdown, quoteL2Gas, quoteL2BaseCost, quoteL1Gas, quoteL2Gas2 } from './chunk-5L6EYUJB.js';
|
|
3
|
+
import { findL1MessageSentLog, messengerLogIndex, isL1MessageSentLog, pickWithdrawRoute } from './chunk-E3KP7XCG.js';
|
|
4
|
+
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, OP_INTEROP, IInteropHandler_default, IERC7786Attributes_default, isBigint, isHash, IInteropCenter_default, sleep, isETH, normalizeAddrEq, isNumber, isAddress, isHash66Array, IInteropRootStorage_default, L2NativeTokenVault_default, assertNever } from './chunk-RI73VJSH.js';
|
|
5
|
+
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_INTEROP_CENTER_ADDRESS, BUNDLE_IDENTIFIER, L2_INTEROP_ROOT_STORAGE_ADDRESS, SAFE_L1_BRIDGE_GAS, FORMAL_ETH_ADDRESS } from './chunk-QQ2OR434.js';
|
|
6
6
|
import { Interface, AbiCoder, ethers, getBytes, Contract, NonceManager, JsonRpcProvider, isError, getAddress, concat, hexlify, toBeArray, toBeHex } from 'ethers';
|
|
7
7
|
|
|
8
8
|
var I_BRIDGEHUB = new Interface([
|
|
@@ -237,6 +237,8 @@ async function quoteL2BaseCost2(input) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// src/adapters/ethers/resources/deposits/services/gas.ts
|
|
240
|
+
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
241
|
+
var ZERO_L2_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
240
242
|
async function quoteL1Gas2(input) {
|
|
241
243
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
242
244
|
const estimator = ethersToGasEstimator(ctx.client.l1);
|
|
@@ -260,24 +262,24 @@ async function quoteL2Gas3(input) {
|
|
|
260
262
|
stateOverrides: input.stateOverrides
|
|
261
263
|
});
|
|
262
264
|
}
|
|
263
|
-
async function
|
|
264
|
-
const { ctx, l1Token } = input;
|
|
265
|
-
const
|
|
265
|
+
async function determineNonBaseL2Gas(input) {
|
|
266
|
+
const { ctx, l1Token, route } = input;
|
|
267
|
+
const fallbackQuote = () => quoteL2Gas3({
|
|
268
|
+
ctx,
|
|
269
|
+
route,
|
|
270
|
+
overrideGasLimit: DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT
|
|
271
|
+
});
|
|
266
272
|
if (ctx.l2GasLimit != null) {
|
|
267
273
|
return quoteL2Gas3({
|
|
268
274
|
ctx,
|
|
269
|
-
route
|
|
275
|
+
route,
|
|
270
276
|
overrideGasLimit: ctx.l2GasLimit
|
|
271
277
|
});
|
|
272
278
|
}
|
|
273
279
|
try {
|
|
274
|
-
const l2TokenAddress = ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).l2TokenAddress(l1Token);
|
|
275
|
-
if (l2TokenAddress ===
|
|
276
|
-
return
|
|
277
|
-
ctx,
|
|
278
|
-
route: "erc20-nonbase",
|
|
279
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
280
|
-
});
|
|
280
|
+
const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).l2TokenAddress(l1Token));
|
|
281
|
+
if (l2TokenAddress === ZERO_L2_TOKEN_ADDRESS) {
|
|
282
|
+
return fallbackQuote();
|
|
281
283
|
}
|
|
282
284
|
const modelTx = {
|
|
283
285
|
to: input.modelTx?.to ?? ctx.sender,
|
|
@@ -287,26 +289,34 @@ async function determineErc20L2Gas(input) {
|
|
|
287
289
|
};
|
|
288
290
|
const gas = await quoteL2Gas3({
|
|
289
291
|
ctx,
|
|
290
|
-
route
|
|
292
|
+
route,
|
|
291
293
|
l2TxForModeling: modelTx
|
|
292
294
|
});
|
|
293
|
-
if (!gas) {
|
|
294
|
-
return
|
|
295
|
-
ctx,
|
|
296
|
-
route: "erc20-nonbase",
|
|
297
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
298
|
-
});
|
|
295
|
+
if (!gas || gas.gasLimit === 0n) {
|
|
296
|
+
return fallbackQuote();
|
|
299
297
|
}
|
|
300
298
|
return gas;
|
|
301
299
|
} catch (err) {
|
|
302
|
-
console.warn("Failed to determine
|
|
303
|
-
return
|
|
304
|
-
ctx,
|
|
305
|
-
route: "erc20-nonbase",
|
|
306
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
307
|
-
});
|
|
300
|
+
console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
|
|
301
|
+
return fallbackQuote();
|
|
308
302
|
}
|
|
309
303
|
}
|
|
304
|
+
async function determineErc20L2Gas(input) {
|
|
305
|
+
return determineNonBaseL2Gas({
|
|
306
|
+
...input,
|
|
307
|
+
route: "erc20-nonbase",
|
|
308
|
+
knownL2Token: input.ctx.resolvedToken?.l2
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
async function determineEthNonBaseL2Gas(input) {
|
|
312
|
+
return determineNonBaseL2Gas({
|
|
313
|
+
ctx: input.ctx,
|
|
314
|
+
route: "eth-nonbase",
|
|
315
|
+
l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
|
|
316
|
+
knownL2Token: input.ctx.resolvedToken?.l2,
|
|
317
|
+
modelTx: input.modelTx
|
|
318
|
+
});
|
|
319
|
+
}
|
|
310
320
|
|
|
311
321
|
// src/adapters/ethers/resources/deposits/routes/eth.ts
|
|
312
322
|
function routeEthDirect() {
|
|
@@ -598,11 +608,9 @@ function routeEthNonBase() {
|
|
|
598
608
|
data: "0x",
|
|
599
609
|
value: 0n
|
|
600
610
|
};
|
|
601
|
-
const l2GasParams = await
|
|
611
|
+
const l2GasParams = await determineEthNonBaseL2Gas({
|
|
602
612
|
ctx,
|
|
603
|
-
|
|
604
|
-
l2TxForModeling: l2TxModel,
|
|
605
|
-
overrideGasLimit: ctx.l2GasLimit
|
|
613
|
+
modelTx: l2TxModel
|
|
606
614
|
});
|
|
607
615
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
608
616
|
const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
|
|
@@ -622,7 +630,7 @@ function routeEthNonBase() {
|
|
|
622
630
|
if (allowance < mintValue) {
|
|
623
631
|
approvals.push({ token: baseToken, spender: ctx.l1AssetRouter, amount: mintValue });
|
|
624
632
|
steps.push({
|
|
625
|
-
key: `approve:${baseToken}`,
|
|
633
|
+
key: `approve:${baseToken}:${ctx.l1AssetRouter}`,
|
|
626
634
|
kind: "approve",
|
|
627
635
|
description: `Approve base token for fees (mintValue)`,
|
|
628
636
|
tx: {
|
|
@@ -1697,7 +1705,7 @@ function createFinalizationServices(client) {
|
|
|
1697
1705
|
chainId: BigInt(chainId),
|
|
1698
1706
|
l2BatchNumber: proof.batchNumber,
|
|
1699
1707
|
l2MessageIndex: proof.id,
|
|
1700
|
-
l2Sender:
|
|
1708
|
+
l2Sender: parsed.to,
|
|
1701
1709
|
l2TxNumberInBatch: txIndex,
|
|
1702
1710
|
message,
|
|
1703
1711
|
merkleProof: proof.proof
|
|
@@ -3415,17 +3423,20 @@ function createInteropResource(client, tokens, contracts, attributes) {
|
|
|
3415
3423
|
}
|
|
3416
3424
|
} catch (e) {
|
|
3417
3425
|
if (isZKsyncError(e)) throw e;
|
|
3418
|
-
throw
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
+
throw toZKsyncError(
|
|
3427
|
+
"EXECUTION",
|
|
3428
|
+
{
|
|
3429
|
+
resource: "interop",
|
|
3430
|
+
operation: "interop.create.sendTransaction",
|
|
3431
|
+
message: "Failed to send or confirm an interop transaction step.",
|
|
3432
|
+
context: {
|
|
3433
|
+
step: step.key,
|
|
3434
|
+
txHash: hash,
|
|
3435
|
+
nonce: Number(step.tx.nonce ?? -1)
|
|
3436
|
+
}
|
|
3426
3437
|
},
|
|
3427
|
-
|
|
3428
|
-
|
|
3438
|
+
e
|
|
3439
|
+
);
|
|
3429
3440
|
}
|
|
3430
3441
|
}
|
|
3431
3442
|
const last = Object.values(stepHashes).pop();
|
|
@@ -60,7 +60,7 @@ var TX_OVERHEAD_GAS = 10000n;
|
|
|
60
60
|
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
61
61
|
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
62
62
|
var DEFAULT_ABI_BYTES = 400n;
|
|
63
|
-
var SAFE_L1_BRIDGE_GAS =
|
|
63
|
+
var SAFE_L1_BRIDGE_GAS = 800000n;
|
|
64
64
|
var L1_FEE_ESTIMATION_COEF_NUMERATOR = 12;
|
|
65
65
|
var L1_FEE_ESTIMATION_COEF_DENOMINATOR = 10;
|
|
66
66
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createErrorHandlers } from './chunk-
|
|
2
|
-
import { createZksRpc, makeTransportFromEthers } from './chunk-
|
|
3
|
-
import { createError, OP_CLIENT, IBridgehub_default, IL1AssetRouter_default, IL1Nullifier_default, L2MessageVerification_default, IInteropHandler_default, IInteropCenter_default, IBaseToken_default, L2NativeTokenVault_default, IL2AssetRouter_default, L1NativeTokenVault_default, OP_DEPOSITS } from './chunk-
|
|
4
|
-
import { L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_INTEROP_CENTER_ADDRESS, L2_INTEROP_HANDLER_ADDRESS, L2_MESSAGE_VERIFICATION_ADDRESS, FORMAL_ETH_ADDRESS } from './chunk-
|
|
1
|
+
import { createErrorHandlers } from './chunk-UDBRUBEK.js';
|
|
2
|
+
import { createZksRpc, makeTransportFromEthers } from './chunk-4S4XDA4N.js';
|
|
3
|
+
import { createError, OP_CLIENT, IBridgehub_default, IL1AssetRouter_default, IL1Nullifier_default, L2MessageVerification_default, IInteropHandler_default, IInteropCenter_default, IBaseToken_default, L2NativeTokenVault_default, IL2AssetRouter_default, L1NativeTokenVault_default, OP_DEPOSITS } from './chunk-RI73VJSH.js';
|
|
4
|
+
import { L2_ASSET_ROUTER_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_INTEROP_CENTER_ADDRESS, L2_INTEROP_HANDLER_ADDRESS, L2_MESSAGE_VERIFICATION_ADDRESS, FORMAL_ETH_ADDRESS } from './chunk-QQ2OR434.js';
|
|
5
5
|
import { BrowserProvider, Interface, Contract } from 'ethers';
|
|
6
6
|
|
|
7
7
|
// src/adapters/ethers/rpc.ts
|