@matterlabs/zksync-js 0.0.7 → 0.0.8
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 +75 -33
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.js +6 -6
- package/dist/adapters/ethers/index.cjs +122 -73
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +9 -9
- package/dist/adapters/ethers/sdk.cjs +26 -13
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +7 -7
- package/dist/adapters/viem/client.cjs +75 -33
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.js +4 -4
- package/dist/adapters/viem/index.cjs +122 -73
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +8 -8
- package/dist/adapters/viem/sdk.cjs +45 -34
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +6 -6
- package/dist/{chunk-GIXLOHLK.js → chunk-3GFCAGGI.js} +1430 -7
- package/dist/{chunk-KAMEGD6I.js → chunk-5V2JRM5J.js} +1 -1
- package/dist/{chunk-EWLA4NUE.js → chunk-63DNJXS3.js} +7 -8
- package/dist/{chunk-NCR42O6O.js → chunk-C3AGOEHR.js} +11 -1
- package/dist/{chunk-NGXRO2ZX.js → chunk-FGXRG2JS.js} +4 -4
- package/dist/{chunk-VRL6Y4YJ.js → chunk-L343N56B.js} +1 -1
- package/dist/{chunk-KRIRXY74.js → chunk-LNIEQ7AN.js} +7 -8
- package/dist/{chunk-NNFWIAVG.js → chunk-NODVRI3E.js} +2 -2
- package/dist/{chunk-GNERKUWO.js → chunk-NVULC4JB.js} +2 -2
- package/dist/{chunk-7VP6742W.js → chunk-ODMBZ2VX.js} +3 -3
- package/dist/{chunk-P5PIWVEO.js → chunk-QZVYN3YA.js} +30 -7
- package/dist/{chunk-WY36Z6YB.js → chunk-SHQQI3UD.js} +57 -19
- package/dist/core/abi.d.ts +5 -0
- package/dist/core/constants.cjs +10 -0
- package/dist/core/constants.cjs.map +1 -1
- package/dist/core/constants.d.ts +10 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +1673 -184
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +2 -1
- package/dist/core/index.js +5 -5
- package/dist/core/internal/abis/IERC7786Attributes.d.ts +42 -0
- package/dist/core/internal/abis/IInteropCenter.d.ts +211 -0
- package/dist/core/internal/abis/IInteropHandler.d.ts +166 -0
- package/dist/core/internal/abis/InteropCenter.d.ts +578 -0
- package/dist/core/internal/abis/InteropRootStorage.d.ts +20 -0
- package/dist/core/internal/abis/L2MessageVerification.d.ts +277 -0
- package/dist/core/resources/interop/attributes/bundle.d.ts +6 -0
- package/dist/core/resources/interop/attributes/call.d.ts +6 -0
- package/dist/core/resources/interop/attributes/index.d.ts +4 -0
- package/dist/core/resources/interop/attributes/resource.d.ts +12 -0
- package/dist/core/resources/interop/attributes/types.d.ts +6 -0
- package/dist/core/resources/interop/events.d.ts +7 -0
- package/dist/core/resources/interop/finalization.d.ts +61 -0
- package/dist/core/resources/interop/plan.d.ts +39 -0
- package/dist/core/resources/interop/route.d.ts +15 -0
- package/dist/core/rpc/types.d.ts +9 -0
- package/dist/core/types/errors.d.ts +43 -2
- package/dist/core/types/flows/base.d.ts +1 -1
- package/dist/core/types/flows/interop.d.ts +231 -0
- package/dist/core/types/flows/withdrawals.d.ts +0 -8
- package/dist/core/types/transactions.d.ts +10 -0
- package/dist/core/utils/addr.d.ts +2 -2
- package/dist/core/utils/events.d.ts +12 -0
- package/dist/core/utils/hash.d.ts +5 -0
- package/dist/core/utils/index.d.ts +5 -0
- package/dist/core/utils/number.d.ts +2 -0
- package/dist/index.cjs +1683 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -5
- package/package.json +6 -2
- package/dist/core/resources/withdrawals/events.d.ts +0 -9
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { createEthersClient as createClient, createEthersClient } from '../../chunk-
|
|
2
|
-
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs } from '../../chunk-
|
|
3
|
-
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
9
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersClient as createClient, createEthersClient } from '../../chunk-FGXRG2JS.js';
|
|
2
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs } from '../../chunk-63DNJXS3.js';
|
|
3
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-NVULC4JB.js';
|
|
4
|
+
import '../../chunk-NODVRI3E.js';
|
|
5
|
+
import '../../chunk-QZVYN3YA.js';
|
|
6
|
+
import '../../chunk-5V2JRM5J.js';
|
|
7
|
+
import '../../chunk-SHQQI3UD.js';
|
|
8
|
+
import '../../chunk-3GFCAGGI.js';
|
|
9
|
+
import '../../chunk-C3AGOEHR.js';
|
|
@@ -5,6 +5,14 @@ var sha3 = require('@noble/hashes/sha3');
|
|
|
5
5
|
var utils = require('@noble/hashes/utils');
|
|
6
6
|
|
|
7
7
|
// src/adapters/ethers/resources/deposits/services/verification.ts
|
|
8
|
+
|
|
9
|
+
// src/core/utils/hash.ts
|
|
10
|
+
var RegExpHex = /^0x[0-9a-fA-F]*$/;
|
|
11
|
+
var isHash = (x, length) => {
|
|
12
|
+
if (!x || typeof x !== "string") return false;
|
|
13
|
+
return (x.length === length) && RegExpHex.test(x);
|
|
14
|
+
};
|
|
15
|
+
var isHash66 = (x) => isHash(x, 66);
|
|
8
16
|
var k256hex = (s) => `0x${utils.bytesToHex(sha3.keccak_256(utils.utf8ToBytes(s)))}`.toLowerCase();
|
|
9
17
|
var FORMAL_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
10
18
|
var ETH_ADDRESS = "0x0000000000000000000000000000000000000001";
|
|
@@ -23,8 +31,11 @@ var DEFAULT_PUBDATA_BYTES = 155n;
|
|
|
23
31
|
var DEFAULT_ABI_BYTES = 400n;
|
|
24
32
|
var SAFE_L1_BRIDGE_GAS = 700000n;
|
|
25
33
|
|
|
34
|
+
// src/core/utils/number.ts
|
|
35
|
+
var isNumber = (x) => typeof x === "number" && Number.isFinite(x);
|
|
36
|
+
var isBigint = (x) => typeof x === "bigint";
|
|
37
|
+
|
|
26
38
|
// src/core/utils/addr.ts
|
|
27
|
-
var isHash66 = (x) => !!x && x.startsWith("0x") && x.length === 66;
|
|
28
39
|
function isAddressEq(a, b) {
|
|
29
40
|
return a.toLowerCase() === b.toLowerCase();
|
|
30
41
|
}
|
|
@@ -53,7 +64,7 @@ function shortJSON(v, max = 240) {
|
|
|
53
64
|
try {
|
|
54
65
|
const s = JSON.stringify(
|
|
55
66
|
v,
|
|
56
|
-
(_k, val) =>
|
|
67
|
+
(_k, val) => isBigint(val) ? `${val.toString()}n` : val
|
|
57
68
|
);
|
|
58
69
|
return s.length > max ? elideMiddle(s, max) : s;
|
|
59
70
|
} catch {
|
|
@@ -73,7 +84,7 @@ function formatContextLine(ctx) {
|
|
|
73
84
|
if (txHash !== void 0)
|
|
74
85
|
parts.push(`txHash=${typeof txHash === "string" ? txHash : shortJSON(txHash, 96)}`);
|
|
75
86
|
if (nonce !== void 0) {
|
|
76
|
-
const nonceStr = typeof nonce === "string" ||
|
|
87
|
+
const nonceStr = typeof nonce === "string" || isNumber(nonce) || isBigint(nonce) ? String(nonce) : shortJSON(nonce, 48);
|
|
77
88
|
parts.push(`nonce=${nonceStr}`);
|
|
78
89
|
}
|
|
79
90
|
return parts.length ? ` ${kv("Context", parts.join(" \u2022 "))}` : void 0;
|
|
@@ -103,17 +114,17 @@ function formatCause(c) {
|
|
|
103
114
|
const head = [];
|
|
104
115
|
if (obj.name !== void 0) {
|
|
105
116
|
const nameVal = obj.name;
|
|
106
|
-
const nameStr = typeof nameVal === "string" ||
|
|
117
|
+
const nameStr = typeof nameVal === "string" || isNumber(nameVal) || isBigint(nameVal) || typeof nameVal === "boolean" ? String(nameVal) : shortJSON(nameVal, 120);
|
|
107
118
|
head.push(`name=${nameStr}`);
|
|
108
119
|
}
|
|
109
120
|
if (obj.code !== void 0) {
|
|
110
121
|
const codeVal = obj.code;
|
|
111
|
-
const codeStr = typeof codeVal === "string" ||
|
|
122
|
+
const codeStr = typeof codeVal === "string" || isNumber(codeVal) || isBigint(codeVal) || typeof codeVal === "boolean" ? String(codeVal) : shortJSON(codeVal, 120);
|
|
112
123
|
head.push(`code=${codeStr}`);
|
|
113
124
|
}
|
|
114
125
|
if (head.length) out.push(` ${kv("Cause", head.join(" "))}`);
|
|
115
126
|
if (obj.message) {
|
|
116
|
-
const messageStr = typeof obj.message === "string" ||
|
|
127
|
+
const messageStr = typeof obj.message === "string" || isNumber(obj.message) || isBigint(obj.message) || typeof obj.message === "boolean" ? String(obj.message) : shortJSON(obj.message, 600);
|
|
117
128
|
out.push(` message=${elideMiddle(messageStr, 600)}`);
|
|
118
129
|
}
|
|
119
130
|
if (obj.data) {
|
|
@@ -5420,8 +5431,7 @@ function routeErc20NonBase2() {
|
|
|
5420
5431
|
tx: approveTx
|
|
5421
5432
|
});
|
|
5422
5433
|
}
|
|
5423
|
-
const
|
|
5424
|
-
const assetId = resolved?.assetId ?? await wrapAs7(
|
|
5434
|
+
const assetId = await wrapAs7(
|
|
5425
5435
|
"CONTRACT",
|
|
5426
5436
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
5427
5437
|
async () => {
|
|
@@ -5460,7 +5470,7 @@ function routeErc20NonBase2() {
|
|
|
5460
5470
|
data: dataWithdraw,
|
|
5461
5471
|
from: ctx.sender
|
|
5462
5472
|
};
|
|
5463
|
-
const withdrawGas = await quoteL2Gas4({ ctx, tx: withdrawTx });
|
|
5473
|
+
const withdrawGas = current >= p.amount ? await quoteL2Gas4({ ctx, tx: withdrawTx }) : void 0;
|
|
5464
5474
|
if (withdrawGas) {
|
|
5465
5475
|
withdrawTx.gasLimit = withdrawGas.gasLimit;
|
|
5466
5476
|
withdrawTx.maxFeePerGas = withdrawGas.maxFeePerGas;
|
|
@@ -5481,11 +5491,14 @@ function routeErc20NonBase2() {
|
|
|
5481
5491
|
};
|
|
5482
5492
|
}
|
|
5483
5493
|
|
|
5484
|
-
// src/core/
|
|
5494
|
+
// src/core/utils/events.ts
|
|
5495
|
+
function extractPreferAddress(opts) {
|
|
5496
|
+
const preferAddr = typeof opts?.prefer === "object" ? opts.prefer.address : opts?.prefer === "assetRouter" ? L2_ASSET_ROUTER_ADDRESS : L1_MESSENGER_ADDRESS;
|
|
5497
|
+
return (preferAddr || L1_MESSENGER_ADDRESS).toLowerCase();
|
|
5498
|
+
}
|
|
5485
5499
|
function findL1MessageSentLog(receipt, opts) {
|
|
5486
5500
|
const index = opts?.index;
|
|
5487
|
-
const preferAddr =
|
|
5488
|
-
const prefer = (preferAddr ?? L1_MESSENGER_ADDRESS).toLowerCase();
|
|
5501
|
+
const preferAddr = extractPreferAddress(opts);
|
|
5489
5502
|
const matches = receipt.logs.filter((lg) => {
|
|
5490
5503
|
const t0 = (lg.topics?.[0] ?? "").toLowerCase();
|
|
5491
5504
|
return t0 === TOPIC_L1_MESSAGE_SENT_NEW || t0 === TOPIC_L1_MESSAGE_SENT_LEG;
|
|
@@ -5493,7 +5506,7 @@ function findL1MessageSentLog(receipt, opts) {
|
|
|
5493
5506
|
if (!matches.length) {
|
|
5494
5507
|
throw new Error("No L1MessageSent event found in L2 receipt logs.");
|
|
5495
5508
|
}
|
|
5496
|
-
const preferred = matches.find((lg) => (lg.address ?? "").toLowerCase() ===
|
|
5509
|
+
const preferred = matches.find((lg) => (lg.address ?? "").toLowerCase() === preferAddr);
|
|
5497
5510
|
const chosen = preferred ?? matches[index] ?? matches[0];
|
|
5498
5511
|
if (!chosen) {
|
|
5499
5512
|
throw new Error("No suitable L1MessageSent event found.");
|