@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
@@ -4,7 +4,23 @@ import { isTransientHttpStatus } from '../http-status.ts'
4
4
 
5
5
  // Chain/Network
6
6
 
7
- /** Thrown when chain not found by chainId, selector, or name. */
7
+ /**
8
+ * Thrown when chain not found by chainId, selector, or name.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * import { networkInfo } from '@chainlink/ccip-sdk'
13
+ *
14
+ * try {
15
+ * const info = networkInfo(999999) // Unknown chain
16
+ * } catch (error) {
17
+ * if (error instanceof CCIPChainNotFoundError) {
18
+ * console.log(`Chain not found: ${error.context.chainIdOrSelector}`)
19
+ * console.log(`Recovery: ${error.recovery}`)
20
+ * }
21
+ * }
22
+ * ```
23
+ */
8
24
  export class CCIPChainNotFoundError extends CCIPError {
9
25
  override readonly name = 'CCIPChainNotFoundError'
10
26
  /** Creates a chain not found error. */
@@ -17,7 +33,20 @@ export class CCIPChainNotFoundError extends CCIPError {
17
33
  }
18
34
  }
19
35
 
20
- /** Thrown when chain family is not supported. */
36
+ /**
37
+ * Thrown when chain family is not supported.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * try {
42
+ * const chain = await createChain('unsupported-family')
43
+ * } catch (error) {
44
+ * if (error instanceof CCIPChainFamilyUnsupportedError) {
45
+ * console.log(`Unsupported family: ${error.context.family}`)
46
+ * }
47
+ * }
48
+ * ```
49
+ */
21
50
  export class CCIPChainFamilyUnsupportedError extends CCIPError {
22
51
  override readonly name = 'CCIPChainFamilyUnsupportedError'
23
52
  /** Creates a chain family unsupported error. */
@@ -30,7 +59,20 @@ export class CCIPChainFamilyUnsupportedError extends CCIPError {
30
59
  }
31
60
  }
32
61
 
33
- /** Thrown when some method/operation is not supported on a given implementation class. */
62
+ /**
63
+ * Thrown when a method or operation is not supported on a given implementation class.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * try {
68
+ * await chain.someUnsupportedMethod()
69
+ * } catch (error) {
70
+ * if (error instanceof CCIPMethodUnsupportedError) {
71
+ * console.log(`Method not supported: ${error.context.class}.${error.context.method}`)
72
+ * }
73
+ * }
74
+ * ```
75
+ */
34
76
  export class CCIPMethodUnsupportedError extends CCIPError {
35
77
  override readonly name = 'CCIPMethodUnsupportedError'
36
78
  /** Creates a method unsupported error. */
@@ -45,7 +87,22 @@ export class CCIPMethodUnsupportedError extends CCIPError {
45
87
 
46
88
  // Block & Transaction
47
89
 
48
- /** Thrown when block not found. Transient: block may not be indexed yet. */
90
+ /**
91
+ * Thrown when block not found. Transient: block may not be indexed yet.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * try {
96
+ * const timestamp = await chain.getBlockTimestamp(999999999)
97
+ * } catch (error) {
98
+ * if (error instanceof CCIPBlockNotFoundError) {
99
+ * if (error.isTransient) {
100
+ * console.log(`Block not indexed yet, retry in ${error.retryAfterMs}ms`)
101
+ * }
102
+ * }
103
+ * }
104
+ * ```
105
+ */
49
106
  export class CCIPBlockNotFoundError extends CCIPError {
50
107
  override readonly name = 'CCIPBlockNotFoundError'
51
108
  /** Creates a block not found error. */
@@ -59,7 +116,23 @@ export class CCIPBlockNotFoundError extends CCIPError {
59
116
  }
60
117
  }
61
118
 
62
- /** Thrown when transaction not found. Transient: tx may be pending. */
119
+ /**
120
+ * Thrown when transaction not found. Transient: tx may be pending.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * try {
125
+ * const tx = await chain.getTransaction('0x1234...')
126
+ * } catch (error) {
127
+ * if (error instanceof CCIPTransactionNotFoundError) {
128
+ * if (error.isTransient) {
129
+ * await sleep(error.retryAfterMs ?? 5000)
130
+ * // Retry the operation
131
+ * }
132
+ * }
133
+ * }
134
+ * ```
135
+ */
63
136
  export class CCIPTransactionNotFoundError extends CCIPError {
64
137
  override readonly name = 'CCIPTransactionNotFoundError'
65
138
  /** Creates a transaction not found error. */
@@ -75,7 +148,20 @@ export class CCIPTransactionNotFoundError extends CCIPError {
75
148
 
76
149
  // CCIP Message
77
150
 
78
- /** Thrown when message format is invalid. */
151
+ /**
152
+ * Thrown when message format is invalid.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * try {
157
+ * const message = EVMChain.decodeMessage(invalidLog)
158
+ * } catch (error) {
159
+ * if (error instanceof CCIPMessageInvalidError) {
160
+ * console.log(`Invalid message format: ${error.message}`)
161
+ * }
162
+ * }
163
+ * ```
164
+ */
79
165
  export class CCIPMessageInvalidError extends CCIPError {
80
166
  override readonly name = 'CCIPMessageInvalidError'
81
167
  /** Creates a message invalid error. */
@@ -89,25 +175,50 @@ export class CCIPMessageInvalidError extends CCIPError {
89
175
  }
90
176
  }
91
177
 
92
- /** Thrown when no CCIPSendRequested event in tx. Transient: tx may not be indexed. */
178
+ /**
179
+ * Thrown when no CCIPSendRequested event in tx. Transient: tx may not be indexed.
180
+ *
181
+ * @example
182
+ * ```typescript
183
+ * try {
184
+ * const messages = await chain.getMessagesInTx('0x1234...')
185
+ * } catch (error) {
186
+ * if (error instanceof CCIPMessageNotFoundInTxError) {
187
+ * if (error.isTransient) {
188
+ * console.log(`Message not indexed yet, retry in ${error.retryAfterMs}ms`)
189
+ * }
190
+ * }
191
+ * }
192
+ * ```
193
+ */
93
194
  export class CCIPMessageNotFoundInTxError extends CCIPError {
94
195
  override readonly name = 'CCIPMessageNotFoundInTxError'
95
196
  /** Creates a message not found in transaction error. */
96
197
  constructor(txHash: string, options?: CCIPErrorOptions) {
97
- super(
98
- CCIPErrorCode.MESSAGE_NOT_FOUND_IN_TX,
99
- `Could not find any CCIPSendRequested message in tx: ${txHash}`,
100
- {
101
- ...options,
102
- isTransient: true,
103
- retryAfterMs: 30000,
104
- context: { ...options?.context, txHash },
105
- },
106
- )
198
+ super(CCIPErrorCode.MESSAGE_NOT_FOUND_IN_TX, `Could not find any CCIP request event in tx`, {
199
+ ...options,
200
+ isTransient: false,
201
+ context: { ...options?.context, txHash },
202
+ })
107
203
  }
108
204
  }
109
205
 
110
- /** Thrown when message with messageId not found. Transient: message may be in transit. */
206
+ /**
207
+ * Thrown when message with messageId not found. Transient: message may be in transit.
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * try {
212
+ * const request = await getMessageById(chain, messageId, onRamp)
213
+ * } catch (error) {
214
+ * if (error instanceof CCIPMessageIdNotFoundError) {
215
+ * if (error.isTransient) {
216
+ * console.log(`Message in transit, retry in ${error.retryAfterMs}ms`)
217
+ * }
218
+ * }
219
+ * }
220
+ * ```
221
+ */
111
222
  export class CCIPMessageIdNotFoundError extends CCIPError {
112
223
  override readonly name = 'CCIPMessageIdNotFoundError'
113
224
  /** Creates a message ID not found error. */
@@ -125,7 +236,21 @@ export class CCIPMessageIdNotFoundError extends CCIPError {
125
236
  }
126
237
  }
127
238
 
128
- /** Thrown when messageId format is invalid. */
239
+ /**
240
+ * Thrown when messageId format is invalid.
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * try {
245
+ * const request = await chain.getMessageById('invalid-format')
246
+ * } catch (error) {
247
+ * if (error instanceof CCIPMessageIdValidationError) {
248
+ * console.log(`Invalid messageId: ${error.message}`)
249
+ * // Not transient - fix the messageId format
250
+ * }
251
+ * }
252
+ * ```
253
+ */
129
254
  export class CCIPMessageIdValidationError extends CCIPError {
130
255
  override readonly name = 'CCIPMessageIdValidationError'
131
256
  /** Creates a message ID validation error. */
@@ -137,7 +262,23 @@ export class CCIPMessageIdValidationError extends CCIPError {
137
262
  }
138
263
  }
139
264
 
140
- /** Thrown when not all messages in batch were found. Transient: may still be indexing. */
265
+ /**
266
+ * Thrown when not all messages in batch were found. Transient: may still be indexing.
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * try {
271
+ * const messages = await getMessagesInBatch(chain, request, commit)
272
+ * } catch (error) {
273
+ * if (error instanceof CCIPMessageBatchIncompleteError) {
274
+ * console.log(`Found ${error.context.foundSeqNums.length} of expected range`)
275
+ * if (error.isTransient) {
276
+ * await sleep(error.retryAfterMs ?? 30000)
277
+ * }
278
+ * }
279
+ * }
280
+ * ```
281
+ */
141
282
  export class CCIPMessageBatchIncompleteError extends CCIPError {
142
283
  override readonly name = 'CCIPMessageBatchIncompleteError'
143
284
  /** Creates a message batch incomplete error. */
@@ -159,7 +300,20 @@ export class CCIPMessageBatchIncompleteError extends CCIPError {
159
300
  }
160
301
  }
161
302
 
162
- /** Thrown when message not in expected batch. */
303
+ /**
304
+ * Thrown when message not in expected batch.
305
+ *
306
+ * @example
307
+ * ```typescript
308
+ * try {
309
+ * const proof = calculateManualExecProof(messages, lane, messageId)
310
+ * } catch (error) {
311
+ * if (error instanceof CCIPMessageNotInBatchError) {
312
+ * console.log(`Message ${error.context.messageId} not in batch range`)
313
+ * }
314
+ * }
315
+ * ```
316
+ */
163
317
  export class CCIPMessageNotInBatchError extends CCIPError {
164
318
  override readonly name = 'CCIPMessageNotInBatchError'
165
319
  /** Creates a message not in batch error. */
@@ -180,7 +334,21 @@ export class CCIPMessageNotInBatchError extends CCIPError {
180
334
  }
181
335
  }
182
336
 
183
- /** Thrown when message retrieval fails via both API and RPC. */
337
+ /**
338
+ * Thrown when message retrieval fails via both API and RPC.
339
+ *
340
+ * @example
341
+ * ```typescript
342
+ * try {
343
+ * const request = await chain.getMessageById('0xabc123...')
344
+ * } catch (error) {
345
+ * if (error instanceof CCIPMessageRetrievalError) {
346
+ * console.log(`Failed to retrieve message: ${error.message}`)
347
+ * console.log(`Recovery: ${error.recovery}`)
348
+ * }
349
+ * }
350
+ * ```
351
+ */
184
352
  export class CCIPMessageRetrievalError extends CCIPError {
185
353
  override readonly name = 'CCIPMessageRetrievalError'
186
354
  /** Creates a message retrieval error with both API and RPC failure context. */
@@ -214,7 +382,21 @@ export class CCIPMessageRetrievalError extends CCIPError {
214
382
 
215
383
  // Lane & Routing
216
384
 
217
- /** Thrown when no offRamp found for lane. */
385
+ /**
386
+ * Thrown when no offRamp found for lane.
387
+ *
388
+ * @example
389
+ * ```typescript
390
+ * try {
391
+ * const offRamp = await discoverOffRamp(source, dest, request)
392
+ * } catch (error) {
393
+ * if (error instanceof CCIPOffRampNotFoundError) {
394
+ * console.log(`No offRamp for ${error.context.onRamp} on ${error.context.destNetwork}`)
395
+ * console.log(`Recovery: ${error.recovery}`)
396
+ * }
397
+ * }
398
+ * ```
399
+ */
218
400
  export class CCIPOffRampNotFoundError extends CCIPError {
219
401
  override readonly name = 'CCIPOffRampNotFoundError'
220
402
  /** Creates an offRamp not found error. */
@@ -231,7 +413,20 @@ export class CCIPOffRampNotFoundError extends CCIPError {
231
413
  }
232
414
  }
233
415
 
234
- /** Thrown when onRamp required but not provided. */
416
+ /**
417
+ * Thrown when onRamp required but not provided.
418
+ *
419
+ * @example
420
+ * ```typescript
421
+ * try {
422
+ * const lane = await chain.getLaneForOnRamp(undefined)
423
+ * } catch (error) {
424
+ * if (error instanceof CCIPOnRampRequiredError) {
425
+ * console.log('onRamp address is required for this operation')
426
+ * }
427
+ * }
428
+ * ```
429
+ */
235
430
  export class CCIPOnRampRequiredError extends CCIPError {
236
431
  override readonly name = 'CCIPOnRampRequiredError'
237
432
  /** Creates an onRamp required error. */
@@ -243,7 +438,20 @@ export class CCIPOnRampRequiredError extends CCIPError {
243
438
  }
244
439
  }
245
440
 
246
- /** Thrown when lane not found between source and destination chains. */
441
+ /**
442
+ * Thrown when lane not found between source and destination chains.
443
+ *
444
+ * @example
445
+ * ```typescript
446
+ * try {
447
+ * const lane = await discoverLane(sourceChainSelector, destChainSelector)
448
+ * } catch (error) {
449
+ * if (error instanceof CCIPLaneNotFoundError) {
450
+ * console.log(`No lane: ${error.context.sourceChainSelector} → ${error.context.destChainSelector}`)
451
+ * }
452
+ * }
453
+ * ```
454
+ */
247
455
  export class CCIPLaneNotFoundError extends CCIPError {
248
456
  override readonly name = 'CCIPLaneNotFoundError'
249
457
  /** Creates a lane not found error. */
@@ -262,7 +470,22 @@ export class CCIPLaneNotFoundError extends CCIPError {
262
470
 
263
471
  // Commit & Merkle
264
472
 
265
- /** Thrown when commit report not found. Transient: DON may not have committed yet. */
473
+ /**
474
+ * Thrown when commit report not found. Transient: DON may not have committed yet.
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * try {
479
+ * const verifications = await chain.getVerifications({ offRamp, request })
480
+ * } catch (error) {
481
+ * if (error instanceof CCIPCommitNotFoundError) {
482
+ * if (error.isTransient) {
483
+ * console.log(`Commit pending, retry in ${error.retryAfterMs}ms`)
484
+ * }
485
+ * }
486
+ * }
487
+ * ```
488
+ */
266
489
  export class CCIPCommitNotFoundError extends CCIPError {
267
490
  override readonly name = 'CCIPCommitNotFoundError'
268
491
  /** Creates a commit not found error. */
@@ -280,7 +503,20 @@ export class CCIPCommitNotFoundError extends CCIPError {
280
503
  }
281
504
  }
282
505
 
283
- /** Thrown when merkle root verification fails. */
506
+ /**
507
+ * Thrown when merkle root verification fails.
508
+ *
509
+ * @example
510
+ * ```typescript
511
+ * try {
512
+ * const proof = calculateManualExecProof(messages, lane, messageId, merkleRoot)
513
+ * } catch (error) {
514
+ * if (error instanceof CCIPMerkleRootMismatchError) {
515
+ * console.log(`Root mismatch: expected=${error.context.expected}, got=${error.context.got}`)
516
+ * }
517
+ * }
518
+ * ```
519
+ */
284
520
  export class CCIPMerkleRootMismatchError extends CCIPError {
285
521
  override readonly name = 'CCIPMerkleRootMismatchError'
286
522
  /** Creates a merkle root mismatch error. */
@@ -297,7 +533,20 @@ export class CCIPMerkleRootMismatchError extends CCIPError {
297
533
  }
298
534
  }
299
535
 
300
- /** Thrown when attempting to create tree without leaves. */
536
+ /**
537
+ * Thrown when attempting to create tree without leaves.
538
+ *
539
+ * @example
540
+ * ```typescript
541
+ * try {
542
+ * const root = createMerkleTree([])
543
+ * } catch (error) {
544
+ * if (error instanceof CCIPMerkleTreeEmptyError) {
545
+ * console.log('Cannot create merkle tree without messages')
546
+ * }
547
+ * }
548
+ * ```
549
+ */
301
550
  export class CCIPMerkleTreeEmptyError extends CCIPError {
302
551
  override readonly name = 'CCIPMerkleTreeEmptyError'
303
552
  /** Creates a merkle tree empty error. */
@@ -315,7 +564,20 @@ export class CCIPMerkleTreeEmptyError extends CCIPError {
315
564
 
316
565
  // Version
317
566
 
318
- /** Thrown when CCIP version not supported. */
567
+ /**
568
+ * Thrown when CCIP version not supported.
569
+ *
570
+ * @example
571
+ * ```typescript
572
+ * try {
573
+ * const [type, version] = await chain.typeAndVersion(contractAddress)
574
+ * } catch (error) {
575
+ * if (error instanceof CCIPVersionUnsupportedError) {
576
+ * console.log(`Version ${error.context.version} not supported`)
577
+ * }
578
+ * }
579
+ * ```
580
+ */
319
581
  export class CCIPVersionUnsupportedError extends CCIPError {
320
582
  override readonly name = 'CCIPVersionUnsupportedError'
321
583
  /** Creates a version unsupported error. */
@@ -328,7 +590,20 @@ export class CCIPVersionUnsupportedError extends CCIPError {
328
590
  }
329
591
  }
330
592
 
331
- /** Thrown when hasher version not supported for chain. */
593
+ /**
594
+ * Thrown when hasher version not supported for chain.
595
+ *
596
+ * @example
597
+ * ```typescript
598
+ * try {
599
+ * const hasher = getLeafHasher(lane)
600
+ * } catch (error) {
601
+ * if (error instanceof CCIPHasherVersionUnsupportedError) {
602
+ * console.log(`Hasher not available for ${error.context.chain} v${error.context.version}`)
603
+ * }
604
+ * }
605
+ * ```
606
+ */
332
607
  export class CCIPHasherVersionUnsupportedError extends CCIPError {
333
608
  override readonly name = 'CCIPHasherVersionUnsupportedError'
334
609
  /** Creates a hasher version unsupported error. */
@@ -347,7 +622,20 @@ export class CCIPHasherVersionUnsupportedError extends CCIPError {
347
622
 
348
623
  // ExtraArgs
349
624
 
350
- /** Thrown when extraArgs cannot be parsed. */
625
+ /**
626
+ * Thrown when extraArgs cannot be parsed.
627
+ *
628
+ * @example
629
+ * ```typescript
630
+ * try {
631
+ * const args = decodeExtraArgs(invalidData)
632
+ * } catch (error) {
633
+ * if (error instanceof CCIPExtraArgsParseError) {
634
+ * console.log(`Cannot parse extraArgs: ${error.context.from}`)
635
+ * }
636
+ * }
637
+ * ```
638
+ */
351
639
  export class CCIPExtraArgsParseError extends CCIPError {
352
640
  override readonly name = 'CCIPExtraArgsParseError'
353
641
  /** Creates an extraArgs parse error. */
@@ -365,6 +653,17 @@ export class CCIPExtraArgsParseError extends CCIPError {
365
653
  *
366
654
  * @param chainFamily - Display name for the chain family (user-facing, differs from ChainFamily enum)
367
655
  * @param extraArgs - The actual invalid extraArgs value (for debugging)
656
+ *
657
+ * @example
658
+ * ```typescript
659
+ * try {
660
+ * const encoded = encodeExtraArgs({ gasLimit: -1n }, 'EVM')
661
+ * } catch (error) {
662
+ * if (error instanceof CCIPExtraArgsInvalidError) {
663
+ * console.log(`Invalid extraArgs for ${error.context.chainFamily}`)
664
+ * }
665
+ * }
666
+ * ```
368
667
  */
369
668
  export class CCIPExtraArgsInvalidError extends CCIPError {
370
669
  override readonly name = 'CCIPExtraArgsInvalidError'
@@ -395,7 +694,20 @@ export class CCIPExtraArgsInvalidError extends CCIPError {
395
694
 
396
695
  // Token & Registry
397
696
 
398
- /** Thrown when token not found in registry. */
697
+ /**
698
+ * Thrown when token not found in registry.
699
+ *
700
+ * @example
701
+ * ```typescript
702
+ * try {
703
+ * const config = await chain.getRegistryTokenConfig(registry, tokenAddress)
704
+ * } catch (error) {
705
+ * if (error instanceof CCIPTokenNotInRegistryError) {
706
+ * console.log(`Token ${error.context.token} not in ${error.context.registry}`)
707
+ * }
708
+ * }
709
+ * ```
710
+ */
399
711
  export class CCIPTokenNotInRegistryError extends CCIPError {
400
712
  override readonly name = 'CCIPTokenNotInRegistryError'
401
713
  /** Creates a token not in registry error. */
@@ -408,7 +720,20 @@ export class CCIPTokenNotInRegistryError extends CCIPError {
408
720
  }
409
721
  }
410
722
 
411
- /** Thrown when token not configured in registry. */
723
+ /**
724
+ * Thrown when token not configured in registry.
725
+ *
726
+ * @example
727
+ * ```typescript
728
+ * try {
729
+ * const pool = await chain.getTokenPoolConfigs(tokenPool)
730
+ * } catch (error) {
731
+ * if (error instanceof CCIPTokenNotConfiguredError) {
732
+ * console.log(`Token ${error.context.token} not configured`)
733
+ * }
734
+ * }
735
+ * ```
736
+ */
412
737
  export class CCIPTokenNotConfiguredError extends CCIPError {
413
738
  override readonly name = 'CCIPTokenNotConfiguredError'
414
739
  /** Creates a token not configured error. */
@@ -425,7 +750,20 @@ export class CCIPTokenNotConfiguredError extends CCIPError {
425
750
  }
426
751
  }
427
752
 
428
- /** Thrown when destination token decimals insufficient. */
753
+ /**
754
+ * Thrown when destination token decimals insufficient.
755
+ *
756
+ * @example
757
+ * ```typescript
758
+ * try {
759
+ * const amounts = await sourceToDestTokenAmounts(source, dest, tokenAmounts)
760
+ * } catch (error) {
761
+ * if (error instanceof CCIPTokenDecimalsInsufficientError) {
762
+ * console.log(`Cannot express ${error.context.amount} with ${error.context.destDecimals} decimals`)
763
+ * }
764
+ * }
765
+ * ```
766
+ */
429
767
  export class CCIPTokenDecimalsInsufficientError extends CCIPError {
430
768
  override readonly name = 'CCIPTokenDecimalsInsufficientError'
431
769
  /** Creates a token decimals insufficient error. */
@@ -450,7 +788,20 @@ export class CCIPTokenDecimalsInsufficientError extends CCIPError {
450
788
 
451
789
  // Contract Type
452
790
 
453
- /** Thrown when contract type is not as expected. */
791
+ /**
792
+ * Thrown when contract type is not as expected.
793
+ *
794
+ * @example
795
+ * ```typescript
796
+ * try {
797
+ * const router = await chain.getRouterForOnRamp(address)
798
+ * } catch (error) {
799
+ * if (error instanceof CCIPContractTypeInvalidError) {
800
+ * console.log(`${error.context.address} is "${error.context.actualType}", expected ${error.context.expectedTypes}`)
801
+ * }
802
+ * }
803
+ * ```
804
+ */
454
805
  export class CCIPContractTypeInvalidError extends CCIPError {
455
806
  override readonly name = 'CCIPContractTypeInvalidError'
456
807
  /** Creates a contract type invalid error. */
@@ -474,7 +825,20 @@ export class CCIPContractTypeInvalidError extends CCIPError {
474
825
 
475
826
  // Wallet & Signer
476
827
 
477
- /** Thrown when wallet must be Signer but isn't. */
828
+ /**
829
+ * Thrown when wallet must be Signer but isn't.
830
+ *
831
+ * @example
832
+ * ```typescript
833
+ * try {
834
+ * await chain.sendMessage({ ...opts, wallet: provider })
835
+ * } catch (error) {
836
+ * if (error instanceof CCIPWalletNotSignerError) {
837
+ * console.log('Wallet must be a Signer to send transactions')
838
+ * }
839
+ * }
840
+ * ```
841
+ */
478
842
  export class CCIPWalletNotSignerError extends CCIPError {
479
843
  override readonly name = 'CCIPWalletNotSignerError'
480
844
  /** Creates a wallet not signer error. */
@@ -489,7 +853,22 @@ export class CCIPWalletNotSignerError extends CCIPError {
489
853
 
490
854
  // Execution
491
855
 
492
- /** Thrown when exec tx not confirmed. Transient: may need more time. */
856
+ /**
857
+ * Thrown when exec tx not confirmed. Transient: may need more time.
858
+ *
859
+ * @example
860
+ * ```typescript
861
+ * try {
862
+ * await chain.execute({ offRamp, input, wallet })
863
+ * } catch (error) {
864
+ * if (error instanceof CCIPExecTxNotConfirmedError) {
865
+ * if (error.isTransient) {
866
+ * await sleep(error.retryAfterMs ?? 5000)
867
+ * }
868
+ * }
869
+ * }
870
+ * ```
871
+ */
493
872
  export class CCIPExecTxNotConfirmedError extends CCIPError {
494
873
  override readonly name = 'CCIPExecTxNotConfirmedError'
495
874
  /** Creates an exec transaction not confirmed error. */
@@ -503,7 +882,20 @@ export class CCIPExecTxNotConfirmedError extends CCIPError {
503
882
  }
504
883
  }
505
884
 
506
- /** Thrown when exec tx reverted. */
885
+ /**
886
+ * Thrown when exec tx reverted.
887
+ *
888
+ * @example
889
+ * ```typescript
890
+ * try {
891
+ * await chain.execute({ offRamp, input, wallet })
892
+ * } catch (error) {
893
+ * if (error instanceof CCIPExecTxRevertedError) {
894
+ * console.log(`Execution reverted: ${error.context.txHash}`)
895
+ * }
896
+ * }
897
+ * ```
898
+ */
507
899
  export class CCIPExecTxRevertedError extends CCIPError {
508
900
  override readonly name = 'CCIPExecTxRevertedError'
509
901
  /** Creates an exec transaction reverted error. */
@@ -518,7 +910,22 @@ export class CCIPExecTxRevertedError extends CCIPError {
518
910
 
519
911
  // Attestation (USDC/LBTC)
520
912
 
521
- /** Thrown when USDC attestation fetch fails. Transient: attestation may not be ready. */
913
+ /**
914
+ * Thrown when USDC attestation fetch fails. Transient: attestation may not be ready.
915
+ *
916
+ * @example
917
+ * ```typescript
918
+ * try {
919
+ * const offchainData = await chain.getOffchainTokenData(request)
920
+ * } catch (error) {
921
+ * if (error instanceof CCIPUsdcAttestationError) {
922
+ * if (error.isTransient) {
923
+ * console.log(`USDC attestation pending, retry in ${error.retryAfterMs}ms`)
924
+ * }
925
+ * }
926
+ * }
927
+ * ```
928
+ */
522
929
  export class CCIPUsdcAttestationError extends CCIPError {
523
930
  override readonly name = 'CCIPUsdcAttestationError'
524
931
  /** Creates a USDC attestation error. */
@@ -536,7 +943,22 @@ export class CCIPUsdcAttestationError extends CCIPError {
536
943
  }
537
944
  }
538
945
 
539
- /** Thrown when LBTC attestation fetch fails. Transient: attestation may not be ready. */
946
+ /**
947
+ * Thrown when LBTC attestation fetch fails. Transient: attestation may not be ready.
948
+ *
949
+ * @example
950
+ * ```typescript
951
+ * try {
952
+ * const offchainData = await chain.getOffchainTokenData(request)
953
+ * } catch (error) {
954
+ * if (error instanceof CCIPLbtcAttestationError) {
955
+ * if (error.isTransient) {
956
+ * console.log(`LBTC attestation pending, retry in ${error.retryAfterMs}ms`)
957
+ * }
958
+ * }
959
+ * }
960
+ * ```
961
+ */
540
962
  export class CCIPLbtcAttestationError extends CCIPError {
541
963
  override readonly name = 'CCIPLbtcAttestationError'
542
964
  /** Creates an LBTC attestation error. */
@@ -554,7 +976,23 @@ export class CCIPLbtcAttestationError extends CCIPError {
554
976
  }
555
977
  }
556
978
 
557
- /** Thrown when LBTC attestation not found for payload hash. Transient: may not be processed yet. */
979
+ /**
980
+ * Thrown when LBTC attestation not found for payload hash. Transient: may not be processed yet.
981
+ *
982
+ * @example
983
+ * ```typescript
984
+ * try {
985
+ * const offchainData = await chain.getOffchainTokenData(request)
986
+ * } catch (error) {
987
+ * if (error instanceof CCIPLbtcAttestationNotFoundError) {
988
+ * console.log(`Attestation not found for hash: ${error.context.payloadHash}`)
989
+ * if (error.isTransient) {
990
+ * await sleep(error.retryAfterMs ?? 30000)
991
+ * }
992
+ * }
993
+ * }
994
+ * ```
995
+ */
558
996
  export class CCIPLbtcAttestationNotFoundError extends CCIPError {
559
997
  override readonly name = 'CCIPLbtcAttestationNotFoundError'
560
998
  /** Creates an LBTC attestation not found error. */
@@ -572,7 +1010,23 @@ export class CCIPLbtcAttestationNotFoundError extends CCIPError {
572
1010
  }
573
1011
  }
574
1012
 
575
- /** Thrown when LBTC attestation is not yet approved. Transient: may be pending notarization. */
1013
+ /**
1014
+ * Thrown when LBTC attestation is not yet approved. Transient: may be pending notarization.
1015
+ *
1016
+ * @example
1017
+ * ```typescript
1018
+ * try {
1019
+ * const offchainData = await chain.getOffchainTokenData(request)
1020
+ * } catch (error) {
1021
+ * if (error instanceof CCIPLbtcAttestationNotApprovedError) {
1022
+ * console.log(`Attestation pending approval for: ${error.context.payloadHash}`)
1023
+ * if (error.isTransient) {
1024
+ * await sleep(error.retryAfterMs ?? 30000)
1025
+ * }
1026
+ * }
1027
+ * }
1028
+ * ```
1029
+ */
576
1030
  export class CCIPLbtcAttestationNotApprovedError extends CCIPError {
577
1031
  override readonly name = 'CCIPLbtcAttestationNotApprovedError'
578
1032
  /** Creates an LBTC attestation not approved error. */
@@ -592,7 +1046,22 @@ export class CCIPLbtcAttestationNotApprovedError extends CCIPError {
592
1046
 
593
1047
  // Solana
594
1048
 
595
- /** Thrown when lookup table not found. Transient: may not be synced yet. */
1049
+ /**
1050
+ * Thrown when lookup table not found. Transient: may not be synced yet.
1051
+ *
1052
+ * @example
1053
+ * ```typescript
1054
+ * try {
1055
+ * const lookupTable = await solanaChain.getLookupTable(address)
1056
+ * } catch (error) {
1057
+ * if (error instanceof CCIPSolanaLookupTableNotFoundError) {
1058
+ * if (error.isTransient) {
1059
+ * console.log(`Lookup table not synced, retry in ${error.retryAfterMs}ms`)
1060
+ * }
1061
+ * }
1062
+ * }
1063
+ * ```
1064
+ */
596
1065
  export class CCIPSolanaLookupTableNotFoundError extends CCIPError {
597
1066
  override readonly name = 'CCIPSolanaLookupTableNotFoundError'
598
1067
  /** Creates a Solana lookup table not found error. */
@@ -612,7 +1081,20 @@ export class CCIPSolanaLookupTableNotFoundError extends CCIPError {
612
1081
 
613
1082
  // Aptos
614
1083
 
615
- /** Thrown for invalid Aptos transaction hash or version. */
1084
+ /**
1085
+ * Thrown for invalid Aptos transaction hash or version.
1086
+ *
1087
+ * @example
1088
+ * ```typescript
1089
+ * try {
1090
+ * const tx = await aptosChain.getTransaction('invalid-hash')
1091
+ * } catch (error) {
1092
+ * if (error instanceof CCIPAptosTransactionInvalidError) {
1093
+ * console.log(`Invalid tx: ${error.context.hashOrVersion}`)
1094
+ * }
1095
+ * }
1096
+ * ```
1097
+ */
616
1098
  export class CCIPAptosTransactionInvalidError extends CCIPError {
617
1099
  override readonly name = 'CCIPAptosTransactionInvalidError'
618
1100
  /** Creates an Aptos transaction invalid error. */
@@ -627,7 +1109,23 @@ export class CCIPAptosTransactionInvalidError extends CCIPError {
627
1109
 
628
1110
  // HTTP & Data
629
1111
 
630
- /** Thrown for HTTP errors. Transient if 429 or 5xx. */
1112
+ /**
1113
+ * Thrown for HTTP errors. Transient if 429 or 5xx.
1114
+ *
1115
+ * @example
1116
+ * ```typescript
1117
+ * try {
1118
+ * const latency = await chain.getLaneLatency(destChainSelector)
1119
+ * } catch (error) {
1120
+ * if (error instanceof CCIPHttpError) {
1121
+ * console.log(`HTTP ${error.context.status}: ${error.context.statusText}`)
1122
+ * if (error.isTransient) {
1123
+ * // 429 or 5xx - safe to retry
1124
+ * }
1125
+ * }
1126
+ * }
1127
+ * ```
1128
+ */
631
1129
  export class CCIPHttpError extends CCIPError {
632
1130
  override readonly name = 'CCIPHttpError'
633
1131
  /** Creates an HTTP error. */
@@ -640,7 +1138,23 @@ export class CCIPHttpError extends CCIPError {
640
1138
  }
641
1139
  }
642
1140
 
643
- /** Thrown when a request times out. Transient: network may recover. */
1141
+ /**
1142
+ * Thrown when a request times out. Transient: network may recover.
1143
+ *
1144
+ * @example
1145
+ * ```typescript
1146
+ * try {
1147
+ * const tx = await chain.getTransaction('0x1234...')
1148
+ * } catch (error) {
1149
+ * if (error instanceof CCIPTimeoutError) {
1150
+ * console.log(`Operation timed out: ${error.context.operation}`)
1151
+ * if (error.isTransient) {
1152
+ * console.log(`Retry in ${error.retryAfterMs}ms`)
1153
+ * }
1154
+ * }
1155
+ * }
1156
+ * ```
1157
+ */
644
1158
  export class CCIPTimeoutError extends CCIPError {
645
1159
  override readonly name = 'CCIPTimeoutError'
646
1160
  /** Creates a timeout error. */
@@ -654,7 +1168,20 @@ export class CCIPTimeoutError extends CCIPError {
654
1168
  }
655
1169
  }
656
1170
 
657
- /** Thrown for not implemented features. */
1171
+ /**
1172
+ * Thrown for not implemented features.
1173
+ *
1174
+ * @example
1175
+ * ```typescript
1176
+ * try {
1177
+ * await chain.someUnimplementedMethod()
1178
+ * } catch (error) {
1179
+ * if (error instanceof CCIPNotImplementedError) {
1180
+ * console.log(`Feature not implemented: ${error.context.feature}`)
1181
+ * }
1182
+ * }
1183
+ * ```
1184
+ */
658
1185
  export class CCIPNotImplementedError extends CCIPError {
659
1186
  override readonly name = 'CCIPNotImplementedError'
660
1187
  /** Creates a not implemented error. */
@@ -673,7 +1200,20 @@ export class CCIPNotImplementedError extends CCIPError {
673
1200
 
674
1201
  // Data Format & Parsing
675
1202
 
676
- /** Thrown when data format is not supported. */
1203
+ /**
1204
+ * Thrown when data format is not supported.
1205
+ *
1206
+ * @example
1207
+ * ```typescript
1208
+ * try {
1209
+ * const parsed = parseData(unknownFormat)
1210
+ * } catch (error) {
1211
+ * if (error instanceof CCIPDataFormatUnsupportedError) {
1212
+ * console.log(`Unsupported format: ${error.context.data}`)
1213
+ * }
1214
+ * }
1215
+ * ```
1216
+ */
677
1217
  export class CCIPDataFormatUnsupportedError extends CCIPError {
678
1218
  override readonly name = 'CCIPDataFormatUnsupportedError'
679
1219
  /** Creates a data format unsupported error. */
@@ -686,7 +1226,20 @@ export class CCIPDataFormatUnsupportedError extends CCIPError {
686
1226
  }
687
1227
  }
688
1228
 
689
- /** Thrown when typeAndVersion string cannot be parsed. */
1229
+ /**
1230
+ * Thrown when typeAndVersion string cannot be parsed.
1231
+ *
1232
+ * @example
1233
+ * ```typescript
1234
+ * try {
1235
+ * const [type, version] = await chain.typeAndVersion(contractAddress)
1236
+ * } catch (error) {
1237
+ * if (error instanceof CCIPTypeVersionInvalidError) {
1238
+ * console.log(`Cannot parse: ${error.context.typeAndVersion}`)
1239
+ * }
1240
+ * }
1241
+ * ```
1242
+ */
690
1243
  export class CCIPTypeVersionInvalidError extends CCIPError {
691
1244
  override readonly name = 'CCIPTypeVersionInvalidError'
692
1245
  /** Creates a type version invalid error. */
@@ -699,7 +1252,20 @@ export class CCIPTypeVersionInvalidError extends CCIPError {
699
1252
  }
700
1253
  }
701
1254
 
702
- /** Thrown when no block found before timestamp. */
1255
+ /**
1256
+ * Thrown when no block found before timestamp.
1257
+ *
1258
+ * @example
1259
+ * ```typescript
1260
+ * try {
1261
+ * const block = await chain.getBlockBeforeTimestamp(timestamp)
1262
+ * } catch (error) {
1263
+ * if (error instanceof CCIPBlockBeforeTimestampNotFoundError) {
1264
+ * console.log(`No block before timestamp: ${error.context.timestamp}`)
1265
+ * }
1266
+ * }
1267
+ * ```
1268
+ */
703
1269
  export class CCIPBlockBeforeTimestampNotFoundError extends CCIPError {
704
1270
  override readonly name = 'CCIPBlockBeforeTimestampNotFoundError'
705
1271
  /** Creates a block before timestamp not found error. */
@@ -716,7 +1282,20 @@ export class CCIPBlockBeforeTimestampNotFoundError extends CCIPError {
716
1282
  }
717
1283
  }
718
1284
 
719
- /** Thrown when message decoding fails. */
1285
+ /**
1286
+ * Thrown when message decoding fails.
1287
+ *
1288
+ * @example
1289
+ * ```typescript
1290
+ * try {
1291
+ * const message = EVMChain.decodeMessage(log)
1292
+ * } catch (error) {
1293
+ * if (error instanceof CCIPMessageDecodeError) {
1294
+ * console.log(`Decode failed: ${error.context.reason}`)
1295
+ * }
1296
+ * }
1297
+ * ```
1298
+ */
720
1299
  export class CCIPMessageDecodeError extends CCIPError {
721
1300
  override readonly name = 'CCIPMessageDecodeError'
722
1301
  /** Creates a message decode error. */
@@ -733,7 +1312,46 @@ export class CCIPMessageDecodeError extends CCIPError {
733
1312
  }
734
1313
  }
735
1314
 
736
- /** Thrown when RPC endpoint not found. */
1315
+ /**
1316
+ * Thrown when network family is not supported for an operation.
1317
+ *
1318
+ * @example
1319
+ * ```typescript
1320
+ * try {
1321
+ * const chain = await Chain.fromUrl(rpcUrl)
1322
+ * } catch (error) {
1323
+ * if (error instanceof CCIPNetworkFamilyUnsupportedError) {
1324
+ * console.log(`Unsupported family: ${error.context.family}`)
1325
+ * }
1326
+ * }
1327
+ * ```
1328
+ */
1329
+ export class CCIPNetworkFamilyUnsupportedError extends CCIPError {
1330
+ override readonly name = 'CCIPNetworkFamilyUnsupportedError'
1331
+ /** Creates a network family unsupported error. */
1332
+ constructor(family: string, options?: CCIPErrorOptions) {
1333
+ super(CCIPErrorCode.NETWORK_FAMILY_UNSUPPORTED, `Unsupported network family: ${family}`, {
1334
+ ...options,
1335
+ isTransient: false,
1336
+ context: { ...options?.context, family },
1337
+ })
1338
+ }
1339
+ }
1340
+
1341
+ /**
1342
+ * Thrown when RPC endpoint not found.
1343
+ *
1344
+ * @example
1345
+ * ```typescript
1346
+ * try {
1347
+ * const chain = await EVMChain.fromUrl(rpcUrl)
1348
+ * } catch (error) {
1349
+ * if (error instanceof CCIPRpcNotFoundError) {
1350
+ * console.log(`No RPC for chainId: ${error.context.chainId}`)
1351
+ * }
1352
+ * }
1353
+ * ```
1354
+ */
737
1355
  export class CCIPRpcNotFoundError extends CCIPError {
738
1356
  override readonly name = 'CCIPRpcNotFoundError'
739
1357
  /** Creates an RPC not found error. */
@@ -746,7 +1364,22 @@ export class CCIPRpcNotFoundError extends CCIPError {
746
1364
  }
747
1365
  }
748
1366
 
749
- /** Thrown when logs not found for filter criteria. */
1367
+ /**
1368
+ * Thrown when logs not found for filter criteria. Transient: logs may not be indexed yet.
1369
+ *
1370
+ * @example
1371
+ * ```typescript
1372
+ * try {
1373
+ * const logs = await chain.getLogs(filter)
1374
+ * } catch (error) {
1375
+ * if (error instanceof CCIPLogsNotFoundError) {
1376
+ * if (error.isTransient) {
1377
+ * await sleep(error.retryAfterMs ?? 5000)
1378
+ * }
1379
+ * }
1380
+ * }
1381
+ * ```
1382
+ */
750
1383
  export class CCIPLogsNotFoundError extends CCIPError {
751
1384
  override readonly name = 'CCIPLogsNotFoundError'
752
1385
  /** Creates a logs not found error. */
@@ -760,7 +1393,20 @@ export class CCIPLogsNotFoundError extends CCIPError {
760
1393
  }
761
1394
  }
762
1395
 
763
- /** Thrown when log topics not found. */
1396
+ /**
1397
+ * Thrown when log topics not found.
1398
+ *
1399
+ * @example
1400
+ * ```typescript
1401
+ * try {
1402
+ * const logs = await chain.getLogs({ topics: ['0xunknown'] })
1403
+ * } catch (error) {
1404
+ * if (error instanceof CCIPLogTopicsNotFoundError) {
1405
+ * console.log(`Topics not matched: ${error.context.topics}`)
1406
+ * }
1407
+ * }
1408
+ * ```
1409
+ */
764
1410
  export class CCIPLogTopicsNotFoundError extends CCIPError {
765
1411
  override readonly name = 'CCIPLogTopicsNotFoundError'
766
1412
  /** Creates a log topics not found error. */
@@ -773,10 +1419,23 @@ export class CCIPLogTopicsNotFoundError extends CCIPError {
773
1419
  }
774
1420
  }
775
1421
 
776
- /** Thrown when trying to `watch` logs but giving a fixed `endBlock` */
1422
+ /**
1423
+ * Thrown when trying to `watch` logs but giving a fixed `endBlock`.
1424
+ *
1425
+ * @example
1426
+ * ```typescript
1427
+ * try {
1428
+ * await chain.watchLogs({ endBlock: 1000 }) // Fixed endBlock not allowed
1429
+ * } catch (error) {
1430
+ * if (error instanceof CCIPLogsWatchRequiresFinalityError) {
1431
+ * console.log('Use "latest" or "finalized" for endBlock in watch mode')
1432
+ * }
1433
+ * }
1434
+ * ```
1435
+ */
777
1436
  export class CCIPLogsWatchRequiresFinalityError extends CCIPError {
778
1437
  override readonly name = 'CCIPLogsWatchRequiresFinalityError'
779
- /** Creates a watch requires finality error. */
1438
+ /** Creates a logs watch requires finality error. */
780
1439
  constructor(endBlock?: number | string, options?: CCIPErrorOptions) {
781
1440
  super(
782
1441
  CCIPErrorCode.LOGS_WATCH_REQUIRES_FINALITY,
@@ -786,10 +1445,23 @@ export class CCIPLogsWatchRequiresFinalityError extends CCIPError {
786
1445
  }
787
1446
  }
788
1447
 
789
- /** Thrown when trying to `watch` logs without a start point. */
1448
+ /**
1449
+ * Thrown when trying to `watch` logs but no start position provided.
1450
+ *
1451
+ * @example
1452
+ * ```typescript
1453
+ * try {
1454
+ * await chain.watchLogs({}) // Missing startBlock or startTime
1455
+ * } catch (error) {
1456
+ * if (error instanceof CCIPLogsWatchRequiresStartError) {
1457
+ * console.log('Provide startBlock or startTime for watch mode')
1458
+ * }
1459
+ * }
1460
+ * ```
1461
+ */
790
1462
  export class CCIPLogsWatchRequiresStartError extends CCIPError {
791
1463
  override readonly name = 'CCIPLogsWatchRequiresStartError'
792
- /** Creates a watch requires start error. */
1464
+ /** Creates a logs watch requires start error. */
793
1465
  constructor(options?: CCIPErrorOptions) {
794
1466
  super(CCIPErrorCode.LOGS_WATCH_REQUIRES_START, `Watch mode requires startBlock or startTime`, {
795
1467
  ...options,
@@ -798,7 +1470,20 @@ export class CCIPLogsWatchRequiresStartError extends CCIPError {
798
1470
  }
799
1471
  }
800
1472
 
801
- /** Thrown when address is required for logs filtering, but not provided. */
1473
+ /**
1474
+ * Thrown when address is required for logs filtering, but not provided.
1475
+ *
1476
+ * @example
1477
+ * ```typescript
1478
+ * try {
1479
+ * await chain.getLogs({ topics: [...] }) // Missing address
1480
+ * } catch (error) {
1481
+ * if (error instanceof CCIPLogsAddressRequiredError) {
1482
+ * console.log('Contract address is required for this chain')
1483
+ * }
1484
+ * }
1485
+ * ```
1486
+ */
802
1487
  export class CCIPLogsAddressRequiredError extends CCIPError {
803
1488
  override readonly name = 'CCIPLogsAddressRequiredError'
804
1489
  /** Creates a Solana program address required error. */
@@ -812,7 +1497,20 @@ export class CCIPLogsAddressRequiredError extends CCIPError {
812
1497
 
813
1498
  // Chain Family
814
1499
 
815
- /** Thrown when network family does not match expected for a Chain constructor. */
1500
+ /**
1501
+ * Thrown when network family does not match expected for a Chain constructor.
1502
+ *
1503
+ * @example
1504
+ * ```typescript
1505
+ * try {
1506
+ * const chain = new EVMChain(provider, solanaNetworkInfo) // Wrong family
1507
+ * } catch (error) {
1508
+ * if (error instanceof CCIPChainFamilyMismatchError) {
1509
+ * console.log(`Expected ${error.context.expected}, got ${error.context.actual}`)
1510
+ * }
1511
+ * }
1512
+ * ```
1513
+ */
816
1514
  export class CCIPChainFamilyMismatchError extends CCIPError {
817
1515
  override readonly name = 'CCIPChainFamilyMismatchError'
818
1516
  /** Creates a chain family mismatch error. */
@@ -829,9 +1527,49 @@ export class CCIPChainFamilyMismatchError extends CCIPError {
829
1527
  }
830
1528
  }
831
1529
 
1530
+ // Token Pool
1531
+
1532
+ /**
1533
+ * Thrown when legacy (pre-1.5) token pools are not supported.
1534
+ *
1535
+ * @example
1536
+ * ```typescript
1537
+ * try {
1538
+ * await chain.getTokenPoolConfigs(legacyPool)
1539
+ * } catch (error) {
1540
+ * if (error instanceof CCIPLegacyTokenPoolsUnsupportedError) {
1541
+ * console.log('Upgrade to CCIP v1.5+ token pools')
1542
+ * }
1543
+ * }
1544
+ * ```
1545
+ */
1546
+ export class CCIPLegacyTokenPoolsUnsupportedError extends CCIPError {
1547
+ override readonly name = 'CCIPLegacyTokenPoolsUnsupportedError'
1548
+ /** Creates a legacy token pools unsupported error. */
1549
+ constructor(options?: CCIPErrorOptions) {
1550
+ super(CCIPErrorCode.LEGACY_TOKEN_POOLS_UNSUPPORTED, 'Legacy <1.5 token pools not supported', {
1551
+ ...options,
1552
+ isTransient: false,
1553
+ })
1554
+ }
1555
+ }
1556
+
832
1557
  // Merkle Validation
833
1558
 
834
- /** Thrown when merkle proof is empty. */
1559
+ /**
1560
+ * Thrown when merkle proof is empty.
1561
+ *
1562
+ * @example
1563
+ * ```typescript
1564
+ * try {
1565
+ * verifyMerkleProof({ leaves: [], proofs: [] })
1566
+ * } catch (error) {
1567
+ * if (error instanceof CCIPMerkleProofEmptyError) {
1568
+ * console.log('Cannot verify empty merkle proof')
1569
+ * }
1570
+ * }
1571
+ * ```
1572
+ */
835
1573
  export class CCIPMerkleProofEmptyError extends CCIPError {
836
1574
  override readonly name = 'CCIPMerkleProofEmptyError'
837
1575
  /** Creates a merkle proof empty error. */
@@ -847,7 +1585,20 @@ export class CCIPMerkleProofEmptyError extends CCIPError {
847
1585
  }
848
1586
  }
849
1587
 
850
- /** Thrown when merkle leaves or proofs exceed max limit. */
1588
+ /**
1589
+ * Thrown when merkle leaves or proofs exceed max limit.
1590
+ *
1591
+ * @example
1592
+ * ```typescript
1593
+ * try {
1594
+ * verifyMerkleProof({ leaves: largeArray, proofs })
1595
+ * } catch (error) {
1596
+ * if (error instanceof CCIPMerkleProofTooLargeError) {
1597
+ * console.log(`Proof exceeds limit: ${error.context.limit}`)
1598
+ * }
1599
+ * }
1600
+ * ```
1601
+ */
851
1602
  export class CCIPMerkleProofTooLargeError extends CCIPError {
852
1603
  override readonly name = 'CCIPMerkleProofTooLargeError'
853
1604
  /** Creates a merkle proof too large error. */
@@ -860,7 +1611,20 @@ export class CCIPMerkleProofTooLargeError extends CCIPError {
860
1611
  }
861
1612
  }
862
1613
 
863
- /** Thrown when total hashes exceed max merkle tree size. */
1614
+ /**
1615
+ * Thrown when total hashes exceed max merkle tree size.
1616
+ *
1617
+ * @example
1618
+ * ```typescript
1619
+ * try {
1620
+ * createMerkleTree(hashes)
1621
+ * } catch (error) {
1622
+ * if (error instanceof CCIPMerkleHashesTooLargeError) {
1623
+ * console.log(`${error.context.totalHashes} exceeds limit ${error.context.limit}`)
1624
+ * }
1625
+ * }
1626
+ * ```
1627
+ */
864
1628
  export class CCIPMerkleHashesTooLargeError extends CCIPError {
865
1629
  override readonly name = 'CCIPMerkleHashesTooLargeError'
866
1630
  /** Creates a merkle hashes too large error. */
@@ -877,7 +1641,20 @@ export class CCIPMerkleHashesTooLargeError extends CCIPError {
877
1641
  }
878
1642
  }
879
1643
 
880
- /** Thrown when source flags count does not match expected total. */
1644
+ /**
1645
+ * Thrown when source flags count does not match expected total.
1646
+ *
1647
+ * @example
1648
+ * ```typescript
1649
+ * try {
1650
+ * verifyMerkleProof({ hashes, sourceFlags })
1651
+ * } catch (error) {
1652
+ * if (error instanceof CCIPMerkleFlagsMismatchError) {
1653
+ * console.log(`Hashes: ${error.context.totalHashes}, Flags: ${error.context.flagsLength}`)
1654
+ * }
1655
+ * }
1656
+ * ```
1657
+ */
881
1658
  export class CCIPMerkleFlagsMismatchError extends CCIPError {
882
1659
  override readonly name = 'CCIPMerkleFlagsMismatchError'
883
1660
  /** Creates a merkle flags mismatch error. */
@@ -894,7 +1671,20 @@ export class CCIPMerkleFlagsMismatchError extends CCIPError {
894
1671
  }
895
1672
  }
896
1673
 
897
- /** Thrown when proof source flags count does not match proof hashes. */
1674
+ /**
1675
+ * Thrown when proof source flags count does not match proof hashes.
1676
+ *
1677
+ * @example
1678
+ * ```typescript
1679
+ * try {
1680
+ * verifyMerkleProof({ sourceFlags, proofs })
1681
+ * } catch (error) {
1682
+ * if (error instanceof CCIPMerkleProofFlagsMismatchError) {
1683
+ * console.log(`Flags: ${error.context.sourceProofCount}, Proofs: ${error.context.proofsLength}`)
1684
+ * }
1685
+ * }
1686
+ * ```
1687
+ */
898
1688
  export class CCIPMerkleProofFlagsMismatchError extends CCIPError {
899
1689
  override readonly name = 'CCIPMerkleProofFlagsMismatchError'
900
1690
  /** Creates a merkle proof flags mismatch error. */
@@ -911,7 +1701,20 @@ export class CCIPMerkleProofFlagsMismatchError extends CCIPError {
911
1701
  }
912
1702
  }
913
1703
 
914
- /** Thrown when not all proofs were consumed during verification. */
1704
+ /**
1705
+ * Thrown when not all proofs were consumed during verification.
1706
+ *
1707
+ * @example
1708
+ * ```typescript
1709
+ * try {
1710
+ * verifyMerkleProof({ leaves, proofs, root })
1711
+ * } catch (error) {
1712
+ * if (error instanceof CCIPMerkleProofIncompleteError) {
1713
+ * console.log('Merkle proof verification incomplete')
1714
+ * }
1715
+ * }
1716
+ * ```
1717
+ */
915
1718
  export class CCIPMerkleProofIncompleteError extends CCIPError {
916
1719
  override readonly name = 'CCIPMerkleProofIncompleteError'
917
1720
  /** Creates a merkle proof incomplete error. */
@@ -927,7 +1730,20 @@ export class CCIPMerkleProofIncompleteError extends CCIPError {
927
1730
  }
928
1731
  }
929
1732
 
930
- /** Thrown on internal merkle computation error. */
1733
+ /**
1734
+ * Thrown on internal merkle computation error.
1735
+ *
1736
+ * @example
1737
+ * ```typescript
1738
+ * try {
1739
+ * computeMerkleRoot(hashes)
1740
+ * } catch (error) {
1741
+ * if (error instanceof CCIPMerkleInternalError) {
1742
+ * console.log(`Internal merkle error: ${error.message}`)
1743
+ * }
1744
+ * }
1745
+ * ```
1746
+ */
931
1747
  export class CCIPMerkleInternalError extends CCIPError {
932
1748
  override readonly name = 'CCIPMerkleInternalError'
933
1749
  /** Creates a merkle internal error. */
@@ -941,7 +1757,20 @@ export class CCIPMerkleInternalError extends CCIPError {
941
1757
 
942
1758
  // Address Validation
943
1759
 
944
- /** Thrown when EVM address is invalid. */
1760
+ /**
1761
+ * Thrown when EVM address is invalid.
1762
+ *
1763
+ * @example
1764
+ * ```typescript
1765
+ * try {
1766
+ * EVMChain.getAddress('not-an-address')
1767
+ * } catch (error) {
1768
+ * if (error instanceof CCIPAddressInvalidEvmError) {
1769
+ * console.log(`Invalid address: ${error.context.address}`)
1770
+ * }
1771
+ * }
1772
+ * ```
1773
+ */
945
1774
  export class CCIPAddressInvalidEvmError extends CCIPError {
946
1775
  override readonly name = 'CCIPAddressInvalidEvmError'
947
1776
  /** Creates an EVM address invalid error. */
@@ -956,7 +1785,20 @@ export class CCIPAddressInvalidEvmError extends CCIPError {
956
1785
 
957
1786
  // Version Requirements
958
1787
 
959
- /** Thrown when CCIP version requires lane info. */
1788
+ /**
1789
+ * Thrown when CCIP version requires lane info.
1790
+ *
1791
+ * @example
1792
+ * ```typescript
1793
+ * try {
1794
+ * EVMChain.decodeCommits(log) // Missing lane for v1.6
1795
+ * } catch (error) {
1796
+ * if (error instanceof CCIPVersionRequiresLaneError) {
1797
+ * console.log(`Version ${error.context.version} requires lane parameter`)
1798
+ * }
1799
+ * }
1800
+ * ```
1801
+ */
960
1802
  export class CCIPVersionRequiresLaneError extends CCIPError {
961
1803
  override readonly name = 'CCIPVersionRequiresLaneError'
962
1804
  /** Creates a version requires lane error. */
@@ -973,7 +1815,20 @@ export class CCIPVersionRequiresLaneError extends CCIPError {
973
1815
  }
974
1816
  }
975
1817
 
976
- /** Thrown when version feature is unavailable. */
1818
+ /**
1819
+ * Thrown when version feature is unavailable.
1820
+ *
1821
+ * @example
1822
+ * ```typescript
1823
+ * try {
1824
+ * await chain.getFeature(oldVersion)
1825
+ * } catch (error) {
1826
+ * if (error instanceof CCIPVersionFeatureUnavailableError) {
1827
+ * console.log(`${error.context.feature} requires v${error.context.minVersion}+`)
1828
+ * }
1829
+ * }
1830
+ * ```
1831
+ */
977
1832
  export class CCIPVersionFeatureUnavailableError extends CCIPError {
978
1833
  override readonly name = 'CCIPVersionFeatureUnavailableError'
979
1834
  /** Creates a version feature unavailable error. */
@@ -991,7 +1846,20 @@ export class CCIPVersionFeatureUnavailableError extends CCIPError {
991
1846
 
992
1847
  // Contract Validation
993
1848
 
994
- /** Thrown when contract is not a Router or expected CCIP contract. */
1849
+ /**
1850
+ * Thrown when contract is not a Router or expected CCIP contract.
1851
+ *
1852
+ * @example
1853
+ * ```typescript
1854
+ * try {
1855
+ * await chain.getRouterForOnRamp(address)
1856
+ * } catch (error) {
1857
+ * if (error instanceof CCIPContractNotRouterError) {
1858
+ * console.log(`${error.context.address} is "${error.context.typeAndVersion}"`)
1859
+ * }
1860
+ * }
1861
+ * ```
1862
+ */
995
1863
  export class CCIPContractNotRouterError extends CCIPError {
996
1864
  override readonly name = 'CCIPContractNotRouterError'
997
1865
  /** Creates a contract not router error. */
@@ -1010,7 +1878,20 @@ export class CCIPContractNotRouterError extends CCIPError {
1010
1878
 
1011
1879
  // Log Data
1012
1880
 
1013
- /** Thrown when log data is invalid. */
1881
+ /**
1882
+ * Thrown when log data is invalid.
1883
+ *
1884
+ * @example
1885
+ * ```typescript
1886
+ * try {
1887
+ * const message = EVMChain.decodeMessage(log)
1888
+ * } catch (error) {
1889
+ * if (error instanceof CCIPLogDataInvalidError) {
1890
+ * console.log(`Invalid log data: ${error.context.data}`)
1891
+ * }
1892
+ * }
1893
+ * ```
1894
+ */
1014
1895
  export class CCIPLogDataInvalidError extends CCIPError {
1015
1896
  override readonly name = 'CCIPLogDataInvalidError'
1016
1897
  /** Creates a log data invalid error. */
@@ -1025,7 +1906,20 @@ export class CCIPLogDataInvalidError extends CCIPError {
1025
1906
 
1026
1907
  // Wallet
1027
1908
 
1028
- /** Thrown when wallet is not a valid signer. */
1909
+ /**
1910
+ * Thrown when wallet is not a valid signer.
1911
+ *
1912
+ * @example
1913
+ * ```typescript
1914
+ * try {
1915
+ * await chain.sendMessage({ ...opts, wallet: invalidWallet })
1916
+ * } catch (error) {
1917
+ * if (error instanceof CCIPWalletInvalidError) {
1918
+ * console.log('Provide a valid signer wallet')
1919
+ * }
1920
+ * }
1921
+ * ```
1922
+ */
1029
1923
  export class CCIPWalletInvalidError extends CCIPError {
1030
1924
  override readonly name = 'CCIPWalletInvalidError'
1031
1925
  /** Creates a wallet invalid error. */
@@ -1039,7 +1933,20 @@ export class CCIPWalletInvalidError extends CCIPError {
1039
1933
 
1040
1934
  // Source Chain
1041
1935
 
1042
- /** Thrown when source chain is unsupported for EVM hasher. */
1936
+ /**
1937
+ * Thrown when source chain is unsupported for EVM hasher.
1938
+ *
1939
+ * @example
1940
+ * ```typescript
1941
+ * try {
1942
+ * const hasher = chain.getDestLeafHasher(lane)
1943
+ * } catch (error) {
1944
+ * if (error instanceof CCIPSourceChainUnsupportedError) {
1945
+ * console.log(`Unsupported source: ${error.context.chainSelector}`)
1946
+ * }
1947
+ * }
1948
+ * ```
1949
+ */
1043
1950
  export class CCIPSourceChainUnsupportedError extends CCIPError {
1044
1951
  override readonly name = 'CCIPSourceChainUnsupportedError'
1045
1952
  /** Creates a source chain unsupported error. */
@@ -1058,7 +1965,22 @@ export class CCIPSourceChainUnsupportedError extends CCIPError {
1058
1965
 
1059
1966
  // Solana-specific errors
1060
1967
 
1061
- /** Thrown when block time cannot be retrieved for a slot. */
1968
+ /**
1969
+ * Thrown when block time cannot be retrieved for a slot. Transient: slot may not be indexed.
1970
+ *
1971
+ * @example
1972
+ * ```typescript
1973
+ * try {
1974
+ * const timestamp = await solanaChain.getBlockTimestamp(slot)
1975
+ * } catch (error) {
1976
+ * if (error instanceof CCIPBlockTimeNotFoundError) {
1977
+ * if (error.isTransient) {
1978
+ * await sleep(error.retryAfterMs ?? 5000)
1979
+ * }
1980
+ * }
1981
+ * }
1982
+ * ```
1983
+ */
1062
1984
  export class CCIPBlockTimeNotFoundError extends CCIPError {
1063
1985
  override readonly name = 'CCIPBlockTimeNotFoundError'
1064
1986
  /** Creates a block time not found error. */
@@ -1072,7 +1994,20 @@ export class CCIPBlockTimeNotFoundError extends CCIPError {
1072
1994
  }
1073
1995
  }
1074
1996
 
1075
- /** Thrown when topics are not valid strings. */
1997
+ /**
1998
+ * Thrown when topics are not valid strings.
1999
+ *
2000
+ * @example
2001
+ * ```typescript
2002
+ * try {
2003
+ * await chain.getLogs({ topics: [123] }) // Invalid topic type
2004
+ * } catch (error) {
2005
+ * if (error instanceof CCIPTopicsInvalidError) {
2006
+ * console.log('Topics must be string values')
2007
+ * }
2008
+ * }
2009
+ * ```
2010
+ */
1076
2011
  export class CCIPTopicsInvalidError extends CCIPError {
1077
2012
  override readonly name = 'CCIPTopicsInvalidError'
1078
2013
  /** Creates a Solana topics invalid error. */
@@ -1085,7 +2020,22 @@ export class CCIPTopicsInvalidError extends CCIPError {
1085
2020
  }
1086
2021
  }
1087
2022
 
1088
- /** Thrown when reference addresses account not found for offRamp. */
2023
+ /**
2024
+ * Thrown when reference addresses account not found for offRamp. Transient: may not be synced.
2025
+ *
2026
+ * @example
2027
+ * ```typescript
2028
+ * try {
2029
+ * await solanaChain.getOffRampForRouter(router)
2030
+ * } catch (error) {
2031
+ * if (error instanceof CCIPSolanaRefAddressesNotFoundError) {
2032
+ * if (error.isTransient) {
2033
+ * await sleep(error.retryAfterMs ?? 5000)
2034
+ * }
2035
+ * }
2036
+ * }
2037
+ * ```
2038
+ */
1089
2039
  export class CCIPSolanaRefAddressesNotFoundError extends CCIPError {
1090
2040
  override readonly name = 'CCIPSolanaRefAddressesNotFoundError'
1091
2041
  /** Creates a reference addresses not found error. */
@@ -1103,7 +2053,22 @@ export class CCIPSolanaRefAddressesNotFoundError extends CCIPError {
1103
2053
  }
1104
2054
  }
1105
2055
 
1106
- /** Thrown when OffRamp events not found in feeQuoter transactions. */
2056
+ /**
2057
+ * Thrown when OffRamp events not found in feeQuoter transactions. Transient: events may not be indexed.
2058
+ *
2059
+ * @example
2060
+ * ```typescript
2061
+ * try {
2062
+ * await solanaChain.getOffRampsForRouter(router)
2063
+ * } catch (error) {
2064
+ * if (error instanceof CCIPSolanaOffRampEventsNotFoundError) {
2065
+ * if (error.isTransient) {
2066
+ * await sleep(error.retryAfterMs ?? 10000)
2067
+ * }
2068
+ * }
2069
+ * }
2070
+ * ```
2071
+ */
1107
2072
  export class CCIPSolanaOffRampEventsNotFoundError extends CCIPError {
1108
2073
  override readonly name = 'CCIPSolanaOffRampEventsNotFoundError'
1109
2074
  /** Creates an offRamp events not found error. */
@@ -1121,7 +2086,20 @@ export class CCIPSolanaOffRampEventsNotFoundError extends CCIPError {
1121
2086
  }
1122
2087
  }
1123
2088
 
1124
- /** Thrown when token pool info not found. */
2089
+ /**
2090
+ * Thrown when token pool info not found.
2091
+ *
2092
+ * @example
2093
+ * ```typescript
2094
+ * try {
2095
+ * await chain.getTokenPoolConfigs(tokenPool)
2096
+ * } catch (error) {
2097
+ * if (error instanceof CCIPTokenPoolInfoNotFoundError) {
2098
+ * console.log(`TokenPool not found: ${error.context.tokenPool}`)
2099
+ * }
2100
+ * }
2101
+ * ```
2102
+ */
1125
2103
  export class CCIPTokenPoolInfoNotFoundError extends CCIPError {
1126
2104
  override readonly name = 'CCIPTokenPoolInfoNotFoundError'
1127
2105
  /** Creates a token pool info not found error. */
@@ -1134,7 +2112,20 @@ export class CCIPTokenPoolInfoNotFoundError extends CCIPError {
1134
2112
  }
1135
2113
  }
1136
2114
 
1137
- /** Thrown when SPL token is invalid or not Token-2022. */
2115
+ /**
2116
+ * Thrown when SPL token is invalid or not Token-2022.
2117
+ *
2118
+ * @example
2119
+ * ```typescript
2120
+ * try {
2121
+ * await solanaChain.getTokenInfo(tokenAddress)
2122
+ * } catch (error) {
2123
+ * if (error instanceof CCIPSplTokenInvalidError) {
2124
+ * console.log(`Invalid SPL token: ${error.context.token}`)
2125
+ * }
2126
+ * }
2127
+ * ```
2128
+ */
1138
2129
  export class CCIPSplTokenInvalidError extends CCIPError {
1139
2130
  override readonly name = 'CCIPSplTokenInvalidError'
1140
2131
  /** Creates an SPL token invalid error. */
@@ -1147,7 +2138,20 @@ export class CCIPSplTokenInvalidError extends CCIPError {
1147
2138
  }
1148
2139
  }
1149
2140
 
1150
- /** Thrown when token data cannot be parsed. */
2141
+ /**
2142
+ * Thrown when token data cannot be parsed.
2143
+ *
2144
+ * @example
2145
+ * ```typescript
2146
+ * try {
2147
+ * await chain.getTokenInfo(tokenAddress)
2148
+ * } catch (error) {
2149
+ * if (error instanceof CCIPTokenDataParseError) {
2150
+ * console.log(`Cannot parse token: ${error.context.token}`)
2151
+ * }
2152
+ * }
2153
+ * ```
2154
+ */
1151
2155
  export class CCIPTokenDataParseError extends CCIPError {
1152
2156
  override readonly name = 'CCIPTokenDataParseError'
1153
2157
  /** Creates a token data parse error. */
@@ -1160,7 +2164,20 @@ export class CCIPTokenDataParseError extends CCIPError {
1160
2164
  }
1161
2165
  }
1162
2166
 
1163
- /** Thrown when EVMExtraArgsV2 has unsupported length. */
2167
+ /**
2168
+ * Thrown when EVMExtraArgsV2 has unsupported length.
2169
+ *
2170
+ * @example
2171
+ * ```typescript
2172
+ * try {
2173
+ * SolanaChain.decodeExtraArgs(data)
2174
+ * } catch (error) {
2175
+ * if (error instanceof CCIPExtraArgsLengthInvalidError) {
2176
+ * console.log(`Unsupported length: ${error.context.length}`)
2177
+ * }
2178
+ * }
2179
+ * ```
2180
+ */
1164
2181
  export class CCIPExtraArgsLengthInvalidError extends CCIPError {
1165
2182
  override readonly name = 'CCIPExtraArgsLengthInvalidError'
1166
2183
  /** Creates an extraArgs length invalid error. */
@@ -1173,7 +2190,20 @@ export class CCIPExtraArgsLengthInvalidError extends CCIPError {
1173
2190
  }
1174
2191
  }
1175
2192
 
1176
- /** Thrown when Solana can only encode EVMExtraArgsV2 but got different args. */
2193
+ /**
2194
+ * Thrown when Solana can only encode EVMExtraArgsV2 but got different args.
2195
+ *
2196
+ * @example
2197
+ * ```typescript
2198
+ * try {
2199
+ * SolanaChain.encodeExtraArgs(unsupportedArgs)
2200
+ * } catch (error) {
2201
+ * if (error instanceof CCIPSolanaExtraArgsEncodingError) {
2202
+ * console.log('Use EVMExtraArgsV2 format for Solana')
2203
+ * }
2204
+ * }
2205
+ * ```
2206
+ */
1177
2207
  export class CCIPSolanaExtraArgsEncodingError extends CCIPError {
1178
2208
  override readonly name = 'CCIPSolanaExtraArgsEncodingError'
1179
2209
  /** Creates a Solana extraArgs encoding error. */
@@ -1189,7 +2219,20 @@ export class CCIPSolanaExtraArgsEncodingError extends CCIPError {
1189
2219
  }
1190
2220
  }
1191
2221
 
1192
- /** Thrown when log data is missing or not a string. */
2222
+ /**
2223
+ * Thrown when log data is missing or not a string.
2224
+ *
2225
+ * @example
2226
+ * ```typescript
2227
+ * try {
2228
+ * const message = Chain.decodeMessage(log)
2229
+ * } catch (error) {
2230
+ * if (error instanceof CCIPLogDataMissingError) {
2231
+ * console.log('Log data is missing or invalid')
2232
+ * }
2233
+ * }
2234
+ * ```
2235
+ */
1193
2236
  export class CCIPLogDataMissingError extends CCIPError {
1194
2237
  override readonly name = 'CCIPLogDataMissingError'
1195
2238
  /** Creates a log data missing error. */
@@ -1201,7 +2244,20 @@ export class CCIPLogDataMissingError extends CCIPError {
1201
2244
  }
1202
2245
  }
1203
2246
 
1204
- /** Thrown when ExecutionState is invalid. */
2247
+ /**
2248
+ * Thrown when ExecutionState is invalid.
2249
+ *
2250
+ * @example
2251
+ * ```typescript
2252
+ * try {
2253
+ * const receipt = Chain.decodeReceipt(log)
2254
+ * } catch (error) {
2255
+ * if (error instanceof CCIPExecutionStateInvalidError) {
2256
+ * console.log(`Invalid state: ${error.context.state}`)
2257
+ * }
2258
+ * }
2259
+ * ```
2260
+ */
1205
2261
  export class CCIPExecutionStateInvalidError extends CCIPError {
1206
2262
  override readonly name = 'CCIPExecutionStateInvalidError'
1207
2263
  /** Creates an execution state invalid error. */
@@ -1214,7 +2270,20 @@ export class CCIPExecutionStateInvalidError extends CCIPError {
1214
2270
  }
1215
2271
  }
1216
2272
 
1217
- /** Thrown when execution report message is not for Solana. */
2273
+ /**
2274
+ * Thrown when execution report message is not for the expected chain.
2275
+ *
2276
+ * @example
2277
+ * ```typescript
2278
+ * try {
2279
+ * await chain.execute({ offRamp, input, wallet })
2280
+ * } catch (error) {
2281
+ * if (error instanceof CCIPExecutionReportChainMismatchError) {
2282
+ * console.log(`Message not for ${error.context.chain}`)
2283
+ * }
2284
+ * }
2285
+ * ```
2286
+ */
1218
2287
  export class CCIPExecutionReportChainMismatchError extends CCIPError {
1219
2288
  override readonly name = 'CCIPExecutionReportChainMismatchError'
1220
2289
  /** Creates an execution report chain mismatch error. */
@@ -1227,7 +2296,20 @@ export class CCIPExecutionReportChainMismatchError extends CCIPError {
1227
2296
  }
1228
2297
  }
1229
2298
 
1230
- /** Thrown when token pool state PDA not found. */
2299
+ /**
2300
+ * Thrown when token pool state PDA not found.
2301
+ *
2302
+ * @example
2303
+ * ```typescript
2304
+ * try {
2305
+ * await solanaChain.getTokenPoolConfigs(tokenPool)
2306
+ * } catch (error) {
2307
+ * if (error instanceof CCIPTokenPoolStateNotFoundError) {
2308
+ * console.log(`State not found at: ${error.context.tokenPool}`)
2309
+ * }
2310
+ * }
2311
+ * ```
2312
+ */
1231
2313
  export class CCIPTokenPoolStateNotFoundError extends CCIPError {
1232
2314
  override readonly name = 'CCIPTokenPoolStateNotFoundError'
1233
2315
  /** Creates a token pool state not found error. */
@@ -1244,7 +2326,20 @@ export class CCIPTokenPoolStateNotFoundError extends CCIPError {
1244
2326
  }
1245
2327
  }
1246
2328
 
1247
- /** Thrown when ChainConfig not found for token pool and remote chain. */
2329
+ /**
2330
+ * Thrown when ChainConfig not found for token pool and remote chain.
2331
+ *
2332
+ * @example
2333
+ * ```typescript
2334
+ * try {
2335
+ * await chain.getTokenPoolRemotes(tokenPool, destChainSelector)
2336
+ * } catch (error) {
2337
+ * if (error instanceof CCIPTokenPoolChainConfigNotFoundError) {
2338
+ * console.log(`No config for ${error.context.remoteNetwork}`)
2339
+ * }
2340
+ * }
2341
+ * ```
2342
+ */
1248
2343
  export class CCIPTokenPoolChainConfigNotFoundError extends CCIPError {
1249
2344
  override readonly name = 'CCIPTokenPoolChainConfigNotFoundError'
1250
2345
  /** Creates a token pool chain config not found error. */
@@ -1268,7 +2363,20 @@ export class CCIPTokenPoolChainConfigNotFoundError extends CCIPError {
1268
2363
 
1269
2364
  // Aptos-specific errors
1270
2365
 
1271
- /** Thrown when Aptos network is unknown. */
2366
+ /**
2367
+ * Thrown when Aptos network is unknown.
2368
+ *
2369
+ * @example
2370
+ * ```typescript
2371
+ * try {
2372
+ * const chain = await AptosChain.fromUrl('https://unknown-network')
2373
+ * } catch (error) {
2374
+ * if (error instanceof CCIPAptosNetworkUnknownError) {
2375
+ * console.log(`Unknown network: ${error.context.url}`)
2376
+ * }
2377
+ * }
2378
+ * ```
2379
+ */
1272
2380
  export class CCIPAptosNetworkUnknownError extends CCIPError {
1273
2381
  override readonly name = 'CCIPAptosNetworkUnknownError'
1274
2382
  /** Creates an Aptos network unknown error. */
@@ -1281,7 +2389,20 @@ export class CCIPAptosNetworkUnknownError extends CCIPError {
1281
2389
  }
1282
2390
  }
1283
2391
 
1284
- /** Thrown when Aptos transaction type is invalid. */
2392
+ /**
2393
+ * Thrown when Aptos transaction type is invalid.
2394
+ *
2395
+ * @example
2396
+ * ```typescript
2397
+ * try {
2398
+ * await aptosChain.getMessagesInTx(txHash)
2399
+ * } catch (error) {
2400
+ * if (error instanceof CCIPAptosTransactionTypeInvalidError) {
2401
+ * console.log('Expected user_transaction type')
2402
+ * }
2403
+ * }
2404
+ * ```
2405
+ */
1285
2406
  export class CCIPAptosTransactionTypeInvalidError extends CCIPError {
1286
2407
  override readonly name = 'CCIPAptosTransactionTypeInvalidError'
1287
2408
  /** Creates an Aptos transaction type invalid error. */
@@ -1297,7 +2418,20 @@ export class CCIPAptosTransactionTypeInvalidError extends CCIPError {
1297
2418
  }
1298
2419
  }
1299
2420
 
1300
- /** Thrown when Aptos registry type is invalid. */
2421
+ /**
2422
+ * Thrown when Aptos registry type is invalid.
2423
+ *
2424
+ * @example
2425
+ * ```typescript
2426
+ * try {
2427
+ * await aptosChain.getTokenAdminRegistryFor(registry)
2428
+ * } catch (error) {
2429
+ * if (error instanceof CCIPAptosRegistryTypeInvalidError) {
2430
+ * console.log(`Expected TokenAdminRegistry, got: ${error.context.actualType}`)
2431
+ * }
2432
+ * }
2433
+ * ```
2434
+ */
1301
2435
  export class CCIPAptosRegistryTypeInvalidError extends CCIPError {
1302
2436
  override readonly name = 'CCIPAptosRegistryTypeInvalidError'
1303
2437
  /** Creates an Aptos registry type invalid error. */
@@ -1314,7 +2448,20 @@ export class CCIPAptosRegistryTypeInvalidError extends CCIPError {
1314
2448
  }
1315
2449
  }
1316
2450
 
1317
- /** Thrown when Aptos log data is invalid. */
2451
+ /**
2452
+ * Thrown when Aptos log data is invalid.
2453
+ *
2454
+ * @example
2455
+ * ```typescript
2456
+ * try {
2457
+ * const message = AptosChain.decodeMessage(log)
2458
+ * } catch (error) {
2459
+ * if (error instanceof CCIPAptosLogInvalidError) {
2460
+ * console.log(`Invalid log: ${error.context.log}`)
2461
+ * }
2462
+ * }
2463
+ * ```
2464
+ */
1318
2465
  export class CCIPAptosLogInvalidError extends CCIPError {
1319
2466
  override readonly name = 'CCIPAptosLogInvalidError'
1320
2467
  /** Creates an Aptos log invalid error. */
@@ -1327,7 +2474,22 @@ export class CCIPAptosLogInvalidError extends CCIPError {
1327
2474
  }
1328
2475
  }
1329
2476
 
1330
- /** Thrown when Aptos address is invalid. */
2477
+ /**
2478
+ * Thrown when Aptos address is invalid.
2479
+ *
2480
+ * @example
2481
+ * ```typescript
2482
+ * import { CCIPDataFormatUnsupportedError } from '@chainlink/ccip-sdk'
2483
+ *
2484
+ * try {
2485
+ * AptosChain.getAddress('invalid-address')
2486
+ * } catch (error) {
2487
+ * if (error instanceof CCIPDataFormatUnsupportedError) {
2488
+ * console.log(`Invalid address: ${error.message}`)
2489
+ * }
2490
+ * }
2491
+ * ```
2492
+ */
1331
2493
  export class CCIPAptosAddressInvalidError extends CCIPError {
1332
2494
  override readonly name = 'CCIPAptosAddressInvalidError'
1333
2495
  /** Creates an Aptos address invalid error. */
@@ -1340,7 +2502,20 @@ export class CCIPAptosAddressInvalidError extends CCIPError {
1340
2502
  }
1341
2503
  }
1342
2504
 
1343
- /** Thrown when Aptos can only encode specific extra args types. */
2505
+ /**
2506
+ * Thrown when Aptos can only encode specific extra args types.
2507
+ *
2508
+ * @example
2509
+ * ```typescript
2510
+ * try {
2511
+ * AptosChain.encodeExtraArgs(unsupportedArgs)
2512
+ * } catch (error) {
2513
+ * if (error instanceof CCIPAptosExtraArgsEncodingError) {
2514
+ * console.log('Use EVMExtraArgsV2 or SVMExtraArgsV1 for Aptos')
2515
+ * }
2516
+ * }
2517
+ * ```
2518
+ */
1344
2519
  export class CCIPAptosExtraArgsEncodingError extends CCIPError {
1345
2520
  override readonly name = 'CCIPAptosExtraArgsEncodingError'
1346
2521
  /** Creates an Aptos extraArgs encoding error. */
@@ -1356,7 +2531,20 @@ export class CCIPAptosExtraArgsEncodingError extends CCIPError {
1356
2531
  }
1357
2532
  }
1358
2533
 
1359
- /** Thrown when Aptos wallet is invalid. */
2534
+ /**
2535
+ * Thrown when Aptos wallet is invalid.
2536
+ *
2537
+ * @example
2538
+ * ```typescript
2539
+ * try {
2540
+ * await aptosChain.sendMessage({ ...opts, wallet: invalidWallet })
2541
+ * } catch (error) {
2542
+ * if (error instanceof CCIPAptosWalletInvalidError) {
2543
+ * console.log('Provide a valid Aptos account wallet')
2544
+ * }
2545
+ * }
2546
+ * ```
2547
+ */
1360
2548
  export class CCIPAptosWalletInvalidError extends CCIPError {
1361
2549
  override readonly name = 'CCIPAptosWalletInvalidError'
1362
2550
  /** Creates an Aptos wallet invalid error. */
@@ -1373,7 +2561,20 @@ export class CCIPAptosWalletInvalidError extends CCIPError {
1373
2561
  }
1374
2562
  }
1375
2563
 
1376
- /** Thrown when Aptos expects EVMExtraArgsV2 reports. */
2564
+ /**
2565
+ * Thrown when Aptos expects EVMExtraArgsV2 reports.
2566
+ *
2567
+ * @example
2568
+ * ```typescript
2569
+ * try {
2570
+ * await aptosChain.execute({ offRamp, input, wallet })
2571
+ * } catch (error) {
2572
+ * if (error instanceof CCIPAptosExtraArgsV2RequiredError) {
2573
+ * console.log('Aptos requires EVMExtraArgsV2 format')
2574
+ * }
2575
+ * }
2576
+ * ```
2577
+ */
1377
2578
  export class CCIPAptosExtraArgsV2RequiredError extends CCIPError {
1378
2579
  override readonly name = 'CCIPAptosExtraArgsV2RequiredError'
1379
2580
  /** Creates an Aptos EVMExtraArgsV2 required error. */
@@ -1385,7 +2586,20 @@ export class CCIPAptosExtraArgsV2RequiredError extends CCIPError {
1385
2586
  }
1386
2587
  }
1387
2588
 
1388
- /** Thrown when token is not registered in Aptos registry. */
2589
+ /**
2590
+ * Thrown when token is not registered in Aptos registry.
2591
+ *
2592
+ * @example
2593
+ * ```typescript
2594
+ * try {
2595
+ * await aptosChain.getRegistryTokenConfig(registry, token)
2596
+ * } catch (error) {
2597
+ * if (error instanceof CCIPAptosTokenNotRegisteredError) {
2598
+ * console.log(`Token ${error.context.token} not in registry`)
2599
+ * }
2600
+ * }
2601
+ * ```
2602
+ */
1389
2603
  export class CCIPAptosTokenNotRegisteredError extends CCIPError {
1390
2604
  override readonly name = 'CCIPAptosTokenNotRegisteredError'
1391
2605
  /** Creates an Aptos token not registered error. */
@@ -1402,7 +2616,20 @@ export class CCIPAptosTokenNotRegisteredError extends CCIPError {
1402
2616
  }
1403
2617
  }
1404
2618
 
1405
- /** Thrown for unexpected Aptos transaction type. */
2619
+ /**
2620
+ * Thrown for unexpected Aptos transaction type.
2621
+ *
2622
+ * @example
2623
+ * ```typescript
2624
+ * try {
2625
+ * await aptosChain.getTransaction(txHash)
2626
+ * } catch (error) {
2627
+ * if (error instanceof CCIPAptosTransactionTypeUnexpectedError) {
2628
+ * console.log(`Unexpected type: ${error.context.type}`)
2629
+ * }
2630
+ * }
2631
+ * ```
2632
+ */
1406
2633
  export class CCIPAptosTransactionTypeUnexpectedError extends CCIPError {
1407
2634
  override readonly name = 'CCIPAptosTransactionTypeUnexpectedError'
1408
2635
  /** Creates an Aptos transaction type unexpected error. */
@@ -1415,7 +2642,20 @@ export class CCIPAptosTransactionTypeUnexpectedError extends CCIPError {
1415
2642
  }
1416
2643
  }
1417
2644
 
1418
- /** Thrown when Aptos address with module is required. */
2645
+ /**
2646
+ * Thrown when Aptos address with module is required.
2647
+ *
2648
+ * @example
2649
+ * ```typescript
2650
+ * try {
2651
+ * await aptosChain.getLogs({ address: '0x1' }) // Missing module
2652
+ * } catch (error) {
2653
+ * if (error instanceof CCIPAptosAddressModuleRequiredError) {
2654
+ * console.log('Provide address with module name')
2655
+ * }
2656
+ * }
2657
+ * ```
2658
+ */
1419
2659
  export class CCIPAptosAddressModuleRequiredError extends CCIPError {
1420
2660
  override readonly name = 'CCIPAptosAddressModuleRequiredError'
1421
2661
  /** Creates an Aptos address module required error. */
@@ -1431,9 +2671,52 @@ export class CCIPAptosAddressModuleRequiredError extends CCIPError {
1431
2671
  }
1432
2672
  }
1433
2673
 
2674
+ /**
2675
+ * Thrown when Aptos topic is invalid.
2676
+ *
2677
+ * @example
2678
+ * ```typescript
2679
+ * try {
2680
+ * await aptosChain.getLogs({ topics: ['invalid'] })
2681
+ * } catch (error) {
2682
+ * if (error instanceof CCIPAptosTopicInvalidError) {
2683
+ * console.log(`Invalid topic: ${error.context.topic}`)
2684
+ * }
2685
+ * }
2686
+ * ```
2687
+ */
2688
+ export class CCIPAptosTopicInvalidError extends CCIPError {
2689
+ override readonly name = 'CCIPAptosTopicInvalidError'
2690
+ /** Creates an Aptos topic invalid error. */
2691
+ constructor(topic?: string, options?: CCIPErrorOptions) {
2692
+ super(
2693
+ CCIPErrorCode.APTOS_TOPIC_INVALID,
2694
+ topic ? `Unknown topic event handler="${topic}"` : 'single string topic required',
2695
+ {
2696
+ ...options,
2697
+ isTransient: false,
2698
+ context: { ...options?.context, topic },
2699
+ },
2700
+ )
2701
+ }
2702
+ }
2703
+
1434
2704
  // Borsh
1435
2705
 
1436
- /** Thrown when Borsh type is unknown. */
2706
+ /**
2707
+ * Thrown when Borsh type is unknown.
2708
+ *
2709
+ * @example
2710
+ * ```typescript
2711
+ * try {
2712
+ * decodeBorsh(data, 'UnknownType')
2713
+ * } catch (error) {
2714
+ * if (error instanceof CCIPBorshTypeUnknownError) {
2715
+ * console.log(`Unknown type: ${error.context.name}`)
2716
+ * }
2717
+ * }
2718
+ * ```
2719
+ */
1437
2720
  export class CCIPBorshTypeUnknownError extends CCIPError {
1438
2721
  override readonly name = 'CCIPBorshTypeUnknownError'
1439
2722
  /** Creates a Borsh type unknown error. */
@@ -1446,7 +2729,20 @@ export class CCIPBorshTypeUnknownError extends CCIPError {
1446
2729
  }
1447
2730
  }
1448
2731
 
1449
- /** Thrown when Borsh method is unknown. */
2732
+ /**
2733
+ * Thrown when Borsh method is unknown.
2734
+ *
2735
+ * @example
2736
+ * ```typescript
2737
+ * try {
2738
+ * callBorshMethod('unknownMethod')
2739
+ * } catch (error) {
2740
+ * if (error instanceof CCIPBorshMethodUnknownError) {
2741
+ * console.log(`Unknown method: ${error.context.method}`)
2742
+ * }
2743
+ * }
2744
+ * ```
2745
+ */
1450
2746
  export class CCIPBorshMethodUnknownError extends CCIPError {
1451
2747
  override readonly name = 'CCIPBorshMethodUnknownError'
1452
2748
  /** Creates a Borsh method unknown error. */
@@ -1461,7 +2757,20 @@ export class CCIPBorshMethodUnknownError extends CCIPError {
1461
2757
 
1462
2758
  // CLI & Validation
1463
2759
 
1464
- /** Thrown when CLI argument is invalid. */
2760
+ /**
2761
+ * Thrown when CLI argument is invalid.
2762
+ *
2763
+ * @example
2764
+ * ```typescript
2765
+ * try {
2766
+ * parseArguments(['--invalid-arg'])
2767
+ * } catch (error) {
2768
+ * if (error instanceof CCIPArgumentInvalidError) {
2769
+ * console.log(`${error.context.argument}: ${error.context.reason}`)
2770
+ * }
2771
+ * }
2772
+ * ```
2773
+ */
1465
2774
  export class CCIPArgumentInvalidError extends CCIPError {
1466
2775
  override readonly name = 'CCIPArgumentInvalidError'
1467
2776
  /** Creates an argument invalid error. */
@@ -1474,7 +2783,22 @@ export class CCIPArgumentInvalidError extends CCIPError {
1474
2783
  }
1475
2784
  }
1476
2785
 
1477
- /** Thrown when execution receipt not found in tx logs. Transient: receipt may not be indexed yet. */
2786
+ /**
2787
+ * Thrown when execution receipt not found in tx logs. Transient: receipt may not be indexed yet.
2788
+ *
2789
+ * @example
2790
+ * ```typescript
2791
+ * try {
2792
+ * const receipt = await chain.getExecutionReceiptInTx(txHash)
2793
+ * } catch (error) {
2794
+ * if (error instanceof CCIPReceiptNotFoundError) {
2795
+ * if (error.isTransient) {
2796
+ * await sleep(error.retryAfterMs ?? 5000)
2797
+ * }
2798
+ * }
2799
+ * }
2800
+ * ```
2801
+ */
1478
2802
  export class CCIPReceiptNotFoundError extends CCIPError {
1479
2803
  override readonly name = 'CCIPReceiptNotFoundError'
1480
2804
  /** Creates a receipt not found error. */
@@ -1488,7 +2812,20 @@ export class CCIPReceiptNotFoundError extends CCIPError {
1488
2812
  }
1489
2813
  }
1490
2814
 
1491
- /** Thrown when data cannot be parsed. */
2815
+ /**
2816
+ * Thrown when data cannot be parsed.
2817
+ *
2818
+ * @example
2819
+ * ```typescript
2820
+ * try {
2821
+ * const parsed = Chain.parse(data)
2822
+ * } catch (error) {
2823
+ * if (error instanceof CCIPDataParseError) {
2824
+ * console.log(`Parse failed for: ${error.context.data}`)
2825
+ * }
2826
+ * }
2827
+ * ```
2828
+ */
1492
2829
  export class CCIPDataParseError extends CCIPError {
1493
2830
  override readonly name = 'CCIPDataParseError'
1494
2831
  /** Creates a data parse error. */
@@ -1502,7 +2839,20 @@ export class CCIPDataParseError extends CCIPError {
1502
2839
  }
1503
2840
  }
1504
2841
 
1505
- /** Thrown when token not found in supported tokens list. */
2842
+ /**
2843
+ * Thrown when token not found in supported tokens list.
2844
+ *
2845
+ * @example
2846
+ * ```typescript
2847
+ * try {
2848
+ * const tokens = await chain.getSupportedTokens(router, destChainSelector)
2849
+ * } catch (error) {
2850
+ * if (error instanceof CCIPTokenNotFoundError) {
2851
+ * console.log(`Token not found: ${error.context.token}`)
2852
+ * }
2853
+ * }
2854
+ * ```
2855
+ */
1506
2856
  export class CCIPTokenNotFoundError extends CCIPError {
1507
2857
  override readonly name = 'CCIPTokenNotFoundError'
1508
2858
  /** Creates a token not found error. */
@@ -1534,7 +2884,20 @@ export class CCIPInsufficientBalanceError extends CCIPError {
1534
2884
 
1535
2885
  // Solana-specific (additional)
1536
2886
 
1537
- /** Thrown when router config not found at PDA. */
2887
+ /**
2888
+ * Thrown when router config not found at PDA.
2889
+ *
2890
+ * @example
2891
+ * ```typescript
2892
+ * try {
2893
+ * await solanaChain.getOnRampForRouter(router, destChainSelector)
2894
+ * } catch (error) {
2895
+ * if (error instanceof CCIPSolanaRouterConfigNotFoundError) {
2896
+ * console.log(`Config not found at: ${error.context.configPda}`)
2897
+ * }
2898
+ * }
2899
+ * ```
2900
+ */
1538
2901
  export class CCIPSolanaRouterConfigNotFoundError extends CCIPError {
1539
2902
  override readonly name = 'CCIPSolanaRouterConfigNotFoundError'
1540
2903
  /** Creates a Solana router config not found error. */
@@ -1547,7 +2910,20 @@ export class CCIPSolanaRouterConfigNotFoundError extends CCIPError {
1547
2910
  }
1548
2911
  }
1549
2912
 
1550
- /** Thrown when fee result from router is invalid. */
2913
+ /**
2914
+ * Thrown when fee result from router is invalid.
2915
+ *
2916
+ * @example
2917
+ * ```typescript
2918
+ * try {
2919
+ * const fee = await solanaChain.getFee(router, message)
2920
+ * } catch (error) {
2921
+ * if (error instanceof CCIPSolanaFeeResultInvalidError) {
2922
+ * console.log(`Invalid fee result: ${error.context.result}`)
2923
+ * }
2924
+ * }
2925
+ * ```
2926
+ */
1551
2927
  export class CCIPSolanaFeeResultInvalidError extends CCIPError {
1552
2928
  override readonly name = 'CCIPSolanaFeeResultInvalidError'
1553
2929
  /** Creates a Solana fee result invalid error. */
@@ -1560,7 +2936,20 @@ export class CCIPSolanaFeeResultInvalidError extends CCIPError {
1560
2936
  }
1561
2937
  }
1562
2938
 
1563
- /** Thrown when token mint not found. */
2939
+ /**
2940
+ * Thrown when token mint not found.
2941
+ *
2942
+ * @example
2943
+ * ```typescript
2944
+ * try {
2945
+ * await solanaChain.getTokenInfo(mintAddress)
2946
+ * } catch (error) {
2947
+ * if (error instanceof CCIPTokenMintNotFoundError) {
2948
+ * console.log(`Mint not found: ${error.context.token}`)
2949
+ * }
2950
+ * }
2951
+ * ```
2952
+ */
1564
2953
  export class CCIPTokenMintNotFoundError extends CCIPError {
1565
2954
  override readonly name = 'CCIPTokenMintNotFoundError'
1566
2955
  /** Creates a token mint not found error. */
@@ -1573,7 +2962,22 @@ export class CCIPTokenMintNotFoundError extends CCIPError {
1573
2962
  }
1574
2963
  }
1575
2964
 
1576
- /** Thrown when token mint exists but is not a valid SPL token (wrong owner program). */
2965
+ /**
2966
+ * Thrown when token mint exists but is not a valid SPL token (wrong owner program).
2967
+ *
2968
+ * @example
2969
+ * ```typescript
2970
+ * try {
2971
+ * const tokenInfo = await solanaChain.getTokenInfo(mintAddress)
2972
+ * } catch (error) {
2973
+ * if (error instanceof CCIPTokenMintInvalidError) {
2974
+ * console.log(`Invalid mint: ${error.context.token}`)
2975
+ * console.log(`Owner: ${error.context.actualOwner}`)
2976
+ * console.log(`Expected: ${error.context.expectedOwners.join(' or ')}`)
2977
+ * }
2978
+ * }
2979
+ * ```
2980
+ */
1577
2981
  export class CCIPTokenMintInvalidError extends CCIPError {
1578
2982
  override readonly name = 'CCIPTokenMintInvalidError'
1579
2983
  /** Creates a token mint invalid error. */
@@ -1596,7 +3000,20 @@ export class CCIPTokenMintInvalidError extends CCIPError {
1596
3000
  }
1597
3001
  }
1598
3002
 
1599
- /** Thrown when token amount is invalid. */
3003
+ /**
3004
+ * Thrown when token amount is invalid.
3005
+ *
3006
+ * @example
3007
+ * ```typescript
3008
+ * try {
3009
+ * await chain.sendMessage({ tokenAmounts: [{ token: '', amount: 0n }] })
3010
+ * } catch (error) {
3011
+ * if (error instanceof CCIPTokenAmountInvalidError) {
3012
+ * console.log('Token address and positive amount required')
3013
+ * }
3014
+ * }
3015
+ * ```
3016
+ */
1600
3017
  export class CCIPTokenAmountInvalidError extends CCIPError {
1601
3018
  override readonly name = 'CCIPTokenAmountInvalidError'
1602
3019
  /** Creates a token amount invalid error. */
@@ -1612,7 +3029,21 @@ export class CCIPTokenAmountInvalidError extends CCIPError {
1612
3029
  }
1613
3030
  }
1614
3031
 
1615
- /** Thrown when token account (e.g., Solana ATA) does not exist for holder. */
3032
+ /**
3033
+ * Thrown when token account (e.g., Solana ATA) does not exist for holder.
3034
+ *
3035
+ * @example
3036
+ * ```typescript
3037
+ * try {
3038
+ * const balance = await solanaChain.getBalance({ address: holder, token: mint })
3039
+ * } catch (error) {
3040
+ * if (error instanceof CCIPTokenAccountNotFoundError) {
3041
+ * console.log(`No ATA for token ${error.context.token}`)
3042
+ * console.log(`Holder: ${error.context.holder}`)
3043
+ * }
3044
+ * }
3045
+ * ```
3046
+ */
1616
3047
  export class CCIPTokenAccountNotFoundError extends CCIPError {
1617
3048
  override readonly name = 'CCIPTokenAccountNotFoundError'
1618
3049
  /** Creates a token account not found error. */
@@ -1629,7 +3060,22 @@ export class CCIPTokenAccountNotFoundError extends CCIPError {
1629
3060
  }
1630
3061
  }
1631
3062
 
1632
- /** Thrown when transaction not finalized after timeout. */
3063
+ /**
3064
+ * Thrown when transaction not finalized after timeout. Transient: may need more time.
3065
+ *
3066
+ * @example
3067
+ * ```typescript
3068
+ * try {
3069
+ * await chain.waitFinalized(txHash)
3070
+ * } catch (error) {
3071
+ * if (error instanceof CCIPTransactionNotFinalizedError) {
3072
+ * if (error.isTransient) {
3073
+ * await sleep(error.retryAfterMs ?? 10000)
3074
+ * }
3075
+ * }
3076
+ * }
3077
+ * ```
3078
+ */
1633
3079
  export class CCIPTransactionNotFinalizedError extends CCIPError {
1634
3080
  override readonly name = 'CCIPTransactionNotFinalizedError'
1635
3081
  /** Creates a transaction not finalized error. */
@@ -1647,7 +3093,20 @@ export class CCIPTransactionNotFinalizedError extends CCIPError {
1647
3093
  }
1648
3094
  }
1649
3095
 
1650
- /** Thrown when CCTP event decode fails. */
3096
+ /**
3097
+ * Thrown when CCTP event decode fails.
3098
+ *
3099
+ * @example
3100
+ * ```typescript
3101
+ * try {
3102
+ * const cctpData = decodeCctpEvent(log)
3103
+ * } catch (error) {
3104
+ * if (error instanceof CCIPCctpDecodeError) {
3105
+ * console.log(`CCTP decode failed: ${error.context.log}`)
3106
+ * }
3107
+ * }
3108
+ * ```
3109
+ */
1651
3110
  export class CCIPCctpDecodeError extends CCIPError {
1652
3111
  override readonly name = 'CCIPCctpDecodeError'
1653
3112
  /** Creates a CCTP decode error. */
@@ -1660,7 +3119,20 @@ export class CCIPCctpDecodeError extends CCIPError {
1660
3119
  }
1661
3120
  }
1662
3121
 
1663
- /** Thrown when Sui hasher version is unsupported. */
3122
+ /**
3123
+ * Thrown when Sui hasher version is unsupported.
3124
+ *
3125
+ * @example
3126
+ * ```typescript
3127
+ * try {
3128
+ * const hasher = SuiChain.getDestLeafHasher(lane)
3129
+ * } catch (error) {
3130
+ * if (error instanceof CCIPSuiHasherVersionUnsupportedError) {
3131
+ * console.log(`Unsupported hasher: ${error.context.version}`)
3132
+ * }
3133
+ * }
3134
+ * ```
3135
+ */
1664
3136
  export class CCIPSuiHasherVersionUnsupportedError extends CCIPError {
1665
3137
  override readonly name = 'CCIPSuiHasherVersionUnsupportedError'
1666
3138
  /** Creates a Sui hasher version unsupported error. */
@@ -1677,7 +3149,20 @@ export class CCIPSuiHasherVersionUnsupportedError extends CCIPError {
1677
3149
  }
1678
3150
  }
1679
3151
 
1680
- /** Thrown when Sui message version is invalid. */
3152
+ /**
3153
+ * Thrown when Sui message version is invalid.
3154
+ *
3155
+ * @example
3156
+ * ```typescript
3157
+ * try {
3158
+ * const message = SuiChain.decodeMessage(log)
3159
+ * } catch (error) {
3160
+ * if (error instanceof CCIPSuiMessageVersionInvalidError) {
3161
+ * console.log('Only CCIP v1.6 format is supported for Sui')
3162
+ * }
3163
+ * }
3164
+ * ```
3165
+ */
1681
3166
  export class CCIPSuiMessageVersionInvalidError extends CCIPError {
1682
3167
  override readonly name = 'CCIPSuiMessageVersionInvalidError'
1683
3168
  /** Creates a Sui message version invalid error. */
@@ -1693,10 +3178,31 @@ export class CCIPSuiMessageVersionInvalidError extends CCIPError {
1693
3178
  }
1694
3179
  }
1695
3180
 
1696
- /** Thrown when Sui log data is invalid. */
3181
+ /**
3182
+ * Thrown when Sui log data is invalid.
3183
+ *
3184
+ * This error occurs when attempting to decode a Sui event log that doesn't
3185
+ * conform to the expected CCIP message format.
3186
+ *
3187
+ * @example
3188
+ * ```typescript
3189
+ * try {
3190
+ * const message = SuiChain.decodeMessage(log)
3191
+ * } catch (error) {
3192
+ * if (error instanceof CCIPSuiLogInvalidError) {
3193
+ * console.log('Invalid Sui log format:', error.context.log)
3194
+ * }
3195
+ * }
3196
+ * ```
3197
+ */
1697
3198
  export class CCIPSuiLogInvalidError extends CCIPError {
1698
3199
  override readonly name = 'CCIPSuiLogInvalidError'
1699
- /** Creates a Sui log invalid error. */
3200
+ /**
3201
+ * Creates a Sui log invalid error.
3202
+ *
3203
+ * @param log - The invalid log data
3204
+ * @param options - Additional error options
3205
+ */
1700
3206
  constructor(log: unknown, options?: CCIPErrorOptions) {
1701
3207
  super(CCIPErrorCode.LOG_DATA_INVALID, `Invalid sui log: ${String(log)}`, {
1702
3208
  ...options,
@@ -1706,7 +3212,20 @@ export class CCIPSuiLogInvalidError extends CCIPError {
1706
3212
  }
1707
3213
  }
1708
3214
 
1709
- /** Thrown when Solana lane version is unsupported. */
3215
+ /**
3216
+ * Thrown when Solana lane version is unsupported.
3217
+ *
3218
+ * @example
3219
+ * ```typescript
3220
+ * try {
3221
+ * const lane = await solanaChain.getLane(onRamp, offRamp)
3222
+ * } catch (error) {
3223
+ * if (error instanceof CCIPSolanaLaneVersionUnsupportedError) {
3224
+ * console.log(`Unsupported version: ${error.context.version}`)
3225
+ * }
3226
+ * }
3227
+ * ```
3228
+ */
1710
3229
  export class CCIPSolanaLaneVersionUnsupportedError extends CCIPError {
1711
3230
  override readonly name = 'CCIPSolanaLaneVersionUnsupportedError'
1712
3231
  /** Creates a Solana lane version unsupported error. */
@@ -1719,7 +3238,20 @@ export class CCIPSolanaLaneVersionUnsupportedError extends CCIPError {
1719
3238
  }
1720
3239
  }
1721
3240
 
1722
- /** Thrown when multiple CCTP events found in transaction. */
3241
+ /**
3242
+ * Thrown when multiple CCTP events found in transaction.
3243
+ *
3244
+ * @example
3245
+ * ```typescript
3246
+ * try {
3247
+ * const cctpData = await chain.getOffchainTokenData(request)
3248
+ * } catch (error) {
3249
+ * if (error instanceof CCIPCctpMultipleEventsError) {
3250
+ * console.log(`Found ${error.context.count} events, expected 1`)
3251
+ * }
3252
+ * }
3253
+ * ```
3254
+ */
1723
3255
  export class CCIPCctpMultipleEventsError extends CCIPError {
1724
3256
  override readonly name = 'CCIPCctpMultipleEventsError'
1725
3257
  /** Creates a CCTP multiple events error. */
@@ -1736,7 +3268,20 @@ export class CCIPCctpMultipleEventsError extends CCIPError {
1736
3268
  }
1737
3269
  }
1738
3270
 
1739
- /** Thrown when compute units exceed limit. */
3271
+ /**
3272
+ * Thrown when compute units exceed limit.
3273
+ *
3274
+ * @example
3275
+ * ```typescript
3276
+ * try {
3277
+ * await solanaChain.execute({ offRamp, input, wallet })
3278
+ * } catch (error) {
3279
+ * if (error instanceof CCIPSolanaComputeUnitsExceededError) {
3280
+ * console.log(`CU: ${error.context.simulated} > limit ${error.context.limit}`)
3281
+ * }
3282
+ * }
3283
+ * ```
3284
+ */
1740
3285
  export class CCIPSolanaComputeUnitsExceededError extends CCIPError {
1741
3286
  override readonly name = 'CCIPSolanaComputeUnitsExceededError'
1742
3287
  /** Creates a compute units exceeded error. */
@@ -1753,7 +3298,20 @@ export class CCIPSolanaComputeUnitsExceededError extends CCIPError {
1753
3298
  }
1754
3299
  }
1755
3300
 
1756
- /** Thrown when Aptos hasher version is unsupported. */
3301
+ /**
3302
+ * Thrown when Aptos hasher version is unsupported.
3303
+ *
3304
+ * @example
3305
+ * ```typescript
3306
+ * try {
3307
+ * const hasher = AptosChain.getDestLeafHasher(lane)
3308
+ * } catch (error) {
3309
+ * if (error instanceof CCIPAptosHasherVersionUnsupportedError) {
3310
+ * console.log(`Unsupported hasher: ${error.context.version}`)
3311
+ * }
3312
+ * }
3313
+ * ```
3314
+ */
1757
3315
  export class CCIPAptosHasherVersionUnsupportedError extends CCIPError {
1758
3316
  override readonly name = 'CCIPAptosHasherVersionUnsupportedError'
1759
3317
  /** Creates an Aptos hasher version unsupported error. */
@@ -1772,7 +3330,21 @@ export class CCIPAptosHasherVersionUnsupportedError extends CCIPError {
1772
3330
 
1773
3331
  // API Client
1774
3332
 
1775
- /** Thrown when API client is not available (explicitly opted out). */
3333
+ /**
3334
+ * Thrown when API client is not available (explicitly opted out).
3335
+ *
3336
+ * @example
3337
+ * ```typescript
3338
+ * const chain = await EVMChain.fromUrl(rpc, { apiClient: null }) // Opt-out of API
3339
+ * try {
3340
+ * await chain.getLaneLatency(destChainSelector)
3341
+ * } catch (error) {
3342
+ * if (error instanceof CCIPApiClientNotAvailableError) {
3343
+ * console.log('API client disabled - initialize with apiClient or remove opt-out')
3344
+ * }
3345
+ * }
3346
+ * ```
3347
+ */
1776
3348
  export class CCIPApiClientNotAvailableError extends CCIPError {
1777
3349
  override readonly name = 'CCIPApiClientNotAvailableError'
1778
3350
  /**
@@ -1788,15 +3360,24 @@ export class CCIPApiClientNotAvailableError extends CCIPError {
1788
3360
  }
1789
3361
  }
1790
3362
 
1791
- /** Thrown when API returns hasNextPage=true unexpectedly (more than 100 messages). */
3363
+ /**
3364
+ * Thrown when API returns hasNextPage=true unexpectedly (more than 100 messages).
3365
+ *
3366
+ * @example
3367
+ * ```typescript
3368
+ * try {
3369
+ * const messages = await chain.getMessagesInTx(txHash)
3370
+ * } catch (error) {
3371
+ * if (error instanceof CCIPUnexpectedPaginationError) {
3372
+ * console.log(`Too many messages in tx: ${error.context.txHash}`)
3373
+ * console.log(`Message count: ${error.context.messageCount}+`)
3374
+ * }
3375
+ * }
3376
+ * ```
3377
+ */
1792
3378
  export class CCIPUnexpectedPaginationError extends CCIPError {
1793
3379
  override readonly name = 'CCIPUnexpectedPaginationError'
1794
- /**
1795
- * Creates an unexpected pagination error.
1796
- * @param txHash - The transaction hash queried
1797
- * @param messageCount - Number of messages returned in the response
1798
- * @param options - Additional error options
1799
- */
3380
+ /** Creates an unexpected pagination error. */
1800
3381
  constructor(txHash: string, messageCount: number, options?: CCIPErrorOptions) {
1801
3382
  super(
1802
3383
  CCIPErrorCode.API_UNEXPECTED_PAGINATION,
@@ -1812,7 +3393,22 @@ export class CCIPUnexpectedPaginationError extends CCIPError {
1812
3393
 
1813
3394
  // Viem Adapter
1814
3395
 
1815
- /** Thrown when viem adapter encounters an issue. */
3396
+ /**
3397
+ * Thrown when viem adapter encounters an issue.
3398
+ *
3399
+ * @example
3400
+ * ```typescript
3401
+ * import { fromViemClient } from '@chainlink/ccip-sdk/viem'
3402
+ *
3403
+ * try {
3404
+ * const chain = await fromViemClient(viemClient)
3405
+ * } catch (error) {
3406
+ * if (error instanceof CCIPViemAdapterError) {
3407
+ * console.log(`Viem adapter error: ${error.message}`)
3408
+ * }
3409
+ * }
3410
+ * ```
3411
+ */
1816
3412
  export class CCIPViemAdapterError extends CCIPError {
1817
3413
  override readonly name = 'CCIPViemAdapterError'
1818
3414
  /**