@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/aptos/index.d.ts
CHANGED
|
@@ -11,11 +11,16 @@ export type { UnsignedAptosTx };
|
|
|
11
11
|
* Aptos chain implementation supporting Aptos networks.
|
|
12
12
|
*/
|
|
13
13
|
export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
14
|
+
/** Chain family identifier for Aptos networks. */
|
|
14
15
|
static readonly family: "APTOS";
|
|
16
|
+
/** Native token decimals (8 for APT). */
|
|
15
17
|
static readonly decimals = 8;
|
|
16
18
|
readonly destroy$: Promise<void>;
|
|
19
|
+
/** The Aptos SDK provider for blockchain interactions. */
|
|
17
20
|
provider: Aptos;
|
|
21
|
+
/** Retrieves token information for a given token address. */
|
|
18
22
|
getTokenInfo: (token: string) => Promise<TokenInfo>;
|
|
23
|
+
/** @internal */
|
|
19
24
|
_getAccountModulesNames: (address: string) => Promise<string[]>;
|
|
20
25
|
/**
|
|
21
26
|
* Creates a new AptosChain instance.
|
|
@@ -42,18 +47,23 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
42
47
|
* @param url - RPC URL, Aptos Network enum value or [fullNodeUrl, Network] tuple.
|
|
43
48
|
* @param ctx - context containing logger
|
|
44
49
|
* @returns A new AptosChain instance.
|
|
50
|
+
* @throws {@link CCIPAptosNetworkUnknownError} if network cannot be determined from URL
|
|
45
51
|
*/
|
|
46
52
|
static fromUrl(url: string | Network | readonly [string, Network], ctx?: ChainContext): Promise<AptosChain>;
|
|
47
53
|
/** {@inheritDoc Chain.getBlockTimestamp} */
|
|
48
54
|
getBlockTimestamp(version: number | 'finalized'): Promise<number>;
|
|
49
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritDoc Chain.getTransaction}
|
|
57
|
+
* @throws {@link CCIPAptosTransactionInvalidError} if hash/version format is invalid
|
|
58
|
+
* @throws {@link CCIPAptosTransactionTypeInvalidError} if transaction is not a user transaction
|
|
59
|
+
*/
|
|
50
60
|
getTransaction(hashOrVersion: string | number): Promise<ChainTransaction>;
|
|
51
61
|
/** {@inheritDoc Chain.getLogs} */
|
|
52
62
|
getLogs(opts: LogFilter & {
|
|
53
63
|
versionAsHash?: boolean;
|
|
54
64
|
}): AsyncIterableIterator<Log_>;
|
|
55
65
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
56
|
-
getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R,
|
|
66
|
+
getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
|
|
57
67
|
page?: number;
|
|
58
68
|
}): Promise<R['message'][]>;
|
|
59
69
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
@@ -68,20 +78,22 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
68
78
|
getOffRampsForRouter(router: string, _sourceChainSelector: bigint): Promise<string[]>;
|
|
69
79
|
/** {@inheritDoc Chain.getOnRampForRouter} */
|
|
70
80
|
getOnRampForRouter(router: string, _destChainSelector: bigint): Promise<string>;
|
|
71
|
-
/** {@inheritDoc Chain.
|
|
72
|
-
|
|
73
|
-
/** {@inheritDoc Chain.getCommitStoreForOffRamp} */
|
|
74
|
-
getCommitStoreForOffRamp(offRamp: string): Promise<string>;
|
|
81
|
+
/** {@inheritDoc Chain.getOnRampsForOffRamp} */
|
|
82
|
+
getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]>;
|
|
75
83
|
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
76
84
|
getTokenForTokenPool(tokenPool: string): Promise<string>;
|
|
77
85
|
/** {@inheritDoc Chain.getBalance} */
|
|
78
86
|
getBalance(opts: GetBalanceOpts): Promise<bigint>;
|
|
79
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
89
|
+
* @throws {@link CCIPAptosRegistryTypeInvalidError} if registry type is invalid
|
|
90
|
+
*/
|
|
80
91
|
getTokenAdminRegistryFor(address: string): Promise<string>;
|
|
81
92
|
/**
|
|
82
93
|
* Decodes a CCIP message from an Aptos log event.
|
|
83
94
|
* @param log - Log with data field.
|
|
84
95
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
96
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
85
97
|
*/
|
|
86
98
|
static decodeMessage(log: {
|
|
87
99
|
data: BytesLike | Record<string, unknown>;
|
|
@@ -100,6 +112,7 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
100
112
|
* Encodes extra arguments for Aptos CCIP messages.
|
|
101
113
|
* @param extraArgs - Extra arguments to encode.
|
|
102
114
|
* @returns Encoded extra arguments as hex string.
|
|
115
|
+
* @throws {@link CCIPAptosExtraArgsEncodingError} if extra args format is not supported
|
|
103
116
|
*/
|
|
104
117
|
static encodeExtraArgs(extraArgs: ExtraArgs): string;
|
|
105
118
|
/**
|
|
@@ -107,18 +120,21 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
107
120
|
* @param log - Log with data field.
|
|
108
121
|
* @param lane - Lane info for filtering.
|
|
109
122
|
* @returns Array of CommitReport or undefined if not valid.
|
|
123
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
110
124
|
*/
|
|
111
125
|
static decodeCommits({ data }: Pick<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined;
|
|
112
126
|
/**
|
|
113
127
|
* Decodes an execution receipt from an Aptos log event.
|
|
114
128
|
* @param log - Log with data field.
|
|
115
129
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
130
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
116
131
|
*/
|
|
117
132
|
static decodeReceipt({ data }: Pick<Log_, 'data'>): ExecutionReceipt | undefined;
|
|
118
133
|
/**
|
|
119
134
|
* Converts bytes to an Aptos address.
|
|
120
135
|
* @param bytes - Bytes to convert.
|
|
121
136
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
137
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if bytes length exceeds 32
|
|
122
138
|
*/
|
|
123
139
|
static getAddress(bytes: BytesLike | readonly number[]): string;
|
|
124
140
|
/**
|
|
@@ -135,14 +151,23 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
135
151
|
getFee({ router, destChainSelector, message, }: Parameters<Chain['getFee']>[0]): Promise<bigint>;
|
|
136
152
|
/** {@inheritDoc Chain.generateUnsignedSendMessage} */
|
|
137
153
|
generateUnsignedSendMessage(opts: Parameters<Chain['generateUnsignedSendMessage']>[0]): Promise<UnsignedAptosTx>;
|
|
138
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* {@inheritDoc Chain.sendMessage}
|
|
156
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
157
|
+
*/
|
|
139
158
|
sendMessage(opts: Parameters<Chain['sendMessage']>[0]): Promise<CCIPRequest>;
|
|
140
159
|
/** {@inheritDoc Chain.getOffchainTokenData} */
|
|
141
160
|
getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
161
|
+
/**
|
|
162
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
163
|
+
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
164
|
+
*/
|
|
165
|
+
generateUnsignedExecute({ payer, ...opts }: Parameters<Chain['generateUnsignedExecute']>[0]): Promise<UnsignedAptosTx>;
|
|
166
|
+
/**
|
|
167
|
+
* {@inheritDoc Chain.execute}
|
|
168
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
169
|
+
*/
|
|
170
|
+
execute(opts: Parameters<Chain['execute']>[0]): Promise<CCIPExecution>;
|
|
146
171
|
/**
|
|
147
172
|
* Parses raw Aptos data into typed structures.
|
|
148
173
|
* @param data - Raw data to parse.
|
|
@@ -159,14 +184,17 @@ export declare class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
159
184
|
getSupportedTokens(address: string, opts?: {
|
|
160
185
|
page?: number;
|
|
161
186
|
}): Promise<string[]>;
|
|
162
|
-
/**
|
|
187
|
+
/**
|
|
188
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
189
|
+
* @throws {@link CCIPAptosTokenNotRegisteredError} if token is not registered
|
|
190
|
+
*/
|
|
163
191
|
getRegistryTokenConfig(registry: string, token: string): Promise<{
|
|
164
192
|
administrator: string;
|
|
165
193
|
pendingAdministrator?: string;
|
|
166
194
|
tokenPool?: string;
|
|
167
195
|
}>;
|
|
168
|
-
/** {@inheritDoc Chain.
|
|
169
|
-
|
|
196
|
+
/** {@inheritDoc Chain.getTokenPoolConfig} */
|
|
197
|
+
getTokenPoolConfig(tokenPool: string): Promise<{
|
|
170
198
|
token: string;
|
|
171
199
|
router: string;
|
|
172
200
|
typeAndVersion?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/aptos/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAEL,WAAW,EAEX,OAAO,EAGR,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,KAAK,SAAS,EAAoC,MAAM,QAAQ,CAAA;AAEzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,EACN,MAAM,aAAa,CAAA;AAkBpB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,cAAc,EAGpB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,YAAY,CAAA;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAQrD,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,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,EACf,WAAW,EACZ,MAAM,aAAa,CAAA;AAapB,YAAY,EAAE,eAAe,EAAE,CAAA;AAE/B;;GAEG;AACH,qBAA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AAoB,CAAC,EAAE,MAAM,CAAA;QAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAC;IAkBF,6CAA6C;IACvC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QACnD,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;QACd,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB,CAAC;IAkCF,8CAA8C;IACxC,mBAAmB,CACvB,SAAS,EAAE,MAAM,EACjB,mBAAmB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAsG3C,uCAAuC;IACjC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;CAavE"}
|
package/dist/aptos/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { Aptos, AptosConfig, Deserializer, Network, SimpleTransaction, TransactionResponseType, } from '@aptos-labs/ts-sdk';
|
|
2
|
-
import { concat,
|
|
1
|
+
import { Aptos, AptosApiError, AptosConfig, Deserializer, Network, SimpleTransaction, TransactionResponseType, } from '@aptos-labs/ts-sdk';
|
|
2
|
+
import { concat, isBytesLike, isHexString } from 'ethers';
|
|
3
3
|
import { memoize } from 'micro-memoize';
|
|
4
4
|
import { Chain, } from "../chain.js";
|
|
5
|
+
import { generateUnsignedExecuteReport } from "./exec.js";
|
|
6
|
+
import { getAptosLeafHasher } from "./hasher.js";
|
|
7
|
+
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from "./logs.js";
|
|
5
8
|
import { generateUnsignedCcipSend, getFee } from "./send.js";
|
|
6
|
-
import {
|
|
9
|
+
import { CCIPAptosExtraArgsEncodingError, CCIPAptosExtraArgsV2RequiredError, CCIPAptosLogInvalidError, CCIPAptosNetworkUnknownError, CCIPAptosRegistryTypeInvalidError, CCIPAptosTokenNotRegisteredError, CCIPAptosTransactionInvalidError, CCIPAptosTransactionTypeInvalidError, CCIPAptosWalletInvalidError, CCIPError, CCIPTokenPoolChainConfigNotFoundError, } from "../errors/index.js";
|
|
7
10
|
import { EVMExtraArgsV2Tag, SVMExtraArgsV1Tag, } from "../extra-args.js";
|
|
8
|
-
import {
|
|
11
|
+
import { isAptosAccount } from "./types.js";
|
|
12
|
+
import { BcsEVMExtraArgsV2Codec, BcsSVMExtraArgsV1Codec, decodeMoveExtraArgs, getMoveAddress, } from "../shared/bcs-codecs.js";
|
|
9
13
|
import { supportedChains } from "../supported-chains.js";
|
|
10
14
|
import { ChainFamily, } from "../types.js";
|
|
11
|
-
import { convertKeysToCamelCase, decodeAddress, decodeOnRampAddress, getAddressBytes,
|
|
12
|
-
import { generateUnsignedExecuteReport } from "./exec.js";
|
|
13
|
-
import { getAptosLeafHasher } from "./hasher.js";
|
|
14
|
-
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from "./logs.js";
|
|
15
|
+
import { convertKeysToCamelCase, decodeAddress, decodeOnRampAddress, getAddressBytes, networkInfo, parseTypeAndVersion, util, } from "../utils.js";
|
|
15
16
|
import { getTokenInfo } from "./token.js";
|
|
16
17
|
import { buildMessageForDest, decodeMessage, getMessagesInBatch } from "../requests.js";
|
|
17
18
|
/**
|
|
@@ -21,11 +22,16 @@ export class AptosChain extends Chain {
|
|
|
21
22
|
static {
|
|
22
23
|
supportedChains[ChainFamily.Aptos] = AptosChain;
|
|
23
24
|
}
|
|
25
|
+
/** Chain family identifier for Aptos networks. */
|
|
24
26
|
static family = ChainFamily.Aptos;
|
|
27
|
+
/** Native token decimals (8 for APT). */
|
|
25
28
|
static decimals = 8;
|
|
26
29
|
destroy$;
|
|
30
|
+
/** The Aptos SDK provider for blockchain interactions. */
|
|
27
31
|
provider;
|
|
32
|
+
/** Retrieves token information for a given token address. */
|
|
28
33
|
getTokenInfo;
|
|
34
|
+
/** @internal */
|
|
29
35
|
_getAccountModulesNames;
|
|
30
36
|
/**
|
|
31
37
|
* Creates a new AptosChain instance.
|
|
@@ -86,6 +92,7 @@ export class AptosChain extends Chain {
|
|
|
86
92
|
* @param url - RPC URL, Aptos Network enum value or [fullNodeUrl, Network] tuple.
|
|
87
93
|
* @param ctx - context containing logger
|
|
88
94
|
* @returns A new AptosChain instance.
|
|
95
|
+
* @throws {@link CCIPAptosNetworkUnknownError} if network cannot be determined from URL
|
|
89
96
|
*/
|
|
90
97
|
static async fromUrl(url, ctx) {
|
|
91
98
|
let network;
|
|
@@ -114,7 +121,11 @@ export class AptosChain extends Chain {
|
|
|
114
121
|
async getBlockTimestamp(version) {
|
|
115
122
|
return getVersionTimestamp(this.provider, version);
|
|
116
123
|
}
|
|
117
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* {@inheritDoc Chain.getTransaction}
|
|
126
|
+
* @throws {@link CCIPAptosTransactionInvalidError} if hash/version format is invalid
|
|
127
|
+
* @throws {@link CCIPAptosTransactionTypeInvalidError} if transaction is not a user transaction
|
|
128
|
+
*/
|
|
118
129
|
async getTransaction(hashOrVersion) {
|
|
119
130
|
let tx;
|
|
120
131
|
if (isHexString(hashOrVersion, 32)) {
|
|
@@ -150,8 +161,8 @@ export class AptosChain extends Chain {
|
|
|
150
161
|
yield* streamAptosLogs(this, opts);
|
|
151
162
|
}
|
|
152
163
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
153
|
-
async getMessagesInBatch(request,
|
|
154
|
-
return getMessagesInBatch(this, request,
|
|
164
|
+
async getMessagesInBatch(request, range, opts) {
|
|
165
|
+
return getMessagesInBatch(this, request, range, opts);
|
|
155
166
|
}
|
|
156
167
|
/** {@inheritDoc Chain.typeAndVersion} */
|
|
157
168
|
async typeAndVersion(address) {
|
|
@@ -184,19 +195,15 @@ export class AptosChain extends Chain {
|
|
|
184
195
|
getOnRampForRouter(router, _destChainSelector) {
|
|
185
196
|
return Promise.resolve(router.split('::')[0] + '::onramp');
|
|
186
197
|
}
|
|
187
|
-
/** {@inheritDoc Chain.
|
|
188
|
-
async
|
|
198
|
+
/** {@inheritDoc Chain.getOnRampsForOffRamp} */
|
|
199
|
+
async getOnRampsForOffRamp(offRamp, sourceChainSelector) {
|
|
189
200
|
const [sourceChainConfig] = await this.provider.view({
|
|
190
201
|
payload: {
|
|
191
202
|
function: `${offRamp.includes('::') ? offRamp : offRamp + '::offramp'}::get_source_chain_config`,
|
|
192
203
|
functionArguments: [sourceChainSelector],
|
|
193
204
|
},
|
|
194
205
|
});
|
|
195
|
-
return decodeAddress(sourceChainConfig.on_ramp, networkInfo(sourceChainSelector).family);
|
|
196
|
-
}
|
|
197
|
-
/** {@inheritDoc Chain.getCommitStoreForOffRamp} */
|
|
198
|
-
getCommitStoreForOffRamp(offRamp) {
|
|
199
|
-
return Promise.resolve(offRamp.split('::')[0] + '::offramp');
|
|
206
|
+
return [decodeAddress(sourceChainConfig.on_ramp, networkInfo(sourceChainSelector).family)];
|
|
200
207
|
}
|
|
201
208
|
/** {@inheritDoc Chain.getTokenForTokenPool} */
|
|
202
209
|
async getTokenForTokenPool(tokenPool) {
|
|
@@ -229,7 +236,10 @@ export class AptosChain extends Chain {
|
|
|
229
236
|
});
|
|
230
237
|
return BigInt(balance);
|
|
231
238
|
}
|
|
232
|
-
/**
|
|
239
|
+
/**
|
|
240
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
241
|
+
* @throws {@link CCIPAptosRegistryTypeInvalidError} if registry type is invalid
|
|
242
|
+
*/
|
|
233
243
|
async getTokenAdminRegistryFor(address) {
|
|
234
244
|
const registry = address.split('::')[0] + '::token_admin_registry';
|
|
235
245
|
const [type] = await this.typeAndVersion(registry);
|
|
@@ -242,6 +252,7 @@ export class AptosChain extends Chain {
|
|
|
242
252
|
* Decodes a CCIP message from an Aptos log event.
|
|
243
253
|
* @param log - Log with data field.
|
|
244
254
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
255
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
245
256
|
*/
|
|
246
257
|
static decodeMessage(log) {
|
|
247
258
|
const { data } = log;
|
|
@@ -262,43 +273,21 @@ export class AptosChain extends Chain {
|
|
|
262
273
|
* @returns Decoded extra arguments or undefined if unknown format.
|
|
263
274
|
*/
|
|
264
275
|
static decodeExtraArgs(extraArgs) {
|
|
265
|
-
|
|
266
|
-
switch (tag) {
|
|
267
|
-
case EVMExtraArgsV2Tag: {
|
|
268
|
-
const parsed = EVMExtraArgsV2Codec.parse(getBytes(dataSlice(data, 4)));
|
|
269
|
-
// Aptos serialization of EVMExtraArgsV2: 37 bytes total: 4 tag + 32 LE gasLimit + 1 allowOOOE
|
|
270
|
-
return {
|
|
271
|
-
_tag: 'EVMExtraArgsV2',
|
|
272
|
-
...parsed,
|
|
273
|
-
gasLimit: BigInt(parsed.gasLimit),
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
case SVMExtraArgsV1Tag: {
|
|
277
|
-
const parsed = SVMExtraArgsV1Codec.parse(getBytes(dataSlice(data, 4)));
|
|
278
|
-
// Aptos serialization of SVMExtraArgsV1: 13 bytes total: 4 tag + 8 LE computeUnits
|
|
279
|
-
return {
|
|
280
|
-
_tag: 'SVMExtraArgsV1',
|
|
281
|
-
...parsed,
|
|
282
|
-
computeUnits: BigInt(parsed.computeUnits),
|
|
283
|
-
accountIsWritableBitmap: BigInt(parsed.accountIsWritableBitmap),
|
|
284
|
-
tokenReceiver: decodeAddress(new Uint8Array(parsed.tokenReceiver), ChainFamily.Solana),
|
|
285
|
-
accounts: parsed.accounts.map((account) => decodeAddress(new Uint8Array(account), ChainFamily.Solana)),
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
}
|
|
276
|
+
return decodeMoveExtraArgs(extraArgs);
|
|
289
277
|
}
|
|
290
278
|
/**
|
|
291
279
|
* Encodes extra arguments for Aptos CCIP messages.
|
|
292
280
|
* @param extraArgs - Extra arguments to encode.
|
|
293
281
|
* @returns Encoded extra arguments as hex string.
|
|
282
|
+
* @throws {@link CCIPAptosExtraArgsEncodingError} if extra args format is not supported
|
|
294
283
|
*/
|
|
295
284
|
static encodeExtraArgs(extraArgs) {
|
|
296
285
|
if ('gasLimit' in extraArgs && 'allowOutOfOrderExecution' in extraArgs)
|
|
297
|
-
return concat([EVMExtraArgsV2Tag,
|
|
286
|
+
return concat([EVMExtraArgsV2Tag, BcsEVMExtraArgsV2Codec.serialize(extraArgs).toBytes()]);
|
|
298
287
|
else if ('computeUnits' in extraArgs)
|
|
299
288
|
return concat([
|
|
300
289
|
SVMExtraArgsV1Tag,
|
|
301
|
-
|
|
290
|
+
BcsSVMExtraArgsV1Codec.serialize({
|
|
302
291
|
...extraArgs,
|
|
303
292
|
computeUnits: Number(extraArgs.computeUnits),
|
|
304
293
|
tokenReceiver: getAddressBytes(extraArgs.tokenReceiver),
|
|
@@ -312,6 +301,7 @@ export class AptosChain extends Chain {
|
|
|
312
301
|
* @param log - Log with data field.
|
|
313
302
|
* @param lane - Lane info for filtering.
|
|
314
303
|
* @returns Array of CommitReport or undefined if not valid.
|
|
304
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
315
305
|
*/
|
|
316
306
|
static decodeCommits({ data }, lane) {
|
|
317
307
|
if (!data || typeof data != 'object')
|
|
@@ -332,6 +322,7 @@ export class AptosChain extends Chain {
|
|
|
332
322
|
* Decodes an execution receipt from an Aptos log event.
|
|
333
323
|
* @param log - Log with data field.
|
|
334
324
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
325
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
335
326
|
*/
|
|
336
327
|
static decodeReceipt({ data }) {
|
|
337
328
|
if (!data || typeof data != 'object')
|
|
@@ -345,22 +336,10 @@ export class AptosChain extends Chain {
|
|
|
345
336
|
* Converts bytes to an Aptos address.
|
|
346
337
|
* @param bytes - Bytes to convert.
|
|
347
338
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
339
|
+
* @throws {@link CCIPDataFormatUnsupportedError} if bytes length exceeds 32
|
|
348
340
|
*/
|
|
349
341
|
static getAddress(bytes) {
|
|
350
|
-
|
|
351
|
-
if (Array.isArray(bytes))
|
|
352
|
-
bytes = new Uint8Array(bytes);
|
|
353
|
-
if (typeof bytes === 'string' && bytes.startsWith('0x')) {
|
|
354
|
-
const idx = bytes.indexOf('::');
|
|
355
|
-
if (idx > 0) {
|
|
356
|
-
suffix = bytes.slice(idx);
|
|
357
|
-
bytes = bytes.slice(0, idx);
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
bytes = getDataBytes(bytes);
|
|
361
|
-
if (bytes.length > 32)
|
|
362
|
-
throw new CCIPAptosAddressInvalidError(hexlify(bytes));
|
|
363
|
-
return zeroPadValue(bytes, 32) + suffix;
|
|
342
|
+
return getMoveAddress(bytes);
|
|
364
343
|
}
|
|
365
344
|
/**
|
|
366
345
|
* Validates a transaction hash format for Aptos
|
|
@@ -395,7 +374,10 @@ export class AptosChain extends Chain {
|
|
|
395
374
|
transactions: [tx],
|
|
396
375
|
};
|
|
397
376
|
}
|
|
398
|
-
/**
|
|
377
|
+
/**
|
|
378
|
+
* {@inheritDoc Chain.sendMessage}
|
|
379
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
380
|
+
*/
|
|
399
381
|
async sendMessage(opts) {
|
|
400
382
|
const account = opts.wallet;
|
|
401
383
|
if (!isAptosAccount(account)) {
|
|
@@ -424,24 +406,33 @@ export class AptosChain extends Chain {
|
|
|
424
406
|
// default offchain token data
|
|
425
407
|
return Promise.resolve(request.message.tokenAmounts.map(() => undefined));
|
|
426
408
|
}
|
|
427
|
-
/**
|
|
428
|
-
|
|
429
|
-
|
|
409
|
+
/**
|
|
410
|
+
* {@inheritDoc Chain.generateUnsignedExecute}
|
|
411
|
+
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
412
|
+
*/
|
|
413
|
+
async generateUnsignedExecute({ payer, ...opts }) {
|
|
414
|
+
if (!('input' in opts &&
|
|
415
|
+
'message' in opts.input &&
|
|
416
|
+
'allowOutOfOrderExecution' in opts.input.message &&
|
|
417
|
+
'gasLimit' in opts.input.message)) {
|
|
430
418
|
throw new CCIPAptosExtraArgsV2RequiredError();
|
|
431
419
|
}
|
|
432
|
-
const tx = await generateUnsignedExecuteReport(this.provider, payer, offRamp,
|
|
420
|
+
const tx = await generateUnsignedExecuteReport(this.provider, payer, opts.offRamp, opts.input, opts);
|
|
433
421
|
return {
|
|
434
422
|
family: ChainFamily.Aptos,
|
|
435
423
|
transactions: [tx],
|
|
436
424
|
};
|
|
437
425
|
}
|
|
438
|
-
/**
|
|
439
|
-
|
|
426
|
+
/**
|
|
427
|
+
* {@inheritDoc Chain.execute}
|
|
428
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
429
|
+
*/
|
|
430
|
+
async execute(opts) {
|
|
440
431
|
const account = opts.wallet;
|
|
441
432
|
if (!isAptosAccount(account)) {
|
|
442
433
|
throw new CCIPAptosWalletInvalidError(this.constructor.name, util.inspect(opts.wallet));
|
|
443
434
|
}
|
|
444
|
-
const unsignedTx = await this.
|
|
435
|
+
const unsignedTx = await this.generateUnsignedExecute({
|
|
445
436
|
...opts,
|
|
446
437
|
payer: account.accountAddress.toString(),
|
|
447
438
|
});
|
|
@@ -465,10 +456,15 @@ export class AptosChain extends Chain {
|
|
|
465
456
|
* @returns Parsed data or undefined.
|
|
466
457
|
*/
|
|
467
458
|
static parse(data) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
459
|
+
try {
|
|
460
|
+
if (isBytesLike(data)) {
|
|
461
|
+
const parsedExtraArgs = this.decodeExtraArgs(data);
|
|
462
|
+
if (parsedExtraArgs)
|
|
463
|
+
return parsedExtraArgs;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
catch {
|
|
467
|
+
// ignore
|
|
472
468
|
}
|
|
473
469
|
}
|
|
474
470
|
/** {@inheritDoc Chain.getSupportedTokens} */
|
|
@@ -487,7 +483,10 @@ export class AptosChain extends Chain {
|
|
|
487
483
|
} while (hasMore);
|
|
488
484
|
return page;
|
|
489
485
|
}
|
|
490
|
-
/**
|
|
486
|
+
/**
|
|
487
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
488
|
+
* @throws {@link CCIPAptosTokenNotRegisteredError} if token is not registered
|
|
489
|
+
*/
|
|
491
490
|
async getRegistryTokenConfig(registry, token) {
|
|
492
491
|
const [tokenPool, administrator, pendingAdministrator] = await this.provider.view({
|
|
493
492
|
payload: {
|
|
@@ -503,8 +502,8 @@ export class AptosChain extends Chain {
|
|
|
503
502
|
...(!tokenPool.match(/^0x0*$/) && { tokenPool }),
|
|
504
503
|
};
|
|
505
504
|
}
|
|
506
|
-
/** {@inheritDoc Chain.
|
|
507
|
-
async
|
|
505
|
+
/** {@inheritDoc Chain.getTokenPoolConfig} */
|
|
506
|
+
async getTokenPoolConfig(tokenPool) {
|
|
508
507
|
const modulesNames = (await this._getAccountModulesNames(tokenPool))
|
|
509
508
|
.reverse()
|
|
510
509
|
.filter((name) => name.endsWith('token_pool'));
|
|
@@ -541,8 +540,8 @@ export class AptosChain extends Chain {
|
|
|
541
540
|
/** {@inheritDoc Chain.getTokenPoolRemotes} */
|
|
542
541
|
async getTokenPoolRemotes(tokenPool, remoteChainSelector) {
|
|
543
542
|
const modulesNames = (await this._getAccountModulesNames(tokenPool))
|
|
544
|
-
.
|
|
545
|
-
.
|
|
543
|
+
.filter((name) => name.endsWith('token_pool'))
|
|
544
|
+
.sort((a, b) => b.length - a.length);
|
|
546
545
|
let firstErr;
|
|
547
546
|
for (const name of modulesNames) {
|
|
548
547
|
try {
|
|
@@ -579,35 +578,43 @@ export class AptosChain extends Chain {
|
|
|
579
578
|
functionArguments: [chain.chainSelector],
|
|
580
579
|
},
|
|
581
580
|
});
|
|
582
|
-
|
|
583
|
-
remoteToken
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
581
|
+
try {
|
|
582
|
+
const [[remoteToken], [remotePools], [inboundRateLimiterState], [outboundRateLimiterState],] = await Promise.all([
|
|
583
|
+
remoteToken$,
|
|
584
|
+
remotePools$,
|
|
585
|
+
inboundRateLimiterState$,
|
|
586
|
+
outboundRateLimiterState$,
|
|
587
|
+
]);
|
|
588
|
+
return [
|
|
589
|
+
chain.name,
|
|
590
|
+
{
|
|
591
|
+
remoteToken: decodeAddress(remoteToken, chain.family),
|
|
592
|
+
remotePools: remotePools.map((pool) => decodeAddress(pool, chain.family)),
|
|
593
|
+
inboundRateLimiterState: inboundRateLimiterState.is_enabled
|
|
594
|
+
? {
|
|
595
|
+
capacity: BigInt(inboundRateLimiterState.capacity),
|
|
596
|
+
lastUpdated: Number(inboundRateLimiterState.last_updated),
|
|
597
|
+
rate: BigInt(inboundRateLimiterState.rate),
|
|
598
|
+
tokens: BigInt(inboundRateLimiterState.tokens),
|
|
599
|
+
}
|
|
600
|
+
: null,
|
|
601
|
+
outboundRateLimiterState: outboundRateLimiterState.is_enabled
|
|
602
|
+
? {
|
|
603
|
+
capacity: BigInt(outboundRateLimiterState.capacity),
|
|
604
|
+
lastUpdated: Number(outboundRateLimiterState.last_updated),
|
|
605
|
+
rate: BigInt(outboundRateLimiterState.rate),
|
|
606
|
+
tokens: BigInt(outboundRateLimiterState.tokens),
|
|
607
|
+
}
|
|
608
|
+
: null,
|
|
609
|
+
},
|
|
610
|
+
];
|
|
611
|
+
}
|
|
612
|
+
catch (err) {
|
|
613
|
+
if (err instanceof AptosApiError &&
|
|
614
|
+
err.message.includes('Key not found in the smart table'))
|
|
615
|
+
throw new CCIPTokenPoolChainConfigNotFoundError(tokenPool, tokenPool, chain.name);
|
|
616
|
+
throw err;
|
|
617
|
+
}
|
|
611
618
|
})));
|
|
612
619
|
}
|
|
613
620
|
catch (err) {
|