@tetherto/wdk-wallet 1.0.0-beta.14 → 1.0.0-beta.16

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.
@@ -15,6 +15,8 @@
15
15
 
16
16
  import { NotImplementedError } from './errors.js'
17
17
 
18
+ import { IWalletAccountReadOnlySimple } from './wallet-account-read-only-simple.js'
19
+
18
20
  /**
19
21
  * @typedef {Object} Transaction
20
22
  * @property {string} to - The transaction's recipient.
@@ -41,47 +43,7 @@ import { NotImplementedError } from './errors.js'
41
43
  */
42
44
 
43
45
  /** @interface */
44
- export class IWalletAccountReadOnly {
45
- /**
46
- * Returns the account's address.
47
- *
48
- * @returns {Promise<string>} The account's address.
49
- */
50
- async getAddress () {
51
- throw new NotImplementedError('getAddress()')
52
- }
53
-
54
- /**
55
- * Verifies a message's signature.
56
- *
57
- * @param {string} message - The original message.
58
- * @param {string} signature - The signature to verify.
59
- * @returns {Promise<boolean>} True if the signature is valid.
60
- * @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
61
- */
62
- async verify (message, signature) {
63
- throw new NotImplementedError('verify(message, signature)')
64
- }
65
-
66
- /**
67
- * Returns the account's native token balance.
68
- *
69
- * @returns {Promise<bigint>} The native token balance.
70
- */
71
- async getBalance () {
72
- throw new NotImplementedError('getBalance()')
73
- }
74
-
75
- /**
76
- * Returns the account balance for a specific token.
77
- *
78
- * @param {string} tokenAddress - The smart contract address of the token.
79
- * @returns {Promise<bigint>} The token balance.
80
- */
81
- async getTokenBalance (tokenAddress) {
82
- throw new NotImplementedError('getTokenBalance(tokenAddress)')
83
- }
84
-
46
+ export class IWalletAccountReadOnly extends IWalletAccountReadOnlySimple {
85
47
  /**
86
48
  * Quotes the costs of a send transaction operation.
87
49
  *
@@ -101,16 +63,6 @@ export class IWalletAccountReadOnly {
101
63
  async quoteTransfer (options) {
102
64
  throw new NotImplementedError('quoteTransfer(options)')
103
65
  }
104
-
105
- /**
106
- * Returns a transaction's receipt.
107
- *
108
- * @param {string} hash - The transaction's hash.
109
- * @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
110
- */
111
- async getTransactionReceipt (hash) {
112
- throw new NotImplementedError('getTransactionReceipt(hash)')
113
- }
114
66
  }
115
67
 
116
68
  /**
package/types/index.d.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export { default } from "./src/wallet-manager.js";
2
+ export { IWalletAccount } from "./src/wallet-account.js";
3
+ export { ISigner } from "./src/signer.js";
1
4
  export type FeeRates = import("./src/wallet-manager.js").FeeRates;
2
5
  export type WalletConfig = import("./src/wallet-manager.js").WalletConfig;
3
6
  export type Transaction = import("./src/wallet-account-read-only.js").Transaction;
@@ -5,8 +8,5 @@ export type TransactionResult = import("./src/wallet-account-read-only.js").Tran
5
8
  export type TransferOptions = import("./src/wallet-account-read-only.js").TransferOptions;
6
9
  export type TransferResult = import("./src/wallet-account-read-only.js").TransferResult;
7
10
  export type KeyPair = import("./src/wallet-account.js").KeyPair;
8
- export { default } from "./src/wallet-manager.js";
9
11
  export { default as WalletAccountReadOnly, IWalletAccountReadOnly } from "./src/wallet-account-read-only.js";
10
- export { IWalletAccount } from "./src/wallet-account.js";
11
- export { NotImplementedError, SignerError } from "./src/errors.js";
12
- export { ISigner } from "./src/signer.js";
12
+ export { NotImplementedError, SignerError, UnsupportedOperationError, ValueError, NoSuchElementError } from "./src/errors.js";
@@ -14,3 +14,29 @@ export class SignerError extends Error {
14
14
  */
15
15
  constructor(message: string);
16
16
  }
17
+ export class UnsupportedOperationError extends Error {
18
+ /**
19
+ * Create a new unsupported operation error. Thrown by an optional operation
20
+ * that the concrete implementation deliberately does not support.
21
+ *
22
+ * @param {string} operation - The name of the operation that is not supported.
23
+ */
24
+ constructor(operation: string);
25
+ }
26
+ export class ValueError extends Error {
27
+ /**
28
+ * Create a new value error. Thrown when an argument fails validation.
29
+ *
30
+ * @param {string} message - The error's message.
31
+ */
32
+ constructor(message: string);
33
+ }
34
+ export class NoSuchElementError extends Error {
35
+ /**
36
+ * Create a new no such element error. Thrown when a lookup finds no element for
37
+ * the given identifier.
38
+ *
39
+ * @param {string} message - The error's message.
40
+ */
41
+ constructor(message: string);
42
+ }
@@ -0,0 +1,11 @@
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 type MultisigInfo = import("./wallet-account-read-only-multisig.js").MultisigInfo;
5
+ export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
6
+ export type MultisigMessageProposal = import("./wallet-account-read-only-multisig.js").MultisigMessageProposal;
7
+ export type KeyPair = import("../wallet-account.js").KeyPair;
8
+ export type MultisigTransactionOptions = import("./wallet-account-multisig.js").MultisigTransactionOptions;
9
+ export type MultisigAutoExecuteResult = import("./wallet-account-multisig.js").MultisigAutoExecuteResult;
10
+ export type MultisigSignature = import("./wallet-account-multisig.js").MultisigSignature;
11
+ export type MultisigOptions = import("./multisig-owner-management.js").MultisigOptions;
@@ -0,0 +1,49 @@
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 {Error} If the account is not an owner of the multisig wallet.
14
+ */
15
+ addOwner(owner: string, options?: MultisigOptions): Promise<MultisigProposal>;
16
+ /**
17
+ * Proposes removing an owner from the multisig wallet account.
18
+ *
19
+ * @param {string} owner - The owner's address.
20
+ * @param {MultisigOptions} [options] - The multisig options.
21
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
22
+ * @throws {Error} If the account is not an owner of the multisig wallet.
23
+ */
24
+ removeOwner(owner: string, options?: MultisigOptions): Promise<MultisigProposal>;
25
+ /**
26
+ * Proposes replacing an owner with a different one.
27
+ *
28
+ * @param {string} oldOwner - The old owner.
29
+ * @param {string} newOwner - The new owner.
30
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
31
+ * @throws {Error} If the account is not an owner of the multisig wallet.
32
+ */
33
+ swapOwner(oldOwner: string, newOwner: string): Promise<MultisigProposal>;
34
+ /**
35
+ * Proposes changing the signature threshold.
36
+ *
37
+ * @param {number} newThreshold - The new threshold.
38
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
39
+ * @throws {Error} If the account is not an owner of the multisig wallet.
40
+ */
41
+ changeThreshold(newThreshold: number): Promise<MultisigProposal>;
42
+ }
43
+ export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
44
+ export type MultisigOptions = {
45
+ /**
46
+ * - The new amount of approvals required to execute a transaction.
47
+ */
48
+ threshold: number;
49
+ };
@@ -0,0 +1,107 @@
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 & MultisigAutoExecuteResult>} The created proposal; its `status` is `'executed'` when `autoExecute` ran to completion, otherwise `'pending'`.
35
+ * @throws {Error} If the account is not an owner of the multisig wallet.
36
+ */
37
+ propose(tx: Transaction, transactionOptions?: MultisigTransactionOptions): Promise<MultisigProposal & MultisigAutoExecuteResult>;
38
+ /**
39
+ * Proposes signing a message.
40
+ *
41
+ * @param {string} message - The message to sign.
42
+ * @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
43
+ * @throws {Error} If the account is not an owner of the multisig wallet.
44
+ */
45
+ proposeMessage(message: string): Promise<MultisigMessageProposal & MultisigSignature>;
46
+ /**
47
+ * Approves an existing message proposal.
48
+ *
49
+ * @param {string} messageId - The message's hash.
50
+ * @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
51
+ * @throws {Error} If the account is not an owner of the multisig wallet.
52
+ * @throws {NoSuchElementError} If no message exists for the given id.
53
+ */
54
+ approveMessageProposal(messageId: string): Promise<MultisigMessageProposal & MultisigSignature>;
55
+ /**
56
+ * Approves a pending proposal.
57
+ *
58
+ * @param {string} proposalId - The proposal's id.
59
+ * @returns {Promise<MultisigProposal & MultisigAutoExecuteResult>} The multisig proposal.
60
+ * @throws {Error} If the account is not an owner of the multisig wallet.
61
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
62
+ */
63
+ approveProposal(proposalId: string): Promise<MultisigProposal & MultisigAutoExecuteResult>;
64
+ /**
65
+ * Rejects a pending proposal.
66
+ *
67
+ * @param {string} proposalId - The proposal's id.
68
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
69
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
70
+ */
71
+ rejectProposal(proposalId: string): Promise<MultisigProposal>;
72
+ /**
73
+ * Submits an approved proposal for on-chain execution.
74
+ *
75
+ * @param {string} proposalId - The proposal's id.
76
+ * @returns {Promise<TransactionResult>} The on-chain transaction's result.
77
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
78
+ * @throws {ValueError} If the proposal has not reached the approval threshold.
79
+ */
80
+ executeProposal(proposalId: string): Promise<TransactionResult>;
81
+ }
82
+ export type Transaction = import("../wallet-account-read-only.js").Transaction;
83
+ export type TransactionResult = import("../wallet-account-read-only.js").TransactionResult;
84
+ export type KeyPair = import("../wallet-account.js").KeyPair;
85
+ export type MultisigProposal = import("./wallet-account-read-only-multisig.js").MultisigProposal;
86
+ export type MultisigMessageProposal = import("./wallet-account-read-only-multisig.js").MultisigMessageProposal;
87
+ export type NoSuchElementError = import("../errors.js").NoSuchElementError;
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
+ export type MultisigSignature = {
102
+ /**
103
+ * - The caller's signature.
104
+ */
105
+ signature: string;
106
+ };
107
+ import { IWalletAccountReadOnlyMultisig } from './wallet-account-read-only-multisig.js';
@@ -0,0 +1,103 @@
1
+ /** @interface */
2
+ export interface IWalletAccountReadOnlyMultisig extends IWalletAccountReadOnlySimple {
3
+ /**
4
+ * Returns the multisig wallet account info.
5
+ *
6
+ * @returns {Promise<MultisigInfo>} The info.
7
+ */
8
+ getMultisigInfo(): Promise<MultisigInfo>;
9
+ /**
10
+ * Returns a list of proposals by their identifiers.
11
+ *
12
+ * @param {string[]} proposalIds - The list of proposal identifiers.
13
+ * @returns {Promise<Record<string, MultisigProposal | null>>} For each proposal id, the proposal details or
14
+ * null if the proposal has not been found.
15
+ */
16
+ getProposals(proposalIds: string[]): Promise<Record<string, MultisigProposal | null>>;
17
+ /**
18
+ * Returns a proposal by its identifier.
19
+ *
20
+ * @param {string} proposalId - The proposal's identifier.
21
+ * @returns {Promise<MultisigProposal | null>} The proposal details, or null if it has not been found.
22
+ */
23
+ getProposal(proposalId: string): Promise<MultisigProposal | null>;
24
+ /**
25
+ * Returns a list of message proposals by their hashes.
26
+ *
27
+ * @param {string[]} messageIds - The list of message hashes
28
+ * @returns {Promise<Record<string, MultisigMessageProposal | null>>} For each message hash, the message details or
29
+ * null if the message has not been found.
30
+ */
31
+ getMessageProposals(messageIds: string[]): Promise<Record<string, MultisigMessageProposal | null>>;
32
+ /**
33
+ * Returns a message proposal by its identifier.
34
+ *
35
+ * @param {string} messageId - The message's hash.
36
+ * @returns {Promise<MultisigMessageProposal | null>} The message details, or null if it has not been found.
37
+ */
38
+ getMessageProposal(messageId: string): Promise<MultisigMessageProposal | null>;
39
+ /**
40
+ * Quotes the on-chain cost of executing a pending proposal.
41
+ *
42
+ * @param {string} proposalId - The proposal's id.
43
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The execution cost estimate.
44
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
45
+ */
46
+ quoteExecuteProposal(proposalId: string): Promise<Omit<TransactionResult, "hash">>;
47
+ }
48
+ export type MultisigInfo = {
49
+ /**
50
+ * - The multisig wallet account address.
51
+ */
52
+ address: string;
53
+ /**
54
+ * - The owners of the multisig wallet account.
55
+ */
56
+ owners: string[];
57
+ /**
58
+ * - The minimum amount of signatures to execute a transaction.
59
+ */
60
+ threshold: number;
61
+ };
62
+ export type MultisigProposal = {
63
+ /**
64
+ * - The proposal's id.
65
+ */
66
+ proposalId: string;
67
+ /**
68
+ * - The current number of confirmations.
69
+ */
70
+ confirmations: number;
71
+ /**
72
+ * - The minimum amount of confirmations to execute the transaction.
73
+ */
74
+ threshold: number;
75
+ /**
76
+ * - The proposal's lifecycle state: `'pending'` while it still awaits confirmations or on-chain execution, `'executed'` once it has been executed on-chain.
77
+ */
78
+ status: 'pending' | 'executed';
79
+ };
80
+ export type MultisigMessageProposal = {
81
+ /**
82
+ * - The message's hash.
83
+ */
84
+ messageId: string;
85
+ /**
86
+ * - The original message.
87
+ */
88
+ message: string;
89
+ /**
90
+ * - The current number of confirmations.
91
+ */
92
+ confirmations: number;
93
+ /**
94
+ * - The minimum amount of confirmations to sign the message.
95
+ */
96
+ threshold: number;
97
+ /**
98
+ * - The final combined signature when the threshold is met.
99
+ */
100
+ combinedSignature: string | null;
101
+ };
102
+ export type TransactionResult = import("../wallet-account-read-only.js").TransactionResult;
103
+ import { IWalletAccountReadOnlySimple } from '../wallet-account-read-only-simple.js';
@@ -44,8 +44,27 @@ export type SwidgeStatusResult = import("./swidge-protocol.js").SwidgeStatusResu
44
44
  export type SwidgeSupportedChain = import("./swidge-protocol.js").SwidgeSupportedChain;
45
45
  export type SwidgeSupportedToken = import("./swidge-protocol.js").SwidgeSupportedToken;
46
46
  export type SwidgeSupportedTokensOptions = import("./swidge-protocol.js").SwidgeSupportedTokensOptions;
47
+ export type Blockchain = import("./sda-protocol.js").Blockchain;
48
+ export type SdaToken = import("./sda-protocol.js").SdaToken;
49
+ export type SdaDepositAddressLimits = import("./sda-protocol.js").SdaDepositAddressLimits;
50
+ export type SdaRoutesOptions = import("./sda-protocol.js").SdaRoutesOptions;
51
+ export type SdaRoute = import("./sda-protocol.js").SdaRoute;
52
+ export type SdaDepositOptions = import("./sda-protocol.js").SdaDepositOptions;
53
+ export type SdaFeeType = import("./sda-protocol.js").SdaFeeType;
54
+ export type SdaFee = import("./sda-protocol.js").SdaFee;
55
+ export type SdaDepositQuote = import("./sda-protocol.js").SdaDepositQuote;
56
+ export type SdaCreateDepositAddressOptions = import("./sda-protocol.js").SdaCreateDepositAddressOptions;
57
+ export type SdaDepositAddress = import("./sda-protocol.js").SdaDepositAddress;
58
+ export type SdaTransferStatus = import("./sda-protocol.js").SdaTransferStatus;
59
+ export type SdaTransfer = import("./sda-protocol.js").SdaTransfer;
60
+ export type SdaTransfersOptions = import("./sda-protocol.js").SdaTransfersOptions;
61
+ export type SdaRecoverById = import("./sda-protocol.js").SdaRecoverById;
62
+ export type SdaRecoverByAddress = import("./sda-protocol.js").SdaRecoverByAddress;
63
+ export type SdaRecoveryOptions = import("./sda-protocol.js").SdaRecoveryOptions;
64
+ export type SdaRecoveryResult = import("./sda-protocol.js").SdaRecoveryResult;
47
65
  export { default as SwapProtocol, ISwapProtocol } from "./swap-protocol.js";
48
66
  export { default as BridgeProtocol, IBridgeProtocol } from "./bridge-protocol.js";
49
67
  export { default as LendingProtocol, ILendingProtocol } from "./lending-protocol.js";
50
68
  export { default as FiatProtocol, IFiatProtocol } from "./fiat-protocol.js";
51
69
  export { default as SwidgeProtocol, ISwidgeProtocol } from "./swidge-protocol.js";
70
+ export { default as SdaProtocol, ISdaProtocol } from "./sda-protocol.js";