@tetherto/wdk-wallet 1.0.0-beta.15 → 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 +5 -1
- package/src/errors.js +280 -19
- 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 +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 +162 -0
- package/src/wallet-account-read-only.js +176 -55
- 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 +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 +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 +144 -0
- package/types/src/wallet-account-read-only.d.ts +97 -39
- package/types/src/wallet-account.d.ts +27 -3
- package/types/src/wallet-manager.d.ts +37 -35
package/types/src/errors.d.ts
CHANGED
|
@@ -1,42 +1,226 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Enum for provider error reasons.
|
|
3
|
+
*/
|
|
4
|
+
export type ProviderErrorReason = string;
|
|
5
|
+
export namespace ProviderErrorReason {
|
|
6
|
+
let NETWORK_ERROR: string;
|
|
7
|
+
let UNAUTHORIZED: string;
|
|
8
|
+
let FORBIDDEN: string;
|
|
9
|
+
let REQUEST_TIMEOUT: string;
|
|
10
|
+
let INTERNAL_SERVER_ERROR: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Enum for transaction error reasons.
|
|
14
|
+
*/
|
|
15
|
+
export type TransactionErrorReason = string;
|
|
16
|
+
export namespace TransactionErrorReason {
|
|
17
|
+
let INSUFFICIENT_BALANCE: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Enum for transfer error reasons.
|
|
21
|
+
*/
|
|
22
|
+
export type TransferErrorReason = string;
|
|
23
|
+
export namespace TransferErrorReason {
|
|
24
|
+
let INSUFFICIENT_BALANCE_1: string;
|
|
25
|
+
export { INSUFFICIENT_BALANCE_1 as INSUFFICIENT_BALANCE };
|
|
26
|
+
export let INSUFFICIENT_TOKEN_BALANCE: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Super-class for errors thrown by wallet development kit's wallet and protocol modules.
|
|
30
|
+
*/
|
|
31
|
+
export class WdkError extends Error {
|
|
32
|
+
/**
|
|
33
|
+
* Creates a new wallet development kit error.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} message - The error's message.
|
|
36
|
+
* @param {ErrorOptions} [options] - The error's options.
|
|
37
|
+
*/
|
|
38
|
+
constructor(message: string, options?: ErrorOptions);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when an abstract method is lacking implementation in the sub-class.
|
|
42
|
+
*/
|
|
43
|
+
export class NotImplementedError extends WdkError {
|
|
2
44
|
/**
|
|
3
|
-
*
|
|
45
|
+
* Creates a new not implemented error.
|
|
4
46
|
*
|
|
5
47
|
* @param {string} methodName - The method's name.
|
|
6
48
|
*/
|
|
7
49
|
constructor(methodName: string);
|
|
8
50
|
}
|
|
9
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when an assertion fails.
|
|
53
|
+
*/
|
|
54
|
+
export class AssertionError extends WdkError {
|
|
10
55
|
/**
|
|
11
|
-
*
|
|
56
|
+
* Creates a new assertion error.
|
|
12
57
|
*
|
|
13
58
|
* @param {string} message - The error's message.
|
|
14
59
|
*/
|
|
15
60
|
constructor(message: string);
|
|
16
61
|
}
|
|
17
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Thrown when an operation is not supported in the implementation of an interface or abstract class.
|
|
64
|
+
*/
|
|
65
|
+
export class UnsupportedOperationError extends WdkError {
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new unsupported operation error.
|
|
68
|
+
*
|
|
69
|
+
* @param {string} method - The method's name.
|
|
70
|
+
*/
|
|
71
|
+
constructor(method: string);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Thrown when a method's argument holds an invalid value.
|
|
75
|
+
*/
|
|
76
|
+
export class ValueError extends WdkError {
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new value error.
|
|
79
|
+
*
|
|
80
|
+
* @param {string} message - The error's message.
|
|
81
|
+
* @param {ErrorOptions} [options] - The error's options.
|
|
82
|
+
*/
|
|
83
|
+
constructor(message: string, options?: ErrorOptions);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Thrown when no element is found for the given identifier.
|
|
87
|
+
*/
|
|
88
|
+
export class NoSuchElementError extends WdkError {
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new no such element error.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} message - The error's message.
|
|
93
|
+
* @param {ErrorOptions} [options] - The error's options.
|
|
94
|
+
*/
|
|
95
|
+
constructor(message: string, options?: ErrorOptions);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Thrown when an operation rejects to use the given signer.
|
|
99
|
+
*/
|
|
100
|
+
export class InvalidSignerError extends WdkError {
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new invalid signer error.
|
|
103
|
+
*
|
|
104
|
+
* @param {string} message - The error's message.
|
|
105
|
+
* @param {ErrorOptions} [options] - The error's options.
|
|
106
|
+
*/
|
|
107
|
+
constructor(message: string, options?: ErrorOptions);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Thrown when an address doesn't match an existing token.
|
|
111
|
+
*/
|
|
112
|
+
export class InvalidTokenError extends WdkError {
|
|
18
113
|
/**
|
|
19
|
-
*
|
|
20
|
-
* that the concrete implementation deliberately does not support.
|
|
114
|
+
* Creates a new invalid token error.
|
|
21
115
|
*
|
|
22
|
-
* @param {string}
|
|
116
|
+
* @param {string} message - The error's message.
|
|
117
|
+
* @param {ErrorOptions} options - The error's options.
|
|
23
118
|
*/
|
|
24
|
-
constructor(
|
|
119
|
+
constructor(message: string, options: ErrorOptions);
|
|
25
120
|
}
|
|
26
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Thrown when an operation requires a provider.
|
|
123
|
+
*/
|
|
124
|
+
export class ProviderRequiredError extends WdkError {
|
|
27
125
|
/**
|
|
28
|
-
*
|
|
126
|
+
* Creates a new provider required error.
|
|
29
127
|
*
|
|
30
128
|
* @param {string} message - The error's message.
|
|
31
129
|
*/
|
|
32
130
|
constructor(message: string);
|
|
33
131
|
}
|
|
34
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Thrown when a provider fails to perform an operation.
|
|
134
|
+
*/
|
|
135
|
+
export class ProviderError extends WdkError {
|
|
35
136
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
137
|
+
* Creates a new provider error.
|
|
138
|
+
*
|
|
139
|
+
* @param {string} message - The error's message.
|
|
140
|
+
* @param {ProviderErrorOptions & ErrorOptions} options - The error's options.
|
|
141
|
+
*/
|
|
142
|
+
constructor(message: string, options: ProviderErrorOptions & ErrorOptions);
|
|
143
|
+
/**
|
|
144
|
+
* The error's reason.
|
|
145
|
+
*
|
|
146
|
+
* @type {string}
|
|
147
|
+
*/
|
|
148
|
+
reason: string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Thrown when a transaction fails with an error.
|
|
152
|
+
*/
|
|
153
|
+
export class TransactionError extends WdkError {
|
|
154
|
+
/**
|
|
155
|
+
* Creates a new transaction error.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} message - The error's message.
|
|
158
|
+
* @param {TransactionErrorOptions & ErrorOptions} options - The error's options.
|
|
159
|
+
*/
|
|
160
|
+
constructor(message: string, options: TransactionErrorOptions & ErrorOptions);
|
|
161
|
+
/**
|
|
162
|
+
* The error's reason.
|
|
163
|
+
*
|
|
164
|
+
* @type {string}
|
|
165
|
+
*/
|
|
166
|
+
reason: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Thrown when a transfer fails with an error.
|
|
170
|
+
*/
|
|
171
|
+
export class TransferError extends WdkError {
|
|
172
|
+
/**
|
|
173
|
+
* Creates a new transaction error.
|
|
174
|
+
*
|
|
175
|
+
* @param {string} message - The error's message.
|
|
176
|
+
* @param {TransferErrorOptions & ErrorOptions} options - The error's options.
|
|
177
|
+
*/
|
|
178
|
+
constructor(message: string, options: TransferErrorOptions & ErrorOptions);
|
|
179
|
+
/**
|
|
180
|
+
* The error's reason.
|
|
181
|
+
*
|
|
182
|
+
* @type {string}
|
|
183
|
+
*/
|
|
184
|
+
reason: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Thrown when an operation exceeds its maximum fee threshold.
|
|
188
|
+
*/
|
|
189
|
+
export class MaximumFeeExceededError extends WdkError {
|
|
190
|
+
/**
|
|
191
|
+
* Creates a new maximum fee exceeded error.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} message - The error's message.
|
|
194
|
+
* @param {ErrorOptions} options - The error's options.
|
|
195
|
+
*/
|
|
196
|
+
constructor(message: string, options: ErrorOptions);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Thrown when an operation times out.
|
|
200
|
+
*/
|
|
201
|
+
export class TimeoutError extends WdkError {
|
|
202
|
+
/**
|
|
203
|
+
* Create a new timeout error.
|
|
38
204
|
*
|
|
39
205
|
* @param {string} message - The error's message.
|
|
40
206
|
*/
|
|
41
207
|
constructor(message: string);
|
|
42
208
|
}
|
|
209
|
+
export type ProviderErrorOptions = {
|
|
210
|
+
/**
|
|
211
|
+
* - The error's reason.
|
|
212
|
+
*/
|
|
213
|
+
reason: ProviderErrorReason;
|
|
214
|
+
};
|
|
215
|
+
export type TransactionErrorOptions = {
|
|
216
|
+
/**
|
|
217
|
+
* - The error's reason.
|
|
218
|
+
*/
|
|
219
|
+
reason: TransactionErrorReason;
|
|
220
|
+
};
|
|
221
|
+
export type TransferErrorOptions = {
|
|
222
|
+
/**
|
|
223
|
+
* - The error's reason.
|
|
224
|
+
*/
|
|
225
|
+
reason: TransferErrorReason;
|
|
226
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown when the account is not an owner of the multisig wallet.
|
|
3
|
+
*/
|
|
4
|
+
export class AccountNotOwnerError extends WdkError {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new account not owner error.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} message - The error's message.
|
|
9
|
+
*/
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when the account attempts to execute a proposal but its threshold has not been met yet.
|
|
14
|
+
*/
|
|
15
|
+
export class ThresholdNotMetError extends WdkError {
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new threshold not met error.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} message - The error's message.
|
|
20
|
+
*/
|
|
21
|
+
constructor(message: string);
|
|
22
|
+
}
|
|
23
|
+
export type TransactionErrorOptions = import("../errors.js").TransactionErrorOptions;
|
|
24
|
+
import { MaximumFeeExceededError } from '../errors.js';
|
|
25
|
+
import { NoSuchElementError } from '../errors.js';
|
|
26
|
+
import { NotImplementedError } from '../errors.js';
|
|
27
|
+
import { ProviderError } from '../errors.js';
|
|
28
|
+
import { ProviderRequiredError } from '../errors.js';
|
|
29
|
+
import { TransactionError } from '../errors.js';
|
|
30
|
+
import { TransactionErrorReason } from '../errors.js';
|
|
31
|
+
import { ValueError } from '../errors.js';
|
|
32
|
+
import { WdkError } from '../errors.js';
|
|
33
|
+
export { MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ValueError, WdkError };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { IWalletAccountReadOnlyMultisig } from "./wallet-account-read-only-multisig.js";
|
|
2
|
+
export { IWalletAccountMultisig } from "./wallet-account-multisig.js";
|
|
3
|
+
export { IMultisigOwnerManagement } from "./multisig-owner-management.js";
|
|
4
|
+
export { IMultisigMessageSigningReadOnly } from "./multisig-message-signing-read-only.js";
|
|
5
|
+
export { IMultisigMessageSigning } from "./multisig-message-signing.js";
|
|
6
|
+
export type KeyPair = import("../wallet-account.js").KeyPair;
|
|
7
|
+
export type MultisigInfo = import("./wallet-account-read-only-multisig.js").MultisigInfo;
|
|
8
|
+
export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
|
|
9
|
+
export type MultisigTransactionOptions = import("./wallet-account-multisig.js").MultisigTransactionOptions;
|
|
10
|
+
export type MultisigAutoExecuteResult = import("./wallet-account-multisig.js").MultisigAutoExecuteResult;
|
|
11
|
+
export type MultisigMessageProposal = import("./multisig-message-signing-read-only.js").MultisigMessageProposal;
|
|
12
|
+
export type MultisigSignature = import("./multisig-message-signing.js").MultisigSignature;
|
|
13
|
+
export type MultisigOptions = import("./multisig-owner-management.js").MultisigOptions;
|
|
14
|
+
export type TransactionErrorOptions = import("./errors.js").TransactionErrorOptions;
|
|
15
|
+
export { AccountNotOwnerError, MaximumFeeExceededError, NoSuchElementError, NotImplementedError, ProviderError, ProviderRequiredError, TransactionError, TransactionErrorReason, ThresholdNotMetError, ValueError, WdkError } from "./errors.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds the read-only message-signing queries to a multisig wallet.
|
|
3
|
+
*
|
|
4
|
+
* @interface
|
|
5
|
+
*/
|
|
6
|
+
export interface IMultisigMessageSigningReadOnly {
|
|
7
|
+
/**
|
|
8
|
+
* Returns a list of message proposals by their hashes.
|
|
9
|
+
*
|
|
10
|
+
* @param {string[]} messageIds - The list of message's hashes.
|
|
11
|
+
* @returns {Promise<Record<string, MultisigMessageProposal | null>>} For each message hash, the message details or
|
|
12
|
+
* null if the message has not been found.
|
|
13
|
+
* @throws {ValueError} If the list of message's identifiers contains an invalid id.
|
|
14
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
15
|
+
* @throws {ProviderError} If the provider fails to fetch the messages.
|
|
16
|
+
*/
|
|
17
|
+
getMessageProposals(messageIds: string[]): Promise<Record<string, MultisigMessageProposal | null>>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a message proposal by its identifier.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} messageId - The message's hash.
|
|
22
|
+
* @returns {Promise<MultisigMessageProposal | null>} The message details, or null if it has not been found.
|
|
23
|
+
* @throws {ValueError} If the message's identifier is not a valid id.
|
|
24
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
25
|
+
* @throws {ProviderError} If the provider fails to fetch the message.
|
|
26
|
+
*/
|
|
27
|
+
getMessageProposal(messageId: string): Promise<MultisigMessageProposal | null>;
|
|
28
|
+
}
|
|
29
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
30
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
31
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
32
|
+
export type MultisigMessageProposal = {
|
|
33
|
+
/**
|
|
34
|
+
* - The message's hash.
|
|
35
|
+
*/
|
|
36
|
+
messageId: string;
|
|
37
|
+
/**
|
|
38
|
+
* - The original message.
|
|
39
|
+
*/
|
|
40
|
+
message: string;
|
|
41
|
+
/**
|
|
42
|
+
* - The current number of confirmations.
|
|
43
|
+
*/
|
|
44
|
+
confirmations: number;
|
|
45
|
+
/**
|
|
46
|
+
* - The minimum amount of confirmations to sign the message.
|
|
47
|
+
*/
|
|
48
|
+
threshold: number;
|
|
49
|
+
/**
|
|
50
|
+
* - The final combined signature when the threshold is met.
|
|
51
|
+
*/
|
|
52
|
+
combinedSignature: string | null;
|
|
53
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds message-signing features to a multisig wallet.
|
|
3
|
+
*
|
|
4
|
+
* @interface
|
|
5
|
+
*/
|
|
6
|
+
export interface IMultisigMessageSigning extends IMultisigMessageSigningReadOnly {
|
|
7
|
+
/**
|
|
8
|
+
* Proposes signing a message.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} message - The message to sign.
|
|
11
|
+
* @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
|
|
12
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
13
|
+
* @throws {ProviderError} If the provider fails to propose the message.
|
|
14
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
15
|
+
*/
|
|
16
|
+
proposeMessage(message: string): Promise<MultisigMessageProposal & MultisigSignature>;
|
|
17
|
+
/**
|
|
18
|
+
* Approves an existing message proposal.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} messageId - The message's hash.
|
|
21
|
+
* @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
|
|
22
|
+
* @throws {ValueError} If the message's identifier is not a valid id.
|
|
23
|
+
* @throws {NoSuchElementError} If no message exists for the given id.
|
|
24
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
25
|
+
*/
|
|
26
|
+
approveMessageProposal(messageId: string): Promise<MultisigMessageProposal & MultisigSignature>;
|
|
27
|
+
}
|
|
28
|
+
export type MultisigMessageProposal = import("./multisig-message-signing-read-only.js").MultisigMessageProposal;
|
|
29
|
+
export type AccountNotOwnerError = import("./errors.js").AccountNotOwnerError;
|
|
30
|
+
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
|
31
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
32
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
33
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
34
|
+
export type MultisigSignature = {
|
|
35
|
+
/**
|
|
36
|
+
* - The caller's signature.
|
|
37
|
+
*/
|
|
38
|
+
signature: string;
|
|
39
|
+
};
|
|
40
|
+
import { IMultisigMessageSigningReadOnly } from './multisig-message-signing-read-only.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adds owner management features to a multisig wallet.
|
|
3
|
+
*
|
|
4
|
+
* @interface
|
|
5
|
+
*/
|
|
6
|
+
export interface IMultisigOwnerManagement {
|
|
7
|
+
/**
|
|
8
|
+
* Proposes adding a new owner to the multisig wallet account.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} owner - The owner's address.
|
|
11
|
+
* @param {MultisigOptions} [options] - The multisig options.
|
|
12
|
+
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
13
|
+
* @throws {ValueError} If the address or options are not valid.
|
|
14
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
15
|
+
* @throws {ProviderError} If the provider fails to add the owner.
|
|
16
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
17
|
+
*/
|
|
18
|
+
addOwner(owner: string, options?: MultisigOptions): Promise<MultisigProposal>;
|
|
19
|
+
/**
|
|
20
|
+
* Proposes removing an owner from the multisig wallet account.
|
|
21
|
+
*
|
|
22
|
+
* @param {string} owner - The owner's address.
|
|
23
|
+
* @param {MultisigOptions} [options] - The multisig options.
|
|
24
|
+
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
25
|
+
* @throws {ValueError} If the address or options are not valid.
|
|
26
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
27
|
+
* @throws {ProviderError} If the provider fails to remove the owner.
|
|
28
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
29
|
+
*/
|
|
30
|
+
removeOwner(owner: string, options?: MultisigOptions): Promise<MultisigProposal>;
|
|
31
|
+
/**
|
|
32
|
+
* Proposes replacing an owner with a different one.
|
|
33
|
+
*
|
|
34
|
+
* @param {string} oldOwner - The old owner.
|
|
35
|
+
* @param {string} newOwner - The new owner.
|
|
36
|
+
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
37
|
+
* @throws {ValueError} If the addresses are not valid.
|
|
38
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
39
|
+
* @throws {ProviderError} If the provider fails to swap the two owners.
|
|
40
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
41
|
+
*/
|
|
42
|
+
swapOwner(oldOwner: string, newOwner: string): Promise<MultisigProposal>;
|
|
43
|
+
/**
|
|
44
|
+
* Proposes changing the signature threshold.
|
|
45
|
+
*
|
|
46
|
+
* @param {number} newThreshold - The new threshold.
|
|
47
|
+
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
48
|
+
* @throws {ValueError} If the threshold is not valid.
|
|
49
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
50
|
+
* @throws {ProviderError} If the provider fails to change the threshold.
|
|
51
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
52
|
+
*/
|
|
53
|
+
changeThreshold(newThreshold: number): Promise<MultisigProposal>;
|
|
54
|
+
}
|
|
55
|
+
export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
|
|
56
|
+
export type AccountNotOwnerError = import("./errors.js").AccountNotOwnerError;
|
|
57
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
58
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
59
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
60
|
+
export type MultisigOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* - The new amount of approvals required to execute a transaction.
|
|
63
|
+
*/
|
|
64
|
+
threshold: number;
|
|
65
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** @interface */
|
|
2
|
+
export interface IWalletAccountMultisig extends IWalletAccountReadOnlyMultisig {
|
|
3
|
+
/**
|
|
4
|
+
* The derivation path's index of this account.
|
|
5
|
+
*
|
|
6
|
+
* @type {number}
|
|
7
|
+
*/
|
|
8
|
+
get index(): number;
|
|
9
|
+
/**
|
|
10
|
+
* The derivation path of this account (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)).
|
|
11
|
+
*
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
get path(): string;
|
|
15
|
+
/**
|
|
16
|
+
* The key pair of this account.
|
|
17
|
+
*
|
|
18
|
+
* @type {KeyPair}
|
|
19
|
+
*/
|
|
20
|
+
get keyPair(): KeyPair;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the signer's address.
|
|
23
|
+
*
|
|
24
|
+
* @returns {Promise<string>} The signer's address.
|
|
25
|
+
*/
|
|
26
|
+
getSignerAddress(): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Proposes sending a transaction for the other owners to approve. Does not execute on-chain:
|
|
29
|
+
* the returned proposal must be approved up to the threshold and then executed via
|
|
30
|
+
* {@link executeProposal}.
|
|
31
|
+
*
|
|
32
|
+
* @param {Transaction} tx - The transaction.
|
|
33
|
+
* @param {MultisigTransactionOptions} [transactionOptions] - The multisig transaction's options.
|
|
34
|
+
* @returns {Promise<MultisigProposal>} The created proposal; its `status` is `'executed'` when `autoExecute` ran to completion, otherwise `'pending'`.
|
|
35
|
+
* @throws {ValueError} If the transaction is not valid.
|
|
36
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
37
|
+
* @throws {ProviderError} If the provider fails to propose the transaction.
|
|
38
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
39
|
+
*/
|
|
40
|
+
propose(tx: Transaction, transactionOptions?: MultisigTransactionOptions): Promise<MultisigProposal>;
|
|
41
|
+
/**
|
|
42
|
+
* Approves a pending proposal.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} proposalId - The proposal's id.
|
|
45
|
+
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
46
|
+
* @throws {ValueError} If the proposal's identifier is not a valid id.
|
|
47
|
+
* @throws {NoSuchElementError} If no message exists for the given id.
|
|
48
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
49
|
+
*/
|
|
50
|
+
approveProposal(proposalId: string): Promise<MultisigProposal>;
|
|
51
|
+
/**
|
|
52
|
+
* Rejects a pending proposal.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} proposalId - The proposal's id.
|
|
55
|
+
* @returns {Promise<MultisigProposal>} The multisig proposal.
|
|
56
|
+
* @throws {ValueError} If the proposal's identifier is not a valid id.
|
|
57
|
+
* @throws {NoSuchElementError} If no message exists for the given id.
|
|
58
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
59
|
+
*/
|
|
60
|
+
rejectProposal(proposalId: string): Promise<MultisigProposal>;
|
|
61
|
+
/**
|
|
62
|
+
* Submits an approved proposal for on-chain execution.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} proposalId - The proposal's id.
|
|
65
|
+
* @returns {Promise<TransactionResult>} The on-chain transaction's result.
|
|
66
|
+
* @throws {ValueError} If the proposal's identifier is not a valid id.
|
|
67
|
+
* @throws {NoSuchElementError} If no proposal exists for the given id.
|
|
68
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
69
|
+
* @throws {ProviderError} If the provider fails to execute the proposal.
|
|
70
|
+
* @throws {TransactionError} If the transaction fails with an error.
|
|
71
|
+
* @throws {AccountNotOwnerError} If the account is not an owner of the multisig wallet.
|
|
72
|
+
* @throws {ThresholdNotMetError} If the proposal's threshold has not been met yet.
|
|
73
|
+
* @throws {MaximumFeeExceededError} If the the costs of the transaction exceeds the transaction max. fee option.
|
|
74
|
+
*/
|
|
75
|
+
executeProposal(proposalId: string): Promise<TransactionResult>;
|
|
76
|
+
}
|
|
77
|
+
export type Transaction = import("../wallet-account-read-only.js").Transaction;
|
|
78
|
+
export type TransactionResult = import("../wallet-account-read-only.js").TransactionResult;
|
|
79
|
+
export type KeyPair = import("../wallet-account.js").KeyPair;
|
|
80
|
+
export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
|
|
81
|
+
export type AccountNotOwnerError = import("./errors.js").AccountNotOwnerError;
|
|
82
|
+
export type MaximumFeeExceededError = import("./errors.js").MaximumFeeExceededError;
|
|
83
|
+
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
|
84
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
85
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
86
|
+
export type TransactionError = import("./errors.js").TransactionError;
|
|
87
|
+
export type ThresholdNotMetError = import("./errors.js").ThresholdNotMetError;
|
|
88
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
89
|
+
export type MultisigTransactionOptions = {
|
|
90
|
+
/**
|
|
91
|
+
* - If true, automatically executes the transaction when the approval threshold is met (only takes effect if this signer's approval is the last one required).
|
|
92
|
+
*/
|
|
93
|
+
autoExecute?: boolean;
|
|
94
|
+
};
|
|
95
|
+
export type MultisigAutoExecuteResult = {
|
|
96
|
+
/**
|
|
97
|
+
* - If auto execute is set to true and the method call triggers the execution of the proposal, this field is set to the corresponding transaction's result (i.e., hash and fee).
|
|
98
|
+
*/
|
|
99
|
+
transaction?: TransactionResult;
|
|
100
|
+
};
|
|
101
|
+
import { IWalletAccountReadOnlyMultisig } from './wallet-account-read-only-multisig.js';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** @interface */
|
|
2
|
+
export interface IWalletAccountReadOnlyMultisig extends IWalletAccountReadOnlySimple {
|
|
3
|
+
/**
|
|
4
|
+
* Returns the multisig wallet account info.
|
|
5
|
+
*
|
|
6
|
+
* @returns {Promise<MultisigInfo>} The info.
|
|
7
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
8
|
+
* @throws {ProviderError} If the provider fails to fetch the multisig wallet's info.
|
|
9
|
+
*/
|
|
10
|
+
getMultisigInfo(): Promise<MultisigInfo>;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a list of proposals by their identifiers.
|
|
13
|
+
*
|
|
14
|
+
* @param {string[]} proposalIds - The list of proposal's identifiers.
|
|
15
|
+
* @returns {Promise<Record<string, MultisigProposal | null>>} For each proposal id, the proposal details or
|
|
16
|
+
* null if the proposal has not been found.
|
|
17
|
+
* @throws {ValueError} If the list of proposal's identifiers contains an invalid id.
|
|
18
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
19
|
+
* @throws {ProviderError} If the provider fails to fetch the proposals.
|
|
20
|
+
*/
|
|
21
|
+
getProposals(proposalIds: string[]): Promise<Record<string, MultisigProposal | null>>;
|
|
22
|
+
/**
|
|
23
|
+
* Returns a proposal by its identifier.
|
|
24
|
+
*
|
|
25
|
+
* @param {string} proposalId - The proposal's identifier.
|
|
26
|
+
* @returns {Promise<MultisigProposal | null>} The proposal details, or null if it has not been found.
|
|
27
|
+
* @throws {ValueError} If the proposal's identifier is not a valid id.
|
|
28
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
29
|
+
* @throws {ProviderError} If the provider fails to fetch the proposal.
|
|
30
|
+
*/
|
|
31
|
+
getProposal(proposalId: string): Promise<MultisigProposal | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Quotes the on-chain cost of executing a pending proposal.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} proposalId - The proposal's id.
|
|
36
|
+
* @returns {Promise<Omit<TransactionResult, 'hash'>>} The execution cost estimate.
|
|
37
|
+
* @throws {ValueError} If the proposal's identifier is not a valid id.
|
|
38
|
+
* @throws {NoSuchElementError} If no proposal exists for the given id.
|
|
39
|
+
* @throws {ProviderRequiredError} If the method requires a provider.
|
|
40
|
+
* @throws {ProviderError} If the provider fails to estimate the costs of the transaction.
|
|
41
|
+
* @throws {TransactionError} If the transaction fails with an error.
|
|
42
|
+
*/
|
|
43
|
+
quoteExecuteProposal(proposalId: string): Promise<Omit<TransactionResult, "hash">>;
|
|
44
|
+
}
|
|
45
|
+
export type TransactionResult = import("../wallet-account-read-only.js").TransactionResult;
|
|
46
|
+
export type NoSuchElementError = import("./errors.js").NoSuchElementError;
|
|
47
|
+
export type ProviderError = import("./errors.js").ProviderError;
|
|
48
|
+
export type ProviderRequiredError = import("./errors.js").ProviderRequiredError;
|
|
49
|
+
export type TransactionError = import("./errors.js").TransactionError;
|
|
50
|
+
export type ValueError = import("./errors.js").ValueError;
|
|
51
|
+
export type MultisigInfo = {
|
|
52
|
+
/**
|
|
53
|
+
* - The multisig wallet account address.
|
|
54
|
+
*/
|
|
55
|
+
address: string;
|
|
56
|
+
/**
|
|
57
|
+
* - The owners of the multisig wallet account.
|
|
58
|
+
*/
|
|
59
|
+
owners: string[];
|
|
60
|
+
/**
|
|
61
|
+
* - The minimum amount of signatures to execute a transaction.
|
|
62
|
+
*/
|
|
63
|
+
threshold: number;
|
|
64
|
+
};
|
|
65
|
+
export type MultisigProposal = {
|
|
66
|
+
/**
|
|
67
|
+
* - The proposal's id.
|
|
68
|
+
*/
|
|
69
|
+
proposalId: string;
|
|
70
|
+
/**
|
|
71
|
+
* - The current number of confirmations.
|
|
72
|
+
*/
|
|
73
|
+
confirmations: number;
|
|
74
|
+
/**
|
|
75
|
+
* - The minimum amount of confirmations to execute the transaction.
|
|
76
|
+
*/
|
|
77
|
+
threshold: number;
|
|
78
|
+
/**
|
|
79
|
+
* - The proposal's lifecycle state: `'pending'` while it still awaits confirmations or on-chain execution, `'executed'` once it has been executed on-chain.
|
|
80
|
+
*/
|
|
81
|
+
status: "pending" | "executed";
|
|
82
|
+
};
|
|
83
|
+
import { IWalletAccountReadOnlySimple } from '../wallet-account-read-only-simple.js';
|