@xchainjs/xchain-utxo-providers 2.0.5 → 2.0.7
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/index.esm.js
CHANGED
|
@@ -55,7 +55,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
55
55
|
* @param {string} hash The transaction hash.
|
|
56
56
|
* @returns {Transactions}
|
|
57
57
|
*/
|
|
58
|
-
const getTx$3 = (
|
|
58
|
+
const getTx$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, hash }) {
|
|
59
59
|
const url = `${sochainUrl}/transaction/${network}/${hash}`;
|
|
60
60
|
const response = yield axios.get(url, { headers: { 'API-KEY': apiKey } });
|
|
61
61
|
const tx = response.data;
|
|
@@ -71,7 +71,7 @@ const getTx$3 = ({ apiKey, sochainUrl, network, hash }) => __awaiter(void 0, voi
|
|
|
71
71
|
* @param {string} hash The transaction hash.
|
|
72
72
|
* @returns {Transactions}
|
|
73
73
|
*/
|
|
74
|
-
const getTxs$3 = (
|
|
74
|
+
const getTxs$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, sochainUrl, network, page, }) {
|
|
75
75
|
const url = `${sochainUrl}/transactions/${network}/${address}/${page}`; //TODO support paging
|
|
76
76
|
const response = yield axios.get(url, { headers: { 'API-KEY': apiKey } });
|
|
77
77
|
const txs = response.data;
|
|
@@ -88,7 +88,7 @@ const getTxs$3 = ({ apiKey, address, sochainUrl, network, page, }) => __awaiter(
|
|
|
88
88
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
89
89
|
* @returns {number}
|
|
90
90
|
*/
|
|
91
|
-
const getBalance$3 = (
|
|
91
|
+
const getBalance$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, address, confirmedOnly, assetDecimals, }) {
|
|
92
92
|
const url = `${sochainUrl}/balance/${network}/${address}`;
|
|
93
93
|
const response = yield axios.get(url, { headers: { 'API-KEY': apiKey } });
|
|
94
94
|
const balanceResponse = response.data;
|
|
@@ -108,7 +108,7 @@ const getBalance$3 = ({ apiKey, sochainUrl, network, address, confirmedOnly, ass
|
|
|
108
108
|
* @param {string} address
|
|
109
109
|
* @returns {AddressUTXO[]}
|
|
110
110
|
*/
|
|
111
|
-
const getUnspentTxs$1 = (
|
|
111
|
+
const getUnspentTxs$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, address, page, }) {
|
|
112
112
|
const url = [sochainUrl, 'unspent_outputs', network, address, page].filter((v) => !!v).join('/');
|
|
113
113
|
const resp = yield axios.get(url, { headers: { 'API-KEY': apiKey } });
|
|
114
114
|
const response = resp.data;
|
|
@@ -139,7 +139,7 @@ const getUnspentTxs$1 = ({ apiKey, sochainUrl, network, address, page, }) => __a
|
|
|
139
139
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
140
140
|
* @returns {number}
|
|
141
141
|
*/
|
|
142
|
-
const broadcastTx$3 = (
|
|
142
|
+
const broadcastTx$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, txHex, }) {
|
|
143
143
|
const url = `${sochainUrl}/broadcast_transaction/${network}`;
|
|
144
144
|
const response = yield axios.post(url, { tx_hex: txHex }, { headers: { 'API-KEY': apiKey } });
|
|
145
145
|
const broadcastResponse = response.data;
|
|
@@ -224,8 +224,8 @@ class SochainProvider {
|
|
|
224
224
|
* @returns {TxsPage} The transaction history.
|
|
225
225
|
*/
|
|
226
226
|
getTransactions(params) {
|
|
227
|
-
var _a;
|
|
228
227
|
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
var _a;
|
|
229
229
|
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
230
230
|
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
231
231
|
if (offset < 0 || limit < 0)
|
|
@@ -376,7 +376,7 @@ const isErrorResponse = (response) => {
|
|
|
376
376
|
*
|
|
377
377
|
* @throws {"failed to query account by a given address"} thrown if failed to query account by a given address
|
|
378
378
|
*/
|
|
379
|
-
const getAccount = (
|
|
379
|
+
const getAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
380
380
|
const url = `${haskoinUrl}/${network}/address/${address}/balance`;
|
|
381
381
|
const result = (yield axios.get(url)).data;
|
|
382
382
|
if (!result || isErrorResponse(result))
|
|
@@ -391,7 +391,7 @@ const getAccount = ({ haskoinUrl, network, address }) => __awaiter(void 0, void
|
|
|
391
391
|
* @param {string} address
|
|
392
392
|
* @returns {AddressDTO}
|
|
393
393
|
*/
|
|
394
|
-
const getAddress = (
|
|
394
|
+
const getAddress = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
395
395
|
const url = `${haskoinUrl}/${network}/address/${address}/balance`;
|
|
396
396
|
const response = yield axios.get(url);
|
|
397
397
|
const addressResponse = response.data;
|
|
@@ -406,7 +406,7 @@ const getAddress = ({ haskoinUrl, network, address }) => __awaiter(void 0, void
|
|
|
406
406
|
*
|
|
407
407
|
* @throws {"failed to query transaction by a given hash"} thrown if failed to query transaction by a given hash
|
|
408
408
|
*/
|
|
409
|
-
const getTx$2 = (
|
|
409
|
+
const getTx$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, txId, network }) {
|
|
410
410
|
const result = (yield axios.get(`${haskoinUrl}/${network}/transaction/${txId}`)).data;
|
|
411
411
|
if (!result || isErrorResponse(result))
|
|
412
412
|
throw new Error(`failed to query transaction by a given hash ${txId}`);
|
|
@@ -421,7 +421,7 @@ const getTx$2 = ({ haskoinUrl, txId, network }) => __awaiter(void 0, void 0, voi
|
|
|
421
421
|
*
|
|
422
422
|
* @throws {"failed to query transaction by a given hash"} thrown if failed to query raw transaction by a given hash
|
|
423
423
|
*/
|
|
424
|
-
const getRawTransaction = (
|
|
424
|
+
const getRawTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, txId }) {
|
|
425
425
|
const result = (yield axios.get(`${haskoinUrl}/${network}/transaction/${txId}/raw`))
|
|
426
426
|
.data;
|
|
427
427
|
if (!result || isErrorResponse(result))
|
|
@@ -438,7 +438,7 @@ const getRawTransaction = ({ haskoinUrl, network, txId }) => __awaiter(void 0, v
|
|
|
438
438
|
* @param {string} hash The transaction hash.
|
|
439
439
|
* @returns {Transactions}
|
|
440
440
|
*/
|
|
441
|
-
const getTxs$2 = (
|
|
441
|
+
const getTxs$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ address, haskoinUrl, network, limit, offset, }) {
|
|
442
442
|
const params = { limit: `${limit}`, offset: `${offset}` };
|
|
443
443
|
const url = `${haskoinUrl}/${network}/address/${address}/transactions/full`;
|
|
444
444
|
const result = (yield axios.get(url, { params })).data;
|
|
@@ -451,7 +451,7 @@ const getTxs$2 = ({ address, haskoinUrl, network, limit, offset, }) => __awaiter
|
|
|
451
451
|
* @param param
|
|
452
452
|
* @returns Returns BaseAmount
|
|
453
453
|
*/
|
|
454
|
-
const getBalance$2 = (
|
|
454
|
+
const getBalance$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, assetDecimals, }) {
|
|
455
455
|
const { data: { confirmed, unconfirmed }, } = yield axios.get(`${haskoinUrl}/${haskoinNetwork}/address/${address}/balance`);
|
|
456
456
|
const confirmedAmount = baseAmount(confirmed, assetDecimals);
|
|
457
457
|
const unconfirmedAmount = baseAmount(unconfirmed, assetDecimals);
|
|
@@ -466,7 +466,7 @@ const getBalance$2 = ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, asse
|
|
|
466
466
|
*
|
|
467
467
|
* @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
|
|
468
468
|
*/
|
|
469
|
-
const getUnspentTxs = (
|
|
469
|
+
const getUnspentTxs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
470
470
|
// Get transaction count for a given address.
|
|
471
471
|
const account = yield getAccount({ haskoinUrl, network, address });
|
|
472
472
|
// Set limit to the transaction count to be all the utxos.
|
|
@@ -483,7 +483,7 @@ const getUnspentTxs = ({ haskoinUrl, network, address }) => __awaiter(void 0, vo
|
|
|
483
483
|
* @param {string} hash tx id
|
|
484
484
|
* @returns {TxConfirmedStatus}
|
|
485
485
|
*/
|
|
486
|
-
const getIsTxConfirmed = (
|
|
486
|
+
const getIsTxConfirmed = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, txId }) {
|
|
487
487
|
const tx = yield getTx$2({ haskoinUrl, network, txId });
|
|
488
488
|
return {
|
|
489
489
|
network: network,
|
|
@@ -503,7 +503,7 @@ const confirmedTxs = [];
|
|
|
503
503
|
*
|
|
504
504
|
* It will get it from cache or try to get it from haskoin (if not cached before)
|
|
505
505
|
*/
|
|
506
|
-
const getConfirmedTxStatus = (
|
|
506
|
+
const getConfirmedTxStatus = (_a) => __awaiter(void 0, [_a], void 0, function* ({ txHash, haskoinUrl, network, }) {
|
|
507
507
|
// try to get it from cache
|
|
508
508
|
if (confirmedTxs.includes(txHash))
|
|
509
509
|
return true;
|
|
@@ -527,7 +527,7 @@ const getConfirmedTxStatus = ({ txHash, haskoinUrl, network, }) => __awaiter(voi
|
|
|
527
527
|
* @param {string} address
|
|
528
528
|
* @returns {AddressUTXO[]}
|
|
529
529
|
*/
|
|
530
|
-
const getConfirmedUnspentTxs = (
|
|
530
|
+
const getConfirmedUnspentTxs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
531
531
|
const txs = yield getUnspentTxs({
|
|
532
532
|
haskoinUrl,
|
|
533
533
|
network,
|
|
@@ -553,7 +553,7 @@ const txHexMap = {};
|
|
|
553
553
|
*
|
|
554
554
|
* It will try to get it from cache before requesting it from Sochain
|
|
555
555
|
*/
|
|
556
|
-
const getTxHex = (
|
|
556
|
+
const getTxHex = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, txId }) {
|
|
557
557
|
// try to get hex from cache
|
|
558
558
|
let txHex = txHexMap[txId];
|
|
559
559
|
if (!!txHex)
|
|
@@ -573,7 +573,7 @@ const getTxHex = ({ haskoinUrl, network, txId }) => __awaiter(void 0, void 0, vo
|
|
|
573
573
|
*
|
|
574
574
|
* @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
|
|
575
575
|
*/
|
|
576
|
-
const getUnspentTransactions = (
|
|
576
|
+
const getUnspentTransactions = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
577
577
|
// Get transaction count for a given address.
|
|
578
578
|
const account = yield getAccount({ haskoinUrl, network, address });
|
|
579
579
|
// Set limit to the transaction count to be all the utxos.
|
|
@@ -594,8 +594,8 @@ const getUnspentTransactions = ({ haskoinUrl, network, address }) => __awaiter(v
|
|
|
594
594
|
* @param {BroadcastTxParams} params
|
|
595
595
|
* @returns {TxHash} Transaction hash.
|
|
596
596
|
*/
|
|
597
|
-
const broadcastTx$2 = (
|
|
598
|
-
var
|
|
597
|
+
const broadcastTx$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ txHex, haskoinUrl, haskoinNetwork, }) {
|
|
598
|
+
var _b;
|
|
599
599
|
const MAX_RETRIES = 5;
|
|
600
600
|
let retries = 0;
|
|
601
601
|
const axiosInstance = axios.create();
|
|
@@ -608,7 +608,7 @@ const broadcastTx$2 = ({ txHex, haskoinUrl, haskoinNetwork, }) => __awaiter(void
|
|
|
608
608
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
609
609
|
}
|
|
610
610
|
catch (error) {
|
|
611
|
-
if (((
|
|
611
|
+
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 500) {
|
|
612
612
|
retries++;
|
|
613
613
|
yield delay(200 * retries);
|
|
614
614
|
}
|
|
@@ -680,8 +680,8 @@ class HaskoinProvider {
|
|
|
680
680
|
* @returns {TxsPage} The transaction history.
|
|
681
681
|
*/
|
|
682
682
|
getTransactions(params) {
|
|
683
|
-
var _a;
|
|
684
683
|
return __awaiter(this, void 0, void 0, function* () {
|
|
684
|
+
var _a;
|
|
685
685
|
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
686
686
|
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
687
687
|
if (offset + limit > 2000)
|
|
@@ -778,7 +778,7 @@ class HaskoinProvider {
|
|
|
778
778
|
* @param {string} hash The transaction hash.
|
|
779
779
|
* @returns {Transactions}
|
|
780
780
|
*/
|
|
781
|
-
const getTx$1 = (
|
|
781
|
+
const getTx$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, network, hash, limit = 20 }) {
|
|
782
782
|
const params = { includeHex: 'true', limit: limit.toString() };
|
|
783
783
|
if (apiKey)
|
|
784
784
|
params['token'] = apiKey;
|
|
@@ -796,7 +796,7 @@ const getTx$1 = ({ apiKey, baseUrl, network, hash, limit = 20 }) => __awaiter(vo
|
|
|
796
796
|
* @param {string} hash The transaction hash.
|
|
797
797
|
* @returns {Transactions}
|
|
798
798
|
*/
|
|
799
|
-
const getTxs$1 = ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspentOnly, })
|
|
799
|
+
const getTxs$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspentOnly, }) {
|
|
800
800
|
const params = { limit: `${limit}`, unspentOnly: `${unspentOnly}` };
|
|
801
801
|
const url = `${baseUrl}/${network}/addrs/${address}`;
|
|
802
802
|
if (apiKey)
|
|
@@ -817,7 +817,7 @@ const getTxs$1 = ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspe
|
|
|
817
817
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
818
818
|
* @returns {number}
|
|
819
819
|
*/
|
|
820
|
-
const getBalance$1 = (
|
|
820
|
+
const getBalance$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, network, address, confirmedOnly, assetDecimals, }) {
|
|
821
821
|
const params = {};
|
|
822
822
|
const url = `${baseUrl}/${network}/addrs/${address}/balance`;
|
|
823
823
|
if (apiKey)
|
|
@@ -828,7 +828,7 @@ const getBalance$1 = ({ apiKey, baseUrl, network, address, confirmedOnly, assetD
|
|
|
828
828
|
const finalBalance = baseAmount(balanceResponse.final_balance, assetDecimals);
|
|
829
829
|
return confirmedOnly ? confirmedAmount : finalBalance;
|
|
830
830
|
});
|
|
831
|
-
const broadcastTx$1 = (
|
|
831
|
+
const broadcastTx$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, network, txHex, }) {
|
|
832
832
|
const params = {};
|
|
833
833
|
const url = `${baseUrl}/${network}/txs/push`;
|
|
834
834
|
if (apiKey)
|
|
@@ -843,7 +843,7 @@ const broadcastTx$1 = ({ apiKey, baseUrl, network, txHex, }) => __awaiter(void 0
|
|
|
843
843
|
* @param {string} apiKey API key provided by Blockcypher.
|
|
844
844
|
* @returns {ChainResponse}
|
|
845
845
|
*/
|
|
846
|
-
const getBlockchainData = (
|
|
846
|
+
const getBlockchainData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ baseUrl, apiKey, }) {
|
|
847
847
|
const params = {};
|
|
848
848
|
if (apiKey)
|
|
849
849
|
params['token'] = apiKey;
|
|
@@ -910,8 +910,8 @@ class BlockcypherProvider {
|
|
|
910
910
|
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
911
911
|
* @returns {TxsPage} The transaction history.
|
|
912
912
|
*/
|
|
913
|
-
getTransactions(
|
|
914
|
-
return __awaiter(this,
|
|
913
|
+
getTransactions(params_1) {
|
|
914
|
+
return __awaiter(this, arguments, void 0, function* (params, unspentOnly = false) {
|
|
915
915
|
const rawTxs = yield this.getRawTransactions(params, unspentOnly);
|
|
916
916
|
const txs = rawTxs.map((i) => this.mapTransactionToTx(i));
|
|
917
917
|
const result = {
|
|
@@ -1024,9 +1024,9 @@ class BlockcypherProvider {
|
|
|
1024
1024
|
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
1025
1025
|
* @returns {TxsPage} The transaction history.
|
|
1026
1026
|
*/
|
|
1027
|
-
getRawTransactions(
|
|
1028
|
-
|
|
1029
|
-
|
|
1027
|
+
getRawTransactions(params_1) {
|
|
1028
|
+
return __awaiter(this, arguments, void 0, function* (params, unspentOnly = false) {
|
|
1029
|
+
var _a;
|
|
1030
1030
|
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
1031
1031
|
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
1032
1032
|
if (offset + limit > 2000)
|
|
@@ -1040,7 +1040,7 @@ class BlockcypherProvider {
|
|
|
1040
1040
|
baseUrl: this.baseUrl,
|
|
1041
1041
|
network: this.blockcypherNetwork,
|
|
1042
1042
|
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
1043
|
-
limit: 2000,
|
|
1043
|
+
limit: 2000, // fetch the maximum
|
|
1044
1044
|
unspentOnly,
|
|
1045
1045
|
});
|
|
1046
1046
|
//remove duplicates
|
|
@@ -1108,8 +1108,8 @@ class BitgoProvider {
|
|
|
1108
1108
|
* @returns {FeeRates} Estimated fee rates
|
|
1109
1109
|
*/
|
|
1110
1110
|
getFeeRates() {
|
|
1111
|
-
var _a, _b, _c, _d;
|
|
1112
1111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1112
|
+
var _a, _b, _c, _d;
|
|
1113
1113
|
const gasFeeEstimateResponse = yield getFeeEstimate(`${this.baseUrl}/api/v2/${this.blockchainId}`, {
|
|
1114
1114
|
numBlocks: 2,
|
|
1115
1115
|
});
|
|
@@ -1171,7 +1171,7 @@ class BitgoProvider {
|
|
|
1171
1171
|
* @param {string} hash The transaction hash.
|
|
1172
1172
|
* @returns {Transactions}
|
|
1173
1173
|
*/
|
|
1174
|
-
const getTx = (
|
|
1174
|
+
const getTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, hash }) {
|
|
1175
1175
|
const url = `${baseUrl}/tx/${hash}`;
|
|
1176
1176
|
const response = yield axios.get(url, {
|
|
1177
1177
|
headers: {
|
|
@@ -1189,7 +1189,7 @@ const getTx = ({ apiKey, baseUrl, hash }) => __awaiter(void 0, void 0, void 0, f
|
|
|
1189
1189
|
* @param {string} hash The transaction hash.
|
|
1190
1190
|
* @returns {Transactions}
|
|
1191
1191
|
*/
|
|
1192
|
-
const getTxs = (
|
|
1192
|
+
const getTxs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, baseUrl, limit, }) {
|
|
1193
1193
|
const url = `${baseUrl}/address/${address}`;
|
|
1194
1194
|
const response = yield axios.get(url, {
|
|
1195
1195
|
params: {
|
|
@@ -1210,7 +1210,7 @@ const getTxs = ({ apiKey, address, baseUrl, limit, }) => __awaiter(void 0, void
|
|
|
1210
1210
|
* @param {string} address address.
|
|
1211
1211
|
* @returns {Transactions}
|
|
1212
1212
|
*/
|
|
1213
|
-
const getUTXOs = (
|
|
1213
|
+
const getUTXOs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, baseUrl, isConfirmed = true, }) {
|
|
1214
1214
|
const url = `${baseUrl}/utxo/${address}`;
|
|
1215
1215
|
const response = yield axios.get(url, {
|
|
1216
1216
|
params: {
|
|
@@ -1232,7 +1232,7 @@ const getUTXOs = ({ apiKey, address, baseUrl, isConfirmed = true, }) => __awaite
|
|
|
1232
1232
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
1233
1233
|
* @returns {number}
|
|
1234
1234
|
*/
|
|
1235
|
-
const getBalance = ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecimals, })
|
|
1235
|
+
const getBalance = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecimals, }) {
|
|
1236
1236
|
const url = `${baseUrl}/address/${address}`;
|
|
1237
1237
|
const response = yield axios.get(url, {
|
|
1238
1238
|
headers: {
|
|
@@ -1245,7 +1245,7 @@ const getBalance = ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecim
|
|
|
1245
1245
|
: baseAmount(balanceResponse.balance).plus(balanceResponse.unconfirmedBalance, assetDecimals);
|
|
1246
1246
|
return balance;
|
|
1247
1247
|
});
|
|
1248
|
-
const broadcastTx = (
|
|
1248
|
+
const broadcastTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, txHex, }) {
|
|
1249
1249
|
const url = `${baseUrl}/sendtx/${txHex}`;
|
|
1250
1250
|
const response = yield axios.get(url, {
|
|
1251
1251
|
headers: {
|
|
@@ -1375,8 +1375,8 @@ class NownodesProvider {
|
|
|
1375
1375
|
});
|
|
1376
1376
|
}
|
|
1377
1377
|
getRawTransactions(params) {
|
|
1378
|
-
var _a;
|
|
1379
1378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1379
|
+
var _a;
|
|
1380
1380
|
if (params === null || params === void 0 ? void 0 : params.startTime) {
|
|
1381
1381
|
throw Error('startTime not supported on nownodes provider');
|
|
1382
1382
|
}
|
package/lib/index.js
CHANGED
|
@@ -62,7 +62,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
62
62
|
* @param {string} hash The transaction hash.
|
|
63
63
|
* @returns {Transactions}
|
|
64
64
|
*/
|
|
65
|
-
const getTx$3 = (
|
|
65
|
+
const getTx$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, hash }) {
|
|
66
66
|
const url = `${sochainUrl}/transaction/${network}/${hash}`;
|
|
67
67
|
const response = yield axios__default.default.get(url, { headers: { 'API-KEY': apiKey } });
|
|
68
68
|
const tx = response.data;
|
|
@@ -78,7 +78,7 @@ const getTx$3 = ({ apiKey, sochainUrl, network, hash }) => __awaiter(void 0, voi
|
|
|
78
78
|
* @param {string} hash The transaction hash.
|
|
79
79
|
* @returns {Transactions}
|
|
80
80
|
*/
|
|
81
|
-
const getTxs$3 = (
|
|
81
|
+
const getTxs$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, sochainUrl, network, page, }) {
|
|
82
82
|
const url = `${sochainUrl}/transactions/${network}/${address}/${page}`; //TODO support paging
|
|
83
83
|
const response = yield axios__default.default.get(url, { headers: { 'API-KEY': apiKey } });
|
|
84
84
|
const txs = response.data;
|
|
@@ -95,7 +95,7 @@ const getTxs$3 = ({ apiKey, address, sochainUrl, network, page, }) => __awaiter(
|
|
|
95
95
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
96
96
|
* @returns {number}
|
|
97
97
|
*/
|
|
98
|
-
const getBalance$3 = (
|
|
98
|
+
const getBalance$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, address, confirmedOnly, assetDecimals, }) {
|
|
99
99
|
const url = `${sochainUrl}/balance/${network}/${address}`;
|
|
100
100
|
const response = yield axios__default.default.get(url, { headers: { 'API-KEY': apiKey } });
|
|
101
101
|
const balanceResponse = response.data;
|
|
@@ -115,7 +115,7 @@ const getBalance$3 = ({ apiKey, sochainUrl, network, address, confirmedOnly, ass
|
|
|
115
115
|
* @param {string} address
|
|
116
116
|
* @returns {AddressUTXO[]}
|
|
117
117
|
*/
|
|
118
|
-
const getUnspentTxs$1 = (
|
|
118
|
+
const getUnspentTxs$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, address, page, }) {
|
|
119
119
|
const url = [sochainUrl, 'unspent_outputs', network, address, page].filter((v) => !!v).join('/');
|
|
120
120
|
const resp = yield axios__default.default.get(url, { headers: { 'API-KEY': apiKey } });
|
|
121
121
|
const response = resp.data;
|
|
@@ -146,7 +146,7 @@ const getUnspentTxs$1 = ({ apiKey, sochainUrl, network, address, page, }) => __a
|
|
|
146
146
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
147
147
|
* @returns {number}
|
|
148
148
|
*/
|
|
149
|
-
const broadcastTx$3 = (
|
|
149
|
+
const broadcastTx$3 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, sochainUrl, network, txHex, }) {
|
|
150
150
|
const url = `${sochainUrl}/broadcast_transaction/${network}`;
|
|
151
151
|
const response = yield axios__default.default.post(url, { tx_hex: txHex }, { headers: { 'API-KEY': apiKey } });
|
|
152
152
|
const broadcastResponse = response.data;
|
|
@@ -231,8 +231,8 @@ class SochainProvider {
|
|
|
231
231
|
* @returns {TxsPage} The transaction history.
|
|
232
232
|
*/
|
|
233
233
|
getTransactions(params) {
|
|
234
|
-
var _a;
|
|
235
234
|
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
var _a;
|
|
236
236
|
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
237
237
|
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
238
238
|
if (offset < 0 || limit < 0)
|
|
@@ -383,7 +383,7 @@ const isErrorResponse = (response) => {
|
|
|
383
383
|
*
|
|
384
384
|
* @throws {"failed to query account by a given address"} thrown if failed to query account by a given address
|
|
385
385
|
*/
|
|
386
|
-
const getAccount = (
|
|
386
|
+
const getAccount = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
387
387
|
const url = `${haskoinUrl}/${network}/address/${address}/balance`;
|
|
388
388
|
const result = (yield axios__default.default.get(url)).data;
|
|
389
389
|
if (!result || isErrorResponse(result))
|
|
@@ -398,7 +398,7 @@ const getAccount = ({ haskoinUrl, network, address }) => __awaiter(void 0, void
|
|
|
398
398
|
* @param {string} address
|
|
399
399
|
* @returns {AddressDTO}
|
|
400
400
|
*/
|
|
401
|
-
const getAddress = (
|
|
401
|
+
const getAddress = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
402
402
|
const url = `${haskoinUrl}/${network}/address/${address}/balance`;
|
|
403
403
|
const response = yield axios__default.default.get(url);
|
|
404
404
|
const addressResponse = response.data;
|
|
@@ -413,7 +413,7 @@ const getAddress = ({ haskoinUrl, network, address }) => __awaiter(void 0, void
|
|
|
413
413
|
*
|
|
414
414
|
* @throws {"failed to query transaction by a given hash"} thrown if failed to query transaction by a given hash
|
|
415
415
|
*/
|
|
416
|
-
const getTx$2 = (
|
|
416
|
+
const getTx$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, txId, network }) {
|
|
417
417
|
const result = (yield axios__default.default.get(`${haskoinUrl}/${network}/transaction/${txId}`)).data;
|
|
418
418
|
if (!result || isErrorResponse(result))
|
|
419
419
|
throw new Error(`failed to query transaction by a given hash ${txId}`);
|
|
@@ -428,7 +428,7 @@ const getTx$2 = ({ haskoinUrl, txId, network }) => __awaiter(void 0, void 0, voi
|
|
|
428
428
|
*
|
|
429
429
|
* @throws {"failed to query transaction by a given hash"} thrown if failed to query raw transaction by a given hash
|
|
430
430
|
*/
|
|
431
|
-
const getRawTransaction = (
|
|
431
|
+
const getRawTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, txId }) {
|
|
432
432
|
const result = (yield axios__default.default.get(`${haskoinUrl}/${network}/transaction/${txId}/raw`))
|
|
433
433
|
.data;
|
|
434
434
|
if (!result || isErrorResponse(result))
|
|
@@ -445,7 +445,7 @@ const getRawTransaction = ({ haskoinUrl, network, txId }) => __awaiter(void 0, v
|
|
|
445
445
|
* @param {string} hash The transaction hash.
|
|
446
446
|
* @returns {Transactions}
|
|
447
447
|
*/
|
|
448
|
-
const getTxs$2 = (
|
|
448
|
+
const getTxs$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ address, haskoinUrl, network, limit, offset, }) {
|
|
449
449
|
const params = { limit: `${limit}`, offset: `${offset}` };
|
|
450
450
|
const url = `${haskoinUrl}/${network}/address/${address}/transactions/full`;
|
|
451
451
|
const result = (yield axios__default.default.get(url, { params })).data;
|
|
@@ -458,7 +458,7 @@ const getTxs$2 = ({ address, haskoinUrl, network, limit, offset, }) => __awaiter
|
|
|
458
458
|
* @param param
|
|
459
459
|
* @returns Returns BaseAmount
|
|
460
460
|
*/
|
|
461
|
-
const getBalance$2 = (
|
|
461
|
+
const getBalance$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, assetDecimals, }) {
|
|
462
462
|
const { data: { confirmed, unconfirmed }, } = yield axios__default.default.get(`${haskoinUrl}/${haskoinNetwork}/address/${address}/balance`);
|
|
463
463
|
const confirmedAmount = xchainUtil.baseAmount(confirmed, assetDecimals);
|
|
464
464
|
const unconfirmedAmount = xchainUtil.baseAmount(unconfirmed, assetDecimals);
|
|
@@ -473,7 +473,7 @@ const getBalance$2 = ({ haskoinUrl, haskoinNetwork, address, confirmedOnly, asse
|
|
|
473
473
|
*
|
|
474
474
|
* @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
|
|
475
475
|
*/
|
|
476
|
-
const getUnspentTxs = (
|
|
476
|
+
const getUnspentTxs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
477
477
|
// Get transaction count for a given address.
|
|
478
478
|
const account = yield getAccount({ haskoinUrl, network, address });
|
|
479
479
|
// Set limit to the transaction count to be all the utxos.
|
|
@@ -490,7 +490,7 @@ const getUnspentTxs = ({ haskoinUrl, network, address }) => __awaiter(void 0, vo
|
|
|
490
490
|
* @param {string} hash tx id
|
|
491
491
|
* @returns {TxConfirmedStatus}
|
|
492
492
|
*/
|
|
493
|
-
const getIsTxConfirmed = (
|
|
493
|
+
const getIsTxConfirmed = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, txId }) {
|
|
494
494
|
const tx = yield getTx$2({ haskoinUrl, network, txId });
|
|
495
495
|
return {
|
|
496
496
|
network: network,
|
|
@@ -510,7 +510,7 @@ const confirmedTxs = [];
|
|
|
510
510
|
*
|
|
511
511
|
* It will get it from cache or try to get it from haskoin (if not cached before)
|
|
512
512
|
*/
|
|
513
|
-
const getConfirmedTxStatus = (
|
|
513
|
+
const getConfirmedTxStatus = (_a) => __awaiter(void 0, [_a], void 0, function* ({ txHash, haskoinUrl, network, }) {
|
|
514
514
|
// try to get it from cache
|
|
515
515
|
if (confirmedTxs.includes(txHash))
|
|
516
516
|
return true;
|
|
@@ -534,7 +534,7 @@ const getConfirmedTxStatus = ({ txHash, haskoinUrl, network, }) => __awaiter(voi
|
|
|
534
534
|
* @param {string} address
|
|
535
535
|
* @returns {AddressUTXO[]}
|
|
536
536
|
*/
|
|
537
|
-
const getConfirmedUnspentTxs = (
|
|
537
|
+
const getConfirmedUnspentTxs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
538
538
|
const txs = yield getUnspentTxs({
|
|
539
539
|
haskoinUrl,
|
|
540
540
|
network,
|
|
@@ -560,7 +560,7 @@ const txHexMap = {};
|
|
|
560
560
|
*
|
|
561
561
|
* It will try to get it from cache before requesting it from Sochain
|
|
562
562
|
*/
|
|
563
|
-
const getTxHex = (
|
|
563
|
+
const getTxHex = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, txId }) {
|
|
564
564
|
// try to get hex from cache
|
|
565
565
|
let txHex = txHexMap[txId];
|
|
566
566
|
if (!!txHex)
|
|
@@ -580,7 +580,7 @@ const getTxHex = ({ haskoinUrl, network, txId }) => __awaiter(void 0, void 0, vo
|
|
|
580
580
|
*
|
|
581
581
|
* @throws {"failed to query unspent transactions"} thrown if failed to query unspent transactions
|
|
582
582
|
*/
|
|
583
|
-
const getUnspentTransactions = (
|
|
583
|
+
const getUnspentTransactions = (_a) => __awaiter(void 0, [_a], void 0, function* ({ haskoinUrl, network, address }) {
|
|
584
584
|
// Get transaction count for a given address.
|
|
585
585
|
const account = yield getAccount({ haskoinUrl, network, address });
|
|
586
586
|
// Set limit to the transaction count to be all the utxos.
|
|
@@ -601,8 +601,8 @@ const getUnspentTransactions = ({ haskoinUrl, network, address }) => __awaiter(v
|
|
|
601
601
|
* @param {BroadcastTxParams} params
|
|
602
602
|
* @returns {TxHash} Transaction hash.
|
|
603
603
|
*/
|
|
604
|
-
const broadcastTx$2 = (
|
|
605
|
-
var
|
|
604
|
+
const broadcastTx$2 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ txHex, haskoinUrl, haskoinNetwork, }) {
|
|
605
|
+
var _b;
|
|
606
606
|
const MAX_RETRIES = 5;
|
|
607
607
|
let retries = 0;
|
|
608
608
|
const axiosInstance = axios__default.default.create();
|
|
@@ -615,7 +615,7 @@ const broadcastTx$2 = ({ txHex, haskoinUrl, haskoinNetwork, }) => __awaiter(void
|
|
|
615
615
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
616
616
|
}
|
|
617
617
|
catch (error) {
|
|
618
|
-
if (((
|
|
618
|
+
if (((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) === 500) {
|
|
619
619
|
retries++;
|
|
620
620
|
yield xchainUtil.delay(200 * retries);
|
|
621
621
|
}
|
|
@@ -687,8 +687,8 @@ class HaskoinProvider {
|
|
|
687
687
|
* @returns {TxsPage} The transaction history.
|
|
688
688
|
*/
|
|
689
689
|
getTransactions(params) {
|
|
690
|
-
var _a;
|
|
691
690
|
return __awaiter(this, void 0, void 0, function* () {
|
|
691
|
+
var _a;
|
|
692
692
|
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
693
693
|
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
694
694
|
if (offset + limit > 2000)
|
|
@@ -785,7 +785,7 @@ class HaskoinProvider {
|
|
|
785
785
|
* @param {string} hash The transaction hash.
|
|
786
786
|
* @returns {Transactions}
|
|
787
787
|
*/
|
|
788
|
-
const getTx$1 = (
|
|
788
|
+
const getTx$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, network, hash, limit = 20 }) {
|
|
789
789
|
const params = { includeHex: 'true', limit: limit.toString() };
|
|
790
790
|
if (apiKey)
|
|
791
791
|
params['token'] = apiKey;
|
|
@@ -803,7 +803,7 @@ const getTx$1 = ({ apiKey, baseUrl, network, hash, limit = 20 }) => __awaiter(vo
|
|
|
803
803
|
* @param {string} hash The transaction hash.
|
|
804
804
|
* @returns {Transactions}
|
|
805
805
|
*/
|
|
806
|
-
const getTxs$1 = ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspentOnly, })
|
|
806
|
+
const getTxs$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspentOnly, }) {
|
|
807
807
|
const params = { limit: `${limit}`, unspentOnly: `${unspentOnly}` };
|
|
808
808
|
const url = `${baseUrl}/${network}/addrs/${address}`;
|
|
809
809
|
if (apiKey)
|
|
@@ -824,7 +824,7 @@ const getTxs$1 = ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspe
|
|
|
824
824
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
825
825
|
* @returns {number}
|
|
826
826
|
*/
|
|
827
|
-
const getBalance$1 = (
|
|
827
|
+
const getBalance$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, network, address, confirmedOnly, assetDecimals, }) {
|
|
828
828
|
const params = {};
|
|
829
829
|
const url = `${baseUrl}/${network}/addrs/${address}/balance`;
|
|
830
830
|
if (apiKey)
|
|
@@ -835,7 +835,7 @@ const getBalance$1 = ({ apiKey, baseUrl, network, address, confirmedOnly, assetD
|
|
|
835
835
|
const finalBalance = xchainUtil.baseAmount(balanceResponse.final_balance, assetDecimals);
|
|
836
836
|
return confirmedOnly ? confirmedAmount : finalBalance;
|
|
837
837
|
});
|
|
838
|
-
const broadcastTx$1 = (
|
|
838
|
+
const broadcastTx$1 = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, network, txHex, }) {
|
|
839
839
|
const params = {};
|
|
840
840
|
const url = `${baseUrl}/${network}/txs/push`;
|
|
841
841
|
if (apiKey)
|
|
@@ -850,7 +850,7 @@ const broadcastTx$1 = ({ apiKey, baseUrl, network, txHex, }) => __awaiter(void 0
|
|
|
850
850
|
* @param {string} apiKey API key provided by Blockcypher.
|
|
851
851
|
* @returns {ChainResponse}
|
|
852
852
|
*/
|
|
853
|
-
const getBlockchainData = (
|
|
853
|
+
const getBlockchainData = (_a) => __awaiter(void 0, [_a], void 0, function* ({ baseUrl, apiKey, }) {
|
|
854
854
|
const params = {};
|
|
855
855
|
if (apiKey)
|
|
856
856
|
params['token'] = apiKey;
|
|
@@ -917,8 +917,8 @@ class BlockcypherProvider {
|
|
|
917
917
|
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
918
918
|
* @returns {TxsPage} The transaction history.
|
|
919
919
|
*/
|
|
920
|
-
getTransactions(
|
|
921
|
-
return __awaiter(this,
|
|
920
|
+
getTransactions(params_1) {
|
|
921
|
+
return __awaiter(this, arguments, void 0, function* (params, unspentOnly = false) {
|
|
922
922
|
const rawTxs = yield this.getRawTransactions(params, unspentOnly);
|
|
923
923
|
const txs = rawTxs.map((i) => this.mapTransactionToTx(i));
|
|
924
924
|
const result = {
|
|
@@ -1031,9 +1031,9 @@ class BlockcypherProvider {
|
|
|
1031
1031
|
* @param {TxHistoryParams} params The options to get transaction history. (optional)
|
|
1032
1032
|
* @returns {TxsPage} The transaction history.
|
|
1033
1033
|
*/
|
|
1034
|
-
getRawTransactions(
|
|
1035
|
-
|
|
1036
|
-
|
|
1034
|
+
getRawTransactions(params_1) {
|
|
1035
|
+
return __awaiter(this, arguments, void 0, function* (params, unspentOnly = false) {
|
|
1036
|
+
var _a;
|
|
1037
1037
|
const offset = (_a = params === null || params === void 0 ? void 0 : params.offset) !== null && _a !== void 0 ? _a : 0;
|
|
1038
1038
|
const limit = (params === null || params === void 0 ? void 0 : params.limit) || 10;
|
|
1039
1039
|
if (offset + limit > 2000)
|
|
@@ -1047,7 +1047,7 @@ class BlockcypherProvider {
|
|
|
1047
1047
|
baseUrl: this.baseUrl,
|
|
1048
1048
|
network: this.blockcypherNetwork,
|
|
1049
1049
|
address: `${params === null || params === void 0 ? void 0 : params.address}`,
|
|
1050
|
-
limit: 2000,
|
|
1050
|
+
limit: 2000, // fetch the maximum
|
|
1051
1051
|
unspentOnly,
|
|
1052
1052
|
});
|
|
1053
1053
|
//remove duplicates
|
|
@@ -1115,8 +1115,8 @@ class BitgoProvider {
|
|
|
1115
1115
|
* @returns {FeeRates} Estimated fee rates
|
|
1116
1116
|
*/
|
|
1117
1117
|
getFeeRates() {
|
|
1118
|
-
var _a, _b, _c, _d;
|
|
1119
1118
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1119
|
+
var _a, _b, _c, _d;
|
|
1120
1120
|
const gasFeeEstimateResponse = yield getFeeEstimate(`${this.baseUrl}/api/v2/${this.blockchainId}`, {
|
|
1121
1121
|
numBlocks: 2,
|
|
1122
1122
|
});
|
|
@@ -1178,7 +1178,7 @@ class BitgoProvider {
|
|
|
1178
1178
|
* @param {string} hash The transaction hash.
|
|
1179
1179
|
* @returns {Transactions}
|
|
1180
1180
|
*/
|
|
1181
|
-
const getTx = (
|
|
1181
|
+
const getTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, hash }) {
|
|
1182
1182
|
const url = `${baseUrl}/tx/${hash}`;
|
|
1183
1183
|
const response = yield axios__default.default.get(url, {
|
|
1184
1184
|
headers: {
|
|
@@ -1196,7 +1196,7 @@ const getTx = ({ apiKey, baseUrl, hash }) => __awaiter(void 0, void 0, void 0, f
|
|
|
1196
1196
|
* @param {string} hash The transaction hash.
|
|
1197
1197
|
* @returns {Transactions}
|
|
1198
1198
|
*/
|
|
1199
|
-
const getTxs = (
|
|
1199
|
+
const getTxs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, baseUrl, limit, }) {
|
|
1200
1200
|
const url = `${baseUrl}/address/${address}`;
|
|
1201
1201
|
const response = yield axios__default.default.get(url, {
|
|
1202
1202
|
params: {
|
|
@@ -1217,7 +1217,7 @@ const getTxs = ({ apiKey, address, baseUrl, limit, }) => __awaiter(void 0, void
|
|
|
1217
1217
|
* @param {string} address address.
|
|
1218
1218
|
* @returns {Transactions}
|
|
1219
1219
|
*/
|
|
1220
|
-
const getUTXOs = (
|
|
1220
|
+
const getUTXOs = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, address, baseUrl, isConfirmed = true, }) {
|
|
1221
1221
|
const url = `${baseUrl}/utxo/${address}`;
|
|
1222
1222
|
const response = yield axios__default.default.get(url, {
|
|
1223
1223
|
params: {
|
|
@@ -1239,7 +1239,7 @@ const getUTXOs = ({ apiKey, address, baseUrl, isConfirmed = true, }) => __awaite
|
|
|
1239
1239
|
* @param {boolean} confirmedOnly Flag whether to get balances of confirmed txs only or for all
|
|
1240
1240
|
* @returns {number}
|
|
1241
1241
|
*/
|
|
1242
|
-
const getBalance = ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecimals, })
|
|
1242
|
+
const getBalance = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecimals, }) {
|
|
1243
1243
|
const url = `${baseUrl}/address/${address}`;
|
|
1244
1244
|
const response = yield axios__default.default.get(url, {
|
|
1245
1245
|
headers: {
|
|
@@ -1252,7 +1252,7 @@ const getBalance = ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecim
|
|
|
1252
1252
|
: xchainUtil.baseAmount(balanceResponse.balance).plus(balanceResponse.unconfirmedBalance, assetDecimals);
|
|
1253
1253
|
return balance;
|
|
1254
1254
|
});
|
|
1255
|
-
const broadcastTx = (
|
|
1255
|
+
const broadcastTx = (_a) => __awaiter(void 0, [_a], void 0, function* ({ apiKey, baseUrl, txHex, }) {
|
|
1256
1256
|
const url = `${baseUrl}/sendtx/${txHex}`;
|
|
1257
1257
|
const response = yield axios__default.default.get(url, {
|
|
1258
1258
|
headers: {
|
|
@@ -1382,8 +1382,8 @@ class NownodesProvider {
|
|
|
1382
1382
|
});
|
|
1383
1383
|
}
|
|
1384
1384
|
getRawTransactions(params) {
|
|
1385
|
-
var _a;
|
|
1386
1385
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1386
|
+
var _a;
|
|
1387
1387
|
if (params === null || params === void 0 ? void 0 : params.startTime) {
|
|
1388
1388
|
throw Error('startTime not supported on nownodes provider');
|
|
1389
1389
|
}
|
|
@@ -21,12 +21,12 @@ export declare const getTx: ({ apiKey, baseUrl, network, hash, limit }: TxHashPa
|
|
|
21
21
|
* @returns {Transactions}
|
|
22
22
|
*/
|
|
23
23
|
export declare const getTxs: ({ apiKey, address, baseUrl, network, beforeBlock, limit, unspentOnly, }: {
|
|
24
|
-
apiKey?: string
|
|
24
|
+
apiKey?: string;
|
|
25
25
|
address: string;
|
|
26
26
|
baseUrl: string;
|
|
27
27
|
network: BlockcypherNetwork;
|
|
28
28
|
limit: number;
|
|
29
|
-
beforeBlock?: number
|
|
29
|
+
beforeBlock?: number;
|
|
30
30
|
unspentOnly: boolean;
|
|
31
31
|
}) => Promise<GetTxsDTO>;
|
|
32
32
|
/**
|
|
@@ -56,13 +56,13 @@ export declare const getIsTxConfirmed: ({ apiKey, baseUrl, network, hash, }: TxH
|
|
|
56
56
|
* It will get it from cache or try to get it from Sochain (if not cached before)
|
|
57
57
|
*/
|
|
58
58
|
export declare const getConfirmedTxStatus: ({ apiKey, txHash, baseUrl, network, }: {
|
|
59
|
-
apiKey?: string
|
|
59
|
+
apiKey?: string;
|
|
60
60
|
baseUrl: string;
|
|
61
61
|
txHash: TxHash;
|
|
62
62
|
network: BlockcypherNetwork;
|
|
63
63
|
}) => Promise<boolean>;
|
|
64
64
|
export declare const broadcastTx: ({ apiKey, baseUrl, network, txHex, }: {
|
|
65
|
-
apiKey?: string
|
|
65
|
+
apiKey?: string;
|
|
66
66
|
baseUrl: string;
|
|
67
67
|
txHex: string;
|
|
68
68
|
network: BlockcypherNetwork;
|
|
@@ -75,5 +75,5 @@ export declare const broadcastTx: ({ apiKey, baseUrl, network, txHex, }: {
|
|
|
75
75
|
*/
|
|
76
76
|
export declare const getBlockchainData: ({ baseUrl, apiKey, }: {
|
|
77
77
|
baseUrl: string;
|
|
78
|
-
apiKey?: string
|
|
78
|
+
apiKey?: string;
|
|
79
79
|
}) => Promise<ChainResponse>;
|
|
@@ -19,7 +19,7 @@ export declare const getTx: ({ apiKey, baseUrl, hash }: TxHashParams) => Promise
|
|
|
19
19
|
* @returns {Transactions}
|
|
20
20
|
*/
|
|
21
21
|
export declare const getTxs: ({ apiKey, address, baseUrl, limit, }: {
|
|
22
|
-
apiKey?: string
|
|
22
|
+
apiKey?: string;
|
|
23
23
|
address: string;
|
|
24
24
|
baseUrl: string;
|
|
25
25
|
limit: number;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import { Balance as BaseBalance, FeeRates, Network, Tx as BaseTx, TxFrom as BaseTxFrom, TxHash, TxHistoryParams, TxTo as BaseTxTo, TxsPage as BaseTxsPage } from '@xchainjs/xchain-client';
|
|
4
2
|
import { Address, Asset } from '@xchainjs/xchain-util';
|
|
5
3
|
export type Witness = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-utxo-providers",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.esm.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@supercharge/promise-pool": "2.4.0",
|
|
32
|
-
"@xchainjs/xchain-client": "2.0.
|
|
33
|
-
"@xchainjs/xchain-util": "2.0.
|
|
32
|
+
"@xchainjs/xchain-client": "2.0.7",
|
|
33
|
+
"@xchainjs/xchain-util": "2.0.4",
|
|
34
34
|
"axios": "^1.8.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|