@matterlabs/zksync-js 0.0.5 → 0.0.7
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 +170 -48
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.js +6 -6
- package/dist/adapters/ethers/errors/error-ops.d.ts +26 -19
- package/dist/adapters/ethers/index.cjs +194 -50
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.js +9 -9
- package/dist/adapters/ethers/resources/withdrawals/index.d.ts +11 -0
- package/dist/adapters/ethers/sdk.cjs +75 -47
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.js +7 -7
- package/dist/adapters/viem/client.cjs +119 -3
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.js +4 -4
- package/dist/adapters/viem/errors/error-ops.d.ts +26 -19
- package/dist/adapters/viem/index.cjs +194 -50
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.js +8 -8
- package/dist/adapters/viem/resources/withdrawals/index.d.ts +11 -0
- package/dist/adapters/viem/sdk.cjs +75 -47
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.js +6 -6
- package/dist/{chunk-YUK547UF.js → chunk-7VP6742W.js} +3 -3
- package/dist/{chunk-NBJEQAOE.js → chunk-EWLA4NUE.js} +28 -6
- package/dist/{chunk-M5J2MM2U.js → chunk-GIXLOHLK.js} +1 -1
- package/dist/{chunk-XRE7H466.js → chunk-GNERKUWO.js} +3 -47
- package/dist/chunk-KAMEGD6I.js +75 -0
- package/dist/{chunk-JXUFGIJG.js → chunk-KRIRXY74.js} +30 -52
- package/dist/{chunk-F2ENUV3A.js → chunk-NCR42O6O.js} +1 -1
- package/dist/{chunk-3MRGU4HV.js → chunk-NGXRO2ZX.js} +4 -4
- package/dist/{chunk-LL3WKCFJ.js → chunk-NNFWIAVG.js} +2 -2
- package/dist/{chunk-NEC2ZKHI.js → chunk-P5PIWVEO.js} +1 -1
- package/dist/{chunk-NTEIA5KA.js → chunk-VRL6Y4YJ.js} +1 -1
- package/dist/{chunk-6K6VJQAL.js → chunk-WY36Z6YB.js} +122 -5
- package/dist/core/constants.cjs +1 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/errors/error-ops.d.ts +18 -0
- package/dist/core/index.cjs +120 -3
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +5 -5
- package/dist/core/rpc/types.d.ts +5 -0
- package/dist/core/rpc/zks.d.ts +4 -1
- package/dist/index.cjs +121 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/dist/chunk-NCAIVYBR.js +0 -23
|
@@ -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-NGXRO2ZX.js';
|
|
2
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs } from '../../chunk-EWLA4NUE.js';
|
|
3
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-GNERKUWO.js';
|
|
4
|
+
import '../../chunk-NNFWIAVG.js';
|
|
5
|
+
import '../../chunk-P5PIWVEO.js';
|
|
6
|
+
import '../../chunk-KAMEGD6I.js';
|
|
7
|
+
import '../../chunk-WY36Z6YB.js';
|
|
8
|
+
import '../../chunk-GIXLOHLK.js';
|
|
9
|
+
import '../../chunk-NCR42O6O.js';
|
|
@@ -38,6 +38,17 @@ export interface WithdrawalsResource {
|
|
|
38
38
|
pollMs?: number;
|
|
39
39
|
timeoutMs?: number;
|
|
40
40
|
}): Promise<TransactionReceiptZKsyncOS | TransactionReceipt | null>;
|
|
41
|
+
tryWait(h: WithdrawalWaitable | Hex, opts: {
|
|
42
|
+
for: 'l2' | 'ready' | 'finalized';
|
|
43
|
+
pollMs?: number;
|
|
44
|
+
timeoutMs?: number;
|
|
45
|
+
}): Promise<{
|
|
46
|
+
ok: true;
|
|
47
|
+
value: TransactionReceiptZKsyncOS | TransactionReceipt;
|
|
48
|
+
} | {
|
|
49
|
+
ok: false;
|
|
50
|
+
error: unknown;
|
|
51
|
+
}>;
|
|
41
52
|
finalize(l2TxHash: Hex): Promise<{
|
|
42
53
|
status: WithdrawalStatus;
|
|
43
54
|
receipt?: TransactionReceipt;
|
|
@@ -21,7 +21,7 @@ var TX_OVERHEAD_GAS = 10000n;
|
|
|
21
21
|
var TX_MEMORY_OVERHEAD_GAS = 10n;
|
|
22
22
|
var DEFAULT_PUBDATA_BYTES = 155n;
|
|
23
23
|
var DEFAULT_ABI_BYTES = 400n;
|
|
24
|
-
var SAFE_L1_BRIDGE_GAS =
|
|
24
|
+
var SAFE_L1_BRIDGE_GAS = 700000n;
|
|
25
25
|
|
|
26
26
|
// src/core/utils/addr.ts
|
|
27
27
|
var isHash66 = (x) => !!x && x.startsWith("0x") && x.length === 66;
|
|
@@ -3821,6 +3821,56 @@ function ethersToGasEstimator(provider) {
|
|
|
3821
3821
|
};
|
|
3822
3822
|
}
|
|
3823
3823
|
|
|
3824
|
+
// src/core/errors/error-ops.ts
|
|
3825
|
+
function resolveMessage(op, msg) {
|
|
3826
|
+
if (!msg) return `Error during ${op}.`;
|
|
3827
|
+
return typeof msg === "function" ? msg() : msg;
|
|
3828
|
+
}
|
|
3829
|
+
function createErrorOps(decodeRevert2) {
|
|
3830
|
+
function toZKsyncError2(type, base, err) {
|
|
3831
|
+
if (isZKsyncError(err)) return err;
|
|
3832
|
+
const revert = decodeRevert2 ? decodeRevert2(err) : void 0;
|
|
3833
|
+
return createError(type, { ...base, ...revert ? { revert } : {}, cause: shapeCause(err) });
|
|
3834
|
+
}
|
|
3835
|
+
function createErrorHandlers2(resource) {
|
|
3836
|
+
async function run(kind, operation, fn, opts) {
|
|
3837
|
+
try {
|
|
3838
|
+
return await fn();
|
|
3839
|
+
} catch (e) {
|
|
3840
|
+
if (isZKsyncError(e)) throw e;
|
|
3841
|
+
const message = resolveMessage(operation, opts?.message);
|
|
3842
|
+
throw toZKsyncError2(kind, { resource, operation, context: opts?.ctx ?? {}, message }, e);
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
function wrap2(operation, fn, opts) {
|
|
3846
|
+
return run("INTERNAL", operation, fn, opts);
|
|
3847
|
+
}
|
|
3848
|
+
function wrapAs9(kind, operation, fn, opts) {
|
|
3849
|
+
return run(kind, operation, fn, opts);
|
|
3850
|
+
}
|
|
3851
|
+
async function toResult2(operation, fn, opts) {
|
|
3852
|
+
try {
|
|
3853
|
+
const value = await wrap2(operation, fn, opts);
|
|
3854
|
+
return { ok: true, value };
|
|
3855
|
+
} catch (e) {
|
|
3856
|
+
const shaped = isZKsyncError(e) ? e : toZKsyncError2(
|
|
3857
|
+
"INTERNAL",
|
|
3858
|
+
{
|
|
3859
|
+
resource,
|
|
3860
|
+
operation,
|
|
3861
|
+
context: opts?.ctx ?? {},
|
|
3862
|
+
message: resolveMessage(operation, opts?.message)
|
|
3863
|
+
},
|
|
3864
|
+
e
|
|
3865
|
+
);
|
|
3866
|
+
return { ok: false, error: shaped };
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
return { wrap: wrap2, wrapAs: wrapAs9, toResult: toResult2 };
|
|
3870
|
+
}
|
|
3871
|
+
return { toZKsyncError: toZKsyncError2, createErrorHandlers: createErrorHandlers2 };
|
|
3872
|
+
}
|
|
3873
|
+
|
|
3824
3874
|
// src/core/errors/withdrawal-revert-map.ts
|
|
3825
3875
|
var REVERT_TO_READINESS = {
|
|
3826
3876
|
// Already done
|
|
@@ -3944,51 +3994,7 @@ function classifyReadinessFromRevert(e) {
|
|
|
3944
3994
|
}
|
|
3945
3995
|
|
|
3946
3996
|
// src/adapters/ethers/errors/error-ops.ts
|
|
3947
|
-
|
|
3948
|
-
if (isZKsyncError(err)) return err;
|
|
3949
|
-
const revert = decodeRevert(err);
|
|
3950
|
-
return createError(type, { ...base, ...revert ? { revert } : {}, cause: shapeCause(err) });
|
|
3951
|
-
}
|
|
3952
|
-
function resolveMessage(op, msg) {
|
|
3953
|
-
if (!msg) return `Error during ${op}.`;
|
|
3954
|
-
return typeof msg === "function" ? msg() : msg;
|
|
3955
|
-
}
|
|
3956
|
-
function createErrorHandlers(resource) {
|
|
3957
|
-
async function run(kind, operation, fn, opts) {
|
|
3958
|
-
try {
|
|
3959
|
-
return await fn();
|
|
3960
|
-
} catch (e) {
|
|
3961
|
-
if (isZKsyncError(e)) throw e;
|
|
3962
|
-
const message = resolveMessage(operation, opts?.message);
|
|
3963
|
-
throw toZKsyncError(kind, { resource, operation, context: opts?.ctx ?? {}, message }, e);
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
|
-
function wrap2(operation, fn, opts) {
|
|
3967
|
-
return run("INTERNAL", operation, fn, opts);
|
|
3968
|
-
}
|
|
3969
|
-
function wrapAs9(kind, operation, fn, opts) {
|
|
3970
|
-
return run(kind, operation, fn, opts);
|
|
3971
|
-
}
|
|
3972
|
-
async function toResult2(operation, fn, opts) {
|
|
3973
|
-
try {
|
|
3974
|
-
const value = await wrap2(operation, fn, opts);
|
|
3975
|
-
return { ok: true, value };
|
|
3976
|
-
} catch (e) {
|
|
3977
|
-
const shaped = isZKsyncError(e) ? e : toZKsyncError(
|
|
3978
|
-
"INTERNAL",
|
|
3979
|
-
{
|
|
3980
|
-
resource,
|
|
3981
|
-
operation,
|
|
3982
|
-
context: opts?.ctx ?? {},
|
|
3983
|
-
message: resolveMessage(operation, opts?.message)
|
|
3984
|
-
},
|
|
3985
|
-
e
|
|
3986
|
-
);
|
|
3987
|
-
return { ok: false, error: shaped };
|
|
3988
|
-
}
|
|
3989
|
-
}
|
|
3990
|
-
return { wrap: wrap2, wrapAs: wrapAs9, toResult: toResult2 };
|
|
3991
|
-
}
|
|
3997
|
+
var { toZKsyncError, createErrorHandlers } = createErrorOps(decodeRevert);
|
|
3992
3998
|
|
|
3993
3999
|
// src/adapters/ethers/resources/deposits/services/fee.ts
|
|
3994
4000
|
var { wrapAs } = createErrorHandlers("deposits");
|
|
@@ -6101,6 +6107,27 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
6101
6107
|
message: "Internal error while attempting to tryFinalize withdrawal.",
|
|
6102
6108
|
ctx: { l2TxHash, where: "withdrawals.tryFinalize" }
|
|
6103
6109
|
});
|
|
6110
|
+
const tryWait = (h, opts) => toResult2(
|
|
6111
|
+
OP_WITHDRAWALS.tryWait,
|
|
6112
|
+
async () => {
|
|
6113
|
+
const v = await wait(h, opts);
|
|
6114
|
+
if (v) return v;
|
|
6115
|
+
throw createError("STATE", {
|
|
6116
|
+
resource: "withdrawals",
|
|
6117
|
+
operation: "withdrawals.tryWait",
|
|
6118
|
+
message: opts.for === "l2" ? "No L2 receipt yet; the withdrawal has not executed on L2." : "No L1 receipt yet; the withdrawal has not been included on L1.",
|
|
6119
|
+
context: {
|
|
6120
|
+
for: opts.for,
|
|
6121
|
+
l2TxHash: typeof h === "string" ? h : "l2TxHash" in h ? h.l2TxHash : void 0,
|
|
6122
|
+
where: "withdrawals.tryWait"
|
|
6123
|
+
}
|
|
6124
|
+
});
|
|
6125
|
+
},
|
|
6126
|
+
{
|
|
6127
|
+
message: "Internal error while waiting for withdrawal.",
|
|
6128
|
+
ctx: { input: h, for: opts?.for, where: "withdrawals.tryWait" }
|
|
6129
|
+
}
|
|
6130
|
+
);
|
|
6104
6131
|
return {
|
|
6105
6132
|
quote,
|
|
6106
6133
|
tryQuote,
|
|
@@ -6111,7 +6138,8 @@ function createWithdrawalsResource(client, tokens, contracts) {
|
|
|
6111
6138
|
status,
|
|
6112
6139
|
wait,
|
|
6113
6140
|
finalize,
|
|
6114
|
-
tryFinalize
|
|
6141
|
+
tryFinalize,
|
|
6142
|
+
tryWait
|
|
6115
6143
|
};
|
|
6116
6144
|
}
|
|
6117
6145
|
|