@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 { buildDirectRequestStruct, createContractsResource, createDepositsResource, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createViemSdk, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
export { buildDirectRequestStruct, createContractsResource, createDepositsResource, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createViemSdk, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-7GZDTLHX.js';
|
|
2
|
+
import '../../chunk-IDXSGCGF.js';
|
|
3
|
+
import '../../chunk-LGTYM5XP.js';
|
|
4
4
|
export { createViemClient as createClient, createViemClient } from '../../chunk-CK5UFAZK.js';
|
|
5
5
|
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-SBGBYZJM.js';
|
|
6
6
|
import '../../chunk-BWKWWLY4.js';
|
|
@@ -8614,6 +8614,14 @@ function isL1MessageSentLog(log, opts) {
|
|
|
8614
8614
|
const preferAddr = extractPreferAddress(opts);
|
|
8615
8615
|
return log.address.toLowerCase() === preferAddr && (topic === TOPIC_L1_MESSAGE_SENT_LEG.toLowerCase() || topic === TOPIC_L1_MESSAGE_SENT_NEW.toLowerCase());
|
|
8616
8616
|
}
|
|
8617
|
+
var SENDER_TOPIC = /^0x0{24}([0-9a-fA-F]{40})$/;
|
|
8618
|
+
function l1MessageSentSender(log) {
|
|
8619
|
+
const sender = SENDER_TOPIC.exec(log.topics?.[1] ?? "")?.[1];
|
|
8620
|
+
if (!sender) {
|
|
8621
|
+
throw new Error("L1MessageSent log has no valid sender topic.");
|
|
8622
|
+
}
|
|
8623
|
+
return `0x${sender.toLowerCase()}`;
|
|
8624
|
+
}
|
|
8617
8625
|
|
|
8618
8626
|
// src/core/resources/withdrawals/logs.ts
|
|
8619
8627
|
function messengerLogIndex(raw, opts) {
|
|
@@ -8728,7 +8736,7 @@ function createFinalizationServices(client) {
|
|
|
8728
8736
|
chainId: BigInt(chainId),
|
|
8729
8737
|
l2BatchNumber: proof.batchNumber,
|
|
8730
8738
|
l2MessageIndex: proof.id,
|
|
8731
|
-
l2Sender:
|
|
8739
|
+
l2Sender: l1MessageSentSender(ev),
|
|
8732
8740
|
l2TxNumberInBatch: txIndex,
|
|
8733
8741
|
message,
|
|
8734
8742
|
merkleProof: proof.proof
|
|
@@ -8903,6 +8911,23 @@ function createFinalizationServices(client) {
|
|
|
8903
8911
|
};
|
|
8904
8912
|
}
|
|
8905
8913
|
|
|
8914
|
+
// src/core/resources/withdrawals/status.ts
|
|
8915
|
+
function phaseFromReadiness(r) {
|
|
8916
|
+
switch (r.kind) {
|
|
8917
|
+
case "FINALIZED":
|
|
8918
|
+
return { phase: "FINALIZED" };
|
|
8919
|
+
case "READY":
|
|
8920
|
+
return { phase: "READY_TO_FINALIZE" };
|
|
8921
|
+
case "NOT_READY":
|
|
8922
|
+
return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
|
|
8923
|
+
case "UNFINALIZABLE":
|
|
8924
|
+
return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
|
|
8925
|
+
default:
|
|
8926
|
+
return assertNever(r);
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
|
|
8930
|
+
|
|
8906
8931
|
// src/adapters/viem/resources/withdrawals/index.ts
|
|
8907
8932
|
var ROUTES2 = {
|
|
8908
8933
|
base: routeEthBase(),
|
|
@@ -9100,9 +9125,8 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
9100
9125
|
} catch {
|
|
9101
9126
|
}
|
|
9102
9127
|
const readiness = await svc.simulateFinalizeReadiness(pack.params);
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
return { phase: "PENDING", l2TxHash, key };
|
|
9128
|
+
const { phase, reason } = phaseFromReadiness(readiness);
|
|
9129
|
+
return { phase, reason, l2TxHash, key };
|
|
9106
9130
|
},
|
|
9107
9131
|
{
|
|
9108
9132
|
message: "Internal error while checking withdrawal status.",
|
|
@@ -9150,6 +9174,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
9150
9174
|
const deadline = opts.timeoutMs ? Date.now() + opts.timeoutMs : void 0;
|
|
9151
9175
|
while (true) {
|
|
9152
9176
|
const s = await status(l2Hash);
|
|
9177
|
+
if (s.phase === "UNFINALIZABLE") {
|
|
9178
|
+
throw createError("STATE", {
|
|
9179
|
+
resource: "withdrawals",
|
|
9180
|
+
operation: OP_WITHDRAWALS.wait,
|
|
9181
|
+
message: "Withdrawal can never be finalized.",
|
|
9182
|
+
context: { l2TxHash: l2Hash, reason: s.reason }
|
|
9183
|
+
});
|
|
9184
|
+
}
|
|
9153
9185
|
if (opts.for === "ready") {
|
|
9154
9186
|
if (s.phase === "READY_TO_FINALIZE" || s.phase === "FINALIZED") return null;
|
|
9155
9187
|
} else {
|