@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
package/AGENTS.md ADDED
@@ -0,0 +1,49 @@
1
+ # Agent Guide
2
+
3
+ This repository is part of the Tether WDK (Wallet Development Kit) ecosystem. It follows strict coding conventions and tooling standards to ensure consistency, reliability, and cross-platform compatibility (Node.js and Bare runtime).
4
+
5
+ ## Project Overview
6
+ - **Architecture:** Modular architecture with clear separation between Core, Wallet managers, and Protocols.
7
+ - **Runtime:** Supports both Node.js and Bare runtime.
8
+
9
+ ## Tech Stack & Tooling
10
+ - **Language:** JavaScript (ES2015+).
11
+ - **Module System:** ES Modules (`"type": "module"` in package.json).
12
+ - **Type Checking:** TypeScript is used purely for generating type declarations (`.d.ts`). The source code remains JavaScript.
13
+ - Command: `npm run build:types`
14
+ - **Linting:** `standard` (JavaScript Standard Style).
15
+ - Command: `npm run lint` / `npm run lint:fix`
16
+ - **Testing:** `jest` (configured with `experimental-vm-modules` for ESM support).
17
+ - Command: `npm test`
18
+ - **Dependencies:** `cross-env` is consistently used for environment variable management in scripts.
19
+
20
+ ## Coding Conventions
21
+ - **File Naming:** Kebab-case (e.g., `wallet-manager.js`).
22
+ - **Class Naming:** PascalCase (e.g., `WdkManager`).
23
+ - **Private Members:** Prefixed with `_` (underscore) and explicitly documented with `@private`.
24
+ - **Imports:** Explicit file extensions are mandatory (e.g., `import ... from './file.js'`).
25
+ - **Copyright:** All source files must include the standard Tether copyright header.
26
+
27
+ ## Documentation (JSDoc)
28
+ Source code must be strictly typed using JSDoc comments to support the `build:types` process.
29
+ - **Types:** Use `@typedef` to define or import types.
30
+ - **Methods:** Use `@param`, `@returns`, `@throws`.
31
+ - **Generics:** Use `@template`.
32
+
33
+ ## Development Workflow
34
+ 1. **Install:** `npm install`
35
+ 2. **Lint:** `npm run lint`
36
+ 3. **Test:** `npm test`
37
+ 4. **Build Types:** `npm run build:types`
38
+
39
+ ## Key Files
40
+ - `index.js`: Main entry point.
41
+ - `bare.js`: Entry point for Bare runtime optimization.
42
+ - `src/`: Core logic.
43
+ - `types/`: Generated type definitions (do not edit manually).
44
+
45
+ ## Repository Specifics
46
+ - **Domain:** Base Abstract Classes.
47
+ - **Role:** Defines the standard interfaces and base classes for all specific blockchain wallet implementations.
48
+ - **Key Classes:** `WalletManager`, `WalletAccount`, `WalletAccountReadOnly`, `Protocol`.
49
+ - **Usage:** Primarily a dependency for other `@tetherto/wdk-wallet-*` packages.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## What This Does
4
4
 
5
- Base classes for the wallet and protocol modules in the [Wallet Development Kit (WDK)](https://docs.wallet.tether.io).
5
+ Base classes for the wallet and protocol modules in the [WDK (Wallet Development Kit)](https://docs.wdk.tether.io/) by Tether.
6
6
 
7
7
  ## Who Should Use This
8
8
 
@@ -32,7 +32,7 @@ This module is for internal use only. If you want to build a wallet, use one of
32
32
 
33
33
  ## Learn More
34
34
 
35
- For full docs, visit [docs.wallet.tether.io](https://docs.wallet.tether.io)
35
+ For general WDK documentation, visit [docs.wdk.tether.io](https://docs.wdk.tether.io/)
36
36
 
37
37
  ## License
38
38
 
package/bare.js CHANGED
@@ -13,8 +13,8 @@
13
13
  // limitations under the License.
14
14
  'use strict'
15
15
 
16
- import 'bare-wdk-runtime'
16
+ import 'bare-node-runtime/global'
17
17
 
18
- export * from './index.js' with { imports: 'bare-wdk-runtime/package' }
18
+ export * from './index.js' with { imports: 'bare-node-runtime/imports' }
19
19
 
20
- export { default } from './index.js' with { imports: 'bare-wdk-runtime/package' }
20
+ export { default } from './index.js' with { imports: 'bare-node-runtime/imports' }
package/index.js CHANGED
@@ -20,13 +20,25 @@
20
20
  /** @typedef {import('./src/wallet-account-read-only.js').TransactionResult} TransactionResult */
21
21
  /** @typedef {import('./src/wallet-account-read-only.js').TransferOptions} TransferOptions */
22
22
  /** @typedef {import('./src/wallet-account-read-only.js').TransferResult} TransferResult */
23
+ /** @typedef {import('./src/wallet-account-read-only-simple.js').Finality} Finality */
24
+ /** @typedef {import('./src/wallet-account-read-only-simple.js').TransactionReceipt} TransactionReceipt */
25
+ /** @typedef {import('./src/wallet-account-read-only-simple.js').WaitForTransactionTarget} WaitForTransactionTarget */
26
+ /** @typedef {import('./src/wallet-account-read-only-simple.js').WaitForTransactionOptions} WaitForTransactionOptions */
23
27
 
24
28
  /** @typedef {import('./src/wallet-account.js').KeyPair} KeyPair */
25
29
 
30
+ /** @typedef {import('./src/errors.js').ProviderErrorOptions} ProviderErrorOptions */
31
+ /** @typedef {import('./src/errors.js').TransactionErrorOptions} TransactionErrorOptions */
32
+ /** @typedef {import('./src/errors.js').TransferErrorOptions} TransferErrorOptions */
33
+
26
34
  export { default } from './src/wallet-manager.js'
27
35
 
28
- export { default as WalletAccountReadOnly, IWalletAccountReadOnly } from './src/wallet-account-read-only.js'
36
+ export { default as WalletAccountReadOnly, IWalletAccountReadOnly, FINALITY } from './src/wallet-account-read-only.js'
29
37
 
30
38
  export { IWalletAccount } from './src/wallet-account.js'
31
39
 
32
- export { NotImplementedError } from './src/errors.js'
40
+ export { ISigner } from './src/signer.js'
41
+
42
+ export { IDisposable } from './src/disposable.js'
43
+
44
+ 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'
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet",
3
- "version": "1.0.0-beta.2",
4
- "description": "A simple package to manage BIP-32 wallets.",
5
- "keywords": ["wdk", "wallet", "bip-32"],
3
+ "version": "1.0.0-beta.21",
4
+ "description": "Base wallet and protocol classes for WDK (Wallet Development Kit) by Tether. For internal use only.",
5
+ "homepage": "https://docs.wdk.tether.io/",
6
+ "keywords": [
7
+ "wdk",
8
+ "wallet",
9
+ "bip-32"
10
+ ],
6
11
  "author": "Tether",
7
12
  "license": "Apache-2.0",
8
13
  "repository": {
@@ -20,7 +25,7 @@
20
25
  "test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
21
26
  },
22
27
  "dependencies": {
23
- "bare-wdk-runtime": "2.0.0",
28
+ "bare-node-runtime": "^1.4.0",
24
29
  "bip39": "3.1.0"
25
30
  },
26
31
  "devDependencies": {
@@ -39,6 +44,10 @@
39
44
  "types": "./types/src/protocols/index.d.ts",
40
45
  "default": "./src/protocols/index.js"
41
46
  },
47
+ "./multisig": {
48
+ "types": "./types/src/multisig/index.d.ts",
49
+ "default": "./src/multisig/index.js"
50
+ },
42
51
  "./package": {
43
52
  "default": "./package.json"
44
53
  }
@@ -47,6 +56,11 @@
47
56
  "access": "public",
48
57
  "registry": "https://registry.npmjs.org/"
49
58
  },
59
+ "overrides": {
60
+ "brace-expansion": ">=1.1.13",
61
+ "flatted": ">=3.4.2",
62
+ "picomatch": ">=2.3.2"
63
+ },
50
64
  "standard": {
51
65
  "ignore": [
52
66
  "bare.js",
@@ -0,0 +1,26 @@
1
+ // Copyright 2024 Tether Operations Limited
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ 'use strict'
15
+
16
+ import { NotImplementedError } from './errors.js'
17
+
18
+ /** @interface */
19
+ export class IDisposable {
20
+ /**
21
+ * Disposes the object along with all its data (cleaning up any sensitive field from memory).
22
+ */
23
+ dispose () {
24
+ throw new NotImplementedError('dispose()')
25
+ }
26
+ }
package/src/errors.js CHANGED
@@ -13,15 +13,330 @@
13
13
  // limitations under the License.
14
14
  'use strict'
15
15
 
16
- export class NotImplementedError extends Error {
16
+ /**
17
+ * @typedef {Object} ProviderErrorOptions
18
+ * @property {ProviderErrorReason} reason - The error's reason.
19
+ */
20
+
21
+ /**
22
+ * @typedef {Object} TransactionErrorOptions
23
+ * @property {TransactionErrorReason} reason - The error's reason.
24
+ */
25
+
26
+ /**
27
+ * @typedef {Object} TransferErrorOptions
28
+ * @property {TransferErrorReason} reason - The error's reason.
29
+ */
30
+
31
+ /**
32
+ * Enum for provider error reasons.
33
+ *
34
+ * @readonly
35
+ * @enum {string}
36
+ */
37
+ export const ProviderErrorReason = {
38
+ /**
39
+ * Thrown when the client fails to establish a connection with the provider.
40
+ */
41
+ NETWORK_ERROR: 'NETWORK_ERROR',
42
+ /**
43
+ * Thrown when the client fails to authenticate to the provider.
44
+ */
45
+ UNAUTHORIZED: 'UNAUTHORIZED',
46
+ /**
47
+ * Thrown when the client doesn't have enough permissions to perform an operation.
48
+ */
49
+ FORBIDDEN: 'FORBIDDEN',
50
+ /**
51
+ * Thrown when the provider times out.
52
+ */
53
+ REQUEST_TIMEOUT: 'REQUEST_TIMEOUT',
54
+ /**
55
+ * Thrown when the provider experiences an internal server error.
56
+ */
57
+ INTERNAL_SERVER_ERROR: 'INTERNAL_SERVER_ERROR'
58
+ }
59
+
60
+ /**
61
+ * Enum for transaction error reasons.
62
+ *
63
+ * @readonly
64
+ * @enum {string}
65
+ */
66
+ export const TransactionErrorReason = {
67
+ /**
68
+ * Thrown when the account doesn't have enough funds to perform the transaction.
69
+ */
70
+ INSUFFICIENT_BALANCE: 'INSUFFICIENT_BALANCE'
71
+ }
72
+
73
+ /**
74
+ * Enum for transfer error reasons.
75
+ *
76
+ * @readonly
77
+ * @enum {string}
78
+ */
79
+ export const TransferErrorReason = {
80
+ /**
81
+ * Thrown when the account doesn't have enough funds to cover the costs of the transfer.
82
+ */
83
+ INSUFFICIENT_BALANCE: 'INSUFFICIENT_BALANCE',
84
+ /**
85
+ * Thrown when the account doesn't have enough funds to perform the transfer.
86
+ */
87
+ INSUFFICIENT_TOKEN_BALANCE: 'INSUFFICIENT_TOKEN_BALANCE'
88
+ }
89
+
90
+ /**
91
+ * Super-class for errors thrown by wallet development kit's wallet and protocol modules.
92
+ */
93
+ export class WdkError extends Error {
94
+ /**
95
+ * Creates a new wallet development kit error.
96
+ *
97
+ * @param {string} message - The error's message.
98
+ * @param {ErrorOptions} [options] - The error's options.
99
+ */
100
+ constructor (message, options) {
101
+ super(message, options)
102
+
103
+ this.name = 'WdkError'
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Thrown when an abstract method is lacking implementation in the sub-class.
109
+ */
110
+ export class NotImplementedError extends WdkError {
17
111
  /**
18
- * Create a new not implemented error.
112
+ * Creates a new not implemented error.
19
113
  *
20
114
  * @param {string} methodName - The method's name.
21
115
  */
22
116
  constructor (methodName) {
23
- super(`Method '${methodName}' must be implemented.`)
117
+ super(`Method '${methodName}' is not implemented.`)
24
118
 
25
119
  this.name = 'NotImplementedError'
26
120
  }
27
121
  }
122
+
123
+ /**
124
+ * Thrown when an assertion fails.
125
+ */
126
+ export class AssertionError extends WdkError {
127
+ /**
128
+ * Creates a new assertion error.
129
+ *
130
+ * @param {string} message - The error's message.
131
+ */
132
+ constructor (message) {
133
+ super(message)
134
+
135
+ this.name = 'AssertionError'
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Thrown when an operation is not supported in the implementation of an interface or abstract class.
141
+ */
142
+ export class UnsupportedOperationError extends WdkError {
143
+ /**
144
+ * Creates a new unsupported operation error.
145
+ *
146
+ * @param {string} method - The method's name.
147
+ */
148
+ constructor (method) {
149
+ super(`Method '${method}' is not supported.`)
150
+
151
+ this.name = 'UnsupportedOperationError'
152
+ }
153
+ }
154
+
155
+ /**
156
+ * Thrown when a method's argument holds an invalid value.
157
+ */
158
+ export class ValueError extends WdkError {
159
+ /**
160
+ * Creates a new value error.
161
+ *
162
+ * @param {string} message - The error's message.
163
+ * @param {ErrorOptions} [options] - The error's options.
164
+ */
165
+ constructor (message, options) {
166
+ super(message, options)
167
+
168
+ this.name = 'ValueError'
169
+ }
170
+ }
171
+
172
+ /**
173
+ * Thrown when no element is found for the given identifier.
174
+ */
175
+ export class NoSuchElementError extends WdkError {
176
+ /**
177
+ * Creates a new no such element error.
178
+ *
179
+ * @param {string} message - The error's message.
180
+ * @param {ErrorOptions} [options] - The error's options.
181
+ */
182
+ constructor (message, options) {
183
+ super(message, options)
184
+
185
+ this.name = 'NoSuchElementError'
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Thrown when an operation rejects to use the given signer.
191
+ */
192
+ export class InvalidSignerError extends WdkError {
193
+ /**
194
+ * Creates a new invalid signer error.
195
+ *
196
+ * @param {string} message - The error's message.
197
+ * @param {ErrorOptions} [options] - The error's options.
198
+ */
199
+ constructor (message, options) {
200
+ super(message, options)
201
+
202
+ this.name = 'InvalidSignerError'
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Thrown when an address doesn't match an existing token.
208
+ */
209
+ export class InvalidTokenError extends WdkError {
210
+ /**
211
+ * Creates a new invalid token error.
212
+ *
213
+ * @param {string} message - The error's message.
214
+ * @param {ErrorOptions} options - The error's options.
215
+ */
216
+ constructor (message, options) {
217
+ super(message, options)
218
+
219
+ this.name = 'InvalidTokenError'
220
+ }
221
+ }
222
+
223
+ /**
224
+ * Thrown when an operation requires a provider.
225
+ */
226
+ export class ProviderRequiredError extends WdkError {
227
+ /**
228
+ * Creates a new provider required error.
229
+ *
230
+ * @param {string} message - The error's message.
231
+ */
232
+ constructor (message) {
233
+ super(message)
234
+
235
+ this.name = 'ProviderRequiredError'
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Thrown when a provider fails to perform an operation.
241
+ */
242
+ export class ProviderError extends WdkError {
243
+ /**
244
+ * Creates a new provider error.
245
+ *
246
+ * @param {string} message - The error's message.
247
+ * @param {ProviderErrorOptions & ErrorOptions} options - The error's options.
248
+ */
249
+ constructor (message, options) {
250
+ super(message, options)
251
+
252
+ this.name = 'ProviderError'
253
+
254
+ /**
255
+ * The error's reason.
256
+ *
257
+ * @type {string}
258
+ */
259
+ this.reason = options.reason
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Thrown when a transaction fails with an error.
265
+ */
266
+ export class TransactionError extends WdkError {
267
+ /**
268
+ * Creates a new transaction error.
269
+ *
270
+ * @param {string} message - The error's message.
271
+ * @param {TransactionErrorOptions & ErrorOptions} options - The error's options.
272
+ */
273
+ constructor (message, options) {
274
+ super(message, options)
275
+
276
+ this.name = 'TransactionError'
277
+
278
+ /**
279
+ * The error's reason.
280
+ *
281
+ * @type {string}
282
+ */
283
+ this.reason = options.reason
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Thrown when a transfer fails with an error.
289
+ */
290
+ export class TransferError extends WdkError {
291
+ /**
292
+ * Creates a new transaction error.
293
+ *
294
+ * @param {string} message - The error's message.
295
+ * @param {TransferErrorOptions & ErrorOptions} options - The error's options.
296
+ */
297
+ constructor (message, options) {
298
+ super(message, options)
299
+
300
+ this.name = 'TransferError'
301
+
302
+ /**
303
+ * The error's reason.
304
+ *
305
+ * @type {string}
306
+ */
307
+ this.reason = options.reason
308
+ }
309
+ }
310
+
311
+ /**
312
+ * Thrown when an operation exceeds its maximum fee threshold.
313
+ */
314
+ export class MaximumFeeExceededError extends WdkError {
315
+ /**
316
+ * Creates a new maximum fee exceeded error.
317
+ *
318
+ * @param {string} message - The error's message.
319
+ * @param {ErrorOptions} options - The error's options.
320
+ */
321
+ constructor (message, options) {
322
+ super(message, options)
323
+
324
+ this.name = 'MaximumFeeExceededError'
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Thrown when an operation times out.
330
+ */
331
+ export class TimeoutError extends WdkError {
332
+ /**
333
+ * Create a new timeout error.
334
+ *
335
+ * @param {string} message - The error's message.
336
+ */
337
+ constructor (message) {
338
+ super(message)
339
+
340
+ this.name = 'TimeoutError'
341
+ }
342
+ }
@@ -0,0 +1,54 @@
1
+ // Copyright 2024 Tether Operations Limited
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ 'use strict'
15
+
16
+ import { MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ValueError, WdkError } from '../errors.js'
17
+
18
+ export { MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ValueError, WdkError }
19
+
20
+ /**
21
+ * @typedef {import('../errors.js').TransactionErrorOptions} TransactionErrorOptions
22
+ */
23
+
24
+ /**
25
+ * Thrown when the account is not an owner of the multisig wallet.
26
+ */
27
+ export class AccountNotOwnerError extends WdkError {
28
+ /**
29
+ * Creates a new account not owner error.
30
+ *
31
+ * @param {string} message - The error's message.
32
+ */
33
+ constructor (message) {
34
+ super(message)
35
+
36
+ this.name = 'AccountNotOwnerError'
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Thrown when the account attempts to execute a proposal but its threshold has not been met yet.
42
+ */
43
+ export class ThresholdNotMetError extends WdkError {
44
+ /**
45
+ * Creates a new threshold not met error.
46
+ *
47
+ * @param {string} message - The error's message.
48
+ */
49
+ constructor (message) {
50
+ super(message)
51
+
52
+ this.name = 'ThresholdNotMetError'
53
+ }
54
+ }
@@ -0,0 +1,42 @@
1
+ // Copyright 2024 Tether Operations Limited
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ 'use strict'
15
+
16
+ /** @typedef {import('../wallet-account.js').KeyPair} KeyPair */
17
+
18
+ /** @typedef {import('./wallet-account-read-only-multisig.js').MultisigInfo} MultisigInfo */
19
+ /** @typedef {import('./wallet-account-read-only-multisig.js').MultisigProposal} MultisigProposal */
20
+
21
+ /** @typedef {import('./wallet-account-multisig.js').MultisigTransactionOptions} MultisigTransactionOptions */
22
+ /** @typedef {import('./wallet-account-multisig.js').MultisigInteractionResult} MultisigInteractionResult */
23
+
24
+ /** @typedef {import('./multisig-message-signing-read-only.js').MultisigMessageProposal} MultisigMessageProposal */
25
+
26
+ /** @typedef {import('./multisig-message-signing.js').MultisigSignature} MultisigSignature */
27
+
28
+ /** @typedef {import('./multisig-owner-management.js').MultisigOptions} MultisigOptions */
29
+
30
+ /** @typedef {import('./errors.js').TransactionErrorOptions} TransactionErrorOptions */
31
+
32
+ export { IWalletAccountReadOnlyMultisig } from './wallet-account-read-only-multisig.js'
33
+
34
+ export { IWalletAccountMultisig } from './wallet-account-multisig.js'
35
+
36
+ export { IMultisigOwnerManagement } from './multisig-owner-management.js'
37
+
38
+ export { IMultisigMessageSigningReadOnly } from './multisig-message-signing-read-only.js'
39
+
40
+ export { IMultisigMessageSigning } from './multisig-message-signing.js'
41
+
42
+ export { AccountNotOwnerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ThresholdNotMetError, ValueError, WdkError } from './errors.js'
@@ -0,0 +1,63 @@
1
+ // Copyright 2024 Tether Operations Limited
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ 'use strict'
15
+
16
+ import { NotImplementedError } from './errors.js'
17
+
18
+ /** @typedef {import('./errors.js').ProviderError} ProviderError */
19
+ /** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
20
+ /** @typedef {import('./errors.js').ValueError} ValueError */
21
+
22
+ /**
23
+ * @typedef {Object} MultisigMessageProposal
24
+ * @property {string} messageId - The message's hash.
25
+ * @property {string} message - The original message.
26
+ * @property {number} confirmations - The current number of confirmations.
27
+ * @property {number} threshold - The minimum amount of confirmations to sign the message.
28
+ * @property {string | null} combinedSignature - The final combined signature when the threshold is met.
29
+ */
30
+
31
+ /**
32
+ * Adds the read-only message-signing queries to a multisig wallet.
33
+ *
34
+ * @interface
35
+ */
36
+ export class IMultisigMessageSigningReadOnly {
37
+ /**
38
+ * Returns a list of message proposals by their hashes.
39
+ *
40
+ * @param {string[]} messageIds - The list of message's hashes.
41
+ * @returns {Promise<Record<string, MultisigMessageProposal | null>>} For each message hash, the message details or
42
+ * null if the message has not been found.
43
+ * @throws {ValueError} If the list of message's identifiers contains an invalid id.
44
+ * @throws {ProviderRequiredError} If the method requires a provider.
45
+ * @throws {ProviderError} If the provider fails to fetch the messages.
46
+ */
47
+ async getMessageProposals (messageIds) {
48
+ throw new NotImplementedError('getMessageProposals(messageIds)')
49
+ }
50
+
51
+ /**
52
+ * Returns a message proposal by its identifier.
53
+ *
54
+ * @param {string} messageId - The message's hash.
55
+ * @returns {Promise<MultisigMessageProposal | null>} The message details, or null if it has not been found.
56
+ * @throws {ValueError} If the message's identifier is not a valid id.
57
+ * @throws {ProviderRequiredError} If the method requires a provider.
58
+ * @throws {ProviderError} If the provider fails to fetch the message.
59
+ */
60
+ async getMessageProposal (messageId) {
61
+ throw new NotImplementedError('getMessageProposal(messageId)')
62
+ }
63
+ }