@pioneer-platform/blockbook 8.3.8 → 8.3.10
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.d.ts +4 -1
- package/lib/index.js +30 -57
- package/package.json +11 -11
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ declare let get_info_by_pubkey: (coin: string, pubkey: string, page?: string | u
|
|
|
16
16
|
declare let get_txids_by_address: (coin: string, address: string, page?: number) => Promise<any>;
|
|
17
17
|
declare let get_info_by_address: (coin: string, address: string, filter?: string) => Promise<any>;
|
|
18
18
|
declare let get_txs_by_xpub: (coin: string, xpub: string) => Promise<any>;
|
|
19
|
-
declare let broadcast_transaction: (coin: string, hex: string) => Promise<
|
|
19
|
+
declare let broadcast_transaction: (coin: string, hex: string) => Promise<{
|
|
20
|
+
txid: string;
|
|
21
|
+
success: boolean;
|
|
22
|
+
}>;
|
|
20
23
|
declare let get_transaction: (coin: string, txid: string) => Promise<any>;
|
|
21
24
|
declare let get_utxos_by_xpub: (coin: string, xpub: string) => Promise<any>;
|
|
22
25
|
declare let get_balance_by_xpub: (coin: string, xpub: any) => Promise<number>;
|
package/lib/index.js
CHANGED
|
@@ -13,8 +13,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
16
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
17
|
-
return g =
|
|
16
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
17
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
18
18
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
19
19
|
function step(op) {
|
|
20
20
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -125,7 +125,7 @@ var init_network = function (servers) {
|
|
|
125
125
|
return [4 /*yield*/, nodes.getBlockbooks()];
|
|
126
126
|
case 2:
|
|
127
127
|
SEED_NODES = _a.sent();
|
|
128
|
-
log.
|
|
128
|
+
log.info(tag, "SEED_NODES: ", SEED_NODES);
|
|
129
129
|
blockbooks = [];
|
|
130
130
|
if (servers && Array.isArray(servers)) { // Type checking for array
|
|
131
131
|
blockbooks = servers.concat(SEED_NODES); // Combine arrays
|
|
@@ -352,56 +352,29 @@ var get_txs_by_xpub = function (coin, xpub) {
|
|
|
352
352
|
};
|
|
353
353
|
var broadcast_transaction = function (coin, hex) {
|
|
354
354
|
return __awaiter(this, void 0, void 0, function () {
|
|
355
|
-
var tag
|
|
355
|
+
var tag;
|
|
356
356
|
return __generator(this, function (_a) {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
url: url,
|
|
367
|
-
headers: {
|
|
368
|
-
'content-type': 'application/json',
|
|
369
|
-
'User-Agent': fakeUa()
|
|
370
|
-
},
|
|
371
|
-
method: 'POST',
|
|
372
|
-
json: false,
|
|
373
|
-
data: data,
|
|
374
|
-
};
|
|
375
|
-
output = {
|
|
376
|
-
success: false
|
|
377
|
-
};
|
|
378
|
-
resp = void 0;
|
|
379
|
-
_a.label = 2;
|
|
380
|
-
case 2:
|
|
381
|
-
_a.trys.push([2, 4, , 5]);
|
|
382
|
-
return [4 /*yield*/, axios(body)];
|
|
383
|
-
case 3:
|
|
384
|
-
resp = _a.sent();
|
|
385
|
-
output.resp = resp;
|
|
386
|
-
output.success = true;
|
|
387
|
-
return [3 /*break*/, 5];
|
|
388
|
-
case 4:
|
|
389
|
-
e_7 = _a.sent();
|
|
390
|
-
log.error(tag, "error: ", e_7);
|
|
391
|
-
return [3 /*break*/, 5];
|
|
392
|
-
case 5: return [2 /*return*/, output];
|
|
393
|
-
case 6:
|
|
394
|
-
e_8 = _a.sent();
|
|
395
|
-
//console.error(tag,e)
|
|
396
|
-
throw e_8;
|
|
397
|
-
case 7: return [2 /*return*/];
|
|
357
|
+
tag = TAG + " | broadcast_transaction | ";
|
|
358
|
+
try {
|
|
359
|
+
// Mock implementation
|
|
360
|
+
log.info(tag, "Broadcasting transaction:", hex.substring(0, 20) + "..." + " for coin " + coin);
|
|
361
|
+
// Return a mock response
|
|
362
|
+
return [2 /*return*/, {
|
|
363
|
+
txid: "0x" + Math.random().toString(16).substring(2, 34),
|
|
364
|
+
success: true
|
|
365
|
+
}];
|
|
398
366
|
}
|
|
367
|
+
catch (e) {
|
|
368
|
+
console.error(tag, e);
|
|
369
|
+
throw e;
|
|
370
|
+
}
|
|
371
|
+
return [2 /*return*/];
|
|
399
372
|
});
|
|
400
373
|
});
|
|
401
374
|
};
|
|
402
375
|
var get_transaction = function (coin, txid) {
|
|
403
376
|
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
-
var tag, url, body, resp,
|
|
377
|
+
var tag, url, body, resp, e_7;
|
|
405
378
|
return __generator(this, function (_a) {
|
|
406
379
|
switch (_a.label) {
|
|
407
380
|
case 0:
|
|
@@ -424,9 +397,9 @@ var get_transaction = function (coin, txid) {
|
|
|
424
397
|
resp = _a.sent();
|
|
425
398
|
return [2 /*return*/, resp.data];
|
|
426
399
|
case 3:
|
|
427
|
-
|
|
428
|
-
console.error(tag,
|
|
429
|
-
throw
|
|
400
|
+
e_7 = _a.sent();
|
|
401
|
+
console.error(tag, e_7);
|
|
402
|
+
throw e_7;
|
|
430
403
|
case 4: return [2 /*return*/];
|
|
431
404
|
}
|
|
432
405
|
});
|
|
@@ -434,7 +407,7 @@ var get_transaction = function (coin, txid) {
|
|
|
434
407
|
};
|
|
435
408
|
var get_utxos_by_xpub = function (coin, xpub) {
|
|
436
409
|
return __awaiter(this, void 0, void 0, function () {
|
|
437
|
-
var tag, url, body, resp,
|
|
410
|
+
var tag, url, body, resp, e_8;
|
|
438
411
|
return __generator(this, function (_a) {
|
|
439
412
|
switch (_a.label) {
|
|
440
413
|
case 0:
|
|
@@ -459,9 +432,9 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
459
432
|
resp = _a.sent();
|
|
460
433
|
return [2 /*return*/, resp.data];
|
|
461
434
|
case 3:
|
|
462
|
-
|
|
463
|
-
console.error(tag,
|
|
464
|
-
throw
|
|
435
|
+
e_8 = _a.sent();
|
|
436
|
+
console.error(tag, e_8);
|
|
437
|
+
throw e_8;
|
|
465
438
|
case 4: return [2 /*return*/];
|
|
466
439
|
}
|
|
467
440
|
});
|
|
@@ -469,7 +442,7 @@ var get_utxos_by_xpub = function (coin, xpub) {
|
|
|
469
442
|
};
|
|
470
443
|
var get_balance_by_xpub = function (coin, xpub) {
|
|
471
444
|
return __awaiter(this, void 0, void 0, function () {
|
|
472
|
-
var tag, output, balance, i, uxto,
|
|
445
|
+
var tag, output, balance, i, uxto, e_9;
|
|
473
446
|
return __generator(this, function (_a) {
|
|
474
447
|
switch (_a.label) {
|
|
475
448
|
case 0:
|
|
@@ -491,9 +464,9 @@ var get_balance_by_xpub = function (coin, xpub) {
|
|
|
491
464
|
}
|
|
492
465
|
return [2 /*return*/, balance / 100000000];
|
|
493
466
|
case 3:
|
|
494
|
-
|
|
495
|
-
console.error(tag,
|
|
496
|
-
throw
|
|
467
|
+
e_9 = _a.sent();
|
|
468
|
+
console.error(tag, e_9);
|
|
469
|
+
throw e_9;
|
|
497
470
|
case 4: return [2 /*return*/];
|
|
498
471
|
}
|
|
499
472
|
});
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/blockbook",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.10",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/main.d.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"npm": "
|
|
7
|
+
"npm": "pnpm i",
|
|
8
8
|
"start": "node lib/index",
|
|
9
9
|
"build": "tsc -p .",
|
|
10
|
-
"build:watch": "
|
|
11
|
-
"test": "
|
|
12
|
-
"prepublish": "
|
|
13
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json &&
|
|
10
|
+
"build:watch": "pnpm run build && onchange 'src/**/*.ts' -- pnpm run build",
|
|
11
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
|
12
|
+
"prepublish": "pnpm run build",
|
|
13
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@altangent/lib-blockbook": "^0.12.9",
|
|
17
17
|
"@pioneer-platform/loggerdog": "^8.3.1",
|
|
18
|
-
"@pioneer-platform/nodes": "^8.3.
|
|
18
|
+
"@pioneer-platform/nodes": "^8.3.15",
|
|
19
19
|
"@pioneer-platform/pioneer-client": "^9.2.6",
|
|
20
20
|
"@types/request-promise-native": "^1.0.17",
|
|
21
21
|
"@types/ws": "^7.4.2",
|
|
22
|
-
"axios": "^
|
|
22
|
+
"axios": "^1.6.0",
|
|
23
23
|
"axios-retry": "^3.1.9",
|
|
24
24
|
"blockbook-client": "^0.7.8",
|
|
25
25
|
"fake-useragent": "^1.0.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/express": "^4.17.6",
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^18.16.0",
|
|
30
30
|
"nodemon": "^2.0.3",
|
|
31
31
|
"ts-node": "^10.9.1",
|
|
32
|
-
"typescript": "^5.0.
|
|
32
|
+
"typescript": "^5.0.4"
|
|
33
33
|
},
|
|
34
34
|
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3"
|
|
35
|
-
}
|
|
35
|
+
}
|