@tetherto/wdk-wallet 1.0.0-beta.16 → 1.0.0-beta.17

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 (45) hide show
  1. package/index.js +11 -12
  2. package/package.json +1 -1
  3. package/src/errors.js +280 -19
  4. package/src/multisig/errors.js +54 -0
  5. package/src/multisig/index.js +15 -3
  6. package/src/multisig/multisig-message-signing-read-only.js +63 -0
  7. package/src/multisig/multisig-message-signing.js +64 -0
  8. package/src/multisig/multisig-owner-management.js +22 -5
  9. package/src/multisig/wallet-account-multisig.js +28 -39
  10. package/src/multisig/wallet-account-read-only-multisig.js +20 -34
  11. package/src/protocols/bridge-protocol.js +35 -1
  12. package/src/protocols/errors.js +510 -0
  13. package/src/protocols/fiat-protocol.js +104 -4
  14. package/src/protocols/index.js +13 -0
  15. package/src/protocols/lending-protocol.js +114 -2
  16. package/src/protocols/sda-protocol.js +103 -16
  17. package/src/protocols/swap-protocol.js +35 -1
  18. package/src/protocols/swidge-protocol.js +166 -55
  19. package/src/signer.js +8 -4
  20. package/src/wallet-account-read-only-simple.js +86 -1
  21. package/src/wallet-account-read-only.js +175 -6
  22. package/src/wallet-account.js +25 -1
  23. package/src/wallet-manager.js +38 -22
  24. package/types/index.d.ts +9 -2
  25. package/types/src/errors.d.ts +198 -14
  26. package/types/src/multisig/errors.d.ts +33 -0
  27. package/types/src/multisig/index.d.ts +7 -3
  28. package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
  29. package/types/src/multisig/multisig-message-signing.d.ts +40 -0
  30. package/types/src/multisig/multisig-owner-management.d.ts +20 -4
  31. package/types/src/multisig/wallet-account-multisig.d.ts +29 -35
  32. package/types/src/multisig/wallet-account-read-only-multisig.d.ts +20 -40
  33. package/types/src/protocols/bridge-protocol.d.ts +39 -3
  34. package/types/src/protocols/errors.d.ts +366 -0
  35. package/types/src/protocols/fiat-protocol.d.ts +103 -9
  36. package/types/src/protocols/index.d.ts +11 -0
  37. package/types/src/protocols/lending-protocol.d.ts +118 -4
  38. package/types/src/protocols/sda-protocol.d.ts +120 -23
  39. package/types/src/protocols/swap-protocol.d.ts +40 -4
  40. package/types/src/protocols/swidge-protocol.d.ts +106 -38
  41. package/types/src/signer.d.ts +6 -4
  42. package/types/src/wallet-account-read-only-simple.d.ts +99 -1
  43. package/types/src/wallet-account-read-only.d.ts +95 -3
  44. package/types/src/wallet-account.d.ts +27 -3
  45. package/types/src/wallet-manager.d.ts +37 -35
@@ -13,7 +13,7 @@
13
13
  // limitations under the License.
14
14
  'use strict'
15
15
 
16
- import { NotImplementedError } from '../errors.js'
16
+ import { BridgeError, NotImplementedError, SwapError, SwidgeError } from './errors.js'
17
17
 
18
18
  /** @typedef {import('../wallet-account-read-only.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
19
19
 
@@ -27,6 +27,15 @@ import { NotImplementedError } from '../errors.js'
27
27
  /** @typedef {import('./bridge-protocol.js').BridgeOptions} BridgeOptions */
28
28
  /** @typedef {import('./bridge-protocol.js').BridgeResult} BridgeResult */
29
29
 
30
+ /** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
31
+ /** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
32
+ /** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
33
+ /** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
34
+ /** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
35
+ /** @typedef {import('./errors.js').ProviderError} ProviderError */
36
+ /** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
37
+ /** @typedef {import('./errors.js').ValueError} ValueError */
38
+
30
39
  /**
31
40
  * @typedef {'pending' | 'action-required' | 'completed' | 'failed'
32
41
  * | 'refund-pending' | 'refunded' | 'cancelled' | 'expired' | 'partial'} SwidgeStatus
@@ -151,8 +160,8 @@ import { NotImplementedError } from '../errors.js'
151
160
 
152
161
  /**
153
162
  * @interface
154
- * @implements {ISwapProtocol}
155
- * @implements {IBridgeProtocol}
163
+ * @extends {ISwapProtocol}
164
+ * @extends {IBridgeProtocol}
156
165
  */
157
166
  export class ISwidgeProtocol {
158
167
  /**
@@ -162,6 +171,12 @@ export class ISwidgeProtocol {
162
171
  *
163
172
  * @param {SwidgeOptions} options - The swidge options.
164
173
  * @returns {Promise<SwidgeQuote>} The quoted swidge details.
174
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swidge.
175
+ * @throws {ValueError} If the swidge options are not valid.
176
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
177
+ * @throws {ProviderRequiredError} If the method requires a provider.
178
+ * @throws {ProviderError} If the provider fails to perform the swidge.
179
+ * @throws {SwidgeError} If the swidge fails with an error.
165
180
  */
166
181
  async quoteSwidge (options) {
167
182
  throw new NotImplementedError('quoteSwidge(options)')
@@ -173,6 +188,13 @@ export class ISwidgeProtocol {
173
188
  * @param {SwidgeOptions} options - The swidge options.
174
189
  * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
175
190
  * @returns {Promise<SwidgeResult>} The swidge execution result.
191
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
192
+ * @throws {ValueError} If the swidge options are not valid.
193
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
194
+ * @throws {ProviderRequiredError} If the method requires a provider.
195
+ * @throws {ProviderError} If the provider fails to perform the swidge.
196
+ * @throws {SwidgeError} If the swidge fails with an error.
197
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
176
198
  */
177
199
  async swidge (options, config) {
178
200
  throw new NotImplementedError('swidge(options, config)')
@@ -184,7 +206,10 @@ export class ISwidgeProtocol {
184
206
  * @param {string} id - The swidge execution identifier returned by swidge.
185
207
  * @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
186
208
  * @returns {Promise<SwidgeStatusResult>} The current swidge status.
187
- * @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
209
+ * @throws {ValueError} If the id is not valid.
210
+ * @throws {NoSuchElementError} If no swidge exists for the given id.
211
+ * @throws {ProviderRequiredError} If the method requires a provider.
212
+ * @throws {ProviderError} If the provider fails to fetch the swidge's status.
188
213
  */
189
214
  async getSwidgeStatus (id, options) {
190
215
  throw new NotImplementedError('getSwidgeStatus(id, options)')
@@ -194,6 +219,8 @@ export class ISwidgeProtocol {
194
219
  * Retrieves the chains supported by the provider for swidge operations.
195
220
  *
196
221
  * @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
222
+ * @throws {ProviderRequiredError} If the method requires a provider.
223
+ * @throws {ProviderError} If the provider fails to fetch the available blockchains.
197
224
  */
198
225
  async getSupportedChains () {
199
226
  throw new NotImplementedError('getSupportedChains()')
@@ -204,6 +231,8 @@ export class ISwidgeProtocol {
204
231
  *
205
232
  * @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
206
233
  * @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
234
+ * @throws {ProviderRequiredError} If the method requires a provider.
235
+ * @throws {ProviderError} If the provider fails to fetch the available tokens.
207
236
  */
208
237
  async getSupportedTokens (options) {
209
238
  throw new NotImplementedError('getSupportedTokens(options)')
@@ -263,19 +292,35 @@ export default class SwidgeProtocol {
263
292
  *
264
293
  * @param {SwapOptions} options - The swap's options.
265
294
  * @returns {Promise<SwapResult>} The swap's result.
266
- * @throws {Error} If no account, or a read-only account was given at construction.
295
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swap.
296
+ * @throws {ValueError} If the swap options are not valid.
297
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
298
+ * @throws {ProviderRequiredError} If the method requires a provider.
299
+ * @throws {ProviderError} If the provider fails to perform the swap.
300
+ * @throws {SwapError} If the swap fails with an error.
301
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
267
302
  */
268
303
  async swap (options) {
269
- const result = await this.swidge({
270
- fromToken: options.tokenIn,
271
- toToken: options.tokenOut,
272
- recipient: options.to,
273
- fromTokenAmount: options.tokenInAmount,
274
- toTokenAmount: options.tokenOutAmount,
275
- minAmountOut: options.minAmountOut
276
- })
277
- const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
278
- return { hash: result.id, fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
304
+ try {
305
+ const result = await this.swidge({
306
+ fromToken: options.tokenIn,
307
+ toToken: options.tokenOut,
308
+ recipient: options.to,
309
+ fromTokenAmount: options.tokenInAmount,
310
+ toTokenAmount: options.tokenOutAmount,
311
+ minAmountOut: options.minAmountOut
312
+ })
313
+
314
+ const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
315
+
316
+ return { hash: result.id, fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
317
+ } catch (error) {
318
+ if (error instanceof SwidgeError) {
319
+ throw new SwapError(error.message, { reason: error.reason, cause: error })
320
+ }
321
+
322
+ throw error
323
+ }
279
324
  }
280
325
 
281
326
  /**
@@ -283,19 +328,34 @@ export default class SwidgeProtocol {
283
328
  *
284
329
  * @param {SwapOptions} options - The swap's options.
285
330
  * @returns {Promise<Omit<SwapResult, 'hash'>>} The swap's quotes.
286
- * @throws {Error} If no account was given at construction.
331
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
332
+ * @throws {ValueError} If the swap options are not valid.
333
+ * @throws {InvalidTokenError} If the input or output tokens are not valid ERC 20 token's addresses.
334
+ * @throws {ProviderRequiredError} If the method requires a provider.
335
+ * @throws {ProviderError} If the provider fails to estimate the costs of the swap.
336
+ * @throws {SwapError} If the swap fails with an error.
287
337
  */
288
338
  async quoteSwap (options) {
289
- const result = await this.quoteSwidge({
290
- fromToken: options.tokenIn,
291
- toToken: options.tokenOut,
292
- recipient: options.to,
293
- fromTokenAmount: options.tokenInAmount,
294
- toTokenAmount: options.tokenOutAmount,
295
- minAmountOut: options.minAmountOut
296
- })
297
- const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
298
- return { fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
339
+ try {
340
+ const result = await this.quoteSwidge({
341
+ fromToken: options.tokenIn,
342
+ toToken: options.tokenOut,
343
+ recipient: options.to,
344
+ fromTokenAmount: options.tokenInAmount,
345
+ toTokenAmount: options.tokenOutAmount,
346
+ minAmountOut: options.minAmountOut
347
+ })
348
+
349
+ const fee = result.fees.reduce((acc, f) => acc + f.amount, 0n)
350
+
351
+ return { fee, tokenInAmount: result.fromTokenAmount, tokenOutAmount: result.toTokenAmount }
352
+ } catch (error) {
353
+ if (error instanceof SwidgeError) {
354
+ throw new SwapError(error.message, { reason: error.reason, cause: error })
355
+ }
356
+
357
+ throw error
358
+ }
299
359
  }
300
360
 
301
361
  /**
@@ -303,21 +363,38 @@ export default class SwidgeProtocol {
303
363
  *
304
364
  * @param {BridgeOptions} options - The bridge's options.
305
365
  * @returns {Promise<BridgeResult>} The bridge's result.
306
- * @throws {Error} If no account, or a read-only account was given at construction.
366
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a bridge.
367
+ * @throws {ValueError} If the bridge options are not valid.
368
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
369
+ * @throws {ProviderRequiredError} If the method requires a provider.
370
+ * @throws {ProviderError} If the provider fails to perform the bridge.
371
+ * @throws {BridgeError} If the bridge fails with an error.
372
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
307
373
  */
308
374
  async bridge (options) {
309
- const { id: hash, fees } = await this.swidge({
310
- fromToken: options.token,
311
- toToken: options.token,
312
- toChain: options.targetChain,
313
- recipient: options.recipient,
314
- fromTokenAmount: options.amount
315
- })
316
- const fee = fees.filter(f => f.type === 'network')
317
- .reduce((acc, { amount }) => acc + amount, 0n)
318
- const bridgeFee = fees.filter(f => f.type === 'protocol')
319
- .reduce((acc, { amount }) => acc + amount, 0n)
320
- return { hash, fee, bridgeFee }
375
+ try {
376
+ const { id: hash, fees } = await this.swidge({
377
+ fromToken: options.token,
378
+ toToken: options.token,
379
+ toChain: options.targetChain,
380
+ recipient: options.recipient,
381
+ fromTokenAmount: options.amount
382
+ })
383
+
384
+ const fee = fees.filter(f => f.type === 'network')
385
+ .reduce((acc, { amount }) => acc + amount, 0n)
386
+
387
+ const bridgeFee = fees.filter(f => f.type === 'protocol')
388
+ .reduce((acc, { amount }) => acc + amount, 0n)
389
+
390
+ return { hash, fee, bridgeFee }
391
+ } catch (error) {
392
+ if (error instanceof SwidgeError) {
393
+ throw new BridgeError(error.message, { reason: error.reason, cause: error })
394
+ }
395
+
396
+ throw error
397
+ }
321
398
  }
322
399
 
323
400
  /**
@@ -325,21 +402,37 @@ export default class SwidgeProtocol {
325
402
  *
326
403
  * @param {BridgeOptions} options - The bridge's options.
327
404
  * @returns {Promise<Omit<BridgeResult, 'hash'>>} The bridge's quotes.
328
- * @throws {Error} If no account was given at construction.
405
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swap.
406
+ * @throws {ValueError} If the bridge options are not valid.
407
+ * @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
408
+ * @throws {ProviderRequiredError} If the method requires a provider.
409
+ * @throws {ProviderError} If the provider fails to perform the bridge.
410
+ * @throws {BridgeError} If the bridge fails with an error.
329
411
  */
330
412
  async quoteBridge (options) {
331
- const { fees } = await this.quoteSwidge({
332
- fromToken: options.token,
333
- toToken: options.token,
334
- toChain: options.targetChain,
335
- recipient: options.recipient,
336
- fromTokenAmount: options.amount
337
- })
338
- const fee = fees.filter(f => f.type === 'network')
339
- .reduce((acc, { amount }) => acc + amount, 0n)
340
- const bridgeFee = fees.filter(f => f.type === 'protocol')
341
- .reduce((acc, { amount }) => acc + amount, 0n)
342
- return { fee, bridgeFee }
413
+ try {
414
+ const { fees } = await this.quoteSwidge({
415
+ fromToken: options.token,
416
+ toToken: options.token,
417
+ toChain: options.targetChain,
418
+ recipient: options.recipient,
419
+ fromTokenAmount: options.amount
420
+ })
421
+
422
+ const fee = fees.filter(f => f.type === 'network')
423
+ .reduce((acc, { amount }) => acc + amount, 0n)
424
+
425
+ const bridgeFee = fees.filter(f => f.type === 'protocol')
426
+ .reduce((acc, { amount }) => acc + amount, 0n)
427
+
428
+ return { fee, bridgeFee }
429
+ } catch (error) {
430
+ if (error instanceof SwidgeError) {
431
+ throw new BridgeError(error.message, { reason: error.reason, cause: error })
432
+ }
433
+
434
+ throw error
435
+ }
343
436
  }
344
437
 
345
438
  /**
@@ -350,7 +443,12 @@ export default class SwidgeProtocol {
350
443
  * @abstract
351
444
  * @param {SwidgeOptions} options - The swidge options.
352
445
  * @returns {Promise<SwidgeQuote>} The quoted swidge details.
353
- * @throws {Error} If no account was given at construction.
446
+ * @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a swidge.
447
+ * @throws {ValueError} If the swidge options are not valid.
448
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
449
+ * @throws {ProviderRequiredError} If the method requires a provider.
450
+ * @throws {ProviderError} If the provider fails to perform the swidge.
451
+ * @throws {SwidgeError} If the swidge fails with an error.
354
452
  */
355
453
  async quoteSwidge (options) {
356
454
  throw new NotImplementedError('quoteSwidge(options)')
@@ -363,7 +461,13 @@ export default class SwidgeProtocol {
363
461
  * @param {SwidgeOptions} options - The swidge options.
364
462
  * @param {SwidgeProtocolConfig} [config] - Optional provider-specific execution configuration.
365
463
  * @returns {Promise<SwidgeResult>} The swidge execution result.
366
- * @throws {Error} If no account, or a read-only account was given at construction.
464
+ * @throws {AccountRequiredError} If the protocol requires a full account to perform a swidge.
465
+ * @throws {ValueError} If the swidge options are not valid.
466
+ * @throws {InvalidTokenError} If the from or to tokens are not valid ERC 20 token's addresses.
467
+ * @throws {ProviderRequiredError} If the method requires a provider.
468
+ * @throws {ProviderError} If the provider fails to perform the swidge.
469
+ * @throws {SwidgeError} If the swidge fails with an error.
470
+ * @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the max. network or protocol fee options.
367
471
  */
368
472
  async swidge (options, config) {
369
473
  throw new NotImplementedError('swidge(options, config)')
@@ -376,7 +480,10 @@ export default class SwidgeProtocol {
376
480
  * @param {string} id - The swidge execution identifier returned by swidge.
377
481
  * @param {SwidgeStatusOptions} [options] - Optional hints to assist provider lookups.
378
482
  * @returns {Promise<SwidgeStatusResult>} The current swidge status.
379
- * @throws {Error} If the id is invalid, or no swidge exists with the given identifier.
483
+ * @throws {ValueError} If the id is not valid.
484
+ * @throws {NoSuchElementError} If no swidge exists for the given id.
485
+ * @throws {ProviderRequiredError} If the method requires a provider.
486
+ * @throws {ProviderError} If the provider fails to fetch the swidge's status.
380
487
  */
381
488
  async getSwidgeStatus (id, options) {
382
489
  throw new NotImplementedError('getSwidgeStatus(id, options)')
@@ -387,6 +494,8 @@ export default class SwidgeProtocol {
387
494
  *
388
495
  * @abstract
389
496
  * @returns {Promise<SwidgeSupportedChain[]>} The supported chains.
497
+ * @throws {ProviderRequiredError} If the method requires a provider.
498
+ * @throws {ProviderError} If the provider fails to fetch the available blockchains.
390
499
  */
391
500
  async getSupportedChains () {
392
501
  throw new NotImplementedError('getSupportedChains()')
@@ -398,6 +507,8 @@ export default class SwidgeProtocol {
398
507
  * @abstract
399
508
  * @param {SwidgeSupportedTokensOptions} [options] - Optional filters for chain- or route-scoped token discovery.
400
509
  * @returns {Promise<SwidgeSupportedToken[]>} The supported tokens.
510
+ * @throws {ProviderRequiredError} If the method requires a provider.
511
+ * @throws {ProviderError} If the provider fails to fetch the available tokens.
401
512
  */
402
513
  async getSupportedTokens (options) {
403
514
  throw new NotImplementedError('getSupportedTokens(options)')
package/src/signer.js CHANGED
@@ -15,6 +15,9 @@
15
15
 
16
16
  import { NotImplementedError } from './errors.js'
17
17
 
18
+ /** @typedef {import('./errors.js').UnsupportedOperationError} UnsupportedOperationError */
19
+ /** @typedef {import('./errors.js').ValueError} ValueError */
20
+
18
21
  /**
19
22
  * A minimal, cross-chain signer interface.
20
23
  *
@@ -24,12 +27,13 @@ export class ISigner {
24
27
  /**
25
28
  * Derive a child signer using a relative path (e.g., "0'/0/0").
26
29
  *
27
- * @param {string} relPath - The relative derivation path.
30
+ * @param {string} path - The relative derivation path.
28
31
  * @returns {Promise<ISigner>} The derived signer.
29
- * @throws {SignerError} If the signer does not support derivation.
32
+ * @throws {UnsupportedOperationError} If the signer does not support account derivation.
33
+ * @throws {ValueError} If the path is not valid.
30
34
  */
31
- async derive (relPath) {
32
- throw new NotImplementedError('derive(relPath)')
35
+ async derive (path) {
36
+ throw new NotImplementedError('derive(path)')
33
37
  }
34
38
 
35
39
  /**
@@ -15,6 +15,52 @@
15
15
 
16
16
  import { NotImplementedError } from './errors.js'
17
17
 
18
+ /** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
19
+ /** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
20
+ /** @typedef {import('./errors.js').ProviderError} ProviderError */
21
+ /** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
22
+ /** @typedef {import('./errors.js').TimeoutError} TimeoutError */
23
+ /** @typedef {import('./errors.js').ValueError} ValueError */
24
+ /** @typedef {import('./errors.js').UnsupportedOperationError} UnsupportedOperationError */
25
+
26
+ /**
27
+ * A normalized, cross-chain transaction finality level.
28
+ *
29
+ * - `pending`: seen, not settled (mempool / processed / in-flight).
30
+ * - `confirmed`: settled, reversible only under extreme conditions.
31
+ * - `final`: irreversible per the chain's own guarantees.
32
+ * - `dropped`: evicted / replaced, never landed.
33
+ *
34
+ * @typedef {'pending' | 'confirmed' | 'final' | 'dropped'} Finality
35
+ */
36
+
37
+ /**
38
+ * A normalized, cross-chain transaction receipt. Blockchain modules extend this
39
+ * type with their own native receipt fields (e.g. `confirmations`, the raw
40
+ * transaction and receipt objects, etc.).
41
+ *
42
+ * @typedef {Object} TransactionReceipt
43
+ * @property {string} hash - The transaction's identifier (hash / signature / lt:hash).
44
+ * @property {Finality} finality - The transaction's finality level.
45
+ * @property {boolean} [success] - The execution's result (not set if the transaction is still pending or it has been dropped).
46
+ * @property {number} [block] - A reference to the including block (block number / height / slot / masterchain seqno).
47
+ * @property {bigint} [fee] - The fee paid, when known.
48
+ */
49
+
50
+ /**
51
+ * The finality level to wait for.
52
+ *
53
+ * @typedef {'confirmed' | 'final'} WaitForTransactionTarget
54
+ */
55
+
56
+ /**
57
+ * @typedef {Object} WaitForTransactionOptions
58
+ * @property {WaitForTransactionTarget} [target] - The finality target to wait for (default: 'confirmed').
59
+ * @property {number} [timeout] - The total time budget in milliseconds before giving up. If omitted, the account's `defaultWaitTimeout` is used.
60
+ * @property {number} [interval] - The poll cadence in milliseconds. If omitted, the account's `defaultWaitInterval` is used.
61
+ * @property {number} [maxPollErrors] - How many consecutive getTransaction() failures to tolerate before rethrowing (default: 3).
62
+ */
63
+
18
64
  /**
19
65
  * The read-only members shared by every wallet account, single-signer or multisig.
20
66
  *
@@ -40,7 +86,7 @@ export class IWalletAccountReadOnlySimple {
40
86
  * @param {string} message - The original message.
41
87
  * @param {string} signature - The signature to verify.
42
88
  * @returns {Promise<boolean>} True if the signature is valid.
43
- * @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
89
+ * @throws {UnsupportedOperationError} If the read-only wallet account class is not able to provide an implementation for the method.
44
90
  */
45
91
  async verify (message, signature) {
46
92
  throw new NotImplementedError('verify(message, signature)')
@@ -50,6 +96,8 @@ export class IWalletAccountReadOnlySimple {
50
96
  * Returns the account's native token balance.
51
97
  *
52
98
  * @returns {Promise<bigint>} The native token balance.
99
+ * @throws {ProviderRequiredError} If the method requires a provider.
100
+ * @throws {ProviderError} If the provider fails to fetch the account's balance.
53
101
  */
54
102
  async getBalance () {
55
103
  throw new NotImplementedError('getBalance()')
@@ -60,6 +108,10 @@ export class IWalletAccountReadOnlySimple {
60
108
  *
61
109
  * @param {string} tokenAddress - The smart contract address of the token.
62
110
  * @returns {Promise<bigint>} The token balance.
111
+ * @throws {ValueError} If the token's address is not valid.
112
+ * @throws {InvalidTokenError} If the token's address doesn't match an existing ERC 20 token.
113
+ * @throws {ProviderRequiredError} If the method requires a provider.
114
+ * @throws {ProviderError} If the provider fails to fetch the account's token balance.
63
115
  */
64
116
  async getTokenBalance (tokenAddress) {
65
117
  throw new NotImplementedError('getTokenBalance(tokenAddress)')
@@ -68,10 +120,43 @@ export class IWalletAccountReadOnlySimple {
68
120
  /**
69
121
  * Returns a transaction's receipt.
70
122
  *
123
+ * @deprecated Use {@link getTransaction} instead, which returns a normalized, finality-based receipt. The native receipt fields remain available on each module's extended return type.
71
124
  * @param {string} hash - The transaction's hash.
72
125
  * @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
126
+ * @throws {ValueError} If the hash is not valid.
127
+ * @throws {ProviderRequiredError} If the method requires a provider.
128
+ * @throws {ProviderError} If the provider fails to fetch the transaction's receipt.
73
129
  */
74
130
  async getTransactionReceipt (hash) {
75
131
  throw new NotImplementedError('getTransactionReceipt(hash)')
76
132
  }
133
+
134
+ /**
135
+ * Returns a normalized, finality-based receipt for a transaction.
136
+ *
137
+ * @param {string} hash - The transaction's identifier (hash / signature / lt:hash).
138
+ * @returns {Promise<TransactionReceipt>} The normalized receipt.
139
+ * @throws {ValueError} If the hash is not a valid identifier.
140
+ * @throws {NoSuchElementError} If no transaction has been found for the given hash.
141
+ * @throws {ProviderRequiredError} If the method requires a provider.
142
+ * @throws {ProviderError} If the provider fails to fetch the transaction.
143
+ */
144
+ async getTransaction (hash) {
145
+ throw new NotImplementedError('getTransaction(hash)')
146
+ }
147
+
148
+ /**
149
+ * Blocks until a transaction reaches a terminal state (the requested finality target or `dropped`), or times out.
150
+ *
151
+ * @param {string} hash - The transaction's identifier.
152
+ * @param {WaitForTransactionOptions} [options] - The wait options.
153
+ * @returns {Promise<TransactionReceipt>} The terminal receipt: the finality target reached (inspect `success` to tell success from revert), or `dropped`.
154
+ * @throws {ValueError} If the hash is not a valid identifier.
155
+ * @throws {ProviderRequiredError} If the method requires a provider.
156
+ * @throws {ProviderError} If the provider fails to fetch the transaction.
157
+ * @throws {TimeoutError} If the operation times out.
158
+ */
159
+ async waitForTransaction (hash, options) {
160
+ throw new NotImplementedError('waitForTransaction(hash, options)')
161
+ }
77
162
  }