@m0-foundation/ntt-sdk-route 0.0.24 → 0.0.26
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/index.d.mts +33 -46
- package/dist/index.d.ts +33 -46
- package/dist/index.js +8588 -876
- package/dist/index.mjs +8585 -874
- package/package.json +7 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Network, routes, Chain, ChainContext, TokenId, Signer, ChainAddress, AccountAddress } from '@wormhole-foundation/sdk-connect';
|
|
2
|
-
import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
|
|
3
|
-
import { EvmNtt } from '@wormhole-foundation/sdk-evm-ntt';
|
|
4
|
-
import { SolanaNtt } from '@wormhole-foundation/sdk-solana-ntt';
|
|
5
2
|
import { EvmChains, EvmUnsignedTransaction } from '@wormhole-foundation/sdk-evm';
|
|
6
3
|
import { SolanaChains, SolanaUnsignedTransaction } from '@wormhole-foundation/sdk-solana';
|
|
7
4
|
import { NttRoute } from '@wormhole-foundation/sdk-route-ntt';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
|
|
6
|
+
import { Connection, AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
10
7
|
|
|
11
8
|
type Op = NttRoute.Options;
|
|
12
9
|
type Tp = routes.TransferParams<Op>;
|
|
@@ -15,15 +12,9 @@ type Vp = NttRoute.ValidatedParams;
|
|
|
15
12
|
type QR = routes.QuoteResult<Op, Vp>;
|
|
16
13
|
type Q = routes.Quote<Op, Vp>;
|
|
17
14
|
type R = NttRoute.AutomaticTransferReceipt;
|
|
18
|
-
type Contracts = Ntt.Contracts & {
|
|
19
|
-
mLikeTokens: string[];
|
|
20
|
-
};
|
|
21
15
|
declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<N, Op, Vp, R> implements routes.StaticRouteMethods<typeof M0AutomaticRoute> {
|
|
22
16
|
static NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
|
|
23
|
-
static EVM_USDZ_TOKEN: string;
|
|
24
|
-
static EVM_WRAPPED_M_TOKEN: string;
|
|
25
17
|
static EXECUTOR_ENTRYPOINT: string;
|
|
26
|
-
static EVM_CONTRACTS: Contracts;
|
|
27
18
|
static meta: {
|
|
28
19
|
name: string;
|
|
29
20
|
provider: string;
|
|
@@ -31,12 +22,12 @@ declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<
|
|
|
31
22
|
static supportedNetworks(): Network[];
|
|
32
23
|
static isPlatformSupported(platform: string): boolean;
|
|
33
24
|
static supportedChains(network: Network): Chain[];
|
|
34
|
-
static getContracts(chainContext: ChainContext<Network>): Contracts;
|
|
25
|
+
static getContracts(chainContext: ChainContext<Network>): Ntt.Contracts;
|
|
35
26
|
static supportedSourceTokens(fromChain: ChainContext<Network>): Promise<TokenId[]>;
|
|
36
27
|
static supportedDestinationTokens<N extends Network>(token: TokenId, fromChain: ChainContext<N>, toChain: ChainContext<N>): Promise<TokenId[]>;
|
|
37
28
|
static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean;
|
|
38
29
|
getDefaultOptions(): Op;
|
|
39
|
-
isAvailable(
|
|
30
|
+
isAvailable(_: routes.RouteTransferRequest<N>): Promise<boolean>;
|
|
40
31
|
validate(request: routes.RouteTransferRequest<N>, params: Tp): Promise<Vr>;
|
|
41
32
|
quote(request: routes.RouteTransferRequest<N>, params: Vp): Promise<QR>;
|
|
42
33
|
initiate(request: routes.RouteTransferRequest<N>, signer: Signer, quote: Q, to: ChainAddress): Promise<R>;
|
|
@@ -44,44 +35,40 @@ declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<
|
|
|
44
35
|
* Modified from EvmNtt `transfer` function to call `transferMLikeToken` instead
|
|
45
36
|
* https://github.com/wormhole-foundation/native-token-transfers/blob/main/evm/ts/src/ntt.ts#L461
|
|
46
37
|
*/
|
|
47
|
-
transferMLike<N extends Network, C extends EvmChains>(
|
|
48
|
-
|
|
49
|
-
transferSolanaExtension<N extends Network, C extends SolanaChains>(ntt: SolanaNtt<N, C>, sender: AccountAddress<C>, amount: bigint, recipient: ChainAddress, sourceToken: string, destinationToken: string, options: Ntt.TransferOptions, outboxItem?: Keypair): AsyncGenerator<SolanaUnsignedTransaction<N, C>>;
|
|
38
|
+
transferMLike<N extends Network, C extends EvmChains>(ctx: ChainContext<Network>, sender: AccountAddress<C>, amount: bigint, destination: ChainAddress, sourceToken: string, destinationToken: string, options: Ntt.TransferOptions): AsyncGenerator<EvmUnsignedTransaction<N, C>>;
|
|
39
|
+
transferSolanaExtension<N extends Network, C extends SolanaChains>(ctx: ChainContext<Network>, sender: AccountAddress<C>, amount: bigint, recipient: ChainAddress, sourceToken: string, destinationToken: string): AsyncGenerator<SolanaUnsignedTransaction<N, C>>;
|
|
50
40
|
track(receipt: R, timeout?: number): AsyncGenerator<R, void, unknown>;
|
|
51
41
|
private getExecutorQuote;
|
|
52
|
-
private requiresExecutor;
|
|
53
42
|
}
|
|
54
43
|
|
|
55
|
-
type
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
type extensionToken = {
|
|
45
|
+
destinations: {
|
|
46
|
+
[chainId: number]: Set<string>;
|
|
47
|
+
};
|
|
48
|
+
extensionProgram: PublicKey;
|
|
58
49
|
tokenProgram: PublicKey;
|
|
50
|
+
mint: PublicKey;
|
|
59
51
|
};
|
|
60
|
-
declare class
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
private static
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
static
|
|
79
|
-
|
|
80
|
-
chain: Chain;
|
|
81
|
-
nttMessage: Ntt.Message;
|
|
82
|
-
recipient: PublicKey;
|
|
83
|
-
revertWhenNotReady: boolean;
|
|
84
|
-
}): Promise<TransactionInstruction[]>;
|
|
52
|
+
declare class SvmRouter {
|
|
53
|
+
connection: Connection;
|
|
54
|
+
chain: Chain;
|
|
55
|
+
network: Exclude<Network, "Devnet">;
|
|
56
|
+
private cachedLookupTable;
|
|
57
|
+
private tokens;
|
|
58
|
+
private static instance;
|
|
59
|
+
static evmPeer: string;
|
|
60
|
+
constructor(connection: Connection, chain: Chain, network: Exclude<Network, "Devnet">, cachedLookupTable?: AddressLookupTableAccount | null, tokens?: Record<string, extensionToken> | null);
|
|
61
|
+
static fromChainContext(ctx: ChainContext<Network>): Promise<SvmRouter>;
|
|
62
|
+
buildSendTokenInstruction(amount: bigint, sender: PublicKey, sourceToken: string, destinationToken: string, destinationChain: Chain, recipient: string): Promise<TransactionInstruction>;
|
|
63
|
+
getSupportedExtensions(): Promise<Record<string, extensionToken>>;
|
|
64
|
+
getSupportedSourceTokens(): Promise<TokenId[]>;
|
|
65
|
+
getSupportedDestinationTokens(sourceToken: string, toChain: Chain): Promise<TokenId[]>;
|
|
66
|
+
getAddressLookupTableAccounts(): Promise<AddressLookupTableAccount>;
|
|
67
|
+
buildExecutorRelayInstruction(sender: PublicKey, quote: NttWithExecutor.Quote, destinationChain: Chain): Promise<TransactionInstruction>;
|
|
68
|
+
private getRemainingAccounts;
|
|
69
|
+
static applyScaledUiMultiplier(connection: Connection, mint: PublicKey, amount: bigint): Promise<bigint>;
|
|
70
|
+
static hexToBytes32(hex: string): number[];
|
|
71
|
+
static bytes32toHex(bytes: number[]): string;
|
|
85
72
|
}
|
|
86
73
|
|
|
87
|
-
export { M0AutomaticRoute,
|
|
74
|
+
export { M0AutomaticRoute, SvmRouter as SolanaRouter };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Network, routes, Chain, ChainContext, TokenId, Signer, ChainAddress, AccountAddress } from '@wormhole-foundation/sdk-connect';
|
|
2
|
-
import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
|
|
3
|
-
import { EvmNtt } from '@wormhole-foundation/sdk-evm-ntt';
|
|
4
|
-
import { SolanaNtt } from '@wormhole-foundation/sdk-solana-ntt';
|
|
5
2
|
import { EvmChains, EvmUnsignedTransaction } from '@wormhole-foundation/sdk-evm';
|
|
6
3
|
import { SolanaChains, SolanaUnsignedTransaction } from '@wormhole-foundation/sdk-solana';
|
|
7
4
|
import { NttRoute } from '@wormhole-foundation/sdk-route-ntt';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { Ntt, NttWithExecutor } from '@wormhole-foundation/sdk-definitions-ntt';
|
|
6
|
+
import { Connection, AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
10
7
|
|
|
11
8
|
type Op = NttRoute.Options;
|
|
12
9
|
type Tp = routes.TransferParams<Op>;
|
|
@@ -15,15 +12,9 @@ type Vp = NttRoute.ValidatedParams;
|
|
|
15
12
|
type QR = routes.QuoteResult<Op, Vp>;
|
|
16
13
|
type Q = routes.Quote<Op, Vp>;
|
|
17
14
|
type R = NttRoute.AutomaticTransferReceipt;
|
|
18
|
-
type Contracts = Ntt.Contracts & {
|
|
19
|
-
mLikeTokens: string[];
|
|
20
|
-
};
|
|
21
15
|
declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<N, Op, Vp, R> implements routes.StaticRouteMethods<typeof M0AutomaticRoute> {
|
|
22
16
|
static NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
|
|
23
|
-
static EVM_USDZ_TOKEN: string;
|
|
24
|
-
static EVM_WRAPPED_M_TOKEN: string;
|
|
25
17
|
static EXECUTOR_ENTRYPOINT: string;
|
|
26
|
-
static EVM_CONTRACTS: Contracts;
|
|
27
18
|
static meta: {
|
|
28
19
|
name: string;
|
|
29
20
|
provider: string;
|
|
@@ -31,12 +22,12 @@ declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<
|
|
|
31
22
|
static supportedNetworks(): Network[];
|
|
32
23
|
static isPlatformSupported(platform: string): boolean;
|
|
33
24
|
static supportedChains(network: Network): Chain[];
|
|
34
|
-
static getContracts(chainContext: ChainContext<Network>): Contracts;
|
|
25
|
+
static getContracts(chainContext: ChainContext<Network>): Ntt.Contracts;
|
|
35
26
|
static supportedSourceTokens(fromChain: ChainContext<Network>): Promise<TokenId[]>;
|
|
36
27
|
static supportedDestinationTokens<N extends Network>(token: TokenId, fromChain: ChainContext<N>, toChain: ChainContext<N>): Promise<TokenId[]>;
|
|
37
28
|
static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean;
|
|
38
29
|
getDefaultOptions(): Op;
|
|
39
|
-
isAvailable(
|
|
30
|
+
isAvailable(_: routes.RouteTransferRequest<N>): Promise<boolean>;
|
|
40
31
|
validate(request: routes.RouteTransferRequest<N>, params: Tp): Promise<Vr>;
|
|
41
32
|
quote(request: routes.RouteTransferRequest<N>, params: Vp): Promise<QR>;
|
|
42
33
|
initiate(request: routes.RouteTransferRequest<N>, signer: Signer, quote: Q, to: ChainAddress): Promise<R>;
|
|
@@ -44,44 +35,40 @@ declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<
|
|
|
44
35
|
* Modified from EvmNtt `transfer` function to call `transferMLikeToken` instead
|
|
45
36
|
* https://github.com/wormhole-foundation/native-token-transfers/blob/main/evm/ts/src/ntt.ts#L461
|
|
46
37
|
*/
|
|
47
|
-
transferMLike<N extends Network, C extends EvmChains>(
|
|
48
|
-
|
|
49
|
-
transferSolanaExtension<N extends Network, C extends SolanaChains>(ntt: SolanaNtt<N, C>, sender: AccountAddress<C>, amount: bigint, recipient: ChainAddress, sourceToken: string, destinationToken: string, options: Ntt.TransferOptions, outboxItem?: Keypair): AsyncGenerator<SolanaUnsignedTransaction<N, C>>;
|
|
38
|
+
transferMLike<N extends Network, C extends EvmChains>(ctx: ChainContext<Network>, sender: AccountAddress<C>, amount: bigint, destination: ChainAddress, sourceToken: string, destinationToken: string, options: Ntt.TransferOptions): AsyncGenerator<EvmUnsignedTransaction<N, C>>;
|
|
39
|
+
transferSolanaExtension<N extends Network, C extends SolanaChains>(ctx: ChainContext<Network>, sender: AccountAddress<C>, amount: bigint, recipient: ChainAddress, sourceToken: string, destinationToken: string): AsyncGenerator<SolanaUnsignedTransaction<N, C>>;
|
|
50
40
|
track(receipt: R, timeout?: number): AsyncGenerator<R, void, unknown>;
|
|
51
41
|
private getExecutorQuote;
|
|
52
|
-
private requiresExecutor;
|
|
53
42
|
}
|
|
54
43
|
|
|
55
|
-
type
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
type extensionToken = {
|
|
45
|
+
destinations: {
|
|
46
|
+
[chainId: number]: Set<string>;
|
|
47
|
+
};
|
|
48
|
+
extensionProgram: PublicKey;
|
|
58
49
|
tokenProgram: PublicKey;
|
|
50
|
+
mint: PublicKey;
|
|
59
51
|
};
|
|
60
|
-
declare class
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
private static
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
static
|
|
79
|
-
|
|
80
|
-
chain: Chain;
|
|
81
|
-
nttMessage: Ntt.Message;
|
|
82
|
-
recipient: PublicKey;
|
|
83
|
-
revertWhenNotReady: boolean;
|
|
84
|
-
}): Promise<TransactionInstruction[]>;
|
|
52
|
+
declare class SvmRouter {
|
|
53
|
+
connection: Connection;
|
|
54
|
+
chain: Chain;
|
|
55
|
+
network: Exclude<Network, "Devnet">;
|
|
56
|
+
private cachedLookupTable;
|
|
57
|
+
private tokens;
|
|
58
|
+
private static instance;
|
|
59
|
+
static evmPeer: string;
|
|
60
|
+
constructor(connection: Connection, chain: Chain, network: Exclude<Network, "Devnet">, cachedLookupTable?: AddressLookupTableAccount | null, tokens?: Record<string, extensionToken> | null);
|
|
61
|
+
static fromChainContext(ctx: ChainContext<Network>): Promise<SvmRouter>;
|
|
62
|
+
buildSendTokenInstruction(amount: bigint, sender: PublicKey, sourceToken: string, destinationToken: string, destinationChain: Chain, recipient: string): Promise<TransactionInstruction>;
|
|
63
|
+
getSupportedExtensions(): Promise<Record<string, extensionToken>>;
|
|
64
|
+
getSupportedSourceTokens(): Promise<TokenId[]>;
|
|
65
|
+
getSupportedDestinationTokens(sourceToken: string, toChain: Chain): Promise<TokenId[]>;
|
|
66
|
+
getAddressLookupTableAccounts(): Promise<AddressLookupTableAccount>;
|
|
67
|
+
buildExecutorRelayInstruction(sender: PublicKey, quote: NttWithExecutor.Quote, destinationChain: Chain): Promise<TransactionInstruction>;
|
|
68
|
+
private getRemainingAccounts;
|
|
69
|
+
static applyScaledUiMultiplier(connection: Connection, mint: PublicKey, amount: bigint): Promise<bigint>;
|
|
70
|
+
static hexToBytes32(hex: string): number[];
|
|
71
|
+
static bytes32toHex(bytes: number[]): string;
|
|
85
72
|
}
|
|
86
73
|
|
|
87
|
-
export { M0AutomaticRoute,
|
|
74
|
+
export { M0AutomaticRoute, SvmRouter as SolanaRouter };
|