@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
|
@@ -13,12 +13,24 @@
|
|
|
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.js').IWalletAccountReadOnly} IWalletAccountReadOnly */
|
|
19
19
|
|
|
20
20
|
/** @typedef {import('../wallet-account.js').IWalletAccount} IWalletAccount */
|
|
21
21
|
|
|
22
|
+
/** @typedef {import('./errors.js').AccountRequiredError} AccountRequiredError */
|
|
23
|
+
/** @typedef {import('./errors.js').BorrowError} BorrowError */
|
|
24
|
+
/** @typedef {import('./errors.js').InvalidTokenError} InvalidTokenError */
|
|
25
|
+
/** @typedef {import('./errors.js').MaximumFeeExceededError} MaximumFeeExceededError */
|
|
26
|
+
/** @typedef {import('./errors.js').ReadOnlyAccountRequiredError} ReadOnlyAccountRequiredError */
|
|
27
|
+
/** @typedef {import('./errors.js').ProviderError} ProviderError */
|
|
28
|
+
/** @typedef {import('./errors.js').ProviderRequiredError} ProviderRequiredError */
|
|
29
|
+
/** @typedef {import('./errors.js').RepayError} RepayError */
|
|
30
|
+
/** @typedef {import('./errors.js').SupplyError} SupplyError */
|
|
31
|
+
/** @typedef {import('./errors.js').ValueError} ValueError */
|
|
32
|
+
/** @typedef {import('./errors.js').WithdrawError} WithdrawError */
|
|
33
|
+
|
|
22
34
|
/**
|
|
23
35
|
* @typedef {Object} SupplyOptions
|
|
24
36
|
* @property {string} token - The address of the token to supply.
|
|
@@ -78,6 +90,13 @@ export class ILendingProtocol {
|
|
|
78
90
|
*
|
|
79
91
|
* @param {SupplyOptions} options - The supply's options.
|
|
80
92
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
93
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
94
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
95
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
96
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
97
|
+
* @throws {ProviderError} If the provider fails to perform the supply.
|
|
98
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
99
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the supply max. fee option.
|
|
81
100
|
*/
|
|
82
101
|
async supply (options) {
|
|
83
102
|
throw new NotImplementedError('supply(options)')
|
|
@@ -88,6 +107,12 @@ export class ILendingProtocol {
|
|
|
88
107
|
*
|
|
89
108
|
* @param {SupplyOptions} options - The supply's options.
|
|
90
109
|
* @returns {Promise<Omit<SupplyResult, 'hash'>>} The supply's costs.
|
|
110
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a supply.
|
|
111
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
112
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
113
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
114
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the supply.
|
|
115
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
91
116
|
*/
|
|
92
117
|
async quoteSupply (options) {
|
|
93
118
|
throw new NotImplementedError('quoteSupply(options)')
|
|
@@ -98,6 +123,13 @@ export class ILendingProtocol {
|
|
|
98
123
|
*
|
|
99
124
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
100
125
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
126
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
127
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
128
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
129
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
130
|
+
* @throws {ProviderError} If the provider fails to perform the withdraw.
|
|
131
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
132
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the withdraw max. fee option.
|
|
101
133
|
*/
|
|
102
134
|
async withdraw (options) {
|
|
103
135
|
throw new NotImplementedError('withdraw(options)')
|
|
@@ -108,6 +140,12 @@ export class ILendingProtocol {
|
|
|
108
140
|
*
|
|
109
141
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
110
142
|
* @returns {Promise<Omit<WithdrawResult, 'hash'>>} The withdraw's costs.
|
|
143
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a supply.
|
|
144
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
145
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
146
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
147
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the withdraw.
|
|
148
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
111
149
|
*/
|
|
112
150
|
async quoteWithdraw (options) {
|
|
113
151
|
throw new NotImplementedError('quoteWithdraw(options)')
|
|
@@ -118,6 +156,13 @@ export class ILendingProtocol {
|
|
|
118
156
|
*
|
|
119
157
|
* @param {BorrowOptions} options - The borrow's options.
|
|
120
158
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
159
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
160
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
161
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
162
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
163
|
+
* @throws {ProviderError} If the provider fails to perform the borrow.
|
|
164
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
165
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the borrow max. fee option.
|
|
121
166
|
*/
|
|
122
167
|
async borrow (options) {
|
|
123
168
|
throw new NotImplementedError('borrow(options)')
|
|
@@ -128,6 +173,12 @@ export class ILendingProtocol {
|
|
|
128
173
|
*
|
|
129
174
|
* @param {BorrowOptions} options - The borrow's options.
|
|
130
175
|
* @returns {Promise<Omit<BorrowResult, 'hash'>>} The borrow's costs.
|
|
176
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a borrow.
|
|
177
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
178
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
179
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
180
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the borrow.
|
|
181
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
131
182
|
*/
|
|
132
183
|
async quoteBorrow (options) {
|
|
133
184
|
throw new NotImplementedError('quoteBorrow(options)')
|
|
@@ -136,8 +187,15 @@ export class ILendingProtocol {
|
|
|
136
187
|
/**
|
|
137
188
|
* Repays a specific token amount.
|
|
138
189
|
*
|
|
139
|
-
* @param {RepayOptions} options - The
|
|
190
|
+
* @param {RepayOptions} options - The repay's options.
|
|
140
191
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
192
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
193
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
194
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
195
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
196
|
+
* @throws {ProviderError} If the provider fails to perform the repay.
|
|
197
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
198
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the repay max. fee option.
|
|
141
199
|
*/
|
|
142
200
|
async repay (options) {
|
|
143
201
|
throw new NotImplementedError('repay(options)')
|
|
@@ -148,6 +206,12 @@ export class ILendingProtocol {
|
|
|
148
206
|
*
|
|
149
207
|
* @param {RepayOptions} options - The repay's options.
|
|
150
208
|
* @returns {Promise<Omit<RepayResult, 'hash'>>} The repay's costs.
|
|
209
|
+
* @throws {ReadOnlyAccountRequiredError} If the protocol requires a read-only or full account to quote the costs of a repay.
|
|
210
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
211
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
212
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
213
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the repay.
|
|
214
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
151
215
|
*/
|
|
152
216
|
async quoteRepay (options) {
|
|
153
217
|
throw new NotImplementedError('quoteRepay(options)')
|
|
@@ -188,6 +252,13 @@ export default class LendingProtocol {
|
|
|
188
252
|
* @abstract
|
|
189
253
|
* @param {SupplyOptions} options - The supply's options.
|
|
190
254
|
* @returns {Promise<SupplyResult>} The supply's result.
|
|
255
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a supply.
|
|
256
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
257
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
258
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
259
|
+
* @throws {ProviderError} If the provider fails to perform the supply.
|
|
260
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
261
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the supply max. fee option.
|
|
191
262
|
*/
|
|
192
263
|
async supply (options) {
|
|
193
264
|
throw new NotImplementedError('supply(options)')
|
|
@@ -199,6 +270,11 @@ export default class LendingProtocol {
|
|
|
199
270
|
* @abstract
|
|
200
271
|
* @param {SupplyOptions} options - The supply's options.
|
|
201
272
|
* @returns {Promise<Omit<SupplyResult, 'hash'>>} The supply's costs.
|
|
273
|
+
* @throws {ValueError} If the supply options are not valid.
|
|
274
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
275
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
276
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the supply.
|
|
277
|
+
* @throws {SupplyError} If the supply fails with an error.
|
|
202
278
|
*/
|
|
203
279
|
async quoteSupply (options) {
|
|
204
280
|
throw new NotImplementedError('quoteSupply(options)')
|
|
@@ -210,6 +286,13 @@ export default class LendingProtocol {
|
|
|
210
286
|
* @abstract
|
|
211
287
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
212
288
|
* @returns {Promise<WithdrawResult>} The withdraw's result.
|
|
289
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a withdraw.
|
|
290
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
291
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
292
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
293
|
+
* @throws {ProviderError} If the provider fails to perform the withdraw.
|
|
294
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
295
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the withdraw max. fee option.
|
|
213
296
|
*/
|
|
214
297
|
async withdraw (options) {
|
|
215
298
|
throw new NotImplementedError('withdraw(options)')
|
|
@@ -221,6 +304,11 @@ export default class LendingProtocol {
|
|
|
221
304
|
* @abstract
|
|
222
305
|
* @param {WithdrawOptions} options - The withdraw's options.
|
|
223
306
|
* @returns {Promise<Omit<WithdrawResult, 'hash'>>} The withdraw's costs.
|
|
307
|
+
* @throws {ValueError} If the withdraw options are not valid.
|
|
308
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
309
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
310
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the withdraw.
|
|
311
|
+
* @throws {WithdrawError} If the withdraw fails with an error.
|
|
224
312
|
*/
|
|
225
313
|
async quoteWithdraw (options) {
|
|
226
314
|
throw new NotImplementedError('quoteWithdraw(options)')
|
|
@@ -232,6 +320,13 @@ export default class LendingProtocol {
|
|
|
232
320
|
* @abstract
|
|
233
321
|
* @param {BorrowOptions} options - The borrow's options.
|
|
234
322
|
* @returns {Promise<BorrowResult>} The borrow's result.
|
|
323
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a borrow.
|
|
324
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
325
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
326
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
327
|
+
* @throws {ProviderError} If the provider fails to perform the borrow.
|
|
328
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
329
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the borrow max. fee option.
|
|
235
330
|
*/
|
|
236
331
|
async borrow (options) {
|
|
237
332
|
throw new NotImplementedError('borrow(options)')
|
|
@@ -243,6 +338,11 @@ export default class LendingProtocol {
|
|
|
243
338
|
* @abstract
|
|
244
339
|
* @param {BorrowOptions} options - The borrow's options.
|
|
245
340
|
* @returns {Promise<Omit<BorrowResult, 'hash'>>} The borrow's costs.
|
|
341
|
+
* @throws {ValueError} If the borrow options are not valid.
|
|
342
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
343
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
344
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the borrow.
|
|
345
|
+
* @throws {BorrowError} If the borrow fails with an error.
|
|
246
346
|
*/
|
|
247
347
|
async quoteBorrow (options) {
|
|
248
348
|
throw new NotImplementedError('quoteBorrow(options)')
|
|
@@ -254,6 +354,13 @@ export default class LendingProtocol {
|
|
|
254
354
|
* @abstract
|
|
255
355
|
* @param {RepayOptions} options - The borrow's options.
|
|
256
356
|
* @returns {Promise<RepayResult>} The repay's result.
|
|
357
|
+
* @throws {AccountRequiredError} If the protocol requires a full account to perform a repay.
|
|
358
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
359
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
360
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
361
|
+
* @throws {ProviderError} If the provider fails to perform the repay.
|
|
362
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
363
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the repay max. fee option.
|
|
257
364
|
*/
|
|
258
365
|
async repay (options) {
|
|
259
366
|
throw new NotImplementedError('repay(options)')
|
|
@@ -265,6 +372,11 @@ export default class LendingProtocol {
|
|
|
265
372
|
* @abstract
|
|
266
373
|
* @param {RepayOptions} options - The repay's options.
|
|
267
374
|
* @returns {Promise<Omit<RepayResult, 'hash'>>} The repay's costs.
|
|
375
|
+
* @throws {ValueError} If the repay options are not valid.
|
|
376
|
+
* @throws {InvalidTokenError} If the token is not a valid ERC 20 token's address.
|
|
377
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
378
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the repay.
|
|
379
|
+
* @throws {RepayError} If the repay fails with an error.
|
|
268
380
|
*/
|
|
269
381
|
async quoteRepay (options) {
|
|
270
382
|
throw new NotImplementedError('quoteRepay(options)')
|