@pioneer-platform/pioneer 8.2.16 → 8.2.18

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.
Files changed (2) hide show
  1. package/lib/index.js +21 -12
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1016,7 +1016,7 @@ var update_pubkeys = function (username, pubkeys, context) {
1016
1016
  */
1017
1017
  var register_pubkeys = function (username, pubkeys) {
1018
1018
  return __awaiter(this, void 0, void 0, function () {
1019
- var tag, saveActions, allBalances, output, i, pubkeyInfo, nativeAsset, pubkeyExists, entryMongo, xpub, result, zpub, result, result, action, pushTagMongo, saveMongoBulk, allPubkeys, i, pubkeyInfo, e_9;
1019
+ var tag, saveActions, allBalances, output, i, pubkeyInfo, nativeAsset, pubkeyExists, entryMongo, xpub, result, zpub, result, result, action, pushTagMongo, saveMongoBulk, e_9, allPubkeys, i, pubkeyInfo, e_10;
1020
1020
  var _a, _b;
1021
1021
  return __generator(this, function (_c) {
1022
1022
  switch (_c.label) {
@@ -1024,7 +1024,7 @@ var register_pubkeys = function (username, pubkeys) {
1024
1024
  tag = TAG + " | register_pubkeys | ";
1025
1025
  _c.label = 1;
1026
1026
  case 1:
1027
- _c.trys.push([1, 18, , 19]);
1027
+ _c.trys.push([1, 20, , 21]);
1028
1028
  log.debug(tag, "input: ", { username: username, pubkeys: pubkeys });
1029
1029
  saveActions = [];
1030
1030
  allBalances = [];
@@ -1135,7 +1135,9 @@ var register_pubkeys = function (username, pubkeys) {
1135
1135
  saveActions.push(action);
1136
1136
  return [3 /*break*/, 13];
1137
1137
  case 11:
1138
- if (!(pubkeyExists.indexOf(username) === -1)) return [3 /*break*/, 13];
1138
+ //add tag for username
1139
+ log.info(tag, "pubkeyExists.tags: ", pubkeyExists.tags);
1140
+ if (!(pubkeyExists.tags.indexOf(username) === -1)) return [3 /*break*/, 13];
1139
1141
  return [4 /*yield*/, pubkeysDB.update({ pubkey: pubkeyInfo.pubkey }, { $addToSet: { tags: { $each: [username] } } })];
1140
1142
  case 12:
1141
1143
  pushTagMongo = _c.sent();
@@ -1147,14 +1149,21 @@ var register_pubkeys = function (username, pubkeys) {
1147
1149
  case 14:
1148
1150
  //bulk write to mongo
1149
1151
  log.info(tag, "saveActions: ", saveActions);
1150
- if (!(saveActions.length > 0)) return [3 /*break*/, 16];
1151
- return [4 /*yield*/, pubkeysDB.bulkWrite(saveActions, { ordered: false })];
1152
+ if (!(saveActions.length > 0)) return [3 /*break*/, 18];
1153
+ _c.label = 15;
1152
1154
  case 15:
1155
+ _c.trys.push([15, 17, , 18]);
1156
+ return [4 /*yield*/, pubkeysDB.bulkWrite(saveActions, { ordered: false })];
1157
+ case 16:
1153
1158
  saveMongoBulk = _c.sent();
1154
1159
  log.info(tag, "saveMongoBulk: ", saveMongoBulk);
1155
- _c.label = 16;
1156
- case 16: return [4 /*yield*/, pubkeysDB.find({ tags: { $in: [username] } })];
1160
+ return [3 /*break*/, 18];
1157
1161
  case 17:
1162
+ e_9 = _c.sent();
1163
+ log.error("Failed to update in bulk!");
1164
+ return [3 /*break*/, 18];
1165
+ case 18: return [4 /*yield*/, pubkeysDB.find({ tags: { $in: [username] } })];
1166
+ case 19:
1158
1167
  allPubkeys = _c.sent();
1159
1168
  log.info(tag, "allPubkeys: ", allPubkeys.length);
1160
1169
  //get all balances for username
@@ -1166,11 +1175,11 @@ var register_pubkeys = function (username, pubkeys) {
1166
1175
  (_b = output.nfts).push.apply(_b, pubkeyInfo.nfts);
1167
1176
  }
1168
1177
  return [2 /*return*/, output];
1169
- case 18:
1170
- e_9 = _c.sent();
1171
- console.error(tag, "e: ", e_9);
1172
- throw e_9;
1173
- case 19: return [2 /*return*/];
1178
+ case 20:
1179
+ e_10 = _c.sent();
1180
+ console.error(tag, "e: ", e_10);
1181
+ throw e_10;
1182
+ case 21: return [2 /*return*/];
1174
1183
  }
1175
1184
  });
1176
1185
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/pioneer",
3
- "version": "8.2.16",
3
+ "version": "8.2.18",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {