@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,8 +1,8 @@
|
|
|
1
1
|
export { createEthersClient as createClient, createEthersClient } from '../../chunk-24TE2NNJ.js';
|
|
2
|
-
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-
|
|
2
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-2CGBLD5H.js';
|
|
3
3
|
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-NJK325XV.js';
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
4
|
+
import '../../chunk-IDXSGCGF.js';
|
|
5
|
+
import '../../chunk-LGTYM5XP.js';
|
|
6
6
|
import '../../chunk-BWKWWLY4.js';
|
|
7
7
|
import '../../chunk-JSBMIT4S.js';
|
|
8
8
|
import '../../chunk-UEKFQAOS.js';
|
|
@@ -8127,6 +8127,14 @@ function isL1MessageSentLog(log, opts) {
|
|
|
8127
8127
|
const preferAddr = extractPreferAddress(opts);
|
|
8128
8128
|
return log.address.toLowerCase() === preferAddr && (topic === TOPIC_L1_MESSAGE_SENT_LEG.toLowerCase() || topic === TOPIC_L1_MESSAGE_SENT_NEW.toLowerCase());
|
|
8129
8129
|
}
|
|
8130
|
+
var SENDER_TOPIC = /^0x0{24}([0-9a-fA-F]{40})$/;
|
|
8131
|
+
function l1MessageSentSender(log) {
|
|
8132
|
+
const sender = SENDER_TOPIC.exec(log.topics?.[1] ?? "")?.[1];
|
|
8133
|
+
if (!sender) {
|
|
8134
|
+
throw new Error("L1MessageSent log has no valid sender topic.");
|
|
8135
|
+
}
|
|
8136
|
+
return `0x${sender.toLowerCase()}`;
|
|
8137
|
+
}
|
|
8130
8138
|
|
|
8131
8139
|
// src/core/resources/withdrawals/logs.ts
|
|
8132
8140
|
function messengerLogIndex(raw, opts) {
|
|
@@ -8234,7 +8242,7 @@ function createFinalizationServices(client) {
|
|
|
8234
8242
|
chainId: BigInt(chainId),
|
|
8235
8243
|
l2BatchNumber: proof.batchNumber,
|
|
8236
8244
|
l2MessageIndex: proof.id,
|
|
8237
|
-
l2Sender:
|
|
8245
|
+
l2Sender: l1MessageSentSender(ev),
|
|
8238
8246
|
l2TxNumberInBatch: txIndex,
|
|
8239
8247
|
message,
|
|
8240
8248
|
merkleProof: proof.proof
|
|
@@ -8373,6 +8381,23 @@ function createFinalizationServices(client) {
|
|
|
8373
8381
|
};
|
|
8374
8382
|
}
|
|
8375
8383
|
|
|
8384
|
+
// src/core/resources/withdrawals/status.ts
|
|
8385
|
+
function phaseFromReadiness(r) {
|
|
8386
|
+
switch (r.kind) {
|
|
8387
|
+
case "FINALIZED":
|
|
8388
|
+
return { phase: "FINALIZED" };
|
|
8389
|
+
case "READY":
|
|
8390
|
+
return { phase: "READY_TO_FINALIZE" };
|
|
8391
|
+
case "NOT_READY":
|
|
8392
|
+
return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
|
|
8393
|
+
case "UNFINALIZABLE":
|
|
8394
|
+
return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
|
|
8395
|
+
default:
|
|
8396
|
+
return assertNever(r);
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
|
|
8400
|
+
|
|
8376
8401
|
// src/adapters/ethers/resources/withdrawals/index.ts
|
|
8377
8402
|
var ROUTES2 = {
|
|
8378
8403
|
base: routeEthBase(),
|
|
@@ -8547,9 +8572,8 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
8547
8572
|
} catch {
|
|
8548
8573
|
}
|
|
8549
8574
|
const readiness = await svc.simulateFinalizeReadiness(pack.params);
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
return { phase: "PENDING", l2TxHash, key };
|
|
8575
|
+
const { phase, reason } = phaseFromReadiness(readiness);
|
|
8576
|
+
return { phase, reason, l2TxHash, key };
|
|
8553
8577
|
},
|
|
8554
8578
|
{
|
|
8555
8579
|
message: "Internal error while checking withdrawal status.",
|
|
@@ -8593,6 +8617,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
8593
8617
|
const deadline = opts.timeoutMs ? Date.now() + opts.timeoutMs : void 0;
|
|
8594
8618
|
while (true) {
|
|
8595
8619
|
const s = await status(l2Hash);
|
|
8620
|
+
if (s.phase === "UNFINALIZABLE") {
|
|
8621
|
+
throw createError("STATE", {
|
|
8622
|
+
resource: "withdrawals",
|
|
8623
|
+
operation: OP_WITHDRAWALS.wait,
|
|
8624
|
+
message: "Withdrawal can never be finalized.",
|
|
8625
|
+
context: { l2TxHash: l2Hash, reason: s.reason }
|
|
8626
|
+
});
|
|
8627
|
+
}
|
|
8596
8628
|
if (opts.for === "ready") {
|
|
8597
8629
|
if (s.phase === "READY_TO_FINALIZE" || s.phase === "FINALIZED") return null;
|
|
8598
8630
|
} else {
|