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

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 (47) hide show
  1. package/AGENTS.md +49 -0
  2. package/bare.js +3 -3
  3. package/index.js +12 -2
  4. package/package.json +16 -3
  5. package/src/errors.js +318 -3
  6. package/src/multisig/errors.js +54 -0
  7. package/src/multisig/index.js +42 -0
  8. package/src/multisig/multisig-message-signing-read-only.js +63 -0
  9. package/src/multisig/multisig-message-signing.js +64 -0
  10. package/src/multisig/multisig-owner-management.js +94 -0
  11. package/src/multisig/wallet-account-multisig.js +144 -0
  12. package/src/multisig/wallet-account-read-only-multisig.js +98 -0
  13. package/src/protocols/bridge-protocol.js +35 -1
  14. package/src/protocols/errors.js +510 -0
  15. package/src/protocols/fiat-protocol.js +401 -0
  16. package/src/protocols/index.js +76 -0
  17. package/src/protocols/lending-protocol.js +114 -2
  18. package/src/protocols/sda-protocol.js +643 -0
  19. package/src/protocols/swap-protocol.js +36 -1
  20. package/src/protocols/swidge-protocol.js +516 -0
  21. package/src/signer.js +54 -0
  22. package/src/wallet-account-read-only-simple.js +162 -0
  23. package/src/wallet-account-read-only.js +186 -40
  24. package/src/wallet-account.js +49 -2
  25. package/src/wallet-manager.js +153 -24
  26. package/types/index.d.ts +12 -4
  27. package/types/src/errors.d.ts +220 -2
  28. package/types/src/multisig/errors.d.ts +33 -0
  29. package/types/src/multisig/index.d.ts +15 -0
  30. package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
  31. package/types/src/multisig/multisig-message-signing.d.ts +40 -0
  32. package/types/src/multisig/multisig-owner-management.d.ts +65 -0
  33. package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
  34. package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
  35. package/types/src/protocols/bridge-protocol.d.ts +39 -3
  36. package/types/src/protocols/errors.d.ts +366 -0
  37. package/types/src/protocols/fiat-protocol.d.ts +409 -0
  38. package/types/src/protocols/index.d.ts +64 -0
  39. package/types/src/protocols/lending-protocol.d.ts +118 -4
  40. package/types/src/protocols/sda-protocol.d.ts +737 -0
  41. package/types/src/protocols/swap-protocol.d.ts +44 -4
  42. package/types/src/protocols/swidge-protocol.d.ts +483 -0
  43. package/types/src/signer.d.ts +28 -0
  44. package/types/src/wallet-account-read-only-simple.d.ts +144 -0
  45. package/types/src/wallet-account-read-only.d.ts +104 -27
  46. package/types/src/wallet-account.d.ts +44 -4
  47. package/types/src/wallet-manager.d.ts +102 -15
@@ -15,12 +15,19 @@
15
15
 
16
16
  import * as bip39 from 'bip39'
17
17
 
18
- import { NotImplementedError } from './errors.js'
18
+ import { 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
+
24
+ /** @typedef {import('./errors.js').InvalidSignerError} InvalidSignerError */
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
 
@@ -33,30 +40,53 @@ import { NotImplementedError } from './errors.js'
33
40
  /** @abstract */
34
41
  export default class WalletManager {
35
42
  /**
36
- * Creates a new wallet manager.
43
+ * Creates a new wallet manager from a seed.
44
+ *
45
+ * @overload
46
+ * @param {string | Uint8Array} seed - A BIP-39 mnemonic seed phrase, or a raw BIP-32 master seed (16-64 bytes).
47
+ * @param {WalletConfig} [config] - The wallet configuration.
48
+ * @throws {ValueError} If the seed is not a valid seed or BIP-39 seed phrase.
49
+ */
50
+
51
+ /**
52
+ * Creates a new wallet manager from a default signer.
37
53
  *
38
- * @param {string | Uint8Array} seed - The wallet's [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
54
+ * @overload
55
+ * @param {ISigner} signer - The default signer.
39
56
  * @param {WalletConfig} [config] - The wallet configuration.
57
+ * @throws {InvalidSignerError} If the given signer doesn't support account derivation.
40
58
  */
41
- constructor (seed, config = { }) {
42
- if (typeof seed === 'string') {
43
- if (!WalletManager.isValidSeedPhrase(seed)) {
44
- throw new Error('The seed phrase is invalid.')
59
+ constructor (seedOrSigner, config = {}) {
60
+ // TODO: Add check to assert that the default signer is derivable.
61
+
62
+ if (typeof seedOrSigner === 'string') {
63
+ if (!WalletManager.isValidSeedPhrase(seedOrSigner)) {
64
+ throw new ValueError('Invalid seed phrase.')
45
65
  }
46
66
 
47
- seed = bip39.mnemonicToSeedSync(seed)
67
+ seedOrSigner = bip39.mnemonicToSeedSync(seedOrSigner)
48
68
  }
49
69
 
70
+ const isSeed = seedOrSigner instanceof Uint8Array
71
+
50
72
  /** @private */
51
- this._seed = seed
73
+ this._seed = isSeed ? seedOrSigner : undefined
52
74
 
53
75
  /**
54
- * The wallet configuration.
76
+ * The default signer.
55
77
  *
56
78
  * @protected
57
- * @type {WalletConfig}
79
+ * @type {ISigner | undefined}
58
80
  */
59
- this._config = config
81
+ this._defaultSigner = isSeed ? undefined : seedOrSigner
82
+
83
+ /**
84
+ * A map between signer names and signers added via {@link addSigner}.
85
+ *
86
+ * @protected
87
+ * @type {Record<string, ISigner>}
88
+ */
89
+ this._signers = {}
60
90
 
61
91
  /**
62
92
  * A map between derivation paths and wallet accounts. The {@link dispose} method will automatically dispose
@@ -64,18 +94,29 @@ export default class WalletManager {
64
94
  * {@link getAccount} and {@link getAccountByPath} methods.
65
95
  *
66
96
  * @protected
67
- * @type {{ [path: string]: IWalletAccount }}
97
+ * @type {Record<string, IWalletAccount>}
68
98
  */
69
99
  this._accounts = {}
100
+
101
+ /**
102
+ * The wallet configuration.
103
+ *
104
+ * @protected
105
+ * @type {WalletConfig}
106
+ */
107
+ this._config = config
70
108
  }
71
109
 
72
110
  /**
73
111
  * Returns a random [BIP-39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) seed phrase.
74
112
  *
113
+ * @param {12 | 24} [wordCount] - The number of words in the seed phrase (default: 12).
75
114
  * @returns {string} The seed phrase.
76
115
  */
77
- static getRandomSeedPhrase () {
78
- return bip39.generateMnemonic()
116
+ static getRandomSeedPhrase (wordCount = 12) {
117
+ const strength = wordCount === 12 ? 128 : 256
118
+
119
+ return bip39.generateMnemonic(strength)
79
120
  }
80
121
 
81
122
  /**
@@ -89,23 +130,96 @@ export default class WalletManager {
89
130
  }
90
131
 
91
132
  /**
92
- * The seed phrase of the wallet.
133
+ * The seed of the wallet.
93
134
  *
94
- * @type {Uint8Array}
135
+ * @type {Uint8Array | undefined}
95
136
  */
96
137
  get seed () {
97
138
  return this._seed
98
139
  }
99
140
 
141
+ /**
142
+ * Registers a signer with the given name.
143
+ *
144
+ * @param {string} signerName - The signer name.
145
+ * @param {ISigner} signer - The signer.
146
+ * @returns {WalletManager} The wallet manager.
147
+ * @throws {ValueError} If the signer name is an empty or blank string.
148
+ */
149
+ addSigner (signerName, signer) {
150
+ if (!signerName.trim()) {
151
+ throw new ValueError('The signer name cannot be an empty or blank string.')
152
+ }
153
+
154
+ this._signers[signerName] = signer
155
+
156
+ return this
157
+ }
158
+
159
+ /**
160
+ * Returns the default signer, or the signer with the given name.
161
+ *
162
+ * @param {string} [signerName] - If set, returns the signer with the given name.
163
+ * @returns {ISigner} The signer.
164
+ * @throws {NoSuchElementError} If the default signer is not set, or no signers are found for the given name.
165
+ */
166
+ getSigner (signerName) {
167
+ if (signerName === undefined) {
168
+ if (this._defaultSigner === undefined) {
169
+ throw new NoSuchElementError('No default signer set.')
170
+ }
171
+
172
+ return this._defaultSigner
173
+ }
174
+
175
+ const signer = this._signers[signerName]
176
+
177
+ if (signer === undefined) {
178
+ throw new NoSuchElementError(`No signer found with name "${signerName}".`)
179
+ }
180
+
181
+ return signer
182
+ }
183
+
184
+ /**
185
+ * Returns a shallow copy of the map of signers registered via {@link addSigner}.
186
+ * The default signer is not included; use {@link getSigner} with no arguments
187
+ * to retrieve it.
188
+ *
189
+ * @returns {Record<string, ISigner>} A map of signer names to signers. Empty if no signers have been registered.
190
+ */
191
+ getSigners () {
192
+ return { ...this._signers }
193
+ }
194
+
100
195
  /**
101
196
  * Returns the wallet account at a specific index (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)).
102
197
  *
103
- * @abstract
198
+ * @overload
104
199
  * @param {number} [index] - The index of the account to get (default: 0).
200
+ * @param {Object} [options] - Account options.
201
+ * @param {string} [options.signerName] - The signer name.
105
202
  * @returns {Promise<IWalletAccount>} The account.
203
+ * @throws {ValueError} If the index is not valid.
204
+ * @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
205
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
106
206
  */
107
- async getAccount (index = 0) {
108
- throw new NotImplementedError('getAccount(index)')
207
+
208
+ /**
209
+ * Returns the wallet account associated with a registered signer. For
210
+ * non-derivable signers (e.g., private-key signers), returns the signer's
211
+ * single account. For derivable signers, returns the wallet account at the
212
+ * signer's root, with no further derivation.
213
+ *
214
+ * @overload
215
+ * @param {string} signerName - The signer name registered via {@link addSigner}.
216
+ * @returns {Promise<IWalletAccount>} The account.
217
+ * @throws {NoSuchElementError} If no signer exists with the given name.
218
+ */
219
+
220
+ /** @abstract */
221
+ async getAccount (indexOrSignerName = 0, options = {}) {
222
+ throw new NotImplementedError('getAccount(indexOrSignerName, options?)')
109
223
  }
110
224
 
111
225
  /**
@@ -113,10 +227,15 @@ export default class WalletManager {
113
227
  *
114
228
  * @abstract
115
229
  * @param {string} path - The derivation path (e.g. "0'/0/0").
230
+ * @param {Object} [options] - Account options.
231
+ * @param {string} [options.signerName] - The signer name. Omit to use the default signer.
116
232
  * @returns {Promise<IWalletAccount>} The account.
233
+ * @throws {ValueError} If the path is not valid.
234
+ * @throws {NoSuchElementError} If a signer name is given but no signer exists with that name.
235
+ * @throws {InvalidSignerError} If the signer doesn't support account derivation.
117
236
  */
118
- async getAccountByPath (path) {
119
- throw new NotImplementedError('getAccountByPath(path)')
237
+ async getAccountByPath (path, options = {}) {
238
+ throw new NotImplementedError('getAccountByPath(path, options?)')
120
239
  }
121
240
 
122
241
  /**
@@ -124,21 +243,31 @@ export default class WalletManager {
124
243
  *
125
244
  * @abstract
126
245
  * @returns {Promise<FeeRates>} The fee rates (in base unit).
246
+ * @throws {ProviderRequiredError} If the method requires a provider.
247
+ * @throws {ProviderError} If the provider fails to fetch fee rates.
127
248
  */
128
249
  async getFeeRates () {
129
250
  throw new NotImplementedError('getFeeRates()')
130
251
  }
131
252
 
132
253
  /**
133
- * Disposes all the wallet accounts, erasing their private keys from the memory.
254
+ * Disposes all wallet accounts and signers, clearing secret material from memory.
134
255
  */
135
256
  dispose () {
136
257
  for (const account of Object.values(this._accounts)) {
137
- if (account.keyPair.privateKey) {
258
+ if (account.keyPair?.privateKey) {
138
259
  account.dispose()
139
260
  }
140
261
  }
141
262
 
263
+ this._defaultSigner?.dispose()
264
+
265
+ for (const signer of Object.values(this._signers)) {
266
+ signer.dispose()
267
+ }
268
+
142
269
  this._accounts = {}
270
+ this._defaultSigner = undefined
271
+ this._signers = {}
143
272
  }
144
273
  }
package/types/index.d.ts CHANGED
@@ -1,11 +1,19 @@
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 type ProviderErrorOptions = import("./src/errors.js").ProviderErrorOptions;
16
+ export type TransactionErrorOptions = import("./src/errors.js").TransactionErrorOptions;
17
+ export type TransferErrorOptions = import("./src/errors.js").TransferErrorOptions;
18
+ export { default as WalletAccountReadOnly, IWalletAccountReadOnly, FINALITY } from "./src/wallet-account-read-only.js";
19
+ 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";
@@ -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';