@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.
Files changed (170) hide show
  1. package/README.md +2 -2
  2. package/dist/all-chains.d.ts +23 -0
  3. package/dist/all-chains.d.ts.map +1 -0
  4. package/dist/all-chains.js +24 -0
  5. package/dist/all-chains.js.map +1 -0
  6. package/dist/api/index.d.ts +86 -7
  7. package/dist/api/index.d.ts.map +1 -1
  8. package/dist/api/index.js +270 -10
  9. package/dist/api/index.js.map +1 -1
  10. package/dist/api/types.d.ts +134 -13
  11. package/dist/api/types.d.ts.map +1 -1
  12. package/dist/aptos/index.d.ts +38 -17
  13. package/dist/aptos/index.d.ts.map +1 -1
  14. package/dist/aptos/index.js +91 -61
  15. package/dist/aptos/index.js.map +1 -1
  16. package/dist/aptos/logs.js +3 -3
  17. package/dist/aptos/logs.js.map +1 -1
  18. package/dist/chain.d.ts +300 -42
  19. package/dist/chain.d.ts.map +1 -1
  20. package/dist/chain.js +160 -9
  21. package/dist/chain.js.map +1 -1
  22. package/dist/errors/codes.d.ts +9 -3
  23. package/dist/errors/codes.d.ts.map +1 -1
  24. package/dist/errors/codes.js +10 -3
  25. package/dist/errors/codes.js.map +1 -1
  26. package/dist/errors/index.d.ts +8 -8
  27. package/dist/errors/index.d.ts.map +1 -1
  28. package/dist/errors/index.js +8 -8
  29. package/dist/errors/index.js.map +1 -1
  30. package/dist/errors/recovery.d.ts.map +1 -1
  31. package/dist/errors/recovery.js +10 -4
  32. package/dist/errors/recovery.js.map +1 -1
  33. package/dist/errors/specialized.d.ts +62 -21
  34. package/dist/errors/specialized.d.ts.map +1 -1
  35. package/dist/errors/specialized.js +128 -41
  36. package/dist/errors/specialized.js.map +1 -1
  37. package/dist/evm/extra-args.d.ts +25 -0
  38. package/dist/evm/extra-args.d.ts.map +1 -0
  39. package/dist/evm/extra-args.js +328 -0
  40. package/dist/evm/extra-args.js.map +1 -0
  41. package/dist/evm/gas.d.ts +14 -0
  42. package/dist/evm/gas.d.ts.map +1 -0
  43. package/dist/evm/gas.js +92 -0
  44. package/dist/evm/gas.js.map +1 -0
  45. package/dist/evm/index.d.ts +76 -32
  46. package/dist/evm/index.d.ts.map +1 -1
  47. package/dist/evm/index.js +94 -104
  48. package/dist/evm/index.js.map +1 -1
  49. package/dist/evm/offchain.d.ts.map +1 -1
  50. package/dist/evm/offchain.js +8 -8
  51. package/dist/evm/offchain.js.map +1 -1
  52. package/dist/execution.d.ts.map +1 -1
  53. package/dist/execution.js +24 -3
  54. package/dist/execution.js.map +1 -1
  55. package/dist/extra-args.d.ts +103 -4
  56. package/dist/extra-args.d.ts.map +1 -1
  57. package/dist/extra-args.js +28 -3
  58. package/dist/extra-args.js.map +1 -1
  59. package/dist/gas.d.ts +46 -19
  60. package/dist/gas.d.ts.map +1 -1
  61. package/dist/gas.js +56 -68
  62. package/dist/gas.js.map +1 -1
  63. package/dist/index.d.ts +18 -15
  64. package/dist/index.d.ts.map +1 -1
  65. package/dist/index.js +14 -13
  66. package/dist/index.js.map +1 -1
  67. package/dist/offchain.d.ts +5 -4
  68. package/dist/offchain.d.ts.map +1 -1
  69. package/dist/offchain.js +7 -6
  70. package/dist/offchain.js.map +1 -1
  71. package/dist/requests.d.ts +30 -20
  72. package/dist/requests.d.ts.map +1 -1
  73. package/dist/requests.js +86 -56
  74. package/dist/requests.js.map +1 -1
  75. package/dist/selectors.d.ts +2 -1
  76. package/dist/selectors.d.ts.map +1 -1
  77. package/dist/selectors.js +625 -278
  78. package/dist/selectors.js.map +1 -1
  79. package/dist/solana/exec.d.ts.map +1 -1
  80. package/dist/solana/exec.js +2 -1
  81. package/dist/solana/exec.js.map +1 -1
  82. package/dist/solana/index.d.ts +73 -22
  83. package/dist/solana/index.d.ts.map +1 -1
  84. package/dist/solana/index.js +91 -28
  85. package/dist/solana/index.js.map +1 -1
  86. package/dist/solana/offchain.js +2 -2
  87. package/dist/solana/offchain.js.map +1 -1
  88. package/dist/solana/send.d.ts.map +1 -1
  89. package/dist/solana/send.js +6 -9
  90. package/dist/solana/send.js.map +1 -1
  91. package/dist/solana/utils.d.ts +29 -1
  92. package/dist/solana/utils.d.ts.map +1 -1
  93. package/dist/solana/utils.js +39 -1
  94. package/dist/solana/utils.js.map +1 -1
  95. package/dist/sui/discovery.d.ts +7 -4
  96. package/dist/sui/discovery.d.ts.map +1 -1
  97. package/dist/sui/discovery.js +66 -19
  98. package/dist/sui/discovery.js.map +1 -1
  99. package/dist/sui/events.d.ts +23 -12
  100. package/dist/sui/events.d.ts.map +1 -1
  101. package/dist/sui/events.js +267 -128
  102. package/dist/sui/events.js.map +1 -1
  103. package/dist/sui/index.d.ts +57 -41
  104. package/dist/sui/index.d.ts.map +1 -1
  105. package/dist/sui/index.js +286 -159
  106. package/dist/sui/index.js.map +1 -1
  107. package/dist/sui/objects.d.ts +14 -4
  108. package/dist/sui/objects.d.ts.map +1 -1
  109. package/dist/sui/objects.js +61 -68
  110. package/dist/sui/objects.js.map +1 -1
  111. package/dist/sui/types.d.ts +33 -0
  112. package/dist/sui/types.d.ts.map +1 -1
  113. package/dist/sui/types.js.map +1 -1
  114. package/dist/ton/index.d.ts +67 -21
  115. package/dist/ton/index.d.ts.map +1 -1
  116. package/dist/ton/index.js +159 -30
  117. package/dist/ton/index.js.map +1 -1
  118. package/dist/ton/send.d.ts +52 -0
  119. package/dist/ton/send.d.ts.map +1 -0
  120. package/dist/ton/send.js +166 -0
  121. package/dist/ton/send.js.map +1 -0
  122. package/dist/ton/utils.d.ts +3 -3
  123. package/dist/ton/utils.d.ts.map +1 -1
  124. package/dist/ton/utils.js +6 -5
  125. package/dist/ton/utils.js.map +1 -1
  126. package/dist/types.d.ts +126 -9
  127. package/dist/types.d.ts.map +1 -1
  128. package/dist/types.js +19 -5
  129. package/dist/types.js.map +1 -1
  130. package/dist/utils.d.ts +67 -4
  131. package/dist/utils.d.ts.map +1 -1
  132. package/dist/utils.js +126 -17
  133. package/dist/utils.js.map +1 -1
  134. package/package.json +14 -9
  135. package/src/all-chains.ts +26 -0
  136. package/src/api/index.ts +348 -13
  137. package/src/api/types.ts +160 -13
  138. package/src/aptos/index.ts +98 -76
  139. package/src/aptos/logs.ts +3 -3
  140. package/src/chain.ts +408 -51
  141. package/src/errors/codes.ts +10 -3
  142. package/src/errors/index.ts +8 -5
  143. package/src/errors/recovery.ts +18 -5
  144. package/src/errors/specialized.ts +168 -49
  145. package/src/evm/extra-args.ts +377 -0
  146. package/src/evm/gas.ts +150 -0
  147. package/src/evm/index.ts +123 -155
  148. package/src/evm/offchain.ts +15 -9
  149. package/src/execution.ts +26 -3
  150. package/src/extra-args.ts +108 -4
  151. package/src/gas.ts +101 -115
  152. package/src/index.ts +27 -14
  153. package/src/offchain.ts +12 -6
  154. package/src/requests.ts +117 -67
  155. package/src/selectors.ts +632 -280
  156. package/src/solana/exec.ts +3 -1
  157. package/src/solana/index.ts +97 -37
  158. package/src/solana/offchain.ts +2 -2
  159. package/src/solana/send.ts +5 -23
  160. package/src/solana/utils.ts +66 -0
  161. package/src/sui/discovery.ts +92 -31
  162. package/src/sui/events.ts +346 -239
  163. package/src/sui/index.ts +365 -212
  164. package/src/sui/objects.ts +74 -98
  165. package/src/sui/types.ts +35 -0
  166. package/src/ton/index.ts +199 -35
  167. package/src/ton/send.ts +222 -0
  168. package/src/ton/utils.ts +7 -6
  169. package/src/types.ts +128 -9
  170. package/src/utils.ts +169 -21
@@ -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
- CCIPOnRampRequiredError,
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
- /** {@inheritDoc Chain.getTransaction} */
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.getTokenAdminRegistryFor} */
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 (typeof bytes === 'string' && !bytes.startsWith('0x')) {
505
- bytes = decodeBase64(bytes)
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
- if (dataLength(bytes) > 32) throw new CCIPAptosAddressInvalidError(hexlify(bytes))
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
- /** {@inheritDoc Chain.sendMessage} */
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
- /** {@inheritDoc Chain.generateUnsignedExecuteReport} */
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
- /** {@inheritDoc Chain.executeReport} */
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
- /** {@inheritDoc Chain.getRegistryTokenConfig} */
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.getTokenPoolConfigs} */
715
- async getTokenPoolConfigs(tokenPool: string): Promise<{
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
- const [
807
- [remoteToken],
808
- [remotePools],
809
- [inboundRateLimiterState],
810
- [outboundRateLimiterState],
811
- ] = await Promise.all([
812
- remoteToken$,
813
- remotePools$,
814
- inboundRateLimiterState$,
815
- outboundRateLimiterState$,
816
- ])
817
- return [
818
- chain.name,
819
- {
820
- remoteToken: decodeAddress(remoteToken, chain.family),
821
- remotePools: remotePools.map((pool) => decodeAddress(pool, chain.family)),
822
- inboundRateLimiterState: inboundRateLimiterState.is_enabled
823
- ? {
824
- capacity: BigInt(inboundRateLimiterState.capacity),
825
- lastUpdated: Number(inboundRateLimiterState.last_updated),
826
- rate: BigInt(inboundRateLimiterState.rate),
827
- tokens: BigInt(inboundRateLimiterState.tokens),
828
- }
829
- : null,
830
- outboundRateLimiterState: outboundRateLimiterState.is_enabled
831
- ? {
832
- capacity: BigInt(outboundRateLimiterState.capacity),
833
- lastUpdated: Number(outboundRateLimiterState.last_updated),
834
- rate: BigInt(outboundRateLimiterState.rate),
835
- tokens: BigInt(outboundRateLimiterState.tokens),
836
- }
837
- : null,
838
- },
839
- ] as const
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 CCIPAptosTopicInvalidError()
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 CCIPAptosTopicInvalidError(opts.topics[0])
252
+ if (!eventHandlerField) throw new CCIPTopicsInvalidError(opts.topics)
253
253
  }
254
254
  const [stateAddr] = await ctx.provider.view<[string]>({
255
255
  payload: {