@matterlabs/zksync-js 0.0.19 → 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 +38 -6
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +3 -3
- package/dist/adapters/ethers/sdk.cjs +38 -6
- 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-5H3VTIYD.js → chunk-2CGBLD5H.js} +15 -8
- 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
|
@@ -9921,7 +9921,7 @@ function routeErc20NonBase2() {
|
|
|
9921
9921
|
async build(p, ctx) {
|
|
9922
9922
|
const steps = [];
|
|
9923
9923
|
const approvals = [];
|
|
9924
|
-
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.
|
|
9924
|
+
const erc20 = new ethers.Contract(p.token, IERC20_default, ctx.client.l2);
|
|
9925
9925
|
const current = await wrapAs8(
|
|
9926
9926
|
"CONTRACT",
|
|
9927
9927
|
OP_WITHDRAWALS.erc20.allowance,
|
|
@@ -10047,6 +10047,14 @@ function isL1MessageSentLog(log, opts) {
|
|
|
10047
10047
|
const preferAddr = extractPreferAddress(opts);
|
|
10048
10048
|
return log.address.toLowerCase() === preferAddr && (topic === TOPIC_L1_MESSAGE_SENT_LEG.toLowerCase() || topic === TOPIC_L1_MESSAGE_SENT_NEW.toLowerCase());
|
|
10049
10049
|
}
|
|
10050
|
+
var SENDER_TOPIC = /^0x0{24}([0-9a-fA-F]{40})$/;
|
|
10051
|
+
function l1MessageSentSender(log) {
|
|
10052
|
+
const sender = SENDER_TOPIC.exec(log.topics?.[1] ?? "")?.[1];
|
|
10053
|
+
if (!sender) {
|
|
10054
|
+
throw new Error("L1MessageSent log has no valid sender topic.");
|
|
10055
|
+
}
|
|
10056
|
+
return `0x${sender.toLowerCase()}`;
|
|
10057
|
+
}
|
|
10050
10058
|
|
|
10051
10059
|
// src/core/resources/withdrawals/logs.ts
|
|
10052
10060
|
function messengerLogIndex(raw, opts) {
|
|
@@ -10154,7 +10162,7 @@ function createFinalizationServices(client) {
|
|
|
10154
10162
|
chainId: BigInt(chainId),
|
|
10155
10163
|
l2BatchNumber: proof.batchNumber,
|
|
10156
10164
|
l2MessageIndex: proof.id,
|
|
10157
|
-
l2Sender:
|
|
10165
|
+
l2Sender: l1MessageSentSender(ev),
|
|
10158
10166
|
l2TxNumberInBatch: txIndex,
|
|
10159
10167
|
message,
|
|
10160
10168
|
merkleProof: proof.proof
|
|
@@ -10293,6 +10301,23 @@ function createFinalizationServices(client) {
|
|
|
10293
10301
|
};
|
|
10294
10302
|
}
|
|
10295
10303
|
|
|
10304
|
+
// src/core/resources/withdrawals/status.ts
|
|
10305
|
+
function phaseFromReadiness(r) {
|
|
10306
|
+
switch (r.kind) {
|
|
10307
|
+
case "FINALIZED":
|
|
10308
|
+
return { phase: "FINALIZED" };
|
|
10309
|
+
case "READY":
|
|
10310
|
+
return { phase: "READY_TO_FINALIZE" };
|
|
10311
|
+
case "NOT_READY":
|
|
10312
|
+
return { phase: "PENDING", reason: formatReason(r.reason, r.detail) };
|
|
10313
|
+
case "UNFINALIZABLE":
|
|
10314
|
+
return { phase: "UNFINALIZABLE", reason: formatReason(r.reason, r.detail) };
|
|
10315
|
+
default:
|
|
10316
|
+
return assertNever(r);
|
|
10317
|
+
}
|
|
10318
|
+
}
|
|
10319
|
+
var formatReason = (reason, detail) => detail ? `${reason}: ${detail}` : reason;
|
|
10320
|
+
|
|
10296
10321
|
// src/adapters/ethers/resources/withdrawals/index.ts
|
|
10297
10322
|
var ROUTES2 = {
|
|
10298
10323
|
base: routeEthBase(),
|
|
@@ -10467,9 +10492,8 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10467
10492
|
} catch {
|
|
10468
10493
|
}
|
|
10469
10494
|
const readiness = await svc.simulateFinalizeReadiness(pack.params);
|
|
10470
|
-
|
|
10471
|
-
|
|
10472
|
-
return { phase: "PENDING", l2TxHash, key };
|
|
10495
|
+
const { phase, reason } = phaseFromReadiness(readiness);
|
|
10496
|
+
return { phase, reason, l2TxHash, key };
|
|
10473
10497
|
},
|
|
10474
10498
|
{
|
|
10475
10499
|
message: "Internal error while checking withdrawal status.",
|
|
@@ -10513,6 +10537,14 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
10513
10537
|
const deadline = opts.timeoutMs ? Date.now() + opts.timeoutMs : void 0;
|
|
10514
10538
|
while (true) {
|
|
10515
10539
|
const s = await status(l2Hash);
|
|
10540
|
+
if (s.phase === "UNFINALIZABLE") {
|
|
10541
|
+
throw createError("STATE", {
|
|
10542
|
+
resource: "withdrawals",
|
|
10543
|
+
operation: OP_WITHDRAWALS.wait,
|
|
10544
|
+
message: "Withdrawal can never be finalized.",
|
|
10545
|
+
context: { l2TxHash: l2Hash, reason: s.reason }
|
|
10546
|
+
});
|
|
10547
|
+
}
|
|
10516
10548
|
if (opts.for === "ready") {
|
|
10517
10549
|
if (s.phase === "READY_TO_FINALIZE" || s.phase === "FINALIZED") return null;
|
|
10518
10550
|
} else {
|
|
@@ -10966,7 +10998,7 @@ async function buildApproveSteps(approvals, ctx) {
|
|
|
10966
10998
|
async function resolveErc20AssetIds(erc20Tokens, ctx) {
|
|
10967
10999
|
const assetIds = /* @__PURE__ */ new Map();
|
|
10968
11000
|
if (erc20Tokens.length === 0) return assetIds;
|
|
10969
|
-
const ntv = new ethers.Contract(ctx.l2NativeTokenVault, L2NativeTokenVault_default, ctx.client.
|
|
11001
|
+
const ntv = new ethers.Contract(ctx.l2NativeTokenVault, L2NativeTokenVault_default, ctx.client.l2);
|
|
10970
11002
|
for (const token of erc20Tokens) {
|
|
10971
11003
|
const assetId = await ntv.getFunction("ensureTokenIsRegistered").staticCall(token);
|
|
10972
11004
|
assetIds.set(token.toLowerCase(), assetId);
|