@tetherto/wdk-wallet 1.0.0-beta.15 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tetherto/wdk-wallet",
3
- "version": "1.0.0-beta.15",
3
+ "version": "1.0.0-beta.16",
4
4
  "description": "A simple package to manage BIP-32 wallets.",
5
5
  "keywords": [
6
6
  "wdk",
@@ -43,6 +43,10 @@
43
43
  "types": "./types/src/protocols/index.d.ts",
44
44
  "default": "./src/protocols/index.js"
45
45
  },
46
+ "./multisig": {
47
+ "types": "./types/src/multisig/index.d.ts",
48
+ "default": "./src/multisig/index.js"
49
+ },
46
50
  "./package": {
47
51
  "default": "./package.json"
48
52
  }
@@ -0,0 +1,30 @@
1
+ // Copyright 2024 Tether Operations Limited
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ 'use strict'
15
+
16
+ /** @typedef {import('./wallet-account-read-only-multisig.js').MultisigInfo} MultisigInfo */
17
+ /** @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
+
21
+ /** @typedef {import('./wallet-account-multisig.js').MultisigTransactionOptions} MultisigTransactionOptions */
22
+ /** @typedef {import('./wallet-account-multisig.js').MultisigAutoExecuteResult} MultisigAutoExecuteResult */
23
+ /** @typedef {import('./wallet-account-multisig.js').MultisigSignature} MultisigSignature */
24
+ /** @typedef {import('./multisig-owner-management.js').MultisigOptions} MultisigOptions */
25
+
26
+ export { IWalletAccountReadOnlyMultisig } from './wallet-account-read-only-multisig.js'
27
+
28
+ export { IWalletAccountMultisig } from './wallet-account-multisig.js'
29
+
30
+ export { IMultisigOwnerManagement } from './multisig-owner-management.js'
@@ -0,0 +1,77 @@
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('./wallet-account-read-only-multisig.js').MultisigProposal} MultisigProposal */
19
+
20
+ /**
21
+ * @typedef {Object} MultisigOptions
22
+ * @property {number} threshold - The new amount of approvals required to execute a transaction.
23
+ */
24
+
25
+ /**
26
+ * Adds owner management features to a multisig wallet.
27
+ *
28
+ * @interface
29
+ */
30
+ export class IMultisigOwnerManagement {
31
+ /**
32
+ * Proposes adding a new owner to the multisig wallet account.
33
+ *
34
+ * @param {string} owner - The owner's address.
35
+ * @param {MultisigOptions} [options] - The multisig options.
36
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
37
+ * @throws {Error} If the account is not an owner of the multisig wallet.
38
+ */
39
+ async addOwner (owner, options) {
40
+ throw new NotImplementedError('addOwner(owner, options)')
41
+ }
42
+
43
+ /**
44
+ * Proposes removing an owner from the multisig wallet account.
45
+ *
46
+ * @param {string} owner - The owner's address.
47
+ * @param {MultisigOptions} [options] - The multisig options.
48
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
49
+ * @throws {Error} If the account is not an owner of the multisig wallet.
50
+ */
51
+ async removeOwner (owner, options) {
52
+ throw new NotImplementedError('removeOwner(owner, options)')
53
+ }
54
+
55
+ /**
56
+ * Proposes replacing an owner with a different one.
57
+ *
58
+ * @param {string} oldOwner - The old owner.
59
+ * @param {string} newOwner - The new owner.
60
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
61
+ * @throws {Error} If the account is not an owner of the multisig wallet.
62
+ */
63
+ async swapOwner (oldOwner, newOwner) {
64
+ throw new NotImplementedError('swapOwner(oldOwner, newOwner)')
65
+ }
66
+
67
+ /**
68
+ * Proposes changing the signature threshold.
69
+ *
70
+ * @param {number} newThreshold - The new threshold.
71
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
72
+ * @throws {Error} If the account is not an owner of the multisig wallet.
73
+ */
74
+ async changeThreshold (newThreshold) {
75
+ throw new NotImplementedError('changeThreshold(newThreshold)')
76
+ }
77
+ }
@@ -0,0 +1,155 @@
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 { IWalletAccountReadOnlyMultisig } from './wallet-account-read-only-multisig.js'
17
+
18
+ import { NotImplementedError } from '../errors.js'
19
+
20
+ /** @typedef {import('../wallet-account-read-only.js').Transaction} Transaction */
21
+ /** @typedef {import('../wallet-account-read-only.js').TransactionResult} TransactionResult */
22
+
23
+ /** @typedef {import('../wallet-account.js').KeyPair} KeyPair */
24
+
25
+ /** @typedef {import('./wallet-account-read-only-multisig.js').MultisigProposal} MultisigProposal */
26
+ /** @typedef {import('./wallet-account-read-only-multisig.js').MultisigMessageProposal} MultisigMessageProposal */
27
+
28
+ /** @typedef {import('../errors.js').NoSuchElementError} NoSuchElementError */
29
+ /** @typedef {import('../errors.js').ValueError} ValueError */
30
+
31
+ /**
32
+ * @typedef {Object} MultisigTransactionOptions
33
+ * @property {boolean} [autoExecute] - 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).
34
+ */
35
+
36
+ /**
37
+ * @typedef {Object} MultisigAutoExecuteResult
38
+ * @property {TransactionResult} [transaction] - 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).
39
+ */
40
+
41
+ /**
42
+ * @typedef {Object} MultisigSignature
43
+ * @property {string} signature - The caller's signature.
44
+ */
45
+
46
+ /** @interface */
47
+ export class IWalletAccountMultisig extends IWalletAccountReadOnlyMultisig {
48
+ /**
49
+ * The derivation path's index of this account.
50
+ *
51
+ * @type {number}
52
+ */
53
+ get index () {
54
+ throw new NotImplementedError('index')
55
+ }
56
+
57
+ /**
58
+ * The derivation path of this account (see [BIP-44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)).
59
+ *
60
+ * @type {string}
61
+ */
62
+ get path () {
63
+ throw new NotImplementedError('path')
64
+ }
65
+
66
+ /**
67
+ * The key pair of this account.
68
+ *
69
+ * @type {KeyPair}
70
+ */
71
+ get keyPair () {
72
+ throw new NotImplementedError('keyPair')
73
+ }
74
+
75
+ /**
76
+ * Returns the signer's address.
77
+ *
78
+ * @returns {Promise<string>} The signer's address.
79
+ */
80
+ async getSignerAddress () {
81
+ throw new NotImplementedError('getSignerAddress()')
82
+ }
83
+
84
+ /**
85
+ * Proposes sending a transaction for the other owners to approve. Does not execute on-chain:
86
+ * the returned proposal must be approved up to the threshold and then executed via
87
+ * {@link executeProposal}.
88
+ *
89
+ * @param {Transaction} tx - The transaction.
90
+ * @param {MultisigTransactionOptions} [transactionOptions] - The multisig transaction's options.
91
+ * @returns {Promise<MultisigProposal & MultisigAutoExecuteResult>} The created proposal; its `status` is `'executed'` when `autoExecute` ran to completion, otherwise `'pending'`.
92
+ * @throws {Error} If the account is not an owner of the multisig wallet.
93
+ */
94
+ async propose (tx, transactionOptions) {
95
+ throw new NotImplementedError('propose(tx, transactionOptions)')
96
+ }
97
+
98
+ /**
99
+ * Proposes signing a message.
100
+ *
101
+ * @param {string} message - The message to sign.
102
+ * @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
103
+ * @throws {Error} If the account is not an owner of the multisig wallet.
104
+ */
105
+ async proposeMessage (message) {
106
+ throw new NotImplementedError('proposeMessage(message)')
107
+ }
108
+
109
+ /**
110
+ * Approves an existing message proposal.
111
+ *
112
+ * @param {string} messageId - The message's hash.
113
+ * @returns {Promise<MultisigMessageProposal & MultisigSignature>} The multisig message proposal.
114
+ * @throws {Error} If the account is not an owner of the multisig wallet.
115
+ * @throws {NoSuchElementError} If no message exists for the given id.
116
+ */
117
+ async approveMessageProposal (messageId) {
118
+ throw new NotImplementedError('approveMessageProposal(messageId)')
119
+ }
120
+
121
+ /**
122
+ * Approves a pending proposal.
123
+ *
124
+ * @param {string} proposalId - The proposal's id.
125
+ * @returns {Promise<MultisigProposal & MultisigAutoExecuteResult>} The multisig proposal.
126
+ * @throws {Error} If the account is not an owner of the multisig wallet.
127
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
128
+ */
129
+ async approveProposal (proposalId) {
130
+ throw new NotImplementedError('approveProposal(proposalId)')
131
+ }
132
+
133
+ /**
134
+ * Rejects a pending proposal.
135
+ *
136
+ * @param {string} proposalId - The proposal's id.
137
+ * @returns {Promise<MultisigProposal>} The multisig proposal.
138
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
139
+ */
140
+ async rejectProposal (proposalId) {
141
+ throw new NotImplementedError('rejectProposal(proposalId)')
142
+ }
143
+
144
+ /**
145
+ * Submits an approved proposal for on-chain execution.
146
+ *
147
+ * @param {string} proposalId - The proposal's id.
148
+ * @returns {Promise<TransactionResult>} The on-chain transaction's result.
149
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
150
+ * @throws {ValueError} If the proposal has not reached the approval threshold.
151
+ */
152
+ async executeProposal (proposalId) {
153
+ throw new NotImplementedError('executeProposal(proposalId)')
154
+ }
155
+ }
@@ -0,0 +1,112 @@
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 { IWalletAccountReadOnlySimple } from '../wallet-account-read-only-simple.js'
17
+
18
+ import { NotImplementedError } from '../errors.js'
19
+
20
+ /** @typedef {import('../errors.js').NoSuchElementError} NoSuchElementError */
21
+
22
+ /** @typedef {import('../wallet-account-read-only.js').TransactionResult} TransactionResult */
23
+
24
+ /**
25
+ * @typedef {Object} MultisigInfo
26
+ * @property {string} address - The multisig wallet account address.
27
+ * @property {string[]} owners - The owners of the multisig wallet account.
28
+ * @property {number} threshold - The minimum amount of signatures to execute a transaction.
29
+ */
30
+
31
+ /**
32
+ *
33
+ * @typedef {Object} MultisigProposal
34
+ * @property {string} proposalId - The proposal's id.
35
+ * @property {number} confirmations - The current number of confirmations.
36
+ * @property {number} threshold - The minimum amount of confirmations to execute the transaction.
37
+ * @property {'pending' | 'executed'} status - The proposal's lifecycle state: `'pending'` while it still awaits confirmations or on-chain execution, `'executed'` once it has been executed on-chain.
38
+ */
39
+
40
+ /**
41
+ * @typedef {Object} MultisigMessageProposal
42
+ * @property {string} messageId - The message's hash.
43
+ * @property {string} message - The original message.
44
+ * @property {number} confirmations - The current number of confirmations.
45
+ * @property {number} threshold - The minimum amount of confirmations to sign the message.
46
+ * @property {string | null} combinedSignature - The final combined signature when the threshold is met.
47
+ */
48
+
49
+ /** @interface */
50
+ export class IWalletAccountReadOnlyMultisig extends IWalletAccountReadOnlySimple {
51
+ /**
52
+ * Returns the multisig wallet account info.
53
+ *
54
+ * @returns {Promise<MultisigInfo>} The info.
55
+ */
56
+ async getMultisigInfo () {
57
+ throw new NotImplementedError('getMultisigInfo()')
58
+ }
59
+
60
+ /**
61
+ * Returns a list of proposals by their identifiers.
62
+ *
63
+ * @param {string[]} proposalIds - The list of proposal identifiers.
64
+ * @returns {Promise<Record<string, MultisigProposal | null>>} For each proposal id, the proposal details or
65
+ * null if the proposal has not been found.
66
+ */
67
+ async getProposals (proposalIds) {
68
+ throw new NotImplementedError('getProposals(proposalIds)')
69
+ }
70
+
71
+ /**
72
+ * Returns a proposal by its identifier.
73
+ *
74
+ * @param {string} proposalId - The proposal's identifier.
75
+ * @returns {Promise<MultisigProposal | null>} The proposal details, or null if it has not been found.
76
+ */
77
+ async getProposal (proposalId) {
78
+ throw new NotImplementedError('getProposal(proposalId)')
79
+ }
80
+
81
+ /**
82
+ * Returns a list of message proposals by their hashes.
83
+ *
84
+ * @param {string[]} messageIds - The list of message hashes
85
+ * @returns {Promise<Record<string, MultisigMessageProposal | null>>} For each message hash, the message details or
86
+ * null if the message has not been found.
87
+ */
88
+ async getMessageProposals (messageIds) {
89
+ throw new NotImplementedError('getMessageProposals(messageIds)')
90
+ }
91
+
92
+ /**
93
+ * Returns a message proposal by its identifier.
94
+ *
95
+ * @param {string} messageId - The message's hash.
96
+ * @returns {Promise<MultisigMessageProposal | null>} The message details, or null if it has not been found.
97
+ */
98
+ async getMessageProposal (messageId) {
99
+ throw new NotImplementedError('getMessageProposal(messageId)')
100
+ }
101
+
102
+ /**
103
+ * Quotes the on-chain cost of executing a pending proposal.
104
+ *
105
+ * @param {string} proposalId - The proposal's id.
106
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The execution cost estimate.
107
+ * @throws {NoSuchElementError} If no proposal exists for the given id.
108
+ */
109
+ async quoteExecuteProposal (proposalId) {
110
+ throw new NotImplementedError('quoteExecuteProposal(proposalId)')
111
+ }
112
+ }
@@ -0,0 +1,77 @@
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
+ /**
19
+ * The read-only members shared by every wallet account, single-signer or multisig.
20
+ *
21
+ * This is an internal base interface: it is not exported from the package entry point.
22
+ * Consumers use {@link IWalletAccountReadOnly} or {@link IWalletAccountReadOnlyMultisig},
23
+ * which both extend it.
24
+ *
25
+ * @interface
26
+ */
27
+ export class IWalletAccountReadOnlySimple {
28
+ /**
29
+ * Returns the account's address.
30
+ *
31
+ * @returns {Promise<string>} The account's address.
32
+ */
33
+ async getAddress () {
34
+ throw new NotImplementedError('getAddress()')
35
+ }
36
+
37
+ /**
38
+ * Verifies a message's signature.
39
+ *
40
+ * @param {string} message - The original message.
41
+ * @param {string} signature - The signature to verify.
42
+ * @returns {Promise<boolean>} True if the signature is valid.
43
+ * @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
44
+ */
45
+ async verify (message, signature) {
46
+ throw new NotImplementedError('verify(message, signature)')
47
+ }
48
+
49
+ /**
50
+ * Returns the account's native token balance.
51
+ *
52
+ * @returns {Promise<bigint>} The native token balance.
53
+ */
54
+ async getBalance () {
55
+ throw new NotImplementedError('getBalance()')
56
+ }
57
+
58
+ /**
59
+ * Returns the account balance for a specific token.
60
+ *
61
+ * @param {string} tokenAddress - The smart contract address of the token.
62
+ * @returns {Promise<bigint>} The token balance.
63
+ */
64
+ async getTokenBalance (tokenAddress) {
65
+ throw new NotImplementedError('getTokenBalance(tokenAddress)')
66
+ }
67
+
68
+ /**
69
+ * Returns a transaction's receipt.
70
+ *
71
+ * @param {string} hash - The transaction's hash.
72
+ * @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
73
+ */
74
+ async getTransactionReceipt (hash) {
75
+ throw new NotImplementedError('getTransactionReceipt(hash)')
76
+ }
77
+ }
@@ -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
  /**
@@ -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';
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The read-only members shared by every wallet account, single-signer or multisig.
3
+ *
4
+ * This is an internal base interface: it is not exported from the package entry point.
5
+ * Consumers use {@link IWalletAccountReadOnly} or {@link IWalletAccountReadOnlyMultisig},
6
+ * which both extend it.
7
+ *
8
+ * @interface
9
+ */
10
+ export interface IWalletAccountReadOnlySimple {
11
+ /**
12
+ * Returns the account's address.
13
+ *
14
+ * @returns {Promise<string>} The account's address.
15
+ */
16
+ getAddress(): Promise<string>;
17
+ /**
18
+ * Verifies a message's signature.
19
+ *
20
+ * @param {string} message - The original message.
21
+ * @param {string} signature - The signature to verify.
22
+ * @returns {Promise<boolean>} True if the signature is valid.
23
+ * @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
24
+ */
25
+ verify(message: string, signature: string): Promise<boolean>;
26
+ /**
27
+ * Returns the account's native token balance.
28
+ *
29
+ * @returns {Promise<bigint>} The native token balance.
30
+ */
31
+ getBalance(): Promise<bigint>;
32
+ /**
33
+ * Returns the account balance for a specific token.
34
+ *
35
+ * @param {string} tokenAddress - The smart contract address of the token.
36
+ * @returns {Promise<bigint>} The token balance.
37
+ */
38
+ getTokenBalance(tokenAddress: string): Promise<bigint>;
39
+ /**
40
+ * Returns a transaction's receipt.
41
+ *
42
+ * @param {string} hash - The transaction's hash.
43
+ * @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
44
+ */
45
+ getTransactionReceipt(hash: string): Promise<unknown | null>;
46
+ }
@@ -1,33 +1,5 @@
1
1
  /** @interface */
2
- export interface IWalletAccountReadOnly {
3
- /**
4
- * Returns the account's address.
5
- *
6
- * @returns {Promise<string>} The account's address.
7
- */
8
- getAddress(): Promise<string>;
9
- /**
10
- * Verifies a message's signature.
11
- *
12
- * @param {string} message - The original message.
13
- * @param {string} signature - The signature to verify.
14
- * @returns {Promise<boolean>} True if the signature is valid.
15
- * @throws {Error} If the read-only wallet account class is not able to provide an implementation for the method.
16
- */
17
- verify(message: string, signature: string): Promise<boolean>;
18
- /**
19
- * Returns the account's native token balance.
20
- *
21
- * @returns {Promise<bigint>} The native token balance.
22
- */
23
- getBalance(): Promise<bigint>;
24
- /**
25
- * Returns the account balance for a specific token.
26
- *
27
- * @param {string} tokenAddress - The smart contract address of the token.
28
- * @returns {Promise<bigint>} The token balance.
29
- */
30
- getTokenBalance(tokenAddress: string): Promise<bigint>;
2
+ export interface IWalletAccountReadOnly extends IWalletAccountReadOnlySimple {
31
3
  /**
32
4
  * Quotes the costs of a send transaction operation.
33
5
  *
@@ -42,13 +14,6 @@ export interface IWalletAccountReadOnly {
42
14
  * @returns {Promise<Omit<TransferResult, 'hash'>>} The transfer's quotes.
43
15
  */
44
16
  quoteTransfer(options: TransferOptions): Promise<Omit<TransferResult, "hash">>;
45
- /**
46
- * Returns a transaction's receipt.
47
- *
48
- * @param {string} hash - The transaction's hash.
49
- * @returns {Promise<unknown | null>} The receipt, or null if the transaction has not been included in a block yet.
50
- */
51
- getTransactionReceipt(hash: string): Promise<unknown | null>;
52
17
  }
53
18
  /**
54
19
  * @abstract
@@ -170,3 +135,4 @@ export type TransferResult = {
170
135
  */
171
136
  fee: bigint;
172
137
  };
138
+ import { IWalletAccountReadOnlySimple } from './wallet-account-read-only-simple.js';