@pioneer-platform/pioneer
Advanced tools
Comparing version 8.2.15 to 8.2.16
@@ -37,3 +37,3 @@ declare const TAG = " | Pioneer | "; | ||
declare let register_xpub: (username: string, pubkey: any, context: string) => Promise<{ | ||
pubkeys: any; | ||
nfts: any; | ||
balances: any; | ||
@@ -40,0 +40,0 @@ }>; |
113
lib/index.js
@@ -740,3 +740,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tag, queueId, account, index, address, work, _a, pubkeys, balances, e_6; | ||
var tag, queueId, account, index, address, work, _a, balances, nfts, e_6; | ||
return __generator(this, function (_b) { | ||
@@ -785,6 +785,5 @@ switch (_b.label) { | ||
case 3: | ||
_a = _b.sent(), pubkeys = _a.pubkeys, balances = _a.balances; | ||
log.debug(tag, "pubkeys: ", pubkeys.length); | ||
log.debug(tag, "balances: ", balances.length); | ||
return [2 /*return*/, { pubkeys: pubkeys, balances: balances }]; | ||
_a = _b.sent(), balances = _a.balances, nfts = _a.nfts; | ||
log.info(tag, "balances: ", balances.length); | ||
return [2 /*return*/, { nfts: nfts, balances: balances }]; | ||
case 4: | ||
@@ -844,10 +843,9 @@ e_6 = _b.sent(); | ||
var tag, saveActions, output, allPubkeys, PubkeyMap, i, pubkeyInfo, allBalances, allKnownPubkeys, knownPubkeys_1, i, unknown, i, pubkey, pubkeyInfo, nativeAsset, entryMongo, result, result, result, keyExists, pushTagMongo, resultSave, e_8; | ||
var _a, _b, _c; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
tag = TAG + " | update_pubkeys | "; | ||
_d.label = 1; | ||
_a.label = 1; | ||
case 1: | ||
_d.trys.push([1, 20, , 21]); | ||
_a.trys.push([1, 20, , 21]); | ||
log.debug(tag, "input: ", { username: username, pubkeys: pubkeys, context: context }); | ||
@@ -871,3 +869,3 @@ saveActions = []; | ||
case 2: | ||
allKnownPubkeys = _d.sent(); | ||
allKnownPubkeys = _a.sent(); | ||
log.debug(tag, "allKnownPubkeys: ", allKnownPubkeys.length); | ||
@@ -885,3 +883,3 @@ knownPubkeys_1 = []; | ||
i = 0; | ||
_d.label = 3; | ||
_a.label = 3; | ||
case 3: | ||
@@ -936,6 +934,5 @@ if (!(i < unknown.length)) return [3 /*break*/, 17]; | ||
case 4: | ||
result = _d.sent(); | ||
result = _a.sent(); | ||
entryMongo.balances = result.balances; | ||
allBalances.push.apply(allBalances, result.balances); | ||
(_a = output.pubkeys).push.apply(_a, result.pubkeys); | ||
return [3 /*break*/, 10]; | ||
@@ -954,6 +951,5 @@ case 5: | ||
case 6: | ||
result = _d.sent(); | ||
result = _a.sent(); | ||
entryMongo.balances = result.balances; | ||
allBalances.push.apply(allBalances, result.balances); | ||
(_b = output.pubkeys).push.apply(_b, result.pubkeys); | ||
return [3 /*break*/, 10]; | ||
@@ -965,10 +961,9 @@ case 7: | ||
case 8: | ||
result = _d.sent(); | ||
result = _a.sent(); | ||
entryMongo.balances = result.balances; | ||
allBalances.push.apply(allBalances, result.balances); | ||
(_c = output.pubkeys).push.apply(_c, result.pubkeys); | ||
return [3 /*break*/, 10]; | ||
case 9: | ||
log.error("Unhandled type: ", pubkeyInfo.type); | ||
_d.label = 10; | ||
_a.label = 10; | ||
case 10: | ||
@@ -979,3 +974,3 @@ //verify write | ||
case 11: | ||
keyExists = _d.sent(); | ||
keyExists = _a.sent(); | ||
if (!keyExists) return [3 /*break*/, 13]; | ||
@@ -985,3 +980,3 @@ log.debug(tag, "Key already registered! key: ", entryMongo); | ||
case 12: | ||
pushTagMongo = _d.sent(); | ||
pushTagMongo = _a.sent(); | ||
log.debug(tag, "pushTagMongo: ", pushTagMongo); | ||
@@ -996,5 +991,5 @@ return [3 /*break*/, 16]; | ||
case 15: | ||
resultSave = _d.sent(); | ||
resultSave = _a.sent(); | ||
log.debug(tag, "resultSave: ", resultSave); | ||
_d.label = 16; | ||
_a.label = 16; | ||
case 16: | ||
@@ -1006,3 +1001,3 @@ i++; | ||
log.debug(tag, " No new pubkeys! "); | ||
_d.label = 19; | ||
_a.label = 19; | ||
case 19: | ||
@@ -1018,3 +1013,3 @@ log.debug(tag, "output: ", output); | ||
case 20: | ||
e_8 = _d.sent(); | ||
e_8 = _a.sent(); | ||
console.error(tag, "e: ", e_8); | ||
@@ -1037,11 +1032,11 @@ throw e_8; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var tag, saveActions, allBalances, output, i, pubkeyInfo, nativeAsset, pubkeyExists, entryMongo, xpub, result, zpub, result, result, action, saveMongoBulk, allPubkeys, i, pubkeyInfo, e_9; | ||
var _a, _b, _c, _d, _e; | ||
return __generator(this, function (_f) { | ||
switch (_f.label) { | ||
var tag, saveActions, allBalances, output, i, pubkeyInfo, nativeAsset, pubkeyExists, entryMongo, xpub, result, zpub, result, result, action, pushTagMongo, saveMongoBulk, allPubkeys, i, pubkeyInfo, e_9; | ||
var _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
tag = TAG + " | register_pubkeys | "; | ||
_f.label = 1; | ||
_c.label = 1; | ||
case 1: | ||
_f.trys.push([1, 16, , 17]); | ||
_c.trys.push([1, 18, , 19]); | ||
log.debug(tag, "input: ", { username: username, pubkeys: pubkeys }); | ||
@@ -1055,5 +1050,5 @@ saveActions = []; | ||
i = 0; | ||
_f.label = 2; | ||
_c.label = 2; | ||
case 2: | ||
if (!(i < pubkeys.length)) return [3 /*break*/, 12]; | ||
if (!(i < pubkeys.length)) return [3 /*break*/, 14]; | ||
pubkeyInfo = pubkeys[i]; | ||
@@ -1084,3 +1079,4 @@ log.debug(tag, "pubkeyInfo: ", pubkeyInfo); | ||
case 3: | ||
pubkeyExists = _f.sent(); | ||
pubkeyExists = _c.sent(); | ||
log.info(tag, "pubkeyExists: ", pubkeyExists); | ||
if (!!pubkeyExists) return [3 /*break*/, 11]; | ||
@@ -1111,6 +1107,5 @@ entryMongo = { | ||
case 4: | ||
result = _f.sent(); | ||
result = _c.sent(); | ||
entryMongo.balances = result.balances; | ||
allBalances.push.apply(allBalances, result.balances); | ||
(_a = output.pubkeys).push.apply(_a, result.pubkeys); | ||
return [3 /*break*/, 10]; | ||
@@ -1127,6 +1122,5 @@ case 5: | ||
case 6: | ||
result = _f.sent(); | ||
result = _c.sent(); | ||
entryMongo.balances = result.balances; | ||
allBalances.push.apply(allBalances, result.balances); | ||
(_b = output.pubkeys).push.apply(_b, result.pubkeys); | ||
return [3 /*break*/, 10]; | ||
@@ -1141,10 +1135,9 @@ case 7: | ||
case 8: | ||
result = _f.sent(); | ||
result = _c.sent(); | ||
entryMongo.balances = result.balances; | ||
allBalances.push.apply(allBalances, result.balances); | ||
(_c = output.pubkeys).push.apply(_c, result.pubkeys); | ||
return [3 /*break*/, 10]; | ||
case 9: | ||
log.error(tag, "Unhandled type: ", pubkeyInfo.type); | ||
_f.label = 10; | ||
_c.label = 10; | ||
case 10: | ||
@@ -1160,17 +1153,27 @@ //verify write | ||
}; | ||
log.info(tag, "action: ", action); | ||
saveActions.push(action); | ||
_f.label = 11; | ||
return [3 /*break*/, 13]; | ||
case 11: | ||
if (!(pubkeyExists.indexOf(username) === -1)) return [3 /*break*/, 13]; | ||
return [4 /*yield*/, pubkeysDB.update({ pubkey: pubkeyInfo.pubkey }, { $addToSet: { tags: { $each: [username] } } })]; | ||
case 12: | ||
pushTagMongo = _c.sent(); | ||
log.info(tag, "pushTagMongo: ", pushTagMongo); | ||
_c.label = 13; | ||
case 13: | ||
i++; | ||
return [3 /*break*/, 2]; | ||
case 12: | ||
if (!(saveActions.length > 0)) return [3 /*break*/, 14]; | ||
case 14: | ||
//bulk write to mongo | ||
log.info(tag, "saveActions: ", saveActions); | ||
if (!(saveActions.length > 0)) return [3 /*break*/, 16]; | ||
return [4 /*yield*/, pubkeysDB.bulkWrite(saveActions, { ordered: false })]; | ||
case 13: | ||
saveMongoBulk = _f.sent(); | ||
case 15: | ||
saveMongoBulk = _c.sent(); | ||
log.info(tag, "saveMongoBulk: ", saveMongoBulk); | ||
_f.label = 14; | ||
case 14: return [4 /*yield*/, pubkeysDB.find({ tags: { $in: [username] } })]; | ||
case 15: | ||
allPubkeys = _f.sent(); | ||
_c.label = 16; | ||
case 16: return [4 /*yield*/, pubkeysDB.find({ tags: { $in: [username] } })]; | ||
case 17: | ||
allPubkeys = _c.sent(); | ||
log.info(tag, "allPubkeys: ", allPubkeys.length); | ||
@@ -1181,12 +1184,12 @@ //get all balances for username | ||
if (pubkeyInfo.balances) | ||
(_d = output.balances).push.apply(_d, pubkeyInfo.balances); | ||
(_a = output.balances).push.apply(_a, pubkeyInfo.balances); | ||
if (pubkeyInfo.nfts) | ||
(_e = output.nfts).push.apply(_e, pubkeyInfo.nfts); | ||
(_b = output.nfts).push.apply(_b, pubkeyInfo.nfts); | ||
} | ||
return [2 /*return*/, output]; | ||
case 16: | ||
e_9 = _f.sent(); | ||
case 18: | ||
e_9 = _c.sent(); | ||
console.error(tag, "e: ", e_9); | ||
throw e_9; | ||
case 17: return [2 /*return*/]; | ||
case 19: return [2 /*return*/]; | ||
} | ||
@@ -1193,0 +1196,0 @@ }); |
{ | ||
"name": "@pioneer-platform/pioneer", | ||
"version": "8.2.15", | ||
"version": "8.2.16", | ||
"main": "./lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
62645
1222