@matterlabs/zksync-js 0.0.11 → 0.0.12
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.js +6 -6
- package/dist/adapters/ethers/index.cjs +39 -31
- 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 +39 -31
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +7 -7
- package/dist/adapters/viem/client.js +6 -6
- package/dist/adapters/viem/index.cjs +36 -29
- 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-N4PR5SVB.js → chunk-4PFO3J7W.js} +2 -2
- package/dist/{chunk-QFEYV4O3.js → chunk-6CLYCJMV.js} +1 -1
- package/dist/{chunk-TL26ZONW.js → chunk-6JM4PE62.js} +43 -35
- package/dist/{chunk-CCUAGJ6K.js → chunk-AUN5Y2A3.js} +40 -33
- package/dist/{chunk-EWBYKU4G.js → chunk-BGUNJK2H.js} +4 -4
- package/dist/{chunk-ZVHFVUDE.js → chunk-E3KP7XCG.js} +1 -1
- package/dist/{chunk-H3BPVVMN.js → chunk-GMNLOTNG.js} +1 -1
- package/dist/{chunk-IQVH7YZT.js → chunk-I5VQBVQ2.js} +2 -2
- package/dist/{chunk-6IT5PEEN.js → chunk-IUSH7YBZ.js} +1 -1
- package/dist/{chunk-FXSFLZ6D.js → chunk-LWA7LC3N.js} +4 -4
- package/dist/{chunk-USXSAFYA.js → chunk-NBQVHW2N.js} +2 -2
- package/dist/{chunk-C3AGOEHR.js → chunk-QQ2OR434.js} +1 -1
- package/dist/{chunk-QUI3J42E.js → chunk-TE2YQHVI.js} +2 -2
- 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.js +5 -5
- package/dist/core/rpc/types.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,6 +117,19 @@ console.log('Deposit complete ✅');
|
|
|
117
117
|
|
|
118
118
|
Bug reports, fixes, and new features are welcome! Please read the [contributing guide](.github/CONTRIBUTING.md) to get started.
|
|
119
119
|
|
|
120
|
+
## 🤖 AI Instruction Map
|
|
121
|
+
|
|
122
|
+
For AI-assisted contribution workflows:
|
|
123
|
+
|
|
124
|
+
| Path | Purpose |
|
|
125
|
+
|---|---|
|
|
126
|
+
| [`AGENTS.md`](./AGENTS.md) | Repo-wide policy, boundaries, and required verification rules. |
|
|
127
|
+
| [`llm/`](./llm/) | Canonical contributor contracts (architecture, API gate, testing, release, style). |
|
|
128
|
+
| [`.codex/config.toml`](./.codex/config.toml) | Codex multi-agent registry and role wiring. |
|
|
129
|
+
| [`.codex/agents/`](./.codex/agents/) | Canonical role behavior (`.toml`) for explorer/planner/implementer/reviewer/tester/docs/release/api-sentinel. |
|
|
130
|
+
| [`agents/`](./agents/) | Human-readable role summaries that mirror `.codex/agents` behavior. |
|
|
131
|
+
| [`.agents/skills/`](./.agents/skills/) | Repo-scoped reusable skills for focused workflows (for example API gate, adapter parity, contract interaction patterns). |
|
|
132
|
+
|
|
120
133
|
## 📜 License
|
|
121
134
|
|
|
122
135
|
This project is licensed under the terms of the **MIT License** – see the [LICENSE](LICENSE) file for details.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createEthersClient } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersClient } from '../../chunk-LWA7LC3N.js';
|
|
2
|
+
import '../../chunk-4PFO3J7W.js';
|
|
3
|
+
import '../../chunk-NBQVHW2N.js';
|
|
4
|
+
import '../../chunk-GMNLOTNG.js';
|
|
5
|
+
import '../../chunk-6CLYCJMV.js';
|
|
6
|
+
import '../../chunk-QQ2OR434.js';
|
|
@@ -48,7 +48,7 @@ var TX_OVERHEAD_GAS = 10000n;
|
|
|
48
48
|
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
49
49
|
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
50
50
|
var DEFAULT_ABI_BYTES = 400n;
|
|
51
|
-
var SAFE_L1_BRIDGE_GAS =
|
|
51
|
+
var SAFE_L1_BRIDGE_GAS = 800000n;
|
|
52
52
|
|
|
53
53
|
// src/core/utils/addr.ts
|
|
54
54
|
function isAddress(x) {
|
|
@@ -7500,6 +7500,8 @@ async function quoteL2BaseCost2(input) {
|
|
|
7500
7500
|
}
|
|
7501
7501
|
|
|
7502
7502
|
// src/adapters/ethers/resources/deposits/services/gas.ts
|
|
7503
|
+
var DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT = 3000000n;
|
|
7504
|
+
var ZERO_L2_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
7503
7505
|
async function quoteL1Gas2(input) {
|
|
7504
7506
|
const { ctx, tx, overrides, fallbackGasLimit } = input;
|
|
7505
7507
|
const estimator = ethersToGasEstimator(ctx.client.l1);
|
|
@@ -7523,24 +7525,24 @@ async function quoteL2Gas2(input) {
|
|
|
7523
7525
|
stateOverrides: input.stateOverrides
|
|
7524
7526
|
});
|
|
7525
7527
|
}
|
|
7526
|
-
async function
|
|
7527
|
-
const { ctx, l1Token } = input;
|
|
7528
|
-
const
|
|
7528
|
+
async function determineNonBaseL2Gas(input) {
|
|
7529
|
+
const { ctx, l1Token, route } = input;
|
|
7530
|
+
const fallbackQuote = () => quoteL2Gas2({
|
|
7531
|
+
ctx,
|
|
7532
|
+
route,
|
|
7533
|
+
overrideGasLimit: DEFAULT_SAFE_NONBASE_L2_GAS_LIMIT
|
|
7534
|
+
});
|
|
7529
7535
|
if (ctx.l2GasLimit != null) {
|
|
7530
7536
|
return quoteL2Gas2({
|
|
7531
7537
|
ctx,
|
|
7532
|
-
route
|
|
7538
|
+
route,
|
|
7533
7539
|
overrideGasLimit: ctx.l2GasLimit
|
|
7534
7540
|
});
|
|
7535
7541
|
}
|
|
7536
7542
|
try {
|
|
7537
|
-
const l2TokenAddress = ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).l2TokenAddress(l1Token);
|
|
7538
|
-
if (l2TokenAddress ===
|
|
7539
|
-
return
|
|
7540
|
-
ctx,
|
|
7541
|
-
route: "erc20-nonbase",
|
|
7542
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
7543
|
-
});
|
|
7543
|
+
const l2TokenAddress = input.knownL2Token ?? (ctx.tokens ? await ctx.tokens.toL2Address(l1Token) : await (await ctx.contracts.l2NativeTokenVault()).l2TokenAddress(l1Token));
|
|
7544
|
+
if (l2TokenAddress === ZERO_L2_TOKEN_ADDRESS) {
|
|
7545
|
+
return fallbackQuote();
|
|
7544
7546
|
}
|
|
7545
7547
|
const modelTx = {
|
|
7546
7548
|
to: input.modelTx?.to ?? ctx.sender,
|
|
@@ -7550,26 +7552,34 @@ async function determineErc20L2Gas(input) {
|
|
|
7550
7552
|
};
|
|
7551
7553
|
const gas = await quoteL2Gas2({
|
|
7552
7554
|
ctx,
|
|
7553
|
-
route
|
|
7555
|
+
route,
|
|
7554
7556
|
l2TxForModeling: modelTx
|
|
7555
7557
|
});
|
|
7556
|
-
if (!gas) {
|
|
7557
|
-
return
|
|
7558
|
-
ctx,
|
|
7559
|
-
route: "erc20-nonbase",
|
|
7560
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
7561
|
-
});
|
|
7558
|
+
if (!gas || gas.gasLimit === 0n) {
|
|
7559
|
+
return fallbackQuote();
|
|
7562
7560
|
}
|
|
7563
7561
|
return gas;
|
|
7564
7562
|
} catch (err) {
|
|
7565
|
-
console.warn("Failed to determine
|
|
7566
|
-
return
|
|
7567
|
-
ctx,
|
|
7568
|
-
route: "erc20-nonbase",
|
|
7569
|
-
overrideGasLimit: DEFAULT_SAFE_L2_GAS_LIMIT
|
|
7570
|
-
});
|
|
7563
|
+
console.warn("Failed to determine non-base deposit L2 gas; defaulting to safe gas limit.", err);
|
|
7564
|
+
return fallbackQuote();
|
|
7571
7565
|
}
|
|
7572
7566
|
}
|
|
7567
|
+
async function determineErc20L2Gas(input) {
|
|
7568
|
+
return determineNonBaseL2Gas({
|
|
7569
|
+
...input,
|
|
7570
|
+
route: "erc20-nonbase",
|
|
7571
|
+
knownL2Token: input.ctx.resolvedToken?.l2
|
|
7572
|
+
});
|
|
7573
|
+
}
|
|
7574
|
+
async function determineEthNonBaseL2Gas(input) {
|
|
7575
|
+
return determineNonBaseL2Gas({
|
|
7576
|
+
ctx: input.ctx,
|
|
7577
|
+
route: "eth-nonbase",
|
|
7578
|
+
l1Token: input.ctx.resolvedToken?.l1 ?? FORMAL_ETH_ADDRESS,
|
|
7579
|
+
knownL2Token: input.ctx.resolvedToken?.l2,
|
|
7580
|
+
modelTx: input.modelTx
|
|
7581
|
+
});
|
|
7582
|
+
}
|
|
7573
7583
|
|
|
7574
7584
|
// src/core/resources/deposits/fee.ts
|
|
7575
7585
|
function buildFeeBreakdown(p) {
|
|
@@ -7884,11 +7894,9 @@ function routeEthNonBase() {
|
|
|
7884
7894
|
data: "0x",
|
|
7885
7895
|
value: 0n
|
|
7886
7896
|
};
|
|
7887
|
-
const l2GasParams = await
|
|
7897
|
+
const l2GasParams = await determineEthNonBaseL2Gas({
|
|
7888
7898
|
ctx,
|
|
7889
|
-
|
|
7890
|
-
l2TxForModeling: l2TxModel,
|
|
7891
|
-
overrideGasLimit: ctx.l2GasLimit
|
|
7899
|
+
modelTx: l2TxModel
|
|
7892
7900
|
});
|
|
7893
7901
|
if (!l2GasParams) throw new Error("Failed to estimate L2 gas parameters.");
|
|
7894
7902
|
const baseCost = await quoteL2BaseCost2({ ctx, l2GasLimit: l2GasParams.gasLimit });
|
|
@@ -7908,7 +7916,7 @@ function routeEthNonBase() {
|
|
|
7908
7916
|
if (allowance < mintValue) {
|
|
7909
7917
|
approvals.push({ token: baseToken, spender: ctx.l1AssetRouter, amount: mintValue });
|
|
7910
7918
|
steps.push({
|
|
7911
|
-
key: `approve:${baseToken}`,
|
|
7919
|
+
key: `approve:${baseToken}:${ctx.l1AssetRouter}`,
|
|
7912
7920
|
kind: "approve",
|
|
7913
7921
|
description: `Approve base token for fees (mintValue)`,
|
|
7914
7922
|
tx: {
|
|
@@ -9115,7 +9123,7 @@ function createFinalizationServices(client) {
|
|
|
9115
9123
|
chainId: BigInt(chainId),
|
|
9116
9124
|
l2BatchNumber: proof.batchNumber,
|
|
9117
9125
|
l2MessageIndex: proof.id,
|
|
9118
|
-
l2Sender:
|
|
9126
|
+
l2Sender: parsed.to,
|
|
9119
9127
|
l2TxNumberInBatch: txIndex,
|
|
9120
9128
|
message,
|
|
9121
9129
|
merkleProof: proof.proof
|