@matterlabs/zksync-js 0.0.20 → 0.0.21
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/index.cjs +36 -4
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +3 -3
- package/dist/adapters/ethers/sdk.cjs +36 -4
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +3 -3
- package/dist/adapters/viem/index.cjs +36 -4
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +3 -3
- package/dist/adapters/viem/sdk.cjs +36 -4
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +3 -3
- package/dist/{chunk-E2XKJCI5.js → chunk-2CGBLD5H.js} +13 -6
- package/dist/{chunk-3T5V4HKS.js → chunk-7GZDTLHX.js} +13 -6
- package/dist/{chunk-6LYAENO6.js → chunk-IDXSGCGF.js} +20 -3
- package/dist/{chunk-3HHUZXSV.js → chunk-LGTYM5XP.js} +9 -1
- package/dist/core/index.cjs +9 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/resources/withdrawals/status.d.ts +5 -0
- package/dist/core/types/flows/withdrawals.d.ts +2 -2
- package/dist/core/utils/events.d.ts +2 -0
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createViemSdk } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
export { createViemSdk } from '../../chunk-7GZDTLHX.js';
|
|
2
|
+
import '../../chunk-IDXSGCGF.js';
|
|
3
|
+
import '../../chunk-LGTYM5XP.js';
|
|
4
4
|
import '../../chunk-SBGBYZJM.js';
|
|
5
5
|
import '../../chunk-JSBMIT4S.js';
|
|
6
6
|
import '../../chunk-UEKFQAOS.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-NJK325XV.js';
|
|
2
|
-
import { createNTVCodec, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL2BaseCost, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-
|
|
3
|
-
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-
|
|
2
|
+
import { createNTVCodec, resolveCreateDepositL1GasLimit, phaseFromReadiness, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL2BaseCost, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-IDXSGCGF.js';
|
|
3
|
+
import { findL1MessageSentLog, messengerLogIndex, l1MessageSentSender, pickWithdrawRoute } from './chunk-LGTYM5XP.js';
|
|
4
4
|
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, OP_INTEROP, IInteropHandler_default, IERC7786Attributes_default, IInteropRootStorage_default, IInteropCenter_default, sleep, isETH, normalizeAddrEq, IL2AssetRouter_default, L2NativeTokenVault_default, assertNever } from './chunk-UEKFQAOS.js';
|
|
5
5
|
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_INTEROP_ROOT_STORAGE_ADDRESS, BUFFER, SAFE_L1_BRIDGE_GAS, L2_ASSET_ROUTER_ADDRESS, FORMAL_ETH_ADDRESS } from './chunk-MT4X5FEO.js';
|
|
6
6
|
import { Interface, keccak256, AbiCoder, ethers, getBytes, Contract, NonceManager, JsonRpcProvider, getAddress, concat, hexlify, toBeArray, toBeHex, isError } from 'ethers';
|
|
@@ -1919,7 +1919,7 @@ function createFinalizationServices(client) {
|
|
|
1919
1919
|
chainId: BigInt(chainId),
|
|
1920
1920
|
l2BatchNumber: proof.batchNumber,
|
|
1921
1921
|
l2MessageIndex: proof.id,
|
|
1922
|
-
l2Sender:
|
|
1922
|
+
l2Sender: l1MessageSentSender(ev),
|
|
1923
1923
|
l2TxNumberInBatch: txIndex,
|
|
1924
1924
|
message,
|
|
1925
1925
|
merkleProof: proof.proof
|
|
@@ -2232,9 +2232,8 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2232
2232
|
} catch {
|
|
2233
2233
|
}
|
|
2234
2234
|
const readiness = await svc.simulateFinalizeReadiness(pack.params);
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
return { phase: "PENDING", l2TxHash, key };
|
|
2235
|
+
const { phase, reason } = phaseFromReadiness(readiness);
|
|
2236
|
+
return { phase, reason, l2TxHash, key };
|
|
2238
2237
|
},
|
|
2239
2238
|
{
|
|
2240
2239
|
message: "Internal error while checking withdrawal status.",
|
|
@@ -2278,6 +2277,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2278
2277
|
const deadline = opts.timeoutMs ? Date.now() + opts.timeoutMs : void 0;
|
|
2279
2278
|
while (true) {
|
|
2280
2279
|
const s = await status(l2Hash);
|
|
2280
|
+
if (s.phase === "UNFINALIZABLE") {
|
|
2281
|
+
throw createError("STATE", {
|
|
2282
|
+
resource: "withdrawals",
|
|
2283
|
+
operation: OP_WITHDRAWALS.wait,
|
|
2284
|
+
message: "Withdrawal can never be finalized.",
|
|
2285
|
+
context: { l2TxHash: l2Hash, reason: s.reason }
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2281
2288
|
if (opts.for === "ready") {
|
|
2282
2289
|
if (s.phase === "READY_TO_FINALIZE" || s.phase === "FINALIZED") return null;
|
|
2283
2290
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createNTVCodec, resolveCreateDepositL1GasLimit, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-
|
|
2
|
-
import { findL1MessageSentLog, messengerLogIndex, pickWithdrawRoute } from './chunk-
|
|
1
|
+
import { createNTVCodec, resolveCreateDepositL1GasLimit, phaseFromReadiness, isInteropFinalizationInfo, DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, resolveIdsFromWaitable, parseBundleReceiptInfo, buildFinalizationInfo, parseBundleSentFromReceipt, createAttributesResource, pickInteropRoute, ZERO_HASH, toGasOverrides, applyPriorityL2GasLimitBuffer, buildFeeBreakdown, buildIndirectBundle, preflightIndirect, buildDirectBundle, preflightDirect, derivePriorityTxGasBreakdown, quoteL2Gas, quoteL1Gas, derivePriorityBodyGasEstimateCap, quoteL2Gas2, assertProtocolVersion } from './chunk-IDXSGCGF.js';
|
|
2
|
+
import { findL1MessageSentLog, messengerLogIndex, l1MessageSentSender, pickWithdrawRoute } from './chunk-LGTYM5XP.js';
|
|
3
3
|
import { createErrorHandlers, toZKsyncError, classifyReadinessFromRevert } from './chunk-SBGBYZJM.js';
|
|
4
4
|
import { isHash66, IL1Nullifier_default, OP_WITHDRAWALS, createError, normalizeL1Token, isAddressEq, hexEq, OP_DEPOSITS, IERC20_default, isZKsyncError, isReceiptNotFound, OP_INTEROP, IInteropHandler_default, IInteropRootStorage_default, IInteropCenter_default, sleep, IERC7786Attributes_default, IBridgehub_default, isETH, normalizeAddrEq, L2NativeTokenVault_default, IL2AssetRouter_default, IBaseToken_default, assertNever } from './chunk-UEKFQAOS.js';
|
|
5
5
|
import { ETH_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, L1_MESSENGER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, L2_INTEROP_ROOT_STORAGE_ADDRESS, BUFFER, SAFE_L1_BRIDGE_GAS, L2_ASSET_ROUTER_ADDRESS, FORMAL_ETH_ADDRESS } from './chunk-MT4X5FEO.js';
|
|
@@ -2332,7 +2332,7 @@ function createFinalizationServices(client) {
|
|
|
2332
2332
|
chainId: BigInt(chainId),
|
|
2333
2333
|
l2BatchNumber: proof.batchNumber,
|
|
2334
2334
|
l2MessageIndex: proof.id,
|
|
2335
|
-
l2Sender:
|
|
2335
|
+
l2Sender: l1MessageSentSender(ev),
|
|
2336
2336
|
l2TxNumberInBatch: txIndex,
|
|
2337
2337
|
message,
|
|
2338
2338
|
merkleProof: proof.proof
|
|
@@ -2704,9 +2704,8 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2704
2704
|
} catch {
|
|
2705
2705
|
}
|
|
2706
2706
|
const readiness = await svc.simulateFinalizeReadiness(pack.params);
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
return { phase: "PENDING", l2TxHash, key };
|
|
2707
|
+
const { phase, reason } = phaseFromReadiness(readiness);
|
|
2708
|
+
return { phase, reason, l2TxHash, key };
|
|
2710
2709
|
},
|
|
2711
2710
|
{
|
|
2712
2711
|
message: "Internal error while checking withdrawal status.",
|
|
@@ -2754,6 +2753,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
2754
2753
|
const deadline = opts.timeoutMs ? Date.now() + opts.timeoutMs : void 0;
|
|
2755
2754
|
while (true) {
|
|
2756
2755
|
const s = await status(l2Hash);
|
|
2756
|
+
if (s.phase === "UNFINALIZABLE") {
|
|
2757
|
+
throw createError("STATE", {
|
|
2758
|
+
resource: "withdrawals",
|
|
2759
|
+
operation: OP_WITHDRAWALS.wait,
|
|
2760
|
+
message: "Withdrawal can never be finalized.",
|
|
2761
|
+
context: { l2TxHash: l2Hash, reason: s.reason }
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2757
2764
|
if (opts.for === "ready") {
|
|
2758
2765
|
if (s.phase === "READY_TO_FINALIZE" || s.phase === "FINALIZED") return null;
|
|
2759
2766
|
} else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isL1MessageSentLog } from './chunk-
|
|
2
|
-
import { IBridgehub_default, isHash66, isBigint, isHash,
|
|
1
|
+
import { isL1MessageSentLog } from './chunk-LGTYM5XP.js';
|
|
2
|
+
import { IBridgehub_default, assertNever, isHash66, isBigint, isHash, createError, OP_INTEROP, isNumber, isAddress, isHash66Array } from './chunk-UEKFQAOS.js';
|
|
3
3
|
import { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, TX_MEMORY_OVERHEAD_GAS, TX_OVERHEAD_GAS, L1_TX_MIN_L2_GAS_BASE, L1_TX_INTRINSIC_L2_GAS, L1_TX_DELTA_544_ENCODING_BYTES, L1_TX_DELTA_FACTORY_DEPS_L2_GAS, L1_TX_INTRINSIC_PUBDATA, L1_TX_DELTA_FACTORY_DEPS_PUBDATA, TX_SLOT_OVERHEAD_L2_GAS, PRIORITY_TX_MAX_GAS_LIMIT, L2_INTEROP_CENTER_ADDRESS, BUNDLE_IDENTIFIER } from './chunk-MT4X5FEO.js';
|
|
4
4
|
|
|
5
5
|
// src/core/resources/deposits/chains.ts
|
|
@@ -164,6 +164,23 @@ function createNTVCodec(deps) {
|
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
+
// src/core/resources/withdrawals/status.ts
|
|
168
|
+
function phaseFromReadiness(r) {
|
|
169
|
+
switch (r.kind) {
|
|
170
|
+
case "FINALIZED":
|
|
171
|
+
return { phase: "FINALIZED" };
|
|
172
|
+
case "READY":
|
|
173
|
+
return { phase: "READY_TO_FINALIZE" };
|
|
174
|
+
case "NOT_READY":
|
|
175
|
+
return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
|
|
176
|
+
case "UNFINALIZABLE":
|
|
177
|
+
return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
|
|
178
|
+
default:
|
|
179
|
+
return assertNever(r);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
|
|
183
|
+
|
|
167
184
|
// src/core/types/flows/interop.ts
|
|
168
185
|
function isInteropMessageProof(obj) {
|
|
169
186
|
if (typeof obj !== "object" || obj === null) return false;
|
|
@@ -652,4 +669,4 @@ async function quoteL2Gas2(input) {
|
|
|
652
669
|
}
|
|
653
670
|
}
|
|
654
671
|
|
|
655
|
-
export { DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, ZERO_HASH, applyPriorityL2GasLimitBuffer, assertProtocolVersion, buildDirectBundle, buildFeeBreakdown, buildFinalizationInfo, buildIndirectBundle, createAttributesResource, createNTVCodec, derivePriorityBodyGasEstimateCap, derivePriorityTxGasBreakdown, isInteropFinalizationInfo, parseBundleReceiptInfo, parseBundleSentFromReceipt, pickInteropRoute, preflightDirect, preflightIndirect, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, resolveCreateDepositL1GasLimit, resolveIdsFromWaitable, toGasOverrides };
|
|
672
|
+
export { DEFAULT_POLL_MS, DEFAULT_TIMEOUT_MS, ZERO_HASH, applyPriorityL2GasLimitBuffer, assertProtocolVersion, buildDirectBundle, buildFeeBreakdown, buildFinalizationInfo, buildIndirectBundle, createAttributesResource, createNTVCodec, derivePriorityBodyGasEstimateCap, derivePriorityTxGasBreakdown, isInteropFinalizationInfo, parseBundleReceiptInfo, parseBundleSentFromReceipt, phaseFromReadiness, pickInteropRoute, preflightDirect, preflightIndirect, quoteL1Gas, quoteL2BaseCost, quoteL2Gas, quoteL2Gas2, resolveCreateDepositL1GasLimit, resolveIdsFromWaitable, toGasOverrides };
|
|
@@ -40,6 +40,14 @@ function isL1MessageSentLog(log, opts) {
|
|
|
40
40
|
const preferAddr = extractPreferAddress(opts);
|
|
41
41
|
return log.address.toLowerCase() === preferAddr && (topic === TOPIC_L1_MESSAGE_SENT_LEG.toLowerCase() || topic === TOPIC_L1_MESSAGE_SENT_NEW.toLowerCase());
|
|
42
42
|
}
|
|
43
|
+
var SENDER_TOPIC = /^0x0{24}([0-9a-fA-F]{40})$/;
|
|
44
|
+
function l1MessageSentSender(log) {
|
|
45
|
+
const sender = SENDER_TOPIC.exec(log.topics?.[1] ?? "")?.[1];
|
|
46
|
+
if (!sender) {
|
|
47
|
+
throw new Error("L1MessageSent log has no valid sender topic.");
|
|
48
|
+
}
|
|
49
|
+
return `0x${sender.toLowerCase()}`;
|
|
50
|
+
}
|
|
43
51
|
|
|
44
52
|
// src/core/resources/withdrawals/logs.ts
|
|
45
53
|
function messengerLogIndex(raw, opts) {
|
|
@@ -53,4 +61,4 @@ function messengerLogIndex(raw, opts) {
|
|
|
53
61
|
return (hits[index] ?? hits[0]).i;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
export { findL1MessageSentLog, isL1MessageSentLog, messengerLogIndex, pickWithdrawRoute };
|
|
64
|
+
export { findL1MessageSentLog, isL1MessageSentLog, l1MessageSentSender, messengerLogIndex, pickWithdrawRoute };
|
package/dist/core/index.cjs
CHANGED
|
@@ -7369,6 +7369,14 @@ function isL1MessageSentLog(log, opts) {
|
|
|
7369
7369
|
const preferAddr = extractPreferAddress(opts);
|
|
7370
7370
|
return log.address.toLowerCase() === preferAddr && (topic === TOPIC_L1_MESSAGE_SENT_LEG.toLowerCase() || topic === TOPIC_L1_MESSAGE_SENT_NEW.toLowerCase());
|
|
7371
7371
|
}
|
|
7372
|
+
var SENDER_TOPIC = /^0x0{24}([0-9a-fA-F]{40})$/;
|
|
7373
|
+
function l1MessageSentSender(log) {
|
|
7374
|
+
const sender = SENDER_TOPIC.exec(log.topics?.[1] ?? "")?.[1];
|
|
7375
|
+
if (!sender) {
|
|
7376
|
+
throw new Error("L1MessageSent log has no valid sender topic.");
|
|
7377
|
+
}
|
|
7378
|
+
return `0x${sender.toLowerCase()}`;
|
|
7379
|
+
}
|
|
7372
7380
|
|
|
7373
7381
|
// src/core/resources/withdrawals/logs.ts
|
|
7374
7382
|
function messengerLogIndex(raw, opts) {
|
|
@@ -7402,6 +7410,7 @@ exports.isHash66 = isHash66;
|
|
|
7402
7410
|
exports.isHash66Array = isHash66Array;
|
|
7403
7411
|
exports.isHashArray = isHashArray;
|
|
7404
7412
|
exports.isL1MessageSentLog = isL1MessageSentLog;
|
|
7413
|
+
exports.l1MessageSentSender = l1MessageSentSender;
|
|
7405
7414
|
exports.makeTransportFromEthers = makeTransportFromEthers;
|
|
7406
7415
|
exports.makeTransportFromViem = makeTransportFromViem;
|
|
7407
7416
|
exports.messengerLogIndex = messengerLogIndex;
|