@matterlabs/zksync-js 0.0.1 → 0.0.3
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 +1279 -925
- package/dist/adapters/ethers/index.cjs.map +1 -1
- package/dist/adapters/ethers/index.d.ts +1 -0
- package/dist/adapters/ethers/index.js +9 -8
- package/dist/adapters/ethers/resources/contracts/contracts.d.ts +9 -0
- package/dist/adapters/ethers/resources/contracts/index.d.ts +2 -0
- package/dist/adapters/ethers/resources/contracts/types.d.ts +60 -0
- package/dist/adapters/ethers/resources/deposits/context.d.ts +21 -7
- package/dist/adapters/ethers/resources/deposits/index.d.ts +3 -1
- 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 +41 -0
- package/dist/adapters/ethers/resources/tokens/index.d.ts +1 -0
- package/dist/adapters/ethers/resources/tokens/tokens.d.ts +10 -0
- package/dist/adapters/ethers/resources/utils.d.ts +3 -17
- package/dist/adapters/ethers/resources/withdrawals/context.d.ts +15 -7
- package/dist/adapters/ethers/resources/withdrawals/index.d.ts +3 -1
- 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 +1388 -1501
- package/dist/adapters/ethers/sdk.cjs.map +1 -1
- package/dist/adapters/ethers/sdk.d.ts +5 -22
- 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 +1233 -744
- package/dist/adapters/viem/index.cjs.map +1 -1
- package/dist/adapters/viem/index.d.ts +3 -0
- package/dist/adapters/viem/index.js +8 -8
- package/dist/adapters/viem/resources/contracts/contracts.d.ts +9 -0
- package/dist/adapters/viem/resources/contracts/index.d.ts +2 -0
- package/dist/adapters/viem/resources/contracts/types.d.ts +61 -0
- package/dist/adapters/viem/resources/deposits/context.d.ts +21 -7
- package/dist/adapters/viem/resources/deposits/index.d.ts +3 -1
- 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 +37 -0
- package/dist/adapters/viem/resources/tokens/index.d.ts +1 -0
- package/dist/adapters/viem/resources/tokens/tokens.d.ts +3 -0
- package/dist/adapters/viem/resources/utils.d.ts +3 -19
- package/dist/adapters/viem/resources/withdrawals/context.d.ts +14 -9
- package/dist/adapters/viem/resources/withdrawals/index.d.ts +3 -1
- 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 +1225 -699
- package/dist/adapters/viem/sdk.cjs.map +1 -1
- package/dist/adapters/viem/sdk.d.ts +5 -25
- package/dist/adapters/viem/sdk.js +6 -6
- package/dist/{chunk-3LALBFFE.js → chunk-3MRGU4HV.js} +9 -5
- package/dist/{chunk-CGO27P7F.js → chunk-5YWP4CZP.js} +849 -835
- package/dist/{chunk-4HLJJKIY.js → chunk-6K6VJQAL.js} +2 -2
- package/dist/{chunk-6GCT6TLS.js → chunk-F2ENUV3A.js} +13 -1
- package/dist/{chunk-7M4V3FMT.js → chunk-JXUFGIJG.js} +986 -678
- package/dist/chunk-LL3WKCFJ.js +231 -0
- package/dist/{chunk-Y75OMFK6.js → chunk-M5J2MM2U.js} +351 -1
- package/dist/{chunk-263G6636.js → chunk-NCAIVYBR.js} +1 -14
- package/dist/{chunk-DI2CJDPZ.js → chunk-NEC2ZKHI.js} +5 -13
- package/dist/chunk-NTEIA5KA.js +13 -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/codec/ntv.d.ts +48 -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 +4508 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +5 -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/token.d.ts +192 -0
- package/dist/core/types/flows/withdrawals.d.ts +12 -6
- package/dist/core/utils/addr.d.ts +2 -0
- package/dist/index.cjs +4520 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -4
- package/package.json +5 -1
- package/dist/adapters/ethers/resources/token-info.d.ts +0 -31
- package/dist/adapters/ethers/resources/withdrawals/routes/eth-nonbase.d.ts +0 -2
- package/dist/adapters/viem/resources/token-info.d.ts +0 -34
- 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
|
@@ -7,6 +7,7 @@ export type { DepositsResource } from './resources/deposits';
|
|
|
7
7
|
export { createWithdrawalsResource } from './resources/withdrawals';
|
|
8
8
|
export { createFinalizationServices } from './resources/withdrawals';
|
|
9
9
|
export type { WithdrawalsResource, FinalizationServices } from './resources/withdrawals';
|
|
10
|
+
export { createTokensResource } from './resources/tokens';
|
|
10
11
|
export * from './errors/error-ops';
|
|
11
12
|
export * from './errors/revert';
|
|
12
13
|
export type * from './typechain';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import '../../chunk-
|
|
7
|
-
import '../../chunk-
|
|
8
|
-
import '../../chunk-
|
|
1
|
+
export { buildDirectRequestStruct, createDepositsResource, createEthersSdk, createFinalizationServices, createTokensResource, createWithdrawalsResource, encodeNativeTokenVaultTransferData, encodeSecondBridgeArgs, encodeSecondBridgeDataV1, encodeSecondBridgeErc20Args, encodeSecondBridgeEthArgs } from '../../chunk-5YWP4CZP.js';
|
|
2
|
+
import '../../chunk-LL3WKCFJ.js';
|
|
3
|
+
import '../../chunk-NEC2ZKHI.js';
|
|
4
|
+
export { createEthersClient as createClient, createEthersClient } from '../../chunk-3MRGU4HV.js';
|
|
5
|
+
export { classifyReadinessFromRevert, createErrorHandlers, decodeRevert, registerErrorAbi, toZKsyncError } from '../../chunk-XRE7H466.js';
|
|
6
|
+
import '../../chunk-6K6VJQAL.js';
|
|
7
|
+
import '../../chunk-NCAIVYBR.js';
|
|
8
|
+
import '../../chunk-M5J2MM2U.js';
|
|
9
|
+
import '../../chunk-F2ENUV3A.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EthersClient } from '../../client';
|
|
2
|
+
import type { ContractsResource } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a contracts resource for managing resolved addresses and contract instances.
|
|
5
|
+
*
|
|
6
|
+
* @param client - EthersClient instance
|
|
7
|
+
* @returns ContractsResource instance
|
|
8
|
+
*/
|
|
9
|
+
export declare function createContractsResource(client: EthersClient): ContractsResource;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Contract } from 'ethers';
|
|
2
|
+
import type { ResolvedAddresses } from '../../client';
|
|
3
|
+
/**
|
|
4
|
+
* Collection of typed ethers Contract instances for all bridge contracts.
|
|
5
|
+
*/
|
|
6
|
+
export interface ContractInstances {
|
|
7
|
+
bridgehub: Contract;
|
|
8
|
+
l1AssetRouter: Contract;
|
|
9
|
+
l1Nullifier: Contract;
|
|
10
|
+
l1NativeTokenVault: Contract;
|
|
11
|
+
l2AssetRouter: Contract;
|
|
12
|
+
l2NativeTokenVault: Contract;
|
|
13
|
+
l2BaseTokenSystem: Contract;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Contracts resource interface providing access to resolved addresses
|
|
17
|
+
* and contract instances.
|
|
18
|
+
*/
|
|
19
|
+
export interface ContractsResource {
|
|
20
|
+
/**
|
|
21
|
+
* Returns resolved addresses for all bridge contracts.
|
|
22
|
+
*
|
|
23
|
+
* @returns Resolved contract addresses
|
|
24
|
+
*/
|
|
25
|
+
addresses(): Promise<ResolvedAddresses>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns typed Contract instances for all bridge contracts (cached).
|
|
28
|
+
*
|
|
29
|
+
* @returns Contract instances
|
|
30
|
+
*/
|
|
31
|
+
instances(): Promise<ContractInstances>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the Bridgehub contract instance.
|
|
34
|
+
*/
|
|
35
|
+
bridgehub(): Promise<Contract>;
|
|
36
|
+
/**
|
|
37
|
+
* Returns the L1 Asset Router contract instance.
|
|
38
|
+
*/
|
|
39
|
+
l1AssetRouter(): Promise<Contract>;
|
|
40
|
+
/**
|
|
41
|
+
* Returns the L1 Native Token Vault contract instance.
|
|
42
|
+
*/
|
|
43
|
+
l1NativeTokenVault(): Promise<Contract>;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the L1 Nullifier contract instance.
|
|
46
|
+
*/
|
|
47
|
+
l1Nullifier(): Promise<Contract>;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the L2 Asset Router contract instance.
|
|
50
|
+
*/
|
|
51
|
+
l2AssetRouter(): Promise<Contract>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the L2 Native Token Vault contract instance.
|
|
54
|
+
*/
|
|
55
|
+
l2NativeTokenVault(): Promise<Contract>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the L2 Base Token System contract instance.
|
|
58
|
+
*/
|
|
59
|
+
l2BaseTokenSystem(): Promise<Contract>;
|
|
60
|
+
}
|
|
@@ -1,26 +1,40 @@
|
|
|
1
1
|
import type { EthersClient } from '../../client';
|
|
2
|
-
import type { Address } from '../../../../core/types/primitives';
|
|
3
|
-
import { type ResolvedFeeOverrides } from '../utils';
|
|
2
|
+
import type { Address, Hex } from '../../../../core/types/primitives';
|
|
4
3
|
import type { DepositParams, DepositRoute } from '../../../../core/types/flows/deposits';
|
|
5
4
|
import type { CommonCtx } from '../../../../core/types/flows/base';
|
|
5
|
+
import type { TxOverrides } from '../../../../core/types/fees';
|
|
6
|
+
import type { ResolvedToken, TokensResource } from '../../../../core/types/flows/token';
|
|
7
|
+
import type { ContractsResource } from '../contracts';
|
|
6
8
|
export interface BuildCtx extends CommonCtx {
|
|
7
9
|
client: EthersClient;
|
|
10
|
+
tokens: TokensResource;
|
|
11
|
+
contracts: ContractsResource;
|
|
12
|
+
resolvedToken: ResolvedToken;
|
|
13
|
+
baseTokenAssetId: Hex;
|
|
14
|
+
baseTokenL1: Address;
|
|
15
|
+
baseIsEth: boolean;
|
|
8
16
|
l1AssetRouter: Address;
|
|
9
|
-
|
|
10
|
-
l2GasLimit
|
|
17
|
+
gasOverrides?: TxOverrides;
|
|
18
|
+
l2GasLimit?: bigint;
|
|
11
19
|
gasPerPubdata: bigint;
|
|
12
20
|
operatorTip: bigint;
|
|
13
21
|
refundRecipient: Address;
|
|
14
22
|
}
|
|
15
|
-
export declare function commonCtx(p: DepositParams, client: EthersClient): Promise<{
|
|
23
|
+
export declare function commonCtx(p: DepositParams, client: EthersClient, tokens: TokensResource, contracts: ContractsResource): Promise<{
|
|
16
24
|
client: EthersClient;
|
|
25
|
+
tokens: TokensResource;
|
|
26
|
+
contracts: ContractsResource;
|
|
27
|
+
resolvedToken: ResolvedToken;
|
|
28
|
+
baseTokenAssetId: `0x${string}`;
|
|
29
|
+
baseTokenL1: `0x${string}`;
|
|
30
|
+
baseIsEth: boolean;
|
|
17
31
|
l1AssetRouter: `0x${string}`;
|
|
18
32
|
route: DepositRoute;
|
|
19
33
|
bridgehub: `0x${string}`;
|
|
20
34
|
chainIdL2: bigint;
|
|
21
35
|
sender: `0x${string}`;
|
|
22
|
-
|
|
23
|
-
l2GasLimit: bigint;
|
|
36
|
+
gasOverrides: TxOverrides | undefined;
|
|
37
|
+
l2GasLimit: bigint | undefined;
|
|
24
38
|
gasPerPubdata: bigint;
|
|
25
39
|
operatorTip: bigint;
|
|
26
40
|
refundRecipient: `0x${string}`;
|
|
@@ -3,6 +3,8 @@ import type { DepositParams, DepositQuote, DepositHandle, DepositWaitable, Depos
|
|
|
3
3
|
import type { Hex } from '../../../../core/types/primitives.ts';
|
|
4
4
|
import { type TransactionRequest, type TransactionReceipt } from 'ethers';
|
|
5
5
|
import type { DepositRouteStrategy } from './routes/types.ts';
|
|
6
|
+
import type { TokensResource } from '../../../../core/types/flows/token';
|
|
7
|
+
import type { ContractsResource } from '../contracts';
|
|
6
8
|
export declare const ROUTES: Record<DepositRoute, DepositRouteStrategy>;
|
|
7
9
|
export interface DepositsResource {
|
|
8
10
|
quote(p: DepositParams): Promise<DepositQuote>;
|
|
@@ -43,4 +45,4 @@ export interface DepositsResource {
|
|
|
43
45
|
error: unknown;
|
|
44
46
|
}>;
|
|
45
47
|
}
|
|
46
|
-
export declare function createDepositsResource(client: EthersClient): DepositsResource;
|
|
48
|
+
export declare function createDepositsResource(client: EthersClient, tokens?: TokensResource, contracts?: ContractsResource): DepositsResource;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { TransactionRequest } from 'ethers';
|
|
2
2
|
import type { DepositParams } from '../../../../../core/types/flows/deposits';
|
|
3
|
+
import type { DepositFeeBreakdown } from '../../../../../core/types/fees';
|
|
3
4
|
import type { RouteStrategy } from '../../../../../core/types/flows/route';
|
|
4
5
|
import type { BuildCtx as DepositBuildCtx } from '../context';
|
|
5
|
-
export type
|
|
6
|
-
baseCost: bigint;
|
|
7
|
-
mintValue: bigint;
|
|
8
|
-
l1GasLimit?: bigint;
|
|
9
|
-
};
|
|
10
|
-
export type DepositRouteStrategy = RouteStrategy<DepositParams, TransactionRequest, DepositQuoteExtras, DepositBuildCtx>;
|
|
6
|
+
export type DepositRouteStrategy = RouteStrategy<DepositParams, TransactionRequest, DepositFeeBreakdown, DepositBuildCtx>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { TransactionRequest } from 'ethers';
|
|
2
|
+
import type { BuildCtx } from '../context';
|
|
3
|
+
import type { DepositRoute } from '../../../../../core/types/flows/deposits';
|
|
4
|
+
import type { TxOverrides } from '../../../../../core/types/fees';
|
|
5
|
+
import type { Address } from '../../../../../core/types/primitives';
|
|
6
|
+
import { type GasQuote } from '../../../../../core/resources/deposits/gas';
|
|
7
|
+
export type { GasQuote };
|
|
8
|
+
export type QuoteL1GasInput = {
|
|
9
|
+
ctx: BuildCtx;
|
|
10
|
+
tx: TransactionRequest;
|
|
11
|
+
overrides?: TxOverrides;
|
|
12
|
+
fallbackGasLimit?: bigint;
|
|
13
|
+
};
|
|
14
|
+
export type QuoteL2GasInput = {
|
|
15
|
+
ctx: BuildCtx;
|
|
16
|
+
route: DepositRoute;
|
|
17
|
+
l2TxForModeling?: TransactionRequest;
|
|
18
|
+
overrideGasLimit?: bigint;
|
|
19
|
+
stateOverrides?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
export type ResolveErc20L2GasLimitInput = {
|
|
22
|
+
ctx: BuildCtx;
|
|
23
|
+
l1Token: Address;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Quote L1 gas for a deposit transaction.
|
|
27
|
+
*/
|
|
28
|
+
export declare function quoteL1Gas(input: QuoteL1GasInput): Promise<GasQuote | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Quote L2 gas for an L2 transaction.
|
|
31
|
+
*/
|
|
32
|
+
export declare function quoteL2Gas(input: QuoteL2GasInput): Promise<GasQuote | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a safe L2 gas limit for ERC20 deposits based on whether the
|
|
35
|
+
* L2 token contract is already deployed.
|
|
36
|
+
*/
|
|
37
|
+
export declare function determineErc20L2Gas(input: {
|
|
38
|
+
ctx: BuildCtx;
|
|
39
|
+
l1Token: Address;
|
|
40
|
+
modelTx?: TransactionRequest;
|
|
41
|
+
}): Promise<GasQuote | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTokensResource } from './tokens';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EthersClient } from '../../client';
|
|
2
|
+
import type { TokensResource } from '../../../../core/types/flows/token';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a tokens resource for managing token identity, L1/L2 mappings,
|
|
5
|
+
* and bridge assetId primitives.
|
|
6
|
+
*
|
|
7
|
+
* @param client - EthersClient instance
|
|
8
|
+
* @returns TokensResource instance
|
|
9
|
+
*/
|
|
10
|
+
export declare function createTokensResource(client: EthersClient): TokensResource;
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
1
|
import type { Address } from '../../../core/types';
|
|
3
|
-
import type { EthersClient } from '../client';
|
|
4
|
-
import type { Eip1559GasOverrides, ResolvedEip1559Fees } from '../../../core/types/flows/base';
|
|
5
|
-
export declare function encodeNativeTokenVaultAssetId(chainId: bigint, address: string): string;
|
|
6
2
|
export declare function encodeNativeTokenVaultTransferData(amount: bigint, receiver: Address, token: Address): string;
|
|
7
3
|
export declare function encodeSecondBridgeDataV1(assetId: string, transferData: string): string;
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function checkBaseCost(baseCost: ethers.BigNumberish, value: ethers.BigNumberish | Promise<ethers.BigNumberish>): Promise<void>;
|
|
12
|
-
export type ResolvedFeeOverrides = ResolvedEip1559Fees & {
|
|
13
|
-
gasPriceForBaseCost: bigint;
|
|
14
|
-
};
|
|
15
|
-
export declare function getFeeOverrides(client: EthersClient, overrides?: Eip1559GasOverrides): Promise<ResolvedFeeOverrides>;
|
|
16
|
-
export declare function getL2FeeOverrides(client: EthersClient, overrides?: Eip1559GasOverrides): Promise<ResolvedEip1559Fees>;
|
|
17
|
-
export declare function getGasPriceWei(client: EthersClient): Promise<bigint>;
|
|
4
|
+
export declare function encodeSecondBridgeArgs(token: Address, amount: bigint, l2Receiver: Address): `0x${string}`;
|
|
5
|
+
export declare function encodeSecondBridgeErc20Args(token: Address, amount: bigint, l2Receiver: Address): `0x${string}`;
|
|
6
|
+
export declare function encodeSecondBridgeEthArgs(amount: bigint, l2Receiver: Address, ethToken?: Address): `0x${string}`;
|
|
18
7
|
export declare function buildDirectRequestStruct(args: {
|
|
19
8
|
chainId: bigint;
|
|
20
9
|
mintValue: bigint;
|
|
@@ -34,6 +23,3 @@ export declare function buildDirectRequestStruct(args: {
|
|
|
34
23
|
factoryDeps: `0x${string}`[];
|
|
35
24
|
refundRecipient: `0x${string}`;
|
|
36
25
|
};
|
|
37
|
-
export declare function encodeSecondBridgeArgs(token: Address, amount: bigint, l2Receiver: Address): `0x${string}`;
|
|
38
|
-
export declare function encodeSecondBridgeErc20Args(token: Address, amount: bigint, l2Receiver: Address): `0x${string}`;
|
|
39
|
-
export declare function encodeSecondBridgeEthArgs(amount: bigint, l2Receiver: Address, ethToken?: Address): `0x${string}`;
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import type { EthersClient } from '../../client';
|
|
2
2
|
import type { Address } from '../../../../core/types/primitives';
|
|
3
|
-
import type
|
|
4
|
-
import type { CommonCtx
|
|
3
|
+
import { type WithdrawParams, type WithdrawRoute } from '../../../../core/types/flows/withdrawals';
|
|
4
|
+
import type { CommonCtx } from '../../../../core/types/flows/base';
|
|
5
|
+
import type { TxOverrides } from '../../../../core/types/fees';
|
|
6
|
+
import type { Hex } from '../../../../core/types/primitives';
|
|
7
|
+
import type { ResolvedToken, TokensResource } from '../../../../core/types/flows/token';
|
|
8
|
+
import type { ContractsResource } from '../contracts';
|
|
5
9
|
export interface BuildCtx extends CommonCtx {
|
|
6
10
|
client: EthersClient;
|
|
11
|
+
tokens: TokensResource;
|
|
12
|
+
contracts: ContractsResource;
|
|
13
|
+
resolvedToken: ResolvedToken;
|
|
14
|
+
baseTokenAssetId: Hex;
|
|
15
|
+
baseTokenL1: Address;
|
|
16
|
+
baseIsEth: boolean;
|
|
17
|
+
bridgehub: Address;
|
|
7
18
|
l1AssetRouter: Address;
|
|
8
19
|
l1Nullifier: Address;
|
|
9
20
|
l2AssetRouter: Address;
|
|
10
21
|
l2NativeTokenVault: Address;
|
|
11
22
|
l2BaseTokenSystem: Address;
|
|
12
|
-
|
|
13
|
-
l2GasLimit: bigint;
|
|
14
|
-
gasBufferPct: number;
|
|
15
|
-
fee: ResolvedEip1559Fees;
|
|
23
|
+
gasOverrides?: TxOverrides;
|
|
16
24
|
}
|
|
17
|
-
export declare function commonCtx(p: WithdrawParams, client: EthersClient): Promise<BuildCtx & {
|
|
25
|
+
export declare function commonCtx(p: WithdrawParams, client: EthersClient, tokens: TokensResource, contracts: ContractsResource): Promise<BuildCtx & {
|
|
18
26
|
route: WithdrawRoute;
|
|
19
27
|
}>;
|
|
@@ -4,6 +4,8 @@ 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 type { TokensResource } from '../../../../core/types/flows/token';
|
|
8
|
+
import type { ContractsResource } from '../contracts';
|
|
7
9
|
export declare const ROUTES: Record<WithdrawRoute, WithdrawRouteStrategy>;
|
|
8
10
|
export interface WithdrawalsResource {
|
|
9
11
|
quote(p: WithdrawParams): Promise<WithdrawQuote>;
|
|
@@ -51,6 +53,6 @@ export interface WithdrawalsResource {
|
|
|
51
53
|
error: unknown;
|
|
52
54
|
}>;
|
|
53
55
|
}
|
|
54
|
-
export declare function createWithdrawalsResource(client: EthersClient): WithdrawalsResource;
|
|
56
|
+
export declare function createWithdrawalsResource(client: EthersClient, tokens?: TokensResource, contracts?: ContractsResource): WithdrawalsResource;
|
|
55
57
|
export { createFinalizationServices };
|
|
56
58
|
export type { FinalizationServices };
|
|
@@ -3,8 +3,8 @@ import type { WithdrawParams } from '../../../../../core/types/flows/withdrawals
|
|
|
3
3
|
import type { RouteStrategy } from '../../../../../core/types/flows/route';
|
|
4
4
|
import type { BuildCtx as WithdrawBuildCtx } from '../context';
|
|
5
5
|
import type { Address, Hex } from '../../../../../core/types';
|
|
6
|
-
|
|
7
|
-
export type WithdrawRouteStrategy = RouteStrategy<WithdrawParams, TransactionRequest,
|
|
6
|
+
import type { WithdrawalFeeBreakdown } from '../../../../../core/types/fees';
|
|
7
|
+
export type WithdrawRouteStrategy = RouteStrategy<WithdrawParams, TransactionRequest, WithdrawalFeeBreakdown, WithdrawBuildCtx>;
|
|
8
8
|
export interface L2ToL1Log {
|
|
9
9
|
l2ShardId?: number;
|
|
10
10
|
isService?: boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Address } from '../../../../../core/types/primitives';
|
|
2
|
+
import type { WithdrawalFeeBreakdown } from '../../../../../core/types/fees';
|
|
3
|
+
import type { GasQuote } from './gas';
|
|
4
|
+
export type BuildWithdrawFeeBreakdownInput = {
|
|
5
|
+
feeToken: Address;
|
|
6
|
+
l2Gas?: GasQuote;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Builds FeeBreakdown for withdrawals.
|
|
10
|
+
*
|
|
11
|
+
* Withdrawals represent a single L2 transaction:
|
|
12
|
+
* - fees.l2 = cost of the withdraw tx on L2
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildFeeBreakdown(p: BuildWithdrawFeeBreakdownInput): WithdrawalFeeBreakdown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TransactionRequest } from 'ethers';
|
|
2
|
+
import type { BuildCtx } from '../context';
|
|
3
|
+
import { type GasQuote } from '../../../../../core/resources/withdrawals/gas';
|
|
4
|
+
export type { GasQuote };
|
|
5
|
+
export type QuoteWithdrawL2GasInput = {
|
|
6
|
+
ctx: BuildCtx;
|
|
7
|
+
tx: TransactionRequest;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Quotes L2 gas for a withdrawal tx.
|
|
11
|
+
*/
|
|
12
|
+
export declare function quoteL2Gas(input: QuoteWithdrawL2GasInput): Promise<GasQuote | undefined>;
|