@pioneer-platform/pioneer 8.2.11 → 8.2.15
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 +1 -1
- package/lib/index.js +96 -148
- package/package.json +4 -2
package/lib/index.d.ts
CHANGED
|
@@ -39,4 +39,4 @@ declare let register_xpub: (username: string, pubkey: any, context: string) => P
|
|
|
39
39
|
}>;
|
|
40
40
|
declare let register_address: (username: string, pubkey: any, context: string) => Promise<any>;
|
|
41
41
|
declare let update_pubkeys: (username: string, pubkeys: any, context: string) => Promise<any>;
|
|
42
|
-
declare const register_pubkeys: (username: string, pubkeys: any
|
|
42
|
+
declare const register_pubkeys: (username: string, pubkeys: any) => Promise<any>;
|
package/lib/index.js
CHANGED
|
@@ -94,7 +94,7 @@ var networks = {
|
|
|
94
94
|
'ANY': require('@pioneer-platform/utxo-network'),
|
|
95
95
|
'RUNE': require('@pioneer-platform/thor-network'),
|
|
96
96
|
};
|
|
97
|
-
var _b = require('@pioneer-platform/
|
|
97
|
+
var _b = require('@pioneer-platform/cointools'), get_address_from_xpub = _b.get_address_from_xpub, getNativeAssetForBlockchain = _b.getNativeAssetForBlockchain;
|
|
98
98
|
//const bcrypt = require('bcryptjs');
|
|
99
99
|
var numbro = require("numbro");
|
|
100
100
|
var log = require('@pioneer-platform/loggerdog')();
|
|
@@ -165,10 +165,10 @@ module.exports = {
|
|
|
165
165
|
});
|
|
166
166
|
});
|
|
167
167
|
},
|
|
168
|
-
register: function (username, pubkeys
|
|
168
|
+
register: function (username, pubkeys) {
|
|
169
169
|
return __awaiter(this, void 0, void 0, function () {
|
|
170
170
|
return __generator(this, function (_a) {
|
|
171
|
-
return [2 /*return*/, register_pubkeys(username, pubkeys
|
|
171
|
+
return [2 /*return*/, register_pubkeys(username, pubkeys)];
|
|
172
172
|
});
|
|
173
173
|
});
|
|
174
174
|
},
|
|
@@ -235,14 +235,14 @@ function setInCache(key, data, expiration) {
|
|
|
235
235
|
var get_pubkey_balances = function (pubkey) {
|
|
236
236
|
var _a, _b;
|
|
237
237
|
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
-
var tag, output, balances_1, nfts, positions, cacheKey, cachedData, balance, _c, cacheKeyZapper, cachedDataZapper, zapperInfo, cacheKeyAllPioneers, cachedAllPioneers, allPioneers, isPioneer, updatedUsername, pioneerImage, updatedUsername2, cacheKeyBlockbookInfo, cachedBlockbookInfo, blockbookInfo, cacheKeyNetwork, cachedDataNetwork, balanceNetwork, pubkeyInfo,
|
|
238
|
+
var tag, output, balances_1, nfts, positions, cacheKey, cachedData, balance, _c, cacheKeyZapper, cachedDataZapper, zapperInfo, cacheKeyAllPioneers, cachedAllPioneers, allPioneers, isPioneer, updatedUsername, pioneerImage, updatedUsername2, cacheKeyBlockbookInfo, cachedBlockbookInfo, blockbookInfo, cacheKeyNetwork, cachedDataNetwork, balanceNetwork, pubkeyInfo, _loop_1, i, e_2;
|
|
239
239
|
return __generator(this, function (_d) {
|
|
240
240
|
switch (_d.label) {
|
|
241
241
|
case 0:
|
|
242
242
|
tag = TAG + " | get_pubkey_balances | ";
|
|
243
243
|
_d.label = 1;
|
|
244
244
|
case 1:
|
|
245
|
-
_d.trys.push([1,
|
|
245
|
+
_d.trys.push([1, 35, , 36]);
|
|
246
246
|
output = {};
|
|
247
247
|
if (!pubkey.symbol && pubkey.asset)
|
|
248
248
|
pubkey.symbol = pubkey.asset;
|
|
@@ -497,102 +497,30 @@ var get_pubkey_balances = function (pubkey) {
|
|
|
497
497
|
log.debug(tag, "nfts: ", pubkeyInfo.nfts.length);
|
|
498
498
|
log.debug(tag, "balances: ", balances_1);
|
|
499
499
|
log.debug(tag, "balances: ", balances_1.length);
|
|
500
|
-
saveActions = [];
|
|
501
500
|
_loop_1 = function (i) {
|
|
502
|
-
var balance, balanceIndex, assetInfo;
|
|
503
|
-
var _e;
|
|
504
|
-
return __generator(this, function (_f) {
|
|
505
|
-
switch (_f.label) {
|
|
506
|
-
case 0:
|
|
507
|
-
balance = balances_1[i];
|
|
508
|
-
balanceIndex = pubkeyInfo.balances.findIndex(function (e) { return e.symbol === balance.symbol; });
|
|
509
|
-
return [4 /*yield*/, assetsDB.findOne({ symbol: balance.symbol })];
|
|
510
|
-
case 1:
|
|
511
|
-
assetInfo = _f.sent();
|
|
512
|
-
log.debug(tag, "assetInfo: ", assetInfo);
|
|
513
|
-
if (assetInfo) {
|
|
514
|
-
balance.caip = assetInfo.caip;
|
|
515
|
-
balance.image = assetInfo.image;
|
|
516
|
-
balance.assetCaip = assetInfo.caip;
|
|
517
|
-
balance.description = assetInfo.description;
|
|
518
|
-
balance.website = assetInfo.website;
|
|
519
|
-
balance.explorer = assetInfo.explorer;
|
|
520
|
-
balance.context = pubkey.context;
|
|
521
|
-
}
|
|
522
|
-
if (balanceIndex !== -1 && pubkeyInfo.balances[balanceIndex].balance !== balance.balance) {
|
|
523
|
-
saveActions.push({
|
|
524
|
-
updateOne: {
|
|
525
|
-
filter: { pubkey: pubkey.pubkey },
|
|
526
|
-
update: {
|
|
527
|
-
$set: (_e = {}, _e["balances.".concat(balanceIndex)] = balance, _e),
|
|
528
|
-
},
|
|
529
|
-
},
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
log.debug(tag, pubkey.context + ": balance not changed! ", balance.symbol);
|
|
534
|
-
}
|
|
535
|
-
return [2 /*return*/];
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
};
|
|
539
|
-
i = 0;
|
|
540
|
-
_d.label = 35;
|
|
541
|
-
case 35:
|
|
542
|
-
if (!(i < balances_1.length)) return [3 /*break*/, 38];
|
|
543
|
-
return [5 /*yield**/, _loop_1(i)];
|
|
544
|
-
case 36:
|
|
545
|
-
_d.sent();
|
|
546
|
-
_d.label = 37;
|
|
547
|
-
case 37:
|
|
548
|
-
i++;
|
|
549
|
-
return [3 /*break*/, 35];
|
|
550
|
-
case 38:
|
|
551
|
-
_loop_2 = function (i) {
|
|
552
501
|
var nft = nfts[i];
|
|
553
502
|
log.debug(tag, "pubkeyInfo.nfts: ", pubkeyInfo.nfts.length);
|
|
554
503
|
var existingNft = pubkeyInfo.nfts.find(function (e) { return e.name === nft.name; });
|
|
555
|
-
if (!existingNft) {
|
|
556
|
-
saveActions.push({
|
|
557
|
-
updateOne: {
|
|
558
|
-
filter: { pubkey: pubkey.pubkey },
|
|
559
|
-
update: {
|
|
560
|
-
$addToSet: { nfts: nft }
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
504
|
};
|
|
566
505
|
for (i = 0; i < nfts.length; i++) {
|
|
567
|
-
|
|
506
|
+
_loop_1(i);
|
|
568
507
|
}
|
|
569
|
-
if (!(saveActions.length > 0)) return [3 /*break*/, 40];
|
|
570
|
-
return [4 /*yield*/, pubkeysDB.bulkWrite(saveActions, { ordered: false })];
|
|
571
|
-
case 39:
|
|
572
|
-
updateSuccess = _d.sent();
|
|
573
|
-
log.debug(tag, "updateSuccess: ", updateSuccess);
|
|
574
|
-
output.dbUpdate = updateSuccess;
|
|
575
|
-
_d.label = 40;
|
|
576
|
-
case 40:
|
|
577
|
-
//@TODO save transactions
|
|
578
|
-
// Build output
|
|
579
|
-
output.pubkeys = [pubkeyInfo];
|
|
580
508
|
output.balances = balances_1;
|
|
581
509
|
output.nfts = nfts;
|
|
582
510
|
output.success = true;
|
|
583
511
|
return [2 /*return*/, output];
|
|
584
|
-
case
|
|
512
|
+
case 35:
|
|
585
513
|
e_2 = _d.sent();
|
|
586
514
|
console.error(tag, "e: ", e_2);
|
|
587
515
|
throw e_2;
|
|
588
|
-
case
|
|
516
|
+
case 36: return [2 /*return*/];
|
|
589
517
|
}
|
|
590
518
|
});
|
|
591
519
|
});
|
|
592
520
|
};
|
|
593
521
|
var get_and_rescan_pubkeys = function (username) {
|
|
594
522
|
return __awaiter(this, void 0, void 0, function () {
|
|
595
|
-
var tag, pubkeysMongo, userInfo, blockchains, pubkeys, masters, i, pubkeyInfo,
|
|
523
|
+
var tag, pubkeysMongo, userInfo, blockchains, pubkeys, masters, i, pubkeyInfo, _loop_2, j, e_3;
|
|
596
524
|
return __generator(this, function (_a) {
|
|
597
525
|
switch (_a.label) {
|
|
598
526
|
case 0:
|
|
@@ -618,7 +546,7 @@ var get_and_rescan_pubkeys = function (username) {
|
|
|
618
546
|
for (i = 0; i < pubkeysMongo.length; i++) {
|
|
619
547
|
pubkeyInfo = pubkeysMongo[i];
|
|
620
548
|
delete pubkeyInfo._id;
|
|
621
|
-
|
|
549
|
+
_loop_2 = function (j) {
|
|
622
550
|
var context = userInfo.wallets[i];
|
|
623
551
|
if (pubkeyInfo.type === 'zpub') {
|
|
624
552
|
//if context found in tags
|
|
@@ -642,7 +570,7 @@ var get_and_rescan_pubkeys = function (username) {
|
|
|
642
570
|
};
|
|
643
571
|
//for each wallet by user
|
|
644
572
|
for (j = 0; j < userInfo.wallets.length; j++) {
|
|
645
|
-
|
|
573
|
+
_loop_2(j);
|
|
646
574
|
}
|
|
647
575
|
}
|
|
648
576
|
return [2 /*return*/, { pubkeys: pubkeys, masters: masters }];
|
|
@@ -797,7 +725,7 @@ var register_zpub = function (username, pubkey, context) {
|
|
|
797
725
|
case 3:
|
|
798
726
|
result = _a.sent();
|
|
799
727
|
log.debug(result);
|
|
800
|
-
return [2 /*return*/,
|
|
728
|
+
return [2 /*return*/, result];
|
|
801
729
|
case 4:
|
|
802
730
|
e_5 = _a.sent();
|
|
803
731
|
console.error(tag, "e: ", e_5);
|
|
@@ -898,7 +826,7 @@ var register_address = function (username, pubkey, context) {
|
|
|
898
826
|
case 2:
|
|
899
827
|
result = _a.sent();
|
|
900
828
|
log.debug(tag, "result: ", result);
|
|
901
|
-
return [2 /*return*/,
|
|
829
|
+
return [2 /*return*/, result];
|
|
902
830
|
case 3:
|
|
903
831
|
e_7 = _a.sent();
|
|
904
832
|
console.error(tag, "e: ", e_7);
|
|
@@ -1083,29 +1011,40 @@ var update_pubkeys = function (username, pubkeys, context) {
|
|
|
1083
1011
|
});
|
|
1084
1012
|
});
|
|
1085
1013
|
};
|
|
1086
|
-
|
|
1014
|
+
/*
|
|
1015
|
+
Rules:
|
|
1016
|
+
|
|
1017
|
+
only go to network if no pubkey exists
|
|
1018
|
+
|
|
1019
|
+
do not sync balances here (we only sync balances on context change)
|
|
1020
|
+
|
|
1021
|
+
*/
|
|
1022
|
+
var register_pubkeys = function (username, pubkeys) {
|
|
1087
1023
|
return __awaiter(this, void 0, void 0, function () {
|
|
1088
|
-
var tag, saveActions, allBalances, output, i, pubkeyInfo, nativeAsset, entryMongo, xpub, result, zpub, result, result,
|
|
1089
|
-
var _a, _b, _c;
|
|
1090
|
-
return __generator(this, function (
|
|
1091
|
-
switch (
|
|
1024
|
+
var tag, saveActions, allBalances, output, i, pubkeyInfo, nativeAsset, pubkeyExists, entryMongo, xpub, result, zpub, result, result, action, saveMongoBulk, allPubkeys, i, pubkeyInfo, e_9;
|
|
1025
|
+
var _a, _b, _c, _d, _e;
|
|
1026
|
+
return __generator(this, function (_f) {
|
|
1027
|
+
switch (_f.label) {
|
|
1092
1028
|
case 0:
|
|
1093
1029
|
tag = TAG + " | register_pubkeys | ";
|
|
1094
|
-
|
|
1030
|
+
_f.label = 1;
|
|
1095
1031
|
case 1:
|
|
1096
|
-
|
|
1097
|
-
log.debug(tag, "input: ", { username: username, pubkeys: pubkeys
|
|
1032
|
+
_f.trys.push([1, 16, , 17]);
|
|
1033
|
+
log.debug(tag, "input: ", { username: username, pubkeys: pubkeys });
|
|
1098
1034
|
saveActions = [];
|
|
1099
1035
|
allBalances = [];
|
|
1100
1036
|
output = {};
|
|
1101
1037
|
output.pubkeys = [];
|
|
1102
1038
|
output.balances = [];
|
|
1039
|
+
output.nfts = [];
|
|
1103
1040
|
i = 0;
|
|
1104
|
-
|
|
1041
|
+
_f.label = 2;
|
|
1105
1042
|
case 2:
|
|
1106
|
-
if (!(i < pubkeys.length)) return [3 /*break*/,
|
|
1043
|
+
if (!(i < pubkeys.length)) return [3 /*break*/, 12];
|
|
1107
1044
|
pubkeyInfo = pubkeys[i];
|
|
1108
1045
|
log.debug(tag, "pubkeyInfo: ", pubkeyInfo);
|
|
1046
|
+
if (!pubkeyInfo.blockchain)
|
|
1047
|
+
throw Error("Invalid pubkey required field: blockchain");
|
|
1109
1048
|
nativeAsset = getNativeAssetForBlockchain(pubkeyInfo.blockchain);
|
|
1110
1049
|
if (!nativeAsset)
|
|
1111
1050
|
throw Error("104: invalid pubkey! unsupported by coins module!");
|
|
@@ -1113,19 +1052,22 @@ var register_pubkeys = function (username, pubkeys, context) {
|
|
|
1113
1052
|
throw Error("104: invalid pubkey! missing pubkey!");
|
|
1114
1053
|
if (!pubkeyInfo.type)
|
|
1115
1054
|
throw Error("104: invalid pubkey! missing type!");
|
|
1116
|
-
//TODO verify type is in enums
|
|
1117
|
-
//hack
|
|
1118
1055
|
if (!pubkeyInfo.symbol)
|
|
1119
1056
|
pubkeyInfo.symbol = nativeAsset;
|
|
1120
|
-
log.debug(tag, "pubkeyInfo: ", pubkeyInfo);
|
|
1121
|
-
if (!pubkeyInfo.blockchain)
|
|
1122
|
-
throw Error("Invalid pubkey required field: blockchain");
|
|
1123
1057
|
if (!pubkeyInfo.script_type)
|
|
1124
1058
|
throw Error("Invalid pubkey required field: script_type coin:" + pubkeyInfo.blockchain);
|
|
1125
1059
|
if (!pubkeyInfo.network)
|
|
1126
1060
|
throw Error("Invalid pubkey required field: network coin:" + pubkeyInfo.blockchain);
|
|
1127
1061
|
if (!pubkeyInfo.master)
|
|
1128
1062
|
throw Error("Invalid pubkey required field: master coin:" + pubkeyInfo.blockchain);
|
|
1063
|
+
if (!pubkeyInfo.path)
|
|
1064
|
+
throw Error("Invalid pubkey required field: path coin:" + pubkeyInfo.blockchain);
|
|
1065
|
+
if (!pubkeyInfo.context)
|
|
1066
|
+
throw Error("Invalid pubkey required field: context:" + pubkeyInfo.blockchain);
|
|
1067
|
+
return [4 /*yield*/, pubkeysDB.findOne({ pubkey: pubkeyInfo.pubkey })];
|
|
1068
|
+
case 3:
|
|
1069
|
+
pubkeyExists = _f.sent();
|
|
1070
|
+
if (!!pubkeyExists) return [3 /*break*/, 11];
|
|
1129
1071
|
entryMongo = {
|
|
1130
1072
|
pubkey: pubkeyInfo.pubkey,
|
|
1131
1073
|
type: pubkeyInfo.type,
|
|
@@ -1137,9 +1079,9 @@ var register_pubkeys = function (username, pubkeys, context) {
|
|
|
1137
1079
|
script_type: pubkeyInfo.script_type,
|
|
1138
1080
|
network: pubkeyInfo.blockchain,
|
|
1139
1081
|
created: new Date().getTime(),
|
|
1140
|
-
tags: [username, pubkeyInfo.blockchain, pubkeyInfo.symbol, pubkeyInfo.network, context],
|
|
1082
|
+
tags: [username, pubkeyInfo.blockchain, pubkeyInfo.symbol, pubkeyInfo.network, pubkeyInfo.context],
|
|
1141
1083
|
};
|
|
1142
|
-
if (!(pubkeyInfo.type === "xpub")) return [3 /*break*/,
|
|
1084
|
+
if (!(pubkeyInfo.type === "xpub")) return [3 /*break*/, 5];
|
|
1143
1085
|
log.debug(tag, "pubkeyInfo: ", pubkeyInfo);
|
|
1144
1086
|
xpub = pubkeyInfo.pubkey;
|
|
1145
1087
|
log.debug(tag, "xpub: ", xpub);
|
|
@@ -1148,78 +1090,84 @@ var register_pubkeys = function (username, pubkeys, context) {
|
|
|
1148
1090
|
entryMongo.type = 'xpub';
|
|
1149
1091
|
entryMongo.master = pubkeyInfo.address;
|
|
1150
1092
|
entryMongo.address = pubkeyInfo.address;
|
|
1151
|
-
return [4 /*yield*/, register_xpub(username, pubkeyInfo, context)];
|
|
1152
|
-
case
|
|
1153
|
-
result =
|
|
1093
|
+
return [4 /*yield*/, register_xpub(username, pubkeyInfo, pubkeyInfo.context)];
|
|
1094
|
+
case 4:
|
|
1095
|
+
result = _f.sent();
|
|
1096
|
+
entryMongo.balances = result.balances;
|
|
1154
1097
|
allBalances.push.apply(allBalances, result.balances);
|
|
1155
1098
|
(_a = output.pubkeys).push.apply(_a, result.pubkeys);
|
|
1156
|
-
return [3 /*break*/,
|
|
1157
|
-
case
|
|
1158
|
-
if (!(pubkeyInfo.type === "zpub")) return [3 /*break*/,
|
|
1099
|
+
return [3 /*break*/, 10];
|
|
1100
|
+
case 5:
|
|
1101
|
+
if (!(pubkeyInfo.type === "zpub")) return [3 /*break*/, 7];
|
|
1159
1102
|
zpub = pubkeyInfo.pubkey;
|
|
1160
1103
|
entryMongo.pubkey = zpub;
|
|
1161
1104
|
entryMongo.zpub = zpub;
|
|
1162
1105
|
entryMongo.type = 'zpub';
|
|
1163
1106
|
entryMongo.master = pubkeyInfo.address;
|
|
1164
1107
|
entryMongo.address = pubkeyInfo.address;
|
|
1165
|
-
return [4 /*yield*/, register_xpub(username, pubkeyInfo, context)];
|
|
1166
|
-
case
|
|
1167
|
-
result =
|
|
1108
|
+
return [4 /*yield*/, register_xpub(username, pubkeyInfo, pubkeyInfo.context)];
|
|
1109
|
+
case 6:
|
|
1110
|
+
result = _f.sent();
|
|
1111
|
+
entryMongo.balances = result.balances;
|
|
1168
1112
|
allBalances.push.apply(allBalances, result.balances);
|
|
1169
1113
|
(_b = output.pubkeys).push.apply(_b, result.pubkeys);
|
|
1170
|
-
return [3 /*break*/,
|
|
1171
|
-
case
|
|
1172
|
-
if (!(pubkeyInfo.type === "address")) return [3 /*break*/,
|
|
1114
|
+
return [3 /*break*/, 10];
|
|
1115
|
+
case 7:
|
|
1116
|
+
if (!(pubkeyInfo.type === "address")) return [3 /*break*/, 9];
|
|
1173
1117
|
entryMongo.pubkey = pubkeyInfo.pubkey;
|
|
1174
1118
|
entryMongo.master = pubkeyInfo.pubkey;
|
|
1175
1119
|
entryMongo.type = pubkeyInfo.type;
|
|
1176
1120
|
entryMongo.address = pubkeyInfo.address;
|
|
1177
|
-
return [4 /*yield*/, register_address(username, pubkeyInfo, context)];
|
|
1178
|
-
case
|
|
1179
|
-
result =
|
|
1121
|
+
return [4 /*yield*/, register_address(username, pubkeyInfo, pubkeyInfo.context)];
|
|
1122
|
+
case 8:
|
|
1123
|
+
result = _f.sent();
|
|
1124
|
+
entryMongo.balances = result.balances;
|
|
1180
1125
|
allBalances.push.apply(allBalances, result.balances);
|
|
1181
1126
|
(_c = output.pubkeys).push.apply(_c, result.pubkeys);
|
|
1182
|
-
return [3 /*break*/,
|
|
1183
|
-
case 8:
|
|
1184
|
-
log.error("Unhandled type: ", pubkeyInfo.type);
|
|
1185
|
-
_d.label = 9;
|
|
1127
|
+
return [3 /*break*/, 10];
|
|
1186
1128
|
case 9:
|
|
1129
|
+
log.error(tag, "Unhandled type: ", pubkeyInfo.type);
|
|
1130
|
+
_f.label = 10;
|
|
1131
|
+
case 10:
|
|
1187
1132
|
//verify write
|
|
1188
|
-
log.
|
|
1133
|
+
log.info(tag, "entryMongo: ", entryMongo);
|
|
1189
1134
|
if (!entryMongo.pubkey)
|
|
1190
1135
|
throw Error("103: Invalid pubkey! can not save!");
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1136
|
+
if (!entryMongo.balances)
|
|
1137
|
+
throw Error("103: Invalid pubkey! no balances set!");
|
|
1138
|
+
action = {
|
|
1139
|
+
insertOne: entryMongo
|
|
1140
|
+
};
|
|
1141
|
+
saveActions.push(action);
|
|
1142
|
+
_f.label = 11;
|
|
1197
1143
|
case 11:
|
|
1198
|
-
pushTagMongo = _d.sent();
|
|
1199
|
-
log.debug(tag, "pushTagMongo: ", pushTagMongo);
|
|
1200
|
-
return [3 /*break*/, 15];
|
|
1201
|
-
case 12:
|
|
1202
|
-
if (!(!entryMongo.pubkey || entryMongo.pubkey == true)) return [3 /*break*/, 13];
|
|
1203
|
-
log.error(" **** ERROR INVALID PUBKEY ENTRY! ***** pubkeyInfo: ", pubkeyInfo);
|
|
1204
|
-
log.error(" **** ERROR INVALID PUBKEY ENTRY! ***** entryMongo: ", entryMongo);
|
|
1205
|
-
throw Error("105: unable to save invalid pubkey!");
|
|
1206
|
-
case 13: return [4 /*yield*/, pubkeysDB.insert(entryMongo)];
|
|
1207
|
-
case 14:
|
|
1208
|
-
saveMongo = _d.sent();
|
|
1209
|
-
log.debug(tag, "saveMongo: ", saveMongo);
|
|
1210
|
-
_d.label = 15;
|
|
1211
|
-
case 15:
|
|
1212
1144
|
i++;
|
|
1213
1145
|
return [3 /*break*/, 2];
|
|
1214
|
-
case
|
|
1215
|
-
|
|
1216
|
-
|
|
1146
|
+
case 12:
|
|
1147
|
+
if (!(saveActions.length > 0)) return [3 /*break*/, 14];
|
|
1148
|
+
return [4 /*yield*/, pubkeysDB.bulkWrite(saveActions, { ordered: false })];
|
|
1149
|
+
case 13:
|
|
1150
|
+
saveMongoBulk = _f.sent();
|
|
1151
|
+
log.info(tag, "saveMongoBulk: ", saveMongoBulk);
|
|
1152
|
+
_f.label = 14;
|
|
1153
|
+
case 14: return [4 /*yield*/, pubkeysDB.find({ tags: { $in: [username] } })];
|
|
1154
|
+
case 15:
|
|
1155
|
+
allPubkeys = _f.sent();
|
|
1156
|
+
log.info(tag, "allPubkeys: ", allPubkeys.length);
|
|
1157
|
+
//get all balances for username
|
|
1158
|
+
for (i = 0; i < allPubkeys.length; i++) {
|
|
1159
|
+
pubkeyInfo = allPubkeys[i];
|
|
1160
|
+
if (pubkeyInfo.balances)
|
|
1161
|
+
(_d = output.balances).push.apply(_d, pubkeyInfo.balances);
|
|
1162
|
+
if (pubkeyInfo.nfts)
|
|
1163
|
+
(_e = output.nfts).push.apply(_e, pubkeyInfo.nfts);
|
|
1164
|
+
}
|
|
1217
1165
|
return [2 /*return*/, output];
|
|
1218
|
-
case
|
|
1219
|
-
e_9 =
|
|
1166
|
+
case 16:
|
|
1167
|
+
e_9 = _f.sent();
|
|
1220
1168
|
console.error(tag, "e: ", e_9);
|
|
1221
1169
|
throw e_9;
|
|
1222
|
-
case
|
|
1170
|
+
case 17: return [2 /*return*/];
|
|
1223
1171
|
}
|
|
1224
1172
|
});
|
|
1225
1173
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/pioneer",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.15",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -22,12 +22,14 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@pioneer-platform/blockbook": "^8.1.61",
|
|
24
24
|
"@pioneer-platform/blocknative-client": "^8.1.27",
|
|
25
|
+
"@pioneer-platform/cointools": "^8.1.72",
|
|
25
26
|
"@pioneer-platform/loggerdog": "^8.1.31",
|
|
26
27
|
"@pioneer-platform/pioneer-caip": "^8.1.79",
|
|
27
28
|
"@pioneer-platform/redis-queue": "^8.1.24",
|
|
28
29
|
"@pioneer-platform/unchained": "^8.1.63",
|
|
29
30
|
"@pioneer-platform/zapper-client": "^8.1.26",
|
|
30
|
-
"dotenv": "^8.2.0"
|
|
31
|
+
"dotenv": "^8.2.0",
|
|
32
|
+
"short-uuid": "^4.2.2"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/jest": "^25.2.3",
|