@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,6 +1,6 @@
|
|
|
1
|
-
export { createViemClient } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
1
|
+
export { createViemClient } from '../../chunk-2RIARDXZ.js';
|
|
2
|
+
import '../../chunk-5R7L5NM5.js';
|
|
3
|
+
import '../../chunk-4S4XDA4N.js';
|
|
4
|
+
import '../../chunk-53MC5BR2.js';
|
|
5
|
+
import '../../chunk-RI73VJSH.js';
|
|
6
|
+
import '../../chunk-QQ2OR434.js';
|
|
@@ -33,7 +33,7 @@ var TX_OVERHEAD_GAS = 10000n;
|
|
|
33
33
|
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
34
34
|
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
35
35
|
var DEFAULT_ABI_BYTES = 400n;
|
|
36
|
-
var SAFE_L1_BRIDGE_GAS =
|
|
36
|
+
var SAFE_L1_BRIDGE_GAS = 800000n;
|
|
37
37
|
|
|
38
38
|
// src/core/utils/addr.ts
|
|
39
39
|
function isAddressEq(a, b) {
|
|
@@ -450,8 +450,8 @@ function ensureHex(value, field, context) {
|
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
452
|
function ensureNumber(value, field, opts) {
|
|
453
|
-
const operation = opts?.operation
|
|
454
|
-
const messagePrefix = opts?.messagePrefix
|
|
453
|
+
const operation = opts?.operation;
|
|
454
|
+
const messagePrefix = opts?.messagePrefix;
|
|
455
455
|
if (isNumber(value)) return value;
|
|
456
456
|
if (isBigint(value)) return Number(value);
|
|
457
457
|
if (typeof value === "string" && value.trim() !== "") {
|
|
@@ -589,7 +589,6 @@ function normalizeGenesis(raw) {
|
|
|
589
589
|
context: { valueType: typeof contractsRaw }
|
|
590
590
|
});
|
|
591
591
|
}
|
|
592
|
-
const executionVersion = ensureNumber(record["execution_version"], "execution_version");
|
|
593
592
|
const genesisRoot = ensureHex(record["genesis_root"], "genesis_root", {});
|
|
594
593
|
const initialContracts = contractsRaw.map(
|
|
595
594
|
(entry, index) => normalizeContractTuple(entry, index)
|
|
@@ -598,7 +597,6 @@ function normalizeGenesis(raw) {
|
|
|
598
597
|
return {
|
|
599
598
|
initialContracts,
|
|
600
599
|
additionalStorage,
|
|
601
|
-
executionVersion,
|
|
602
600
|
genesisRoot
|
|
603
601
|
};
|
|
604
602
|
} catch (e) {
|
|
@@ -5855,6 +5853,7 @@ function viemToGasEstimator(client) {
|
|
|
5855
5853
|
}
|
|
5856
5854
|
|
|
5857
5855
|
// src/adapters/viem/resources/deposits/services/gas.ts
|
|
5856
|
+
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
5858
5857
|
async function quoteL1Gas2(input) {
|
|
5859
5858
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
5860
5859
|
const estimator = viemToGasEstimator(ctx.client.l1);
|
|
@@ -5879,24 +5878,24 @@ async function quoteL2Gas2(input) {
|
|
|
5879
5878
|
stateOverrides: input.stateOverrides
|
|
5880
5879
|
});
|
|
5881
5880
|
}
|
|
5882
|
-
async function
|
|
5883
|
-
const { ctx, l1Token } = input;
|
|
5884
|
-
const
|
|
5881
|
+
async function determineNonBaseL2Gas(input) {
|
|
5882
|
+
const { ctx, l1Token, route } = input;
|
|
5883
|
+
const fallbackQuote = () => quoteL2Gas2({
|
|
5884
|
+
ctx,
|
|
5885
|
+
route,
|
|
5886
|
+
overrideGasLimit: DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT
|
|
5887
|
+
});
|
|
5885
5888
|
if (ctx.l2GasLimit != null) {
|
|
5886
5889
|
return quoteL2Gas2({
|
|
5887
5890
|
ctx,
|
|
5888
|
-
route
|
|
5891
|
+
route,
|
|
5889
5892
|
overrideGasLimit: ctx.l2GasLimit
|
|
5890
5893
|
});
|
|
5891
5894
|
}
|
|
5892
5895
|
try {
|
|
5893
|
-
const l2TokenAddress = ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).read.l2TokenAddress([l1Token]);
|
|
5896
|
+
const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).read.l2TokenAddress([l1Token]));
|
|
5894
5897
|
if (l2TokenAddress === viem.zeroAddress) {
|
|
5895
|
-
return
|
|
5896
|
-
ctx,
|
|
5897
|
-
route: "erc20-nonbase",
|
|
5898
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
5899
|
-
});
|
|
5898
|
+
return fallbackQuote();
|
|
5900
5899
|
}
|
|
5901
5900
|
const modelTx = {
|
|
5902
5901
|
to: input.modelTx?.to ?? ctx.sender,
|
|
@@ -5906,26 +5905,34 @@ async function determineErc20L2Gas(input) {
|
|
|
5906
5905
|
};
|
|
5907
5906
|
const gas = await quoteL2Gas2({
|
|
5908
5907
|
ctx,
|
|
5909
|
-
route
|
|
5908
|
+
route,
|
|
5910
5909
|
l2TxForModeling: modelTx
|
|
5911
5910
|
});
|
|
5912
|
-
if (!gas) {
|
|
5913
|
-
return
|
|
5914
|
-
ctx,
|
|
5915
|
-
route: "erc20-nonbase",
|
|
5916
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
5917
|
-
});
|
|
5911
|
+
if (!gas || gas.gasLimit === 0n) {
|
|
5912
|
+
return fallbackQuote();
|
|
5918
5913
|
}
|
|
5919
5914
|
return gas;
|
|
5920
5915
|
} catch (err) {
|
|
5921
|
-
console.warn("Failed to determine
|
|
5922
|
-
return
|
|
5923
|
-
ctx,
|
|
5924
|
-
route: "erc20-nonbase",
|
|
5925
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
5926
|
-
});
|
|
5916
|
+
console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
|
|
5917
|
+
return fallbackQuote();
|
|
5927
5918
|
}
|
|
5928
5919
|
}
|
|
5920
|
+
async function determineErc20L2Gas(input) {
|
|
5921
|
+
return determineNonBaseL2Gas({
|
|
5922
|
+
...input,
|
|
5923
|
+
route: "erc20-nonbase",
|
|
5924
|
+
knownL2Token: input.ctx.resolvedToken?.l2
|
|
5925
|
+
});
|
|
5926
|
+
}
|
|
5927
|
+
async function determineEthNonBaseL2Gas(input) {
|
|
5928
|
+
return determineNonBaseL2Gas({
|
|
5929
|
+
ctx: input.ctx,
|
|
5930
|
+
route: "eth-nonbase",
|
|
5931
|
+
l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
|
|
5932
|
+
knownL2Token: input.ctx.resolvedToken?.l2,
|
|
5933
|
+
modelTx: input.modelTx
|
|
5934
|
+
});
|
|
5935
|
+
}
|
|
5929
5936
|
|
|
5930
5937
|
// src/adapters/viem/resources/deposits/services/fee.ts
|
|
5931
5938
|
var { wrapAs } = createErrorHandlers("deposits");
|
|
@@ -6352,11 +6359,9 @@ function routeEthNonBase() {
|
|
|
6352
6359
|
data: "0x",
|
|
6353
6360
|
value: 0n
|
|
6354
6361
|
};
|
|
6355
|
-
const l2Gas = await
|
|
6362
|
+
const l2Gas = await determineEthNonBaseL2Gas({
|
|
6356
6363
|
ctx,
|
|
6357
|
-
|
|
6358
|
-
l2TxForModeling: l2TxModel,
|
|
6359
|
-
overrideGasLimit: ctx.l2GasLimit
|
|
6364
|
+
modelTx: l2TxModel
|
|
6360
6365
|
});
|
|
6361
6366
|
if (!l2Gas) throw new Error("Failed to estimate L2 gas parameters.");
|
|
6362
6367
|
const l2BaseCost = await quoteL2BaseCost({ ctx, l2GasLimit: l2Gas.gasLimit });
|
|
@@ -7847,7 +7852,7 @@ function createFinalizationServices(client) {
|
|
|
7847
7852
|
chainId: BigInt(chainId),
|
|
7848
7853
|
l2BatchNumber: proof.batchNumber,
|
|
7849
7854
|
l2MessageIndex: proof.id,
|
|
7850
|
-
l2Sender:
|
|
7855
|
+
l2Sender: parsed.to,
|
|
7851
7856
|
l2TxNumberInBatch: txIndex,
|
|
7852
7857
|
message,
|
|
7853
7858
|
merkleProof: proof.proof
|