@matterlabs/zksync-js 0.0.1 → 0.0.2
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/README.md +12 -12
- package/dist/adapters/ethers/client.cjs +642 -1
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.js +6 -5
- package/dist/adapters/ethers/estimator.d.ts +4 -0
- package/dist/adapters/ethers/index.cjs +934 -801
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +9 -8
- package/dist/adapters/ethers/resources/deposits/context.d.ts +5 -5
- package/dist/adapters/ethers/resources/deposits/routes/types.d.ts +2 -6
- package/dist/adapters/ethers/resources/deposits/services/fee.d.ts +6 -0
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +40 -0
- package/dist/adapters/ethers/resources/utils.d.ts +4 -15
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +4 -4
- package/dist/adapters/ethers/resources/withdrawals/routes/types.d.ts +2 -2
- package/dist/adapters/ethers/resources/withdrawals/services/fees.d.ts +14 -0
- package/dist/adapters/ethers/resources/withdrawals/services/gas.d.ts +12 -0
- package/dist/adapters/ethers/sdk.cjs +947 -1292
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +7 -6
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +1 -1
- package/dist/adapters/viem/client.js +4 -5
- package/dist/adapters/viem/estimator.d.ts +4 -0
- package/dist/adapters/viem/index.cjs +944 -662
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +8 -8
- package/dist/adapters/viem/resources/deposits/context.d.ts +5 -5
- package/dist/adapters/viem/resources/deposits/routes/types.d.ts +2 -6
- package/dist/adapters/viem/resources/deposits/services/fee.d.ts +6 -0
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +36 -0
- package/dist/adapters/viem/resources/utils.d.ts +3 -16
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +3 -6
- package/dist/adapters/viem/resources/withdrawals/routes/types.d.ts +12 -2
- package/dist/adapters/viem/resources/withdrawals/services/fee.d.ts +17 -0
- package/dist/adapters/viem/resources/withdrawals/services/gas.d.ts +12 -0
- package/dist/adapters/viem/sdk.cjs +877 -563
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +1 -1
- package/dist/adapters/viem/sdk.js +6 -6
- package/dist/{chunk-3LALBFFE.js → chunk-3MRGU4HV.js} +9 -5
- package/dist/{chunk-4HLJJKIY.js → chunk-6K6VJQAL.js} +2 -2
- package/dist/{chunk-CGO27P7F.js → chunk-BCCKWWOX.js} +540 -741
- package/dist/{chunk-6GCT6TLS.js → chunk-F2ENUV3A.js} +13 -1
- package/dist/{chunk-DI2CJDPZ.js → chunk-HLUANWGN.js} +2 -2
- package/dist/{chunk-Y75OMFK6.js → chunk-M5J2MM2U.js} +351 -1
- package/dist/{chunk-263G6636.js → chunk-NCAIVYBR.js} +1 -14
- package/dist/{chunk-7M4V3FMT.js → chunk-OC6ZVLSP.js} +669 -559
- package/dist/chunk-QJS6ETEE.js +217 -0
- package/dist/chunk-XRE7H466.js +157 -0
- package/dist/{chunk-BD2LUO5T.js → chunk-YUK547UF.js} +3 -3
- package/dist/core/abi.d.ts +9 -0
- package/dist/core/adapters/interfaces.d.ts +25 -0
- package/dist/core/constants.cjs +12 -0
- package/dist/core/constants.cjs.map +1 -1
- package/dist/core/constants.d.ts +6 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +4504 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +4 -4
- package/dist/core/resources/deposits/fee.d.ts +15 -0
- package/dist/core/resources/deposits/gas.d.ts +38 -0
- package/dist/core/resources/withdrawals/gas.d.ts +14 -0
- package/dist/core/types/errors.d.ts +1 -1
- package/dist/core/types/fees.d.ts +40 -0
- package/dist/core/types/flows/base.d.ts +0 -10
- package/dist/core/types/flows/deposits.d.ts +20 -6
- package/dist/core/types/flows/route.d.ts +2 -3
- package/dist/core/types/flows/withdrawals.d.ts +12 -6
- package/dist/index.cjs +4516 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -4
- package/package.json +5 -1
- package/dist/adapters/ethers/resources/withdrawals/routes/eth-nonbase.d.ts +0 -2
- package/dist/adapters/viem/resources/withdrawals/routes/eth-nonbase.d.ts +0 -2
- package/dist/chunk-B77GWPO5.js +0 -339
- package/dist/core/internal/abi-registry.d.ts +0 -9
- package/dist/core/utils/gas.d.ts +0 -13
|
@@ -10,6 +10,9 @@ var __export = (target, all) => {
|
|
|
10
10
|
// src/core/constants.ts
|
|
11
11
|
var constants_exports = {};
|
|
12
12
|
__export(constants_exports, {
|
|
13
|
+
BUFFER: () => BUFFER,
|
|
14
|
+
DEFAULT_ABI_BYTES: () => DEFAULT_ABI_BYTES,
|
|
15
|
+
DEFAULT_PUBDATA_BYTES: () => DEFAULT_PUBDATA_BYTES,
|
|
13
16
|
ETH_ADDRESS: () => ETH_ADDRESS,
|
|
14
17
|
FORMAL_ETH_ADDRESS: () => FORMAL_ETH_ADDRESS,
|
|
15
18
|
L1_FEE_ESTIMATION_COEF_DENOMINATOR: () => L1_FEE_ESTIMATION_COEF_DENOMINATOR,
|
|
@@ -19,11 +22,14 @@ __export(constants_exports, {
|
|
|
19
22
|
L2_ASSET_ROUTER_ADDRESS: () => L2_ASSET_ROUTER_ADDRESS,
|
|
20
23
|
L2_BASE_TOKEN_ADDRESS: () => L2_BASE_TOKEN_ADDRESS,
|
|
21
24
|
L2_NATIVE_TOKEN_VAULT_ADDRESS: () => L2_NATIVE_TOKEN_VAULT_ADDRESS,
|
|
25
|
+
SAFE_L1_BRIDGE_GAS: () => SAFE_L1_BRIDGE_GAS,
|
|
22
26
|
TOPIC_CANONICAL_ASSIGNED: () => TOPIC_CANONICAL_ASSIGNED,
|
|
23
27
|
TOPIC_CANONICAL_SUCCESS: () => TOPIC_CANONICAL_SUCCESS,
|
|
24
28
|
TOPIC_L1_MESSAGE_SENT: () => TOPIC_L1_MESSAGE_SENT,
|
|
25
29
|
TOPIC_L1_MESSAGE_SENT_LEG: () => TOPIC_L1_MESSAGE_SENT_LEG,
|
|
26
30
|
TOPIC_L1_MESSAGE_SENT_NEW: () => TOPIC_L1_MESSAGE_SENT_NEW,
|
|
31
|
+
TX_MEMORY_OVERHEAD_GAS: () => TX_MEMORY_OVERHEAD_GAS,
|
|
32
|
+
TX_OVERHEAD_GAS: () => TX_OVERHEAD_GAS,
|
|
27
33
|
k256hex: () => k256hex
|
|
28
34
|
});
|
|
29
35
|
var k256hex = (s) => `0x${bytesToHex(keccak_256(utf8ToBytes(s)))}`.toLowerCase();
|
|
@@ -39,7 +45,13 @@ var TOPIC_L1_MESSAGE_SENT_NEW = k256hex("L1MessageSent(uint256,bytes32,bytes)");
|
|
|
39
45
|
var TOPIC_L1_MESSAGE_SENT_LEG = k256hex("L1MessageSent(address,bytes32,bytes)");
|
|
40
46
|
var TOPIC_CANONICAL_ASSIGNED = "0x779f441679936c5441b671969f37400b8c3ed0071cb47444431bf985754560df";
|
|
41
47
|
var TOPIC_CANONICAL_SUCCESS = "0xe4def01b981193a97a9e81230d7b9f31812ceaf23f864a828a82c687911cb2df";
|
|
48
|
+
var BUFFER = 20n;
|
|
49
|
+
var TX_OVERHEAD_GAS = 10000n;
|
|
50
|
+
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
51
|
+
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
52
|
+
var DEFAULT_ABI_BYTES = 400n;
|
|
53
|
+
var SAFE_L1_BRIDGE_GAS = 600000n;
|
|
42
54
|
var L1_FEE_ESTIMATION_COEF_NUMERATOR = 12;
|
|
43
55
|
var L1_FEE_ESTIMATION_COEF_DENOMINATOR = 10;
|
|
44
56
|
|
|
45
|
-
export { ETH_ADDRESS, FORMAL_ETH_ADDRESS, L1_FEE_ESTIMATION_COEF_DENOMINATOR, L1_FEE_ESTIMATION_COEF_NUMERATOR, L1_MESSENGER_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, TOPIC_L1_MESSAGE_SENT, TOPIC_L1_MESSAGE_SENT_LEG, TOPIC_L1_MESSAGE_SENT_NEW, __export, constants_exports, k256hex };
|
|
57
|
+
export { BUFFER, DEFAULT_ABI_BYTES, DEFAULT_PUBDATA_BYTES, ETH_ADDRESS, FORMAL_ETH_ADDRESS, L1_FEE_ESTIMATION_COEF_DENOMINATOR, L1_FEE_ESTIMATION_COEF_NUMERATOR, L1_MESSENGER_ADDRESS, L1_SOPH_TOKEN_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L2_BASE_TOKEN_ADDRESS, L2_NATIVE_TOKEN_VAULT_ADDRESS, SAFE_L1_BRIDGE_GAS, TOPIC_CANONICAL_ASSIGNED, TOPIC_CANONICAL_SUCCESS, TOPIC_L1_MESSAGE_SENT, TOPIC_L1_MESSAGE_SENT_LEG, TOPIC_L1_MESSAGE_SENT_NEW, TX_MEMORY_OVERHEAD_GAS, TX_OVERHEAD_GAS, __export, constants_exports, k256hex };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FORMAL_ETH_ADDRESS, L2_BASE_TOKEN_ADDRESS, ETH_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L1_MESSENGER_ADDRESS, TOPIC_L1_MESSAGE_SENT_NEW, TOPIC_L1_MESSAGE_SENT_LEG } from './chunk-
|
|
1
|
+
import { FORMAL_ETH_ADDRESS, L2_BASE_TOKEN_ADDRESS, ETH_ADDRESS, L2_ASSET_ROUTER_ADDRESS, L1_MESSENGER_ADDRESS, TOPIC_L1_MESSAGE_SENT_NEW, TOPIC_L1_MESSAGE_SENT_LEG } from './chunk-F2ENUV3A.js';
|
|
2
2
|
|
|
3
3
|
// src/core/utils/addr.ts
|
|
4
4
|
var isHash66 = (x) => !!x && x.startsWith("0x") && x.length === 66;
|
|
@@ -37,7 +37,7 @@ function normalizeTokenForRouting(token) {
|
|
|
37
37
|
function pickWithdrawRoute(args) {
|
|
38
38
|
const tokenNorm = normalizeTokenForRouting(args.token);
|
|
39
39
|
const isL2BaseAlias = tokenNorm.toLowerCase() === L2_BASE_TOKEN_ADDRESS.toLowerCase();
|
|
40
|
-
if (isL2BaseAlias) return
|
|
40
|
+
if (isL2BaseAlias) return "base";
|
|
41
41
|
return "erc20-nonbase";
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { __export } from './chunk-F2ENUV3A.js';
|
|
2
|
+
|
|
1
3
|
// src/core/internal/abis/IBridgehub.ts
|
|
2
4
|
var IBridgehubABI = [
|
|
3
5
|
{
|
|
@@ -3980,6 +3982,20 @@ var IBaseTokenABI = [
|
|
|
3980
3982
|
];
|
|
3981
3983
|
var IBaseToken_default = IBaseTokenABI;
|
|
3982
3984
|
|
|
3985
|
+
// src/core/abi.ts
|
|
3986
|
+
var abi_exports = {};
|
|
3987
|
+
__export(abi_exports, {
|
|
3988
|
+
IBaseTokenABI: () => IBaseToken_default,
|
|
3989
|
+
IBridgehubABI: () => IBridgehub_default,
|
|
3990
|
+
IERC20ABI: () => IERC20_default,
|
|
3991
|
+
IL1AssetRouterABI: () => IL1AssetRouter_default,
|
|
3992
|
+
IL1NullifierABI: () => IL1Nullifier_default,
|
|
3993
|
+
IL2AssetRouterABI: () => IL2AssetRouter_default,
|
|
3994
|
+
L1NativeTokenVaultABI: () => L1NativeTokenVault_default,
|
|
3995
|
+
L2NativeTokenVaultABI: () => L2NativeTokenVault_default,
|
|
3996
|
+
MailboxABI: () => Mailbox_default
|
|
3997
|
+
});
|
|
3998
|
+
|
|
3983
3999
|
// src/core/internal/abis/IERC20.ts
|
|
3984
4000
|
var IERC20ABI = [
|
|
3985
4001
|
{
|
|
@@ -4486,4 +4502,338 @@ var MailboxABI = [
|
|
|
4486
4502
|
];
|
|
4487
4503
|
var Mailbox_default = MailboxABI;
|
|
4488
4504
|
|
|
4489
|
-
|
|
4505
|
+
// src/core/errors/formatter.ts
|
|
4506
|
+
function elideMiddle(s, max = 96) {
|
|
4507
|
+
if (s.length <= max) return s;
|
|
4508
|
+
const keep = Math.max(10, Math.floor((max - 1) / 2));
|
|
4509
|
+
return `${s.slice(0, keep)}\u2026${s.slice(-keep)}`;
|
|
4510
|
+
}
|
|
4511
|
+
function shortJSON(v, max = 240) {
|
|
4512
|
+
try {
|
|
4513
|
+
const s = JSON.stringify(
|
|
4514
|
+
v,
|
|
4515
|
+
(_k, val) => typeof val === "bigint" ? `${val.toString()}n` : val
|
|
4516
|
+
);
|
|
4517
|
+
return s.length > max ? elideMiddle(s, max) : s;
|
|
4518
|
+
} catch {
|
|
4519
|
+
return String(v);
|
|
4520
|
+
}
|
|
4521
|
+
}
|
|
4522
|
+
function kv(label, value) {
|
|
4523
|
+
const width = 10;
|
|
4524
|
+
const pad = label.length >= width ? " " : " ".repeat(width - label.length);
|
|
4525
|
+
return `${label + pad}: ${value}`;
|
|
4526
|
+
}
|
|
4527
|
+
function formatContextLine(ctx) {
|
|
4528
|
+
if (!ctx) return;
|
|
4529
|
+
const txHash = ctx["txHash"] ?? ctx["l1TxHash"] ?? ctx["hash"];
|
|
4530
|
+
const nonce = ctx["nonce"];
|
|
4531
|
+
const parts = [];
|
|
4532
|
+
if (txHash !== void 0)
|
|
4533
|
+
parts.push(`txHash=${typeof txHash === "string" ? txHash : shortJSON(txHash, 96)}`);
|
|
4534
|
+
if (nonce !== void 0) {
|
|
4535
|
+
const nonceStr = typeof nonce === "string" || typeof nonce === "number" || typeof nonce === "bigint" ? String(nonce) : shortJSON(nonce, 48);
|
|
4536
|
+
parts.push(`nonce=${nonceStr}`);
|
|
4537
|
+
}
|
|
4538
|
+
return parts.length ? ` ${kv("Context", parts.join(" \u2022 "))}` : void 0;
|
|
4539
|
+
}
|
|
4540
|
+
function formatStep(ctx) {
|
|
4541
|
+
const step = ctx && typeof ctx["step"] === "string" ? ctx["step"] : void 0;
|
|
4542
|
+
return step ? ` ${kv("Step", step)}` : void 0;
|
|
4543
|
+
}
|
|
4544
|
+
function formatRevert(r) {
|
|
4545
|
+
if (!r) return;
|
|
4546
|
+
const first = [`selector=${r.selector}`];
|
|
4547
|
+
const lines = [];
|
|
4548
|
+
lines.push(` ${kv("Revert", first.join(" "))}`);
|
|
4549
|
+
if (r.name) lines.push(` name=${r.name}`);
|
|
4550
|
+
if (r.contract) lines.push(` contract=${r.contract}`);
|
|
4551
|
+
if (r.fn) lines.push(` fn=${r.fn}`);
|
|
4552
|
+
if (r.args && r.args.length) {
|
|
4553
|
+
lines.push(` args=${shortJSON(r.args, 120)}`);
|
|
4554
|
+
}
|
|
4555
|
+
return lines.join("\n");
|
|
4556
|
+
}
|
|
4557
|
+
function formatCause(c) {
|
|
4558
|
+
if (!c) return [];
|
|
4559
|
+
const out = [];
|
|
4560
|
+
if (typeof c === "object" && c !== null) {
|
|
4561
|
+
const obj = c;
|
|
4562
|
+
const head = [];
|
|
4563
|
+
if (obj.name !== void 0) {
|
|
4564
|
+
const nameVal = obj.name;
|
|
4565
|
+
const nameStr = typeof nameVal === "string" || typeof nameVal === "number" || typeof nameVal === "bigint" || typeof nameVal === "boolean" ? String(nameVal) : shortJSON(nameVal, 120);
|
|
4566
|
+
head.push(`name=${nameStr}`);
|
|
4567
|
+
}
|
|
4568
|
+
if (obj.code !== void 0) {
|
|
4569
|
+
const codeVal = obj.code;
|
|
4570
|
+
const codeStr = typeof codeVal === "string" || typeof codeVal === "number" || typeof codeVal === "bigint" || typeof codeVal === "boolean" ? String(codeVal) : shortJSON(codeVal, 120);
|
|
4571
|
+
head.push(`code=${codeStr}`);
|
|
4572
|
+
}
|
|
4573
|
+
if (head.length) out.push(` ${kv("Cause", head.join(" "))}`);
|
|
4574
|
+
if (obj.message) {
|
|
4575
|
+
const messageStr = typeof obj.message === "string" || typeof obj.message === "number" || typeof obj.message === "bigint" || typeof obj.message === "boolean" ? String(obj.message) : shortJSON(obj.message, 600);
|
|
4576
|
+
out.push(` message=${elideMiddle(messageStr, 600)}`);
|
|
4577
|
+
}
|
|
4578
|
+
if (obj.data) {
|
|
4579
|
+
const dataStr = shortJSON(obj.data, 200);
|
|
4580
|
+
out.push(` data=${elideMiddle(dataStr, 200)}`);
|
|
4581
|
+
}
|
|
4582
|
+
} else {
|
|
4583
|
+
out.push(` ${kv("Cause", shortJSON(c, 200))}`);
|
|
4584
|
+
}
|
|
4585
|
+
return out;
|
|
4586
|
+
}
|
|
4587
|
+
function formatEnvelopePretty(e) {
|
|
4588
|
+
const lines = [];
|
|
4589
|
+
lines.push(`\u2716 ZKsyncError [${e.type}]`);
|
|
4590
|
+
lines.push(` ${kv("Message", e.message)}`);
|
|
4591
|
+
lines.push("");
|
|
4592
|
+
lines.push(` ${kv("Operation", e.operation)}`);
|
|
4593
|
+
const ctx = (() => {
|
|
4594
|
+
const u = e;
|
|
4595
|
+
if (!u || typeof u !== "object") return void 0;
|
|
4596
|
+
const obj = u;
|
|
4597
|
+
const candidate = obj["ctx"] ?? obj["context"];
|
|
4598
|
+
if (candidate && typeof candidate === "object" && candidate !== null) {
|
|
4599
|
+
return candidate;
|
|
4600
|
+
}
|
|
4601
|
+
return void 0;
|
|
4602
|
+
})();
|
|
4603
|
+
const ctxLine = formatContextLine(ctx);
|
|
4604
|
+
if (ctxLine) lines.push(ctxLine);
|
|
4605
|
+
const stepLine = formatStep(ctx);
|
|
4606
|
+
if (stepLine) lines.push(stepLine);
|
|
4607
|
+
const rv = formatRevert(e.revert);
|
|
4608
|
+
if (rv) lines.push(rv);
|
|
4609
|
+
const causeLines = formatCause(e.cause);
|
|
4610
|
+
if (causeLines.length) {
|
|
4611
|
+
if (!ctxLine && !rv) lines.push("");
|
|
4612
|
+
lines.push(...causeLines);
|
|
4613
|
+
}
|
|
4614
|
+
return lines.join("\n");
|
|
4615
|
+
}
|
|
4616
|
+
|
|
4617
|
+
// src/core/types/errors.ts
|
|
4618
|
+
var hasSymbolInspect = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
4619
|
+
var kInspect = hasSymbolInspect ? Symbol.for("nodejs.util.inspect.custom") : void 0;
|
|
4620
|
+
function safeInspect(val) {
|
|
4621
|
+
try {
|
|
4622
|
+
if (typeof val === "string") return val;
|
|
4623
|
+
return JSON.stringify(val, null, 2);
|
|
4624
|
+
} catch {
|
|
4625
|
+
try {
|
|
4626
|
+
return String(val);
|
|
4627
|
+
} catch {
|
|
4628
|
+
return Object.prototype.toString.call(val);
|
|
4629
|
+
}
|
|
4630
|
+
}
|
|
4631
|
+
}
|
|
4632
|
+
var ZKsyncError = class extends Error {
|
|
4633
|
+
constructor(envelope) {
|
|
4634
|
+
super(formatEnvelopePretty(envelope), envelope.cause ? { cause: envelope.cause } : void 0);
|
|
4635
|
+
this.envelope = envelope;
|
|
4636
|
+
this.name = "ZKsyncError";
|
|
4637
|
+
}
|
|
4638
|
+
toJSON() {
|
|
4639
|
+
return { name: this.name, ...this.envelope };
|
|
4640
|
+
}
|
|
4641
|
+
};
|
|
4642
|
+
if (kInspect) {
|
|
4643
|
+
Object.defineProperty(ZKsyncError.prototype, kInspect, {
|
|
4644
|
+
value() {
|
|
4645
|
+
return `${this.name}: ${formatEnvelopePretty(this.envelope)}`;
|
|
4646
|
+
},
|
|
4647
|
+
enumerable: false
|
|
4648
|
+
});
|
|
4649
|
+
}
|
|
4650
|
+
function isZKsyncError(e) {
|
|
4651
|
+
if (!e || typeof e !== "object") return false;
|
|
4652
|
+
const maybe = e;
|
|
4653
|
+
if (!("envelope" in maybe)) return false;
|
|
4654
|
+
const envelope = maybe.envelope;
|
|
4655
|
+
return typeof envelope?.type === "string" && typeof envelope?.message === "string";
|
|
4656
|
+
}
|
|
4657
|
+
function isReceiptNotFound(e) {
|
|
4658
|
+
const chain = [];
|
|
4659
|
+
let cur = e;
|
|
4660
|
+
for (let i = 0; i < 5 && cur; i++) {
|
|
4661
|
+
chain.push(cur);
|
|
4662
|
+
cur = cur.cause;
|
|
4663
|
+
}
|
|
4664
|
+
const NAME_HITS = /* @__PURE__ */ new Set([
|
|
4665
|
+
"TransactionReceiptNotFoundError",
|
|
4666
|
+
// viem
|
|
4667
|
+
"TransactionNotFoundError",
|
|
4668
|
+
// viem
|
|
4669
|
+
"NotFoundError"
|
|
4670
|
+
// some RPC wrappers
|
|
4671
|
+
]);
|
|
4672
|
+
const CODE_HITS = /* @__PURE__ */ new Set([
|
|
4673
|
+
"TRANSACTION_NOT_FOUND",
|
|
4674
|
+
// some ethers-ish shapes / providers
|
|
4675
|
+
"RECEIPT_NOT_FOUND",
|
|
4676
|
+
"NOT_FOUND",
|
|
4677
|
+
-32e3
|
|
4678
|
+
// JSON-RPC server error
|
|
4679
|
+
]);
|
|
4680
|
+
const MSG_RE = /(transaction|receipt)[^]*?(not\s+(?:be\s+)?found|missing)/i;
|
|
4681
|
+
for (const node of chain) {
|
|
4682
|
+
const name = node?.name;
|
|
4683
|
+
const code = node?.code;
|
|
4684
|
+
const short = node?.shortMessage;
|
|
4685
|
+
const msg = String(short ?? node?.message ?? "");
|
|
4686
|
+
if (name && NAME_HITS.has(name)) return true;
|
|
4687
|
+
if (code && CODE_HITS.has(code)) return true;
|
|
4688
|
+
if (MSG_RE.test(msg)) return true;
|
|
4689
|
+
}
|
|
4690
|
+
const raw = (() => {
|
|
4691
|
+
const node = e;
|
|
4692
|
+
const short = node?.shortMessage;
|
|
4693
|
+
const msg = node?.message;
|
|
4694
|
+
if (typeof short === "string" && short) return short;
|
|
4695
|
+
if (typeof msg === "string" && msg) return msg;
|
|
4696
|
+
if (e == null) return "";
|
|
4697
|
+
if (typeof e === "string") return e;
|
|
4698
|
+
return safeInspect(e);
|
|
4699
|
+
})();
|
|
4700
|
+
return MSG_RE.test(raw);
|
|
4701
|
+
}
|
|
4702
|
+
var OP_DEPOSITS = {
|
|
4703
|
+
// high-level flow ops
|
|
4704
|
+
quote: "deposits.quote",
|
|
4705
|
+
tryQuote: "deposits.tryQuote",
|
|
4706
|
+
prepare: "deposits.prepare",
|
|
4707
|
+
tryPrepare: "deposits.tryPrepare",
|
|
4708
|
+
create: "deposits.create",
|
|
4709
|
+
tryCreate: "deposits.tryCreate",
|
|
4710
|
+
status: "deposits.status",
|
|
4711
|
+
wait: "deposits.wait",
|
|
4712
|
+
tryWait: "deposits.tryWait",
|
|
4713
|
+
base: {
|
|
4714
|
+
assertErc20Asset: "deposits.erc20-base:assertErc20Asset",
|
|
4715
|
+
assertMatchesBase: "deposits.erc20-base:assertMatchesBase",
|
|
4716
|
+
baseToken: "deposits.erc20-base:baseToken",
|
|
4717
|
+
allowance: "deposits.erc20-base:allowance",
|
|
4718
|
+
baseCost: "deposits.erc20-base:l2TransactionBaseCost",
|
|
4719
|
+
estGas: "deposits.erc20-base:estimateGas"
|
|
4720
|
+
},
|
|
4721
|
+
nonbase: {
|
|
4722
|
+
baseToken: "deposits.erc20-nonbase:baseToken",
|
|
4723
|
+
assertNotEthAsset: "deposits.erc20-nonbase:assertNotEthAsset",
|
|
4724
|
+
allowance: "deposits.erc20-nonbase:allowance",
|
|
4725
|
+
allowanceFees: "deposits.erc20-nonbase:allowanceFeesBaseToken",
|
|
4726
|
+
baseCost: "deposits.erc20-nonbase:l2TransactionBaseCost",
|
|
4727
|
+
encodeCalldata: "deposits.erc20-nonbase:encodeSecondBridgeErc20Args",
|
|
4728
|
+
estGas: "deposits.erc20-nonbase:estimateGas",
|
|
4729
|
+
assertBaseIsEth: "deposits.erc20-nonbase:assertBaseIsEth",
|
|
4730
|
+
assertBaseIsErc20: "deposits.erc20-nonbase:assertBaseIsErc20",
|
|
4731
|
+
assertNonBaseToken: "deposits.erc20-nonbase:assertNonBaseToken",
|
|
4732
|
+
allowanceToken: "deposits.erc20-nonbase:allowanceToken",
|
|
4733
|
+
allowanceBase: "deposits.erc20-nonbase:allowanceBase"
|
|
4734
|
+
},
|
|
4735
|
+
eth: {
|
|
4736
|
+
baseCost: "deposits.eth:l2TransactionBaseCost",
|
|
4737
|
+
estGas: "deposits.eth:estimateGas"
|
|
4738
|
+
},
|
|
4739
|
+
ethNonBase: {
|
|
4740
|
+
baseToken: "deposits.eth-nonbase:baseToken",
|
|
4741
|
+
baseCost: "deposits.eth-nonbase:l2TransactionBaseCost",
|
|
4742
|
+
allowanceBase: "deposits.eth-nonbase:allowanceBaseToken",
|
|
4743
|
+
ethBalance: "deposits.eth-nonbase:getEthBalance",
|
|
4744
|
+
encodeCalldata: "deposits.eth-nonbase:encodeSecondBridgeEthArgs",
|
|
4745
|
+
estGas: "deposits.eth-nonbase:estimateGas",
|
|
4746
|
+
assertEthAsset: "deposits.eth-nonbase:assertEthAsset",
|
|
4747
|
+
assertNonEthBase: "deposits.eth-nonbase:assertNonEthBase",
|
|
4748
|
+
assertEthBalance: "deposits.eth-nonbase:assertEthBalance"
|
|
4749
|
+
}
|
|
4750
|
+
};
|
|
4751
|
+
var OP_WITHDRAWALS = {
|
|
4752
|
+
quote: "withdrawals.quote",
|
|
4753
|
+
tryQuote: "withdrawals.tryQuote",
|
|
4754
|
+
prepare: "withdrawals.prepare",
|
|
4755
|
+
tryPrepare: "withdrawals.tryPrepare",
|
|
4756
|
+
create: "withdrawals.create",
|
|
4757
|
+
tryCreate: "withdrawals.tryCreate",
|
|
4758
|
+
status: "withdrawals.status",
|
|
4759
|
+
wait: "withdrawals.wait",
|
|
4760
|
+
tryWait: "withdrawals.tryWait",
|
|
4761
|
+
erc20: {
|
|
4762
|
+
allowance: "withdrawals.erc20:allowance",
|
|
4763
|
+
ensureRegistered: "withdrawals.erc20:ensureTokenIsRegistered",
|
|
4764
|
+
encodeAssetData: "withdrawals.erc20:encodeAssetData",
|
|
4765
|
+
encodeWithdraw: "withdrawals.erc20:encodeWithdraw",
|
|
4766
|
+
estGas: "withdrawals.erc20:estimateGas"
|
|
4767
|
+
},
|
|
4768
|
+
eth: {
|
|
4769
|
+
encodeWithdraw: "withdrawals.eth:encodeWithdraw",
|
|
4770
|
+
estGas: "withdrawals.eth:estimateGas"
|
|
4771
|
+
},
|
|
4772
|
+
ethNonBase: {
|
|
4773
|
+
allowance: "withdrawals.eth-nonbase:allowance",
|
|
4774
|
+
ensureRegistered: "withdrawals.eth-nonbase:ensureTokenIsRegistered",
|
|
4775
|
+
encodeAssetData: "withdrawals.eth-nonbase:encodeAssetData",
|
|
4776
|
+
encodeWithdraw: "withdrawals.eth-nonbase:encodeWithdraw",
|
|
4777
|
+
estGas: "withdrawals.eth-nonbase:estimateGas",
|
|
4778
|
+
baseToken: "withdrawals.eth-nonbase:baseToken",
|
|
4779
|
+
assertNonEthBase: "withdrawals.eth-nonbase:assertNonEthBase"
|
|
4780
|
+
},
|
|
4781
|
+
finalize: {
|
|
4782
|
+
fetchParams: {
|
|
4783
|
+
receipt: "withdrawals.finalize.fetchParams:receipt",
|
|
4784
|
+
findMessage: "withdrawals.finalize.fetchParams:findMessage",
|
|
4785
|
+
decodeMessage: "withdrawals.finalize.fetchParams:decodeMessage",
|
|
4786
|
+
rawReceipt: "withdrawals.finalize.fetchParams:rawReceipt",
|
|
4787
|
+
messengerIndex: "withdrawals.finalize.fetchParams:messengerIndex",
|
|
4788
|
+
proof: "withdrawals.finalize.fetchParams:proof",
|
|
4789
|
+
network: "withdrawals.finalize.fetchParams:network",
|
|
4790
|
+
ensureAddresses: "withdrawals.finalize.fetchParams:ensureAddresses"
|
|
4791
|
+
},
|
|
4792
|
+
readiness: {
|
|
4793
|
+
ensureAddresses: "withdrawals.finalize.readiness:ensureAddresses",
|
|
4794
|
+
isFinalized: "withdrawals.finalize.readiness:isWithdrawalFinalized",
|
|
4795
|
+
simulate: "withdrawals.finalize.readiness:simulate"
|
|
4796
|
+
},
|
|
4797
|
+
isFinalized: "withdrawals.finalize.isWithdrawalFinalized",
|
|
4798
|
+
send: "withdrawals.finalize.finalizeDeposit:send",
|
|
4799
|
+
wait: "withdrawals.finalize.finalizeDeposit:wait",
|
|
4800
|
+
estimate: "withdrawals.finalize.estimateFinalizationFees"
|
|
4801
|
+
}
|
|
4802
|
+
};
|
|
4803
|
+
|
|
4804
|
+
// src/core/errors/factory.ts
|
|
4805
|
+
var factory_exports = {};
|
|
4806
|
+
__export(factory_exports, {
|
|
4807
|
+
createError: () => createError,
|
|
4808
|
+
shapeCause: () => shapeCause
|
|
4809
|
+
});
|
|
4810
|
+
function createError(type, input) {
|
|
4811
|
+
return new ZKsyncError({ ...input, type });
|
|
4812
|
+
}
|
|
4813
|
+
function shapeCause(err) {
|
|
4814
|
+
const isRecord = (x) => x !== null && typeof x === "object";
|
|
4815
|
+
let data = void 0;
|
|
4816
|
+
if (isRecord(err)) {
|
|
4817
|
+
const r2 = err;
|
|
4818
|
+
const d = r2.data;
|
|
4819
|
+
if (isRecord(d) && "data" in d) {
|
|
4820
|
+
data = d.data;
|
|
4821
|
+
} else if ("error" in r2 && isRecord(r2.error) && "data" in r2.error) {
|
|
4822
|
+
data = r2.error.data;
|
|
4823
|
+
} else if ("data" in r2) {
|
|
4824
|
+
data = r2.data;
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
const r = isRecord(err) ? err : void 0;
|
|
4828
|
+
const name = r && typeof r.name === "string" ? r.name : void 0;
|
|
4829
|
+
const message = r && typeof r.message === "string" ? r.message : r && typeof r.shortMessage === "string" ? r.shortMessage : void 0;
|
|
4830
|
+
const code = r && "code" in r ? r.code : void 0;
|
|
4831
|
+
return {
|
|
4832
|
+
name,
|
|
4833
|
+
message,
|
|
4834
|
+
code,
|
|
4835
|
+
data: typeof data === "string" && data.startsWith("0x") ? `${data.slice(0, 10)}\u2026` : void 0
|
|
4836
|
+
};
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4839
|
+
export { IBaseToken_default, IBridgehub_default, IERC20_default, IL1AssetRouter_default, IL1Nullifier_default, IL2AssetRouter_default, L1NativeTokenVault_default, L2NativeTokenVault_default, Mailbox_default, OP_DEPOSITS, OP_WITHDRAWALS, abi_exports, createError, factory_exports, formatEnvelopePretty, isReceiptNotFound, isZKsyncError, shapeCause };
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
// src/core/utils/gas.ts
|
|
2
|
-
function assertNoLegacyGas(overrides) {
|
|
3
|
-
if (!overrides) return;
|
|
4
|
-
if ("gasPrice" in overrides && overrides.gasPrice !== void 0) {
|
|
5
|
-
throw new Error("Legacy gasPrice is not supported; use EIP-1559 fields instead.");
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
function assertPriorityFeeBounds(fees) {
|
|
9
|
-
if (fees.maxPriorityFeePerGas > fees.maxFeePerGas) {
|
|
10
|
-
throw new Error("maxPriorityFeePerGas cannot exceed maxFeePerGas.");
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
1
|
// src/core/errors/withdrawal-revert-map.ts
|
|
15
2
|
var REVERT_TO_READINESS = {
|
|
16
3
|
// Already done
|
|
@@ -33,4 +20,4 @@ var REVERT_TO_READINESS = {
|
|
|
33
20
|
LocalRootMustBeZero: { kind: "UNFINALIZABLE", reason: "unsupported" }
|
|
34
21
|
};
|
|
35
22
|
|
|
36
|
-
export { REVERT_TO_READINESS
|
|
23
|
+
export { REVERT_TO_READINESS };
|