@pioneer-platform/maya-network 8.3.7 → 8.3.9
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 +6 -0
- package/lib/index.js +62 -4
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -22,4 +22,10 @@ declare let get_account_info: (address: string) => Promise<any>;
|
|
|
22
22
|
declare let normalize_tx: (tx: any, address?: string) => any;
|
|
23
23
|
declare let get_txs_by_address: (address: string) => Promise<any>;
|
|
24
24
|
declare let get_balance: (address: string) => Promise<number>;
|
|
25
|
+
declare let get_balances: (address: string) => Promise<{
|
|
26
|
+
denom: any;
|
|
27
|
+
amountBase: any;
|
|
28
|
+
amount: number;
|
|
29
|
+
decimals: number;
|
|
30
|
+
}[]>;
|
|
25
31
|
declare let get_node_info_verbose: () => Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -94,6 +94,9 @@ module.exports = {
|
|
|
94
94
|
getBalance: function (address) {
|
|
95
95
|
return get_balance(address);
|
|
96
96
|
},
|
|
97
|
+
getBalances: function (address) {
|
|
98
|
+
return get_balances(address);
|
|
99
|
+
},
|
|
97
100
|
getAccount: function (address) {
|
|
98
101
|
return get_account_info(address);
|
|
99
102
|
},
|
|
@@ -573,9 +576,64 @@ var get_balance = function (address) {
|
|
|
573
576
|
});
|
|
574
577
|
});
|
|
575
578
|
};
|
|
579
|
+
var get_balances = function (address) {
|
|
580
|
+
var _a;
|
|
581
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
582
|
+
var tag, output, accountInfo, i, entry, e_13, e_14;
|
|
583
|
+
return __generator(this, function (_b) {
|
|
584
|
+
switch (_b.label) {
|
|
585
|
+
case 0:
|
|
586
|
+
tag = TAG + " | get_balances | ";
|
|
587
|
+
_b.label = 1;
|
|
588
|
+
case 1:
|
|
589
|
+
_b.trys.push([1, 6, , 7]);
|
|
590
|
+
output = [];
|
|
591
|
+
_b.label = 2;
|
|
592
|
+
case 2:
|
|
593
|
+
_b.trys.push([2, 4, , 5]);
|
|
594
|
+
return [4 /*yield*/, axios({ method: 'GET', url: URL_THORNODE + '/bank/balances/' + address })];
|
|
595
|
+
case 3:
|
|
596
|
+
accountInfo = _b.sent();
|
|
597
|
+
log.info(tag, "accountInfo: ", accountInfo.data);
|
|
598
|
+
//
|
|
599
|
+
if ((_a = accountInfo.data) === null || _a === void 0 ? void 0 : _a.result) {
|
|
600
|
+
for (i = 0; i < accountInfo.data.result.length; i++) {
|
|
601
|
+
entry = accountInfo.data.result[i];
|
|
602
|
+
if (entry.denom === 'cacao') {
|
|
603
|
+
output.push({
|
|
604
|
+
denom: entry.denom,
|
|
605
|
+
amountBase: entry.amount,
|
|
606
|
+
amount: entry.amount / 10000000000,
|
|
607
|
+
decimals: 10
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
if (entry.denom === 'maya') {
|
|
611
|
+
output.push({
|
|
612
|
+
denom: entry.denom,
|
|
613
|
+
amountBase: entry.amount,
|
|
614
|
+
amount: entry.amount / 10000,
|
|
615
|
+
decimals: 4
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return [3 /*break*/, 5];
|
|
621
|
+
case 4:
|
|
622
|
+
e_13 = _b.sent();
|
|
623
|
+
return [3 /*break*/, 5];
|
|
624
|
+
case 5: return [2 /*return*/, output];
|
|
625
|
+
case 6:
|
|
626
|
+
e_14 = _b.sent();
|
|
627
|
+
log.error(tag, "e: ", e_14);
|
|
628
|
+
throw e_14;
|
|
629
|
+
case 7: return [2 /*return*/];
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
};
|
|
576
634
|
var get_node_info_verbose = function () {
|
|
577
635
|
return __awaiter(this, void 0, void 0, function () {
|
|
578
|
-
var tag, output, syncInfo, nodeInfo, lastBlock,
|
|
636
|
+
var tag, output, syncInfo, nodeInfo, lastBlock, e_15;
|
|
579
637
|
return __generator(this, function (_a) {
|
|
580
638
|
switch (_a.label) {
|
|
581
639
|
case 0:
|
|
@@ -602,9 +660,9 @@ var get_node_info_verbose = function () {
|
|
|
602
660
|
output.height = lastBlock.data.block.header.height;
|
|
603
661
|
return [2 /*return*/, output];
|
|
604
662
|
case 5:
|
|
605
|
-
|
|
606
|
-
log.error(tag, "e: ",
|
|
607
|
-
throw
|
|
663
|
+
e_15 = _a.sent();
|
|
664
|
+
log.error(tag, "e: ", e_15);
|
|
665
|
+
throw e_15;
|
|
608
666
|
case 6: return [2 /*return*/];
|
|
609
667
|
}
|
|
610
668
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/maya-network",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.9",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"ts-node": "^8.10.2",
|
|
28
28
|
"typescript": "^5.0.2"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "e4a7114f00103ee48533c369dba4a02021ddcbe4"
|
|
31
31
|
}
|