@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.
- package/AGENTS.md +49 -0
- package/bare.js +3 -3
- package/index.js +12 -2
- package/package.json +16 -3
- package/src/errors.js +318 -3
- package/src/multisig/errors.js +54 -0
- package/src/multisig/index.js +42 -0
- package/src/multisig/multisig-message-signing-read-only.js +63 -0
- package/src/multisig/multisig-message-signing.js +64 -0
- package/src/multisig/multisig-owner-management.js +94 -0
- package/src/multisig/wallet-account-multisig.js +144 -0
- package/src/multisig/wallet-account-read-only-multisig.js +98 -0
- package/src/protocols/bridge-protocol.js +35 -1
- package/src/protocols/errors.js +510 -0
- package/src/protocols/fiat-protocol.js +401 -0
- package/src/protocols/index.js +76 -0
- package/src/protocols/lending-protocol.js +114 -2
- package/src/protocols/sda-protocol.js +643 -0
- package/src/protocols/swap-protocol.js +36 -1
- package/src/protocols/swidge-protocol.js +516 -0
- package/src/signer.js +54 -0
- package/src/wallet-account-read-only-simple.js +162 -0
- package/src/wallet-account-read-only.js +186 -40
- package/src/wallet-account.js +49 -2
- package/src/wallet-manager.js +153 -24
- package/types/index.d.ts +12 -4
- package/types/src/errors.d.ts +220 -2
- package/types/src/multisig/errors.d.ts +33 -0
- package/types/src/multisig/index.d.ts +15 -0
- package/types/src/multisig/multisig-message-signing-read-only.d.ts +53 -0
- package/types/src/multisig/multisig-message-signing.d.ts +40 -0
- package/types/src/multisig/multisig-owner-management.d.ts +65 -0
- package/types/src/multisig/wallet-account-multisig.d.ts +101 -0
- package/types/src/multisig/wallet-account-read-only-multisig.d.ts +83 -0
- package/types/src/protocols/bridge-protocol.d.ts +39 -3
- package/types/src/protocols/errors.d.ts +366 -0
- package/types/src/protocols/fiat-protocol.d.ts +409 -0
- package/types/src/protocols/index.d.ts +64 -0
- package/types/src/protocols/lending-protocol.d.ts +118 -4
- package/types/src/protocols/sda-protocol.d.ts +737 -0
- package/types/src/protocols/swap-protocol.d.ts +44 -4
- package/types/src/protocols/swidge-protocol.d.ts +483 -0
- package/types/src/signer.d.ts +28 -0
- package/types/src/wallet-account-read-only-simple.d.ts +144 -0
- package/types/src/wallet-account-read-only.d.ts +104 -27
- package/types/src/wallet-account.d.ts +44 -4
- package/types/src/wallet-manager.d.ts +102 -15
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/bare.js
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
import 'bare-
|
|
16
|
+
import 'bare-node-runtime/global'
|
|
17
17
|
|
|
18
|
-
export * from './index.js' with { imports: 'bare-
|
|
18
|
+
export * from './index.js' with { imports: 'bare-node-runtime/imports' }
|
|
19
19
|
|
|
20
|
-
export { default } from './index.js' with { imports: 'bare-
|
|
20
|
+
export { default } from './index.js' with { imports: 'bare-node-runtime/imports' }
|
package/index.js
CHANGED
|
@@ -20,13 +20,23 @@
|
|
|
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 {
|
|
40
|
+
export { ISigner } from './src/signer.js'
|
|
41
|
+
|
|
42
|
+
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,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tetherto/wdk-wallet",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.20",
|
|
4
4
|
"description": "A simple package to manage BIP-32 wallets.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wdk",
|
|
7
|
+
"wallet",
|
|
8
|
+
"bip-32"
|
|
9
|
+
],
|
|
6
10
|
"author": "Tether",
|
|
7
11
|
"license": "Apache-2.0",
|
|
8
12
|
"repository": {
|
|
@@ -20,7 +24,7 @@
|
|
|
20
24
|
"test:coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage"
|
|
21
25
|
},
|
|
22
26
|
"dependencies": {
|
|
23
|
-
"bare-
|
|
27
|
+
"bare-node-runtime": "^1.4.0",
|
|
24
28
|
"bip39": "3.1.0"
|
|
25
29
|
},
|
|
26
30
|
"devDependencies": {
|
|
@@ -39,6 +43,10 @@
|
|
|
39
43
|
"types": "./types/src/protocols/index.d.ts",
|
|
40
44
|
"default": "./src/protocols/index.js"
|
|
41
45
|
},
|
|
46
|
+
"./multisig": {
|
|
47
|
+
"types": "./types/src/multisig/index.d.ts",
|
|
48
|
+
"default": "./src/multisig/index.js"
|
|
49
|
+
},
|
|
42
50
|
"./package": {
|
|
43
51
|
"default": "./package.json"
|
|
44
52
|
}
|
|
@@ -47,6 +55,11 @@
|
|
|
47
55
|
"access": "public",
|
|
48
56
|
"registry": "https://registry.npmjs.org/"
|
|
49
57
|
},
|
|
58
|
+
"overrides": {
|
|
59
|
+
"brace-expansion": ">=1.1.13",
|
|
60
|
+
"flatted": ">=3.4.2",
|
|
61
|
+
"picomatch": ">=2.3.2"
|
|
62
|
+
},
|
|
50
63
|
"standard": {
|
|
51
64
|
"ignore": [
|
|
52
65
|
"bare.js",
|
package/src/errors.js
CHANGED
|
@@ -13,15 +13,330 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
|
|
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
|
-
*
|
|
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}'
|
|
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
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { IMultisigMessageSigningReadOnly } from './multisig-message-signing-read-only.js'
|
|
17
|
+
|
|
18
|
+
import { NotImplementedError } from './errors.js'
|
|
19
|
+
|
|
20
|
+
/** @typedef {import('./multisig-message-signing-read-only.js').MultisigMessageProposal} MultisigMessageProposal */
|
|
21
|
+
|
|
22
|
+
/** @typedef {import('./errors.js').AccountNotOwnerError} AccountNotOwnerError */
|
|
23
|
+
/** @typedef {import('./errors.js').NoSuchElementError} NoSuchElementError */
|
|
24
|
+
/** @typedef {import('./errors.js').ProviderError} ProviderError */
|
|
25
|
+
/** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
|
|
26
|
+
/** @typedef {import('./errors.js').ValueError} ValueError */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} MultisigSignature
|
|
30
|
+
* @property {string} signature - The caller's signature.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Adds message-signing features to a multisig wallet.
|
|
35
|
+
*
|
|
36
|
+
* @interface
|
|
37
|
+
*/
|
|
38
|
+
export class IMultisigMessageSigning extends IMultisigMessageSigningReadOnly {
|
|
39
|
+
/**
|
|
40
|
+
* Proposes signing a message.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} message - The message to sign.
|
|
43
|
+
* @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
|
|
44
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
45
|
+
* @throws {ProviderError} If the provider fails to propose the message.
|
|
46
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
47
|
+
*/
|
|
48
|
+
async proposeMessage (message) {
|
|
49
|
+
throw new NotImplementedError('proposeMessage(message)')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Approves an existing message proposal.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} messageId - The message's hash.
|
|
56
|
+
* @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
|
|
57
|
+
* @throws {ValueError} If the message's identifier is not a valid id.
|
|
58
|
+
* @throws {NoSuchElementError} If no message exists for the given id.
|
|
59
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
60
|
+
*/
|
|
61
|
+
async approveMessageProposal (messageId) {
|
|
62
|
+
throw new NotImplementedError('approveMessageProposal(messageId)')
|
|
63
|
+
}
|
|
64
|
+
}
|