@tetherto/wdk-wallet 1.0.0-beta.2 → 1.0.0-beta.21

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 (50) hide show
  1. package/AGENTS.md +49 -0
  2. package/README.md +2 -2
  3. package/bare.js +3 -3
  4. package/index.js +14 -2
  5. package/package.json +18 -4
  6. package/src/disposable.js +26 -0
  7. package/src/errors.js +318 -3
  8. package/src/multisig/errors.js +54 -0
  9. package/src/multisig/index.js +42 -0
  10. package/src/multisig/multisig-message-signing-read-only.js +63 -0
  11. package/src/multisig/multisig-message-signing.js +64 -0
  12. package/src/multisig/multisig-owner-management.js +94 -0
  13. package/src/multisig/wallet-account-multisig.js +144 -0
  14. package/src/multisig/wallet-account-read-only-multisig.js +98 -0
  15. package/src/protocols/bridge-protocol.js +35 -1
  16. package/src/protocols/errors.js +510 -0
  17. package/src/protocols/fiat-protocol.js +401 -0
  18. package/src/protocols/index.js +76 -0
  19. package/src/protocols/lending-protocol.js +114 -2
  20. package/src/protocols/sda-protocol.js +643 -0
  21. package/src/protocols/swap-protocol.js +36 -1
  22. package/src/protocols/swidge-protocol.js +516 -0
  23. package/src/signer.js +89 -0
  24. package/src/wallet-account-read-only-simple.js +162 -0
  25. package/src/wallet-account-read-only.js +186 -40
  26. package/src/wallet-account.js +59 -22
  27. package/src/wallet-manager.js +152 -25
  28. package/types/index.d.ts +13 -4
  29. package/types/src/disposable.d.ts +7 -0
  30. package/types/src/errors.d.ts +220 -2
  31. package/types/src/multisig/errors.d.ts +33 -0
  32. package/types/src/multisig/index.d.ts +15 -0
  33. package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
  34. package/types/src/multisig/multisig-message-signing.d.ts +40 -0
  35. package/types/src/multisig/multisig-owner-management.d.ts +65 -0
  36. package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
  37. package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
  38. package/types/src/protocols/bridge-protocol.d.ts +39 -3
  39. package/types/src/protocols/errors.d.ts +366 -0
  40. package/types/src/protocols/fiat-protocol.d.ts +409 -0
  41. package/types/src/protocols/index.d.ts +64 -0
  42. package/types/src/protocols/lending-protocol.d.ts +118 -4
  43. package/types/src/protocols/sda-protocol.d.ts +737 -0
  44. package/types/src/protocols/swap-protocol.d.ts +44 -4
  45. package/types/src/protocols/swidge-protocol.d.ts +483 -0
  46. package/types/src/signer.d.ts +53 -0
  47. package/types/src/wallet-account-read-only-simple.d.ts +144 -0
  48. package/types/src/wallet-account-read-only.d.ts +104 -27
  49. package/types/src/wallet-account.d.ts +55 -20
  50. package/types/src/wallet-manager.d.ts +109 -17
@@ -15,12 +15,19 @@
15
15
 
16
16
  import * as bip39 from 'bip39'
17
17
 
18
- import { NotImplementedError } from './errors.js'
18
+ import { InvalidSignerError, NoSuchElementError, NotImplementedError, ValueError } from './errors.js'
19
19
 
20
20
  /** @typedef {import('./wallet-account.js').IWalletAccount} IWalletAccount */
21
21
 
22
+ /** @typedef {import('./signer.js').ISigner} ISigner */
23
+ /** @typedef {import('./disposable.js').IDisposable} IDisposable */
24
+
25
+ /** @typedef {import('./errors.js').ProviderError} ProviderError */
26
+ /** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
27
+
22
28
  /**
23
29
  * @typedef {Object} WalletConfig
30
+ * @property {number | bigint} [transactionMaxFee] - The maximum fee amount for sending transactions.
24
31
  * @property {number | bigint} [transferMaxFee] - The maximum fee amount for transfer operations.
25
32
  */
26
33
 
@@ -30,33 +37,62 @@ import { NotImplementedError } from './errors.js'
30
37
  * @property {bigint} fast - The fee rate for transaction sent with fast priority.
31
38
  */
32
39
 
33
- /** @abstract */
40
+ /**
41
+ * @abstract
42
+ * @template {ISigner} [TSigner=ISigner]
43
+ * @implements {IDisposable}
44
+ */
34
45
  export default class WalletManager {
35
46
  /**
36
- * Creates a new wallet manager.
47
+ * Creates a new wallet manager from a seed.
48
+ *
49
+ * @overload
50
+ * @param {string | Uint8Array} seed - A BIP-39 mnemonic seed phrase, or a raw BIP-32 master seed (16-64 bytes).
51
+ * @param {WalletConfig} [config] - The wallet configuration.
52
+ * @throws {ValueError} If the seed is not a valid seed or BIP-39 seed phrase.
53
+ */
54
+
55
+ /**
56
+ * Creates a new wallet manager from a default signer.
37
57
  *
38
- * @param {string | Uint8Array} seed - The wallet's [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
58
+ * @overload
59
+ * @param {TSigner} signer - The default signer.
39
60
  * @param {WalletConfig} [config] - The wallet configuration.
61
+ * @throws {InvalidSignerError} If the given signer doesn't support account derivation.
40
62
  */
41
- constructor (seed, config = { }) {
42
- if (typeof seed === 'string') {
43
- if (!WalletManager.isValidSeedPhrase(seed)) {
44
- throw new Error('The seed phrase is invalid.')
63
+ constructor (seedOrSigner, config = {}) {
64
+ if (typeof seedOrSigner === 'string') {
65
+ if (!WalletManager.isValidSeedPhrase(seedOrSigner)) {
66
+ throw new ValueError('Invalid seed phrase.')
45
67
  }
46
68
 
47
- seed = bip39.mnemonicToSeedSync(seed)
69
+ seedOrSigner = bip39.mnemonicToSeedSync(seedOrSigner)
70
+ }
71
+
72
+ const isSeed = seedOrSigner instanceof Uint8Array
73
+
74
+ if (!isSeed && !seedOrSigner.isDerivable) {
75
+ throw new InvalidSignerError('The default signer must be derivable. Non-derivable signers (e.g. private-key signers) can only be registered by name via addSigner.')
48
76
  }
49
77
 
50
78
  /** @private */
51
- this._seed = seed
79
+ this._seed = isSeed ? seedOrSigner : undefined
52
80
 
53
81
  /**
54
- * The wallet configuration.
82
+ * The default signer.
55
83
  *
56
84
  * @protected
57
- * @type {WalletConfig}
85
+ * @type {TSigner | undefined}
58
86
  */
59
- this._config = config
87
+ this._defaultSigner = isSeed ? undefined : seedOrSigner
88
+
89
+ /**
90
+ * A map between signer names and signers added via {@link addSigner}.
91
+ *
92
+ * @protected
93
+ * @type {Record<string, TSigner>}
94
+ */
95
+ this._signers = {}
60
96
 
61
97
  /**
62
98
  * A map between derivation paths and wallet accounts. The {@link dispose} method will automatically dispose
@@ -64,18 +100,29 @@ export default class WalletManager {
64
100
  * {@link getAccount} and {@link getAccountByPath} methods.
65
101
  *
66
102
  * @protected
67
- * @type {{ [path: string]: IWalletAccount }}
103
+ * @type {Record<string, IWalletAccount>}
68
104
  */
69
105
  this._accounts = {}
106
+
107
+ /**
108
+ * The wallet configuration.
109
+ *
110
+ * @protected
111
+ * @type {WalletConfig}
112
+ */
113
+ this._config = config
70
114
  }
71
115
 
72
116
  /**
73
117
  * Returns a random [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
74
118
  *
119
+ * @param {12 | 24} [wordCount] - The number of words in the seed phrase (default: 12).
75
120
  * @returns {string} The seed phrase.
76
121
  */
77
- static getRandomSeedPhrase () {
78
- return bip39.generateMnemonic()
122
+ static getRandomSeedPhrase (wordCount = 12) {
123
+ const strength = wordCount === 12 ? 128 : 256
124
+
125
+ return bip39.generateMnemonic(strength)
79
126
  }
80
127
 
81
128
  /**
@@ -89,23 +136,96 @@ export default class WalletManager {
89
136
  }
90
137
 
91
138
  /**
92
- * The seed phrase of the wallet.
139
+ * The seed of the wallet.
93
140
  *
94
- * @type {Uint8Array}
141
+ * @type {Uint8Array | undefined}
95
142
  */
96
143
  get seed () {
97
144
  return this._seed
98
145
  }
99
146
 
147
+ /**
148
+ * Registers a signer with the given name.
149
+ *
150
+ * @param {string} signerName - The signer name.
151
+ * @param {TSigner} signer - The signer.
152
+ * @returns {this} The wallet manager.
153
+ * @throws {ValueError} If the signer name is an empty or blank string.
154
+ */
155
+ addSigner (signerName, signer) {
156
+ if (!signerName.trim()) {
157
+ throw new ValueError('The signer name cannot be an empty or blank string.')
158
+ }
159
+
160
+ this._signers[signerName] = signer
161
+
162
+ return this
163
+ }
164
+
165
+ /**
166
+ * Returns the default signer, or the signer with the given name.
167
+ *
168
+ * @param {string} [signerName] - If set, returns the signer with the given name.
169
+ * @returns {TSigner} The signer.
170
+ * @throws {NoSuchElementError} If the default signer is not set, or no signers are found for the given name.
171
+ */
172
+ getSigner (signerName) {
173
+ if (signerName === undefined) {
174
+ if (this._defaultSigner === undefined) {
175
+ throw new NoSuchElementError('No default signer set.')
176
+ }
177
+
178
+ return this._defaultSigner
179
+ }
180
+
181
+ const signer = this._signers[signerName]
182
+
183
+ if (signer === undefined) {
184
+ throw new NoSuchElementError(`No signer found with name "${signerName}".`)
185
+ }
186
+
187
+ return signer
188
+ }
189
+
190
+ /**
191
+ * Returns a shallow copy of the map of signers registered via {@link addSigner}.
192
+ * The default signer is not included; use {@link getSigner} with no arguments
193
+ * to retrieve it.
194
+ *
195
+ * @returns {Record<string, TSigner>} A map of signer names to signers. Empty if no signers have been registered.
196
+ */
197
+ getSigners () {
198
+ return { ...this._signers }
199
+ }
200
+
100
201
  /**
101
202
  * Returns the wallet account at a specific index (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)).
102
203
  *
103
- * @abstract
204
+ * @overload
104
205
  * @param {number} [index] - The index of the account to get (default: 0).
206
+ * @param {Object} [options] - Account options.
207
+ * @param {string} [options.signerName] - The signer name.
105
208
  * @returns {Promise<IWalletAccount>} The account.
209
+ * @throws {ValueError} If the index is not valid.
210
+ * @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
211
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
106
212
  */
107
- async getAccount (index = 0) {
108
- throw new NotImplementedError('getAccount(index)')
213
+
214
+ /**
215
+ * Returns the wallet account associated with a registered signer. For
216
+ * non-derivable signers (e.g., private-key signers), returns the signer's
217
+ * single account. For derivable signers, returns the wallet account at the
218
+ * signer's root, with no further derivation.
219
+ *
220
+ * @overload
221
+ * @param {string} signerName - The signer name registered via {@link addSigner}.
222
+ * @returns {Promise<IWalletAccount>} The account.
223
+ * @throws {NoSuchElementError} If no signer exists with the given name.
224
+ */
225
+
226
+ /** @abstract */
227
+ async getAccount (indexOrSignerName = 0, options = {}) {
228
+ throw new NotImplementedError('getAccount(indexOrSignerName, options?)')
109
229
  }
110
230
 
111
231
  /**
@@ -113,10 +233,15 @@ export default class WalletManager {
113
233
  *
114
234
  * @abstract
115
235
  * @param {string} path - The derivation path (e.g. "0'/0/0").
236
+ * @param {Object} [options] - Account options.
237
+ * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
116
238
  * @returns {Promise<IWalletAccount>} The account.
239
+ * @throws {ValueError} If the path is not valid.
240
+ * @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
241
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
117
242
  */
118
- async getAccountByPath (path) {
119
- throw new NotImplementedError('getAccountByPath(path)')
243
+ async getAccountByPath (path, options = {}) {
244
+ throw new NotImplementedError('getAccountByPath(path, options?)')
120
245
  }
121
246
 
122
247
  /**
@@ -124,17 +249,19 @@ export default class WalletManager {
124
249
  *
125
250
  * @abstract
126
251
  * @returns {Promise<FeeRates>} The fee rates (in base unit).
252
+ * @throws {ProviderRequiredError} If the method requires a provider.
253
+ * @throws {ProviderError} If the provider fails to fetch fee rates.
127
254
  */
128
255
  async getFeeRates () {
129
256
  throw new NotImplementedError('getFeeRates()')
130
257
  }
131
258
 
132
259
  /**
133
- * Disposes all the wallet accounts, erasing their private keys from the memory.
260
+ * Disposes all wallet accounts, clearing secret material from memory.
134
261
  */
135
262
  dispose () {
136
263
  for (const account of Object.values(this._accounts)) {
137
- if (account.keyPair.privateKey) {
264
+ if (account.keyPair?.privateKey) {
138
265
  account.dispose()
139
266
  }
140
267
  }
package/types/index.d.ts CHANGED
@@ -1,11 +1,20 @@
1
+ export { default } from "./src/wallet-manager.js";
2
+ export { IWalletAccount } from "./src/wallet-account.js";
3
+ export { ISigner } from "./src/signer.js";
1
4
  export type FeeRates = import("./src/wallet-manager.js").FeeRates;
2
5
  export type WalletConfig = import("./src/wallet-manager.js").WalletConfig;
3
6
  export type Transaction = import("./src/wallet-account-read-only.js").Transaction;
4
7
  export type TransactionResult = import("./src/wallet-account-read-only.js").TransactionResult;
5
8
  export type TransferOptions = import("./src/wallet-account-read-only.js").TransferOptions;
6
9
  export type TransferResult = import("./src/wallet-account-read-only.js").TransferResult;
10
+ export type Finality = import("./src/wallet-account-read-only-simple.js").Finality;
11
+ export type TransactionReceipt = import("./src/wallet-account-read-only-simple.js").TransactionReceipt;
12
+ export type WaitForTransactionTarget = import("./src/wallet-account-read-only-simple.js").WaitForTransactionTarget;
13
+ export type WaitForTransactionOptions = import("./src/wallet-account-read-only-simple.js").WaitForTransactionOptions;
7
14
  export type KeyPair = import("./src/wallet-account.js").KeyPair;
8
- export { default } from "./src/wallet-manager.js";
9
- export { default as WalletAccountReadOnly, IWalletAccountReadOnly } from "./src/wallet-account-read-only.js";
10
- export { IWalletAccount } from "./src/wallet-account.js";
11
- export { NotImplementedError } from "./src/errors.js";
15
+ export { IDisposable } from "./src/disposable.js";
16
+ export type ProviderErrorOptions = import("./src/errors.js").ProviderErrorOptions;
17
+ export type TransactionErrorOptions = import("./src/errors.js").TransactionErrorOptions;
18
+ export type TransferErrorOptions = import("./src/errors.js").TransferErrorOptions;
19
+ export { default as WalletAccountReadOnly, IWalletAccountReadOnly, FINALITY } from "./src/wallet-account-read-only.js";
20
+ export { AssertionError, InvalidTokenError, InvalidSignerError, InvalidSignerError as SignerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderErrorReason, ProviderRequiredError, TimeoutError, TransactionError, TransactionErrorReason, TransferError, TransferErrorReason, UnsupportedOperationError, ValueError, WdkError } from "./src/errors.js";
@@ -0,0 +1,7 @@
1
+ /** @interface */
2
+ export class IDisposable {
3
+ /**
4
+ * Disposes the object along with all its data (cleaning up any sensitive field from memory).
5
+ */
6
+ dispose(): void;
7
+ }
@@ -1,8 +1,226 @@
1
- export class NotImplementedError extends Error {
1
+ /**
2
+ * Enum for provider error reasons.
3
+ */
4
+ export type ProviderErrorReason = string;
5
+ export namespace ProviderErrorReason {
6
+ let NETWORK_ERROR: string;
7
+ let UNAUTHORIZED: string;
8
+ let FORBIDDEN: string;
9
+ let REQUEST_TIMEOUT: string;
10
+ let INTERNAL_SERVER_ERROR: string;
11
+ }
12
+ /**
13
+ * Enum for transaction error reasons.
14
+ */
15
+ export type TransactionErrorReason = string;
16
+ export namespace TransactionErrorReason {
17
+ let INSUFFICIENT_BALANCE: string;
18
+ }
19
+ /**
20
+ * Enum for transfer error reasons.
21
+ */
22
+ export type TransferErrorReason = string;
23
+ export namespace TransferErrorReason {
24
+ let INSUFFICIENT_BALANCE_1: string;
25
+ export { INSUFFICIENT_BALANCE_1 as INSUFFICIENT_BALANCE };
26
+ export let INSUFFICIENT_TOKEN_BALANCE: string;
27
+ }
28
+ /**
29
+ * Super-class for errors thrown by wallet development kit's wallet and protocol modules.
30
+ */
31
+ export class WdkError extends Error {
2
32
  /**
3
- * Create a new not implemented error.
33
+ * Creates a new wallet development kit error.
34
+ *
35
+ * @param {string} message - The error's message.
36
+ * @param {ErrorOptions} [options] - The error's options.
37
+ */
38
+ constructor(message: string, options?: ErrorOptions);
39
+ }
40
+ /**
41
+ * Thrown when an abstract method is lacking implementation in the sub-class.
42
+ */
43
+ export class NotImplementedError extends WdkError {
44
+ /**
45
+ * Creates a new not implemented error.
4
46
  *
5
47
  * @param {string} methodName - The method's name.
6
48
  */
7
49
  constructor(methodName: string);
8
50
  }
51
+ /**
52
+ * Thrown when an assertion fails.
53
+ */
54
+ export class AssertionError extends WdkError {
55
+ /**
56
+ * Creates a new assertion error.
57
+ *
58
+ * @param {string} message - The error's message.
59
+ */
60
+ constructor(message: string);
61
+ }
62
+ /**
63
+ * Thrown when an operation is not supported in the implementation of an interface or abstract class.
64
+ */
65
+ export class UnsupportedOperationError extends WdkError {
66
+ /**
67
+ * Creates a new unsupported operation error.
68
+ *
69
+ * @param {string} method - The method's name.
70
+ */
71
+ constructor(method: string);
72
+ }
73
+ /**
74
+ * Thrown when a method's argument holds an invalid value.
75
+ */
76
+ export class ValueError extends WdkError {
77
+ /**
78
+ * Creates a new value error.
79
+ *
80
+ * @param {string} message - The error's message.
81
+ * @param {ErrorOptions} [options] - The error's options.
82
+ */
83
+ constructor(message: string, options?: ErrorOptions);
84
+ }
85
+ /**
86
+ * Thrown when no element is found for the given identifier.
87
+ */
88
+ export class NoSuchElementError extends WdkError {
89
+ /**
90
+ * Creates a new no such element error.
91
+ *
92
+ * @param {string} message - The error's message.
93
+ * @param {ErrorOptions} [options] - The error's options.
94
+ */
95
+ constructor(message: string, options?: ErrorOptions);
96
+ }
97
+ /**
98
+ * Thrown when an operation rejects to use the given signer.
99
+ */
100
+ export class InvalidSignerError extends WdkError {
101
+ /**
102
+ * Creates a new invalid signer error.
103
+ *
104
+ * @param {string} message - The error's message.
105
+ * @param {ErrorOptions} [options] - The error's options.
106
+ */
107
+ constructor(message: string, options?: ErrorOptions);
108
+ }
109
+ /**
110
+ * Thrown when an address doesn't match an existing token.
111
+ */
112
+ export class InvalidTokenError extends WdkError {
113
+ /**
114
+ * Creates a new invalid token error.
115
+ *
116
+ * @param {string} message - The error's message.
117
+ * @param {ErrorOptions} options - The error's options.
118
+ */
119
+ constructor(message: string, options: ErrorOptions);
120
+ }
121
+ /**
122
+ * Thrown when an operation requires a provider.
123
+ */
124
+ export class ProviderRequiredError extends WdkError {
125
+ /**
126
+ * Creates a new provider required error.
127
+ *
128
+ * @param {string} message - The error's message.
129
+ */
130
+ constructor(message: string);
131
+ }
132
+ /**
133
+ * Thrown when a provider fails to perform an operation.
134
+ */
135
+ export class ProviderError extends WdkError {
136
+ /**
137
+ * Creates a new provider error.
138
+ *
139
+ * @param {string} message - The error's message.
140
+ * @param {ProviderErrorOptions & ErrorOptions} options - The error's options.
141
+ */
142
+ constructor(message: string, options: ProviderErrorOptions & ErrorOptions);
143
+ /**
144
+ * The error's reason.
145
+ *
146
+ * @type {string}
147
+ */
148
+ reason: string;
149
+ }
150
+ /**
151
+ * Thrown when a transaction fails with an error.
152
+ */
153
+ export class TransactionError extends WdkError {
154
+ /**
155
+ * Creates a new transaction error.
156
+ *
157
+ * @param {string} message - The error's message.
158
+ * @param {TransactionErrorOptions & ErrorOptions} options - The error's options.
159
+ */
160
+ constructor(message: string, options: TransactionErrorOptions & ErrorOptions);
161
+ /**
162
+ * The error's reason.
163
+ *
164
+ * @type {string}
165
+ */
166
+ reason: string;
167
+ }
168
+ /**
169
+ * Thrown when a transfer fails with an error.
170
+ */
171
+ export class TransferError extends WdkError {
172
+ /**
173
+ * Creates a new transaction error.
174
+ *
175
+ * @param {string} message - The error's message.
176
+ * @param {TransferErrorOptions & ErrorOptions} options - The error's options.
177
+ */
178
+ constructor(message: string, options: TransferErrorOptions & ErrorOptions);
179
+ /**
180
+ * The error's reason.
181
+ *
182
+ * @type {string}
183
+ */
184
+ reason: string;
185
+ }
186
+ /**
187
+ * Thrown when an operation exceeds its maximum fee threshold.
188
+ */
189
+ export class MaximumFeeExceededError extends WdkError {
190
+ /**
191
+ * Creates a new maximum fee exceeded error.
192
+ *
193
+ * @param {string} message - The error's message.
194
+ * @param {ErrorOptions} options - The error's options.
195
+ */
196
+ constructor(message: string, options: ErrorOptions);
197
+ }
198
+ /**
199
+ * Thrown when an operation times out.
200
+ */
201
+ export class TimeoutError extends WdkError {
202
+ /**
203
+ * Create a new timeout error.
204
+ *
205
+ * @param {string} message - The error's message.
206
+ */
207
+ constructor(message: string);
208
+ }
209
+ export type ProviderErrorOptions = {
210
+ /**
211
+ * - The error's reason.
212
+ */
213
+ reason: ProviderErrorReason;
214
+ };
215
+ export type TransactionErrorOptions = {
216
+ /**
217
+ * - The error's reason.
218
+ */
219
+ reason: TransactionErrorReason;
220
+ };
221
+ export type TransferErrorOptions = {
222
+ /**
223
+ * - The error's reason.
224
+ */
225
+ reason: TransferErrorReason;
226
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Thrown when the account is not an owner of the multisig wallet.
3
+ */
4
+ export class AccountNotOwnerError extends WdkError {
5
+ /**
6
+ * Creates a new account not owner error.
7
+ *
8
+ * @param {string} message - The error's message.
9
+ */
10
+ constructor(message: string);
11
+ }
12
+ /**
13
+ * Thrown when the account attempts to execute a proposal but its threshold has not been met yet.
14
+ */
15
+ export class ThresholdNotMetError extends WdkError {
16
+ /**
17
+ * Creates a new threshold not met error.
18
+ *
19
+ * @param {string} message - The error's message.
20
+ */
21
+ constructor(message: string);
22
+ }
23
+ export type TransactionErrorOptions = import("../errors.js").TransactionErrorOptions;
24
+ import { MaximumFeeExceededError } from '../errors.js';
25
+ import { NoSuchElementError } from '../errors.js';
26
+ import { NotImplementedError } from '../errors.js';
27
+ import { ProviderError } from '../errors.js';
28
+ import { ProviderRequiredError } from '../errors.js';
29
+ import { TransactionError } from '../errors.js';
30
+ import { TransactionErrorReason } from '../errors.js';
31
+ import { ValueError } from '../errors.js';
32
+ import { WdkError } from '../errors.js';
33
+ export { MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ValueError, WdkError };
@@ -0,0 +1,15 @@
1
+ export { IWalletAccountReadOnlyMultisig } from "./wallet-account-read-only-multisig.js";
2
+ export { IWalletAccountMultisig } from "./wallet-account-multisig.js";
3
+ export { IMultisigOwnerManagement } from "./multisig-owner-management.js";
4
+ export { IMultisigMessageSigningReadOnly } from "./multisig-message-signing-read-only.js";
5
+ export { IMultisigMessageSigning } from "./multisig-message-signing.js";
6
+ export type KeyPair = import("../wallet-account.js").KeyPair;
7
+ export type MultisigInfo = import("./wallet-account-read-only-multisig.js").MultisigInfo;
8
+ export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
9
+ export type MultisigTransactionOptions = import("./wallet-account-multisig.js").MultisigTransactionOptions;
10
+ export type MultisigInteractionResult = import("./wallet-account-multisig.js").MultisigInteractionResult;
11
+ export type MultisigMessageProposal = import("./multisig-message-signing-read-only.js").MultisigMessageProposal;
12
+ export type MultisigSignature = import("./multisig-message-signing.js").MultisigSignature;
13
+ export type MultisigOptions = import("./multisig-owner-management.js").MultisigOptions;
14
+ export type TransactionErrorOptions = import("./errors.js").TransactionErrorOptions;
15
+ export { AccountNotOwnerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ThresholdNotMetError, ValueError, WdkError } from "./errors.js";
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Adds the read-only message-signing queries to a multisig wallet.
3
+ *
4
+ * @interface
5
+ */
6
+ export interface IMultisigMessageSigningReadOnly {
7
+ /**
8
+ * Returns a list of message proposals by their hashes.
9
+ *
10
+ * @param {string[]} messageIds - The list of message's hashes.
11
+ * @returns {Promise<Record<string, MultisigMessageProposal | null>>} For each message hash, the message details or
12
+ * null if the message has not been found.
13
+ * @throws {ValueError} If the list of message's identifiers contains an invalid id.
14
+ * @throws {ProviderRequiredError} If the method requires a provider.
15
+ * @throws {ProviderError} If the provider fails to fetch the messages.
16
+ */
17
+ getMessageProposals(messageIds: string[]): Promise<Record<string, MultisigMessageProposal | null>>;
18
+ /**
19
+ * Returns a message proposal by its identifier.
20
+ *
21
+ * @param {string} messageId - The message's hash.
22
+ * @returns {Promise<MultisigMessageProposal | null>} The message details, or null if it has not been found.
23
+ * @throws {ValueError} If the message's identifier is not a valid id.
24
+ * @throws {ProviderRequiredError} If the method requires a provider.
25
+ * @throws {ProviderError} If the provider fails to fetch the message.
26
+ */
27
+ getMessageProposal(messageId: string): Promise<MultisigMessageProposal | null>;
28
+ }
29
+ export type ProviderError = import("./errors.js").ProviderError;
30
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
31
+ export type ValueError = import("./errors.js").ValueError;
32
+ export type MultisigMessageProposal = {
33
+ /**
34
+ * - The message's hash.
35
+ */
36
+ messageId: string;
37
+ /**
38
+ * - The original message.
39
+ */
40
+ message: string;
41
+ /**
42
+ * - The current number of confirmations.
43
+ */
44
+ confirmations: number;
45
+ /**
46
+ * - The minimum amount of confirmations to sign the message.
47
+ */
48
+ threshold: number;
49
+ /**
50
+ * - The final combined signature when the threshold is met.
51
+ */
52
+ combinedSignature: string | null;
53
+ };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Adds message-signing features to a multisig wallet.
3
+ *
4
+ * @interface
5
+ */
6
+ export interface IMultisigMessageSigning extends IMultisigMessageSigningReadOnly {
7
+ /**
8
+ * Proposes signing a message.
9
+ *
10
+ * @param {string} message - The message to sign.
11
+ * @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
12
+ * @throws {ProviderRequiredError} If the method requires a provider.
13
+ * @throws {ProviderError} If the provider fails to propose the message.
14
+ * @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
15
+ */
16
+ proposeMessage(message: string): Promise<MultisigMessageProposal & MultisigSignature>;
17
+ /**
18
+ * Approves an existing message proposal.
19
+ *
20
+ * @param {string} messageId - The message's hash.
21
+ * @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
22
+ * @throws {ValueError} If the message's identifier is not a valid id.
23
+ * @throws {NoSuchElementError} If no message exists for the given id.
24
+ * @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
25
+ */
26
+ approveMessageProposal(messageId: string): Promise<MultisigMessageProposal & MultisigSignature>;
27
+ }
28
+ export type MultisigMessageProposal = import("./multisig-message-signing-read-only.js").MultisigMessageProposal;
29
+ export type AccountNotOwnerError = import("./errors.js").AccountNotOwnerError;
30
+ export type NoSuchElementError = import("./errors.js").NoSuchElementError;
31
+ export type ProviderError = import("./errors.js").ProviderError;
32
+ export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
33
+ export type ValueError = import("./errors.js").ValueError;
34
+ export type MultisigSignature = {
35
+ /**
36
+ * - The caller's signature.
37
+ */
38
+ signature: string;
39
+ };
40
+ import { IMultisigMessageSigningReadOnly } from './multisig-message-signing-read-only.js';