@chainlink/ccip-sdk 0.96.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 (247) hide show
  1. package/README.md +12 -9
  2. package/dist/api/index.d.ts +21 -8
  3. package/dist/api/index.d.ts.map +1 -1
  4. package/dist/api/index.js +42 -13
  5. package/dist/api/index.js.map +1 -1
  6. package/dist/api/types.d.ts +0 -2
  7. package/dist/api/types.d.ts.map +1 -1
  8. package/dist/aptos/exec.d.ts +2 -2
  9. package/dist/aptos/exec.d.ts.map +1 -1
  10. package/dist/aptos/exec.js.map +1 -1
  11. package/dist/aptos/hasher.d.ts.map +1 -1
  12. package/dist/aptos/hasher.js +1 -1
  13. package/dist/aptos/hasher.js.map +1 -1
  14. package/dist/aptos/index.d.ts +17 -16
  15. package/dist/aptos/index.d.ts.map +1 -1
  16. package/dist/aptos/index.js +42 -73
  17. package/dist/aptos/index.js.map +1 -1
  18. package/dist/aptos/logs.d.ts +2 -2
  19. package/dist/aptos/logs.d.ts.map +1 -1
  20. package/dist/aptos/types.d.ts +2 -19
  21. package/dist/aptos/types.d.ts.map +1 -1
  22. package/dist/aptos/types.js +0 -11
  23. package/dist/aptos/types.js.map +1 -1
  24. package/dist/chain.d.ts +538 -158
  25. package/dist/chain.d.ts.map +1 -1
  26. package/dist/chain.js +132 -19
  27. package/dist/chain.js.map +1 -1
  28. package/dist/commits.d.ts +4 -6
  29. package/dist/commits.d.ts.map +1 -1
  30. package/dist/commits.js +4 -4
  31. package/dist/commits.js.map +1 -1
  32. package/dist/errors/CCIPError.d.ts +33 -4
  33. package/dist/errors/CCIPError.d.ts.map +1 -1
  34. package/dist/errors/CCIPError.js +33 -4
  35. package/dist/errors/CCIPError.js.map +1 -1
  36. package/dist/errors/codes.d.ts +3 -0
  37. package/dist/errors/codes.d.ts.map +1 -1
  38. package/dist/errors/codes.js +3 -1
  39. package/dist/errors/codes.js.map +1 -1
  40. package/dist/errors/index.d.ts +4 -4
  41. package/dist/errors/index.d.ts.map +1 -1
  42. package/dist/errors/index.js +4 -4
  43. package/dist/errors/index.js.map +1 -1
  44. package/dist/errors/recovery.d.ts.map +1 -1
  45. package/dist/errors/recovery.js +4 -1
  46. package/dist/errors/recovery.js.map +1 -1
  47. package/dist/errors/specialized.d.ts +1695 -120
  48. package/dist/errors/specialized.d.ts.map +1 -1
  49. package/dist/errors/specialized.js +1715 -123
  50. package/dist/errors/specialized.js.map +1 -1
  51. package/dist/errors/utils.d.ts.map +1 -1
  52. package/dist/errors/utils.js +0 -1
  53. package/dist/errors/utils.js.map +1 -1
  54. package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
  55. package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
  56. package/dist/evm/abi/OffRamp_2_0.js +744 -0
  57. package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
  58. package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
  59. package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
  60. package/dist/evm/abi/OnRamp_2_0.js +992 -0
  61. package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
  62. package/dist/evm/const.d.ts +12 -2
  63. package/dist/evm/const.d.ts.map +1 -1
  64. package/dist/evm/const.js +8 -2
  65. package/dist/evm/const.js.map +1 -1
  66. package/dist/evm/errors.d.ts.map +1 -1
  67. package/dist/evm/errors.js +7 -2
  68. package/dist/evm/errors.js.map +1 -1
  69. package/dist/evm/extra-args.d.ts.map +1 -1
  70. package/dist/evm/extra-args.js +5 -24
  71. package/dist/evm/extra-args.js.map +1 -1
  72. package/dist/evm/hasher.d.ts.map +1 -1
  73. package/dist/evm/hasher.js +23 -13
  74. package/dist/evm/hasher.js.map +1 -1
  75. package/dist/evm/index.d.ts +73 -16
  76. package/dist/evm/index.d.ts.map +1 -1
  77. package/dist/evm/index.js +241 -146
  78. package/dist/evm/index.js.map +1 -1
  79. package/dist/evm/logs.d.ts +1 -1
  80. package/dist/evm/logs.js +1 -1
  81. package/dist/evm/messages.d.ts +59 -5
  82. package/dist/evm/messages.d.ts.map +1 -1
  83. package/dist/evm/messages.js +210 -0
  84. package/dist/evm/messages.js.map +1 -1
  85. package/dist/evm/offchain.d.ts +1 -14
  86. package/dist/evm/offchain.d.ts.map +1 -1
  87. package/dist/evm/offchain.js +1 -133
  88. package/dist/evm/offchain.js.map +1 -1
  89. package/dist/evm/types.d.ts +7 -2
  90. package/dist/evm/types.d.ts.map +1 -1
  91. package/dist/evm/types.js +22 -1
  92. package/dist/evm/types.js.map +1 -1
  93. package/dist/execution.d.ts +62 -22
  94. package/dist/execution.d.ts.map +1 -1
  95. package/dist/execution.js +98 -61
  96. package/dist/execution.js.map +1 -1
  97. package/dist/extra-args.d.ts +13 -3
  98. package/dist/extra-args.d.ts.map +1 -1
  99. package/dist/extra-args.js +13 -3
  100. package/dist/extra-args.js.map +1 -1
  101. package/dist/gas.d.ts +25 -2
  102. package/dist/gas.d.ts.map +1 -1
  103. package/dist/gas.js +30 -4
  104. package/dist/gas.js.map +1 -1
  105. package/dist/index.d.ts +3 -2
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -1
  108. package/dist/index.js.map +1 -1
  109. package/dist/offchain.d.ts +23 -6
  110. package/dist/offchain.d.ts.map +1 -1
  111. package/dist/offchain.js +92 -17
  112. package/dist/offchain.js.map +1 -1
  113. package/dist/requests.d.ts +85 -14
  114. package/dist/requests.d.ts.map +1 -1
  115. package/dist/requests.js +99 -17
  116. package/dist/requests.js.map +1 -1
  117. package/dist/selectors.d.ts.map +1 -1
  118. package/dist/selectors.js +12 -0
  119. package/dist/selectors.js.map +1 -1
  120. package/dist/shared/bcs-codecs.d.ts +61 -0
  121. package/dist/shared/bcs-codecs.d.ts.map +1 -0
  122. package/dist/shared/bcs-codecs.js +102 -0
  123. package/dist/shared/bcs-codecs.js.map +1 -0
  124. package/dist/shared/constants.d.ts +3 -0
  125. package/dist/shared/constants.d.ts.map +1 -0
  126. package/dist/shared/constants.js +3 -0
  127. package/dist/shared/constants.js.map +1 -0
  128. package/dist/solana/exec.d.ts +2 -2
  129. package/dist/solana/exec.d.ts.map +1 -1
  130. package/dist/solana/exec.js.map +1 -1
  131. package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.d.ts +1 -1
  132. package/dist/solana/idl/1.6.0/BASE_TOKEN_POOL.js +1 -1
  133. package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.d.ts +1 -1
  134. package/dist/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.js +1 -1
  135. package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.d.ts +1 -1
  136. package/dist/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.js +1 -1
  137. package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts +16 -1
  138. package/dist/solana/idl/1.6.0/CCIP_COMMON.d.ts.map +1 -1
  139. package/dist/solana/idl/1.6.0/CCIP_COMMON.js +16 -1
  140. package/dist/solana/idl/1.6.0/CCIP_COMMON.js.map +1 -1
  141. package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.d.ts +1 -1
  142. package/dist/solana/idl/1.6.0/CCIP_OFFRAMP.js +1 -1
  143. package/dist/solana/idl/1.6.0/CCIP_ROUTER.d.ts +1 -1
  144. package/dist/solana/idl/1.6.0/CCIP_ROUTER.js +1 -1
  145. package/dist/solana/index.d.ts +85 -24
  146. package/dist/solana/index.d.ts.map +1 -1
  147. package/dist/solana/index.js +69 -37
  148. package/dist/solana/index.js.map +1 -1
  149. package/dist/solana/offchain.d.ts +1 -13
  150. package/dist/solana/offchain.d.ts.map +1 -1
  151. package/dist/solana/offchain.js +1 -66
  152. package/dist/solana/offchain.js.map +1 -1
  153. package/dist/solana/utils.d.ts +4 -4
  154. package/dist/solana/utils.d.ts.map +1 -1
  155. package/dist/solana/utils.js +1 -1
  156. package/dist/solana/utils.js.map +1 -1
  157. package/dist/sui/hasher.d.ts.map +1 -1
  158. package/dist/sui/hasher.js +1 -1
  159. package/dist/sui/hasher.js.map +1 -1
  160. package/dist/sui/index.d.ts +18 -18
  161. package/dist/sui/index.d.ts.map +1 -1
  162. package/dist/sui/index.js +38 -39
  163. package/dist/sui/index.js.map +1 -1
  164. package/dist/sui/manuallyExec/encoder.d.ts +2 -2
  165. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  166. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  167. package/dist/sui/manuallyExec/index.d.ts +2 -2
  168. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  169. package/dist/ton/exec.d.ts +3 -3
  170. package/dist/ton/exec.d.ts.map +1 -1
  171. package/dist/ton/exec.js +1 -1
  172. package/dist/ton/exec.js.map +1 -1
  173. package/dist/ton/index.d.ts +14 -22
  174. package/dist/ton/index.d.ts.map +1 -1
  175. package/dist/ton/index.js +26 -35
  176. package/dist/ton/index.js.map +1 -1
  177. package/dist/ton/types.d.ts +3 -5
  178. package/dist/ton/types.d.ts.map +1 -1
  179. package/dist/ton/types.js.map +1 -1
  180. package/dist/types.d.ts +55 -20
  181. package/dist/types.d.ts.map +1 -1
  182. package/dist/types.js +6 -1
  183. package/dist/types.js.map +1 -1
  184. package/dist/utils.d.ts +65 -2
  185. package/dist/utils.d.ts.map +1 -1
  186. package/dist/utils.js +74 -2
  187. package/dist/utils.js.map +1 -1
  188. package/package.json +14 -10
  189. package/src/api/index.ts +53 -17
  190. package/src/api/types.ts +0 -2
  191. package/src/aptos/exec.ts +2 -2
  192. package/src/aptos/hasher.ts +1 -1
  193. package/src/aptos/index.ts +55 -100
  194. package/src/aptos/logs.ts +2 -2
  195. package/src/aptos/types.ts +2 -15
  196. package/src/chain.ts +594 -171
  197. package/src/commits.ts +9 -9
  198. package/src/errors/CCIPError.ts +33 -4
  199. package/src/errors/codes.ts +3 -1
  200. package/src/errors/index.ts +4 -0
  201. package/src/errors/recovery.ts +7 -1
  202. package/src/errors/specialized.ts +1726 -130
  203. package/src/errors/utils.ts +0 -1
  204. package/src/evm/abi/OffRamp_2_0.ts +743 -0
  205. package/src/evm/abi/OnRamp_2_0.ts +991 -0
  206. package/src/evm/const.ts +10 -3
  207. package/src/evm/errors.ts +6 -2
  208. package/src/evm/extra-args.ts +4 -21
  209. package/src/evm/hasher.ts +30 -18
  210. package/src/evm/index.ts +314 -176
  211. package/src/evm/logs.ts +1 -1
  212. package/src/evm/messages.ts +323 -11
  213. package/src/evm/offchain.ts +2 -191
  214. package/src/evm/types.ts +20 -2
  215. package/src/execution.ts +125 -86
  216. package/src/extra-args.ts +13 -3
  217. package/src/gas.ts +29 -3
  218. package/src/index.ts +10 -3
  219. package/src/offchain.ts +125 -28
  220. package/src/requests.ts +114 -19
  221. package/src/selectors.ts +12 -0
  222. package/src/shared/bcs-codecs.ts +132 -0
  223. package/src/shared/constants.ts +2 -0
  224. package/src/solana/exec.ts +4 -4
  225. package/src/solana/idl/1.6.0/BASE_TOKEN_POOL.ts +2 -2
  226. package/src/solana/idl/1.6.0/BURN_MINT_TOKEN_POOL.ts +2 -2
  227. package/src/solana/idl/1.6.0/CCIP_CCTP_TOKEN_POOL.ts +2 -2
  228. package/src/solana/idl/1.6.0/CCIP_COMMON.ts +32 -2
  229. package/src/solana/idl/1.6.0/CCIP_OFFRAMP.ts +2 -2
  230. package/src/solana/idl/1.6.0/CCIP_ROUTER.ts +2 -2
  231. package/src/solana/index.ts +110 -85
  232. package/src/solana/offchain.ts +3 -100
  233. package/src/solana/utils.ts +8 -5
  234. package/src/sui/hasher.ts +1 -1
  235. package/src/sui/index.ts +55 -59
  236. package/src/sui/manuallyExec/encoder.ts +2 -2
  237. package/src/sui/manuallyExec/index.ts +2 -2
  238. package/src/ton/exec.ts +4 -7
  239. package/src/ton/index.ts +45 -53
  240. package/src/ton/types.ts +4 -7
  241. package/src/types.ts +81 -37
  242. package/src/utils.ts +73 -2
  243. package/dist/aptos/utils.d.ts +0 -12
  244. package/dist/aptos/utils.d.ts.map +0 -1
  245. package/dist/aptos/utils.js +0 -15
  246. package/dist/aptos/utils.js.map +0 -1
  247. package/src/aptos/utils.ts +0 -24
@@ -2,7 +2,23 @@ import { CCIPError } from "./CCIPError.js";
2
2
  import { CCIPErrorCode } from "./codes.js";
3
3
  import { isTransientHttpStatus } from "../http-status.js";
4
4
  // Chain/Network
5
- /** Thrown when chain not found by chainId, selector, or name. */
5
+ /**
6
+ * Thrown when chain not found by chainId, selector, or name.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { networkInfo } from '@chainlink/ccip-sdk'
11
+ *
12
+ * try {
13
+ * const info = networkInfo(999999) // Unknown chain
14
+ * } catch (error) {
15
+ * if (error instanceof CCIPChainNotFoundError) {
16
+ * console.log(`Chain not found: ${error.context.chainIdOrSelector}`)
17
+ * console.log(`Recovery: ${error.recovery}`)
18
+ * }
19
+ * }
20
+ * ```
21
+ */
6
22
  export class CCIPChainNotFoundError extends CCIPError {
7
23
  name = 'CCIPChainNotFoundError';
8
24
  /** Creates a chain not found error. */
@@ -14,7 +30,20 @@ export class CCIPChainNotFoundError extends CCIPError {
14
30
  });
15
31
  }
16
32
  }
17
- /** Thrown when chain family is not supported. */
33
+ /**
34
+ * Thrown when chain family is not supported.
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * try {
39
+ * const chain = await createChain('unsupported-family')
40
+ * } catch (error) {
41
+ * if (error instanceof CCIPChainFamilyUnsupportedError) {
42
+ * console.log(`Unsupported family: ${error.context.family}`)
43
+ * }
44
+ * }
45
+ * ```
46
+ */
18
47
  export class CCIPChainFamilyUnsupportedError extends CCIPError {
19
48
  name = 'CCIPChainFamilyUnsupportedError';
20
49
  /** Creates a chain family unsupported error. */
@@ -26,7 +55,20 @@ export class CCIPChainFamilyUnsupportedError extends CCIPError {
26
55
  });
27
56
  }
28
57
  }
29
- /** Thrown when some method/operation is not supported on a given implementation class. */
58
+ /**
59
+ * Thrown when a method or operation is not supported on a given implementation class.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * try {
64
+ * await chain.someUnsupportedMethod()
65
+ * } catch (error) {
66
+ * if (error instanceof CCIPMethodUnsupportedError) {
67
+ * console.log(`Method not supported: ${error.context.class}.${error.context.method}`)
68
+ * }
69
+ * }
70
+ * ```
71
+ */
30
72
  export class CCIPMethodUnsupportedError extends CCIPError {
31
73
  name = 'CCIPMethodUnsupportedError';
32
74
  /** Creates a method unsupported error. */
@@ -39,7 +81,22 @@ export class CCIPMethodUnsupportedError extends CCIPError {
39
81
  }
40
82
  }
41
83
  // Block & Transaction
42
- /** Thrown when block not found. Transient: block may not be indexed yet. */
84
+ /**
85
+ * Thrown when block not found. Transient: block may not be indexed yet.
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * try {
90
+ * const timestamp = await chain.getBlockTimestamp(999999999)
91
+ * } catch (error) {
92
+ * if (error instanceof CCIPBlockNotFoundError) {
93
+ * if (error.isTransient) {
94
+ * console.log(`Block not indexed yet, retry in ${error.retryAfterMs}ms`)
95
+ * }
96
+ * }
97
+ * }
98
+ * ```
99
+ */
43
100
  export class CCIPBlockNotFoundError extends CCIPError {
44
101
  name = 'CCIPBlockNotFoundError';
45
102
  /** Creates a block not found error. */
@@ -52,7 +109,23 @@ export class CCIPBlockNotFoundError extends CCIPError {
52
109
  });
53
110
  }
54
111
  }
55
- /** Thrown when transaction not found. Transient: tx may be pending. */
112
+ /**
113
+ * Thrown when transaction not found. Transient: tx may be pending.
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * try {
118
+ * const tx = await chain.getTransaction('0x1234...')
119
+ * } catch (error) {
120
+ * if (error instanceof CCIPTransactionNotFoundError) {
121
+ * if (error.isTransient) {
122
+ * await sleep(error.retryAfterMs ?? 5000)
123
+ * // Retry the operation
124
+ * }
125
+ * }
126
+ * }
127
+ * ```
128
+ */
56
129
  export class CCIPTransactionNotFoundError extends CCIPError {
57
130
  name = 'CCIPTransactionNotFoundError';
58
131
  /** Creates a transaction not found error. */
@@ -66,7 +139,20 @@ export class CCIPTransactionNotFoundError extends CCIPError {
66
139
  }
67
140
  }
68
141
  // CCIP Message
69
- /** Thrown when message format is invalid. */
142
+ /**
143
+ * Thrown when message format is invalid.
144
+ *
145
+ * @example
146
+ * ```typescript
147
+ * try {
148
+ * const message = EVMChain.decodeMessage(invalidLog)
149
+ * } catch (error) {
150
+ * if (error instanceof CCIPMessageInvalidError) {
151
+ * console.log(`Invalid message format: ${error.message}`)
152
+ * }
153
+ * }
154
+ * ```
155
+ */
70
156
  export class CCIPMessageInvalidError extends CCIPError {
71
157
  name = 'CCIPMessageInvalidError';
72
158
  /** Creates a message invalid error. */
@@ -79,20 +165,49 @@ export class CCIPMessageInvalidError extends CCIPError {
79
165
  });
80
166
  }
81
167
  }
82
- /** Thrown when no CCIPSendRequested event in tx. Transient: tx may not be indexed. */
168
+ /**
169
+ * Thrown when no CCIPSendRequested event in tx. Transient: tx may not be indexed.
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * try {
174
+ * const messages = await chain.getMessagesInTx('0x1234...')
175
+ * } catch (error) {
176
+ * if (error instanceof CCIPMessageNotFoundInTxError) {
177
+ * if (error.isTransient) {
178
+ * console.log(`Message not indexed yet, retry in ${error.retryAfterMs}ms`)
179
+ * }
180
+ * }
181
+ * }
182
+ * ```
183
+ */
83
184
  export class CCIPMessageNotFoundInTxError extends CCIPError {
84
185
  name = 'CCIPMessageNotFoundInTxError';
85
186
  /** Creates a message not found in transaction error. */
86
187
  constructor(txHash, options) {
87
- super(CCIPErrorCode.MESSAGE_NOT_FOUND_IN_TX, `Could not find any CCIPSendRequested message in tx: ${txHash}`, {
188
+ super(CCIPErrorCode.MESSAGE_NOT_FOUND_IN_TX, `Could not find any CCIP request event in tx`, {
88
189
  ...options,
89
- isTransient: true,
90
- retryAfterMs: 30000,
190
+ isTransient: false,
91
191
  context: { ...options?.context, txHash },
92
192
  });
93
193
  }
94
194
  }
95
- /** Thrown when message with messageId not found. Transient: message may be in transit. */
195
+ /**
196
+ * Thrown when message with messageId not found. Transient: message may be in transit.
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * try {
201
+ * const request = await getMessageById(chain, messageId, onRamp)
202
+ * } catch (error) {
203
+ * if (error instanceof CCIPMessageIdNotFoundError) {
204
+ * if (error.isTransient) {
205
+ * console.log(`Message in transit, retry in ${error.retryAfterMs}ms`)
206
+ * }
207
+ * }
208
+ * }
209
+ * ```
210
+ */
96
211
  export class CCIPMessageIdNotFoundError extends CCIPError {
97
212
  name = 'CCIPMessageIdNotFoundError';
98
213
  /** Creates a message ID not found error. */
@@ -105,7 +220,21 @@ export class CCIPMessageIdNotFoundError extends CCIPError {
105
220
  });
106
221
  }
107
222
  }
108
- /** Thrown when messageId format is invalid. */
223
+ /**
224
+ * Thrown when messageId format is invalid.
225
+ *
226
+ * @example
227
+ * ```typescript
228
+ * try {
229
+ * const request = await chain.getMessageById('invalid-format')
230
+ * } catch (error) {
231
+ * if (error instanceof CCIPMessageIdValidationError) {
232
+ * console.log(`Invalid messageId: ${error.message}`)
233
+ * // Not transient - fix the messageId format
234
+ * }
235
+ * }
236
+ * ```
237
+ */
109
238
  export class CCIPMessageIdValidationError extends CCIPError {
110
239
  name = 'CCIPMessageIdValidationError';
111
240
  /** Creates a message ID validation error. */
@@ -116,7 +245,23 @@ export class CCIPMessageIdValidationError extends CCIPError {
116
245
  });
117
246
  }
118
247
  }
119
- /** Thrown when not all messages in batch were found. Transient: may still be indexing. */
248
+ /**
249
+ * Thrown when not all messages in batch were found. Transient: may still be indexing.
250
+ *
251
+ * @example
252
+ * ```typescript
253
+ * try {
254
+ * const messages = await getMessagesInBatch(chain, request, commit)
255
+ * } catch (error) {
256
+ * if (error instanceof CCIPMessageBatchIncompleteError) {
257
+ * console.log(`Found ${error.context.foundSeqNums.length} of expected range`)
258
+ * if (error.isTransient) {
259
+ * await sleep(error.retryAfterMs ?? 30000)
260
+ * }
261
+ * }
262
+ * }
263
+ * ```
264
+ */
120
265
  export class CCIPMessageBatchIncompleteError extends CCIPError {
121
266
  name = 'CCIPMessageBatchIncompleteError';
122
267
  /** Creates a message batch incomplete error. */
@@ -129,7 +274,20 @@ export class CCIPMessageBatchIncompleteError extends CCIPError {
129
274
  });
130
275
  }
131
276
  }
132
- /** Thrown when message not in expected batch. */
277
+ /**
278
+ * Thrown when message not in expected batch.
279
+ *
280
+ * @example
281
+ * ```typescript
282
+ * try {
283
+ * const proof = calculateManualExecProof(messages, lane, messageId)
284
+ * } catch (error) {
285
+ * if (error instanceof CCIPMessageNotInBatchError) {
286
+ * console.log(`Message ${error.context.messageId} not in batch range`)
287
+ * }
288
+ * }
289
+ * ```
290
+ */
133
291
  export class CCIPMessageNotInBatchError extends CCIPError {
134
292
  name = 'CCIPMessageNotInBatchError';
135
293
  /** Creates a message not in batch error. */
@@ -141,7 +299,21 @@ export class CCIPMessageNotInBatchError extends CCIPError {
141
299
  });
142
300
  }
143
301
  }
144
- /** Thrown when message retrieval fails via both API and RPC. */
302
+ /**
303
+ * Thrown when message retrieval fails via both API and RPC.
304
+ *
305
+ * @example
306
+ * ```typescript
307
+ * try {
308
+ * const request = await chain.getMessageById('0xabc123...')
309
+ * } catch (error) {
310
+ * if (error instanceof CCIPMessageRetrievalError) {
311
+ * console.log(`Failed to retrieve message: ${error.message}`)
312
+ * console.log(`Recovery: ${error.recovery}`)
313
+ * }
314
+ * }
315
+ * ```
316
+ */
145
317
  export class CCIPMessageRetrievalError extends CCIPError {
146
318
  name = 'CCIPMessageRetrievalError';
147
319
  /** Creates a message retrieval error with both API and RPC failure context. */
@@ -163,7 +335,21 @@ export class CCIPMessageRetrievalError extends CCIPError {
163
335
  }
164
336
  }
165
337
  // Lane & Routing
166
- /** Thrown when no offRamp found for lane. */
338
+ /**
339
+ * Thrown when no offRamp found for lane.
340
+ *
341
+ * @example
342
+ * ```typescript
343
+ * try {
344
+ * const offRamp = await discoverOffRamp(source, dest, request)
345
+ * } catch (error) {
346
+ * if (error instanceof CCIPOffRampNotFoundError) {
347
+ * console.log(`No offRamp for ${error.context.onRamp} on ${error.context.destNetwork}`)
348
+ * console.log(`Recovery: ${error.recovery}`)
349
+ * }
350
+ * }
351
+ * ```
352
+ */
167
353
  export class CCIPOffRampNotFoundError extends CCIPError {
168
354
  name = 'CCIPOffRampNotFoundError';
169
355
  /** Creates an offRamp not found error. */
@@ -175,7 +361,20 @@ export class CCIPOffRampNotFoundError extends CCIPError {
175
361
  });
176
362
  }
177
363
  }
178
- /** Thrown when onRamp required but not provided. */
364
+ /**
365
+ * Thrown when onRamp required but not provided.
366
+ *
367
+ * @example
368
+ * ```typescript
369
+ * try {
370
+ * const lane = await chain.getLaneForOnRamp(undefined)
371
+ * } catch (error) {
372
+ * if (error instanceof CCIPOnRampRequiredError) {
373
+ * console.log('onRamp address is required for this operation')
374
+ * }
375
+ * }
376
+ * ```
377
+ */
179
378
  export class CCIPOnRampRequiredError extends CCIPError {
180
379
  name = 'CCIPOnRampRequiredError';
181
380
  /** Creates an onRamp required error. */
@@ -186,7 +385,20 @@ export class CCIPOnRampRequiredError extends CCIPError {
186
385
  });
187
386
  }
188
387
  }
189
- /** Thrown when lane not found between source and destination chains. */
388
+ /**
389
+ * Thrown when lane not found between source and destination chains.
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * try {
394
+ * const lane = await discoverLane(sourceChainSelector, destChainSelector)
395
+ * } catch (error) {
396
+ * if (error instanceof CCIPLaneNotFoundError) {
397
+ * console.log(`No lane: ${error.context.sourceChainSelector} → ${error.context.destChainSelector}`)
398
+ * }
399
+ * }
400
+ * ```
401
+ */
190
402
  export class CCIPLaneNotFoundError extends CCIPError {
191
403
  name = 'CCIPLaneNotFoundError';
192
404
  /** Creates a lane not found error. */
@@ -199,7 +411,22 @@ export class CCIPLaneNotFoundError extends CCIPError {
199
411
  }
200
412
  }
201
413
  // Commit & Merkle
202
- /** Thrown when commit report not found. Transient: DON may not have committed yet. */
414
+ /**
415
+ * Thrown when commit report not found. Transient: DON may not have committed yet.
416
+ *
417
+ * @example
418
+ * ```typescript
419
+ * try {
420
+ * const verifications = await chain.getVerifications({ offRamp, request })
421
+ * } catch (error) {
422
+ * if (error instanceof CCIPCommitNotFoundError) {
423
+ * if (error.isTransient) {
424
+ * console.log(`Commit pending, retry in ${error.retryAfterMs}ms`)
425
+ * }
426
+ * }
427
+ * }
428
+ * ```
429
+ */
203
430
  export class CCIPCommitNotFoundError extends CCIPError {
204
431
  name = 'CCIPCommitNotFoundError';
205
432
  /** Creates a commit not found error. */
@@ -212,7 +439,20 @@ export class CCIPCommitNotFoundError extends CCIPError {
212
439
  });
213
440
  }
214
441
  }
215
- /** Thrown when merkle root verification fails. */
442
+ /**
443
+ * Thrown when merkle root verification fails.
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * try {
448
+ * const proof = calculateManualExecProof(messages, lane, messageId, merkleRoot)
449
+ * } catch (error) {
450
+ * if (error instanceof CCIPMerkleRootMismatchError) {
451
+ * console.log(`Root mismatch: expected=${error.context.expected}, got=${error.context.got}`)
452
+ * }
453
+ * }
454
+ * ```
455
+ */
216
456
  export class CCIPMerkleRootMismatchError extends CCIPError {
217
457
  name = 'CCIPMerkleRootMismatchError';
218
458
  /** Creates a merkle root mismatch error. */
@@ -224,7 +464,20 @@ export class CCIPMerkleRootMismatchError extends CCIPError {
224
464
  });
225
465
  }
226
466
  }
227
- /** Thrown when attempting to create tree without leaves. */
467
+ /**
468
+ * Thrown when attempting to create tree without leaves.
469
+ *
470
+ * @example
471
+ * ```typescript
472
+ * try {
473
+ * const root = createMerkleTree([])
474
+ * } catch (error) {
475
+ * if (error instanceof CCIPMerkleTreeEmptyError) {
476
+ * console.log('Cannot create merkle tree without messages')
477
+ * }
478
+ * }
479
+ * ```
480
+ */
228
481
  export class CCIPMerkleTreeEmptyError extends CCIPError {
229
482
  name = 'CCIPMerkleTreeEmptyError';
230
483
  /** Creates a merkle tree empty error. */
@@ -236,7 +489,20 @@ export class CCIPMerkleTreeEmptyError extends CCIPError {
236
489
  }
237
490
  }
238
491
  // Version
239
- /** Thrown when CCIP version not supported. */
492
+ /**
493
+ * Thrown when CCIP version not supported.
494
+ *
495
+ * @example
496
+ * ```typescript
497
+ * try {
498
+ * const [type, version] = await chain.typeAndVersion(contractAddress)
499
+ * } catch (error) {
500
+ * if (error instanceof CCIPVersionUnsupportedError) {
501
+ * console.log(`Version ${error.context.version} not supported`)
502
+ * }
503
+ * }
504
+ * ```
505
+ */
240
506
  export class CCIPVersionUnsupportedError extends CCIPError {
241
507
  name = 'CCIPVersionUnsupportedError';
242
508
  /** Creates a version unsupported error. */
@@ -248,7 +514,20 @@ export class CCIPVersionUnsupportedError extends CCIPError {
248
514
  });
249
515
  }
250
516
  }
251
- /** Thrown when hasher version not supported for chain. */
517
+ /**
518
+ * Thrown when hasher version not supported for chain.
519
+ *
520
+ * @example
521
+ * ```typescript
522
+ * try {
523
+ * const hasher = getLeafHasher(lane)
524
+ * } catch (error) {
525
+ * if (error instanceof CCIPHasherVersionUnsupportedError) {
526
+ * console.log(`Hasher not available for ${error.context.chain} v${error.context.version}`)
527
+ * }
528
+ * }
529
+ * ```
530
+ */
252
531
  export class CCIPHasherVersionUnsupportedError extends CCIPError {
253
532
  name = 'CCIPHasherVersionUnsupportedError';
254
533
  /** Creates a hasher version unsupported error. */
@@ -261,7 +540,20 @@ export class CCIPHasherVersionUnsupportedError extends CCIPError {
261
540
  }
262
541
  }
263
542
  // ExtraArgs
264
- /** Thrown when extraArgs cannot be parsed. */
543
+ /**
544
+ * Thrown when extraArgs cannot be parsed.
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * try {
549
+ * const args = decodeExtraArgs(invalidData)
550
+ * } catch (error) {
551
+ * if (error instanceof CCIPExtraArgsParseError) {
552
+ * console.log(`Cannot parse extraArgs: ${error.context.from}`)
553
+ * }
554
+ * }
555
+ * ```
556
+ */
265
557
  export class CCIPExtraArgsParseError extends CCIPError {
266
558
  name = 'CCIPExtraArgsParseError';
267
559
  /** Creates an extraArgs parse error. */
@@ -278,6 +570,17 @@ export class CCIPExtraArgsParseError extends CCIPError {
278
570
  *
279
571
  * @param chainFamily - Display name for the chain family (user-facing, differs from ChainFamily enum)
280
572
  * @param extraArgs - The actual invalid extraArgs value (for debugging)
573
+ *
574
+ * @example
575
+ * ```typescript
576
+ * try {
577
+ * const encoded = encodeExtraArgs({ gasLimit: -1n }, 'EVM')
578
+ * } catch (error) {
579
+ * if (error instanceof CCIPExtraArgsInvalidError) {
580
+ * console.log(`Invalid extraArgs for ${error.context.chainFamily}`)
581
+ * }
582
+ * }
583
+ * ```
281
584
  */
282
585
  export class CCIPExtraArgsInvalidError extends CCIPError {
283
586
  name = 'CCIPExtraArgsInvalidError';
@@ -302,7 +605,20 @@ export class CCIPExtraArgsInvalidError extends CCIPError {
302
605
  }
303
606
  }
304
607
  // Token & Registry
305
- /** Thrown when token not found in registry. */
608
+ /**
609
+ * Thrown when token not found in registry.
610
+ *
611
+ * @example
612
+ * ```typescript
613
+ * try {
614
+ * const config = await chain.getRegistryTokenConfig(registry, tokenAddress)
615
+ * } catch (error) {
616
+ * if (error instanceof CCIPTokenNotInRegistryError) {
617
+ * console.log(`Token ${error.context.token} not in ${error.context.registry}`)
618
+ * }
619
+ * }
620
+ * ```
621
+ */
306
622
  export class CCIPTokenNotInRegistryError extends CCIPError {
307
623
  name = 'CCIPTokenNotInRegistryError';
308
624
  /** Creates a token not in registry error. */
@@ -314,7 +630,20 @@ export class CCIPTokenNotInRegistryError extends CCIPError {
314
630
  });
315
631
  }
316
632
  }
317
- /** Thrown when token not configured in registry. */
633
+ /**
634
+ * Thrown when token not configured in registry.
635
+ *
636
+ * @example
637
+ * ```typescript
638
+ * try {
639
+ * const pool = await chain.getTokenPoolConfigs(tokenPool)
640
+ * } catch (error) {
641
+ * if (error instanceof CCIPTokenNotConfiguredError) {
642
+ * console.log(`Token ${error.context.token} not configured`)
643
+ * }
644
+ * }
645
+ * ```
646
+ */
318
647
  export class CCIPTokenNotConfiguredError extends CCIPError {
319
648
  name = 'CCIPTokenNotConfiguredError';
320
649
  /** Creates a token not configured error. */
@@ -326,7 +655,20 @@ export class CCIPTokenNotConfiguredError extends CCIPError {
326
655
  });
327
656
  }
328
657
  }
329
- /** Thrown when destination token decimals insufficient. */
658
+ /**
659
+ * Thrown when destination token decimals insufficient.
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * try {
664
+ * const amounts = await sourceToDestTokenAmounts(source, dest, tokenAmounts)
665
+ * } catch (error) {
666
+ * if (error instanceof CCIPTokenDecimalsInsufficientError) {
667
+ * console.log(`Cannot express ${error.context.amount} with ${error.context.destDecimals} decimals`)
668
+ * }
669
+ * }
670
+ * ```
671
+ */
330
672
  export class CCIPTokenDecimalsInsufficientError extends CCIPError {
331
673
  name = 'CCIPTokenDecimalsInsufficientError';
332
674
  /** Creates a token decimals insufficient error. */
@@ -339,7 +681,20 @@ export class CCIPTokenDecimalsInsufficientError extends CCIPError {
339
681
  }
340
682
  }
341
683
  // Contract Type
342
- /** Thrown when contract type is not as expected. */
684
+ /**
685
+ * Thrown when contract type is not as expected.
686
+ *
687
+ * @example
688
+ * ```typescript
689
+ * try {
690
+ * const router = await chain.getRouterForOnRamp(address)
691
+ * } catch (error) {
692
+ * if (error instanceof CCIPContractTypeInvalidError) {
693
+ * console.log(`${error.context.address} is "${error.context.actualType}", expected ${error.context.expectedTypes}`)
694
+ * }
695
+ * }
696
+ * ```
697
+ */
343
698
  export class CCIPContractTypeInvalidError extends CCIPError {
344
699
  name = 'CCIPContractTypeInvalidError';
345
700
  /** Creates a contract type invalid error. */
@@ -352,7 +707,20 @@ export class CCIPContractTypeInvalidError extends CCIPError {
352
707
  }
353
708
  }
354
709
  // Wallet & Signer
355
- /** Thrown when wallet must be Signer but isn't. */
710
+ /**
711
+ * Thrown when wallet must be Signer but isn't.
712
+ *
713
+ * @example
714
+ * ```typescript
715
+ * try {
716
+ * await chain.sendMessage({ ...opts, wallet: provider })
717
+ * } catch (error) {
718
+ * if (error instanceof CCIPWalletNotSignerError) {
719
+ * console.log('Wallet must be a Signer to send transactions')
720
+ * }
721
+ * }
722
+ * ```
723
+ */
356
724
  export class CCIPWalletNotSignerError extends CCIPError {
357
725
  name = 'CCIPWalletNotSignerError';
358
726
  /** Creates a wallet not signer error. */
@@ -365,7 +733,22 @@ export class CCIPWalletNotSignerError extends CCIPError {
365
733
  }
366
734
  }
367
735
  // Execution
368
- /** Thrown when exec tx not confirmed. Transient: may need more time. */
736
+ /**
737
+ * Thrown when exec tx not confirmed. Transient: may need more time.
738
+ *
739
+ * @example
740
+ * ```typescript
741
+ * try {
742
+ * await chain.execute({ offRamp, input, wallet })
743
+ * } catch (error) {
744
+ * if (error instanceof CCIPExecTxNotConfirmedError) {
745
+ * if (error.isTransient) {
746
+ * await sleep(error.retryAfterMs ?? 5000)
747
+ * }
748
+ * }
749
+ * }
750
+ * ```
751
+ */
369
752
  export class CCIPExecTxNotConfirmedError extends CCIPError {
370
753
  name = 'CCIPExecTxNotConfirmedError';
371
754
  /** Creates an exec transaction not confirmed error. */
@@ -378,7 +761,20 @@ export class CCIPExecTxNotConfirmedError extends CCIPError {
378
761
  });
379
762
  }
380
763
  }
381
- /** Thrown when exec tx reverted. */
764
+ /**
765
+ * Thrown when exec tx reverted.
766
+ *
767
+ * @example
768
+ * ```typescript
769
+ * try {
770
+ * await chain.execute({ offRamp, input, wallet })
771
+ * } catch (error) {
772
+ * if (error instanceof CCIPExecTxRevertedError) {
773
+ * console.log(`Execution reverted: ${error.context.txHash}`)
774
+ * }
775
+ * }
776
+ * ```
777
+ */
382
778
  export class CCIPExecTxRevertedError extends CCIPError {
383
779
  name = 'CCIPExecTxRevertedError';
384
780
  /** Creates an exec transaction reverted error. */
@@ -391,7 +787,22 @@ export class CCIPExecTxRevertedError extends CCIPError {
391
787
  }
392
788
  }
393
789
  // Attestation (USDC/LBTC)
394
- /** Thrown when USDC attestation fetch fails. Transient: attestation may not be ready. */
790
+ /**
791
+ * Thrown when USDC attestation fetch fails. Transient: attestation may not be ready.
792
+ *
793
+ * @example
794
+ * ```typescript
795
+ * try {
796
+ * const offchainData = await chain.getOffchainTokenData(request)
797
+ * } catch (error) {
798
+ * if (error instanceof CCIPUsdcAttestationError) {
799
+ * if (error.isTransient) {
800
+ * console.log(`USDC attestation pending, retry in ${error.retryAfterMs}ms`)
801
+ * }
802
+ * }
803
+ * }
804
+ * ```
805
+ */
395
806
  export class CCIPUsdcAttestationError extends CCIPError {
396
807
  name = 'CCIPUsdcAttestationError';
397
808
  /** Creates a USDC attestation error. */
@@ -404,7 +815,22 @@ export class CCIPUsdcAttestationError extends CCIPError {
404
815
  });
405
816
  }
406
817
  }
407
- /** Thrown when LBTC attestation fetch fails. Transient: attestation may not be ready. */
818
+ /**
819
+ * Thrown when LBTC attestation fetch fails. Transient: attestation may not be ready.
820
+ *
821
+ * @example
822
+ * ```typescript
823
+ * try {
824
+ * const offchainData = await chain.getOffchainTokenData(request)
825
+ * } catch (error) {
826
+ * if (error instanceof CCIPLbtcAttestationError) {
827
+ * if (error.isTransient) {
828
+ * console.log(`LBTC attestation pending, retry in ${error.retryAfterMs}ms`)
829
+ * }
830
+ * }
831
+ * }
832
+ * ```
833
+ */
408
834
  export class CCIPLbtcAttestationError extends CCIPError {
409
835
  name = 'CCIPLbtcAttestationError';
410
836
  /** Creates an LBTC attestation error. */
@@ -417,7 +843,23 @@ export class CCIPLbtcAttestationError extends CCIPError {
417
843
  });
418
844
  }
419
845
  }
420
- /** Thrown when LBTC attestation not found for payload hash. Transient: may not be processed yet. */
846
+ /**
847
+ * Thrown when LBTC attestation not found for payload hash. Transient: may not be processed yet.
848
+ *
849
+ * @example
850
+ * ```typescript
851
+ * try {
852
+ * const offchainData = await chain.getOffchainTokenData(request)
853
+ * } catch (error) {
854
+ * if (error instanceof CCIPLbtcAttestationNotFoundError) {
855
+ * console.log(`Attestation not found for hash: ${error.context.payloadHash}`)
856
+ * if (error.isTransient) {
857
+ * await sleep(error.retryAfterMs ?? 30000)
858
+ * }
859
+ * }
860
+ * }
861
+ * ```
862
+ */
421
863
  export class CCIPLbtcAttestationNotFoundError extends CCIPError {
422
864
  name = 'CCIPLbtcAttestationNotFoundError';
423
865
  /** Creates an LBTC attestation not found error. */
@@ -430,7 +872,23 @@ export class CCIPLbtcAttestationNotFoundError extends CCIPError {
430
872
  });
431
873
  }
432
874
  }
433
- /** Thrown when LBTC attestation is not yet approved. Transient: may be pending notarization. */
875
+ /**
876
+ * Thrown when LBTC attestation is not yet approved. Transient: may be pending notarization.
877
+ *
878
+ * @example
879
+ * ```typescript
880
+ * try {
881
+ * const offchainData = await chain.getOffchainTokenData(request)
882
+ * } catch (error) {
883
+ * if (error instanceof CCIPLbtcAttestationNotApprovedError) {
884
+ * console.log(`Attestation pending approval for: ${error.context.payloadHash}`)
885
+ * if (error.isTransient) {
886
+ * await sleep(error.retryAfterMs ?? 30000)
887
+ * }
888
+ * }
889
+ * }
890
+ * ```
891
+ */
434
892
  export class CCIPLbtcAttestationNotApprovedError extends CCIPError {
435
893
  name = 'CCIPLbtcAttestationNotApprovedError';
436
894
  /** Creates an LBTC attestation not approved error. */
@@ -444,7 +902,22 @@ export class CCIPLbtcAttestationNotApprovedError extends CCIPError {
444
902
  }
445
903
  }
446
904
  // Solana
447
- /** Thrown when lookup table not found. Transient: may not be synced yet. */
905
+ /**
906
+ * Thrown when lookup table not found. Transient: may not be synced yet.
907
+ *
908
+ * @example
909
+ * ```typescript
910
+ * try {
911
+ * const lookupTable = await solanaChain.getLookupTable(address)
912
+ * } catch (error) {
913
+ * if (error instanceof CCIPSolanaLookupTableNotFoundError) {
914
+ * if (error.isTransient) {
915
+ * console.log(`Lookup table not synced, retry in ${error.retryAfterMs}ms`)
916
+ * }
917
+ * }
918
+ * }
919
+ * ```
920
+ */
448
921
  export class CCIPSolanaLookupTableNotFoundError extends CCIPError {
449
922
  name = 'CCIPSolanaLookupTableNotFoundError';
450
923
  /** Creates a Solana lookup table not found error. */
@@ -458,7 +931,20 @@ export class CCIPSolanaLookupTableNotFoundError extends CCIPError {
458
931
  }
459
932
  }
460
933
  // Aptos
461
- /** Thrown for invalid Aptos transaction hash or version. */
934
+ /**
935
+ * Thrown for invalid Aptos transaction hash or version.
936
+ *
937
+ * @example
938
+ * ```typescript
939
+ * try {
940
+ * const tx = await aptosChain.getTransaction('invalid-hash')
941
+ * } catch (error) {
942
+ * if (error instanceof CCIPAptosTransactionInvalidError) {
943
+ * console.log(`Invalid tx: ${error.context.hashOrVersion}`)
944
+ * }
945
+ * }
946
+ * ```
947
+ */
462
948
  export class CCIPAptosTransactionInvalidError extends CCIPError {
463
949
  name = 'CCIPAptosTransactionInvalidError';
464
950
  /** Creates an Aptos transaction invalid error. */
@@ -471,7 +957,23 @@ export class CCIPAptosTransactionInvalidError extends CCIPError {
471
957
  }
472
958
  }
473
959
  // HTTP & Data
474
- /** Thrown for HTTP errors. Transient if 429 or 5xx. */
960
+ /**
961
+ * Thrown for HTTP errors. Transient if 429 or 5xx.
962
+ *
963
+ * @example
964
+ * ```typescript
965
+ * try {
966
+ * const latency = await chain.getLaneLatency(destChainSelector)
967
+ * } catch (error) {
968
+ * if (error instanceof CCIPHttpError) {
969
+ * console.log(`HTTP ${error.context.status}: ${error.context.statusText}`)
970
+ * if (error.isTransient) {
971
+ * // 429 or 5xx - safe to retry
972
+ * }
973
+ * }
974
+ * }
975
+ * ```
976
+ */
475
977
  export class CCIPHttpError extends CCIPError {
476
978
  name = 'CCIPHttpError';
477
979
  /** Creates an HTTP error. */
@@ -483,7 +985,23 @@ export class CCIPHttpError extends CCIPError {
483
985
  });
484
986
  }
485
987
  }
486
- /** Thrown when a request times out. Transient: network may recover. */
988
+ /**
989
+ * Thrown when a request times out. Transient: network may recover.
990
+ *
991
+ * @example
992
+ * ```typescript
993
+ * try {
994
+ * const tx = await chain.getTransaction('0x1234...')
995
+ * } catch (error) {
996
+ * if (error instanceof CCIPTimeoutError) {
997
+ * console.log(`Operation timed out: ${error.context.operation}`)
998
+ * if (error.isTransient) {
999
+ * console.log(`Retry in ${error.retryAfterMs}ms`)
1000
+ * }
1001
+ * }
1002
+ * }
1003
+ * ```
1004
+ */
487
1005
  export class CCIPTimeoutError extends CCIPError {
488
1006
  name = 'CCIPTimeoutError';
489
1007
  /** Creates a timeout error. */
@@ -496,7 +1014,20 @@ export class CCIPTimeoutError extends CCIPError {
496
1014
  });
497
1015
  }
498
1016
  }
499
- /** Thrown for not implemented features. */
1017
+ /**
1018
+ * Thrown for not implemented features.
1019
+ *
1020
+ * @example
1021
+ * ```typescript
1022
+ * try {
1023
+ * await chain.someUnimplementedMethod()
1024
+ * } catch (error) {
1025
+ * if (error instanceof CCIPNotImplementedError) {
1026
+ * console.log(`Feature not implemented: ${error.context.feature}`)
1027
+ * }
1028
+ * }
1029
+ * ```
1030
+ */
500
1031
  export class CCIPNotImplementedError extends CCIPError {
501
1032
  name = 'CCIPNotImplementedError';
502
1033
  /** Creates a not implemented error. */
@@ -509,7 +1040,20 @@ export class CCIPNotImplementedError extends CCIPError {
509
1040
  }
510
1041
  }
511
1042
  // Data Format & Parsing
512
- /** Thrown when data format is not supported. */
1043
+ /**
1044
+ * Thrown when data format is not supported.
1045
+ *
1046
+ * @example
1047
+ * ```typescript
1048
+ * try {
1049
+ * const parsed = parseData(unknownFormat)
1050
+ * } catch (error) {
1051
+ * if (error instanceof CCIPDataFormatUnsupportedError) {
1052
+ * console.log(`Unsupported format: ${error.context.data}`)
1053
+ * }
1054
+ * }
1055
+ * ```
1056
+ */
513
1057
  export class CCIPDataFormatUnsupportedError extends CCIPError {
514
1058
  name = 'CCIPDataFormatUnsupportedError';
515
1059
  /** Creates a data format unsupported error. */
@@ -521,7 +1065,20 @@ export class CCIPDataFormatUnsupportedError extends CCIPError {
521
1065
  });
522
1066
  }
523
1067
  }
524
- /** Thrown when typeAndVersion string cannot be parsed. */
1068
+ /**
1069
+ * Thrown when typeAndVersion string cannot be parsed.
1070
+ *
1071
+ * @example
1072
+ * ```typescript
1073
+ * try {
1074
+ * const [type, version] = await chain.typeAndVersion(contractAddress)
1075
+ * } catch (error) {
1076
+ * if (error instanceof CCIPTypeVersionInvalidError) {
1077
+ * console.log(`Cannot parse: ${error.context.typeAndVersion}`)
1078
+ * }
1079
+ * }
1080
+ * ```
1081
+ */
525
1082
  export class CCIPTypeVersionInvalidError extends CCIPError {
526
1083
  name = 'CCIPTypeVersionInvalidError';
527
1084
  /** Creates a type version invalid error. */
@@ -533,7 +1090,20 @@ export class CCIPTypeVersionInvalidError extends CCIPError {
533
1090
  });
534
1091
  }
535
1092
  }
536
- /** Thrown when no block found before timestamp. */
1093
+ /**
1094
+ * Thrown when no block found before timestamp.
1095
+ *
1096
+ * @example
1097
+ * ```typescript
1098
+ * try {
1099
+ * const block = await chain.getBlockBeforeTimestamp(timestamp)
1100
+ * } catch (error) {
1101
+ * if (error instanceof CCIPBlockBeforeTimestampNotFoundError) {
1102
+ * console.log(`No block before timestamp: ${error.context.timestamp}`)
1103
+ * }
1104
+ * }
1105
+ * ```
1106
+ */
537
1107
  export class CCIPBlockBeforeTimestampNotFoundError extends CCIPError {
538
1108
  name = 'CCIPBlockBeforeTimestampNotFoundError';
539
1109
  /** Creates a block before timestamp not found error. */
@@ -545,7 +1115,20 @@ export class CCIPBlockBeforeTimestampNotFoundError extends CCIPError {
545
1115
  });
546
1116
  }
547
1117
  }
548
- /** Thrown when message decoding fails. */
1118
+ /**
1119
+ * Thrown when message decoding fails.
1120
+ *
1121
+ * @example
1122
+ * ```typescript
1123
+ * try {
1124
+ * const message = EVMChain.decodeMessage(log)
1125
+ * } catch (error) {
1126
+ * if (error instanceof CCIPMessageDecodeError) {
1127
+ * console.log(`Decode failed: ${error.context.reason}`)
1128
+ * }
1129
+ * }
1130
+ * ```
1131
+ */
549
1132
  export class CCIPMessageDecodeError extends CCIPError {
550
1133
  name = 'CCIPMessageDecodeError';
551
1134
  /** Creates a message decode error. */
@@ -557,7 +1140,45 @@ export class CCIPMessageDecodeError extends CCIPError {
557
1140
  });
558
1141
  }
559
1142
  }
560
- /** Thrown when RPC endpoint not found. */
1143
+ /**
1144
+ * Thrown when network family is not supported for an operation.
1145
+ *
1146
+ * @example
1147
+ * ```typescript
1148
+ * try {
1149
+ * const chain = await Chain.fromUrl(rpcUrl)
1150
+ * } catch (error) {
1151
+ * if (error instanceof CCIPNetworkFamilyUnsupportedError) {
1152
+ * console.log(`Unsupported family: ${error.context.family}`)
1153
+ * }
1154
+ * }
1155
+ * ```
1156
+ */
1157
+ export class CCIPNetworkFamilyUnsupportedError extends CCIPError {
1158
+ name = 'CCIPNetworkFamilyUnsupportedError';
1159
+ /** Creates a network family unsupported error. */
1160
+ constructor(family, options) {
1161
+ super(CCIPErrorCode.NETWORK_FAMILY_UNSUPPORTED, `Unsupported network family: ${family}`, {
1162
+ ...options,
1163
+ isTransient: false,
1164
+ context: { ...options?.context, family },
1165
+ });
1166
+ }
1167
+ }
1168
+ /**
1169
+ * Thrown when RPC endpoint not found.
1170
+ *
1171
+ * @example
1172
+ * ```typescript
1173
+ * try {
1174
+ * const chain = await EVMChain.fromUrl(rpcUrl)
1175
+ * } catch (error) {
1176
+ * if (error instanceof CCIPRpcNotFoundError) {
1177
+ * console.log(`No RPC for chainId: ${error.context.chainId}`)
1178
+ * }
1179
+ * }
1180
+ * ```
1181
+ */
561
1182
  export class CCIPRpcNotFoundError extends CCIPError {
562
1183
  name = 'CCIPRpcNotFoundError';
563
1184
  /** Creates an RPC not found error. */
@@ -569,7 +1190,22 @@ export class CCIPRpcNotFoundError extends CCIPError {
569
1190
  });
570
1191
  }
571
1192
  }
572
- /** Thrown when logs not found for filter criteria. */
1193
+ /**
1194
+ * Thrown when logs not found for filter criteria. Transient: logs may not be indexed yet.
1195
+ *
1196
+ * @example
1197
+ * ```typescript
1198
+ * try {
1199
+ * const logs = await chain.getLogs(filter)
1200
+ * } catch (error) {
1201
+ * if (error instanceof CCIPLogsNotFoundError) {
1202
+ * if (error.isTransient) {
1203
+ * await sleep(error.retryAfterMs ?? 5000)
1204
+ * }
1205
+ * }
1206
+ * }
1207
+ * ```
1208
+ */
573
1209
  export class CCIPLogsNotFoundError extends CCIPError {
574
1210
  name = 'CCIPLogsNotFoundError';
575
1211
  /** Creates a logs not found error. */
@@ -582,7 +1218,20 @@ export class CCIPLogsNotFoundError extends CCIPError {
582
1218
  });
583
1219
  }
584
1220
  }
585
- /** Thrown when log topics not found. */
1221
+ /**
1222
+ * Thrown when log topics not found.
1223
+ *
1224
+ * @example
1225
+ * ```typescript
1226
+ * try {
1227
+ * const logs = await chain.getLogs({ topics: ['0xunknown'] })
1228
+ * } catch (error) {
1229
+ * if (error instanceof CCIPLogTopicsNotFoundError) {
1230
+ * console.log(`Topics not matched: ${error.context.topics}`)
1231
+ * }
1232
+ * }
1233
+ * ```
1234
+ */
586
1235
  export class CCIPLogTopicsNotFoundError extends CCIPError {
587
1236
  name = 'CCIPLogTopicsNotFoundError';
588
1237
  /** Creates a log topics not found error. */
@@ -594,18 +1243,44 @@ export class CCIPLogTopicsNotFoundError extends CCIPError {
594
1243
  });
595
1244
  }
596
1245
  }
597
- /** Thrown when trying to `watch` logs but giving a fixed `endBlock` */
1246
+ /**
1247
+ * Thrown when trying to `watch` logs but giving a fixed `endBlock`.
1248
+ *
1249
+ * @example
1250
+ * ```typescript
1251
+ * try {
1252
+ * await chain.watchLogs({ endBlock: 1000 }) // Fixed endBlock not allowed
1253
+ * } catch (error) {
1254
+ * if (error instanceof CCIPLogsWatchRequiresFinalityError) {
1255
+ * console.log('Use "latest" or "finalized" for endBlock in watch mode')
1256
+ * }
1257
+ * }
1258
+ * ```
1259
+ */
598
1260
  export class CCIPLogsWatchRequiresFinalityError extends CCIPError {
599
1261
  name = 'CCIPLogsWatchRequiresFinalityError';
600
- /** Creates a watch requires finality error. */
1262
+ /** Creates a logs watch requires finality error. */
601
1263
  constructor(endBlock, options) {
602
1264
  super(CCIPErrorCode.LOGS_WATCH_REQUIRES_FINALITY, `Watch mode requires finality config for endBlock (latest, finalized or block depth=negative)`, { ...options, isTransient: false, context: { ...options?.context, endBlock } });
603
1265
  }
604
1266
  }
605
- /** Thrown when trying to `watch` logs without a start point. */
1267
+ /**
1268
+ * Thrown when trying to `watch` logs but no start position provided.
1269
+ *
1270
+ * @example
1271
+ * ```typescript
1272
+ * try {
1273
+ * await chain.watchLogs({}) // Missing startBlock or startTime
1274
+ * } catch (error) {
1275
+ * if (error instanceof CCIPLogsWatchRequiresStartError) {
1276
+ * console.log('Provide startBlock or startTime for watch mode')
1277
+ * }
1278
+ * }
1279
+ * ```
1280
+ */
606
1281
  export class CCIPLogsWatchRequiresStartError extends CCIPError {
607
1282
  name = 'CCIPLogsWatchRequiresStartError';
608
- /** Creates a watch requires start error. */
1283
+ /** Creates a logs watch requires start error. */
609
1284
  constructor(options) {
610
1285
  super(CCIPErrorCode.LOGS_WATCH_REQUIRES_START, `Watch mode requires startBlock or startTime`, {
611
1286
  ...options,
@@ -613,7 +1288,20 @@ export class CCIPLogsWatchRequiresStartError extends CCIPError {
613
1288
  });
614
1289
  }
615
1290
  }
616
- /** Thrown when address is required for logs filtering, but not provided. */
1291
+ /**
1292
+ * Thrown when address is required for logs filtering, but not provided.
1293
+ *
1294
+ * @example
1295
+ * ```typescript
1296
+ * try {
1297
+ * await chain.getLogs({ topics: [...] }) // Missing address
1298
+ * } catch (error) {
1299
+ * if (error instanceof CCIPLogsAddressRequiredError) {
1300
+ * console.log('Contract address is required for this chain')
1301
+ * }
1302
+ * }
1303
+ * ```
1304
+ */
617
1305
  export class CCIPLogsAddressRequiredError extends CCIPError {
618
1306
  name = 'CCIPLogsAddressRequiredError';
619
1307
  /** Creates a Solana program address required error. */
@@ -625,7 +1313,20 @@ export class CCIPLogsAddressRequiredError extends CCIPError {
625
1313
  }
626
1314
  }
627
1315
  // Chain Family
628
- /** Thrown when network family does not match expected for a Chain constructor. */
1316
+ /**
1317
+ * Thrown when network family does not match expected for a Chain constructor.
1318
+ *
1319
+ * @example
1320
+ * ```typescript
1321
+ * try {
1322
+ * const chain = new EVMChain(provider, solanaNetworkInfo) // Wrong family
1323
+ * } catch (error) {
1324
+ * if (error instanceof CCIPChainFamilyMismatchError) {
1325
+ * console.log(`Expected ${error.context.expected}, got ${error.context.actual}`)
1326
+ * }
1327
+ * }
1328
+ * ```
1329
+ */
629
1330
  export class CCIPChainFamilyMismatchError extends CCIPError {
630
1331
  name = 'CCIPChainFamilyMismatchError';
631
1332
  /** Creates a chain family mismatch error. */
@@ -637,8 +1338,46 @@ export class CCIPChainFamilyMismatchError extends CCIPError {
637
1338
  });
638
1339
  }
639
1340
  }
1341
+ // Token Pool
1342
+ /**
1343
+ * Thrown when legacy (pre-1.5) token pools are not supported.
1344
+ *
1345
+ * @example
1346
+ * ```typescript
1347
+ * try {
1348
+ * await chain.getTokenPoolConfigs(legacyPool)
1349
+ * } catch (error) {
1350
+ * if (error instanceof CCIPLegacyTokenPoolsUnsupportedError) {
1351
+ * console.log('Upgrade to CCIP v1.5+ token pools')
1352
+ * }
1353
+ * }
1354
+ * ```
1355
+ */
1356
+ export class CCIPLegacyTokenPoolsUnsupportedError extends CCIPError {
1357
+ name = 'CCIPLegacyTokenPoolsUnsupportedError';
1358
+ /** Creates a legacy token pools unsupported error. */
1359
+ constructor(options) {
1360
+ super(CCIPErrorCode.LEGACY_TOKEN_POOLS_UNSUPPORTED, 'Legacy <1.5 token pools not supported', {
1361
+ ...options,
1362
+ isTransient: false,
1363
+ });
1364
+ }
1365
+ }
640
1366
  // Merkle Validation
641
- /** Thrown when merkle proof is empty. */
1367
+ /**
1368
+ * Thrown when merkle proof is empty.
1369
+ *
1370
+ * @example
1371
+ * ```typescript
1372
+ * try {
1373
+ * verifyMerkleProof({ leaves: [], proofs: [] })
1374
+ * } catch (error) {
1375
+ * if (error instanceof CCIPMerkleProofEmptyError) {
1376
+ * console.log('Cannot verify empty merkle proof')
1377
+ * }
1378
+ * }
1379
+ * ```
1380
+ */
642
1381
  export class CCIPMerkleProofEmptyError extends CCIPError {
643
1382
  name = 'CCIPMerkleProofEmptyError';
644
1383
  /** Creates a merkle proof empty error. */
@@ -649,7 +1388,20 @@ export class CCIPMerkleProofEmptyError extends CCIPError {
649
1388
  });
650
1389
  }
651
1390
  }
652
- /** Thrown when merkle leaves or proofs exceed max limit. */
1391
+ /**
1392
+ * Thrown when merkle leaves or proofs exceed max limit.
1393
+ *
1394
+ * @example
1395
+ * ```typescript
1396
+ * try {
1397
+ * verifyMerkleProof({ leaves: largeArray, proofs })
1398
+ * } catch (error) {
1399
+ * if (error instanceof CCIPMerkleProofTooLargeError) {
1400
+ * console.log(`Proof exceeds limit: ${error.context.limit}`)
1401
+ * }
1402
+ * }
1403
+ * ```
1404
+ */
653
1405
  export class CCIPMerkleProofTooLargeError extends CCIPError {
654
1406
  name = 'CCIPMerkleProofTooLargeError';
655
1407
  /** Creates a merkle proof too large error. */
@@ -661,7 +1413,20 @@ export class CCIPMerkleProofTooLargeError extends CCIPError {
661
1413
  });
662
1414
  }
663
1415
  }
664
- /** Thrown when total hashes exceed max merkle tree size. */
1416
+ /**
1417
+ * Thrown when total hashes exceed max merkle tree size.
1418
+ *
1419
+ * @example
1420
+ * ```typescript
1421
+ * try {
1422
+ * createMerkleTree(hashes)
1423
+ * } catch (error) {
1424
+ * if (error instanceof CCIPMerkleHashesTooLargeError) {
1425
+ * console.log(`${error.context.totalHashes} exceeds limit ${error.context.limit}`)
1426
+ * }
1427
+ * }
1428
+ * ```
1429
+ */
665
1430
  export class CCIPMerkleHashesTooLargeError extends CCIPError {
666
1431
  name = 'CCIPMerkleHashesTooLargeError';
667
1432
  /** Creates a merkle hashes too large error. */
@@ -673,7 +1438,20 @@ export class CCIPMerkleHashesTooLargeError extends CCIPError {
673
1438
  });
674
1439
  }
675
1440
  }
676
- /** Thrown when source flags count does not match expected total. */
1441
+ /**
1442
+ * Thrown when source flags count does not match expected total.
1443
+ *
1444
+ * @example
1445
+ * ```typescript
1446
+ * try {
1447
+ * verifyMerkleProof({ hashes, sourceFlags })
1448
+ * } catch (error) {
1449
+ * if (error instanceof CCIPMerkleFlagsMismatchError) {
1450
+ * console.log(`Hashes: ${error.context.totalHashes}, Flags: ${error.context.flagsLength}`)
1451
+ * }
1452
+ * }
1453
+ * ```
1454
+ */
677
1455
  export class CCIPMerkleFlagsMismatchError extends CCIPError {
678
1456
  name = 'CCIPMerkleFlagsMismatchError';
679
1457
  /** Creates a merkle flags mismatch error. */
@@ -685,7 +1463,20 @@ export class CCIPMerkleFlagsMismatchError extends CCIPError {
685
1463
  });
686
1464
  }
687
1465
  }
688
- /** Thrown when proof source flags count does not match proof hashes. */
1466
+ /**
1467
+ * Thrown when proof source flags count does not match proof hashes.
1468
+ *
1469
+ * @example
1470
+ * ```typescript
1471
+ * try {
1472
+ * verifyMerkleProof({ sourceFlags, proofs })
1473
+ * } catch (error) {
1474
+ * if (error instanceof CCIPMerkleProofFlagsMismatchError) {
1475
+ * console.log(`Flags: ${error.context.sourceProofCount}, Proofs: ${error.context.proofsLength}`)
1476
+ * }
1477
+ * }
1478
+ * ```
1479
+ */
689
1480
  export class CCIPMerkleProofFlagsMismatchError extends CCIPError {
690
1481
  name = 'CCIPMerkleProofFlagsMismatchError';
691
1482
  /** Creates a merkle proof flags mismatch error. */
@@ -697,7 +1488,20 @@ export class CCIPMerkleProofFlagsMismatchError extends CCIPError {
697
1488
  });
698
1489
  }
699
1490
  }
700
- /** Thrown when not all proofs were consumed during verification. */
1491
+ /**
1492
+ * Thrown when not all proofs were consumed during verification.
1493
+ *
1494
+ * @example
1495
+ * ```typescript
1496
+ * try {
1497
+ * verifyMerkleProof({ leaves, proofs, root })
1498
+ * } catch (error) {
1499
+ * if (error instanceof CCIPMerkleProofIncompleteError) {
1500
+ * console.log('Merkle proof verification incomplete')
1501
+ * }
1502
+ * }
1503
+ * ```
1504
+ */
701
1505
  export class CCIPMerkleProofIncompleteError extends CCIPError {
702
1506
  name = 'CCIPMerkleProofIncompleteError';
703
1507
  /** Creates a merkle proof incomplete error. */
@@ -708,7 +1512,20 @@ export class CCIPMerkleProofIncompleteError extends CCIPError {
708
1512
  });
709
1513
  }
710
1514
  }
711
- /** Thrown on internal merkle computation error. */
1515
+ /**
1516
+ * Thrown on internal merkle computation error.
1517
+ *
1518
+ * @example
1519
+ * ```typescript
1520
+ * try {
1521
+ * computeMerkleRoot(hashes)
1522
+ * } catch (error) {
1523
+ * if (error instanceof CCIPMerkleInternalError) {
1524
+ * console.log(`Internal merkle error: ${error.message}`)
1525
+ * }
1526
+ * }
1527
+ * ```
1528
+ */
712
1529
  export class CCIPMerkleInternalError extends CCIPError {
713
1530
  name = 'CCIPMerkleInternalError';
714
1531
  /** Creates a merkle internal error. */
@@ -720,7 +1537,20 @@ export class CCIPMerkleInternalError extends CCIPError {
720
1537
  }
721
1538
  }
722
1539
  // Address Validation
723
- /** Thrown when EVM address is invalid. */
1540
+ /**
1541
+ * Thrown when EVM address is invalid.
1542
+ *
1543
+ * @example
1544
+ * ```typescript
1545
+ * try {
1546
+ * EVMChain.getAddress('not-an-address')
1547
+ * } catch (error) {
1548
+ * if (error instanceof CCIPAddressInvalidEvmError) {
1549
+ * console.log(`Invalid address: ${error.context.address}`)
1550
+ * }
1551
+ * }
1552
+ * ```
1553
+ */
724
1554
  export class CCIPAddressInvalidEvmError extends CCIPError {
725
1555
  name = 'CCIPAddressInvalidEvmError';
726
1556
  /** Creates an EVM address invalid error. */
@@ -733,7 +1563,20 @@ export class CCIPAddressInvalidEvmError extends CCIPError {
733
1563
  }
734
1564
  }
735
1565
  // Version Requirements
736
- /** Thrown when CCIP version requires lane info. */
1566
+ /**
1567
+ * Thrown when CCIP version requires lane info.
1568
+ *
1569
+ * @example
1570
+ * ```typescript
1571
+ * try {
1572
+ * EVMChain.decodeCommits(log) // Missing lane for v1.6
1573
+ * } catch (error) {
1574
+ * if (error instanceof CCIPVersionRequiresLaneError) {
1575
+ * console.log(`Version ${error.context.version} requires lane parameter`)
1576
+ * }
1577
+ * }
1578
+ * ```
1579
+ */
737
1580
  export class CCIPVersionRequiresLaneError extends CCIPError {
738
1581
  name = 'CCIPVersionRequiresLaneError';
739
1582
  /** Creates a version requires lane error. */
@@ -745,7 +1588,20 @@ export class CCIPVersionRequiresLaneError extends CCIPError {
745
1588
  });
746
1589
  }
747
1590
  }
748
- /** Thrown when version feature is unavailable. */
1591
+ /**
1592
+ * Thrown when version feature is unavailable.
1593
+ *
1594
+ * @example
1595
+ * ```typescript
1596
+ * try {
1597
+ * await chain.getFeature(oldVersion)
1598
+ * } catch (error) {
1599
+ * if (error instanceof CCIPVersionFeatureUnavailableError) {
1600
+ * console.log(`${error.context.feature} requires v${error.context.minVersion}+`)
1601
+ * }
1602
+ * }
1603
+ * ```
1604
+ */
749
1605
  export class CCIPVersionFeatureUnavailableError extends CCIPError {
750
1606
  name = 'CCIPVersionFeatureUnavailableError';
751
1607
  /** Creates a version feature unavailable error. */
@@ -761,7 +1617,20 @@ export class CCIPVersionFeatureUnavailableError extends CCIPError {
761
1617
  }
762
1618
  }
763
1619
  // Contract Validation
764
- /** Thrown when contract is not a Router or expected CCIP contract. */
1620
+ /**
1621
+ * Thrown when contract is not a Router or expected CCIP contract.
1622
+ *
1623
+ * @example
1624
+ * ```typescript
1625
+ * try {
1626
+ * await chain.getRouterForOnRamp(address)
1627
+ * } catch (error) {
1628
+ * if (error instanceof CCIPContractNotRouterError) {
1629
+ * console.log(`${error.context.address} is "${error.context.typeAndVersion}"`)
1630
+ * }
1631
+ * }
1632
+ * ```
1633
+ */
765
1634
  export class CCIPContractNotRouterError extends CCIPError {
766
1635
  name = 'CCIPContractNotRouterError';
767
1636
  /** Creates a contract not router error. */
@@ -774,7 +1643,20 @@ export class CCIPContractNotRouterError extends CCIPError {
774
1643
  }
775
1644
  }
776
1645
  // Log Data
777
- /** Thrown when log data is invalid. */
1646
+ /**
1647
+ * Thrown when log data is invalid.
1648
+ *
1649
+ * @example
1650
+ * ```typescript
1651
+ * try {
1652
+ * const message = EVMChain.decodeMessage(log)
1653
+ * } catch (error) {
1654
+ * if (error instanceof CCIPLogDataInvalidError) {
1655
+ * console.log(`Invalid log data: ${error.context.data}`)
1656
+ * }
1657
+ * }
1658
+ * ```
1659
+ */
778
1660
  export class CCIPLogDataInvalidError extends CCIPError {
779
1661
  name = 'CCIPLogDataInvalidError';
780
1662
  /** Creates a log data invalid error. */
@@ -787,7 +1669,20 @@ export class CCIPLogDataInvalidError extends CCIPError {
787
1669
  }
788
1670
  }
789
1671
  // Wallet
790
- /** Thrown when wallet is not a valid signer. */
1672
+ /**
1673
+ * Thrown when wallet is not a valid signer.
1674
+ *
1675
+ * @example
1676
+ * ```typescript
1677
+ * try {
1678
+ * await chain.sendMessage({ ...opts, wallet: invalidWallet })
1679
+ * } catch (error) {
1680
+ * if (error instanceof CCIPWalletInvalidError) {
1681
+ * console.log('Provide a valid signer wallet')
1682
+ * }
1683
+ * }
1684
+ * ```
1685
+ */
791
1686
  export class CCIPWalletInvalidError extends CCIPError {
792
1687
  name = 'CCIPWalletInvalidError';
793
1688
  /** Creates a wallet invalid error. */
@@ -799,7 +1694,20 @@ export class CCIPWalletInvalidError extends CCIPError {
799
1694
  }
800
1695
  }
801
1696
  // Source Chain
802
- /** Thrown when source chain is unsupported for EVM hasher. */
1697
+ /**
1698
+ * Thrown when source chain is unsupported for EVM hasher.
1699
+ *
1700
+ * @example
1701
+ * ```typescript
1702
+ * try {
1703
+ * const hasher = chain.getDestLeafHasher(lane)
1704
+ * } catch (error) {
1705
+ * if (error instanceof CCIPSourceChainUnsupportedError) {
1706
+ * console.log(`Unsupported source: ${error.context.chainSelector}`)
1707
+ * }
1708
+ * }
1709
+ * ```
1710
+ */
803
1711
  export class CCIPSourceChainUnsupportedError extends CCIPError {
804
1712
  name = 'CCIPSourceChainUnsupportedError';
805
1713
  /** Creates a source chain unsupported error. */
@@ -812,7 +1720,22 @@ export class CCIPSourceChainUnsupportedError extends CCIPError {
812
1720
  }
813
1721
  }
814
1722
  // Solana-specific errors
815
- /** Thrown when block time cannot be retrieved for a slot. */
1723
+ /**
1724
+ * Thrown when block time cannot be retrieved for a slot. Transient: slot may not be indexed.
1725
+ *
1726
+ * @example
1727
+ * ```typescript
1728
+ * try {
1729
+ * const timestamp = await solanaChain.getBlockTimestamp(slot)
1730
+ * } catch (error) {
1731
+ * if (error instanceof CCIPBlockTimeNotFoundError) {
1732
+ * if (error.isTransient) {
1733
+ * await sleep(error.retryAfterMs ?? 5000)
1734
+ * }
1735
+ * }
1736
+ * }
1737
+ * ```
1738
+ */
816
1739
  export class CCIPBlockTimeNotFoundError extends CCIPError {
817
1740
  name = 'CCIPBlockTimeNotFoundError';
818
1741
  /** Creates a block time not found error. */
@@ -825,7 +1748,20 @@ export class CCIPBlockTimeNotFoundError extends CCIPError {
825
1748
  });
826
1749
  }
827
1750
  }
828
- /** Thrown when topics are not valid strings. */
1751
+ /**
1752
+ * Thrown when topics are not valid strings.
1753
+ *
1754
+ * @example
1755
+ * ```typescript
1756
+ * try {
1757
+ * await chain.getLogs({ topics: [123] }) // Invalid topic type
1758
+ * } catch (error) {
1759
+ * if (error instanceof CCIPTopicsInvalidError) {
1760
+ * console.log('Topics must be string values')
1761
+ * }
1762
+ * }
1763
+ * ```
1764
+ */
829
1765
  export class CCIPTopicsInvalidError extends CCIPError {
830
1766
  name = 'CCIPTopicsInvalidError';
831
1767
  /** Creates a Solana topics invalid error. */
@@ -837,7 +1773,22 @@ export class CCIPTopicsInvalidError extends CCIPError {
837
1773
  });
838
1774
  }
839
1775
  }
840
- /** Thrown when reference addresses account not found for offRamp. */
1776
+ /**
1777
+ * Thrown when reference addresses account not found for offRamp. Transient: may not be synced.
1778
+ *
1779
+ * @example
1780
+ * ```typescript
1781
+ * try {
1782
+ * await solanaChain.getOffRampForRouter(router)
1783
+ * } catch (error) {
1784
+ * if (error instanceof CCIPSolanaRefAddressesNotFoundError) {
1785
+ * if (error.isTransient) {
1786
+ * await sleep(error.retryAfterMs ?? 5000)
1787
+ * }
1788
+ * }
1789
+ * }
1790
+ * ```
1791
+ */
841
1792
  export class CCIPSolanaRefAddressesNotFoundError extends CCIPError {
842
1793
  name = 'CCIPSolanaRefAddressesNotFoundError';
843
1794
  /** Creates a reference addresses not found error. */
@@ -850,7 +1801,22 @@ export class CCIPSolanaRefAddressesNotFoundError extends CCIPError {
850
1801
  });
851
1802
  }
852
1803
  }
853
- /** Thrown when OffRamp events not found in feeQuoter transactions. */
1804
+ /**
1805
+ * Thrown when OffRamp events not found in feeQuoter transactions. Transient: events may not be indexed.
1806
+ *
1807
+ * @example
1808
+ * ```typescript
1809
+ * try {
1810
+ * await solanaChain.getOffRampsForRouter(router)
1811
+ * } catch (error) {
1812
+ * if (error instanceof CCIPSolanaOffRampEventsNotFoundError) {
1813
+ * if (error.isTransient) {
1814
+ * await sleep(error.retryAfterMs ?? 10000)
1815
+ * }
1816
+ * }
1817
+ * }
1818
+ * ```
1819
+ */
854
1820
  export class CCIPSolanaOffRampEventsNotFoundError extends CCIPError {
855
1821
  name = 'CCIPSolanaOffRampEventsNotFoundError';
856
1822
  /** Creates an offRamp events not found error. */
@@ -863,7 +1829,20 @@ export class CCIPSolanaOffRampEventsNotFoundError extends CCIPError {
863
1829
  });
864
1830
  }
865
1831
  }
866
- /** Thrown when token pool info not found. */
1832
+ /**
1833
+ * Thrown when token pool info not found.
1834
+ *
1835
+ * @example
1836
+ * ```typescript
1837
+ * try {
1838
+ * await chain.getTokenPoolConfigs(tokenPool)
1839
+ * } catch (error) {
1840
+ * if (error instanceof CCIPTokenPoolInfoNotFoundError) {
1841
+ * console.log(`TokenPool not found: ${error.context.tokenPool}`)
1842
+ * }
1843
+ * }
1844
+ * ```
1845
+ */
867
1846
  export class CCIPTokenPoolInfoNotFoundError extends CCIPError {
868
1847
  name = 'CCIPTokenPoolInfoNotFoundError';
869
1848
  /** Creates a token pool info not found error. */
@@ -875,7 +1854,20 @@ export class CCIPTokenPoolInfoNotFoundError extends CCIPError {
875
1854
  });
876
1855
  }
877
1856
  }
878
- /** Thrown when SPL token is invalid or not Token-2022. */
1857
+ /**
1858
+ * Thrown when SPL token is invalid or not Token-2022.
1859
+ *
1860
+ * @example
1861
+ * ```typescript
1862
+ * try {
1863
+ * await solanaChain.getTokenInfo(tokenAddress)
1864
+ * } catch (error) {
1865
+ * if (error instanceof CCIPSplTokenInvalidError) {
1866
+ * console.log(`Invalid SPL token: ${error.context.token}`)
1867
+ * }
1868
+ * }
1869
+ * ```
1870
+ */
879
1871
  export class CCIPSplTokenInvalidError extends CCIPError {
880
1872
  name = 'CCIPSplTokenInvalidError';
881
1873
  /** Creates an SPL token invalid error. */
@@ -887,7 +1879,20 @@ export class CCIPSplTokenInvalidError extends CCIPError {
887
1879
  });
888
1880
  }
889
1881
  }
890
- /** Thrown when token data cannot be parsed. */
1882
+ /**
1883
+ * Thrown when token data cannot be parsed.
1884
+ *
1885
+ * @example
1886
+ * ```typescript
1887
+ * try {
1888
+ * await chain.getTokenInfo(tokenAddress)
1889
+ * } catch (error) {
1890
+ * if (error instanceof CCIPTokenDataParseError) {
1891
+ * console.log(`Cannot parse token: ${error.context.token}`)
1892
+ * }
1893
+ * }
1894
+ * ```
1895
+ */
891
1896
  export class CCIPTokenDataParseError extends CCIPError {
892
1897
  name = 'CCIPTokenDataParseError';
893
1898
  /** Creates a token data parse error. */
@@ -899,7 +1904,20 @@ export class CCIPTokenDataParseError extends CCIPError {
899
1904
  });
900
1905
  }
901
1906
  }
902
- /** Thrown when EVMExtraArgsV2 has unsupported length. */
1907
+ /**
1908
+ * Thrown when EVMExtraArgsV2 has unsupported length.
1909
+ *
1910
+ * @example
1911
+ * ```typescript
1912
+ * try {
1913
+ * SolanaChain.decodeExtraArgs(data)
1914
+ * } catch (error) {
1915
+ * if (error instanceof CCIPExtraArgsLengthInvalidError) {
1916
+ * console.log(`Unsupported length: ${error.context.length}`)
1917
+ * }
1918
+ * }
1919
+ * ```
1920
+ */
903
1921
  export class CCIPExtraArgsLengthInvalidError extends CCIPError {
904
1922
  name = 'CCIPExtraArgsLengthInvalidError';
905
1923
  /** Creates an extraArgs length invalid error. */
@@ -911,7 +1929,20 @@ export class CCIPExtraArgsLengthInvalidError extends CCIPError {
911
1929
  });
912
1930
  }
913
1931
  }
914
- /** Thrown when Solana can only encode EVMExtraArgsV2 but got different args. */
1932
+ /**
1933
+ * Thrown when Solana can only encode EVMExtraArgsV2 but got different args.
1934
+ *
1935
+ * @example
1936
+ * ```typescript
1937
+ * try {
1938
+ * SolanaChain.encodeExtraArgs(unsupportedArgs)
1939
+ * } catch (error) {
1940
+ * if (error instanceof CCIPSolanaExtraArgsEncodingError) {
1941
+ * console.log('Use EVMExtraArgsV2 format for Solana')
1942
+ * }
1943
+ * }
1944
+ * ```
1945
+ */
915
1946
  export class CCIPSolanaExtraArgsEncodingError extends CCIPError {
916
1947
  name = 'CCIPSolanaExtraArgsEncodingError';
917
1948
  /** Creates a Solana extraArgs encoding error. */
@@ -922,7 +1953,20 @@ export class CCIPSolanaExtraArgsEncodingError extends CCIPError {
922
1953
  });
923
1954
  }
924
1955
  }
925
- /** Thrown when log data is missing or not a string. */
1956
+ /**
1957
+ * Thrown when log data is missing or not a string.
1958
+ *
1959
+ * @example
1960
+ * ```typescript
1961
+ * try {
1962
+ * const message = Chain.decodeMessage(log)
1963
+ * } catch (error) {
1964
+ * if (error instanceof CCIPLogDataMissingError) {
1965
+ * console.log('Log data is missing or invalid')
1966
+ * }
1967
+ * }
1968
+ * ```
1969
+ */
926
1970
  export class CCIPLogDataMissingError extends CCIPError {
927
1971
  name = 'CCIPLogDataMissingError';
928
1972
  /** Creates a log data missing error. */
@@ -933,7 +1977,20 @@ export class CCIPLogDataMissingError extends CCIPError {
933
1977
  });
934
1978
  }
935
1979
  }
936
- /** Thrown when ExecutionState is invalid. */
1980
+ /**
1981
+ * Thrown when ExecutionState is invalid.
1982
+ *
1983
+ * @example
1984
+ * ```typescript
1985
+ * try {
1986
+ * const receipt = Chain.decodeReceipt(log)
1987
+ * } catch (error) {
1988
+ * if (error instanceof CCIPExecutionStateInvalidError) {
1989
+ * console.log(`Invalid state: ${error.context.state}`)
1990
+ * }
1991
+ * }
1992
+ * ```
1993
+ */
937
1994
  export class CCIPExecutionStateInvalidError extends CCIPError {
938
1995
  name = 'CCIPExecutionStateInvalidError';
939
1996
  /** Creates an execution state invalid error. */
@@ -945,7 +2002,20 @@ export class CCIPExecutionStateInvalidError extends CCIPError {
945
2002
  });
946
2003
  }
947
2004
  }
948
- /** Thrown when execution report message is not for Solana. */
2005
+ /**
2006
+ * Thrown when execution report message is not for the expected chain.
2007
+ *
2008
+ * @example
2009
+ * ```typescript
2010
+ * try {
2011
+ * await chain.execute({ offRamp, input, wallet })
2012
+ * } catch (error) {
2013
+ * if (error instanceof CCIPExecutionReportChainMismatchError) {
2014
+ * console.log(`Message not for ${error.context.chain}`)
2015
+ * }
2016
+ * }
2017
+ * ```
2018
+ */
949
2019
  export class CCIPExecutionReportChainMismatchError extends CCIPError {
950
2020
  name = 'CCIPExecutionReportChainMismatchError';
951
2021
  /** Creates an execution report chain mismatch error. */
@@ -957,7 +2027,20 @@ export class CCIPExecutionReportChainMismatchError extends CCIPError {
957
2027
  });
958
2028
  }
959
2029
  }
960
- /** Thrown when token pool state PDA not found. */
2030
+ /**
2031
+ * Thrown when token pool state PDA not found.
2032
+ *
2033
+ * @example
2034
+ * ```typescript
2035
+ * try {
2036
+ * await solanaChain.getTokenPoolConfigs(tokenPool)
2037
+ * } catch (error) {
2038
+ * if (error instanceof CCIPTokenPoolStateNotFoundError) {
2039
+ * console.log(`State not found at: ${error.context.tokenPool}`)
2040
+ * }
2041
+ * }
2042
+ * ```
2043
+ */
961
2044
  export class CCIPTokenPoolStateNotFoundError extends CCIPError {
962
2045
  name = 'CCIPTokenPoolStateNotFoundError';
963
2046
  /** Creates a token pool state not found error. */
@@ -969,7 +2052,20 @@ export class CCIPTokenPoolStateNotFoundError extends CCIPError {
969
2052
  });
970
2053
  }
971
2054
  }
972
- /** Thrown when ChainConfig not found for token pool and remote chain. */
2055
+ /**
2056
+ * Thrown when ChainConfig not found for token pool and remote chain.
2057
+ *
2058
+ * @example
2059
+ * ```typescript
2060
+ * try {
2061
+ * await chain.getTokenPoolRemotes(tokenPool, destChainSelector)
2062
+ * } catch (error) {
2063
+ * if (error instanceof CCIPTokenPoolChainConfigNotFoundError) {
2064
+ * console.log(`No config for ${error.context.remoteNetwork}`)
2065
+ * }
2066
+ * }
2067
+ * ```
2068
+ */
973
2069
  export class CCIPTokenPoolChainConfigNotFoundError extends CCIPError {
974
2070
  name = 'CCIPTokenPoolChainConfigNotFoundError';
975
2071
  /** Creates a token pool chain config not found error. */
@@ -982,7 +2078,20 @@ export class CCIPTokenPoolChainConfigNotFoundError extends CCIPError {
982
2078
  }
983
2079
  }
984
2080
  // Aptos-specific errors
985
- /** Thrown when Aptos network is unknown. */
2081
+ /**
2082
+ * Thrown when Aptos network is unknown.
2083
+ *
2084
+ * @example
2085
+ * ```typescript
2086
+ * try {
2087
+ * const chain = await AptosChain.fromUrl('https://unknown-network')
2088
+ * } catch (error) {
2089
+ * if (error instanceof CCIPAptosNetworkUnknownError) {
2090
+ * console.log(`Unknown network: ${error.context.url}`)
2091
+ * }
2092
+ * }
2093
+ * ```
2094
+ */
986
2095
  export class CCIPAptosNetworkUnknownError extends CCIPError {
987
2096
  name = 'CCIPAptosNetworkUnknownError';
988
2097
  /** Creates an Aptos network unknown error. */
@@ -994,7 +2103,20 @@ export class CCIPAptosNetworkUnknownError extends CCIPError {
994
2103
  });
995
2104
  }
996
2105
  }
997
- /** Thrown when Aptos transaction type is invalid. */
2106
+ /**
2107
+ * Thrown when Aptos transaction type is invalid.
2108
+ *
2109
+ * @example
2110
+ * ```typescript
2111
+ * try {
2112
+ * await aptosChain.getMessagesInTx(txHash)
2113
+ * } catch (error) {
2114
+ * if (error instanceof CCIPAptosTransactionTypeInvalidError) {
2115
+ * console.log('Expected user_transaction type')
2116
+ * }
2117
+ * }
2118
+ * ```
2119
+ */
998
2120
  export class CCIPAptosTransactionTypeInvalidError extends CCIPError {
999
2121
  name = 'CCIPAptosTransactionTypeInvalidError';
1000
2122
  /** Creates an Aptos transaction type invalid error. */
@@ -1005,7 +2127,20 @@ export class CCIPAptosTransactionTypeInvalidError extends CCIPError {
1005
2127
  });
1006
2128
  }
1007
2129
  }
1008
- /** Thrown when Aptos registry type is invalid. */
2130
+ /**
2131
+ * Thrown when Aptos registry type is invalid.
2132
+ *
2133
+ * @example
2134
+ * ```typescript
2135
+ * try {
2136
+ * await aptosChain.getTokenAdminRegistryFor(registry)
2137
+ * } catch (error) {
2138
+ * if (error instanceof CCIPAptosRegistryTypeInvalidError) {
2139
+ * console.log(`Expected TokenAdminRegistry, got: ${error.context.actualType}`)
2140
+ * }
2141
+ * }
2142
+ * ```
2143
+ */
1009
2144
  export class CCIPAptosRegistryTypeInvalidError extends CCIPError {
1010
2145
  name = 'CCIPAptosRegistryTypeInvalidError';
1011
2146
  /** Creates an Aptos registry type invalid error. */
@@ -1017,7 +2152,20 @@ export class CCIPAptosRegistryTypeInvalidError extends CCIPError {
1017
2152
  });
1018
2153
  }
1019
2154
  }
1020
- /** Thrown when Aptos log data is invalid. */
2155
+ /**
2156
+ * Thrown when Aptos log data is invalid.
2157
+ *
2158
+ * @example
2159
+ * ```typescript
2160
+ * try {
2161
+ * const message = AptosChain.decodeMessage(log)
2162
+ * } catch (error) {
2163
+ * if (error instanceof CCIPAptosLogInvalidError) {
2164
+ * console.log(`Invalid log: ${error.context.log}`)
2165
+ * }
2166
+ * }
2167
+ * ```
2168
+ */
1021
2169
  export class CCIPAptosLogInvalidError extends CCIPError {
1022
2170
  name = 'CCIPAptosLogInvalidError';
1023
2171
  /** Creates an Aptos log invalid error. */
@@ -1029,7 +2177,22 @@ export class CCIPAptosLogInvalidError extends CCIPError {
1029
2177
  });
1030
2178
  }
1031
2179
  }
1032
- /** Thrown when Aptos address is invalid. */
2180
+ /**
2181
+ * Thrown when Aptos address is invalid.
2182
+ *
2183
+ * @example
2184
+ * ```typescript
2185
+ * import { CCIPDataFormatUnsupportedError } from '@chainlink/ccip-sdk'
2186
+ *
2187
+ * try {
2188
+ * AptosChain.getAddress('invalid-address')
2189
+ * } catch (error) {
2190
+ * if (error instanceof CCIPDataFormatUnsupportedError) {
2191
+ * console.log(`Invalid address: ${error.message}`)
2192
+ * }
2193
+ * }
2194
+ * ```
2195
+ */
1033
2196
  export class CCIPAptosAddressInvalidError extends CCIPError {
1034
2197
  name = 'CCIPAptosAddressInvalidError';
1035
2198
  /** Creates an Aptos address invalid error. */
@@ -1041,7 +2204,20 @@ export class CCIPAptosAddressInvalidError extends CCIPError {
1041
2204
  });
1042
2205
  }
1043
2206
  }
1044
- /** Thrown when Aptos can only encode specific extra args types. */
2207
+ /**
2208
+ * Thrown when Aptos can only encode specific extra args types.
2209
+ *
2210
+ * @example
2211
+ * ```typescript
2212
+ * try {
2213
+ * AptosChain.encodeExtraArgs(unsupportedArgs)
2214
+ * } catch (error) {
2215
+ * if (error instanceof CCIPAptosExtraArgsEncodingError) {
2216
+ * console.log('Use EVMExtraArgsV2 or SVMExtraArgsV1 for Aptos')
2217
+ * }
2218
+ * }
2219
+ * ```
2220
+ */
1045
2221
  export class CCIPAptosExtraArgsEncodingError extends CCIPError {
1046
2222
  name = 'CCIPAptosExtraArgsEncodingError';
1047
2223
  /** Creates an Aptos extraArgs encoding error. */
@@ -1052,7 +2228,20 @@ export class CCIPAptosExtraArgsEncodingError extends CCIPError {
1052
2228
  });
1053
2229
  }
1054
2230
  }
1055
- /** Thrown when Aptos wallet is invalid. */
2231
+ /**
2232
+ * Thrown when Aptos wallet is invalid.
2233
+ *
2234
+ * @example
2235
+ * ```typescript
2236
+ * try {
2237
+ * await aptosChain.sendMessage({ ...opts, wallet: invalidWallet })
2238
+ * } catch (error) {
2239
+ * if (error instanceof CCIPAptosWalletInvalidError) {
2240
+ * console.log('Provide a valid Aptos account wallet')
2241
+ * }
2242
+ * }
2243
+ * ```
2244
+ */
1056
2245
  export class CCIPAptosWalletInvalidError extends CCIPError {
1057
2246
  name = 'CCIPAptosWalletInvalidError';
1058
2247
  /** Creates an Aptos wallet invalid error. */
@@ -1064,7 +2253,20 @@ export class CCIPAptosWalletInvalidError extends CCIPError {
1064
2253
  });
1065
2254
  }
1066
2255
  }
1067
- /** Thrown when Aptos expects EVMExtraArgsV2 reports. */
2256
+ /**
2257
+ * Thrown when Aptos expects EVMExtraArgsV2 reports.
2258
+ *
2259
+ * @example
2260
+ * ```typescript
2261
+ * try {
2262
+ * await aptosChain.execute({ offRamp, input, wallet })
2263
+ * } catch (error) {
2264
+ * if (error instanceof CCIPAptosExtraArgsV2RequiredError) {
2265
+ * console.log('Aptos requires EVMExtraArgsV2 format')
2266
+ * }
2267
+ * }
2268
+ * ```
2269
+ */
1068
2270
  export class CCIPAptosExtraArgsV2RequiredError extends CCIPError {
1069
2271
  name = 'CCIPAptosExtraArgsV2RequiredError';
1070
2272
  /** Creates an Aptos EVMExtraArgsV2 required error. */
@@ -1075,7 +2277,20 @@ export class CCIPAptosExtraArgsV2RequiredError extends CCIPError {
1075
2277
  });
1076
2278
  }
1077
2279
  }
1078
- /** Thrown when token is not registered in Aptos registry. */
2280
+ /**
2281
+ * Thrown when token is not registered in Aptos registry.
2282
+ *
2283
+ * @example
2284
+ * ```typescript
2285
+ * try {
2286
+ * await aptosChain.getRegistryTokenConfig(registry, token)
2287
+ * } catch (error) {
2288
+ * if (error instanceof CCIPAptosTokenNotRegisteredError) {
2289
+ * console.log(`Token ${error.context.token} not in registry`)
2290
+ * }
2291
+ * }
2292
+ * ```
2293
+ */
1079
2294
  export class CCIPAptosTokenNotRegisteredError extends CCIPError {
1080
2295
  name = 'CCIPAptosTokenNotRegisteredError';
1081
2296
  /** Creates an Aptos token not registered error. */
@@ -1087,7 +2302,20 @@ export class CCIPAptosTokenNotRegisteredError extends CCIPError {
1087
2302
  });
1088
2303
  }
1089
2304
  }
1090
- /** Thrown for unexpected Aptos transaction type. */
2305
+ /**
2306
+ * Thrown for unexpected Aptos transaction type.
2307
+ *
2308
+ * @example
2309
+ * ```typescript
2310
+ * try {
2311
+ * await aptosChain.getTransaction(txHash)
2312
+ * } catch (error) {
2313
+ * if (error instanceof CCIPAptosTransactionTypeUnexpectedError) {
2314
+ * console.log(`Unexpected type: ${error.context.type}`)
2315
+ * }
2316
+ * }
2317
+ * ```
2318
+ */
1091
2319
  export class CCIPAptosTransactionTypeUnexpectedError extends CCIPError {
1092
2320
  name = 'CCIPAptosTransactionTypeUnexpectedError';
1093
2321
  /** Creates an Aptos transaction type unexpected error. */
@@ -1099,7 +2327,20 @@ export class CCIPAptosTransactionTypeUnexpectedError extends CCIPError {
1099
2327
  });
1100
2328
  }
1101
2329
  }
1102
- /** Thrown when Aptos address with module is required. */
2330
+ /**
2331
+ * Thrown when Aptos address with module is required.
2332
+ *
2333
+ * @example
2334
+ * ```typescript
2335
+ * try {
2336
+ * await aptosChain.getLogs({ address: '0x1' }) // Missing module
2337
+ * } catch (error) {
2338
+ * if (error instanceof CCIPAptosAddressModuleRequiredError) {
2339
+ * console.log('Provide address with module name')
2340
+ * }
2341
+ * }
2342
+ * ```
2343
+ */
1103
2344
  export class CCIPAptosAddressModuleRequiredError extends CCIPError {
1104
2345
  name = 'CCIPAptosAddressModuleRequiredError';
1105
2346
  /** Creates an Aptos address module required error. */
@@ -1110,8 +2351,46 @@ export class CCIPAptosAddressModuleRequiredError extends CCIPError {
1110
2351
  });
1111
2352
  }
1112
2353
  }
2354
+ /**
2355
+ * Thrown when Aptos topic is invalid.
2356
+ *
2357
+ * @example
2358
+ * ```typescript
2359
+ * try {
2360
+ * await aptosChain.getLogs({ topics: ['invalid'] })
2361
+ * } catch (error) {
2362
+ * if (error instanceof CCIPAptosTopicInvalidError) {
2363
+ * console.log(`Invalid topic: ${error.context.topic}`)
2364
+ * }
2365
+ * }
2366
+ * ```
2367
+ */
2368
+ export class CCIPAptosTopicInvalidError extends CCIPError {
2369
+ name = 'CCIPAptosTopicInvalidError';
2370
+ /** Creates an Aptos topic invalid error. */
2371
+ constructor(topic, options) {
2372
+ super(CCIPErrorCode.APTOS_TOPIC_INVALID, topic ? `Unknown topic event handler="${topic}"` : 'single string topic required', {
2373
+ ...options,
2374
+ isTransient: false,
2375
+ context: { ...options?.context, topic },
2376
+ });
2377
+ }
2378
+ }
1113
2379
  // Borsh
1114
- /** Thrown when Borsh type is unknown. */
2380
+ /**
2381
+ * Thrown when Borsh type is unknown.
2382
+ *
2383
+ * @example
2384
+ * ```typescript
2385
+ * try {
2386
+ * decodeBorsh(data, 'UnknownType')
2387
+ * } catch (error) {
2388
+ * if (error instanceof CCIPBorshTypeUnknownError) {
2389
+ * console.log(`Unknown type: ${error.context.name}`)
2390
+ * }
2391
+ * }
2392
+ * ```
2393
+ */
1115
2394
  export class CCIPBorshTypeUnknownError extends CCIPError {
1116
2395
  name = 'CCIPBorshTypeUnknownError';
1117
2396
  /** Creates a Borsh type unknown error. */
@@ -1123,7 +2402,20 @@ export class CCIPBorshTypeUnknownError extends CCIPError {
1123
2402
  });
1124
2403
  }
1125
2404
  }
1126
- /** Thrown when Borsh method is unknown. */
2405
+ /**
2406
+ * Thrown when Borsh method is unknown.
2407
+ *
2408
+ * @example
2409
+ * ```typescript
2410
+ * try {
2411
+ * callBorshMethod('unknownMethod')
2412
+ * } catch (error) {
2413
+ * if (error instanceof CCIPBorshMethodUnknownError) {
2414
+ * console.log(`Unknown method: ${error.context.method}`)
2415
+ * }
2416
+ * }
2417
+ * ```
2418
+ */
1127
2419
  export class CCIPBorshMethodUnknownError extends CCIPError {
1128
2420
  name = 'CCIPBorshMethodUnknownError';
1129
2421
  /** Creates a Borsh method unknown error. */
@@ -1136,7 +2428,20 @@ export class CCIPBorshMethodUnknownError extends CCIPError {
1136
2428
  }
1137
2429
  }
1138
2430
  // CLI & Validation
1139
- /** Thrown when CLI argument is invalid. */
2431
+ /**
2432
+ * Thrown when CLI argument is invalid.
2433
+ *
2434
+ * @example
2435
+ * ```typescript
2436
+ * try {
2437
+ * parseArguments(['--invalid-arg'])
2438
+ * } catch (error) {
2439
+ * if (error instanceof CCIPArgumentInvalidError) {
2440
+ * console.log(`${error.context.argument}: ${error.context.reason}`)
2441
+ * }
2442
+ * }
2443
+ * ```
2444
+ */
1140
2445
  export class CCIPArgumentInvalidError extends CCIPError {
1141
2446
  name = 'CCIPArgumentInvalidError';
1142
2447
  /** Creates an argument invalid error. */
@@ -1148,7 +2453,22 @@ export class CCIPArgumentInvalidError extends CCIPError {
1148
2453
  });
1149
2454
  }
1150
2455
  }
1151
- /** Thrown when execution receipt not found in tx logs. Transient: receipt may not be indexed yet. */
2456
+ /**
2457
+ * Thrown when execution receipt not found in tx logs. Transient: receipt may not be indexed yet.
2458
+ *
2459
+ * @example
2460
+ * ```typescript
2461
+ * try {
2462
+ * const receipt = await chain.getExecutionReceiptInTx(txHash)
2463
+ * } catch (error) {
2464
+ * if (error instanceof CCIPReceiptNotFoundError) {
2465
+ * if (error.isTransient) {
2466
+ * await sleep(error.retryAfterMs ?? 5000)
2467
+ * }
2468
+ * }
2469
+ * }
2470
+ * ```
2471
+ */
1152
2472
  export class CCIPReceiptNotFoundError extends CCIPError {
1153
2473
  name = 'CCIPReceiptNotFoundError';
1154
2474
  /** Creates a receipt not found error. */
@@ -1161,7 +2481,20 @@ export class CCIPReceiptNotFoundError extends CCIPError {
1161
2481
  });
1162
2482
  }
1163
2483
  }
1164
- /** Thrown when data cannot be parsed. */
2484
+ /**
2485
+ * Thrown when data cannot be parsed.
2486
+ *
2487
+ * @example
2488
+ * ```typescript
2489
+ * try {
2490
+ * const parsed = Chain.parse(data)
2491
+ * } catch (error) {
2492
+ * if (error instanceof CCIPDataParseError) {
2493
+ * console.log(`Parse failed for: ${error.context.data}`)
2494
+ * }
2495
+ * }
2496
+ * ```
2497
+ */
1165
2498
  export class CCIPDataParseError extends CCIPError {
1166
2499
  name = 'CCIPDataParseError';
1167
2500
  /** Creates a data parse error. */
@@ -1174,7 +2507,20 @@ export class CCIPDataParseError extends CCIPError {
1174
2507
  });
1175
2508
  }
1176
2509
  }
1177
- /** Thrown when token not found in supported tokens list. */
2510
+ /**
2511
+ * Thrown when token not found in supported tokens list.
2512
+ *
2513
+ * @example
2514
+ * ```typescript
2515
+ * try {
2516
+ * const tokens = await chain.getSupportedTokens(router, destChainSelector)
2517
+ * } catch (error) {
2518
+ * if (error instanceof CCIPTokenNotFoundError) {
2519
+ * console.log(`Token not found: ${error.context.token}`)
2520
+ * }
2521
+ * }
2522
+ * ```
2523
+ */
1178
2524
  export class CCIPTokenNotFoundError extends CCIPError {
1179
2525
  name = 'CCIPTokenNotFoundError';
1180
2526
  /** Creates a token not found error. */
@@ -1199,7 +2545,20 @@ export class CCIPInsufficientBalanceError extends CCIPError {
1199
2545
  }
1200
2546
  }
1201
2547
  // Solana-specific (additional)
1202
- /** Thrown when router config not found at PDA. */
2548
+ /**
2549
+ * Thrown when router config not found at PDA.
2550
+ *
2551
+ * @example
2552
+ * ```typescript
2553
+ * try {
2554
+ * await solanaChain.getOnRampForRouter(router, destChainSelector)
2555
+ * } catch (error) {
2556
+ * if (error instanceof CCIPSolanaRouterConfigNotFoundError) {
2557
+ * console.log(`Config not found at: ${error.context.configPda}`)
2558
+ * }
2559
+ * }
2560
+ * ```
2561
+ */
1203
2562
  export class CCIPSolanaRouterConfigNotFoundError extends CCIPError {
1204
2563
  name = 'CCIPSolanaRouterConfigNotFoundError';
1205
2564
  /** Creates a Solana router config not found error. */
@@ -1211,7 +2570,20 @@ export class CCIPSolanaRouterConfigNotFoundError extends CCIPError {
1211
2570
  });
1212
2571
  }
1213
2572
  }
1214
- /** Thrown when fee result from router is invalid. */
2573
+ /**
2574
+ * Thrown when fee result from router is invalid.
2575
+ *
2576
+ * @example
2577
+ * ```typescript
2578
+ * try {
2579
+ * const fee = await solanaChain.getFee(router, message)
2580
+ * } catch (error) {
2581
+ * if (error instanceof CCIPSolanaFeeResultInvalidError) {
2582
+ * console.log(`Invalid fee result: ${error.context.result}`)
2583
+ * }
2584
+ * }
2585
+ * ```
2586
+ */
1215
2587
  export class CCIPSolanaFeeResultInvalidError extends CCIPError {
1216
2588
  name = 'CCIPSolanaFeeResultInvalidError';
1217
2589
  /** Creates a Solana fee result invalid error. */
@@ -1223,7 +2595,20 @@ export class CCIPSolanaFeeResultInvalidError extends CCIPError {
1223
2595
  });
1224
2596
  }
1225
2597
  }
1226
- /** Thrown when token mint not found. */
2598
+ /**
2599
+ * Thrown when token mint not found.
2600
+ *
2601
+ * @example
2602
+ * ```typescript
2603
+ * try {
2604
+ * await solanaChain.getTokenInfo(mintAddress)
2605
+ * } catch (error) {
2606
+ * if (error instanceof CCIPTokenMintNotFoundError) {
2607
+ * console.log(`Mint not found: ${error.context.token}`)
2608
+ * }
2609
+ * }
2610
+ * ```
2611
+ */
1227
2612
  export class CCIPTokenMintNotFoundError extends CCIPError {
1228
2613
  name = 'CCIPTokenMintNotFoundError';
1229
2614
  /** Creates a token mint not found error. */
@@ -1235,7 +2620,22 @@ export class CCIPTokenMintNotFoundError extends CCIPError {
1235
2620
  });
1236
2621
  }
1237
2622
  }
1238
- /** Thrown when token mint exists but is not a valid SPL token (wrong owner program). */
2623
+ /**
2624
+ * Thrown when token mint exists but is not a valid SPL token (wrong owner program).
2625
+ *
2626
+ * @example
2627
+ * ```typescript
2628
+ * try {
2629
+ * const tokenInfo = await solanaChain.getTokenInfo(mintAddress)
2630
+ * } catch (error) {
2631
+ * if (error instanceof CCIPTokenMintInvalidError) {
2632
+ * console.log(`Invalid mint: ${error.context.token}`)
2633
+ * console.log(`Owner: ${error.context.actualOwner}`)
2634
+ * console.log(`Expected: ${error.context.expectedOwners.join(' or ')}`)
2635
+ * }
2636
+ * }
2637
+ * ```
2638
+ */
1239
2639
  export class CCIPTokenMintInvalidError extends CCIPError {
1240
2640
  name = 'CCIPTokenMintInvalidError';
1241
2641
  /** Creates a token mint invalid error. */
@@ -1248,7 +2648,20 @@ export class CCIPTokenMintInvalidError extends CCIPError {
1248
2648
  });
1249
2649
  }
1250
2650
  }
1251
- /** Thrown when token amount is invalid. */
2651
+ /**
2652
+ * Thrown when token amount is invalid.
2653
+ *
2654
+ * @example
2655
+ * ```typescript
2656
+ * try {
2657
+ * await chain.sendMessage({ tokenAmounts: [{ token: '', amount: 0n }] })
2658
+ * } catch (error) {
2659
+ * if (error instanceof CCIPTokenAmountInvalidError) {
2660
+ * console.log('Token address and positive amount required')
2661
+ * }
2662
+ * }
2663
+ * ```
2664
+ */
1252
2665
  export class CCIPTokenAmountInvalidError extends CCIPError {
1253
2666
  name = 'CCIPTokenAmountInvalidError';
1254
2667
  /** Creates a token amount invalid error. */
@@ -1259,7 +2672,21 @@ export class CCIPTokenAmountInvalidError extends CCIPError {
1259
2672
  });
1260
2673
  }
1261
2674
  }
1262
- /** Thrown when token account (e.g., Solana ATA) does not exist for holder. */
2675
+ /**
2676
+ * Thrown when token account (e.g., Solana ATA) does not exist for holder.
2677
+ *
2678
+ * @example
2679
+ * ```typescript
2680
+ * try {
2681
+ * const balance = await solanaChain.getBalance({ address: holder, token: mint })
2682
+ * } catch (error) {
2683
+ * if (error instanceof CCIPTokenAccountNotFoundError) {
2684
+ * console.log(`No ATA for token ${error.context.token}`)
2685
+ * console.log(`Holder: ${error.context.holder}`)
2686
+ * }
2687
+ * }
2688
+ * ```
2689
+ */
1263
2690
  export class CCIPTokenAccountNotFoundError extends CCIPError {
1264
2691
  name = 'CCIPTokenAccountNotFoundError';
1265
2692
  /** Creates a token account not found error. */
@@ -1271,7 +2698,22 @@ export class CCIPTokenAccountNotFoundError extends CCIPError {
1271
2698
  });
1272
2699
  }
1273
2700
  }
1274
- /** Thrown when transaction not finalized after timeout. */
2701
+ /**
2702
+ * Thrown when transaction not finalized after timeout. Transient: may need more time.
2703
+ *
2704
+ * @example
2705
+ * ```typescript
2706
+ * try {
2707
+ * await chain.waitFinalized(txHash)
2708
+ * } catch (error) {
2709
+ * if (error instanceof CCIPTransactionNotFinalizedError) {
2710
+ * if (error.isTransient) {
2711
+ * await sleep(error.retryAfterMs ?? 10000)
2712
+ * }
2713
+ * }
2714
+ * }
2715
+ * ```
2716
+ */
1275
2717
  export class CCIPTransactionNotFinalizedError extends CCIPError {
1276
2718
  name = 'CCIPTransactionNotFinalizedError';
1277
2719
  /** Creates a transaction not finalized error. */
@@ -1284,7 +2726,20 @@ export class CCIPTransactionNotFinalizedError extends CCIPError {
1284
2726
  });
1285
2727
  }
1286
2728
  }
1287
- /** Thrown when CCTP event decode fails. */
2729
+ /**
2730
+ * Thrown when CCTP event decode fails.
2731
+ *
2732
+ * @example
2733
+ * ```typescript
2734
+ * try {
2735
+ * const cctpData = decodeCctpEvent(log)
2736
+ * } catch (error) {
2737
+ * if (error instanceof CCIPCctpDecodeError) {
2738
+ * console.log(`CCTP decode failed: ${error.context.log}`)
2739
+ * }
2740
+ * }
2741
+ * ```
2742
+ */
1288
2743
  export class CCIPCctpDecodeError extends CCIPError {
1289
2744
  name = 'CCIPCctpDecodeError';
1290
2745
  /** Creates a CCTP decode error. */
@@ -1296,7 +2751,20 @@ export class CCIPCctpDecodeError extends CCIPError {
1296
2751
  });
1297
2752
  }
1298
2753
  }
1299
- /** Thrown when Sui hasher version is unsupported. */
2754
+ /**
2755
+ * Thrown when Sui hasher version is unsupported.
2756
+ *
2757
+ * @example
2758
+ * ```typescript
2759
+ * try {
2760
+ * const hasher = SuiChain.getDestLeafHasher(lane)
2761
+ * } catch (error) {
2762
+ * if (error instanceof CCIPSuiHasherVersionUnsupportedError) {
2763
+ * console.log(`Unsupported hasher: ${error.context.version}`)
2764
+ * }
2765
+ * }
2766
+ * ```
2767
+ */
1300
2768
  export class CCIPSuiHasherVersionUnsupportedError extends CCIPError {
1301
2769
  name = 'CCIPSuiHasherVersionUnsupportedError';
1302
2770
  /** Creates a Sui hasher version unsupported error. */
@@ -1308,7 +2776,20 @@ export class CCIPSuiHasherVersionUnsupportedError extends CCIPError {
1308
2776
  });
1309
2777
  }
1310
2778
  }
1311
- /** Thrown when Sui message version is invalid. */
2779
+ /**
2780
+ * Thrown when Sui message version is invalid.
2781
+ *
2782
+ * @example
2783
+ * ```typescript
2784
+ * try {
2785
+ * const message = SuiChain.decodeMessage(log)
2786
+ * } catch (error) {
2787
+ * if (error instanceof CCIPSuiMessageVersionInvalidError) {
2788
+ * console.log('Only CCIP v1.6 format is supported for Sui')
2789
+ * }
2790
+ * }
2791
+ * ```
2792
+ */
1312
2793
  export class CCIPSuiMessageVersionInvalidError extends CCIPError {
1313
2794
  name = 'CCIPSuiMessageVersionInvalidError';
1314
2795
  /** Creates a Sui message version invalid error. */
@@ -1319,10 +2800,31 @@ export class CCIPSuiMessageVersionInvalidError extends CCIPError {
1319
2800
  });
1320
2801
  }
1321
2802
  }
1322
- /** Thrown when Sui log data is invalid. */
2803
+ /**
2804
+ * Thrown when Sui log data is invalid.
2805
+ *
2806
+ * This error occurs when attempting to decode a Sui event log that doesn't
2807
+ * conform to the expected CCIP message format.
2808
+ *
2809
+ * @example
2810
+ * ```typescript
2811
+ * try {
2812
+ * const message = SuiChain.decodeMessage(log)
2813
+ * } catch (error) {
2814
+ * if (error instanceof CCIPSuiLogInvalidError) {
2815
+ * console.log('Invalid Sui log format:', error.context.log)
2816
+ * }
2817
+ * }
2818
+ * ```
2819
+ */
1323
2820
  export class CCIPSuiLogInvalidError extends CCIPError {
1324
2821
  name = 'CCIPSuiLogInvalidError';
1325
- /** Creates a Sui log invalid error. */
2822
+ /**
2823
+ * Creates a Sui log invalid error.
2824
+ *
2825
+ * @param log - The invalid log data
2826
+ * @param options - Additional error options
2827
+ */
1326
2828
  constructor(log, options) {
1327
2829
  super(CCIPErrorCode.LOG_DATA_INVALID, `Invalid sui log: ${String(log)}`, {
1328
2830
  ...options,
@@ -1331,7 +2833,20 @@ export class CCIPSuiLogInvalidError extends CCIPError {
1331
2833
  });
1332
2834
  }
1333
2835
  }
1334
- /** Thrown when Solana lane version is unsupported. */
2836
+ /**
2837
+ * Thrown when Solana lane version is unsupported.
2838
+ *
2839
+ * @example
2840
+ * ```typescript
2841
+ * try {
2842
+ * const lane = await solanaChain.getLane(onRamp, offRamp)
2843
+ * } catch (error) {
2844
+ * if (error instanceof CCIPSolanaLaneVersionUnsupportedError) {
2845
+ * console.log(`Unsupported version: ${error.context.version}`)
2846
+ * }
2847
+ * }
2848
+ * ```
2849
+ */
1335
2850
  export class CCIPSolanaLaneVersionUnsupportedError extends CCIPError {
1336
2851
  name = 'CCIPSolanaLaneVersionUnsupportedError';
1337
2852
  /** Creates a Solana lane version unsupported error. */
@@ -1343,7 +2858,20 @@ export class CCIPSolanaLaneVersionUnsupportedError extends CCIPError {
1343
2858
  });
1344
2859
  }
1345
2860
  }
1346
- /** Thrown when multiple CCTP events found in transaction. */
2861
+ /**
2862
+ * Thrown when multiple CCTP events found in transaction.
2863
+ *
2864
+ * @example
2865
+ * ```typescript
2866
+ * try {
2867
+ * const cctpData = await chain.getOffchainTokenData(request)
2868
+ * } catch (error) {
2869
+ * if (error instanceof CCIPCctpMultipleEventsError) {
2870
+ * console.log(`Found ${error.context.count} events, expected 1`)
2871
+ * }
2872
+ * }
2873
+ * ```
2874
+ */
1347
2875
  export class CCIPCctpMultipleEventsError extends CCIPError {
1348
2876
  name = 'CCIPCctpMultipleEventsError';
1349
2877
  /** Creates a CCTP multiple events error. */
@@ -1355,7 +2883,20 @@ export class CCIPCctpMultipleEventsError extends CCIPError {
1355
2883
  });
1356
2884
  }
1357
2885
  }
1358
- /** Thrown when compute units exceed limit. */
2886
+ /**
2887
+ * Thrown when compute units exceed limit.
2888
+ *
2889
+ * @example
2890
+ * ```typescript
2891
+ * try {
2892
+ * await solanaChain.execute({ offRamp, input, wallet })
2893
+ * } catch (error) {
2894
+ * if (error instanceof CCIPSolanaComputeUnitsExceededError) {
2895
+ * console.log(`CU: ${error.context.simulated} > limit ${error.context.limit}`)
2896
+ * }
2897
+ * }
2898
+ * ```
2899
+ */
1359
2900
  export class CCIPSolanaComputeUnitsExceededError extends CCIPError {
1360
2901
  name = 'CCIPSolanaComputeUnitsExceededError';
1361
2902
  /** Creates a compute units exceeded error. */
@@ -1367,7 +2908,20 @@ export class CCIPSolanaComputeUnitsExceededError extends CCIPError {
1367
2908
  });
1368
2909
  }
1369
2910
  }
1370
- /** Thrown when Aptos hasher version is unsupported. */
2911
+ /**
2912
+ * Thrown when Aptos hasher version is unsupported.
2913
+ *
2914
+ * @example
2915
+ * ```typescript
2916
+ * try {
2917
+ * const hasher = AptosChain.getDestLeafHasher(lane)
2918
+ * } catch (error) {
2919
+ * if (error instanceof CCIPAptosHasherVersionUnsupportedError) {
2920
+ * console.log(`Unsupported hasher: ${error.context.version}`)
2921
+ * }
2922
+ * }
2923
+ * ```
2924
+ */
1371
2925
  export class CCIPAptosHasherVersionUnsupportedError extends CCIPError {
1372
2926
  name = 'CCIPAptosHasherVersionUnsupportedError';
1373
2927
  /** Creates an Aptos hasher version unsupported error. */
@@ -1380,7 +2934,21 @@ export class CCIPAptosHasherVersionUnsupportedError extends CCIPError {
1380
2934
  }
1381
2935
  }
1382
2936
  // API Client
1383
- /** Thrown when API client is not available (explicitly opted out). */
2937
+ /**
2938
+ * Thrown when API client is not available (explicitly opted out).
2939
+ *
2940
+ * @example
2941
+ * ```typescript
2942
+ * const chain = await EVMChain.fromUrl(rpc, { apiClient: null }) // Opt-out of API
2943
+ * try {
2944
+ * await chain.getLaneLatency(destChainSelector)
2945
+ * } catch (error) {
2946
+ * if (error instanceof CCIPApiClientNotAvailableError) {
2947
+ * console.log('API client disabled - initialize with apiClient or remove opt-out')
2948
+ * }
2949
+ * }
2950
+ * ```
2951
+ */
1384
2952
  export class CCIPApiClientNotAvailableError extends CCIPError {
1385
2953
  name = 'CCIPApiClientNotAvailableError';
1386
2954
  /**
@@ -1391,15 +2959,24 @@ export class CCIPApiClientNotAvailableError extends CCIPError {
1391
2959
  super(CCIPErrorCode.API_CLIENT_NOT_AVAILABLE, 'CCIP API client is not available. Initialize with an apiClient or remove the explicit opt-out (apiClient: null).', { ...options, isTransient: false });
1392
2960
  }
1393
2961
  }
1394
- /** Thrown when API returns hasNextPage=true unexpectedly (more than 100 messages). */
2962
+ /**
2963
+ * Thrown when API returns hasNextPage=true unexpectedly (more than 100 messages).
2964
+ *
2965
+ * @example
2966
+ * ```typescript
2967
+ * try {
2968
+ * const messages = await chain.getMessagesInTx(txHash)
2969
+ * } catch (error) {
2970
+ * if (error instanceof CCIPUnexpectedPaginationError) {
2971
+ * console.log(`Too many messages in tx: ${error.context.txHash}`)
2972
+ * console.log(`Message count: ${error.context.messageCount}+`)
2973
+ * }
2974
+ * }
2975
+ * ```
2976
+ */
1395
2977
  export class CCIPUnexpectedPaginationError extends CCIPError {
1396
2978
  name = 'CCIPUnexpectedPaginationError';
1397
- /**
1398
- * Creates an unexpected pagination error.
1399
- * @param txHash - The transaction hash queried
1400
- * @param messageCount - Number of messages returned in the response
1401
- * @param options - Additional error options
1402
- */
2979
+ /** Creates an unexpected pagination error. */
1403
2980
  constructor(txHash, messageCount, options) {
1404
2981
  super(CCIPErrorCode.API_UNEXPECTED_PAGINATION, `Transaction ${txHash} contains more CCIP messages than expected (${messageCount}+ returned with hasNextPage=true)`, {
1405
2982
  ...options,
@@ -1409,7 +2986,22 @@ export class CCIPUnexpectedPaginationError extends CCIPError {
1409
2986
  }
1410
2987
  }
1411
2988
  // Viem Adapter
1412
- /** Thrown when viem adapter encounters an issue. */
2989
+ /**
2990
+ * Thrown when viem adapter encounters an issue.
2991
+ *
2992
+ * @example
2993
+ * ```typescript
2994
+ * import { fromViemClient } from '@chainlink/ccip-sdk/viem'
2995
+ *
2996
+ * try {
2997
+ * const chain = await fromViemClient(viemClient)
2998
+ * } catch (error) {
2999
+ * if (error instanceof CCIPViemAdapterError) {
3000
+ * console.log(`Viem adapter error: ${error.message}`)
3001
+ * }
3002
+ * }
3003
+ * ```
3004
+ */
1413
3005
  export class CCIPViemAdapterError extends CCIPError {
1414
3006
  name = 'CCIPViemAdapterError';
1415
3007
  /**