@tetherto/wdk-wallet 1.0.0-beta.11 → 1.0.0-beta.13

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.11",
3
+ "version": "1.0.0-beta.13",
4
4
  "description": "A simple package to manage BIP-32 wallets.",
5
5
  "keywords": [
6
6
  "wdk",
package/src/signer.js CHANGED
@@ -15,8 +15,6 @@
15
15
 
16
16
  import { NotImplementedError } from './errors.js'
17
17
 
18
- /** @typedef {import('./wallet-account-read-only.js').Transaction} Transaction */
19
-
20
18
  /**
21
19
  * A minimal, cross-chain signer interface.
22
20
  *
@@ -34,16 +32,6 @@ export class ISigner {
34
32
  throw new NotImplementedError('derive(relPath)')
35
33
  }
36
34
 
37
- /**
38
- * Signs a transaction.
39
- *
40
- * @param {Transaction} tx - The transaction to sign.
41
- * @returns {Promise<unknown>} The signed transaction.
42
- */
43
- async signTransaction (tx) {
44
- throw new NotImplementedError('signTransaction(tx)')
45
- }
46
-
47
35
  /**
48
36
  * Returns the signer's address.
49
37
  *
@@ -29,7 +29,10 @@ import { NotImplementedError } from './errors.js'
29
29
  * @property {Uint8Array | null} privateKey - The private key (null if the account has been disposed).
30
30
  */
31
31
 
32
- /** @interface */
32
+ /**
33
+ * @interface
34
+ * @template [TSignedTransaction=unknown]
35
+ */
33
36
  export class IWalletAccount extends IWalletAccountReadOnly {
34
37
  /**
35
38
  * The derivation path's index of this account.
@@ -72,7 +75,7 @@ export class IWalletAccount extends IWalletAccountReadOnly {
72
75
  * Signs a transaction
73
76
  *
74
77
  * @param {Transaction} tx - The transaction to sign.
75
- * @returns {Promise<unknown>} The signed transaction.
78
+ * @returns {Promise<TSignedTransaction>} The signed transaction.
76
79
  */
77
80
  async signTransaction (tx) {
78
81
  throw new NotImplementedError('signTransaction(tx)')
@@ -92,13 +95,23 @@ export class IWalletAccount extends IWalletAccountReadOnly {
92
95
  /**
93
96
  * Sends a transaction.
94
97
  *
95
- * @param {Transaction} tx - The transaction.
98
+ * @param {Transaction | TSignedTransaction} tx - The transaction.
96
99
  * @returns {Promise<TransactionResult>} The transaction's result.
97
100
  */
98
101
  async sendTransaction (tx) {
99
102
  throw new NotImplementedError('sendTransaction(tx)')
100
103
  }
101
104
 
105
+ /**
106
+ * Quotes the costs of a send transaction operation.
107
+ *
108
+ * @param {Transaction | TSignedTransaction} tx - The transaction.
109
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
110
+ */
111
+ async quoteSendTransaction (tx) {
112
+ throw new NotImplementedError('quoteSendTransaction(tx)')
113
+ }
114
+
102
115
  /**
103
116
  * Transfers a token to another address.
104
117
  *
@@ -12,13 +12,6 @@ export class ISigner {
12
12
  * @throws {SignerError} If the signer does not support derivation.
13
13
  */
14
14
  derive(relPath: string): Promise<ISigner>;
15
- /**
16
- * Signs a transaction.
17
- *
18
- * @param {Transaction} tx - The transaction to sign.
19
- * @returns {Promise<unknown>} The signed transaction.
20
- */
21
- signTransaction(tx: Transaction): Promise<unknown>;
22
15
  /**
23
16
  * Returns the signer's address.
24
17
  *
@@ -30,5 +23,4 @@ export class ISigner {
30
23
  */
31
24
  dispose(): void;
32
25
  }
33
- export type Transaction = import("./wallet-account-read-only.js").Transaction;
34
26
  export type SignerError = import("./errors.js").SignerError;
@@ -1,5 +1,5 @@
1
1
  /** @interface */
2
- export interface IWalletAccount extends IWalletAccountReadOnly {
2
+ export interface IWalletAccount<TSignedTransaction = unknown> extends IWalletAccountReadOnly {
3
3
  /**
4
4
  * The derivation path's index of this account.
5
5
  *
@@ -29,9 +29,9 @@ export interface IWalletAccount extends IWalletAccountReadOnly {
29
29
  * Signs a transaction.
30
30
  *
31
31
  * @param {Transaction} tx - The transaction to sign.
32
- * @returns {Promise<unknown>} The signed transaction.
32
+ * @returns {Promise<TSignedTransaction>} The signed transaction.
33
33
  */
34
- signTransaction(tx: Transaction): Promise<unknown>;
34
+ signTransaction(tx: Transaction): Promise<TSignedTransaction>;
35
35
  /**
36
36
  * Verifies a message's signature.
37
37
  *
@@ -43,10 +43,19 @@ export interface IWalletAccount extends IWalletAccountReadOnly {
43
43
  /**
44
44
  * Sends a transaction.
45
45
  *
46
- * @param {Transaction} tx - The transaction.
46
+ * @overload
47
+ * @param {Transaction | TSignedTransaction} tx - The transaction.
47
48
  * @returns {Promise<TransactionResult>} The transaction's result.
48
49
  */
49
- sendTransaction(tx: Transaction): Promise<TransactionResult>;
50
+ sendTransaction(tx: Transaction | TSignedTransaction): Promise<TransactionResult>;
51
+ /**
52
+ * Quotes the costs of a send transaction operation.
53
+ *
54
+ * @overload
55
+ * @param {Transaction | TSignedTransaction} tx - The transaction.
56
+ * @returns {Promise<Omit<TransactionResult, 'hash'>>} The transaction's quotes.
57
+ */
58
+ quoteSendTransaction(tx: Transaction | TSignedTransaction): Promise<Omit<TransactionResult, "hash">>;
50
59
  /**
51
60
  * Transfers a token to another address.
52
61
  *