@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,8 +1,8 @@
|
|
|
1
|
-
export { buildDirectRequestStruct, classifyReadinessFromRevert, createContractsResource, createDepositsResource, createErrorHandlers, createFinalizationServices, createTokensResource, createViemSdk, createWithdrawalsResource, decodeRevert, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, registerErrorAbi, toZKsyncError } from '../../chunk-
|
|
2
|
-
import '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
export { createViemClient as createClient, createViemClient } from '../../chunk-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
1
|
+
export { buildDirectRequestStruct, classifyReadinessFromRevert, createContractsResource, createDepositsResource, createErrorHandlers, createFinalizationServices, createTokensResource, createViemSdk, createWithdrawalsResource, decodeRevert, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, registerErrorAbi, toZKsyncError } from '../../chunk-LNIEQ7AN.js';
|
|
2
|
+
import '../../chunk-NODVRI3E.js';
|
|
3
|
+
import '../../chunk-QZVYN3YA.js';
|
|
4
|
+
import '../../chunk-5V2JRM5J.js';
|
|
5
|
+
export { createViemClient as createClient, createViemClient } from '../../chunk-ODMBZ2VX.js';
|
|
6
|
+
import '../../chunk-SHQQI3UD.js';
|
|
7
|
+
import '../../chunk-3GFCAGGI.js';
|
|
8
|
+
import '../../chunk-C3AGOEHR.js';
|
|
@@ -3736,6 +3736,37 @@ function buildDirectRequestStruct(args) {
|
|
|
3736
3736
|
};
|
|
3737
3737
|
}
|
|
3738
3738
|
|
|
3739
|
+
// src/core/utils/hash.ts
|
|
3740
|
+
var RegExpHex = /^0x[0-9a-fA-F]*$/;
|
|
3741
|
+
var isHash = (x, length) => {
|
|
3742
|
+
if (!x || typeof x !== "string") return false;
|
|
3743
|
+
return (x.length === length) && RegExpHex.test(x);
|
|
3744
|
+
};
|
|
3745
|
+
var isHash66 = (x) => isHash(x, 66);
|
|
3746
|
+
|
|
3747
|
+
// src/core/utils/number.ts
|
|
3748
|
+
var isNumber = (x) => typeof x === "number" && Number.isFinite(x);
|
|
3749
|
+
var isBigint = (x) => typeof x === "bigint";
|
|
3750
|
+
|
|
3751
|
+
// src/core/utils/addr.ts
|
|
3752
|
+
function isAddressEq(a, b) {
|
|
3753
|
+
return a.toLowerCase() === b.toLowerCase();
|
|
3754
|
+
}
|
|
3755
|
+
function isETH(token) {
|
|
3756
|
+
return isAddressEq(token, FORMAL_ETH_ADDRESS) || isAddressEq(token, L2_BASE_TOKEN_ADDRESS) || isAddressEq(token, ETH_ADDRESS);
|
|
3757
|
+
}
|
|
3758
|
+
function normalizeAddrEq(a, b) {
|
|
3759
|
+
if (!a || !b) return false;
|
|
3760
|
+
const normalize = (s) => {
|
|
3761
|
+
const hasPrefix = s.slice(0, 2).toLowerCase() === "0x";
|
|
3762
|
+
const body = hasPrefix ? s.slice(2) : s;
|
|
3763
|
+
return `0x${body.toLowerCase()}`;
|
|
3764
|
+
};
|
|
3765
|
+
return normalize(a) === normalize(b);
|
|
3766
|
+
}
|
|
3767
|
+
var hexEq = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
3768
|
+
var normalizeL1Token = (token) => isAddressEq(token, FORMAL_ETH_ADDRESS) ? ETH_ADDRESS : token;
|
|
3769
|
+
|
|
3739
3770
|
// src/core/errors/formatter.ts
|
|
3740
3771
|
function elideMiddle(s, max = 96) {
|
|
3741
3772
|
if (s.length <= max) return s;
|
|
@@ -3746,7 +3777,7 @@ function shortJSON(v, max = 240) {
|
|
|
3746
3777
|
try {
|
|
3747
3778
|
const s = JSON.stringify(
|
|
3748
3779
|
v,
|
|
3749
|
-
(_k, val) =>
|
|
3780
|
+
(_k, val) => isBigint(val) ? `${val.toString()}n` : val
|
|
3750
3781
|
);
|
|
3751
3782
|
return s.length > max ? elideMiddle(s, max) : s;
|
|
3752
3783
|
} catch {
|
|
@@ -3766,7 +3797,7 @@ function formatContextLine(ctx) {
|
|
|
3766
3797
|
if (txHash !== void 0)
|
|
3767
3798
|
parts.push(`txHash=${typeof txHash === "string" ? txHash : shortJSON(txHash, 96)}`);
|
|
3768
3799
|
if (nonce !== void 0) {
|
|
3769
|
-
const nonceStr = typeof nonce === "string" ||
|
|
3800
|
+
const nonceStr = typeof nonce === "string" || isNumber(nonce) || isBigint(nonce) ? String(nonce) : shortJSON(nonce, 48);
|
|
3770
3801
|
parts.push(`nonce=${nonceStr}`);
|
|
3771
3802
|
}
|
|
3772
3803
|
return parts.length ? ` ${kv("Context", parts.join(" \u2022 "))}` : void 0;
|
|
@@ -3796,17 +3827,17 @@ function formatCause(c) {
|
|
|
3796
3827
|
const head = [];
|
|
3797
3828
|
if (obj.name !== void 0) {
|
|
3798
3829
|
const nameVal = obj.name;
|
|
3799
|
-
const nameStr = typeof nameVal === "string" ||
|
|
3830
|
+
const nameStr = typeof nameVal === "string" || isNumber(nameVal) || isBigint(nameVal) || typeof nameVal === "boolean" ? String(nameVal) : shortJSON(nameVal, 120);
|
|
3800
3831
|
head.push(`name=${nameStr}`);
|
|
3801
3832
|
}
|
|
3802
3833
|
if (obj.code !== void 0) {
|
|
3803
3834
|
const codeVal = obj.code;
|
|
3804
|
-
const codeStr = typeof codeVal === "string" ||
|
|
3835
|
+
const codeStr = typeof codeVal === "string" || isNumber(codeVal) || isBigint(codeVal) || typeof codeVal === "boolean" ? String(codeVal) : shortJSON(codeVal, 120);
|
|
3805
3836
|
head.push(`code=${codeStr}`);
|
|
3806
3837
|
}
|
|
3807
3838
|
if (head.length) out.push(` ${kv("Cause", head.join(" "))}`);
|
|
3808
3839
|
if (obj.message) {
|
|
3809
|
-
const messageStr = typeof obj.message === "string" ||
|
|
3840
|
+
const messageStr = typeof obj.message === "string" || isNumber(obj.message) || isBigint(obj.message) || typeof obj.message === "boolean" ? String(obj.message) : shortJSON(obj.message, 600);
|
|
3810
3841
|
out.push(` message=${elideMiddle(messageStr, 600)}`);
|
|
3811
3842
|
}
|
|
3812
3843
|
if (obj.data) {
|
|
@@ -4634,28 +4665,6 @@ function routeEthDirect() {
|
|
|
4634
4665
|
}
|
|
4635
4666
|
};
|
|
4636
4667
|
}
|
|
4637
|
-
|
|
4638
|
-
// src/core/utils/addr.ts
|
|
4639
|
-
var isHash66 = (x) => !!x && x.startsWith("0x") && x.length === 66;
|
|
4640
|
-
function isAddressEq(a, b) {
|
|
4641
|
-
return a.toLowerCase() === b.toLowerCase();
|
|
4642
|
-
}
|
|
4643
|
-
function isETH(token) {
|
|
4644
|
-
return isAddressEq(token, FORMAL_ETH_ADDRESS) || isAddressEq(token, L2_BASE_TOKEN_ADDRESS) || isAddressEq(token, ETH_ADDRESS);
|
|
4645
|
-
}
|
|
4646
|
-
function normalizeAddrEq(a, b) {
|
|
4647
|
-
if (!a || !b) return false;
|
|
4648
|
-
const normalize = (s) => {
|
|
4649
|
-
const hasPrefix = s.slice(0, 2).toLowerCase() === "0x";
|
|
4650
|
-
const body = hasPrefix ? s.slice(2) : s;
|
|
4651
|
-
return `0x${body.toLowerCase()}`;
|
|
4652
|
-
};
|
|
4653
|
-
return normalize(a) === normalize(b);
|
|
4654
|
-
}
|
|
4655
|
-
var hexEq = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
4656
|
-
var normalizeL1Token = (token) => isAddressEq(token, FORMAL_ETH_ADDRESS) ? ETH_ADDRESS : token;
|
|
4657
|
-
|
|
4658
|
-
// src/adapters/viem/resources/deposits/routes/erc20-nonbase.ts
|
|
4659
4668
|
var { wrapAs: wrapAs3 } = createErrorHandlers("deposits");
|
|
4660
4669
|
function routeErc20NonBase() {
|
|
4661
4670
|
return {
|
|
@@ -6201,8 +6210,7 @@ function routeErc20NonBase2() {
|
|
|
6201
6210
|
tx: approveTx
|
|
6202
6211
|
});
|
|
6203
6212
|
}
|
|
6204
|
-
const
|
|
6205
|
-
const assetId = resolved?.assetId ?? (await wrapAs8(
|
|
6213
|
+
const assetId = (await wrapAs8(
|
|
6206
6214
|
"CONTRACT",
|
|
6207
6215
|
OP_WITHDRAWALS.erc20.ensureRegistered,
|
|
6208
6216
|
() => ctx.client.l2.simulateContract({
|
|
@@ -6236,7 +6244,7 @@ function routeErc20NonBase2() {
|
|
|
6236
6244
|
value: 0n,
|
|
6237
6245
|
from: ctx.sender
|
|
6238
6246
|
};
|
|
6239
|
-
const withdrawGas = await quoteL2Gas4({ ctx, tx: withdrawTxCandidate });
|
|
6247
|
+
const withdrawGas = current >= p.amount ? await quoteL2Gas4({ ctx, tx: withdrawTxCandidate }) : void 0;
|
|
6240
6248
|
if (withdrawGas) {
|
|
6241
6249
|
withdrawTxCandidate.gas = withdrawGas.gasLimit;
|
|
6242
6250
|
withdrawTxCandidate.maxFeePerGas = withdrawGas.maxFeePerGas;
|
|
@@ -6290,11 +6298,14 @@ function routeErc20NonBase2() {
|
|
|
6290
6298
|
};
|
|
6291
6299
|
}
|
|
6292
6300
|
|
|
6293
|
-
// src/core/
|
|
6301
|
+
// src/core/utils/events.ts
|
|
6302
|
+
function extractPreferAddress(opts) {
|
|
6303
|
+
const preferAddr = typeof opts?.prefer === "object" ? opts.prefer.address : opts?.prefer === "assetRouter" ? L2_ASSET_ROUTER_ADDRESS : L1_MESSENGER_ADDRESS;
|
|
6304
|
+
return (preferAddr || L1_MESSENGER_ADDRESS).toLowerCase();
|
|
6305
|
+
}
|
|
6294
6306
|
function findL1MessageSentLog(receipt, opts) {
|
|
6295
6307
|
const index = opts?.index;
|
|
6296
|
-
const preferAddr =
|
|
6297
|
-
const prefer = (preferAddr ?? L1_MESSENGER_ADDRESS).toLowerCase();
|
|
6308
|
+
const preferAddr = extractPreferAddress(opts);
|
|
6298
6309
|
const matches = receipt.logs.filter((lg) => {
|
|
6299
6310
|
const t0 = (lg.topics?.[0] ?? "").toLowerCase();
|
|
6300
6311
|
return t0 === TOPIC_L1_MESSAGE_SENT_NEW || t0 === TOPIC_L1_MESSAGE_SENT_LEG;
|
|
@@ -6302,7 +6313,7 @@ function findL1MessageSentLog(receipt, opts) {
|
|
|
6302
6313
|
if (!matches.length) {
|
|
6303
6314
|
throw new Error("No L1MessageSent event found in L2 receipt logs.");
|
|
6304
6315
|
}
|
|
6305
|
-
const preferred = matches.find((lg) => (lg.address ?? "").toLowerCase() ===
|
|
6316
|
+
const preferred = matches.find((lg) => (lg.address ?? "").toLowerCase() === preferAddr);
|
|
6306
6317
|
const chosen = preferred ?? matches[index] ?? matches[0];
|
|
6307
6318
|
if (!chosen) {
|
|
6308
6319
|
throw new Error("No suitable L1MessageSent event found.");
|