@xchainjs/xchain-utxo 0.1.1 → 0.1.3
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/lib/client.d.ts +105 -20
- package/lib/index.d.ts +3 -0
- package/lib/index.esm.js +93 -19
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +93 -19
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
package/lib/client.d.ts
CHANGED
|
@@ -1,66 +1,86 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Balance, BaseXChainClient, ExplorerProviders, FeeEstimateOptions, FeeRate, FeeRates, Fees, FeesWithRates, Protocol, Tx, TxHash, TxHistoryParams, TxsPage } from '@xchainjs/xchain-client';
|
|
2
|
+
import { Balance, BaseXChainClient, ExplorerProviders, FeeEstimateOptions, FeeRate, FeeRates, Fees, FeesWithRates, Protocol, Tx, TxHash, TxHistoryParams, TxParams, TxsPage } from '@xchainjs/xchain-client';
|
|
3
3
|
import { Address, Asset, Chain } from '@xchainjs/xchain-util';
|
|
4
4
|
import { UTXO, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers';
|
|
5
5
|
import { UtxoClientParams } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Abstract base class for creating blockchain clients in the UTXO model.
|
|
8
|
+
*/
|
|
6
9
|
export declare abstract class Client extends BaseXChainClient {
|
|
7
10
|
protected explorerProviders: ExplorerProviders;
|
|
8
11
|
protected dataProviders: UtxoOnlineDataProviders[];
|
|
9
12
|
/**
|
|
10
|
-
* Constructor
|
|
11
|
-
* Client is initialized with network type
|
|
13
|
+
* Constructor for creating a UTXO client instance.
|
|
12
14
|
*
|
|
13
|
-
* @param {Chain} chain
|
|
14
|
-
* @param {UtxoClientParams} params
|
|
15
|
+
* @param {Chain} chain The blockchain chain type.
|
|
16
|
+
* @param {UtxoClientParams} params The parameters required for client initialization.
|
|
15
17
|
*/
|
|
16
18
|
constructor(chain: Chain, params: UtxoClientParams);
|
|
17
19
|
/**
|
|
18
|
-
* Get the explorer
|
|
20
|
+
* Get the explorer URL based on the network.
|
|
19
21
|
*
|
|
20
|
-
* @returns {string} The explorer
|
|
22
|
+
* @returns {string} The explorer URL.
|
|
21
23
|
*/
|
|
22
24
|
getExplorerUrl(): string;
|
|
23
25
|
/**
|
|
24
|
-
* Get the explorer
|
|
26
|
+
* Get the explorer URL for a given address based on the network.
|
|
25
27
|
*
|
|
26
|
-
* @param {
|
|
27
|
-
* @returns {string} The explorer
|
|
28
|
+
* @param {string} address The address to query.
|
|
29
|
+
* @returns {string} The explorer URL for the address.
|
|
28
30
|
*/
|
|
29
31
|
getExplorerAddressUrl(address: string): string;
|
|
30
32
|
/**
|
|
31
|
-
* Get the explorer
|
|
33
|
+
* Get the explorer URL for a given transaction ID based on the network.
|
|
32
34
|
*
|
|
33
|
-
* @param {string} txID The transaction
|
|
34
|
-
* @returns {string} The explorer
|
|
35
|
+
* @param {string} txID The transaction ID.
|
|
36
|
+
* @returns {string} The explorer URL for the transaction.
|
|
35
37
|
*/
|
|
36
38
|
getExplorerTxUrl(txID: string): string;
|
|
37
39
|
/**
|
|
38
|
-
* Get transaction history of a given address with pagination options.
|
|
39
|
-
* By default it will return the transaction history of the current wallet.
|
|
40
|
+
* Get the transaction history of a given address with pagination options.
|
|
40
41
|
*
|
|
41
|
-
* @param {TxHistoryParams} params The options to get transaction history.
|
|
42
|
+
* @param {TxHistoryParams} params The options to get transaction history.
|
|
42
43
|
* @returns {TxsPage} The transaction history.
|
|
43
44
|
*/
|
|
44
45
|
getTransactions(params?: TxHistoryParams): Promise<TxsPage>;
|
|
45
46
|
/**
|
|
46
|
-
* Get the transaction details of a given transaction
|
|
47
|
+
* Get the transaction details of a given transaction ID.
|
|
47
48
|
*
|
|
48
|
-
* @param {string} txId The transaction
|
|
49
|
-
* @returns {Tx} The transaction details
|
|
49
|
+
* @param {string} txId The transaction ID.
|
|
50
|
+
* @returns {Tx} The transaction details.
|
|
50
51
|
*/
|
|
51
52
|
getTransactionData(txId: string): Promise<Tx>;
|
|
52
53
|
/**
|
|
53
54
|
* Gets balance of a given address.
|
|
54
55
|
*
|
|
55
|
-
* @param {Address} address to get balances from
|
|
56
|
+
* @param {Address} address The address to get balances from
|
|
56
57
|
* @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version
|
|
57
58
|
* @param {confirmedOnly} Flag to get balances of confirmed txs only
|
|
58
59
|
*
|
|
59
60
|
* @returns {Balance[]} BTC balances
|
|
60
61
|
*/
|
|
61
62
|
getBalance(address: Address, _assets?: Asset[], confirmedOnly?: boolean): Promise<Balance[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Scan UTXOs for a given address.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} address The address to scan.
|
|
67
|
+
* @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.
|
|
68
|
+
* @returns {UTXO[]} The UTXOs found.
|
|
69
|
+
*/
|
|
62
70
|
protected scanUTXOs(address: string, confirmedOnly?: boolean): Promise<UTXO[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Get estimated fees with fee rates.
|
|
73
|
+
*
|
|
74
|
+
* @param {FeeEstimateOptions} options Options for fee estimation.
|
|
75
|
+
* @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.
|
|
76
|
+
*/
|
|
63
77
|
getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates>;
|
|
78
|
+
/**
|
|
79
|
+
* Get estimated fees.
|
|
80
|
+
*
|
|
81
|
+
* @param {FeeEstimateOptions} options Options for fee estimation.
|
|
82
|
+
* @returns {Promise<Fees>} Estimated fees.
|
|
83
|
+
*/
|
|
64
84
|
getFees(options?: FeeEstimateOptions): Promise<Fees>;
|
|
65
85
|
/**
|
|
66
86
|
* Get fee rates
|
|
@@ -69,13 +89,78 @@ export declare abstract class Client extends BaseXChainClient {
|
|
|
69
89
|
* @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`
|
|
70
90
|
*/
|
|
71
91
|
getFeeRates(protocol?: Protocol): Promise<FeeRates>;
|
|
92
|
+
/**
|
|
93
|
+
* Broadcast a transaction.
|
|
94
|
+
*
|
|
95
|
+
* @param {string} txHex The transaction hex string.
|
|
96
|
+
* @returns {Promise<TxHash>} The transaction hash.
|
|
97
|
+
*/
|
|
72
98
|
broadcastTx(txHex: string): Promise<TxHash>;
|
|
99
|
+
/**
|
|
100
|
+
* Round-robin method to get balance from data providers.
|
|
101
|
+
* Throws error if no provider can get balance.
|
|
102
|
+
*
|
|
103
|
+
* @param {Address} address The address to get balance for.
|
|
104
|
+
* @returns {Promise<Balance[]>} The balances.
|
|
105
|
+
* @throws Error If no provider is able to get balance.
|
|
106
|
+
*/
|
|
73
107
|
protected roundRobinGetBalance(address: Address): Promise<Balance[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Round-robin method to get unspent transactions from data providers.
|
|
110
|
+
* Throws error if no provider can get unspent transactions.
|
|
111
|
+
*
|
|
112
|
+
* @param {Address} address The address to get unspent transactions for.
|
|
113
|
+
* @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.
|
|
114
|
+
* @returns {Promise<UTXO[]>} The unspent transactions.
|
|
115
|
+
* @throws Error If no provider is able to get unspent transactions.
|
|
116
|
+
*/
|
|
74
117
|
protected roundRobinGetUnspentTxs(address: Address, confirmed: boolean): Promise<UTXO[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Round-robin method to get transaction data from data providers.
|
|
120
|
+
* Throws error if no provider can get transaction data.
|
|
121
|
+
*
|
|
122
|
+
* @param {string} txid The transaction ID to get data for.
|
|
123
|
+
* @returns {Promise<Tx>} The transaction data.
|
|
124
|
+
* @throws Error If no provider is able to get transaction data.
|
|
125
|
+
*/
|
|
75
126
|
protected roundRobinGetTransactionData(txid: string): Promise<Tx>;
|
|
127
|
+
/**
|
|
128
|
+
* Round-robin method to get transactions from data providers.
|
|
129
|
+
* Throws error if no provider can get transactions.
|
|
130
|
+
*
|
|
131
|
+
* @param {TxHistoryParams} params The parameters for fetching transactions.
|
|
132
|
+
* @returns {Promise<TxsPage>} The transaction history.
|
|
133
|
+
* @throws Error If no provider is able to get transactions.
|
|
134
|
+
*/
|
|
76
135
|
protected roundRobinGetTransactions(params: TxHistoryParams): Promise<TxsPage>;
|
|
136
|
+
/**
|
|
137
|
+
* Broadcasts a transaction hex using a round-robin approach across multiple data providers.
|
|
138
|
+
* @param {string} txHex The transaction hex to broadcast.
|
|
139
|
+
* @returns {Promise<TxHash>} The hash of the broadcasted transaction.
|
|
140
|
+
* @throws {Error} Throws an error if no provider is able to broadcast the transaction.
|
|
141
|
+
*/
|
|
77
142
|
protected roundRobinBroadcastTx(txHex: string): Promise<string>;
|
|
143
|
+
/**
|
|
144
|
+
* Abstract method to compile a memo.
|
|
145
|
+
* @param {string} memo The memo string to compile.
|
|
146
|
+
* @returns {Buffer} The compiled memo.
|
|
147
|
+
*/
|
|
78
148
|
protected abstract compileMemo(memo: string): Buffer;
|
|
149
|
+
/**
|
|
150
|
+
* Abstract method to calculate the fee from a list of UTXOs.
|
|
151
|
+
* @param {UTXO[]} inputs The list of UTXOs.
|
|
152
|
+
* @param {FeeRate} feeRate The fee rate.
|
|
153
|
+
* @param {Buffer | null} data Optional data buffer.
|
|
154
|
+
* @returns {number} The calculated fee.
|
|
155
|
+
*/
|
|
79
156
|
protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number;
|
|
157
|
+
/**
|
|
158
|
+
* Retrieves fee rates using a round-robin approach across multiple data providers.
|
|
159
|
+
* @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.
|
|
160
|
+
* @throws {Error} Throws an error if no provider is able to retrieve fee rates.
|
|
161
|
+
*/
|
|
80
162
|
protected roundRobinGetFeeRates(): Promise<FeeRates>;
|
|
163
|
+
abstract transfer(params: TxParams & {
|
|
164
|
+
feeRate?: number;
|
|
165
|
+
}): Promise<string>;
|
|
81
166
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Client } from './client';
|
|
2
2
|
import { PreparedTx, UTXO, UtxoClientParams, Witness } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Exported symbols from the `Client`, `UTXO`, `UtxoClientParams`, `Witness`, and `PreparedTx` modules.
|
|
5
|
+
*/
|
|
3
6
|
export { Client, UTXO, UtxoClientParams, Witness, PreparedTx };
|
package/lib/index.esm.js
CHANGED
|
@@ -26,13 +26,15 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Abstract base class for creating blockchain clients in the UTXO model.
|
|
31
|
+
*/
|
|
29
32
|
class Client extends BaseXChainClient {
|
|
30
33
|
/**
|
|
31
|
-
* Constructor
|
|
32
|
-
* Client is initialized with network type
|
|
34
|
+
* Constructor for creating a UTXO client instance.
|
|
33
35
|
*
|
|
34
|
-
* @param {Chain} chain
|
|
35
|
-
* @param {UtxoClientParams} params
|
|
36
|
+
* @param {Chain} chain The blockchain chain type.
|
|
37
|
+
* @param {UtxoClientParams} params The parameters required for client initialization.
|
|
36
38
|
*/
|
|
37
39
|
constructor(chain, params) {
|
|
38
40
|
super(chain, {
|
|
@@ -45,40 +47,40 @@ class Client extends BaseXChainClient {
|
|
|
45
47
|
this.dataProviders = params.dataProviders;
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
48
|
-
* Get the explorer
|
|
50
|
+
* Get the explorer URL based on the network.
|
|
49
51
|
*
|
|
50
|
-
* @returns {string} The explorer
|
|
52
|
+
* @returns {string} The explorer URL.
|
|
51
53
|
*/
|
|
52
54
|
getExplorerUrl() {
|
|
53
55
|
return this.explorerProviders[this.network].getExplorerUrl();
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
|
-
* Get the explorer
|
|
58
|
+
* Get the explorer URL for a given address based on the network.
|
|
57
59
|
*
|
|
58
|
-
* @param {
|
|
59
|
-
* @returns {string} The explorer
|
|
60
|
+
* @param {string} address The address to query.
|
|
61
|
+
* @returns {string} The explorer URL for the address.
|
|
60
62
|
*/
|
|
61
63
|
getExplorerAddressUrl(address) {
|
|
62
64
|
return this.explorerProviders[this.network].getExplorerAddressUrl(address);
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
|
-
* Get the explorer
|
|
67
|
+
* Get the explorer URL for a given transaction ID based on the network.
|
|
66
68
|
*
|
|
67
|
-
* @param {string} txID The transaction
|
|
68
|
-
* @returns {string} The explorer
|
|
69
|
+
* @param {string} txID The transaction ID.
|
|
70
|
+
* @returns {string} The explorer URL for the transaction.
|
|
69
71
|
*/
|
|
70
72
|
getExplorerTxUrl(txID) {
|
|
71
73
|
return this.explorerProviders[this.network].getExplorerTxUrl(txID);
|
|
72
74
|
}
|
|
73
75
|
/**
|
|
74
|
-
* Get transaction history of a given address with pagination options.
|
|
75
|
-
* By default it will return the transaction history of the current wallet.
|
|
76
|
+
* Get the transaction history of a given address with pagination options.
|
|
76
77
|
*
|
|
77
|
-
* @param {TxHistoryParams} params The options to get transaction history.
|
|
78
|
+
* @param {TxHistoryParams} params The options to get transaction history.
|
|
78
79
|
* @returns {TxsPage} The transaction history.
|
|
79
80
|
*/
|
|
80
81
|
getTransactions(params) {
|
|
81
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
// Filter the parameters for transaction history
|
|
82
84
|
const filteredParams = {
|
|
83
85
|
address: (params === null || params === void 0 ? void 0 : params.address) || (yield this.getAddress()),
|
|
84
86
|
offset: params === null || params === void 0 ? void 0 : params.offset,
|
|
@@ -90,10 +92,10 @@ class Client extends BaseXChainClient {
|
|
|
90
92
|
});
|
|
91
93
|
}
|
|
92
94
|
/**
|
|
93
|
-
* Get the transaction details of a given transaction
|
|
95
|
+
* Get the transaction details of a given transaction ID.
|
|
94
96
|
*
|
|
95
|
-
* @param {string} txId The transaction
|
|
96
|
-
* @returns {Tx} The transaction details
|
|
97
|
+
* @param {string} txId The transaction ID.
|
|
98
|
+
* @returns {Tx} The transaction details.
|
|
97
99
|
*/
|
|
98
100
|
getTransactionData(txId) {
|
|
99
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -103,7 +105,7 @@ class Client extends BaseXChainClient {
|
|
|
103
105
|
/**
|
|
104
106
|
* Gets balance of a given address.
|
|
105
107
|
*
|
|
106
|
-
* @param {Address} address to get balances from
|
|
108
|
+
* @param {Address} address The address to get balances from
|
|
107
109
|
* @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version
|
|
108
110
|
* @param {confirmedOnly} Flag to get balances of confirmed txs only
|
|
109
111
|
*
|
|
@@ -116,15 +118,31 @@ class Client extends BaseXChainClient {
|
|
|
116
118
|
return yield this.roundRobinGetBalance(address);
|
|
117
119
|
});
|
|
118
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Scan UTXOs for a given address.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} address The address to scan.
|
|
125
|
+
* @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.
|
|
126
|
+
* @returns {UTXO[]} The UTXOs found.
|
|
127
|
+
*/
|
|
119
128
|
scanUTXOs(address, confirmedOnly = true) {
|
|
120
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
130
|
return this.roundRobinGetUnspentTxs(address, confirmedOnly);
|
|
122
131
|
});
|
|
123
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Get estimated fees with fee rates.
|
|
135
|
+
*
|
|
136
|
+
* @param {FeeEstimateOptions} options Options for fee estimation.
|
|
137
|
+
* @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.
|
|
138
|
+
*/
|
|
124
139
|
getFeesWithRates(options) {
|
|
125
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
// Scan UTXOs if sender address is provided
|
|
126
142
|
const utxos = (options === null || options === void 0 ? void 0 : options.sender) ? yield this.scanUTXOs(options.sender, false) : [];
|
|
143
|
+
// Compile memo if memo is provided
|
|
127
144
|
const compiledMemo = (options === null || options === void 0 ? void 0 : options.memo) ? this.compileMemo(options.memo) : null;
|
|
145
|
+
// Get fee rates
|
|
128
146
|
const rates = yield this.getFeeRates();
|
|
129
147
|
return {
|
|
130
148
|
fees: {
|
|
@@ -137,6 +155,12 @@ class Client extends BaseXChainClient {
|
|
|
137
155
|
};
|
|
138
156
|
});
|
|
139
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Get estimated fees.
|
|
160
|
+
*
|
|
161
|
+
* @param {FeeEstimateOptions} options Options for fee estimation.
|
|
162
|
+
* @returns {Promise<Fees>} Estimated fees.
|
|
163
|
+
*/
|
|
140
164
|
getFees(options) {
|
|
141
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
142
166
|
const { fees } = yield this.getFeesWithRates(options);
|
|
@@ -173,11 +197,25 @@ class Client extends BaseXChainClient {
|
|
|
173
197
|
throw Error('Can not retrieve fee rates');
|
|
174
198
|
});
|
|
175
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Broadcast a transaction.
|
|
202
|
+
*
|
|
203
|
+
* @param {string} txHex The transaction hex string.
|
|
204
|
+
* @returns {Promise<TxHash>} The transaction hash.
|
|
205
|
+
*/
|
|
176
206
|
broadcastTx(txHex) {
|
|
177
207
|
return __awaiter(this, void 0, void 0, function* () {
|
|
178
208
|
return yield this.roundRobinBroadcastTx(txHex);
|
|
179
209
|
});
|
|
180
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Round-robin method to get balance from data providers.
|
|
213
|
+
* Throws error if no provider can get balance.
|
|
214
|
+
*
|
|
215
|
+
* @param {Address} address The address to get balance for.
|
|
216
|
+
* @returns {Promise<Balance[]>} The balances.
|
|
217
|
+
* @throws Error If no provider is able to get balance.
|
|
218
|
+
*/
|
|
181
219
|
roundRobinGetBalance(address) {
|
|
182
220
|
return __awaiter(this, void 0, void 0, function* () {
|
|
183
221
|
for (const provider of this.dataProviders) {
|
|
@@ -193,6 +231,15 @@ class Client extends BaseXChainClient {
|
|
|
193
231
|
throw Error('no provider able to get balance');
|
|
194
232
|
});
|
|
195
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Round-robin method to get unspent transactions from data providers.
|
|
236
|
+
* Throws error if no provider can get unspent transactions.
|
|
237
|
+
*
|
|
238
|
+
* @param {Address} address The address to get unspent transactions for.
|
|
239
|
+
* @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.
|
|
240
|
+
* @returns {Promise<UTXO[]>} The unspent transactions.
|
|
241
|
+
* @throws Error If no provider is able to get unspent transactions.
|
|
242
|
+
*/
|
|
196
243
|
roundRobinGetUnspentTxs(address, confirmed) {
|
|
197
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
198
245
|
for (const provider of this.dataProviders) {
|
|
@@ -209,6 +256,14 @@ class Client extends BaseXChainClient {
|
|
|
209
256
|
throw Error('no provider able to GetUnspentTxs');
|
|
210
257
|
});
|
|
211
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Round-robin method to get transaction data from data providers.
|
|
261
|
+
* Throws error if no provider can get transaction data.
|
|
262
|
+
*
|
|
263
|
+
* @param {string} txid The transaction ID to get data for.
|
|
264
|
+
* @returns {Promise<Tx>} The transaction data.
|
|
265
|
+
* @throws Error If no provider is able to get transaction data.
|
|
266
|
+
*/
|
|
212
267
|
roundRobinGetTransactionData(txid) {
|
|
213
268
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
269
|
for (const provider of this.dataProviders) {
|
|
@@ -224,6 +279,14 @@ class Client extends BaseXChainClient {
|
|
|
224
279
|
throw Error('no provider able to GetTransactionData');
|
|
225
280
|
});
|
|
226
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Round-robin method to get transactions from data providers.
|
|
284
|
+
* Throws error if no provider can get transactions.
|
|
285
|
+
*
|
|
286
|
+
* @param {TxHistoryParams} params The parameters for fetching transactions.
|
|
287
|
+
* @returns {Promise<TxsPage>} The transaction history.
|
|
288
|
+
* @throws Error If no provider is able to get transactions.
|
|
289
|
+
*/
|
|
227
290
|
roundRobinGetTransactions(params) {
|
|
228
291
|
return __awaiter(this, void 0, void 0, function* () {
|
|
229
292
|
for (const provider of this.dataProviders) {
|
|
@@ -239,6 +302,12 @@ class Client extends BaseXChainClient {
|
|
|
239
302
|
throw Error('no provider able to GetTransactions');
|
|
240
303
|
});
|
|
241
304
|
}
|
|
305
|
+
/**
|
|
306
|
+
* Broadcasts a transaction hex using a round-robin approach across multiple data providers.
|
|
307
|
+
* @param {string} txHex The transaction hex to broadcast.
|
|
308
|
+
* @returns {Promise<TxHash>} The hash of the broadcasted transaction.
|
|
309
|
+
* @throws {Error} Throws an error if no provider is able to broadcast the transaction.
|
|
310
|
+
*/
|
|
242
311
|
roundRobinBroadcastTx(txHex) {
|
|
243
312
|
return __awaiter(this, void 0, void 0, function* () {
|
|
244
313
|
for (const provider of this.dataProviders) {
|
|
@@ -254,6 +323,11 @@ class Client extends BaseXChainClient {
|
|
|
254
323
|
throw Error('no provider able to BroadcastTx');
|
|
255
324
|
});
|
|
256
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Retrieves fee rates using a round-robin approach across multiple data providers.
|
|
328
|
+
* @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.
|
|
329
|
+
* @throws {Error} Throws an error if no provider is able to retrieve fee rates.
|
|
330
|
+
*/
|
|
257
331
|
roundRobinGetFeeRates() {
|
|
258
332
|
return __awaiter(this, void 0, void 0, function* () {
|
|
259
333
|
for (const provider of this.dataProviders) {
|
package/lib/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/client.ts"],"sourcesContent":["import {\n Balance,\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n Tx,\n TxHash,\n TxHistoryParams,\n TxsPage,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UTXO, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { UtxoClientParams } from './types'\n\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor\n * Client is initialized with network type\n *\n * @param {Chain} chain Chain to instantiate the client with\n * @param {UtxoClientParams} params\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer url.\n *\n * @returns {string} The explorer url based on the network.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer url for the given address.\n *\n * @param {Address} address\n * @returns {string} The explorer url for the given address based on the network.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer url for the given transaction id.\n *\n * @param {string} txID The transaction id\n * @returns {string} The explorer url for the given transaction id based on the network.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get transaction history of a given address with pagination options.\n * By default it will return the transaction history of the current wallet.\n *\n * @param {TxHistoryParams} params The options to get transaction history. (optional)\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction id.\n *\n * @param {string} txId The transaction id.\n * @returns {Tx} The transaction details of the given transaction id.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // TODO figure this out ---> !!confirmedOnly)\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address, undefined)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n\n protected abstract compileMemo(memo: string): Buffer\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()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ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n Tx,\n TxHash,\n TxHistoryParams,\n TxParams,\n TxsPage,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UTXO, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { UtxoClientParams } from './types'\n/**\n * Abstract base class for creating blockchain clients in the UTXO model.\n */\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor for creating a UTXO client instance.\n *\n * @param {Chain} chain The blockchain chain type.\n * @param {UtxoClientParams} params The parameters required for client initialization.\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer URL based on the network.\n *\n * @returns {string} The explorer URL.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer URL for a given address based on the network.\n *\n * @param {string} address The address to query.\n * @returns {string} The explorer URL for the address.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer URL for a given transaction ID based on the network.\n *\n * @param {string} txID The transaction ID.\n * @returns {string} The explorer URL for the transaction.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get the transaction history of a given address with pagination options.\n *\n * @param {TxHistoryParams} params The options to get transaction history.\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n // Filter the parameters for transaction history\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction ID.\n *\n * @param {string} txId The transaction ID.\n * @returns {Tx} The transaction details.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address The address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // The actual logic for getting balances\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n /**\n * Scan UTXOs for a given address.\n *\n * @param {string} address The address to scan.\n * @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.\n * @returns {UTXO[]} The UTXOs found.\n */\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n /**\n * Get estimated fees with fee rates.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.\n */\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n // Scan UTXOs if sender address is provided\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n // Compile memo if memo is provided\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n // Get fee rates\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n /**\n * Get estimated fees.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<Fees>} Estimated fees.\n */\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n /**\n * Broadcast a transaction.\n *\n * @param {string} txHex The transaction hex string.\n * @returns {Promise<TxHash>} The transaction hash.\n */\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n /**\n * Round-robin method to get balance from data providers.\n * Throws error if no provider can get balance.\n *\n * @param {Address} address The address to get balance for.\n * @returns {Promise<Balance[]>} The balances.\n * @throws Error If no provider is able to get balance.\n */\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address, undefined)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n /**\n * Round-robin method to get unspent transactions from data providers.\n * Throws error if no provider can get unspent transactions.\n *\n * @param {Address} address The address to get unspent transactions for.\n * @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.\n * @returns {Promise<UTXO[]>} The unspent transactions.\n * @throws Error If no provider is able to get unspent transactions.\n */\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n /**\n * Round-robin method to get transaction data from data providers.\n * Throws error if no provider can get transaction data.\n *\n * @param {string} txid The transaction ID to get data for.\n * @returns {Promise<Tx>} The transaction data.\n * @throws Error If no provider is able to get transaction data.\n */\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n /**\n * Round-robin method to get transactions from data providers.\n * Throws error if no provider can get transactions.\n *\n * @param {TxHistoryParams} params The parameters for fetching transactions.\n * @returns {Promise<TxsPage>} The transaction history.\n * @throws Error If no provider is able to get transactions.\n */\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n /**\n * Broadcasts a transaction hex using a round-robin approach across multiple data providers.\n * @param {string} txHex The transaction hex to broadcast.\n * @returns {Promise<TxHash>} The hash of the broadcasted transaction.\n * @throws {Error} Throws an error if no provider is able to broadcast the transaction.\n */\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n /**\n * Abstract method to compile a memo.\n * @param {string} memo The memo string to compile.\n * @returns {Buffer} The compiled memo.\n */\n protected abstract compileMemo(memo: string): Buffer\n /**\n * Abstract method to calculate the fee from a list of UTXOs.\n * @param {UTXO[]} inputs The list of UTXOs.\n * @param {FeeRate} feeRate The fee rate.\n * @param {Buffer | null} data Optional data buffer.\n * @returns {number} The calculated fee.\n */\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n /**\n * Retrieves fee rates using a round-robin approach across multiple data providers.\n * @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.\n * @throws {Error} Throws an error if no provider is able to retrieve fee rates.\n */\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n public abstract transfer(params: TxParams & { feeRate?: number }): Promise<string>\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;AAEG;AACG,MAAgB,MAAO,SAAQ,gBAAgB,CAAA;AAInD;;;;;AAKG;IACH,WAAY,CAAA,KAAY,EAAE,MAAwB,EAAA;QAChD,KAAK,CAAC,KAAK,EAAE;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;YAC/C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;AAC5B,SAAA,CAAC,CAAA;AACF,QAAA,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;AACjD,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;KAC1C;AAED;;;;AAIG;IACH,cAAc,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,CAAA;KAC7D;AAED;;;;;AAKG;AACH,IAAA,qB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C,IAAI,CAAC,KAAK,CAAC,CAAA;AACpB,iBAAA;AACF,aAAA;AACD,YAAA,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAA;SAC/C,CAAA,CAAA;AAAA,KAAA;AAeD;;;;AAIG;IACa,qBAAqB,GAAA;;AACnC,YAAA,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,aAAa,EAAE;gBACzC,IAAI;oBACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACnC,oBAAA,IAAI,IAAI;AAAE,wBAAA,OAAO,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;AAC1C,iBAAA;AAAC,gBAAA,OAAO,KAAK,EAAE;AACd,oBAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACpB,iBAAA;AACF,aAAA;AACD,YAAA,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAA;SACjD,CAAA,CAAA;AAAA,KAAA;AAEF;;;;"}
|
package/lib/index.js
CHANGED
|
@@ -30,13 +30,15 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Abstract base class for creating blockchain clients in the UTXO model.
|
|
35
|
+
*/
|
|
33
36
|
class Client extends xchainClient.BaseXChainClient {
|
|
34
37
|
/**
|
|
35
|
-
* Constructor
|
|
36
|
-
* Client is initialized with network type
|
|
38
|
+
* Constructor for creating a UTXO client instance.
|
|
37
39
|
*
|
|
38
|
-
* @param {Chain} chain
|
|
39
|
-
* @param {UtxoClientParams} params
|
|
40
|
+
* @param {Chain} chain The blockchain chain type.
|
|
41
|
+
* @param {UtxoClientParams} params The parameters required for client initialization.
|
|
40
42
|
*/
|
|
41
43
|
constructor(chain, params) {
|
|
42
44
|
super(chain, {
|
|
@@ -49,40 +51,40 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
49
51
|
this.dataProviders = params.dataProviders;
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
|
-
* Get the explorer
|
|
54
|
+
* Get the explorer URL based on the network.
|
|
53
55
|
*
|
|
54
|
-
* @returns {string} The explorer
|
|
56
|
+
* @returns {string} The explorer URL.
|
|
55
57
|
*/
|
|
56
58
|
getExplorerUrl() {
|
|
57
59
|
return this.explorerProviders[this.network].getExplorerUrl();
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
|
-
* Get the explorer
|
|
62
|
+
* Get the explorer URL for a given address based on the network.
|
|
61
63
|
*
|
|
62
|
-
* @param {
|
|
63
|
-
* @returns {string} The explorer
|
|
64
|
+
* @param {string} address The address to query.
|
|
65
|
+
* @returns {string} The explorer URL for the address.
|
|
64
66
|
*/
|
|
65
67
|
getExplorerAddressUrl(address) {
|
|
66
68
|
return this.explorerProviders[this.network].getExplorerAddressUrl(address);
|
|
67
69
|
}
|
|
68
70
|
/**
|
|
69
|
-
* Get the explorer
|
|
71
|
+
* Get the explorer URL for a given transaction ID based on the network.
|
|
70
72
|
*
|
|
71
|
-
* @param {string} txID The transaction
|
|
72
|
-
* @returns {string} The explorer
|
|
73
|
+
* @param {string} txID The transaction ID.
|
|
74
|
+
* @returns {string} The explorer URL for the transaction.
|
|
73
75
|
*/
|
|
74
76
|
getExplorerTxUrl(txID) {
|
|
75
77
|
return this.explorerProviders[this.network].getExplorerTxUrl(txID);
|
|
76
78
|
}
|
|
77
79
|
/**
|
|
78
|
-
* Get transaction history of a given address with pagination options.
|
|
79
|
-
* By default it will return the transaction history of the current wallet.
|
|
80
|
+
* Get the transaction history of a given address with pagination options.
|
|
80
81
|
*
|
|
81
|
-
* @param {TxHistoryParams} params The options to get transaction history.
|
|
82
|
+
* @param {TxHistoryParams} params The options to get transaction history.
|
|
82
83
|
* @returns {TxsPage} The transaction history.
|
|
83
84
|
*/
|
|
84
85
|
getTransactions(params) {
|
|
85
86
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
// Filter the parameters for transaction history
|
|
86
88
|
const filteredParams = {
|
|
87
89
|
address: (params === null || params === void 0 ? void 0 : params.address) || (yield this.getAddress()),
|
|
88
90
|
offset: params === null || params === void 0 ? void 0 : params.offset,
|
|
@@ -94,10 +96,10 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
94
96
|
});
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
97
|
-
* Get the transaction details of a given transaction
|
|
99
|
+
* Get the transaction details of a given transaction ID.
|
|
98
100
|
*
|
|
99
|
-
* @param {string} txId The transaction
|
|
100
|
-
* @returns {Tx} The transaction details
|
|
101
|
+
* @param {string} txId The transaction ID.
|
|
102
|
+
* @returns {Tx} The transaction details.
|
|
101
103
|
*/
|
|
102
104
|
getTransactionData(txId) {
|
|
103
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -107,7 +109,7 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
107
109
|
/**
|
|
108
110
|
* Gets balance of a given address.
|
|
109
111
|
*
|
|
110
|
-
* @param {Address} address to get balances from
|
|
112
|
+
* @param {Address} address The address to get balances from
|
|
111
113
|
* @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version
|
|
112
114
|
* @param {confirmedOnly} Flag to get balances of confirmed txs only
|
|
113
115
|
*
|
|
@@ -120,15 +122,31 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
120
122
|
return yield this.roundRobinGetBalance(address);
|
|
121
123
|
});
|
|
122
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Scan UTXOs for a given address.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} address The address to scan.
|
|
129
|
+
* @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.
|
|
130
|
+
* @returns {UTXO[]} The UTXOs found.
|
|
131
|
+
*/
|
|
123
132
|
scanUTXOs(address, confirmedOnly = true) {
|
|
124
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
125
134
|
return this.roundRobinGetUnspentTxs(address, confirmedOnly);
|
|
126
135
|
});
|
|
127
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Get estimated fees with fee rates.
|
|
139
|
+
*
|
|
140
|
+
* @param {FeeEstimateOptions} options Options for fee estimation.
|
|
141
|
+
* @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.
|
|
142
|
+
*/
|
|
128
143
|
getFeesWithRates(options) {
|
|
129
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
// Scan UTXOs if sender address is provided
|
|
130
146
|
const utxos = (options === null || options === void 0 ? void 0 : options.sender) ? yield this.scanUTXOs(options.sender, false) : [];
|
|
147
|
+
// Compile memo if memo is provided
|
|
131
148
|
const compiledMemo = (options === null || options === void 0 ? void 0 : options.memo) ? this.compileMemo(options.memo) : null;
|
|
149
|
+
// Get fee rates
|
|
132
150
|
const rates = yield this.getFeeRates();
|
|
133
151
|
return {
|
|
134
152
|
fees: {
|
|
@@ -141,6 +159,12 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
141
159
|
};
|
|
142
160
|
});
|
|
143
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Get estimated fees.
|
|
164
|
+
*
|
|
165
|
+
* @param {FeeEstimateOptions} options Options for fee estimation.
|
|
166
|
+
* @returns {Promise<Fees>} Estimated fees.
|
|
167
|
+
*/
|
|
144
168
|
getFees(options) {
|
|
145
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
170
|
const { fees } = yield this.getFeesWithRates(options);
|
|
@@ -177,11 +201,25 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
177
201
|
throw Error('Can not retrieve fee rates');
|
|
178
202
|
});
|
|
179
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Broadcast a transaction.
|
|
206
|
+
*
|
|
207
|
+
* @param {string} txHex The transaction hex string.
|
|
208
|
+
* @returns {Promise<TxHash>} The transaction hash.
|
|
209
|
+
*/
|
|
180
210
|
broadcastTx(txHex) {
|
|
181
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
212
|
return yield this.roundRobinBroadcastTx(txHex);
|
|
183
213
|
});
|
|
184
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Round-robin method to get balance from data providers.
|
|
217
|
+
* Throws error if no provider can get balance.
|
|
218
|
+
*
|
|
219
|
+
* @param {Address} address The address to get balance for.
|
|
220
|
+
* @returns {Promise<Balance[]>} The balances.
|
|
221
|
+
* @throws Error If no provider is able to get balance.
|
|
222
|
+
*/
|
|
185
223
|
roundRobinGetBalance(address) {
|
|
186
224
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
225
|
for (const provider of this.dataProviders) {
|
|
@@ -197,6 +235,15 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
197
235
|
throw Error('no provider able to get balance');
|
|
198
236
|
});
|
|
199
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Round-robin method to get unspent transactions from data providers.
|
|
240
|
+
* Throws error if no provider can get unspent transactions.
|
|
241
|
+
*
|
|
242
|
+
* @param {Address} address The address to get unspent transactions for.
|
|
243
|
+
* @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.
|
|
244
|
+
* @returns {Promise<UTXO[]>} The unspent transactions.
|
|
245
|
+
* @throws Error If no provider is able to get unspent transactions.
|
|
246
|
+
*/
|
|
200
247
|
roundRobinGetUnspentTxs(address, confirmed) {
|
|
201
248
|
return __awaiter(this, void 0, void 0, function* () {
|
|
202
249
|
for (const provider of this.dataProviders) {
|
|
@@ -213,6 +260,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
213
260
|
throw Error('no provider able to GetUnspentTxs');
|
|
214
261
|
});
|
|
215
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Round-robin method to get transaction data from data providers.
|
|
265
|
+
* Throws error if no provider can get transaction data.
|
|
266
|
+
*
|
|
267
|
+
* @param {string} txid The transaction ID to get data for.
|
|
268
|
+
* @returns {Promise<Tx>} The transaction data.
|
|
269
|
+
* @throws Error If no provider is able to get transaction data.
|
|
270
|
+
*/
|
|
216
271
|
roundRobinGetTransactionData(txid) {
|
|
217
272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
218
273
|
for (const provider of this.dataProviders) {
|
|
@@ -228,6 +283,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
228
283
|
throw Error('no provider able to GetTransactionData');
|
|
229
284
|
});
|
|
230
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Round-robin method to get transactions from data providers.
|
|
288
|
+
* Throws error if no provider can get transactions.
|
|
289
|
+
*
|
|
290
|
+
* @param {TxHistoryParams} params The parameters for fetching transactions.
|
|
291
|
+
* @returns {Promise<TxsPage>} The transaction history.
|
|
292
|
+
* @throws Error If no provider is able to get transactions.
|
|
293
|
+
*/
|
|
231
294
|
roundRobinGetTransactions(params) {
|
|
232
295
|
return __awaiter(this, void 0, void 0, function* () {
|
|
233
296
|
for (const provider of this.dataProviders) {
|
|
@@ -243,6 +306,12 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
243
306
|
throw Error('no provider able to GetTransactions');
|
|
244
307
|
});
|
|
245
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Broadcasts a transaction hex using a round-robin approach across multiple data providers.
|
|
311
|
+
* @param {string} txHex The transaction hex to broadcast.
|
|
312
|
+
* @returns {Promise<TxHash>} The hash of the broadcasted transaction.
|
|
313
|
+
* @throws {Error} Throws an error if no provider is able to broadcast the transaction.
|
|
314
|
+
*/
|
|
246
315
|
roundRobinBroadcastTx(txHex) {
|
|
247
316
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
317
|
for (const provider of this.dataProviders) {
|
|
@@ -258,6 +327,11 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
258
327
|
throw Error('no provider able to BroadcastTx');
|
|
259
328
|
});
|
|
260
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Retrieves fee rates using a round-robin approach across multiple data providers.
|
|
332
|
+
* @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.
|
|
333
|
+
* @throws {Error} Throws an error if no provider is able to retrieve fee rates.
|
|
334
|
+
*/
|
|
261
335
|
roundRobinGetFeeRates() {
|
|
262
336
|
return __awaiter(this, void 0, void 0, function* () {
|
|
263
337
|
for (const provider of this.dataProviders) {
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/client.ts"],"sourcesContent":["import {\n Balance,\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n Tx,\n TxHash,\n TxHistoryParams,\n TxsPage,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UTXO, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { UtxoClientParams } from './types'\n\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor\n * Client is initialized with network type\n *\n * @param {Chain} chain Chain to instantiate the client with\n * @param {UtxoClientParams} params\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer url.\n *\n * @returns {string} The explorer url based on the network.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer url for the given address.\n *\n * @param {Address} address\n * @returns {string} The explorer url for the given address based on the network.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer url for the given transaction id.\n *\n * @param {string} txID The transaction id\n * @returns {string} The explorer url for the given transaction id based on the network.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get transaction history of a given address with pagination options.\n * By default it will return the transaction history of the current wallet.\n *\n * @param {TxHistoryParams} params The options to get transaction history. (optional)\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction id.\n *\n * @param {string} txId The transaction id.\n * @returns {Tx} The transaction details of the given transaction id.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // TODO figure this out ---> !!confirmedOnly)\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address, undefined)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n\n protected abstract compileMemo(memo: string): Buffer\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n}\n"],"names":["BaseXChainClient","baseAmount","FeeType","Protocol","standardFeeRates"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBM,MAAgB,MAAO,SAAQA,6BAAgB,CAAA;AAInD;;;;;;AAMG;IACH,WAAY,CAAA,KAAY,EAAE,MAAwB,EAAA;QAChD,KAAK,CAAC,KAAK,EAAE;YACX,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;YAC/C,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,SAAS,EAAE,MAAM,CAAC,SAAS;AAC5B,SAAA,CAAC,CAAA;AACF,QAAA,IAAI,CAAC,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAA;AACjD,QAAA,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;KAC1C;AAED;;;;AAIG;IACH,cAAc,GAAA;QACZ,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,CAAA;KAC7D;AAED;;;;;AAKG;AACH,IAAA,qBAAqB,CAAC,OAAe,EAAA;AACnC,QAAA,OAAO,IAAI,CAAC,iBAA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,IAAI,CAAC,aAAa,EAAE;gBACzC,IAAI;oBACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACnC,oBAAA,IAAI,IAAI;AAAE,wBAAA,OAAO,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;AAC1C,iBAAA;AAAC,gBAAA,OAAO,KAAK,EAAE;AACd,oBAAA,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACpB,iBAAA;AACF,aAAA;AACD,YAAA,MAAM,KAAK,CAAC,mCAAmC,CAAC,CAAA;SACjD,CAAA,CAAA;AAAA,KAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/client.ts"],"sourcesContent":["import {\n Balance,\n BaseXChainClient,\n ExplorerProviders,\n FeeEstimateOptions,\n FeeRate,\n FeeRates,\n FeeType,\n Fees,\n FeesWithRates,\n Protocol,\n Tx,\n TxHash,\n TxHistoryParams,\n TxParams,\n TxsPage,\n standardFeeRates,\n} from '@xchainjs/xchain-client'\nimport { Address, Asset, Chain, baseAmount } from '@xchainjs/xchain-util'\nimport { UTXO, UtxoOnlineDataProviders } from '@xchainjs/xchain-utxo-providers'\n\nimport { UtxoClientParams } from './types'\n/**\n * Abstract base class for creating blockchain clients in the UTXO model.\n */\nexport abstract class Client extends BaseXChainClient {\n protected explorerProviders: ExplorerProviders\n protected dataProviders: UtxoOnlineDataProviders[]\n\n /**\n * Constructor for creating a UTXO client instance.\n *\n * @param {Chain} chain The blockchain chain type.\n * @param {UtxoClientParams} params The parameters required for client initialization.\n */\n constructor(chain: Chain, params: UtxoClientParams) {\n super(chain, {\n network: params.network,\n rootDerivationPaths: params.rootDerivationPaths,\n phrase: params.phrase,\n feeBounds: params.feeBounds,\n })\n this.explorerProviders = params.explorerProviders\n this.dataProviders = params.dataProviders\n }\n\n /**\n * Get the explorer URL based on the network.\n *\n * @returns {string} The explorer URL.\n */\n getExplorerUrl(): string {\n return this.explorerProviders[this.network].getExplorerUrl()\n }\n\n /**\n * Get the explorer URL for a given address based on the network.\n *\n * @param {string} address The address to query.\n * @returns {string} The explorer URL for the address.\n */\n getExplorerAddressUrl(address: string): string {\n return this.explorerProviders[this.network].getExplorerAddressUrl(address)\n }\n\n /**\n * Get the explorer URL for a given transaction ID based on the network.\n *\n * @param {string} txID The transaction ID.\n * @returns {string} The explorer URL for the transaction.\n */\n getExplorerTxUrl(txID: string): string {\n return this.explorerProviders[this.network].getExplorerTxUrl(txID)\n }\n\n /**\n * Get the transaction history of a given address with pagination options.\n *\n * @param {TxHistoryParams} params The options to get transaction history.\n * @returns {TxsPage} The transaction history.\n */\n async getTransactions(params?: TxHistoryParams): Promise<TxsPage> {\n // Filter the parameters for transaction history\n const filteredParams: TxHistoryParams = {\n address: params?.address || (await this.getAddress()),\n offset: params?.offset,\n limit: params?.limit,\n startTime: params?.startTime,\n asset: params?.asset,\n }\n\n return await this.roundRobinGetTransactions(filteredParams)\n }\n\n /**\n * Get the transaction details of a given transaction ID.\n *\n * @param {string} txId The transaction ID.\n * @returns {Tx} The transaction details.\n */\n async getTransactionData(txId: string): Promise<Tx> {\n return await this.roundRobinGetTransactionData(txId)\n }\n\n /**\n * Gets balance of a given address.\n *\n * @param {Address} address The address to get balances from\n * @param {undefined} Needed for legacy only to be in common with `XChainClient` interface - will be removed by a next version\n * @param {confirmedOnly} Flag to get balances of confirmed txs only\n *\n * @returns {Balance[]} BTC balances\n */\n // TODO (@xchain-team|@veado) Change params to be an object to be extendable more easily\n // see changes for `xchain-bitcoin` https://github.com/xchainjs/xchainjs-lib/pull/490\n async getBalance(address: Address, _assets?: Asset[] /* not used */, confirmedOnly?: boolean): Promise<Balance[]> {\n // The actual logic for getting balances\n confirmedOnly\n return await this.roundRobinGetBalance(address)\n }\n /**\n * Scan UTXOs for a given address.\n *\n * @param {string} address The address to scan.\n * @param {boolean} confirmedOnly Flag to scan only confirmed UTXOs.\n * @returns {UTXO[]} The UTXOs found.\n */\n protected async scanUTXOs(\n address: string,\n confirmedOnly = true, // default: scan only confirmed UTXOs\n ): Promise<UTXO[]> {\n return this.roundRobinGetUnspentTxs(address, confirmedOnly)\n }\n /**\n * Get estimated fees with fee rates.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<FeesWithRates>} Estimated fees along with fee rates.\n */\n async getFeesWithRates(options?: FeeEstimateOptions): Promise<FeesWithRates> {\n // Scan UTXOs if sender address is provided\n const utxos = options?.sender ? await this.scanUTXOs(options.sender, false) : []\n // Compile memo if memo is provided\n const compiledMemo = options?.memo ? this.compileMemo(options.memo) : null\n // Get fee rates\n const rates = await this.getFeeRates()\n\n return {\n fees: {\n average: baseAmount(this.getFeeFromUtxos(utxos, rates.average, compiledMemo)),\n fast: baseAmount(this.getFeeFromUtxos(utxos, rates.fast, compiledMemo)),\n fastest: baseAmount(this.getFeeFromUtxos(utxos, rates.fastest, compiledMemo)),\n type: FeeType.PerByte,\n },\n rates,\n }\n }\n /**\n * Get estimated fees.\n *\n * @param {FeeEstimateOptions} options Options for fee estimation.\n * @returns {Promise<Fees>} Estimated fees.\n */\n async getFees(options?: FeeEstimateOptions): Promise<Fees> {\n const { fees } = await this.getFeesWithRates(options)\n return fees\n }\n\n /**\n * Get fee rates\n * @param {Protocol} protocol Protocol to interact with. If there's no protocol provided, fee rates are retrieved from chain data providers\n *\n * @returns {FeeRates} The fee rates (average, fast, fastest) in `Satoshis/byte`\n */\n async getFeeRates(protocol?: Protocol): Promise<FeeRates> {\n if (!protocol) {\n try {\n const feeRates = await this.roundRobinGetFeeRates()\n return feeRates\n } catch (error) {\n console.warn('Can not retrieve fee rates from provider')\n }\n }\n\n if (!protocol || Protocol.THORCHAIN) {\n try {\n const feeRate = await this.getFeeRateFromThorchain()\n return standardFeeRates(feeRate)\n } catch (error) {\n console.warn(`Can not retrieve fee rates from Thorchain`)\n }\n }\n // TODO: Return default value\n throw Error('Can not retrieve fee rates')\n }\n /**\n * Broadcast a transaction.\n *\n * @param {string} txHex The transaction hex string.\n * @returns {Promise<TxHash>} The transaction hash.\n */\n async broadcastTx(txHex: string): Promise<TxHash> {\n return await this.roundRobinBroadcastTx(txHex)\n }\n /**\n * Round-robin method to get balance from data providers.\n * Throws error if no provider can get balance.\n *\n * @param {Address} address The address to get balance for.\n * @returns {Promise<Balance[]>} The balances.\n * @throws Error If no provider is able to get balance.\n */\n\n protected async roundRobinGetBalance(address: Address) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getBalance(address, undefined)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get balance')\n }\n /**\n * Round-robin method to get unspent transactions from data providers.\n * Throws error if no provider can get unspent transactions.\n *\n * @param {Address} address The address to get unspent transactions for.\n * @param {boolean} confirmed Flag to indicate whether to get confirmed transactions only.\n * @returns {Promise<UTXO[]>} The unspent transactions.\n * @throws Error If no provider is able to get unspent transactions.\n */\n protected async roundRobinGetUnspentTxs(address: Address, confirmed: boolean) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) {\n return confirmed ? await prov.getConfirmedUnspentTxs(address) : await prov.getUnspentTxs(address)\n }\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetUnspentTxs')\n }\n /**\n * Round-robin method to get transaction data from data providers.\n * Throws error if no provider can get transaction data.\n *\n * @param {string} txid The transaction ID to get data for.\n * @returns {Promise<Tx>} The transaction data.\n * @throws Error If no provider is able to get transaction data.\n */\n protected async roundRobinGetTransactionData(txid: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactionData(txid)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactionData')\n }\n /**\n * Round-robin method to get transactions from data providers.\n * Throws error if no provider can get transactions.\n *\n * @param {TxHistoryParams} params The parameters for fetching transactions.\n * @returns {Promise<TxsPage>} The transaction history.\n * @throws Error If no provider is able to get transactions.\n */\n protected async roundRobinGetTransactions(params: TxHistoryParams) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getTransactions(params)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to GetTransactions')\n }\n /**\n * Broadcasts a transaction hex using a round-robin approach across multiple data providers.\n * @param {string} txHex The transaction hex to broadcast.\n * @returns {Promise<TxHash>} The hash of the broadcasted transaction.\n * @throws {Error} Throws an error if no provider is able to broadcast the transaction.\n */\n protected async roundRobinBroadcastTx(txHex: string) {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.broadcastTx(txHex)\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to BroadcastTx')\n }\n /**\n * Abstract method to compile a memo.\n * @param {string} memo The memo string to compile.\n * @returns {Buffer} The compiled memo.\n */\n protected abstract compileMemo(memo: string): Buffer\n /**\n * Abstract method to calculate the fee from a list of UTXOs.\n * @param {UTXO[]} inputs The list of UTXOs.\n * @param {FeeRate} feeRate The fee rate.\n * @param {Buffer | null} data Optional data buffer.\n * @returns {number} The calculated fee.\n */\n protected abstract getFeeFromUtxos(inputs: UTXO[], feeRate: FeeRate, data: Buffer | null): number\n /**\n * Retrieves fee rates using a round-robin approach across multiple data providers.\n * @returns {Promise<FeeRates>} The fee rates (average, fast, fastest) in `Satoshis/byte`.\n * @throws {Error} Throws an error if no provider is able to retrieve fee rates.\n */\n protected async roundRobinGetFeeRates(): Promise<FeeRates> {\n for (const provider of this.dataProviders) {\n try {\n const prov = provider[this.network]\n if (prov) return await prov.getFeeRates()\n } catch (error) {\n console.warn(error)\n }\n }\n throw Error('no provider able to get fee rates')\n }\n public abstract transfer(params: TxParams & { feeRate?: number }): Promise<string>\n}\n"],"names":["BaseXChainClient","baseAmount","FeeType","Protocol","standardFeeRates"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;;AAEG;AACG,MAAgB,MAAO,SAAQA,6BAAgB,CAAA;AAInD;;;;;AAKG;IACH,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/xchain-utxo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Genereic UTXO client for XChainJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"XChain",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@xchainjs/xchain-client": "^0.16.
|
|
37
|
-
"@xchainjs/xchain-crypto": "^0.3.
|
|
36
|
+
"@xchainjs/xchain-client": "^0.16.1",
|
|
37
|
+
"@xchainjs/xchain-crypto": "^0.3.1",
|
|
38
38
|
"@xchainjs/xchain-util": "^0.13.1",
|
|
39
|
-
"@xchainjs/xchain-utxo-providers": "^0.2.
|
|
39
|
+
"@xchainjs/xchain-utxo-providers": "^0.2.11",
|
|
40
40
|
"axios": "^1.3.6"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@xchainjs/xchain-client": "^0.16.
|
|
44
|
-
"@xchainjs/xchain-crypto": "^0.3.
|
|
43
|
+
"@xchainjs/xchain-client": "^0.16.1",
|
|
44
|
+
"@xchainjs/xchain-crypto": "^0.3.1",
|
|
45
45
|
"@xchainjs/xchain-util": "^0.13.1",
|
|
46
|
-
"@xchainjs/xchain-utxo-providers": "^0.2.
|
|
46
|
+
"@xchainjs/xchain-utxo-providers": "^0.2.11",
|
|
47
47
|
"axios": "^1.3.6"
|
|
48
48
|
}
|
|
49
49
|
}
|