@tetherto/wdk-wallet 1.0.0-beta.16 → 1.0.0-beta.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +11 -12
- package/package.json +1 -1
- package/src/errors.js +280 -19
- package/src/multisig/errors.js +54 -0
- package/src/multisig/index.js +15 -3
- 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 +22 -5
- package/src/multisig/wallet-account-multisig.js +28 -39
- package/src/multisig/wallet-account-read-only-multisig.js +20 -34
- package/src/protocols/bridge-protocol.js +35 -1
- package/src/protocols/errors.js +510 -0
- package/src/protocols/fiat-protocol.js +104 -4
- package/src/protocols/index.js +13 -0
- package/src/protocols/lending-protocol.js +114 -2
- package/src/protocols/sda-protocol.js +103 -16
- package/src/protocols/swap-protocol.js +35 -1
- package/src/protocols/swidge-protocol.js +166 -55
- package/src/signer.js +8 -4
- package/src/wallet-account-read-only-simple.js +86 -1
- package/src/wallet-account-read-only.js +175 -6
- package/src/wallet-account.js +25 -1
- package/src/wallet-manager.js +38 -22
- package/types/index.d.ts +9 -2
- package/types/src/errors.d.ts +198 -14
- package/types/src/multisig/errors.d.ts +33 -0
- package/types/src/multisig/index.d.ts +7 -3
- 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 +20 -4
- package/types/src/multisig/wallet-account-multisig.d.ts +29 -35
- package/types/src/multisig/wallet-account-read-only-multisig.d.ts +20 -40
- 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 +103 -9
- package/types/src/protocols/index.d.ts +11 -0
- package/types/src/protocols/lending-protocol.d.ts +118 -4
- package/types/src/protocols/sda-protocol.d.ts +120 -23
- package/types/src/protocols/swap-protocol.d.ts +40 -4
- package/types/src/protocols/swidge-protocol.d.ts +106 -38
- package/types/src/signer.d.ts +6 -4
- package/types/src/wallet-account-read-only-simple.d.ts +99 -1
- package/types/src/wallet-account-read-only.d.ts +95 -3
- package/types/src/wallet-account.d.ts +27 -3
- package/types/src/wallet-manager.d.ts +37 -35
package/index.js
CHANGED
|
@@ -20,24 +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 {
|
|
29
|
-
default as WalletAccountReadOnly,
|
|
30
|
-
IWalletAccountReadOnly
|
|
31
|
-
} from './src/wallet-account-read-only.js'
|
|
36
|
+
export { default as WalletAccountReadOnly, IWalletAccountReadOnly, FINALITY } from './src/wallet-account-read-only.js'
|
|
32
37
|
|
|
33
38
|
export { IWalletAccount } from './src/wallet-account.js'
|
|
34
39
|
|
|
35
|
-
export {
|
|
36
|
-
NotImplementedError,
|
|
37
|
-
SignerError,
|
|
38
|
-
UnsupportedOperationError,
|
|
39
|
-
ValueError,
|
|
40
|
-
NoSuchElementError
|
|
41
|
-
} from './src/errors.js'
|
|
42
|
-
|
|
43
40
|
export { ISigner } from './src/signer.js'
|
|
41
|
+
|
|
42
|
+
export { AssertionError, InvalidTokenError, InvalidSignerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderErrorReason, ProviderRequiredError, TimeoutError, TransactionError, TransactionErrorReason, TransferError, TransferErrorReason, UnsupportedOperationError, ValueError, WdkError } from './src/errors.js'
|
package/package.json
CHANGED
package/src/errors.js
CHANGED
|
@@ -13,69 +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
|
}
|
|
28
122
|
|
|
29
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Thrown when an assertion fails.
|
|
125
|
+
*/
|
|
126
|
+
export class AssertionError extends WdkError {
|
|
30
127
|
/**
|
|
31
|
-
*
|
|
128
|
+
* Creates a new assertion error.
|
|
32
129
|
*
|
|
33
130
|
* @param {string} message - The error's message.
|
|
34
131
|
*/
|
|
35
132
|
constructor (message) {
|
|
36
133
|
super(message)
|
|
37
134
|
|
|
38
|
-
this.name = '
|
|
135
|
+
this.name = 'AssertionError'
|
|
39
136
|
}
|
|
40
137
|
}
|
|
41
138
|
|
|
42
|
-
|
|
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 {
|
|
43
143
|
/**
|
|
44
|
-
*
|
|
45
|
-
* that the concrete implementation deliberately does not support.
|
|
144
|
+
* Creates a new unsupported operation error.
|
|
46
145
|
*
|
|
47
|
-
* @param {string}
|
|
146
|
+
* @param {string} method - The method's name.
|
|
48
147
|
*/
|
|
49
|
-
constructor (
|
|
50
|
-
super(`
|
|
148
|
+
constructor (method) {
|
|
149
|
+
super(`Method '${method}' is not supported.`)
|
|
51
150
|
|
|
52
151
|
this.name = 'UnsupportedOperationError'
|
|
53
152
|
}
|
|
54
153
|
}
|
|
55
154
|
|
|
56
|
-
|
|
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 {
|
|
57
227
|
/**
|
|
58
|
-
*
|
|
228
|
+
* Creates a new provider required error.
|
|
59
229
|
*
|
|
60
230
|
* @param {string} message - The error's message.
|
|
61
231
|
*/
|
|
62
232
|
constructor (message) {
|
|
63
233
|
super(message)
|
|
64
234
|
|
|
65
|
-
this.name = '
|
|
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
|
|
66
308
|
}
|
|
67
309
|
}
|
|
68
310
|
|
|
69
|
-
|
|
311
|
+
/**
|
|
312
|
+
* Thrown when an operation exceeds its maximum fee threshold.
|
|
313
|
+
*/
|
|
314
|
+
export class MaximumFeeExceededError extends WdkError {
|
|
70
315
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
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.
|
|
73
334
|
*
|
|
74
335
|
* @param {string} message - The error's message.
|
|
75
336
|
*/
|
|
76
337
|
constructor (message) {
|
|
77
338
|
super(message)
|
|
78
339
|
|
|
79
|
-
this.name = '
|
|
340
|
+
this.name = 'TimeoutError'
|
|
80
341
|
}
|
|
81
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
|
+
}
|
package/src/multisig/index.js
CHANGED
|
@@ -13,18 +13,30 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
+
/** @typedef {import('../wallet-account.js').KeyPair} KeyPair */
|
|
17
|
+
|
|
16
18
|
/** @typedef {import('./wallet-account-read-only-multisig.js').MultisigInfo} MultisigInfo */
|
|
17
19
|
/** @typedef {import('./wallet-account-read-only-multisig.js').MultisigProposal} MultisigProposal */
|
|
18
|
-
/** @typedef {import('./wallet-account-read-only-multisig.js').MultisigMessageProposal} MultisigMessageProposal */
|
|
19
|
-
/** @typedef {import('../wallet-account.js').KeyPair} KeyPair */
|
|
20
20
|
|
|
21
21
|
/** @typedef {import('./wallet-account-multisig.js').MultisigTransactionOptions} MultisigTransactionOptions */
|
|
22
22
|
/** @typedef {import('./wallet-account-multisig.js').MultisigAutoExecuteResult} MultisigAutoExecuteResult */
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
/** @typedef {import('./multisig-message-signing-read-only.js').MultisigMessageProposal} MultisigMessageProposal */
|
|
25
|
+
|
|
26
|
+
/** @typedef {import('./multisig-message-signing.js').MultisigSignature} MultisigSignature */
|
|
27
|
+
|
|
24
28
|
/** @typedef {import('./multisig-owner-management.js').MultisigOptions} MultisigOptions */
|
|
25
29
|
|
|
30
|
+
/** @typedef {import('./errors.js').TransactionErrorOptions} TransactionErrorOptions */
|
|
31
|
+
|
|
26
32
|
export { IWalletAccountReadOnlyMultisig } from './wallet-account-read-only-multisig.js'
|
|
27
33
|
|
|
28
34
|
export { IWalletAccountMultisig } from './wallet-account-multisig.js'
|
|
29
35
|
|
|
30
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
|
+
}
|
|
@@ -13,10 +13,15 @@
|
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
'use strict'
|
|
15
15
|
|
|
16
|
-
import { NotImplementedError } from '
|
|
16
|
+
import { NotImplementedError } from './errors.js'
|
|
17
17
|
|
|
18
18
|
/** @typedef {import('./wallet-account-read-only-multisig.js').MultisigProposal} MultisigProposal */
|
|
19
19
|
|
|
20
|
+
/** @typedef {import('./errors.js').AccountNotOwnerError} AccountNotOwnerError */
|
|
21
|
+
/** @typedef {import('./errors.js').ProviderError} ProviderError */
|
|
22
|
+
/** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').ValueError} ValueError */
|
|
24
|
+
|
|
20
25
|
/**
|
|
21
26
|
* @typedef {Object} MultisigOptions
|
|
22
27
|
* @property {number} threshold - The new amount of approvals required to execute a transaction.
|
|
@@ -34,7 +39,10 @@ export class IMultisigOwnerManagement {
|
|
|
34
39
|
* @param {string} owner - The owner's address.
|
|
35
40
|
* @param {MultisigOptions} [options] - The multisig options.
|
|
36
41
|
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
37
|
-
* @throws {
|
|
42
|
+
* @throws {ValueError} If the address or options are not valid.
|
|
43
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
44
|
+
* @throws {ProviderError} If the provider fails to add the owner.
|
|
45
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
38
46
|
*/
|
|
39
47
|
async addOwner (owner, options) {
|
|
40
48
|
throw new NotImplementedError('addOwner(owner, options)')
|
|
@@ -46,7 +54,10 @@ export class IMultisigOwnerManagement {
|
|
|
46
54
|
* @param {string} owner - The owner's address.
|
|
47
55
|
* @param {MultisigOptions} [options] - The multisig options.
|
|
48
56
|
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
49
|
-
* @throws {
|
|
57
|
+
* @throws {ValueError} If the address or options are not valid.
|
|
58
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
59
|
+
* @throws {ProviderError} If the provider fails to remove the owner.
|
|
60
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
50
61
|
*/
|
|
51
62
|
async removeOwner (owner, options) {
|
|
52
63
|
throw new NotImplementedError('removeOwner(owner, options)')
|
|
@@ -58,7 +69,10 @@ export class IMultisigOwnerManagement {
|
|
|
58
69
|
* @param {string} oldOwner - The old owner.
|
|
59
70
|
* @param {string} newOwner - The new owner.
|
|
60
71
|
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
61
|
-
* @throws {
|
|
72
|
+
* @throws {ValueError} If the addresses are not valid.
|
|
73
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
74
|
+
* @throws {ProviderError} If the provider fails to swap the two owners.
|
|
75
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
62
76
|
*/
|
|
63
77
|
async swapOwner (oldOwner, newOwner) {
|
|
64
78
|
throw new NotImplementedError('swapOwner(oldOwner, newOwner)')
|
|
@@ -69,7 +83,10 @@ export class IMultisigOwnerManagement {
|
|
|
69
83
|
*
|
|
70
84
|
* @param {number} newThreshold - The new threshold.
|
|
71
85
|
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
72
|
-
* @throws {
|
|
86
|
+
* @throws {ValueError} If the threshold is not valid.
|
|
87
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
88
|
+
* @throws {ProviderError} If the provider fails to change the threshold.
|
|
89
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
73
90
|
*/
|
|
74
91
|
async changeThreshold (newThreshold) {
|
|
75
92
|
throw new NotImplementedError('changeThreshold(newThreshold)')
|