@matterlabs/zksync-js 0.0.8 → 0.0.9
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 +1640 -236
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +11 -0
- package/dist/adapters/ethers/client.js +5 -5
- package/dist/adapters/ethers/index.cjs +4395 -1525
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.d.ts +4 -0
- package/dist/adapters/ethers/index.js +8 -8
- package/dist/adapters/ethers/resources/contracts/types.d.ts +15 -0
- package/dist/adapters/ethers/resources/deposits/context.d.ts +3 -3
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +2 -2
- package/dist/adapters/ethers/resources/deposits/services/verification.d.ts +1 -1
- package/dist/adapters/ethers/resources/interop/address.d.ts +18 -0
- package/dist/adapters/ethers/resources/interop/attributes/resource.d.ts +9 -0
- package/dist/adapters/ethers/resources/interop/context.d.ts +36 -0
- package/dist/adapters/ethers/resources/interop/index.d.ts +63 -0
- package/dist/adapters/ethers/resources/interop/resolvers.d.ts +9 -0
- package/dist/adapters/ethers/resources/interop/routes/direct.d.ts +2 -0
- package/dist/adapters/ethers/resources/interop/routes/indirect.d.ts +2 -0
- package/dist/adapters/ethers/resources/interop/routes/types.d.ts +13 -0
- package/dist/adapters/ethers/resources/interop/services/erc20.d.ts +15 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/bundle.d.ts +15 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/data-fetchers.d.ts +17 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/decoders.d.ts +12 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/index.d.ts +13 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/polling.d.ts +7 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/status.d.ts +5 -0
- package/dist/adapters/ethers/resources/interop/services/finalization/topics.d.ts +6 -0
- package/dist/adapters/ethers/resources/interop/services/starter-data.d.ts +6 -0
- package/dist/adapters/ethers/resources/interop/types.d.ts +16 -0
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +2 -2
- package/dist/adapters/ethers/sdk.cjs +3357 -917
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +10 -8
- package/dist/adapters/ethers/sdk.js +6 -6
- package/dist/adapters/viem/client.cjs +685 -31
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.js +5 -3
- package/dist/adapters/viem/index.cjs +282 -203
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +1 -0
- package/dist/adapters/viem/index.js +8 -7
- package/dist/adapters/viem/resources/deposits/context.d.ts +3 -3
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +2 -2
- package/dist/adapters/viem/resources/deposits/services/verification.d.ts +1 -1
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +2 -2
- package/dist/adapters/viem/sdk.cjs +39 -58
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +5 -5
- package/dist/{chunk-LNIEQ7AN.js → chunk-5AG6B7UX.js} +36 -60
- package/dist/{chunk-NODVRI3E.js → chunk-AIFHAPJC.js} +8 -2
- package/dist/{chunk-3GFCAGGI.js → chunk-FBKBF7YM.js} +1533 -1434
- package/dist/{chunk-L343N56B.js → chunk-IYEDEUXG.js} +1 -1
- package/dist/chunk-JNWHQJU3.js +209 -0
- package/dist/{chunk-ODMBZ2VX.js → chunk-KLNFDFLA.js} +42 -31
- package/dist/{chunk-NVULC4JB.js → chunk-QDJOEVGJ.js} +2 -2
- package/dist/{chunk-63DNJXS3.js → chunk-RRKVUW3G.js} +1375 -75
- package/dist/{chunk-5V2JRM5J.js → chunk-SRPKTXIF.js} +1 -1
- package/dist/{chunk-SHQQI3UD.js → chunk-UIXU35ZU.js} +1 -1
- package/dist/{chunk-QZVYN3YA.js → chunk-ZVHFVUDE.js} +2 -37
- package/dist/core/index.cjs +3 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +4 -4
- package/dist/core/resources/interop/attributes/types.d.ts +0 -2
- package/dist/core/resources/interop/finalization.d.ts +0 -1
- package/dist/core/types/errors.d.ts +15 -5
- package/dist/core/types/fees.d.ts +9 -0
- package/dist/core/types/flows/interop.d.ts +12 -36
- package/dist/core/types/primitives.d.ts +1 -0
- package/dist/index.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-FGXRG2JS.js +0 -142
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createViemSdk } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
1
|
+
export { createViemSdk } from '../../chunk-5AG6B7UX.js';
|
|
2
|
+
import '../../chunk-AIFHAPJC.js';
|
|
3
|
+
import '../../chunk-ZVHFVUDE.js';
|
|
4
|
+
import '../../chunk-SRPKTXIF.js';
|
|
5
|
+
import '../../chunk-FBKBF7YM.js';
|
|
6
6
|
import '../../chunk-C3AGOEHR.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createNTVCodec, buildFeeBreakdown, quoteL2Gas, quoteL1Gas, quoteL2Gas2 } from './chunk-
|
|
2
|
-
import { findL1MessageSentLog, messengerLogIndex,
|
|
3
|
-
import { createErrorOps, REVERT_TO_READINESS } from './chunk-
|
|
4
|
-
import { IL1Nullifier_default, IERC20_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default, OP_WITHDRAWALS, createError, OP_DEPOSITS, isZKsyncError, isReceiptNotFound, IBridgehub_default, IL2AssetRouter_default, IBaseToken_default } from './chunk-
|
|
5
|
-
import { ETH_ADDRESS, L1_MESSENGER_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS,
|
|
6
|
-
import { keccak256, encodeAbiParameters, decodeErrorResult, concat,
|
|
1
|
+
import { createNTVCodec, toGasOverrides, buildFeeBreakdown, quoteL2Gas, quoteL1Gas, quoteL2Gas2 } from './chunk-AIFHAPJC.js';
|
|
2
|
+
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-ZVHFVUDE.js';
|
|
3
|
+
import { createErrorOps, REVERT_TO_READINESS } from './chunk-SRPKTXIF.js';
|
|
4
|
+
import { IL1Nullifier_default, IERC20_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default, isHash66, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, isZKsyncError, isReceiptNotFound, IBridgehub_default, isETH, normalizeAddrEq, IL2AssetRouter_default, IBaseToken_default } from './chunk-FBKBF7YM.js';
|
|
5
|
+
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, SAFE_L1_BRIDGE_GAS } from './chunk-C3AGOEHR.js';
|
|
6
|
+
import { keccak256, encodeAbiParameters, decodeErrorResult, concat, decodeEventLog, decodeAbiParameters, encodeFunctionData, zeroAddress } from 'viem';
|
|
7
7
|
|
|
8
8
|
// src/adapters/viem/resources/deposits/context.ts
|
|
9
9
|
async function commonCtx(p, client, tokens, contracts) {
|
|
@@ -39,7 +39,7 @@ async function commonCtx(p, client, tokens, contracts) {
|
|
|
39
39
|
bridgehub,
|
|
40
40
|
chainIdL2: BigInt(chainId),
|
|
41
41
|
sender,
|
|
42
|
-
gasOverrides: p.l1TxOverrides,
|
|
42
|
+
gasOverrides: p.l1TxOverrides ? toGasOverrides(p.l1TxOverrides) : void 0,
|
|
43
43
|
l2GasLimit: p.l2GasLimit,
|
|
44
44
|
gasPerPubdata,
|
|
45
45
|
operatorTip,
|
|
@@ -1101,7 +1101,7 @@ var I_BRIDGEHUB_NEW_PRIORITY_REQUEST = {
|
|
|
1101
1101
|
{ name: "data", type: "bytes", indexed: false }
|
|
1102
1102
|
]
|
|
1103
1103
|
};
|
|
1104
|
-
function
|
|
1104
|
+
function getL2TransactionHashFromLogs(logs) {
|
|
1105
1105
|
for (const lg of logs) {
|
|
1106
1106
|
try {
|
|
1107
1107
|
const parsed = decodeEventLog({
|
|
@@ -1133,7 +1133,7 @@ function extractL2TxHashFromL1Logs(logs) {
|
|
|
1133
1133
|
async function waitForL2ExecutionFromL1Tx(l1, l2, l1TxHash) {
|
|
1134
1134
|
const l1Receipt = await l1.waitForTransactionReceipt({ hash: l1TxHash });
|
|
1135
1135
|
if (!l1Receipt) throw new Error("No L1 receipt found");
|
|
1136
|
-
const l2TxHash =
|
|
1136
|
+
const l2TxHash = getL2TransactionHashFromLogs(l1Receipt.logs);
|
|
1137
1137
|
if (!l2TxHash) {
|
|
1138
1138
|
throw createError("VERIFICATION", {
|
|
1139
1139
|
message: "Failed to extract L2 transaction hash from L1 logs",
|
|
@@ -1480,7 +1480,13 @@ function createDepositsResource(client, tokens, contracts) {
|
|
|
1480
1480
|
const plan = await prepare(p);
|
|
1481
1481
|
const stepHashes = {};
|
|
1482
1482
|
const from = client.account.address;
|
|
1483
|
-
let next
|
|
1483
|
+
let next;
|
|
1484
|
+
if (typeof p.l1TxOverrides?.nonce === "number") {
|
|
1485
|
+
next = p.l1TxOverrides.nonce;
|
|
1486
|
+
} else {
|
|
1487
|
+
const blockTag = p.l1TxOverrides?.nonce ?? "latest";
|
|
1488
|
+
next = await client.l1.getTransactionCount({ address: from, blockTag });
|
|
1489
|
+
}
|
|
1484
1490
|
for (const step of plan.steps) {
|
|
1485
1491
|
if (step.kind === "approve") {
|
|
1486
1492
|
try {
|
|
@@ -1627,14 +1633,14 @@ function createDepositsResource(client, tokens, contracts) {
|
|
|
1627
1633
|
if (!l1Rcpt) return { phase: "L1_PENDING", l1TxHash };
|
|
1628
1634
|
let l2TxHash;
|
|
1629
1635
|
try {
|
|
1630
|
-
l2TxHash =
|
|
1636
|
+
l2TxHash = getL2TransactionHashFromLogs(l1Rcpt.logs) ?? void 0;
|
|
1631
1637
|
} catch (e) {
|
|
1632
1638
|
throw toZKsyncError(
|
|
1633
1639
|
"INTERNAL",
|
|
1634
1640
|
{
|
|
1635
1641
|
resource: "deposits",
|
|
1636
|
-
operation: "deposits.status.
|
|
1637
|
-
context: { where: "
|
|
1642
|
+
operation: "deposits.status.getL2TransactionHashFromLogs",
|
|
1643
|
+
context: { where: "getL2TransactionHashFromLogs", l1TxHash },
|
|
1638
1644
|
message: "Failed to derive L2 transaction hash from L1 logs."
|
|
1639
1645
|
},
|
|
1640
1646
|
e
|
|
@@ -1770,7 +1776,7 @@ async function commonCtx2(p, client, tokens, contracts) {
|
|
|
1770
1776
|
l2NativeTokenVault,
|
|
1771
1777
|
l2BaseTokenSystem,
|
|
1772
1778
|
baseIsEth,
|
|
1773
|
-
gasOverrides: p.l2TxOverrides
|
|
1779
|
+
gasOverrides: p.l2TxOverrides ? toGasOverrides(p.l2TxOverrides) : void 0
|
|
1774
1780
|
};
|
|
1775
1781
|
}
|
|
1776
1782
|
|
|
@@ -2124,27 +2130,11 @@ function createFinalizationServices(client) {
|
|
|
2124
2130
|
message,
|
|
2125
2131
|
merkleProof: proof.proof
|
|
2126
2132
|
};
|
|
2127
|
-
const { l1Nullifier } = await
|
|
2128
|
-
"INTERNAL",
|
|
2129
|
-
OP_WITHDRAWALS.finalize.fetchParams.ensureAddresses,
|
|
2130
|
-
() => client.ensureAddresses(),
|
|
2131
|
-
{
|
|
2132
|
-
ctx: { where: "ensureAddresses" },
|
|
2133
|
-
message: "Failed to ensure L1 Nullifier address."
|
|
2134
|
-
}
|
|
2135
|
-
);
|
|
2133
|
+
const { l1Nullifier } = await client.ensureAddresses();
|
|
2136
2134
|
return { params, nullifier: l1Nullifier };
|
|
2137
2135
|
},
|
|
2138
2136
|
async simulateFinalizeReadiness(params) {
|
|
2139
|
-
const { l1Nullifier } = await
|
|
2140
|
-
"INTERNAL",
|
|
2141
|
-
OP_WITHDRAWALS.finalize.readiness.ensureAddresses,
|
|
2142
|
-
() => client.ensureAddresses(),
|
|
2143
|
-
{
|
|
2144
|
-
ctx: { where: "ensureAddresses" },
|
|
2145
|
-
message: "Failed to ensure L1 Nullifier address."
|
|
2146
|
-
}
|
|
2147
|
-
);
|
|
2137
|
+
const { l1Nullifier } = await client.ensureAddresses();
|
|
2148
2138
|
const done = await (async () => {
|
|
2149
2139
|
try {
|
|
2150
2140
|
const result = await wrapAs9(
|
|
@@ -2181,15 +2171,7 @@ function createFinalizationServices(client) {
|
|
|
2181
2171
|
}
|
|
2182
2172
|
},
|
|
2183
2173
|
async isWithdrawalFinalized(key) {
|
|
2184
|
-
const { l1Nullifier } = await
|
|
2185
|
-
"INTERNAL",
|
|
2186
|
-
OP_WITHDRAWALS.finalize.fetchParams.ensureAddresses,
|
|
2187
|
-
() => client.ensureAddresses(),
|
|
2188
|
-
{
|
|
2189
|
-
ctx: { where: "ensureAddresses" },
|
|
2190
|
-
message: "Failed to ensure L1 Nullifier address."
|
|
2191
|
-
}
|
|
2192
|
-
);
|
|
2174
|
+
const { l1Nullifier } = await client.ensureAddresses();
|
|
2193
2175
|
return await wrapAs9(
|
|
2194
2176
|
"RPC",
|
|
2195
2177
|
OP_WITHDRAWALS.finalize.isFinalized,
|
|
@@ -2206,15 +2188,7 @@ function createFinalizationServices(client) {
|
|
|
2206
2188
|
);
|
|
2207
2189
|
},
|
|
2208
2190
|
async estimateFinalization(params) {
|
|
2209
|
-
const { l1Nullifier } = await
|
|
2210
|
-
"INTERNAL",
|
|
2211
|
-
OP_WITHDRAWALS.finalize.estimate,
|
|
2212
|
-
() => client.ensureAddresses(),
|
|
2213
|
-
{
|
|
2214
|
-
ctx: { where: "ensureAddresses" },
|
|
2215
|
-
message: "Failed to ensure L1 Nullifier address."
|
|
2216
|
-
}
|
|
2217
|
-
);
|
|
2191
|
+
const { l1Nullifier } = await client.ensureAddresses();
|
|
2218
2192
|
const gasLimit = await wrapAs9(
|
|
2219
2193
|
"RPC",
|
|
2220
2194
|
OP_WITHDRAWALS.finalize.estimate,
|
|
@@ -2277,15 +2251,7 @@ function createFinalizationServices(client) {
|
|
|
2277
2251
|
};
|
|
2278
2252
|
},
|
|
2279
2253
|
async finalizeDeposit(params) {
|
|
2280
|
-
const { l1Nullifier } = await
|
|
2281
|
-
"INTERNAL",
|
|
2282
|
-
OP_WITHDRAWALS.finalize.fetchParams.ensureAddresses,
|
|
2283
|
-
() => client.ensureAddresses(),
|
|
2284
|
-
{
|
|
2285
|
-
ctx: { where: "ensureAddresses" },
|
|
2286
|
-
message: "Failed to ensure L1 Nullifier address."
|
|
2287
|
-
}
|
|
2288
|
-
);
|
|
2254
|
+
const { l1Nullifier } = await client.ensureAddresses();
|
|
2289
2255
|
try {
|
|
2290
2256
|
const hash = await client.l1Wallet.writeContract({
|
|
2291
2257
|
address: l1Nullifier,
|
|
@@ -2386,6 +2352,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2386
2352
|
const plan = await prepare(p);
|
|
2387
2353
|
const stepHashes = {};
|
|
2388
2354
|
const l2Wallet = client.getL2Wallet();
|
|
2355
|
+
const from = client.account.address;
|
|
2356
|
+
let next;
|
|
2357
|
+
if (typeof p.l2TxOverrides?.nonce === "number") {
|
|
2358
|
+
next = p.l2TxOverrides.nonce;
|
|
2359
|
+
} else {
|
|
2360
|
+
const blockTag = p.l2TxOverrides?.nonce ?? "pending";
|
|
2361
|
+
next = await client.l2.getTransactionCount({ address: from, blockTag });
|
|
2362
|
+
}
|
|
2389
2363
|
for (const step of plan.steps) {
|
|
2390
2364
|
if (p.l2TxOverrides) {
|
|
2391
2365
|
const overrides = p.l2TxOverrides;
|
|
@@ -2419,6 +2393,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2419
2393
|
maxFeePerGas: step.tx.maxFeePerGas,
|
|
2420
2394
|
maxPriorityFeePerGas: step.tx.maxPriorityFeePerGas
|
|
2421
2395
|
} : {};
|
|
2396
|
+
const nonce = next++;
|
|
2422
2397
|
const baseReq = {
|
|
2423
2398
|
address: step.tx.address,
|
|
2424
2399
|
abi: step.tx.abi,
|
|
@@ -2426,6 +2401,7 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2426
2401
|
args: step.tx.args ?? [],
|
|
2427
2402
|
account: step.tx.account ?? l2Wallet.account ?? client.account,
|
|
2428
2403
|
gas: step.tx.gas,
|
|
2404
|
+
nonce,
|
|
2429
2405
|
...fee1559,
|
|
2430
2406
|
...step.tx.dataSuffix ? { dataSuffix: step.tx.dataSuffix } : {},
|
|
2431
2407
|
...step.tx.chain ? { chain: step.tx.chain } : {}
|
|
@@ -2726,4 +2702,4 @@ function createViemSdk(client) {
|
|
|
2726
2702
|
};
|
|
2727
2703
|
}
|
|
2728
2704
|
|
|
2729
|
-
export { buildDirectRequestStruct, classifyReadinessFromRevert, createContractsResource, createDepositsResource, createErrorHandlers, createFinalizationServices, createTokensResource, createViemSdk, createWithdrawalsResource, decodeRevert, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, registerErrorAbi, toZKsyncError };
|
|
2705
|
+
export { buildDirectRequestStruct, classifyReadinessFromRevert, createContractsResource, createDepositsResource, createErrorHandlers, createFinalizationServices, createTokensResource, createViemSdk, createWithdrawalsResource, decodeRevert, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs, registerErrorAbi, toZKsyncError };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBridgehub_default } from './chunk-
|
|
1
|
+
import { IBridgehub_default } from './chunk-FBKBF7YM.js';
|
|
2
2
|
import { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, TX_MEMORY_OVERHEAD_GAS, TX_OVERHEAD_GAS } from './chunk-C3AGOEHR.js';
|
|
3
3
|
|
|
4
4
|
// src/core/codec/ntv.ts
|
|
@@ -15,6 +15,12 @@ function createNTVCodec(deps) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
// src/core/types/fees.ts
|
|
19
|
+
function toGasOverrides(overrides) {
|
|
20
|
+
const { nonce: _, ...gas } = overrides;
|
|
21
|
+
return gas;
|
|
22
|
+
}
|
|
23
|
+
|
|
18
24
|
// src/core/resources/deposits/fee.ts
|
|
19
25
|
function buildFeeBreakdown(p) {
|
|
20
26
|
const l1MaxTotal = p.l1Gas?.maxCost ?? 0n;
|
|
@@ -228,4 +234,4 @@ async function quoteL2Gas2(input) {
|
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
236
|
|
|
231
|
-
export { buildFeeBreakdown, createNTVCodec, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2 };
|
|
237
|
+
export { buildFeeBreakdown, createNTVCodec, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, toGasOverrides };
|