@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,9 +1,9 @@
|
|
|
1
|
-
export { buildDirectRequestStruct, createContractsResource, createDepositsResource, createFinalizationServices, createTokensResource, createViemSdk, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
export { createViemClient as createClient, createViemClient } from '../../chunk-
|
|
5
|
-
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
9
|
-
import '../../chunk-
|
|
1
|
+
export { buildDirectRequestStruct, createContractsResource, createDepositsResource, createFinalizationServices, createTokensResource, createViemSdk, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-EDWBCPO3.js';
|
|
2
|
+
import '../../chunk-5L6EYUJB.js';
|
|
3
|
+
import '../../chunk-E3KP7XCG.js';
|
|
4
|
+
export { createViemClient as createClient, createViemClient } from '../../chunk-2RIARDXZ.js';
|
|
5
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-5R7L5NM5.js';
|
|
6
|
+
import '../../chunk-4S4XDA4N.js';
|
|
7
|
+
import '../../chunk-53MC5BR2.js';
|
|
8
|
+
import '../../chunk-RI73VJSH.js';
|
|
9
|
+
import '../../chunk-QQ2OR434.js';
|
|
@@ -26,12 +26,12 @@ export declare function quoteL1Gas(input: QuoteL1GasInput): Promise<GasQuote | u
|
|
|
26
26
|
* Quote L2 gas for an L2 execution.
|
|
27
27
|
*/
|
|
28
28
|
export declare function quoteL2Gas(input: QuoteL2GasInput): Promise<GasQuote | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
* ERC20 deposits have an extra edge case:
|
|
31
|
-
* if the token is not deployed on L2, the deposit includes deployment cost.
|
|
32
|
-
*/
|
|
33
29
|
export declare function determineErc20L2Gas(input: {
|
|
34
30
|
ctx: BuildCtx;
|
|
35
31
|
l1Token: Address;
|
|
36
32
|
modelTx?: TransactionRequest;
|
|
37
33
|
}): Promise<GasQuote | undefined>;
|
|
34
|
+
export declare function determineEthNonBaseL2Gas(input: {
|
|
35
|
+
ctx: BuildCtx;
|
|
36
|
+
modelTx?: TransactionRequest;
|
|
37
|
+
}): Promise<GasQuote | undefined>;
|
|
@@ -3709,7 +3709,7 @@ var TX_OVERHEAD_GAS = 10000n;
|
|
|
3709
3709
|
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
3710
3710
|
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
3711
3711
|
var DEFAULT_ABI_BYTES = 400n;
|
|
3712
|
-
var SAFE_L1_BRIDGE_GAS =
|
|
3712
|
+
var SAFE_L1_BRIDGE_GAS = 800000n;
|
|
3713
3713
|
|
|
3714
3714
|
// src/adapters/viem/resources/utils.ts
|
|
3715
3715
|
function encodeSecondBridgeArgs(token, amount, l2Receiver) {
|
|
@@ -4453,6 +4453,7 @@ function viemToGasEstimator(client) {
|
|
|
4453
4453
|
}
|
|
4454
4454
|
|
|
4455
4455
|
// src/adapters/viem/resources/deposits/services/gas.ts
|
|
4456
|
+
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
4456
4457
|
async function quoteL1Gas2(input) {
|
|
4457
4458
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
4458
4459
|
const estimator = viemToGasEstimator(ctx.client.l1);
|
|
@@ -4477,24 +4478,24 @@ async function quoteL2Gas2(input) {
|
|
|
4477
4478
|
stateOverrides: input.stateOverrides
|
|
4478
4479
|
});
|
|
4479
4480
|
}
|
|
4480
|
-
async function
|
|
4481
|
-
const { ctx, l1Token } = input;
|
|
4482
|
-
const
|
|
4481
|
+
async function determineNonBaseL2Gas(input) {
|
|
4482
|
+
const { ctx, l1Token, route } = input;
|
|
4483
|
+
const fallbackQuote = () => quoteL2Gas2({
|
|
4484
|
+
ctx,
|
|
4485
|
+
route,
|
|
4486
|
+
overrideGasLimit: DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT
|
|
4487
|
+
});
|
|
4483
4488
|
if (ctx.l2GasLimit != null) {
|
|
4484
4489
|
return quoteL2Gas2({
|
|
4485
4490
|
ctx,
|
|
4486
|
-
route
|
|
4491
|
+
route,
|
|
4487
4492
|
overrideGasLimit: ctx.l2GasLimit
|
|
4488
4493
|
});
|
|
4489
4494
|
}
|
|
4490
4495
|
try {
|
|
4491
|
-
const l2TokenAddress = ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).read.l2TokenAddress([l1Token]);
|
|
4496
|
+
const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).read.l2TokenAddress([l1Token]));
|
|
4492
4497
|
if (l2TokenAddress === viem.zeroAddress) {
|
|
4493
|
-
return
|
|
4494
|
-
ctx,
|
|
4495
|
-
route: "erc20-nonbase",
|
|
4496
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
4497
|
-
});
|
|
4498
|
+
return fallbackQuote();
|
|
4498
4499
|
}
|
|
4499
4500
|
const modelTx = {
|
|
4500
4501
|
to: input.modelTx?.to ?? ctx.sender,
|
|
@@ -4504,26 +4505,34 @@ async function determineErc20L2Gas(input) {
|
|
|
4504
4505
|
};
|
|
4505
4506
|
const gas = await quoteL2Gas2({
|
|
4506
4507
|
ctx,
|
|
4507
|
-
route
|
|
4508
|
+
route,
|
|
4508
4509
|
l2TxForModeling: modelTx
|
|
4509
4510
|
});
|
|
4510
|
-
if (!gas) {
|
|
4511
|
-
return
|
|
4512
|
-
ctx,
|
|
4513
|
-
route: "erc20-nonbase",
|
|
4514
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
4515
|
-
});
|
|
4511
|
+
if (!gas || gas.gasLimit === 0n) {
|
|
4512
|
+
return fallbackQuote();
|
|
4516
4513
|
}
|
|
4517
4514
|
return gas;
|
|
4518
4515
|
} catch (err) {
|
|
4519
|
-
console.warn("Failed to determine
|
|
4520
|
-
return
|
|
4521
|
-
ctx,
|
|
4522
|
-
route: "erc20-nonbase",
|
|
4523
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
4524
|
-
});
|
|
4516
|
+
console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
|
|
4517
|
+
return fallbackQuote();
|
|
4525
4518
|
}
|
|
4526
4519
|
}
|
|
4520
|
+
async function determineErc20L2Gas(input) {
|
|
4521
|
+
return determineNonBaseL2Gas({
|
|
4522
|
+
...input,
|
|
4523
|
+
route: "erc20-nonbase",
|
|
4524
|
+
knownL2Token: input.ctx.resolvedToken?.l2
|
|
4525
|
+
});
|
|
4526
|
+
}
|
|
4527
|
+
async function determineEthNonBaseL2Gas(input) {
|
|
4528
|
+
return determineNonBaseL2Gas({
|
|
4529
|
+
ctx: input.ctx,
|
|
4530
|
+
route: "eth-nonbase",
|
|
4531
|
+
l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
|
|
4532
|
+
knownL2Token: input.ctx.resolvedToken?.l2,
|
|
4533
|
+
modelTx: input.modelTx
|
|
4534
|
+
});
|
|
4535
|
+
}
|
|
4527
4536
|
|
|
4528
4537
|
// src/adapters/viem/resources/deposits/services/fee.ts
|
|
4529
4538
|
var { wrapAs } = createErrorHandlers("deposits");
|
|
@@ -4950,11 +4959,9 @@ function routeEthNonBase() {
|
|
|
4950
4959
|
data: "0x",
|
|
4951
4960
|
value: 0n
|
|
4952
4961
|
};
|
|
4953
|
-
const l2Gas = await
|
|
4962
|
+
const l2Gas = await determineEthNonBaseL2Gas({
|
|
4954
4963
|
ctx,
|
|
4955
|
-
|
|
4956
|
-
l2TxForModeling: l2TxModel,
|
|
4957
|
-
overrideGasLimit: ctx.l2GasLimit
|
|
4964
|
+
modelTx: l2TxModel
|
|
4958
4965
|
});
|
|
4959
4966
|
if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
|
|
4960
4967
|
const l2BaseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2Gas.gasLimit });
|
|
@@ -6445,7 +6452,7 @@ function createFinalizationServices(client) {
|
|
|
6445
6452
|
chainId: BigInt(chainId),
|
|
6446
6453
|
l2BatchNumber: proof.batchNumber,
|
|
6447
6454
|
l2MessageIndex: proof.id,
|
|
6448
|
-
l2Sender:
|
|
6455
|
+
l2Sender: parsed.to,
|
|
6449
6456
|
l2TxNumberInBatch: txIndex,
|
|
6450
6457
|
message,
|
|
6451
6458
|
merkleProof: proof.proof
|