@chainlink/ccip-sdk 0.95.0 → 0.97.0
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 +2 -2
- package/dist/all-chains.d.ts +23 -0
- package/dist/all-chains.d.ts.map +1 -0
- package/dist/all-chains.js +24 -0
- package/dist/all-chains.js.map +1 -0
- package/dist/api/index.d.ts +31 -19
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +46 -25
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +24 -30
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/exec.d.ts +2 -2
- package/dist/aptos/exec.d.ts.map +1 -1
- package/dist/aptos/exec.js.map +1 -1
- package/dist/aptos/hasher.d.ts.map +1 -1
- package/dist/aptos/hasher.js +1 -1
- package/dist/aptos/hasher.js.map +1 -1
- package/dist/aptos/index.d.ts +43 -15
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +112 -105
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/types.d.ts +2 -19
- package/dist/aptos/types.d.ts.map +1 -1
- package/dist/aptos/types.js +0 -11
- package/dist/aptos/types.js.map +1 -1
- package/dist/chain.d.ts +734 -174
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +216 -31
- package/dist/chain.js.map +1 -1
- package/dist/commits.d.ts +4 -6
- package/dist/commits.d.ts.map +1 -1
- package/dist/commits.js +4 -4
- package/dist/commits.js.map +1 -1
- package/dist/errors/CCIPError.d.ts +33 -4
- package/dist/errors/CCIPError.d.ts.map +1 -1
- package/dist/errors/CCIPError.js +33 -4
- package/dist/errors/CCIPError.js.map +1 -1
- package/dist/errors/codes.d.ts +5 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +5 -1
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +6 -1
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +1702 -121
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +1729 -125
- package/dist/errors/specialized.js.map +1 -1
- package/dist/errors/utils.d.ts.map +1 -1
- package/dist/errors/utils.js +0 -1
- package/dist/errors/utils.js.map +1 -1
- package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
- package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OffRamp_2_0.js +744 -0
- package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
- package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
- package/dist/evm/abi/OnRamp_2_0.js +992 -0
- package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
- package/dist/evm/const.d.ts +12 -2
- package/dist/evm/const.d.ts.map +1 -1
- package/dist/evm/const.js +8 -2
- package/dist/evm/const.js.map +1 -1
- package/dist/evm/errors.d.ts.map +1 -1
- package/dist/evm/errors.js +7 -2
- package/dist/evm/errors.js.map +1 -1
- package/dist/evm/extra-args.d.ts +25 -0
- package/dist/evm/extra-args.d.ts.map +1 -0
- package/dist/evm/extra-args.js +309 -0
- package/dist/evm/extra-args.js.map +1 -0
- package/dist/evm/gas.d.ts.map +1 -1
- package/dist/evm/gas.js +7 -12
- package/dist/evm/gas.js.map +1 -1
- package/dist/evm/hasher.d.ts.map +1 -1
- package/dist/evm/hasher.js +23 -13
- package/dist/evm/hasher.js.map +1 -1
- package/dist/evm/index.d.ts +140 -35
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +306 -226
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/messages.d.ts +59 -5
- package/dist/evm/messages.d.ts.map +1 -1
- package/dist/evm/messages.js +210 -0
- package/dist/evm/messages.js.map +1 -1
- package/dist/evm/offchain.js.map +1 -1
- package/dist/evm/types.d.ts +7 -2
- package/dist/evm/types.d.ts.map +1 -1
- package/dist/evm/types.js +22 -1
- package/dist/evm/types.js.map +1 -1
- package/dist/execution.d.ts +62 -22
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +102 -51
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +113 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +38 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +31 -5
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +43 -9
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/index.js.map +1 -1
- package/dist/requests.d.ts +101 -22
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +115 -24
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +24 -0
- package/dist/selectors.js.map +1 -1
- package/dist/shared/bcs-codecs.d.ts +61 -0
- package/dist/shared/bcs-codecs.d.ts.map +1 -0
- package/dist/shared/bcs-codecs.js +102 -0
- package/dist/shared/bcs-codecs.js.map +1 -0
- package/dist/shared/constants.d.ts +3 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +3 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/solana/exec.d.ts +2 -2
- package/dist/solana/exec.d.ts.map +1 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/index.d.ts +148 -30
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +137 -44
- package/dist/solana/index.js.map +1 -1
- package/dist/sui/hasher.d.ts.map +1 -1
- package/dist/sui/hasher.js +1 -1
- package/dist/sui/hasher.js.map +1 -1
- package/dist/sui/index.d.ts +49 -19
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +76 -43
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/manuallyExec/encoder.d.ts +2 -2
- package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
- package/dist/sui/manuallyExec/encoder.js.map +1 -1
- package/dist/sui/manuallyExec/index.d.ts +2 -2
- package/dist/sui/manuallyExec/index.d.ts.map +1 -1
- package/dist/ton/exec.d.ts +2 -2
- package/dist/ton/exec.d.ts.map +1 -1
- package/dist/ton/exec.js.map +1 -1
- package/dist/ton/index.d.ts +66 -27
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +172 -47
- package/dist/ton/index.js.map +1 -1
- package/dist/ton/send.d.ts +52 -0
- package/dist/ton/send.d.ts.map +1 -0
- package/dist/ton/send.js +166 -0
- package/dist/ton/send.js.map +1 -0
- package/dist/ton/types.d.ts +2 -2
- package/dist/ton/types.d.ts.map +1 -1
- package/dist/ton/types.js.map +1 -1
- package/dist/types.d.ts +148 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +79 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +92 -7
- package/dist/utils.js.map +1 -1
- package/package.json +16 -11
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +58 -34
- package/src/api/types.ts +24 -31
- package/src/aptos/exec.ts +2 -2
- package/src/aptos/hasher.ts +1 -1
- package/src/aptos/index.ts +127 -129
- package/src/aptos/types.ts +2 -15
- package/src/chain.ts +837 -191
- package/src/commits.ts +9 -9
- package/src/errors/CCIPError.ts +33 -4
- package/src/errors/codes.ts +5 -1
- package/src/errors/index.ts +2 -1
- package/src/errors/recovery.ts +9 -1
- package/src/errors/specialized.ts +1745 -132
- package/src/errors/utils.ts +0 -1
- package/src/evm/abi/OffRamp_2_0.ts +743 -0
- package/src/evm/abi/OnRamp_2_0.ts +991 -0
- package/src/evm/const.ts +10 -3
- package/src/evm/errors.ts +6 -2
- package/src/evm/extra-args.ts +360 -0
- package/src/evm/gas.ts +14 -13
- package/src/evm/hasher.ts +30 -18
- package/src/evm/index.ts +376 -281
- package/src/evm/messages.ts +323 -11
- package/src/evm/offchain.ts +2 -2
- package/src/evm/types.ts +20 -2
- package/src/execution.ts +126 -71
- package/src/extra-args.ts +118 -4
- package/src/gas.ts +44 -11
- package/src/index.ts +14 -11
- package/src/requests.ts +128 -24
- package/src/selectors.ts +24 -0
- package/src/shared/bcs-codecs.ts +132 -0
- package/src/shared/constants.ts +2 -0
- package/src/solana/exec.ts +4 -4
- package/src/solana/index.ts +170 -82
- package/src/sui/hasher.ts +1 -1
- package/src/sui/index.ts +88 -56
- package/src/sui/manuallyExec/encoder.ts +2 -2
- package/src/sui/manuallyExec/index.ts +2 -2
- package/src/ton/exec.ts +2 -2
- package/src/ton/index.ts +220 -58
- package/src/ton/send.ts +222 -0
- package/src/ton/types.ts +2 -2
- package/src/types.ts +173 -30
- package/src/utils.ts +91 -7
- package/dist/aptos/utils.d.ts +0 -12
- package/dist/aptos/utils.d.ts.map +0 -1
- package/dist/aptos/utils.js +0 -15
- package/dist/aptos/utils.js.map +0 -1
- package/src/aptos/utils.ts +0 -24
package/dist/ton/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/ton/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAe,EACf,
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/ton/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,WAAW,CAAA;AAGhD,OAAO,EAEL,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,YAAY,CAAA;AAEnB;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAe,EACf,UAAgD,EAChD,IAA4B;IAE5B,iCAAiC;IACjC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAA;IAE7D,0DAA0D;IAC1D,MAAM,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAE/D,gDAAgD;IAChD,MAAM,OAAO,GAAG,SAAS,EAAE;SACxB,SAAS,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC,qCAAqC;SAC5E,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,sBAAsB;SACvC,YAAY,CAAC,gBAAgB,CAAC,CAAC,cAAc;SAC7C,UAAU,CAAC,WAAW,CAAC,CAAC,0CAA0C;SAClE,OAAO,EAAE,CAAA;IAEZ,OAAO;QACL,EAAE,EAAE,OAAO;QACX,IAAI,EAAE,OAAO;KACd,CAAA;AACH,CAAC"}
|
package/dist/ton/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { type BytesLike } from 'ethers';
|
|
|
4
4
|
import type { PickDeep } from 'type-fest';
|
|
5
5
|
import { type ChainContext, type GetBalanceOpts, type LogFilter, Chain } from '../chain.ts';
|
|
6
6
|
import { type EVMExtraArgsV2, type ExtraArgs } from '../extra-args.ts';
|
|
7
|
+
import type { LeafHasher } from '../hasher/common.ts';
|
|
7
8
|
import { type CCIPExecution, type CCIPRequest, type ChainTransaction, type CommitReport, type ExecutionReceipt, type Lane, type Log_, type NetworkInfo, type OffchainTokenData, type WithLogger, ChainFamily } from '../types.ts';
|
|
8
9
|
import { type CCIPMessage_V1_6_TON, type UnsignedTONTx } from './types.ts';
|
|
9
|
-
import type { LeafHasher } from '../hasher/common.ts';
|
|
10
10
|
export type { TONWallet, UnsignedTONTx } from './types.ts';
|
|
11
11
|
/**
|
|
12
12
|
* TON chain implementation supporting TON networks.
|
|
@@ -46,6 +46,7 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
46
46
|
* @param url - RPC endpoint URL for TonClient (v2).
|
|
47
47
|
* @param ctx - Context containing logger.
|
|
48
48
|
* @returns A new TONChain instance.
|
|
49
|
+
* @throws {@link CCIPHttpError} if connection to the RPC endpoint fails
|
|
49
50
|
*/
|
|
50
51
|
static fromUrl(url: string, ctx?: ChainContext): Promise<TONChain>;
|
|
51
52
|
/**
|
|
@@ -57,6 +58,7 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
57
58
|
*
|
|
58
59
|
* @param block - Logical time (lt) as number, or 'finalized' for latest block timestamp
|
|
59
60
|
* @returns Unix timestamp in seconds
|
|
61
|
+
* @throws {@link CCIPNotImplementedError} if lt is not in cache
|
|
60
62
|
*/
|
|
61
63
|
getBlockTimestamp(block: number | 'finalized'): Promise<number>;
|
|
62
64
|
/**
|
|
@@ -72,6 +74,8 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
72
74
|
* @param tx - Transaction identifier in either format
|
|
73
75
|
* @returns ChainTransaction with transaction details
|
|
74
76
|
* Note: `blockNumber` contains logical time (lt), not block seqno
|
|
77
|
+
* @throws {@link CCIPArgumentInvalidError} if hash format is invalid
|
|
78
|
+
* @throws {@link CCIPTransactionNotFoundError} if transaction not found
|
|
75
79
|
*/
|
|
76
80
|
getTransaction(tx: string | Transaction): Promise<ChainTransaction>;
|
|
77
81
|
/**
|
|
@@ -81,38 +85,50 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
81
85
|
* not block sequence numbers. This is because TON transaction APIs are indexed by lt.
|
|
82
86
|
*
|
|
83
87
|
* @param opts - Log filter options (startBlock/endBlock are interpreted as lt values)
|
|
88
|
+
* @throws {@link CCIPTopicsInvalidError} if topics format is invalid
|
|
84
89
|
*/
|
|
85
90
|
getLogs(opts: LogFilter): AsyncIterableIterator<Log_>;
|
|
86
91
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
87
|
-
getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(
|
|
88
|
-
page?: number;
|
|
89
|
-
}): Promise<R['message'][]>;
|
|
92
|
+
getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: Pick<LogFilter, 'page'>): Promise<R['message'][]>;
|
|
90
93
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
91
94
|
typeAndVersion(address: string): Promise<[type: string, version: string, typeAndVersion: string, suffix?: string | undefined]>;
|
|
92
95
|
/** {@inheritDoc Chain.getRouterForOnRamp} */
|
|
93
96
|
getRouterForOnRamp(onRamp: string, destChainSelector: bigint): Promise<string>;
|
|
94
97
|
/** {@inheritDoc Chain.getRouterForOffRamp} */
|
|
95
98
|
getRouterForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
|
|
96
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* {@inheritDoc Chain.getNativeTokenForRouter}
|
|
101
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
102
|
+
*/
|
|
97
103
|
getNativeTokenForRouter(_router: string): Promise<string>;
|
|
98
104
|
/** {@inheritDoc Chain.getOffRampsForRouter} */
|
|
99
105
|
getOffRampsForRouter(router: string, sourceChainSelector: bigint): Promise<string[]>;
|
|
100
106
|
/** {@inheritDoc Chain.getOnRampForRouter} */
|
|
101
107
|
getOnRampForRouter(router: string, destChainSelector: bigint): Promise<string>;
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
/**
|
|
109
|
+
* {@inheritDoc Chain.getOnRampsForOffRamp}
|
|
110
|
+
* @throws {@link CCIPSourceChainUnsupportedError} if source chain is not configured
|
|
111
|
+
*/
|
|
112
|
+
getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]>;
|
|
113
|
+
/**
|
|
114
|
+
* {@inheritDoc Chain.getTokenForTokenPool}
|
|
115
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
116
|
+
*/
|
|
107
117
|
getTokenForTokenPool(_tokenPool: string): Promise<string>;
|
|
108
118
|
/** {@inheritDoc Chain.getTokenInfo} */
|
|
109
119
|
getTokenInfo(token: string): Promise<{
|
|
110
120
|
symbol: string;
|
|
111
121
|
decimals: number;
|
|
112
122
|
}>;
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
|
|
123
|
+
/**
|
|
124
|
+
* {@inheritDoc Chain.getBalance}
|
|
125
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
126
|
+
*/
|
|
127
|
+
getBalance(opts: GetBalanceOpts): Promise<bigint>;
|
|
128
|
+
/**
|
|
129
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
130
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
131
|
+
*/
|
|
116
132
|
getTokenAdminRegistryFor(_address: string): Promise<string>;
|
|
117
133
|
/**
|
|
118
134
|
* Decodes a CCIP message from a TON log event.
|
|
@@ -167,7 +183,7 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
167
183
|
* - sourceChainSelector: uint64 (8 bytes)
|
|
168
184
|
* - sequenceNumber: uint64 (8 bytes)
|
|
169
185
|
* - messageId: uint256 (32 bytes)
|
|
170
|
-
* - state: uint8 (1 byte) -
|
|
186
|
+
* - state: uint8 (1 byte) - InProgress=1, Success=2, Failed=3
|
|
171
187
|
*
|
|
172
188
|
* @param log - Log with data field (base64-encoded BOC).
|
|
173
189
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
@@ -186,6 +202,7 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
186
202
|
* and raw format strings ("workchain:hash").
|
|
187
203
|
* @param bytes - Bytes or string to convert.
|
|
188
204
|
* @returns TON raw address string in format "workchain:hash".
|
|
205
|
+
* @throws {@link CCIPArgumentInvalidError} if bytes length is invalid
|
|
189
206
|
*/
|
|
190
207
|
static getAddress(bytes: BytesLike): string;
|
|
191
208
|
/**
|
|
@@ -217,17 +234,24 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
217
234
|
*/
|
|
218
235
|
static getDestLeafHasher(lane: Lane, _ctx?: WithLogger): LeafHasher;
|
|
219
236
|
/** {@inheritDoc Chain.getFee} */
|
|
220
|
-
getFee(
|
|
237
|
+
getFee({ router, destChainSelector, message, }: Parameters<Chain['getFee']>[0]): Promise<bigint>;
|
|
221
238
|
/** {@inheritDoc Chain.generateUnsignedSendMessage} */
|
|
222
|
-
generateUnsignedSendMessage(
|
|
239
|
+
generateUnsignedSendMessage({ router, destChainSelector, message, sender, }: Parameters<Chain['generateUnsignedSendMessage']>[0]): Promise<UnsignedTONTx>;
|
|
223
240
|
/** {@inheritDoc Chain.sendMessage} */
|
|
224
|
-
sendMessage(
|
|
241
|
+
sendMessage({ router, destChainSelector, message, wallet, }: Parameters<Chain['sendMessage']>[0]): Promise<CCIPRequest>;
|
|
225
242
|
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
226
243
|
getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
244
|
+
/**
|
|
245
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
246
|
+
* @throws {@link CCIPExtraArgsInvalidError} if extra args are not EVMExtraArgsV2 format
|
|
247
|
+
*/
|
|
248
|
+
generateUnsignedExecute(opts: Parameters<Chain['generateUnsignedExecute']>[0]): Promise<UnsignedTONTx>;
|
|
249
|
+
/**
|
|
250
|
+
* {@inheritDoc Chain.execute}
|
|
251
|
+
* @throws {@link CCIPWalletInvalidError} if wallet is not a valid TON wallet
|
|
252
|
+
* @throws {@link CCIPReceiptNotFoundError} if execution receipt not found within timeout
|
|
253
|
+
*/
|
|
254
|
+
execute(opts: Parameters<Chain['execute']>[0]): Promise<CCIPExecution>;
|
|
231
255
|
/**
|
|
232
256
|
* Parses raw TON data into typed structures.
|
|
233
257
|
* @param data - Raw data to parse.
|
|
@@ -238,15 +262,30 @@ export declare class TONChain extends Chain<typeof ChainFamily.TON> {
|
|
|
238
262
|
} & {
|
|
239
263
|
_tag: "EVMExtraArgsV2";
|
|
240
264
|
}) | undefined;
|
|
241
|
-
/**
|
|
265
|
+
/**
|
|
266
|
+
* {@inheritDoc Chain.getSupportedTokens}
|
|
267
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
268
|
+
*/
|
|
242
269
|
getSupportedTokens(_address: string): Promise<string[]>;
|
|
243
|
-
/**
|
|
270
|
+
/**
|
|
271
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
272
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
273
|
+
*/
|
|
244
274
|
getRegistryTokenConfig(_address: string, _tokenName: string): Promise<never>;
|
|
245
|
-
/**
|
|
246
|
-
|
|
247
|
-
|
|
275
|
+
/**
|
|
276
|
+
* {@inheritDoc Chain.getTokenPoolConfig}
|
|
277
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
278
|
+
*/
|
|
279
|
+
getTokenPoolConfig(_tokenPool: string): Promise<never>;
|
|
280
|
+
/**
|
|
281
|
+
* {@inheritDoc Chain.getTokenPoolRemotes}
|
|
282
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
283
|
+
*/
|
|
248
284
|
getTokenPoolRemotes(_tokenPool: string): Promise<never>;
|
|
249
|
-
/**
|
|
285
|
+
/**
|
|
286
|
+
* {@inheritDoc Chain.getFeeTokens}
|
|
287
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
288
|
+
*/
|
|
250
289
|
getFeeTokens(_router: string): Promise<never>;
|
|
251
290
|
}
|
|
252
291
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ton/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ton/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAoC,MAAM,WAAW,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,OAAO,EAAE,KAAK,SAAS,EAAyD,MAAM,QAAQ,CAAA;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ton/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAoC,MAAM,WAAW,CAAA;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,OAAO,EAAE,KAAK,SAAS,EAAyD,MAAM,QAAQ,CAAA;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAIzC,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAa3F,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAqB,MAAM,kBAAkB,CAAA;AACzF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAGrD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAEjB,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,UAAU,EAEf,WAAW,EAEZ,MAAM,aAAa,CAAA;AAWpB,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,aAAa,EAAe,MAAM,YAAY,CAAA;AAEv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BAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIlF;;;OAGG;IACG,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAI5D;;;OAGG;IACG,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAI7D;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;CAGpD"}
|
package/dist/ton/index.js
CHANGED
|
@@ -5,13 +5,15 @@ import { getAdapter } from 'axios';
|
|
|
5
5
|
import { hexlify, isBytesLike, isHexString, toBeArray, toBeHex } from 'ethers';
|
|
6
6
|
import { memoize } from 'micro-memoize';
|
|
7
7
|
import { streamTransactionsForAddress } from "./logs.js";
|
|
8
|
+
import { generateUnsignedCcipSend, getFee as getFeeImpl } from "./send.js";
|
|
8
9
|
import { Chain } from "../chain.js";
|
|
9
|
-
import { CCIPArgumentInvalidError, CCIPExtraArgsInvalidError, CCIPHttpError, CCIPNotImplementedError, CCIPReceiptNotFoundError, CCIPSourceChainUnsupportedError, CCIPTopicsInvalidError, CCIPTransactionNotFoundError, CCIPWalletInvalidError, } from "../errors/
|
|
10
|
+
import { CCIPArgumentInvalidError, CCIPExecutionReportChainMismatchError, CCIPExtraArgsInvalidError, CCIPHttpError, CCIPNotImplementedError, CCIPReceiptNotFoundError, CCIPSourceChainUnsupportedError, CCIPTopicsInvalidError, CCIPTransactionNotFoundError, CCIPWalletInvalidError, } from "../errors/index.js";
|
|
10
11
|
import { EVMExtraArgsV2Tag } from "../extra-args.js";
|
|
12
|
+
import { buildMessageForDest, getMessagesInBatch } from "../requests.js";
|
|
11
13
|
import { supportedChains } from "../supported-chains.js";
|
|
12
|
-
import { ChainFamily, ExecutionState, } from "../types.js";
|
|
14
|
+
import { CCIPVersion, ChainFamily, ExecutionState, } from "../types.js";
|
|
13
15
|
import { bytesToBuffer, createRateLimitedFetch, decodeAddress, networkInfo, parseTypeAndVersion, sleep, } from "../utils.js";
|
|
14
|
-
import { generateUnsignedExecuteReport
|
|
16
|
+
import { generateUnsignedExecuteReport } from "./exec.js";
|
|
15
17
|
import { getTONLeafHasher } from "./hasher.js";
|
|
16
18
|
import { isTONWallet } from "./types.js";
|
|
17
19
|
import { crc32, lookupTxByRawHash, parseJettonContent } from "./utils.js";
|
|
@@ -122,6 +124,7 @@ export class TONChain extends Chain {
|
|
|
122
124
|
* @param url - RPC endpoint URL for TonClient (v2).
|
|
123
125
|
* @param ctx - Context containing logger.
|
|
124
126
|
* @returns A new TONChain instance.
|
|
127
|
+
* @throws {@link CCIPHttpError} if connection to the RPC endpoint fails
|
|
125
128
|
*/
|
|
126
129
|
static async fromUrl(url, ctx) {
|
|
127
130
|
const { logger = console } = ctx ?? {};
|
|
@@ -159,6 +162,7 @@ export class TONChain extends Chain {
|
|
|
159
162
|
*
|
|
160
163
|
* @param block - Logical time (lt) as number, or 'finalized' for latest block timestamp
|
|
161
164
|
* @returns Unix timestamp in seconds
|
|
165
|
+
* @throws {@link CCIPNotImplementedError} if lt is not in cache
|
|
162
166
|
*/
|
|
163
167
|
async getBlockTimestamp(block) {
|
|
164
168
|
if (typeof block != 'number') {
|
|
@@ -182,6 +186,8 @@ export class TONChain extends Chain {
|
|
|
182
186
|
* @param tx - Transaction identifier in either format
|
|
183
187
|
* @returns ChainTransaction with transaction details
|
|
184
188
|
* Note: `blockNumber` contains logical time (lt), not block seqno
|
|
189
|
+
* @throws {@link CCIPArgumentInvalidError} if hash format is invalid
|
|
190
|
+
* @throws {@link CCIPTransactionNotFoundError} if transaction not found
|
|
185
191
|
*/
|
|
186
192
|
async getTransaction(tx) {
|
|
187
193
|
let address;
|
|
@@ -258,6 +264,7 @@ export class TONChain extends Chain {
|
|
|
258
264
|
* not block sequence numbers. This is because TON transaction APIs are indexed by lt.
|
|
259
265
|
*
|
|
260
266
|
* @param opts - Log filter options (startBlock/endBlock are interpreted as lt values)
|
|
267
|
+
* @throws {@link CCIPTopicsInvalidError} if topics format is invalid
|
|
261
268
|
*/
|
|
262
269
|
async *getLogs(opts) {
|
|
263
270
|
let topics;
|
|
@@ -280,8 +287,8 @@ export class TONChain extends Chain {
|
|
|
280
287
|
}
|
|
281
288
|
}
|
|
282
289
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
283
|
-
async getMessagesInBatch(
|
|
284
|
-
return
|
|
290
|
+
async getMessagesInBatch(request, range, opts) {
|
|
291
|
+
return getMessagesInBatch(this, request, range, opts);
|
|
285
292
|
}
|
|
286
293
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
287
294
|
async typeAndVersion(address) {
|
|
@@ -314,9 +321,14 @@ export class TONChain extends Chain {
|
|
|
314
321
|
]);
|
|
315
322
|
return stack.readAddress().toRawString();
|
|
316
323
|
}
|
|
317
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* {@inheritDoc Chain.getNativeTokenForRouter}
|
|
326
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
327
|
+
*/
|
|
318
328
|
getNativeTokenForRouter(_router) {
|
|
319
|
-
|
|
329
|
+
// TON native token is represented as address 0:0...01 (workchain 0, hash = 1)
|
|
330
|
+
// This is a convention for representing native TON in CCIP
|
|
331
|
+
return Promise.resolve('0:0000000000000000000000000000000000000000000000000000000000000001');
|
|
320
332
|
}
|
|
321
333
|
/** {@inheritDoc Chain.getOffRampsForRouter} */
|
|
322
334
|
async getOffRampsForRouter(router, sourceChainSelector) {
|
|
@@ -336,8 +348,11 @@ export class TONChain extends Chain {
|
|
|
336
348
|
]);
|
|
337
349
|
return stack.readAddress().toRawString();
|
|
338
350
|
}
|
|
339
|
-
/**
|
|
340
|
-
|
|
351
|
+
/**
|
|
352
|
+
* {@inheritDoc Chain.getOnRampsForOffRamp}
|
|
353
|
+
* @throws {@link CCIPSourceChainUnsupportedError} if source chain is not configured
|
|
354
|
+
*/
|
|
355
|
+
async getOnRampsForOffRamp(offRamp, sourceChainSelector) {
|
|
341
356
|
try {
|
|
342
357
|
const offRampContract = this.provider.provider(Address.parse(offRamp));
|
|
343
358
|
const { stack } = await offRampContract.get('sourceChainConfig', [
|
|
@@ -362,7 +377,7 @@ export class TONChain extends Chain {
|
|
|
362
377
|
const onRampLength = onRampSlice.loadUint(8);
|
|
363
378
|
onRamp = onRampSlice.loadBuffer(onRampLength);
|
|
364
379
|
}
|
|
365
|
-
return decodeAddress(onRamp, networkInfo(sourceChainSelector).family);
|
|
380
|
+
return [decodeAddress(onRamp, networkInfo(sourceChainSelector).family)];
|
|
366
381
|
}
|
|
367
382
|
catch (error) {
|
|
368
383
|
if (isTvmError(error) && error.exitCode === 266) {
|
|
@@ -373,12 +388,10 @@ export class TONChain extends Chain {
|
|
|
373
388
|
throw error;
|
|
374
389
|
}
|
|
375
390
|
}
|
|
376
|
-
/**
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
381
|
-
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
391
|
+
/**
|
|
392
|
+
* {@inheritDoc Chain.getTokenForTokenPool}
|
|
393
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
394
|
+
*/
|
|
382
395
|
async getTokenForTokenPool(_tokenPool) {
|
|
383
396
|
return Promise.reject(new CCIPNotImplementedError('getTokenForTokenPool'));
|
|
384
397
|
}
|
|
@@ -402,11 +415,39 @@ export class TONChain extends Chain {
|
|
|
402
415
|
return { symbol: '', decimals: this.constructor.decimals };
|
|
403
416
|
}
|
|
404
417
|
}
|
|
405
|
-
/**
|
|
406
|
-
|
|
407
|
-
|
|
418
|
+
/**
|
|
419
|
+
* {@inheritDoc Chain.getBalance}
|
|
420
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
421
|
+
*/
|
|
422
|
+
async getBalance(opts) {
|
|
423
|
+
const { holder, token } = opts;
|
|
424
|
+
const holderAddress = Address.parse(holder);
|
|
425
|
+
if (!token) {
|
|
426
|
+
// Get native TON balance
|
|
427
|
+
const state = await this.provider.getContractState(holderAddress);
|
|
428
|
+
return state.balance;
|
|
429
|
+
}
|
|
430
|
+
// For jetton balance, we need to:
|
|
431
|
+
// 1. Derive the jetton wallet address for this holder
|
|
432
|
+
// 2. Query the balance from that wallet contract
|
|
433
|
+
const jettonMaster = Address.parse(token);
|
|
434
|
+
const { stack } = await this.provider.runMethod(jettonMaster, 'get_wallet_address', [
|
|
435
|
+
{ type: 'slice', cell: beginCell().storeAddress(holderAddress).endCell() },
|
|
436
|
+
]);
|
|
437
|
+
const jettonWalletAddress = stack.readAddress();
|
|
438
|
+
try {
|
|
439
|
+
const { stack: balanceStack } = await this.provider.runMethod(jettonWalletAddress, 'get_wallet_data');
|
|
440
|
+
return balanceStack.readBigNumber(); // First value is balance
|
|
441
|
+
}
|
|
442
|
+
catch {
|
|
443
|
+
// Wallet doesn't exist yet = 0 balance
|
|
444
|
+
return 0n;
|
|
445
|
+
}
|
|
408
446
|
}
|
|
409
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
449
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
450
|
+
*/
|
|
410
451
|
getTokenAdminRegistryFor(_address) {
|
|
411
452
|
return Promise.reject(new CCIPNotImplementedError('getTokenAdminRegistryFor'));
|
|
412
453
|
}
|
|
@@ -436,7 +477,7 @@ export class TONChain extends Chain {
|
|
|
436
477
|
nonce: slice.loadUintBig(64),
|
|
437
478
|
};
|
|
438
479
|
// Load sender address
|
|
439
|
-
const sender = slice.loadAddress().
|
|
480
|
+
const sender = slice.loadAddress().toRawString();
|
|
440
481
|
// Load body cell ref
|
|
441
482
|
const bodyCell = slice.loadRef();
|
|
442
483
|
// Load feeValueJuels (96 bits) at message level, after body ref
|
|
@@ -474,10 +515,7 @@ export class TONChain extends Chain {
|
|
|
474
515
|
// Read allowOutOfOrderExecution (1 bit)
|
|
475
516
|
const allowOutOfOrderExecution = extraArgsSlice.loadBit();
|
|
476
517
|
// Build extraArgs as raw hex matching reference format
|
|
477
|
-
const
|
|
478
|
-
const gasLimitHex = (hasGasLimit ? '8' : '0') + gasLimit.toString(16).padStart(63, '0');
|
|
479
|
-
const oooByte = allowOutOfOrderExecution ? '40' : '00';
|
|
480
|
-
const extraArgs = '0x' + tagHex + gasLimitHex + oooByte;
|
|
518
|
+
const extraArgs = '0x' + extraArgsCell.toBoc().toString('hex');
|
|
481
519
|
// Load tokenAmounts from ref 3
|
|
482
520
|
const _tokenAmountsCell = bodySlice.loadRef();
|
|
483
521
|
const tokenAmounts = []; // TODO: FIXME: parse when implemented
|
|
@@ -623,7 +661,7 @@ export class TONChain extends Chain {
|
|
|
623
661
|
* - sourceChainSelector: uint64 (8 bytes)
|
|
624
662
|
* - sequenceNumber: uint64 (8 bytes)
|
|
625
663
|
* - messageId: uint256 (32 bytes)
|
|
626
|
-
* - state: uint8 (1 byte) -
|
|
664
|
+
* - state: uint8 (1 byte) - InProgress=1, Success=2, Failed=3
|
|
627
665
|
*
|
|
628
666
|
* @param log - Log with data field (base64-encoded BOC).
|
|
629
667
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
@@ -671,6 +709,7 @@ export class TONChain extends Chain {
|
|
|
671
709
|
* and raw format strings ("workchain:hash").
|
|
672
710
|
* @param bytes - Bytes or string to convert.
|
|
673
711
|
* @returns TON raw address string in format "workchain:hash".
|
|
712
|
+
* @throws {@link CCIPArgumentInvalidError} if bytes length is invalid
|
|
674
713
|
*/
|
|
675
714
|
static getAddress(bytes) {
|
|
676
715
|
// If it's already a string address, try to parse and return raw format
|
|
@@ -785,40 +824,111 @@ export class TONChain extends Chain {
|
|
|
785
824
|
return getTONLeafHasher(lane);
|
|
786
825
|
}
|
|
787
826
|
/** {@inheritDoc Chain.getFee} */
|
|
788
|
-
async getFee(
|
|
789
|
-
return
|
|
827
|
+
async getFee({ router, destChainSelector, message, }) {
|
|
828
|
+
return getFeeImpl(this, router, destChainSelector, buildMessageForDest(message, networkInfo(destChainSelector).family));
|
|
790
829
|
}
|
|
791
830
|
/** {@inheritDoc Chain.generateUnsignedSendMessage} */
|
|
792
|
-
generateUnsignedSendMessage(
|
|
793
|
-
|
|
831
|
+
async generateUnsignedSendMessage({ router, destChainSelector, message, sender, }) {
|
|
832
|
+
// Convert MessageInput to AnyMessage with defaults
|
|
833
|
+
const populatedMessage = buildMessageForDest(message, networkInfo(destChainSelector).family);
|
|
834
|
+
// Calculate fee if not provided
|
|
835
|
+
const fee = message.fee ??
|
|
836
|
+
(await this.getFee({
|
|
837
|
+
router,
|
|
838
|
+
destChainSelector,
|
|
839
|
+
message: populatedMessage,
|
|
840
|
+
}));
|
|
841
|
+
const unsigned = generateUnsignedCcipSend(this, sender, router, destChainSelector, {
|
|
842
|
+
...populatedMessage,
|
|
843
|
+
fee,
|
|
844
|
+
});
|
|
845
|
+
return {
|
|
846
|
+
family: ChainFamily.TON,
|
|
847
|
+
...unsigned,
|
|
848
|
+
};
|
|
794
849
|
}
|
|
795
850
|
/** {@inheritDoc Chain.sendMessage} */
|
|
796
|
-
async sendMessage(
|
|
797
|
-
|
|
851
|
+
async sendMessage({ router, destChainSelector, message, wallet, }) {
|
|
852
|
+
if (!isTONWallet(wallet)) {
|
|
853
|
+
throw new CCIPWalletInvalidError(wallet);
|
|
854
|
+
}
|
|
855
|
+
const sender = await wallet.getAddress();
|
|
856
|
+
// Generate unsigned transaction with fee calculation if needed
|
|
857
|
+
const { family: _, ...unsigned } = await this.generateUnsignedSendMessage({
|
|
858
|
+
router,
|
|
859
|
+
destChainSelector,
|
|
860
|
+
message,
|
|
861
|
+
sender,
|
|
862
|
+
});
|
|
863
|
+
// Send transaction
|
|
864
|
+
const startTime = Math.floor(Date.now() / 1000);
|
|
865
|
+
const seqno = await wallet.sendTransaction(unsigned);
|
|
866
|
+
this.logger.info('CCIP send transaction submitted, seqno:', seqno);
|
|
867
|
+
// Wait for CCIPMessageSent event and extract the request
|
|
868
|
+
// Query the OnRamp for the CCIPMessageSent event
|
|
869
|
+
const onRamp = await this.getOnRampForRouter(router, destChainSelector);
|
|
870
|
+
// Poll for the message in recent logs
|
|
871
|
+
for await (const log of this.getLogs({
|
|
872
|
+
address: onRamp,
|
|
873
|
+
topics: [crc32('CCIPMessageSent')],
|
|
874
|
+
startTime,
|
|
875
|
+
watch: sleep(5 * 60e3 /* 5m timeout */),
|
|
876
|
+
})) {
|
|
877
|
+
const msg = TONChain.decodeMessage(log);
|
|
878
|
+
if (!msg)
|
|
879
|
+
continue;
|
|
880
|
+
// Found our message: construct and return the CCIPRequest
|
|
881
|
+
const tx = log.tx ?? (await this.getTransaction(log.transactionHash));
|
|
882
|
+
return {
|
|
883
|
+
lane: {
|
|
884
|
+
sourceChainSelector: this.network.chainSelector,
|
|
885
|
+
destChainSelector,
|
|
886
|
+
onRamp,
|
|
887
|
+
version: CCIPVersion.V1_6,
|
|
888
|
+
},
|
|
889
|
+
message: msg,
|
|
890
|
+
log,
|
|
891
|
+
tx,
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
throw new CCIPTransactionNotFoundError(seqno.toString());
|
|
798
895
|
}
|
|
799
896
|
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
800
897
|
getOffchainTokenData(request) {
|
|
801
898
|
return Promise.resolve(request.message.tokenAmounts.map(() => undefined));
|
|
802
899
|
}
|
|
803
|
-
/**
|
|
804
|
-
|
|
805
|
-
|
|
900
|
+
/**
|
|
901
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
902
|
+
* @throws {@link CCIPExtraArgsInvalidError} if extra args are not EVMExtraArgsV2 format
|
|
903
|
+
*/
|
|
904
|
+
generateUnsignedExecute(opts) {
|
|
905
|
+
if (!('input' in opts &&
|
|
906
|
+
'message' in opts.input &&
|
|
907
|
+
'allowOutOfOrderExecution' in opts.input.message &&
|
|
908
|
+
'gasLimit' in opts.input.message)) {
|
|
806
909
|
throw new CCIPExtraArgsInvalidError('TON');
|
|
807
910
|
}
|
|
808
|
-
const
|
|
911
|
+
const { offRamp, input } = opts;
|
|
912
|
+
const unsigned = generateUnsignedExecuteReport(offRamp, input, opts);
|
|
809
913
|
return Promise.resolve({
|
|
810
914
|
family: ChainFamily.TON,
|
|
811
915
|
...unsigned,
|
|
812
916
|
});
|
|
813
917
|
}
|
|
814
|
-
/**
|
|
815
|
-
|
|
918
|
+
/**
|
|
919
|
+
* {@inheritDoc Chain.execute}
|
|
920
|
+
* @throws {@link CCIPWalletInvalidError} if wallet is not a valid TON wallet
|
|
921
|
+
* @throws {@link CCIPReceiptNotFoundError} if execution receipt not found within timeout
|
|
922
|
+
*/
|
|
923
|
+
async execute(opts) {
|
|
924
|
+
if (!('input' in opts && 'message' in opts.input))
|
|
925
|
+
throw new CCIPExecutionReportChainMismatchError('TON');
|
|
816
926
|
const { offRamp, wallet } = opts;
|
|
817
927
|
if (!isTONWallet(wallet)) {
|
|
818
928
|
throw new CCIPWalletInvalidError(wallet);
|
|
819
929
|
}
|
|
820
930
|
const payer = await wallet.getAddress();
|
|
821
|
-
const { family: _, ...unsigned } = await this.
|
|
931
|
+
const { family: _, ...unsigned } = await this.generateUnsignedExecute({
|
|
822
932
|
...opts,
|
|
823
933
|
payer,
|
|
824
934
|
});
|
|
@@ -828,7 +938,7 @@ export class TONChain extends Chain {
|
|
|
828
938
|
value: toNano('0.3'),
|
|
829
939
|
...unsigned,
|
|
830
940
|
});
|
|
831
|
-
const message = opts.
|
|
941
|
+
const message = opts.input.message;
|
|
832
942
|
for await (const exec of this.getExecutionReceipts({
|
|
833
943
|
offRamp,
|
|
834
944
|
messageId: message.messageId,
|
|
@@ -852,23 +962,38 @@ export class TONChain extends Chain {
|
|
|
852
962
|
return parsedExtraArgs;
|
|
853
963
|
}
|
|
854
964
|
}
|
|
855
|
-
/**
|
|
965
|
+
/**
|
|
966
|
+
* {@inheritDoc Chain.getSupportedTokens}
|
|
967
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
968
|
+
*/
|
|
856
969
|
async getSupportedTokens(_address) {
|
|
857
970
|
return Promise.reject(new CCIPNotImplementedError('getSupportedTokens'));
|
|
858
971
|
}
|
|
859
|
-
/**
|
|
972
|
+
/**
|
|
973
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
974
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
975
|
+
*/
|
|
860
976
|
async getRegistryTokenConfig(_address, _tokenName) {
|
|
861
977
|
return Promise.reject(new CCIPNotImplementedError('getRegistryTokenConfig'));
|
|
862
978
|
}
|
|
863
|
-
/**
|
|
864
|
-
|
|
865
|
-
|
|
979
|
+
/**
|
|
980
|
+
* {@inheritDoc Chain.getTokenPoolConfig}
|
|
981
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
982
|
+
*/
|
|
983
|
+
async getTokenPoolConfig(_tokenPool) {
|
|
984
|
+
return Promise.reject(new CCIPNotImplementedError('getTokenPoolConfig'));
|
|
866
985
|
}
|
|
867
|
-
/**
|
|
986
|
+
/**
|
|
987
|
+
* {@inheritDoc Chain.getTokenPoolRemotes}
|
|
988
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
989
|
+
*/
|
|
868
990
|
async getTokenPoolRemotes(_tokenPool) {
|
|
869
991
|
return Promise.reject(new CCIPNotImplementedError('getTokenPoolRemotes'));
|
|
870
992
|
}
|
|
871
|
-
/**
|
|
993
|
+
/**
|
|
994
|
+
* {@inheritDoc Chain.getFeeTokens}
|
|
995
|
+
* @throws {@link CCIPNotImplementedError} always (not implemented for TON)
|
|
996
|
+
*/
|
|
872
997
|
async getFeeTokens(_router) {
|
|
873
998
|
return Promise.reject(new CCIPNotImplementedError('getFeeTokens'));
|
|
874
999
|
}
|