@matterlabs/zksync-js 0.0.21 → 0.0.23
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 +31 -8
- package/dist/adapters/ethers/client.cjs.map +1 -1
- package/dist/adapters/ethers/client.d.ts +11 -0
- package/dist/adapters/ethers/client.js +6 -5
- package/dist/adapters/ethers/index.cjs +1194 -364
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.d.ts +2 -1
- package/dist/adapters/ethers/index.js +10 -8
- package/dist/adapters/ethers/resources/deposits/context.d.ts +2 -0
- package/dist/adapters/ethers/resources/deposits/services/gas.d.ts +3 -0
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +12 -1
- package/dist/adapters/ethers/resources/withdrawals/index.d.ts +17 -1
- package/dist/adapters/ethers/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
- package/dist/adapters/ethers/resources/withdrawals/services/finalization.d.ts +35 -17
- package/dist/adapters/ethers/resources/withdrawals/services/protocol.d.ts +11 -0
- package/dist/adapters/ethers/sdk.cjs +1166 -370
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +3 -1
- package/dist/adapters/ethers/sdk.js +8 -7
- package/dist/adapters/viem/client.cjs +44 -7
- package/dist/adapters/viem/client.cjs.map +1 -1
- package/dist/adapters/viem/client.d.ts +11 -0
- package/dist/adapters/viem/client.js +6 -5
- package/dist/adapters/viem/index.cjs +1237 -383
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +2 -1
- package/dist/adapters/viem/index.js +10 -8
- package/dist/adapters/viem/resources/deposits/context.d.ts +2 -0
- package/dist/adapters/viem/resources/deposits/services/gas.d.ts +3 -0
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +12 -1
- package/dist/adapters/viem/resources/withdrawals/index.d.ts +17 -1
- package/dist/adapters/viem/resources/withdrawals/routes/interop-bundle.d.ts +2 -0
- package/dist/adapters/viem/resources/withdrawals/services/finalization.d.ts +36 -18
- package/dist/adapters/viem/resources/withdrawals/services/protocol.d.ts +11 -0
- package/dist/adapters/viem/sdk.cjs +1191 -385
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +3 -1
- package/dist/adapters/viem/sdk.js +8 -7
- package/dist/{chunk-UEKFQAOS.js → chunk-2DDJFHHD.js} +304 -9
- package/dist/{chunk-MT4X5FEO.js → chunk-3IPSDGHO.js} +19 -1
- package/dist/{chunk-JSBMIT4S.js → chunk-4GPIHYVF.js} +1 -1
- package/dist/{chunk-SBGBYZJM.js → chunk-4M7VNYGC.js} +2 -2
- package/dist/{chunk-CK5UFAZK.js → chunk-6WIAMFIW.js} +37 -3
- package/dist/chunk-JJ523MOL.js +157 -0
- package/dist/{chunk-7GZDTLHX.js → chunk-NVOFHV3A.js} +666 -304
- package/dist/{chunk-LGTYM5XP.js → chunk-OEUDZFXH.js} +1 -1
- package/dist/{chunk-NJK325XV.js → chunk-TUN6NH5D.js} +2 -2
- package/dist/chunk-UMPAKZCQ.js +19 -0
- package/dist/{chunk-24TE2NNJ.js → chunk-URHDNDFN.js} +24 -4
- package/dist/{chunk-2CGBLD5H.js → chunk-V2TDNGI5.js} +642 -288
- package/dist/{chunk-IDXSGCGF.js → chunk-WPCZNITC.js} +63 -50
- package/dist/{chunk-TYYUG5GA.js → chunk-X2JJDQ4O.js} +1 -1
- package/dist/core/abi.d.ts +1 -0
- package/dist/core/adapters/interfaces.d.ts +2 -0
- package/dist/core/constants.cjs +18 -0
- package/dist/core/constants.cjs.map +1 -1
- package/dist/core/constants.d.ts +17 -0
- package/dist/core/constants.js +1 -1
- package/dist/core/index.cjs +504 -7
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +6 -1
- package/dist/core/index.js +6 -4
- package/dist/core/internal/abis/IERC7786Attributes.d.ts +10 -0
- package/dist/core/internal/abis/IL1NullifierV32.d.ts +221 -0
- package/dist/core/internal/abis/IL2AssetRouter.d.ts +0 -14
- package/dist/core/resources/deposits/priority.d.ts +30 -0
- package/dist/core/resources/interop/attributes/bundle.d.ts +1 -0
- package/dist/core/resources/interop/attributes/resource.d.ts +1 -0
- package/dist/core/resources/protocol/semver.d.ts +18 -0
- package/dist/core/resources/withdrawals/bundle.d.ts +80 -0
- package/dist/core/resources/withdrawals/finalization.d.ts +142 -0
- package/dist/core/resources/withdrawals/protocol.d.ts +55 -0
- package/dist/core/types/flows/withdrawals.d.ts +30 -0
- package/dist/index.cjs +320 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/package.json +1 -1
|
@@ -7,7 +7,8 @@ export type { DepositsResource } from './resources/deposits';
|
|
|
7
7
|
export { getL2TransactionHashFromLogs } from './resources/deposits/services/verification';
|
|
8
8
|
export { createWithdrawalsResource } from './resources/withdrawals';
|
|
9
9
|
export { createFinalizationServices } from './resources/withdrawals';
|
|
10
|
-
export
|
|
10
|
+
export { createWithdrawalProtocolService } from './resources/withdrawals';
|
|
11
|
+
export type { WithdrawalsResource, WithdrawalsResourceOptions, FinalizationServices, WithdrawalProtocolService, } from './resources/withdrawals';
|
|
11
12
|
export { createTokensResource } from './resources/tokens';
|
|
12
13
|
export { createInteropResource } from './resources/interop';
|
|
13
14
|
export { createInteropFinalizationServices } from './resources/interop';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export { createEthersClient as createClient, createEthersClient } from '../../chunk-
|
|
2
|
-
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-
|
|
3
|
-
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-
|
|
4
|
-
import '../../chunk-
|
|
5
|
-
import '../../chunk-
|
|
1
|
+
export { createEthersClient as createClient, createEthersClient } from '../../chunk-URHDNDFN.js';
|
|
2
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createInteropFinalizationServices, createInteropResource, createTokensResource, createWithdrawalProtocolService, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs, getL2TransactionHashFromLogs } from '../../chunk-V2TDNGI5.js';
|
|
3
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-TUN6NH5D.js';
|
|
4
|
+
import '../../chunk-WPCZNITC.js';
|
|
5
|
+
import '../../chunk-JJ523MOL.js';
|
|
6
|
+
import '../../chunk-OEUDZFXH.js';
|
|
7
|
+
import '../../chunk-UMPAKZCQ.js';
|
|
6
8
|
import '../../chunk-BWKWWLY4.js';
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
9
|
-
import '../../chunk-
|
|
9
|
+
import '../../chunk-4GPIHYVF.js';
|
|
10
|
+
import '../../chunk-2DDJFHHD.js';
|
|
11
|
+
import '../../chunk-3IPSDGHO.js';
|
|
@@ -14,6 +14,7 @@ export interface BuildCtx extends CommonCtx {
|
|
|
14
14
|
baseTokenL1: Address;
|
|
15
15
|
baseIsEth: boolean;
|
|
16
16
|
l1AssetRouter: Address;
|
|
17
|
+
l1NativeTokenVault: Address;
|
|
17
18
|
gasOverrides?: TxGasOverrides;
|
|
18
19
|
l2GasLimit?: bigint;
|
|
19
20
|
gasPerPubdata: bigint;
|
|
@@ -29,6 +30,7 @@ export declare function commonCtx(p: DepositParams, client: EthersClient, tokens
|
|
|
29
30
|
baseTokenL1: `0x${string}`;
|
|
30
31
|
baseIsEth: boolean;
|
|
31
32
|
l1AssetRouter: `0x${string}`;
|
|
33
|
+
l1NativeTokenVault: `0x${string}`;
|
|
32
34
|
route: DepositRoute;
|
|
33
35
|
bridgehub: `0x${string}`;
|
|
34
36
|
chainIdL2: bigint;
|
|
@@ -4,6 +4,7 @@ import type { DepositRoute } from '../../../../../core/types/flows/deposits';
|
|
|
4
4
|
import type { TxGasOverrides } from '../../../../../core/types/fees';
|
|
5
5
|
import type { Address } from '../../../../../core/types/primitives';
|
|
6
6
|
import { type GasQuote } from '../../../../../core/resources/deposits/gas';
|
|
7
|
+
import { type PriorityTxL2Leg } from '../../../../../core/resources/deposits/priority.ts';
|
|
7
8
|
export type { GasQuote };
|
|
8
9
|
export type QuoteL1GasInput = {
|
|
9
10
|
ctx: BuildCtx;
|
|
@@ -35,11 +36,13 @@ export declare function determineErc20L2Gas(input: {
|
|
|
35
36
|
l1Token: Address;
|
|
36
37
|
modelTx?: TransactionRequest;
|
|
37
38
|
priorityFloorGasLimit?: bigint;
|
|
39
|
+
priorityTxL2Leg?: PriorityTxL2Leg;
|
|
38
40
|
undeployedGasLimit?: bigint;
|
|
39
41
|
}): Promise<GasQuote | undefined>;
|
|
40
42
|
export declare function determineEthNonBaseL2Gas(input: {
|
|
41
43
|
ctx: BuildCtx;
|
|
42
44
|
modelTx?: TransactionRequest;
|
|
43
45
|
priorityFloorGasLimit?: bigint;
|
|
46
|
+
priorityTxL2Leg?: PriorityTxL2Leg;
|
|
44
47
|
undeployedGasLimit?: bigint;
|
|
45
48
|
}): Promise<GasQuote | undefined>;
|
|
@@ -6,6 +6,7 @@ import { type TxGasOverrides } from '../../../../core/types/fees';
|
|
|
6
6
|
import type { Hex } from '../../../../core/types/primitives';
|
|
7
7
|
import type { ResolvedToken, TokensResource } from '../../../../core/types/flows/token';
|
|
8
8
|
import type { ContractsResource } from '../contracts';
|
|
9
|
+
import type { WithdrawalProtocol } from '../../../../core/resources/withdrawals/protocol';
|
|
9
10
|
export interface BuildCtx extends CommonCtx {
|
|
10
11
|
client: EthersClient;
|
|
11
12
|
tokens: TokensResource;
|
|
@@ -14,14 +15,24 @@ export interface BuildCtx extends CommonCtx {
|
|
|
14
15
|
baseTokenAssetId: Hex;
|
|
15
16
|
baseTokenL1: Address;
|
|
16
17
|
baseIsEth: boolean;
|
|
18
|
+
/** Which token kind is being withdrawn: the chain's base token, or a non-base ERC-20. */
|
|
19
|
+
route: WithdrawRoute;
|
|
20
|
+
/**
|
|
21
|
+
* Which withdrawal protocol the chain speaks. Selects the route builder and the finalization
|
|
22
|
+
* entry point; see `core/resources/withdrawals/protocol.ts`.
|
|
23
|
+
*/
|
|
24
|
+
protocol: WithdrawalProtocol;
|
|
25
|
+
/** Chain id of L1 — the destination of a v32 withdrawal bundle. */
|
|
26
|
+
l1ChainId: bigint;
|
|
17
27
|
bridgehub: Address;
|
|
18
28
|
l1AssetRouter: Address;
|
|
19
29
|
l1Nullifier: Address;
|
|
20
30
|
l2AssetRouter: Address;
|
|
21
31
|
l2NativeTokenVault: Address;
|
|
22
32
|
l2BaseTokenSystem: Address;
|
|
33
|
+
interopCenter: Address;
|
|
23
34
|
gasOverrides?: TxGasOverrides;
|
|
24
35
|
}
|
|
25
|
-
export declare function commonCtx(p: WithdrawParams, client: EthersClient, tokens: TokensResource, contracts: ContractsResource): Promise<BuildCtx & {
|
|
36
|
+
export declare function commonCtx(p: WithdrawParams, client: EthersClient, tokens: TokensResource, contracts: ContractsResource, protocol: WithdrawalProtocol): Promise<BuildCtx & {
|
|
26
37
|
route: WithdrawRoute;
|
|
27
38
|
}>;
|
|
@@ -4,8 +4,13 @@ import type { WithdrawParams, WithdrawQuote, WithdrawPlan, WithdrawHandle, Withd
|
|
|
4
4
|
import type { Hex } from '../../../../core/types/primitives';
|
|
5
5
|
import type { WithdrawRouteStrategy, TransactionReceiptZKsyncOS } from './routes/types';
|
|
6
6
|
import { createFinalizationServices, type FinalizationServices } from './services/finalization';
|
|
7
|
+
import { createWithdrawalProtocolService, type WithdrawalProtocolService } from './services/protocol';
|
|
8
|
+
import type { WithdrawalProtocol } from '../../../../core/resources/withdrawals/protocol';
|
|
7
9
|
import type { TokensResource } from '../../../../core/types/flows/token';
|
|
8
10
|
import type { ContractsResource } from '../contracts';
|
|
11
|
+
/**
|
|
12
|
+
* Protocol v31 routes: one dedicated `withdraw` entry point per token kind.
|
|
13
|
+
*/
|
|
9
14
|
export declare const ROUTES: Record<WithdrawRoute, WithdrawRouteStrategy>;
|
|
10
15
|
export interface WithdrawalsResource {
|
|
11
16
|
quote(p: WithdrawParams): Promise<WithdrawQuote>;
|
|
@@ -64,6 +69,17 @@ export interface WithdrawalsResource {
|
|
|
64
69
|
error: unknown;
|
|
65
70
|
}>;
|
|
66
71
|
}
|
|
67
|
-
export
|
|
72
|
+
export interface WithdrawalsResourceOptions {
|
|
73
|
+
/**
|
|
74
|
+
* Force a withdrawal protocol instead of detecting it.
|
|
75
|
+
*
|
|
76
|
+
* Only needed when detection cannot run — e.g. the chain's Bridgehub is not reachable from the
|
|
77
|
+
* configured L1 provider, so neither the protocol version nor a bytecode probe is conclusive.
|
|
78
|
+
*/
|
|
79
|
+
protocol?: WithdrawalProtocol;
|
|
80
|
+
}
|
|
81
|
+
export declare function createWithdrawalsResource(client: EthersClient, tokens?: TokensResource, contracts?: ContractsResource, options?: WithdrawalsResourceOptions): WithdrawalsResource;
|
|
68
82
|
export { createFinalizationServices };
|
|
69
83
|
export type { FinalizationServices };
|
|
84
|
+
export { createWithdrawalProtocolService };
|
|
85
|
+
export type { WithdrawalProtocolService };
|
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
import { type TransactionReceipt } from 'ethers';
|
|
2
2
|
import type { Address, Hex } from '../../../../../core/types/primitives';
|
|
3
3
|
import type { EthersClient } from '../../../client';
|
|
4
|
-
import { type FinalizeReadiness, type FinalizeDepositParams, type
|
|
4
|
+
import { type FinalizeReadiness, type FinalizeDepositParams, type FinalizationEstimate, type WithdrawalFinalization, type ResolvedWithdrawalFinalization } from '../../../../../core/types/flows/withdrawals';
|
|
5
|
+
import { type WithdrawalOutcome } from '../../../../../core/resources/withdrawals/finalization';
|
|
6
|
+
import { type WithdrawalProtocolService } from './protocol';
|
|
5
7
|
export interface FinalizationServices {
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
9
|
+
* Derive the finalization arguments for a withdrawal, tagged with the protocol they belong to.
|
|
10
|
+
*/
|
|
11
|
+
fetchFinalization(l2TxHash: Hex): Promise<ResolvedWithdrawalFinalization>;
|
|
12
|
+
/**
|
|
13
|
+
* Build `finalizeDeposit` params.
|
|
14
|
+
*
|
|
15
|
+
* @deprecated Only meaningful on protocol v31 chains. Throws on v32+, where withdrawals are
|
|
16
|
+
* finalized through the interop handler — use {@link fetchFinalization} instead.
|
|
8
17
|
*/
|
|
9
18
|
fetchFinalizeDepositParams(l2TxHash: Hex): Promise<{
|
|
10
19
|
params: FinalizeDepositParams;
|
|
11
20
|
nullifier: Address;
|
|
12
21
|
}>;
|
|
22
|
+
/** Check whether the withdrawal has already been finalized on L1. */
|
|
23
|
+
isWithdrawalFinalized(finalization: WithdrawalFinalization): Promise<boolean>;
|
|
13
24
|
/**
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Estimate gas & fees for finalizeDeposit on L1 Nullifier.
|
|
23
|
-
*/
|
|
24
|
-
estimateFinalization(params: FinalizeDepositParams): Promise<FinalizationEstimate>;
|
|
25
|
-
/**
|
|
26
|
-
* Call finalizeDeposit on L1 Nullifier.
|
|
25
|
+
* Classify the withdrawal's on-chain outcome, on either protocol: read from
|
|
26
|
+
* `L1Nullifier.isWithdrawalFinalized` on `legacy-withdrawal`, and from the interop handler's
|
|
27
|
+
* bundle/call status on `interop-bundle`.
|
|
28
|
+
*
|
|
29
|
+
* Distinguishes a terminally-failed withdrawal (v32 only: the bundle was unwound with its call
|
|
30
|
+
* cancelled) from one that is merely not finalized yet — which {@link isWithdrawalFinalized}
|
|
31
|
+
* collapses into `false`. `failed` is unreachable on the legacy protocol, which has no equivalent
|
|
32
|
+
* of an unbundle.
|
|
27
33
|
*/
|
|
28
|
-
|
|
34
|
+
withdrawalOutcome(finalization: WithdrawalFinalization): Promise<WithdrawalOutcome>;
|
|
35
|
+
/** Simulate finalization on L1 to check readiness. */
|
|
36
|
+
simulateFinalizeReadiness(finalization: WithdrawalFinalization): Promise<FinalizeReadiness>;
|
|
37
|
+
/** Estimate gas & fees for finalization on L1. */
|
|
38
|
+
estimateFinalization(finalization: WithdrawalFinalization): Promise<FinalizationEstimate>;
|
|
39
|
+
/** Send the finalization transaction on L1. */
|
|
40
|
+
finalize(finalization: WithdrawalFinalization): Promise<{
|
|
29
41
|
hash: string;
|
|
30
42
|
wait: () => Promise<TransactionReceipt>;
|
|
31
43
|
}>;
|
|
32
44
|
}
|
|
33
|
-
export declare function createFinalizationServices(client: EthersClient
|
|
45
|
+
export declare function createFinalizationServices(client: EthersClient,
|
|
46
|
+
/**
|
|
47
|
+
* Withdrawal-protocol detection. Optional: constructed per client when omitted, so
|
|
48
|
+
* `createFinalizationServices(client)` keeps working. Pass one in to share the detection cache
|
|
49
|
+
* with a withdrawals resource built over the same client.
|
|
50
|
+
*/
|
|
51
|
+
protocolService?: WithdrawalProtocolService): FinalizationServices;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EthersClient } from '../../../client';
|
|
2
|
+
import { type WithdrawalProtocol, type WithdrawalProtocolDetection } from '../../../../../core/resources/withdrawals/protocol';
|
|
3
|
+
export interface WithdrawalProtocolService {
|
|
4
|
+
/** Cached detection for the connected L2. */
|
|
5
|
+
detect(): Promise<WithdrawalProtocolDetection>;
|
|
6
|
+
/** Convenience wrapper around {@link detect}. */
|
|
7
|
+
protocol(): Promise<WithdrawalProtocol>;
|
|
8
|
+
/** Drop the cached result (e.g. after a chain upgrade during a long-lived session). */
|
|
9
|
+
refresh(): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function createWithdrawalProtocolService(client: EthersClient, override?: WithdrawalProtocol): WithdrawalProtocolService;
|