@xchainjs/xchain-utxo-providers 2.0.0 → 2.0.1
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 +18 -13
- package/lib/index.js +18 -13
- package/lib/providers/nownodes/nownodes-api.d.ts +1 -1
- package/package.json +2 -2
package/lib/index.esm.js
CHANGED
|
@@ -605,6 +605,7 @@ const broadcastTx$2 = ({ txHex, haskoinUrl, haskoinNetwork, }) => __awaiter(void
|
|
|
605
605
|
const response = yield axiosInstance.post(url, txHex);
|
|
606
606
|
const { txid } = response.data;
|
|
607
607
|
return txid;
|
|
608
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
608
609
|
}
|
|
609
610
|
catch (error) {
|
|
610
611
|
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 500) {
|
|
@@ -1175,7 +1176,7 @@ const getTx = ({ apiKey, baseUrl, hash }) => __awaiter(void 0, void 0, void 0, f
|
|
|
1175
1176
|
const response = yield axios.get(url, {
|
|
1176
1177
|
headers: {
|
|
1177
1178
|
'api-key': apiKey,
|
|
1178
|
-
}
|
|
1179
|
+
},
|
|
1179
1180
|
});
|
|
1180
1181
|
const tx = response.data;
|
|
1181
1182
|
return tx;
|
|
@@ -1193,11 +1194,11 @@ const getTxs = ({ apiKey, address, baseUrl, limit, }) => __awaiter(void 0, void
|
|
|
1193
1194
|
const response = yield axios.get(url, {
|
|
1194
1195
|
params: {
|
|
1195
1196
|
details: 'txs',
|
|
1196
|
-
pageSize: limit
|
|
1197
|
+
pageSize: limit,
|
|
1197
1198
|
},
|
|
1198
1199
|
headers: {
|
|
1199
1200
|
'api-key': apiKey,
|
|
1200
|
-
}
|
|
1201
|
+
},
|
|
1201
1202
|
});
|
|
1202
1203
|
const txs = response.data;
|
|
1203
1204
|
return txs.transactions;
|
|
@@ -1213,11 +1214,11 @@ const getUTXOs = ({ apiKey, address, baseUrl, isConfirmed = true, }) => __awaite
|
|
|
1213
1214
|
const url = `${baseUrl}/utxo/${address}`;
|
|
1214
1215
|
const response = yield axios.get(url, {
|
|
1215
1216
|
params: {
|
|
1216
|
-
confirmed: isConfirmed
|
|
1217
|
+
confirmed: isConfirmed,
|
|
1217
1218
|
},
|
|
1218
1219
|
headers: {
|
|
1219
1220
|
'api-key': apiKey,
|
|
1220
|
-
}
|
|
1221
|
+
},
|
|
1221
1222
|
});
|
|
1222
1223
|
const utxos = response.data;
|
|
1223
1224
|
return utxos;
|
|
@@ -1236,10 +1237,12 @@ const getBalance = ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecim
|
|
|
1236
1237
|
const response = yield axios.get(url, {
|
|
1237
1238
|
headers: {
|
|
1238
1239
|
'api-key': apiKey,
|
|
1239
|
-
}
|
|
1240
|
+
},
|
|
1240
1241
|
});
|
|
1241
1242
|
const balanceResponse = response.data;
|
|
1242
|
-
const balance = confirmedOnly
|
|
1243
|
+
const balance = confirmedOnly
|
|
1244
|
+
? baseAmount(balanceResponse.balance, assetDecimals)
|
|
1245
|
+
: baseAmount(balanceResponse.balance).plus(balanceResponse.unconfirmedBalance, assetDecimals);
|
|
1243
1246
|
return balance;
|
|
1244
1247
|
});
|
|
1245
1248
|
const broadcastTx = ({ apiKey, baseUrl, txHex, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1247,7 +1250,7 @@ const broadcastTx = ({ apiKey, baseUrl, txHex, }) => __awaiter(void 0, void 0, v
|
|
|
1247
1250
|
const response = yield axios.get(url, {
|
|
1248
1251
|
headers: {
|
|
1249
1252
|
'api-key': apiKey,
|
|
1250
|
-
}
|
|
1253
|
+
},
|
|
1251
1254
|
});
|
|
1252
1255
|
return response.data.result;
|
|
1253
1256
|
});
|
|
@@ -1283,7 +1286,7 @@ class NownodesProvider {
|
|
|
1283
1286
|
apiKey: this._apiKey,
|
|
1284
1287
|
baseUrl: this.baseUrl,
|
|
1285
1288
|
address: address,
|
|
1286
|
-
isConfirmed: true
|
|
1289
|
+
isConfirmed: true,
|
|
1287
1290
|
});
|
|
1288
1291
|
return this.mapUTXOs(allUnspent);
|
|
1289
1292
|
});
|
|
@@ -1294,7 +1297,7 @@ class NownodesProvider {
|
|
|
1294
1297
|
apiKey: this._apiKey,
|
|
1295
1298
|
baseUrl: this.baseUrl,
|
|
1296
1299
|
address: address,
|
|
1297
|
-
isConfirmed: false
|
|
1300
|
+
isConfirmed: false,
|
|
1298
1301
|
});
|
|
1299
1302
|
return this.mapUTXOs(allUnspent);
|
|
1300
1303
|
});
|
|
@@ -1361,11 +1364,13 @@ class NownodesProvider {
|
|
|
1361
1364
|
mapUTXOs(utxos) {
|
|
1362
1365
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1363
1366
|
return utxos.flatMap((currentUtxo) => {
|
|
1364
|
-
return [
|
|
1367
|
+
return [
|
|
1368
|
+
{
|
|
1365
1369
|
hash: currentUtxo.txid,
|
|
1366
1370
|
index: currentUtxo.vout,
|
|
1367
|
-
value: Number(currentUtxo.value)
|
|
1368
|
-
}
|
|
1371
|
+
value: Number(currentUtxo.value),
|
|
1372
|
+
},
|
|
1373
|
+
];
|
|
1369
1374
|
});
|
|
1370
1375
|
});
|
|
1371
1376
|
}
|
package/lib/index.js
CHANGED
|
@@ -612,6 +612,7 @@ const broadcastTx$2 = ({ txHex, haskoinUrl, haskoinNetwork, }) => __awaiter(void
|
|
|
612
612
|
const response = yield axiosInstance.post(url, txHex);
|
|
613
613
|
const { txid } = response.data;
|
|
614
614
|
return txid;
|
|
615
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
615
616
|
}
|
|
616
617
|
catch (error) {
|
|
617
618
|
if (((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 500) {
|
|
@@ -1182,7 +1183,7 @@ const getTx = ({ apiKey, baseUrl, hash }) => __awaiter(void 0, void 0, void 0, f
|
|
|
1182
1183
|
const response = yield axios__default.default.get(url, {
|
|
1183
1184
|
headers: {
|
|
1184
1185
|
'api-key': apiKey,
|
|
1185
|
-
}
|
|
1186
|
+
},
|
|
1186
1187
|
});
|
|
1187
1188
|
const tx = response.data;
|
|
1188
1189
|
return tx;
|
|
@@ -1200,11 +1201,11 @@ const getTxs = ({ apiKey, address, baseUrl, limit, }) => __awaiter(void 0, void
|
|
|
1200
1201
|
const response = yield axios__default.default.get(url, {
|
|
1201
1202
|
params: {
|
|
1202
1203
|
details: 'txs',
|
|
1203
|
-
pageSize: limit
|
|
1204
|
+
pageSize: limit,
|
|
1204
1205
|
},
|
|
1205
1206
|
headers: {
|
|
1206
1207
|
'api-key': apiKey,
|
|
1207
|
-
}
|
|
1208
|
+
},
|
|
1208
1209
|
});
|
|
1209
1210
|
const txs = response.data;
|
|
1210
1211
|
return txs.transactions;
|
|
@@ -1220,11 +1221,11 @@ const getUTXOs = ({ apiKey, address, baseUrl, isConfirmed = true, }) => __awaite
|
|
|
1220
1221
|
const url = `${baseUrl}/utxo/${address}`;
|
|
1221
1222
|
const response = yield axios__default.default.get(url, {
|
|
1222
1223
|
params: {
|
|
1223
|
-
confirmed: isConfirmed
|
|
1224
|
+
confirmed: isConfirmed,
|
|
1224
1225
|
},
|
|
1225
1226
|
headers: {
|
|
1226
1227
|
'api-key': apiKey,
|
|
1227
|
-
}
|
|
1228
|
+
},
|
|
1228
1229
|
});
|
|
1229
1230
|
const utxos = response.data;
|
|
1230
1231
|
return utxos;
|
|
@@ -1243,10 +1244,12 @@ const getBalance = ({ apiKey, baseUrl, address, confirmedOnly = true, assetDecim
|
|
|
1243
1244
|
const response = yield axios__default.default.get(url, {
|
|
1244
1245
|
headers: {
|
|
1245
1246
|
'api-key': apiKey,
|
|
1246
|
-
}
|
|
1247
|
+
},
|
|
1247
1248
|
});
|
|
1248
1249
|
const balanceResponse = response.data;
|
|
1249
|
-
const balance = confirmedOnly
|
|
1250
|
+
const balance = confirmedOnly
|
|
1251
|
+
? xchainUtil.baseAmount(balanceResponse.balance, assetDecimals)
|
|
1252
|
+
: xchainUtil.baseAmount(balanceResponse.balance).plus(balanceResponse.unconfirmedBalance, assetDecimals);
|
|
1250
1253
|
return balance;
|
|
1251
1254
|
});
|
|
1252
1255
|
const broadcastTx = ({ apiKey, baseUrl, txHex, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1254,7 +1257,7 @@ const broadcastTx = ({ apiKey, baseUrl, txHex, }) => __awaiter(void 0, void 0, v
|
|
|
1254
1257
|
const response = yield axios__default.default.get(url, {
|
|
1255
1258
|
headers: {
|
|
1256
1259
|
'api-key': apiKey,
|
|
1257
|
-
}
|
|
1260
|
+
},
|
|
1258
1261
|
});
|
|
1259
1262
|
return response.data.result;
|
|
1260
1263
|
});
|
|
@@ -1290,7 +1293,7 @@ class NownodesProvider {
|
|
|
1290
1293
|
apiKey: this._apiKey,
|
|
1291
1294
|
baseUrl: this.baseUrl,
|
|
1292
1295
|
address: address,
|
|
1293
|
-
isConfirmed: true
|
|
1296
|
+
isConfirmed: true,
|
|
1294
1297
|
});
|
|
1295
1298
|
return this.mapUTXOs(allUnspent);
|
|
1296
1299
|
});
|
|
@@ -1301,7 +1304,7 @@ class NownodesProvider {
|
|
|
1301
1304
|
apiKey: this._apiKey,
|
|
1302
1305
|
baseUrl: this.baseUrl,
|
|
1303
1306
|
address: address,
|
|
1304
|
-
isConfirmed: false
|
|
1307
|
+
isConfirmed: false,
|
|
1305
1308
|
});
|
|
1306
1309
|
return this.mapUTXOs(allUnspent);
|
|
1307
1310
|
});
|
|
@@ -1368,11 +1371,13 @@ class NownodesProvider {
|
|
|
1368
1371
|
mapUTXOs(utxos) {
|
|
1369
1372
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1370
1373
|
return utxos.flatMap((currentUtxo) => {
|
|
1371
|
-
return [
|
|
1374
|
+
return [
|
|
1375
|
+
{
|
|
1372
1376
|
hash: currentUtxo.txid,
|
|
1373
1377
|
index: currentUtxo.vout,
|
|
1374
|
-
value: Number(currentUtxo.value)
|
|
1375
|
-
}
|
|
1378
|
+
value: Number(currentUtxo.value),
|
|
1379
|
+
},
|
|
1380
|
+
];
|
|
1376
1381
|
});
|
|
1377
1382
|
});
|
|
1378
1383
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TxHash } from '@xchainjs/xchain-client';
|
|
2
2
|
import { BaseAmount } from '@xchainjs/xchain-util';
|
|
3
|
-
import { BalanceParams, Transaction, TxHashParams
|
|
3
|
+
import { AddressUTXO, BalanceParams, Transaction, TxHashParams } from './nownodes-api-types';
|
|
4
4
|
/**
|
|
5
5
|
* Get transaction by hash.
|
|
6
6
|
*
|
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.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.esm.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@supercharge/promise-pool": "2.4.0",
|
|
32
|
-
"@xchainjs/xchain-client": "2.0.
|
|
32
|
+
"@xchainjs/xchain-client": "2.0.1",
|
|
33
33
|
"@xchainjs/xchain-util": "2.0.0",
|
|
34
34
|
"axios": "1.8.4"
|
|
35
35
|
},
|