@chainlink/ccip-sdk 0.94.0 → 0.96.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 +86 -7
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +270 -10
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.d.ts +134 -13
- package/dist/api/types.d.ts.map +1 -1
- package/dist/aptos/index.d.ts +38 -17
- package/dist/aptos/index.d.ts.map +1 -1
- package/dist/aptos/index.js +91 -61
- package/dist/aptos/index.js.map +1 -1
- package/dist/aptos/logs.js +3 -3
- package/dist/aptos/logs.js.map +1 -1
- package/dist/chain.d.ts +300 -42
- package/dist/chain.d.ts.map +1 -1
- package/dist/chain.js +160 -9
- package/dist/chain.js.map +1 -1
- package/dist/errors/codes.d.ts +9 -3
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/errors/codes.js +10 -3
- package/dist/errors/codes.js.map +1 -1
- package/dist/errors/index.d.ts +8 -8
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +8 -8
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/recovery.d.ts.map +1 -1
- package/dist/errors/recovery.js +10 -4
- package/dist/errors/recovery.js.map +1 -1
- package/dist/errors/specialized.d.ts +62 -21
- package/dist/errors/specialized.d.ts.map +1 -1
- package/dist/errors/specialized.js +128 -41
- package/dist/errors/specialized.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 +328 -0
- package/dist/evm/extra-args.js.map +1 -0
- package/dist/evm/gas.d.ts +14 -0
- package/dist/evm/gas.d.ts.map +1 -0
- package/dist/evm/gas.js +92 -0
- package/dist/evm/gas.js.map +1 -0
- package/dist/evm/index.d.ts +76 -32
- package/dist/evm/index.d.ts.map +1 -1
- package/dist/evm/index.js +94 -104
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/offchain.d.ts.map +1 -1
- package/dist/evm/offchain.js +8 -8
- package/dist/evm/offchain.js.map +1 -1
- package/dist/execution.d.ts.map +1 -1
- package/dist/execution.js +24 -3
- package/dist/execution.js.map +1 -1
- package/dist/extra-args.d.ts +103 -4
- package/dist/extra-args.d.ts.map +1 -1
- package/dist/extra-args.js +28 -3
- package/dist/extra-args.js.map +1 -1
- package/dist/gas.d.ts +46 -19
- package/dist/gas.d.ts.map +1 -1
- package/dist/gas.js +56 -68
- package/dist/gas.js.map +1 -1
- package/dist/index.d.ts +18 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -13
- package/dist/index.js.map +1 -1
- package/dist/offchain.d.ts +5 -4
- package/dist/offchain.d.ts.map +1 -1
- package/dist/offchain.js +7 -6
- package/dist/offchain.js.map +1 -1
- package/dist/requests.d.ts +30 -20
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +86 -56
- package/dist/requests.js.map +1 -1
- package/dist/selectors.d.ts +2 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/selectors.js +625 -278
- package/dist/selectors.js.map +1 -1
- package/dist/solana/exec.d.ts.map +1 -1
- package/dist/solana/exec.js +2 -1
- package/dist/solana/exec.js.map +1 -1
- package/dist/solana/index.d.ts +73 -22
- package/dist/solana/index.d.ts.map +1 -1
- package/dist/solana/index.js +91 -28
- package/dist/solana/index.js.map +1 -1
- package/dist/solana/offchain.js +2 -2
- package/dist/solana/offchain.js.map +1 -1
- package/dist/solana/send.d.ts.map +1 -1
- package/dist/solana/send.js +6 -9
- package/dist/solana/send.js.map +1 -1
- package/dist/solana/utils.d.ts +29 -1
- package/dist/solana/utils.d.ts.map +1 -1
- package/dist/solana/utils.js +39 -1
- package/dist/solana/utils.js.map +1 -1
- package/dist/sui/discovery.d.ts +7 -4
- package/dist/sui/discovery.d.ts.map +1 -1
- package/dist/sui/discovery.js +66 -19
- package/dist/sui/discovery.js.map +1 -1
- package/dist/sui/events.d.ts +23 -12
- package/dist/sui/events.d.ts.map +1 -1
- package/dist/sui/events.js +267 -128
- package/dist/sui/events.js.map +1 -1
- package/dist/sui/index.d.ts +57 -41
- package/dist/sui/index.d.ts.map +1 -1
- package/dist/sui/index.js +286 -159
- package/dist/sui/index.js.map +1 -1
- package/dist/sui/objects.d.ts +14 -4
- package/dist/sui/objects.d.ts.map +1 -1
- package/dist/sui/objects.js +61 -68
- package/dist/sui/objects.js.map +1 -1
- package/dist/sui/types.d.ts +33 -0
- package/dist/sui/types.d.ts.map +1 -1
- package/dist/sui/types.js.map +1 -1
- package/dist/ton/index.d.ts +67 -21
- package/dist/ton/index.d.ts.map +1 -1
- package/dist/ton/index.js +159 -30
- 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/utils.d.ts +3 -3
- package/dist/ton/utils.d.ts.map +1 -1
- package/dist/ton/utils.js +6 -5
- package/dist/ton/utils.js.map +1 -1
- package/dist/types.d.ts +126 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -5
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +67 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +126 -17
- package/dist/utils.js.map +1 -1
- package/package.json +14 -9
- package/src/all-chains.ts +26 -0
- package/src/api/index.ts +348 -13
- package/src/api/types.ts +160 -13
- package/src/aptos/index.ts +98 -76
- package/src/aptos/logs.ts +3 -3
- package/src/chain.ts +408 -51
- package/src/errors/codes.ts +10 -3
- package/src/errors/index.ts +8 -5
- package/src/errors/recovery.ts +18 -5
- package/src/errors/specialized.ts +168 -49
- package/src/evm/extra-args.ts +377 -0
- package/src/evm/gas.ts +150 -0
- package/src/evm/index.ts +123 -155
- package/src/evm/offchain.ts +15 -9
- package/src/execution.ts +26 -3
- package/src/extra-args.ts +108 -4
- package/src/gas.ts +101 -115
- package/src/index.ts +27 -14
- package/src/offchain.ts +12 -6
- package/src/requests.ts +117 -67
- package/src/selectors.ts +632 -280
- package/src/solana/exec.ts +3 -1
- package/src/solana/index.ts +97 -37
- package/src/solana/offchain.ts +2 -2
- package/src/solana/send.ts +5 -23
- package/src/solana/utils.ts +66 -0
- package/src/sui/discovery.ts +92 -31
- package/src/sui/events.ts +346 -239
- package/src/sui/index.ts +365 -212
- package/src/sui/objects.ts +74 -98
- package/src/sui/types.ts +35 -0
- package/src/ton/index.ts +199 -35
- package/src/ton/send.ts +222 -0
- package/src/ton/utils.ts +7 -6
- package/src/types.ts +128 -9
- package/src/utils.ts +169 -21
package/src/aptos/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Aptos,
|
|
3
|
+
AptosApiError,
|
|
3
4
|
AptosConfig,
|
|
4
5
|
Deserializer,
|
|
5
6
|
Network,
|
|
@@ -9,9 +10,7 @@ import {
|
|
|
9
10
|
import {
|
|
10
11
|
type BytesLike,
|
|
11
12
|
concat,
|
|
12
|
-
dataLength,
|
|
13
13
|
dataSlice,
|
|
14
|
-
decodeBase64,
|
|
15
14
|
getBytes,
|
|
16
15
|
hexlify,
|
|
17
16
|
isBytesLike,
|
|
@@ -23,6 +22,7 @@ import type { PickDeep } from 'type-fest'
|
|
|
23
22
|
|
|
24
23
|
import {
|
|
25
24
|
type ChainContext,
|
|
25
|
+
type GetBalanceOpts,
|
|
26
26
|
type LogFilter,
|
|
27
27
|
type TokenInfo,
|
|
28
28
|
type TokenPoolRemote,
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
CCIPAptosTransactionTypeInvalidError,
|
|
42
42
|
CCIPAptosWalletInvalidError,
|
|
43
43
|
CCIPError,
|
|
44
|
-
|
|
44
|
+
CCIPTokenPoolChainConfigNotFoundError,
|
|
45
45
|
} from '../errors/index.ts'
|
|
46
46
|
import {
|
|
47
47
|
type EVMExtraArgsV2,
|
|
@@ -88,13 +88,7 @@ import { getAptosLeafHasher } from './hasher.ts'
|
|
|
88
88
|
import { getUserTxByVersion, getVersionTimestamp, streamAptosLogs } from './logs.ts'
|
|
89
89
|
import { getTokenInfo } from './token.ts'
|
|
90
90
|
import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
|
|
91
|
-
import {
|
|
92
|
-
buildMessageForDest,
|
|
93
|
-
decodeMessage,
|
|
94
|
-
getMessageById,
|
|
95
|
-
getMessagesInBatch,
|
|
96
|
-
getMessagesInTx,
|
|
97
|
-
} from '../requests.ts'
|
|
91
|
+
import { buildMessageForDest, decodeMessage, getMessagesInBatch } from '../requests.ts'
|
|
98
92
|
export type { UnsignedAptosTx }
|
|
99
93
|
|
|
100
94
|
/**
|
|
@@ -185,6 +179,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
185
179
|
* @param url - RPC URL, Aptos Network enum value or [fullNodeUrl, Network] tuple.
|
|
186
180
|
* @param ctx - context containing logger
|
|
187
181
|
* @returns A new AptosChain instance.
|
|
182
|
+
* @throws {@link CCIPAptosNetworkUnknownError} if network cannot be determined from URL
|
|
188
183
|
*/
|
|
189
184
|
static async fromUrl(
|
|
190
185
|
url: string | Network | readonly [string, Network],
|
|
@@ -211,7 +206,11 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
211
206
|
return getVersionTimestamp(this.provider, version)
|
|
212
207
|
}
|
|
213
208
|
|
|
214
|
-
/**
|
|
209
|
+
/**
|
|
210
|
+
* {@inheritDoc Chain.getTransaction}
|
|
211
|
+
* @throws {@link CCIPAptosTransactionInvalidError} if hash/version format is invalid
|
|
212
|
+
* @throws {@link CCIPAptosTransactionTypeInvalidError} if transaction is not a user transaction
|
|
213
|
+
*/
|
|
215
214
|
async getTransaction(hashOrVersion: string | number): Promise<ChainTransaction> {
|
|
216
215
|
let tx
|
|
217
216
|
if (isHexString(hashOrVersion, 32)) {
|
|
@@ -246,24 +245,6 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
246
245
|
yield* streamAptosLogs(this, opts)
|
|
247
246
|
}
|
|
248
247
|
|
|
249
|
-
/** {@inheritDoc Chain.getMessagesInTx} */
|
|
250
|
-
async getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]> {
|
|
251
|
-
return getMessagesInTx(this, typeof tx === 'string' ? await this.getTransaction(tx) : tx)
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/** {@inheritDoc Chain.getMessageById} */
|
|
255
|
-
override async getMessageById(
|
|
256
|
-
messageId: string,
|
|
257
|
-
onRamp?: string,
|
|
258
|
-
opts?: { page?: number },
|
|
259
|
-
): Promise<CCIPRequest> {
|
|
260
|
-
if (!onRamp) throw new CCIPOnRampRequiredError()
|
|
261
|
-
return getMessageById(this, messageId, {
|
|
262
|
-
address: await this.getOnRampForRouter(onRamp, 0n),
|
|
263
|
-
...opts,
|
|
264
|
-
})
|
|
265
|
-
}
|
|
266
|
-
|
|
267
248
|
/** {@inheritDoc Chain.getMessagesInBatch} */
|
|
268
249
|
async getMessagesInBatch<
|
|
269
250
|
R extends PickDeep<
|
|
@@ -353,7 +334,22 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
353
334
|
throw CCIPError.from(firstErr ?? `Could not view 'get_token' in ${tokenPool}`, 'UNKNOWN')
|
|
354
335
|
}
|
|
355
336
|
|
|
356
|
-
/** {@inheritDoc Chain.
|
|
337
|
+
/** {@inheritDoc Chain.getBalance} */
|
|
338
|
+
async getBalance(opts: GetBalanceOpts): Promise<bigint> {
|
|
339
|
+
const { holder, token } = opts
|
|
340
|
+
const asset = token ?? '0x1::aptos_coin::AptosCoin'
|
|
341
|
+
|
|
342
|
+
const balance = await this.provider.getBalance({
|
|
343
|
+
accountAddress: holder,
|
|
344
|
+
asset,
|
|
345
|
+
})
|
|
346
|
+
return BigInt(balance)
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* {@inheritDoc Chain.getTokenAdminRegistryFor}
|
|
351
|
+
* @throws {@link CCIPAptosRegistryTypeInvalidError} if registry type is invalid
|
|
352
|
+
*/
|
|
357
353
|
async getTokenAdminRegistryFor(address: string): Promise<string> {
|
|
358
354
|
const registry = address.split('::')[0] + '::token_admin_registry'
|
|
359
355
|
const [type] = await this.typeAndVersion(registry)
|
|
@@ -367,6 +363,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
367
363
|
* Decodes a CCIP message from an Aptos log event.
|
|
368
364
|
* @param log - Log with data field.
|
|
369
365
|
* @returns Decoded CCIPMessage or undefined if not valid.
|
|
366
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
370
367
|
*/
|
|
371
368
|
static decodeMessage(log: {
|
|
372
369
|
data: BytesLike | Record<string, unknown>
|
|
@@ -429,6 +426,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
429
426
|
* Encodes extra arguments for Aptos CCIP messages.
|
|
430
427
|
* @param extraArgs - Extra arguments to encode.
|
|
431
428
|
* @returns Encoded extra arguments as hex string.
|
|
429
|
+
* @throws {@link CCIPAptosExtraArgsEncodingError} if extra args format is not supported
|
|
432
430
|
*/
|
|
433
431
|
static encodeExtraArgs(extraArgs: ExtraArgs): string {
|
|
434
432
|
if ('gasLimit' in extraArgs && 'allowOutOfOrderExecution' in extraArgs)
|
|
@@ -451,6 +449,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
451
449
|
* @param log - Log with data field.
|
|
452
450
|
* @param lane - Lane info for filtering.
|
|
453
451
|
* @returns Array of CommitReport or undefined if not valid.
|
|
452
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
454
453
|
*/
|
|
455
454
|
static decodeCommits({ data }: Pick<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined {
|
|
456
455
|
if (!data || typeof data != 'object') throw new CCIPAptosLogInvalidError(data)
|
|
@@ -484,6 +483,7 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
484
483
|
* Decodes an execution receipt from an Aptos log event.
|
|
485
484
|
* @param log - Log with data field.
|
|
486
485
|
* @returns ExecutionReceipt or undefined if not valid.
|
|
486
|
+
* @throws {@link CCIPAptosLogInvalidError} if log data format is invalid
|
|
487
487
|
*/
|
|
488
488
|
static decodeReceipt({ data }: Pick<Log_, 'data'>): ExecutionReceipt | undefined {
|
|
489
489
|
if (!data || typeof data != 'object') throw new CCIPAptosLogInvalidError(data)
|
|
@@ -498,19 +498,20 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
498
498
|
* Converts bytes to an Aptos address.
|
|
499
499
|
* @param bytes - Bytes to convert.
|
|
500
500
|
* @returns Aptos address (0x-prefixed hex, 32 bytes padded).
|
|
501
|
+
* @throws {@link CCIPAptosAddressInvalidError} if bytes length exceeds 32
|
|
501
502
|
*/
|
|
502
|
-
static getAddress(bytes: BytesLike): string {
|
|
503
|
+
static getAddress(bytes: BytesLike | readonly number[]): string {
|
|
503
504
|
let suffix = ''
|
|
504
|
-
if (
|
|
505
|
-
|
|
506
|
-
} else if (typeof bytes === 'string') {
|
|
505
|
+
if (Array.isArray(bytes)) bytes = new Uint8Array(bytes)
|
|
506
|
+
if (typeof bytes === 'string' && bytes.startsWith('0x')) {
|
|
507
507
|
const idx = bytes.indexOf('::')
|
|
508
508
|
if (idx > 0) {
|
|
509
509
|
suffix = bytes.slice(idx)
|
|
510
510
|
bytes = bytes.slice(0, idx)
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
|
|
513
|
+
bytes = getDataBytes(bytes)
|
|
514
|
+
if (bytes.length > 32) throw new CCIPAptosAddressInvalidError(hexlify(bytes))
|
|
514
515
|
return zeroPadValue(bytes, 32) + suffix
|
|
515
516
|
}
|
|
516
517
|
|
|
@@ -567,7 +568,10 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
567
568
|
}
|
|
568
569
|
}
|
|
569
570
|
|
|
570
|
-
/**
|
|
571
|
+
/**
|
|
572
|
+
* {@inheritDoc Chain.sendMessage}
|
|
573
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
574
|
+
*/
|
|
571
575
|
async sendMessage(opts: Parameters<Chain['sendMessage']>[0]): Promise<CCIPRequest> {
|
|
572
576
|
const account = opts.wallet
|
|
573
577
|
if (!isAptosAccount(account)) {
|
|
@@ -602,7 +606,10 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
602
606
|
return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
|
|
603
607
|
}
|
|
604
608
|
|
|
605
|
-
/**
|
|
609
|
+
/**
|
|
610
|
+
* {@inheritDoc Chain.generateUnsignedExecuteReport}
|
|
611
|
+
* @throws {@link CCIPAptosExtraArgsV2RequiredError} if message missing EVMExtraArgsV2 fields
|
|
612
|
+
*/
|
|
606
613
|
async generateUnsignedExecuteReport({
|
|
607
614
|
payer,
|
|
608
615
|
offRamp,
|
|
@@ -626,7 +633,10 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
626
633
|
}
|
|
627
634
|
}
|
|
628
635
|
|
|
629
|
-
/**
|
|
636
|
+
/**
|
|
637
|
+
* {@inheritDoc Chain.executeReport}
|
|
638
|
+
* @throws {@link CCIPAptosWalletInvalidError} if wallet is not a valid Aptos account
|
|
639
|
+
*/
|
|
630
640
|
async executeReport(opts: Parameters<Chain['executeReport']>[0]): Promise<CCIPExecution> {
|
|
631
641
|
const account = opts.wallet
|
|
632
642
|
if (!isAptosAccount(account)) {
|
|
@@ -685,7 +695,10 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
685
695
|
return page
|
|
686
696
|
}
|
|
687
697
|
|
|
688
|
-
/**
|
|
698
|
+
/**
|
|
699
|
+
* {@inheritDoc Chain.getRegistryTokenConfig}
|
|
700
|
+
* @throws {@link CCIPAptosTokenNotRegisteredError} if token is not registered
|
|
701
|
+
*/
|
|
689
702
|
async getRegistryTokenConfig(
|
|
690
703
|
registry: string,
|
|
691
704
|
token: string,
|
|
@@ -711,8 +724,8 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
711
724
|
}
|
|
712
725
|
}
|
|
713
726
|
|
|
714
|
-
/** {@inheritDoc Chain.
|
|
715
|
-
async
|
|
727
|
+
/** {@inheritDoc Chain.getTokenPoolConfig} */
|
|
728
|
+
async getTokenPoolConfig(tokenPool: string): Promise<{
|
|
716
729
|
token: string
|
|
717
730
|
router: string
|
|
718
731
|
typeAndVersion?: string
|
|
@@ -763,8 +776,8 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
763
776
|
tokens: string
|
|
764
777
|
}
|
|
765
778
|
const modulesNames = (await this._getAccountModulesNames(tokenPool))
|
|
766
|
-
.reverse()
|
|
767
779
|
.filter((name) => name.endsWith('token_pool'))
|
|
780
|
+
.sort((a, b) => b.length - a.length)
|
|
768
781
|
let firstErr
|
|
769
782
|
for (const name of modulesNames) {
|
|
770
783
|
try {
|
|
@@ -803,40 +816,49 @@ export class AptosChain extends Chain<typeof ChainFamily.Aptos> {
|
|
|
803
816
|
functionArguments: [chain.chainSelector],
|
|
804
817
|
},
|
|
805
818
|
})
|
|
806
|
-
|
|
807
|
-
[
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
819
|
+
try {
|
|
820
|
+
const [
|
|
821
|
+
[remoteToken],
|
|
822
|
+
[remotePools],
|
|
823
|
+
[inboundRateLimiterState],
|
|
824
|
+
[outboundRateLimiterState],
|
|
825
|
+
] = await Promise.all([
|
|
826
|
+
remoteToken$,
|
|
827
|
+
remotePools$,
|
|
828
|
+
inboundRateLimiterState$,
|
|
829
|
+
outboundRateLimiterState$,
|
|
830
|
+
])
|
|
831
|
+
return [
|
|
832
|
+
chain.name,
|
|
833
|
+
{
|
|
834
|
+
remoteToken: decodeAddress(remoteToken, chain.family),
|
|
835
|
+
remotePools: remotePools.map((pool) => decodeAddress(pool, chain.family)),
|
|
836
|
+
inboundRateLimiterState: inboundRateLimiterState.is_enabled
|
|
837
|
+
? {
|
|
838
|
+
capacity: BigInt(inboundRateLimiterState.capacity),
|
|
839
|
+
lastUpdated: Number(inboundRateLimiterState.last_updated),
|
|
840
|
+
rate: BigInt(inboundRateLimiterState.rate),
|
|
841
|
+
tokens: BigInt(inboundRateLimiterState.tokens),
|
|
842
|
+
}
|
|
843
|
+
: null,
|
|
844
|
+
outboundRateLimiterState: outboundRateLimiterState.is_enabled
|
|
845
|
+
? {
|
|
846
|
+
capacity: BigInt(outboundRateLimiterState.capacity),
|
|
847
|
+
lastUpdated: Number(outboundRateLimiterState.last_updated),
|
|
848
|
+
rate: BigInt(outboundRateLimiterState.rate),
|
|
849
|
+
tokens: BigInt(outboundRateLimiterState.tokens),
|
|
850
|
+
}
|
|
851
|
+
: null,
|
|
852
|
+
},
|
|
853
|
+
] as const
|
|
854
|
+
} catch (err) {
|
|
855
|
+
if (
|
|
856
|
+
err instanceof AptosApiError &&
|
|
857
|
+
err.message.includes('Key not found in the smart table')
|
|
858
|
+
)
|
|
859
|
+
throw new CCIPTokenPoolChainConfigNotFoundError(tokenPool, tokenPool, chain.name)
|
|
860
|
+
throw err
|
|
861
|
+
}
|
|
840
862
|
}),
|
|
841
863
|
),
|
|
842
864
|
)
|
package/src/aptos/logs.ts
CHANGED
|
@@ -10,10 +10,10 @@ import { memoize } from 'micro-memoize'
|
|
|
10
10
|
import type { LogFilter } from '../chain.ts'
|
|
11
11
|
import {
|
|
12
12
|
CCIPAptosAddressModuleRequiredError,
|
|
13
|
-
CCIPAptosTopicInvalidError,
|
|
14
13
|
CCIPAptosTransactionTypeUnexpectedError,
|
|
15
14
|
CCIPLogsWatchRequiresFinalityError,
|
|
16
15
|
CCIPLogsWatchRequiresStartError,
|
|
16
|
+
CCIPTopicsInvalidError,
|
|
17
17
|
} from '../errors/index.ts'
|
|
18
18
|
import type { Log_ } from '../types.ts'
|
|
19
19
|
import { sleep } from '../utils.ts'
|
|
@@ -245,11 +245,11 @@ export async function* streamAptosLogs(
|
|
|
245
245
|
const limit = 100
|
|
246
246
|
if (!opts.address || !opts.address.includes('::')) throw new CCIPAptosAddressModuleRequiredError()
|
|
247
247
|
if (opts.topics?.length !== 1 || typeof opts.topics[0] !== 'string')
|
|
248
|
-
throw new
|
|
248
|
+
throw new CCIPTopicsInvalidError(opts.topics!)
|
|
249
249
|
let eventHandlerField = opts.topics[0]
|
|
250
250
|
if (!eventHandlerField.includes('/')) {
|
|
251
251
|
eventHandlerField = (eventToHandler as Record<string, string>)[eventHandlerField]!
|
|
252
|
-
if (!eventHandlerField) throw new
|
|
252
|
+
if (!eventHandlerField) throw new CCIPTopicsInvalidError(opts.topics)
|
|
253
253
|
}
|
|
254
254
|
const [stateAddr] = await ctx.provider.view<[string]>({
|
|
255
255
|
payload: {
|