@chainlink/ccip-sdk 0.97.0 → 1.0.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 (114) hide show
  1. package/README.md +12 -9
  2. package/dist/api/index.d.ts +4 -0
  3. package/dist/api/index.d.ts.map +1 -1
  4. package/dist/api/index.js +16 -4
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/aptos/index.d.ts +4 -6
  7. package/dist/aptos/index.d.ts.map +1 -1
  8. package/dist/aptos/index.js +0 -5
  9. package/dist/aptos/index.js.map +1 -1
  10. package/dist/aptos/logs.d.ts +2 -2
  11. package/dist/aptos/logs.d.ts.map +1 -1
  12. package/dist/chain.d.ts +11 -12
  13. package/dist/chain.d.ts.map +1 -1
  14. package/dist/chain.js +19 -1
  15. package/dist/chain.js.map +1 -1
  16. package/dist/errors/index.d.ts +3 -3
  17. package/dist/errors/index.d.ts.map +1 -1
  18. package/dist/errors/index.js +3 -3
  19. package/dist/errors/index.js.map +1 -1
  20. package/dist/evm/abi/OnRamp_2_0.d.ts +1 -1
  21. package/dist/evm/abi/OnRamp_2_0.js +1 -1
  22. package/dist/evm/abi/OnRamp_2_0.js.map +1 -1
  23. package/dist/evm/index.d.ts +1 -3
  24. package/dist/evm/index.d.ts.map +1 -1
  25. package/dist/evm/index.js +1 -5
  26. package/dist/evm/index.js.map +1 -1
  27. package/dist/evm/logs.d.ts +1 -1
  28. package/dist/evm/logs.js +1 -1
  29. package/dist/evm/offchain.d.ts +1 -14
  30. package/dist/evm/offchain.d.ts.map +1 -1
  31. package/dist/evm/offchain.js +1 -133
  32. package/dist/evm/offchain.js.map +1 -1
  33. package/dist/index.d.ts +3 -2
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -1
  36. package/dist/index.js.map +1 -1
  37. package/dist/offchain.d.ts +23 -6
  38. package/dist/offchain.d.ts.map +1 -1
  39. package/dist/offchain.js +92 -17
  40. package/dist/offchain.js.map +1 -1
  41. package/dist/requests.d.ts.map +1 -1
  42. package/dist/requests.js +0 -1
  43. package/dist/requests.js.map +1 -1
  44. package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.d.ts +1 -1
  45. package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.js +1 -1
  46. package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.d.ts +1 -1
  47. package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.js +1 -1
  48. package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.d.ts +1 -1
  49. package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.js +1 -1
  50. package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts +16 -1
  51. package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts.map +1 -1
  52. package/dist/solana/idl/1.6.0/CCIP_COMMON.js +16 -1
  53. package/dist/solana/idl/1.6.0/CCIP_COMMON.js.map +1 -1
  54. package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.d.ts +1 -1
  55. package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.js +1 -1
  56. package/dist/solana/idl/1.6.0/CCIP_ROUTER.d.ts +1 -1
  57. package/dist/solana/idl/1.6.0/CCIP_ROUTER.js +1 -1
  58. package/dist/solana/index.d.ts +6 -8
  59. package/dist/solana/index.d.ts.map +1 -1
  60. package/dist/solana/index.js +2 -7
  61. package/dist/solana/index.js.map +1 -1
  62. package/dist/solana/offchain.d.ts +1 -13
  63. package/dist/solana/offchain.d.ts.map +1 -1
  64. package/dist/solana/offchain.js +1 -66
  65. package/dist/solana/offchain.js.map +1 -1
  66. package/dist/solana/utils.d.ts +4 -4
  67. package/dist/solana/utils.d.ts.map +1 -1
  68. package/dist/solana/utils.js +1 -1
  69. package/dist/solana/utils.js.map +1 -1
  70. package/dist/sui/index.d.ts +4 -6
  71. package/dist/sui/index.d.ts.map +1 -1
  72. package/dist/sui/index.js +0 -5
  73. package/dist/sui/index.js.map +1 -1
  74. package/dist/ton/exec.d.ts +2 -2
  75. package/dist/ton/exec.d.ts.map +1 -1
  76. package/dist/ton/exec.js +1 -1
  77. package/dist/ton/exec.js.map +1 -1
  78. package/dist/ton/index.d.ts +5 -6
  79. package/dist/ton/index.d.ts.map +1 -1
  80. package/dist/ton/index.js +0 -4
  81. package/dist/ton/index.js.map +1 -1
  82. package/dist/ton/types.d.ts +3 -5
  83. package/dist/ton/types.d.ts.map +1 -1
  84. package/dist/ton/types.js.map +1 -1
  85. package/dist/types.d.ts +10 -10
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/types.js.map +1 -1
  88. package/package.json +9 -5
  89. package/src/api/index.ts +21 -8
  90. package/src/aptos/index.ts +4 -11
  91. package/src/aptos/logs.ts +2 -2
  92. package/src/chain.ts +17 -12
  93. package/src/errors/index.ts +3 -0
  94. package/src/evm/abi/OnRamp_2_0.ts +1 -1
  95. package/src/evm/index.ts +4 -10
  96. package/src/evm/logs.ts +1 -1
  97. package/src/evm/offchain.ts +2 -191
  98. package/src/index.ts +8 -1
  99. package/src/offchain.ts +125 -28
  100. package/src/requests.ts +2 -3
  101. package/src/solana/idl/1.6.0/BASE_TOKEN_POOL.ts +2 -2
  102. package/src/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.ts +2 -2
  103. package/src/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.ts +2 -2
  104. package/src/solana/idl/1.6.0/CCIP_COMMON.ts +32 -2
  105. package/src/solana/idl/1.6.0/CCIP_OFFRAMP.ts +2 -2
  106. package/src/solana/idl/1.6.0/CCIP_ROUTER.ts +2 -2
  107. package/src/solana/index.ts +10 -17
  108. package/src/solana/offchain.ts +3 -100
  109. package/src/solana/utils.ts +8 -5
  110. package/src/sui/index.ts +5 -12
  111. package/src/ton/exec.ts +3 -6
  112. package/src/ton/index.ts +10 -15
  113. package/src/ton/types.ts +3 -6
  114. package/src/types.ts +13 -10
package/src/sui/index.ts CHANGED
@@ -47,15 +47,14 @@ import {
47
47
  type CCIPMessage,
48
48
  type CCIPRequest,
49
49
  type CCIPVersion,
50
+ type ChainLog,
50
51
  type ChainTransaction,
51
52
  type CommitReport,
52
53
  type ExecutionInput,
53
54
  type ExecutionReceipt,
54
55
  type ExecutionState,
55
56
  type Lane,
56
- type Log_,
57
57
  type NetworkInfo,
58
- type OffchainTokenData,
59
58
  type WithLogger,
60
59
  ChainFamily,
61
60
  } from '../types.ts'
@@ -181,7 +180,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
181
180
  })
182
181
 
183
182
  // Extract events from the transaction
184
- const events: Log_[] = []
183
+ const events: ChainLog[] = []
185
184
  if (txResponse.events?.length) {
186
185
  for (const [i, event] of txResponse.events.entries()) {
187
186
  const eventType = event.type
@@ -576,7 +575,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
576
575
  * @returns Decoded CCIPMessage or undefined if not valid.
577
576
  * @throws {@link CCIPSuiLogInvalidError} if log data format is invalid
578
577
  */
579
- static decodeMessage(log: Log_): CCIPMessage | undefined {
578
+ static decodeMessage(log: ChainLog): CCIPMessage | undefined {
580
579
  const { data } = log
581
580
  if (
582
581
  (typeof data !== 'string' || !data.startsWith('{')) &&
@@ -622,7 +621,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
622
621
  * @returns Array of decoded commit reports or undefined.
623
622
  */
624
623
  static decodeCommits(
625
- { data, topics }: SetOptional<Pick<Log_, 'data' | 'topics'>, 'topics'>,
624
+ { data, topics }: SetOptional<Pick<ChainLog, 'data' | 'topics'>, 'topics'>,
626
625
  lane?: Lane,
627
626
  ): CommitReport[] | undefined {
628
627
  // Check if this is an CommitReportAccepted event
@@ -658,7 +657,7 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
658
657
  static decodeReceipt({
659
658
  data,
660
659
  topics,
661
- }: SetOptional<Pick<Log_, 'data' | 'topics'>, 'topics'>): ExecutionReceipt | undefined {
660
+ }: SetOptional<Pick<ChainLog, 'data' | 'topics'>, 'topics'>): ExecutionReceipt | undefined {
662
661
  // Check if this is an ExecutionStateChanged event
663
662
  if (topics?.[0] && topics[0] !== 'ExecutionStateChanged') return
664
663
 
@@ -728,12 +727,6 @@ export class SuiChain extends Chain<typeof ChainFamily.Sui> {
728
727
  return Promise.reject(new CCIPNotImplementedError('SuiChain.sendMessage'))
729
728
  }
730
729
 
731
- /** {@inheritDoc Chain.getOffchainTokenData} */
732
- getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
733
- // default offchain token data
734
- return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
735
- }
736
-
737
730
  /** {@inheritDoc Chain.generateUnsignedExecute} */
738
731
  override generateUnsignedExecute(
739
732
  _opts: Parameters<Chain['generateUnsignedExecute']>[0],
package/src/ton/exec.ts CHANGED
@@ -1,11 +1,8 @@
1
1
  import { type Cell, beginCell } from '@ton/core'
2
2
 
3
3
  import type { ExecutionInput } from '../types.ts'
4
- import {
5
- type CCIPMessage_V1_6_TON,
6
- MANUALLY_EXECUTE_OPCODE,
7
- serializeExecutionReport,
8
- } from './types.ts'
4
+ import { MANUALLY_EXECUTE_OPCODE, serializeExecutionReport } from './types.ts'
5
+ import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
9
6
 
10
7
  /**
11
8
  * Generates an unsigned execute report payload for the TON OffRamp contract.
@@ -17,7 +14,7 @@ import {
17
14
  */
18
15
  export function generateUnsignedExecuteReport(
19
16
  offRamp: string,
20
- execReport: ExecutionInput<CCIPMessage_V1_6_TON>,
17
+ execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
21
18
  opts?: { gasLimit?: number },
22
19
  ): { to: string; body: Cell } {
23
20
  // Serialize the execution report
package/src/ton/index.ts CHANGED
@@ -29,14 +29,13 @@ import { supportedChains } from '../supported-chains.ts'
29
29
  import {
30
30
  type CCIPExecution,
31
31
  type CCIPRequest,
32
+ type ChainLog,
32
33
  type ChainTransaction,
33
34
  type CommitReport,
34
35
  type ExecutionInput,
35
36
  type ExecutionReceipt,
36
37
  type Lane,
37
- type Log_,
38
38
  type NetworkInfo,
39
- type OffchainTokenData,
40
39
  type WithLogger,
41
40
  CCIPVersion,
42
41
  ChainFamily,
@@ -52,8 +51,9 @@ import {
52
51
  } from '../utils.ts'
53
52
  import { generateUnsignedExecuteReport } from './exec.ts'
54
53
  import { getTONLeafHasher } from './hasher.ts'
55
- import { type CCIPMessage_V1_6_TON, type UnsignedTONTx, isTONWallet } from './types.ts'
54
+ import { type UnsignedTONTx, isTONWallet } from './types.ts'
56
55
  import { crc32, lookupTxByRawHash, parseJettonContent } from './utils.ts'
56
+ import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
57
57
  export type { TONWallet, UnsignedTONTx } from './types.ts'
58
58
 
59
59
  /**
@@ -308,13 +308,13 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
308
308
  const compositeHash = `${address.toRawString()}:${tx.lt}:${tx.hash().toString('hex')}`
309
309
  const res = {
310
310
  hash: compositeHash,
311
- logs: [] as Log_[],
311
+ logs: [] as ChainLog[],
312
312
  blockNumber: Number(tx.lt), // Note: This is lt (logical time), not block seqno
313
313
  timestamp: tx.now,
314
314
  from: address.toRawString(),
315
315
  tx,
316
316
  }
317
- const logs: Log_[] = []
317
+ const logs: ChainLog[] = []
318
318
  for (const [index, msg] of tx.outMessages) {
319
319
  if (msg.info.type !== 'external-out') continue
320
320
  const topics = []
@@ -350,7 +350,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
350
350
  * @param opts - Log filter options (startBlock/endBlock are interpreted as lt values)
351
351
  * @throws {@link CCIPTopicsInvalidError} if topics format is invalid
352
352
  */
353
- async *getLogs(opts: LogFilter): AsyncIterableIterator<Log_> {
353
+ async *getLogs(opts: LogFilter): AsyncIterableIterator<ChainLog> {
354
354
  let topics
355
355
  if (opts.topics?.length) {
356
356
  if (!opts.topics.every((topic) => typeof topic === 'string'))
@@ -587,7 +587,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
587
587
  }: {
588
588
  data: unknown
589
589
  topics?: readonly string[]
590
- }): CCIPMessage_V1_6_TON | undefined {
590
+ }): CCIPMessage_V1_6_EVM | undefined {
591
591
  if (!data || typeof data !== 'string') return
592
592
  if (topics?.length && topics[0] !== crc32('CCIPMessageSent')) return
593
593
 
@@ -660,7 +660,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
660
660
 
661
661
  // Load tokenAmounts from ref 3
662
662
  const _tokenAmountsCell = bodySlice.loadRef()
663
- const tokenAmounts: CCIPMessage_V1_6_TON['tokenAmounts'] = [] // TODO: FIXME: parse when implemented
663
+ const tokenAmounts: CCIPMessage_V1_6_EVM['tokenAmounts'] = [] // TODO: FIXME: parse when implemented
664
664
 
665
665
  // Load feeToken (inline address in body)
666
666
  const feeToken = bodySlice.loadMaybeAddress()?.toString() ?? ''
@@ -1099,11 +1099,6 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
1099
1099
  throw new CCIPTransactionNotFoundError(seqno.toString())
1100
1100
  }
1101
1101
 
1102
- /** {@inheritDoc Chain.getOffchainTokenData} */
1103
- getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]> {
1104
- return Promise.resolve(request.message.tokenAmounts.map(() => undefined))
1105
- }
1106
-
1107
1102
  /**
1108
1103
  * {@inheritDoc Chain.generateUnsignedExecute}
1109
1104
  * @throws {@link CCIPExtraArgsInvalidError} if extra args are not EVMExtraArgsV2 format
@@ -1125,7 +1120,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
1125
1120
 
1126
1121
  const unsigned = generateUnsignedExecuteReport(
1127
1122
  offRamp,
1128
- input as ExecutionInput<CCIPMessage_V1_6_TON>,
1123
+ input as ExecutionInput<CCIPMessage_V1_6_EVM>,
1129
1124
  opts,
1130
1125
  )
1131
1126
 
@@ -1161,7 +1156,7 @@ export class TONChain extends Chain<typeof ChainFamily.TON> {
1161
1156
  ...unsigned,
1162
1157
  })
1163
1158
 
1164
- const message = opts.input.message as CCIPMessage_V1_6_TON
1159
+ const message = opts.input.message as CCIPMessage_V1_6_EVM
1165
1160
  for await (const exec of this.getExecutionReceipts({
1166
1161
  offRamp,
1167
1162
  messageId: message.messageId,
package/src/ton/types.ts CHANGED
@@ -2,13 +2,10 @@ import { type Builder, Address, Cell, beginCell } from '@ton/core'
2
2
  import { toBigInt } from 'ethers'
3
3
 
4
4
  import { CCIPDataFormatUnsupportedError } from '../errors/specialized.ts'
5
- import type { EVMExtraArgsV2 } from '../extra-args.ts'
5
+ import type { CCIPMessage_V1_6_EVM } from '../evm/messages.ts'
6
6
  import type { CCIPMessage_V1_6, ChainFamily, ExecutionInput } from '../types.ts'
7
7
  import { bytesToBuffer } from '../utils.ts'
8
8
 
9
- /** TON-specific CCIP v1.6 message type with EVMExtraArgsV2 (GenericExtraArgsV2) */
10
- export type CCIPMessage_V1_6_TON = CCIPMessage_V1_6 & EVMExtraArgsV2
11
-
12
9
  /** Opcode for OffRamp_ManuallyExecute message on TON */
13
10
  export const MANUALLY_EXECUTE_OPCODE = 0xa00785cf
14
11
 
@@ -83,7 +80,7 @@ function asSnakeData<T>(array: T[], builderFn: (item: T) => Builder): Cell {
83
80
  * @returns BOC-serialized Cell containing the execution report.
84
81
  */
85
82
  export function serializeExecutionReport(
86
- execReport: ExecutionInput<CCIPMessage_V1_6_TON>,
83
+ execReport: ExecutionInput<CCIPMessage_V1_6_EVM>,
87
84
  ): Builder {
88
85
  return beginCell()
89
86
  .storeUint(execReport.message.sourceChainSelector, 64)
@@ -97,7 +94,7 @@ export function serializeExecutionReport(
97
94
  .storeUint(execReport.proofFlagBits, 256)
98
95
  }
99
96
 
100
- function serializeMessage(message: CCIPMessage_V1_6_TON): Builder {
97
+ function serializeMessage(message: CCIPMessage_V1_6_EVM): Builder {
101
98
  return beginCell()
102
99
  .storeUint(BigInt(message.messageId), 256)
103
100
  .storeUint(message.sourceChainSelector, 64)
package/src/types.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AbiParametersToPrimitiveTypes, ExtractAbiEvent } from 'abitype'
2
- import type { BytesLike, Log } from 'ethers'
2
+ import type { BytesLike, Log as EVMLog } from 'ethers'
3
+ import type { SetOptional } from 'type-fest'
3
4
 
4
5
  import type { APICCIPRequestMetadata } from './api/types.ts'
5
6
  import type OffRamp_1_6_ABI from './evm/abi/OffRamp_1_6.ts'
@@ -7,7 +8,6 @@ import type { CCIPMessage_EVM, CCIPMessage_V1_6_EVM, CCIPMessage_V2_0 } from './
7
8
  import type { ExtraArgs } from './extra-args.ts'
8
9
  import type { CCIPMessage_V1_6_Solana } from './solana/types.ts'
9
10
  import type { CCIPMessage_V1_6_Sui } from './sui/types.ts'
10
- import type { CCIPMessage_V1_6_TON } from './ton/types.ts'
11
11
  // v1.6 Base type from EVM contains the intersection of all other CCIPMessage v1.6 types
12
12
  export type { CCIPMessage_V1_6 } from './evm/messages.ts'
13
13
 
@@ -157,17 +157,20 @@ export interface Lane<V extends CCIPVersion = CCIPVersion> {
157
157
  export type CCIPMessage<V extends CCIPVersion = CCIPVersion> = V extends typeof CCIPVersion.V2_0
158
158
  ? CCIPMessage_V2_0
159
159
  : V extends typeof CCIPVersion.V1_6
160
- ? CCIPMessage_V1_6_EVM | CCIPMessage_V1_6_Solana | CCIPMessage_V1_6_Sui | CCIPMessage_V1_6_TON
160
+ ? CCIPMessage_V1_6_EVM | CCIPMessage_V1_6_Solana | CCIPMessage_V1_6_Sui
161
161
  : CCIPMessage_EVM<V>
162
162
 
163
163
  /**
164
164
  * Generic log structure compatible across chain families.
165
165
  */
166
- export type Log_ = Pick<Log, 'topics' | 'index' | 'address' | 'blockNumber' | 'transactionHash'> & {
166
+ export type ChainLog = Pick<
167
+ EVMLog,
168
+ 'topics' | 'index' | 'address' | 'blockNumber' | 'transactionHash'
169
+ > & {
167
170
  /** Log data as bytes or parsed object. */
168
171
  data: BytesLike | Record<string, unknown>
169
172
  /** Optional reference to the containing transaction. */
170
- tx?: ChainTransaction
173
+ tx?: SetOptional<ChainTransaction, 'logs'>
171
174
  }
172
175
 
173
176
  /**
@@ -188,7 +191,7 @@ export type ChainTransaction = {
188
191
  /** Transaction hash. */
189
192
  hash: string
190
193
  /** Logs emitted by this transaction. */
191
- logs: readonly Log_[]
194
+ logs: readonly ChainLog[]
192
195
  /** Block number containing this transaction. */
193
196
  blockNumber: number
194
197
  /** Unix timestamp of the block. */
@@ -206,9 +209,9 @@ export interface CCIPRequest<V extends CCIPVersion = CCIPVersion> {
206
209
  /** Lane configuration for this request. */
207
210
  lane: Lane<V>
208
211
  message: CCIPMessage<V>
209
- log: Log_
212
+ log: ChainLog
210
213
  /** Transaction that emitted the request. */
211
- tx: Pick<ChainTransaction, 'hash' | 'logs' | 'blockNumber' | 'timestamp' | 'from' | 'error'>
214
+ tx: Omit<ChainTransaction, 'logs'>
212
215
 
213
216
  /**
214
217
  * API-enriched metadata. Present only when fetched via CCIP API.
@@ -263,7 +266,7 @@ export type CCIPVerifications =
263
266
  /** The commit report data. */
264
267
  report: CommitReport
265
268
  /** Log event from the commit. */
266
- log: Log_
269
+ log: ChainLog
267
270
  }
268
271
  | {
269
272
  /** Policy for this request */
@@ -373,7 +376,7 @@ export interface CCIPExecution {
373
376
  /** Execution receipt data. */
374
377
  receipt: ExecutionReceipt
375
378
  /** Log event from the execution. */
376
- log: Log_
379
+ log: ChainLog
377
380
  /** Unix timestamp of the execution. */
378
381
  timestamp: number
379
382
  }