@keetanetwork/keetanet-client 0.10.2 → 0.10.3

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.
@@ -127180,18 +127180,18 @@ function client_computeLedgerEffect(_x, _x2, _x3, _x4) {
127180
127180
  * A partial LedgerStorageAPI which just has the methods for "addTimeStatistics"
127181
127181
  */
127182
127182
  function src_client_computeLedgerEffect() {
127183
- src_client_computeLedgerEffect = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee12(options, effects, storageProvider, transaction) {
127183
+ src_client_computeLedgerEffect = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee13(options, effects, storageProvider, transaction) {
127184
127184
  var _options$getFinalNume, getFinalNumericValues, _options$computePermi, computePermissions, _options$computeWeigh, computeWeights, _options$checkNegativ, checkNegative, baseToken, getBalanceCache, getPreviousBalance, getWeightCache, getWeight, getRepCache, getRep, getAccountInfoCache, getAccountInfo, getPermissionCache, getPermissions, supplies, balances, weights, permissions, getBalanceEntry, modifyBalance, modifyWeight, modifySupply, _i, _Object$values, _effects$accountPubKe, _fields$supply, _Object$values$_i, _account, fields, accountPubKey, _iterator3, _step3, supplyChange, permissionUpdates, permissionsReadEntity, _fields$permissions, _iterator4, _step4, permUpdate, _iterator5, _step5, _previousEntry$permis, _permUpdate, newPermissions, _previousEntry, previousPermissions, delegationField, isDelegating, currentDelegation, previousBalance, receivable, tokenPubKey, _fields$balance, _fields$balance2, tokenAcct, _iterator6, _step6, balanceUpdate, isReceive, value, otherAccount, receiveFromPubKey, previousEntry, receivableAmount, receiveValid, balanceChange, otherAccountPubKey, isBaseToken, currentRep, ret;
127185
- return client_common_regeneratorRuntime().wrap(function _callee12$(_context12) {
127186
- while (1) switch (_context12.prev = _context12.next) {
127185
+ return client_common_regeneratorRuntime().wrap(function _callee13$(_context13) {
127186
+ while (1) switch (_context13.prev = _context13.next) {
127187
127187
  case 0:
127188
127188
  _options$getFinalNume = options.getFinalNumericValues, getFinalNumericValues = _options$getFinalNume === void 0 ? false : _options$getFinalNume, _options$computePermi = options.computePermissions, computePermissions = _options$computePermi === void 0 ? false : _options$computePermi, _options$computeWeigh = options.computeWeights, computeWeights = _options$computeWeigh === void 0 ? false : _options$computeWeigh, _options$checkNegativ = options.checkNegative, checkNegative = _options$checkNegativ === void 0 ? false : _options$checkNegativ, baseToken = options.baseToken;
127189
127189
  getBalanceCache = {};
127190
127190
  getPreviousBalance = /*#__PURE__*/function () {
127191
- var _ref = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee4(account, token) {
127191
+ var _ref = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee5(account, token) {
127192
127192
  var accountPubKey, tokenPubKey;
127193
- return client_common_regeneratorRuntime().wrap(function _callee4$(_context4) {
127194
- while (1) switch (_context4.prev = _context4.next) {
127193
+ return client_common_regeneratorRuntime().wrap(function _callee5$(_context5) {
127194
+ while (1) switch (_context5.prev = _context5.next) {
127195
127195
  case 0:
127196
127196
  accountPubKey = client_lib_account.toPublicKeyString(account);
127197
127197
  tokenPubKey = client_lib_account.toPublicKeyString(token);
@@ -127199,20 +127199,20 @@ function src_client_computeLedgerEffect() {
127199
127199
  getBalanceCache[accountPubKey] = {};
127200
127200
  }
127201
127201
  if (!(getBalanceCache[accountPubKey][tokenPubKey] === undefined)) {
127202
- _context4.next = 7;
127202
+ _context5.next = 7;
127203
127203
  break;
127204
127204
  }
127205
- _context4.next = 6;
127205
+ _context5.next = 6;
127206
127206
  return storageProvider.getBalance(transaction, account, token);
127207
127207
  case 6:
127208
- getBalanceCache[accountPubKey][tokenPubKey] = _context4.sent;
127208
+ getBalanceCache[accountPubKey][tokenPubKey] = _context5.sent;
127209
127209
  case 7:
127210
- return _context4.abrupt("return", getBalanceCache[accountPubKey][tokenPubKey]);
127210
+ return _context5.abrupt("return", getBalanceCache[accountPubKey][tokenPubKey]);
127211
127211
  case 8:
127212
127212
  case "end":
127213
- return _context4.stop();
127213
+ return _context5.stop();
127214
127214
  }
127215
- }, _callee4);
127215
+ }, _callee5);
127216
127216
  }));
127217
127217
  return function getPreviousBalance(_x10, _x11) {
127218
127218
  return _ref.apply(this, arguments);
@@ -127220,27 +127220,27 @@ function src_client_computeLedgerEffect() {
127220
127220
  }();
127221
127221
  getWeightCache = {};
127222
127222
  getWeight = /*#__PURE__*/function () {
127223
- var _ref2 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee5(rep) {
127223
+ var _ref2 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee6(rep) {
127224
127224
  var repPubKey;
127225
- return client_common_regeneratorRuntime().wrap(function _callee5$(_context5) {
127226
- while (1) switch (_context5.prev = _context5.next) {
127225
+ return client_common_regeneratorRuntime().wrap(function _callee6$(_context6) {
127226
+ while (1) switch (_context6.prev = _context6.next) {
127227
127227
  case 0:
127228
127228
  repPubKey = client_lib_account.toPublicKeyString(rep);
127229
127229
  if (!(getWeightCache[repPubKey] === undefined)) {
127230
- _context5.next = 5;
127230
+ _context6.next = 5;
127231
127231
  break;
127232
127232
  }
127233
- _context5.next = 4;
127233
+ _context6.next = 4;
127234
127234
  return storageProvider.delegatedWeight(transaction, rep);
127235
127235
  case 4:
127236
- getWeightCache[repPubKey] = _context5.sent;
127236
+ getWeightCache[repPubKey] = _context6.sent;
127237
127237
  case 5:
127238
- return _context5.abrupt("return", getWeightCache[repPubKey]);
127238
+ return _context6.abrupt("return", getWeightCache[repPubKey]);
127239
127239
  case 6:
127240
127240
  case "end":
127241
- return _context5.stop();
127241
+ return _context6.stop();
127242
127242
  }
127243
- }, _callee5);
127243
+ }, _callee6);
127244
127244
  }));
127245
127245
  return function getWeight(_x12) {
127246
127246
  return _ref2.apply(this, arguments);
@@ -127248,35 +127248,35 @@ function src_client_computeLedgerEffect() {
127248
127248
  }();
127249
127249
  getRepCache = {};
127250
127250
  getRep = /*#__PURE__*/function () {
127251
- var _ref3 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee6(account, readWeight) {
127251
+ var _ref3 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee7(account, readWeight) {
127252
127252
  var accountPubKey, resolvedRep;
127253
- return client_common_regeneratorRuntime().wrap(function _callee6$(_context6) {
127254
- while (1) switch (_context6.prev = _context6.next) {
127253
+ return client_common_regeneratorRuntime().wrap(function _callee7$(_context7) {
127254
+ while (1) switch (_context7.prev = _context7.next) {
127255
127255
  case 0:
127256
127256
  accountPubKey = client_lib_account.toPublicKeyString(account);
127257
127257
  if (!(getRepCache[accountPubKey] === undefined)) {
127258
- _context6.next = 5;
127258
+ _context7.next = 5;
127259
127259
  break;
127260
127260
  }
127261
- _context6.next = 4;
127261
+ _context7.next = 4;
127262
127262
  return storageProvider.getAccountRep(transaction, account);
127263
127263
  case 4:
127264
- getRepCache[accountPubKey] = _context6.sent;
127264
+ getRepCache[accountPubKey] = _context7.sent;
127265
127265
  case 5:
127266
127266
  resolvedRep = getRepCache[accountPubKey];
127267
127267
  if (!(resolvedRep && readWeight)) {
127268
- _context6.next = 9;
127268
+ _context7.next = 9;
127269
127269
  break;
127270
127270
  }
127271
- _context6.next = 9;
127271
+ _context7.next = 9;
127272
127272
  return getWeight(resolvedRep);
127273
127273
  case 9:
127274
- return _context6.abrupt("return", resolvedRep);
127274
+ return _context7.abrupt("return", resolvedRep);
127275
127275
  case 10:
127276
127276
  case "end":
127277
- return _context6.stop();
127277
+ return _context7.stop();
127278
127278
  }
127279
- }, _callee6);
127279
+ }, _callee7);
127280
127280
  }));
127281
127281
  return function getRep(_x13, _x14) {
127282
127282
  return _ref3.apply(this, arguments);
@@ -127284,27 +127284,27 @@ function src_client_computeLedgerEffect() {
127284
127284
  }();
127285
127285
  getAccountInfoCache = {};
127286
127286
  getAccountInfo = /*#__PURE__*/function () {
127287
- var _ref4 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee7(account) {
127287
+ var _ref4 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee8(account) {
127288
127288
  var accountPubKey;
127289
- return client_common_regeneratorRuntime().wrap(function _callee7$(_context7) {
127290
- while (1) switch (_context7.prev = _context7.next) {
127289
+ return client_common_regeneratorRuntime().wrap(function _callee8$(_context8) {
127290
+ while (1) switch (_context8.prev = _context8.next) {
127291
127291
  case 0:
127292
127292
  accountPubKey = client_lib_account.toPublicKeyString(account);
127293
127293
  if (!(getAccountInfoCache[accountPubKey] === undefined)) {
127294
- _context7.next = 5;
127294
+ _context8.next = 5;
127295
127295
  break;
127296
127296
  }
127297
- _context7.next = 4;
127297
+ _context8.next = 4;
127298
127298
  return storageProvider.getAccountInfo(transaction, account);
127299
127299
  case 4:
127300
- getAccountInfoCache[accountPubKey] = _context7.sent;
127300
+ getAccountInfoCache[accountPubKey] = _context8.sent;
127301
127301
  case 5:
127302
- return _context7.abrupt("return", getAccountInfoCache[accountPubKey]);
127302
+ return _context8.abrupt("return", getAccountInfoCache[accountPubKey]);
127303
127303
  case 6:
127304
127304
  case "end":
127305
- return _context7.stop();
127305
+ return _context8.stop();
127306
127306
  }
127307
- }, _callee7);
127307
+ }, _callee8);
127308
127308
  }));
127309
127309
  return function getAccountInfo(_x15) {
127310
127310
  return _ref4.apply(this, arguments);
@@ -127312,27 +127312,27 @@ function src_client_computeLedgerEffect() {
127312
127312
  }();
127313
127313
  getPermissionCache = {};
127314
127314
  getPermissions = /*#__PURE__*/function () {
127315
- var _ref5 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee8(account, entityList) {
127315
+ var _ref5 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee9(account, entityList) {
127316
127316
  var accountPubKey;
127317
- return client_common_regeneratorRuntime().wrap(function _callee8$(_context8) {
127318
- while (1) switch (_context8.prev = _context8.next) {
127317
+ return client_common_regeneratorRuntime().wrap(function _callee9$(_context9) {
127318
+ while (1) switch (_context9.prev = _context9.next) {
127319
127319
  case 0:
127320
127320
  accountPubKey = account.publicKeyString.get();
127321
127321
  if (!(getPermissionCache[accountPubKey] === undefined)) {
127322
- _context8.next = 5;
127322
+ _context9.next = 5;
127323
127323
  break;
127324
127324
  }
127325
- _context8.next = 4;
127325
+ _context9.next = 4;
127326
127326
  return storageProvider.listACLsByPrincipal(transaction, account, entityList);
127327
127327
  case 4:
127328
- getPermissionCache[accountPubKey] = _context8.sent;
127328
+ getPermissionCache[accountPubKey] = _context9.sent;
127329
127329
  case 5:
127330
- return _context8.abrupt("return", getPermissionCache[accountPubKey]);
127330
+ return _context9.abrupt("return", getPermissionCache[accountPubKey]);
127331
127331
  case 6:
127332
127332
  case "end":
127333
- return _context8.stop();
127333
+ return _context9.stop();
127334
127334
  }
127335
- }, _callee8);
127335
+ }, _callee9);
127336
127336
  }));
127337
127337
  return function getPermissions(_x16, _x17) {
127338
127338
  return _ref5.apply(this, arguments);
@@ -127358,37 +127358,37 @@ function src_client_computeLedgerEffect() {
127358
127358
  return entry;
127359
127359
  };
127360
127360
  modifyBalance = /*#__PURE__*/function () {
127361
- var _ref6 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee9(account, token, value, isSet) {
127361
+ var _ref6 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee10(account, token, value, isSet) {
127362
127362
  var accountPubKey, tokenPubKey, newEntry, previous, newChange;
127363
- return client_common_regeneratorRuntime().wrap(function _callee9$(_context9) {
127364
- while (1) switch (_context9.prev = _context9.next) {
127363
+ return client_common_regeneratorRuntime().wrap(function _callee10$(_context10) {
127364
+ while (1) switch (_context10.prev = _context10.next) {
127365
127365
  case 0:
127366
127366
  accountPubKey = account.publicKeyString.get();
127367
127367
  tokenPubKey = token.publicKeyString.get();
127368
127368
  newEntry = getBalanceEntry(account, token);
127369
127369
  if (!(newEntry.starting === undefined)) {
127370
- _context9.next = 9;
127370
+ _context10.next = 9;
127371
127371
  break;
127372
127372
  }
127373
- _context9.next = 6;
127373
+ _context10.next = 6;
127374
127374
  return getPreviousBalance(account, token);
127375
127375
  case 6:
127376
- previous = _context9.sent;
127376
+ previous = _context10.sent;
127377
127377
  newEntry.starting = previous;
127378
127378
  newEntry.final = previous;
127379
127379
  case 9:
127380
127380
  newChange = value;
127381
127381
  if (!isSet) {
127382
- _context9.next = 18;
127382
+ _context10.next = 18;
127383
127383
  break;
127384
127384
  }
127385
- _context9.next = 13;
127385
+ _context10.next = 13;
127386
127386
  return getPreviousBalance(account, token);
127387
127387
  case 13:
127388
- newEntry.starting = _context9.sent;
127388
+ newEntry.starting = _context10.sent;
127389
127389
  newChange = value - newEntry.starting;
127390
127390
  newEntry.final = value;
127391
- _context9.next = 19;
127391
+ _context10.next = 19;
127392
127392
  break;
127393
127393
  case 18:
127394
127394
  if (newEntry.final !== undefined) {
@@ -127400,11 +127400,11 @@ function src_client_computeLedgerEffect() {
127400
127400
  newEntry.lowestChange = newEntry.change;
127401
127401
  }
127402
127402
  if (!(newEntry.lowestChange < BigInt(0) && checkNegative)) {
127403
- _context9.next = 24;
127403
+ _context10.next = 24;
127404
127404
  break;
127405
127405
  }
127406
127406
  if (!(newEntry.starting === undefined)) {
127407
- _context9.next = 24;
127407
+ _context10.next = 24;
127408
127408
  break;
127409
127409
  }
127410
127410
  throw new Error('Starting balance should not be undefined here');
@@ -127413,40 +127413,40 @@ function src_client_computeLedgerEffect() {
127413
127413
  newEntry.fellNegative = true;
127414
127414
  }
127415
127415
  balances[accountPubKey][tokenPubKey] = newEntry;
127416
- return _context9.abrupt("return", newChange);
127416
+ return _context10.abrupt("return", newChange);
127417
127417
  case 27:
127418
127418
  case "end":
127419
- return _context9.stop();
127419
+ return _context10.stop();
127420
127420
  }
127421
- }, _callee9);
127421
+ }, _callee10);
127422
127422
  }));
127423
127423
  return function modifyBalance(_x18, _x19, _x20, _x21) {
127424
127424
  return _ref6.apply(this, arguments);
127425
127425
  };
127426
127426
  }();
127427
127427
  modifyWeight = /*#__PURE__*/function () {
127428
- var _ref7 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee10(rep, change) {
127428
+ var _ref7 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee11(rep, change) {
127429
127429
  var repPubKey, newEntry;
127430
- return client_common_regeneratorRuntime().wrap(function _callee10$(_context10) {
127431
- while (1) switch (_context10.prev = _context10.next) {
127430
+ return client_common_regeneratorRuntime().wrap(function _callee11$(_context11) {
127431
+ while (1) switch (_context11.prev = _context11.next) {
127432
127432
  case 0:
127433
127433
  repPubKey = rep.publicKeyString.get();
127434
127434
  newEntry = weights[repPubKey];
127435
127435
  if (!(newEntry === undefined)) {
127436
- _context10.next = 8;
127436
+ _context11.next = 8;
127437
127437
  break;
127438
127438
  }
127439
127439
  newEntry = {
127440
127440
  change: BigInt(0)
127441
127441
  };
127442
127442
  if (!getFinalNumericValues) {
127443
- _context10.next = 8;
127443
+ _context11.next = 8;
127444
127444
  break;
127445
127445
  }
127446
- _context10.next = 7;
127446
+ _context11.next = 7;
127447
127447
  return getWeight(rep);
127448
127448
  case 7:
127449
- newEntry.final = _context10.sent;
127449
+ newEntry.final = _context11.sent;
127450
127450
  case 8:
127451
127451
  if (newEntry.final !== undefined) {
127452
127452
  newEntry.final += change;
@@ -127455,37 +127455,37 @@ function src_client_computeLedgerEffect() {
127455
127455
  weights[repPubKey] = newEntry;
127456
127456
  case 11:
127457
127457
  case "end":
127458
- return _context10.stop();
127458
+ return _context11.stop();
127459
127459
  }
127460
- }, _callee10);
127460
+ }, _callee11);
127461
127461
  }));
127462
127462
  return function modifyWeight(_x22, _x23) {
127463
127463
  return _ref7.apply(this, arguments);
127464
127464
  };
127465
127465
  }();
127466
127466
  modifySupply = /*#__PURE__*/function () {
127467
- var _ref8 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee11(token, change) {
127467
+ var _ref8 = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee12(token, change) {
127468
127468
  var tokenPubKey, newEntry, _yield$getAccountInfo, supply;
127469
- return client_common_regeneratorRuntime().wrap(function _callee11$(_context11) {
127470
- while (1) switch (_context11.prev = _context11.next) {
127469
+ return client_common_regeneratorRuntime().wrap(function _callee12$(_context12) {
127470
+ while (1) switch (_context12.prev = _context12.next) {
127471
127471
  case 0:
127472
127472
  tokenPubKey = token.publicKeyString.get();
127473
127473
  newEntry = supplies[tokenPubKey];
127474
127474
  if (!(newEntry === undefined)) {
127475
- _context11.next = 10;
127475
+ _context12.next = 10;
127476
127476
  break;
127477
127477
  }
127478
127478
  newEntry = {
127479
127479
  change: BigInt(0)
127480
127480
  };
127481
127481
  if (!getFinalNumericValues) {
127482
- _context11.next = 10;
127482
+ _context12.next = 10;
127483
127483
  break;
127484
127484
  }
127485
- _context11.next = 7;
127485
+ _context12.next = 7;
127486
127486
  return getAccountInfo(token);
127487
127487
  case 7:
127488
- _yield$getAccountInfo = _context11.sent;
127488
+ _yield$getAccountInfo = _context12.sent;
127489
127489
  supply = _yield$getAccountInfo.supply;
127490
127490
  newEntry.final = supply;
127491
127491
  case 10:
@@ -127496,9 +127496,9 @@ function src_client_computeLedgerEffect() {
127496
127496
  supplies[tokenPubKey] = newEntry;
127497
127497
  case 13:
127498
127498
  case "end":
127499
- return _context11.stop();
127499
+ return _context12.stop();
127500
127500
  }
127501
- }, _callee11);
127501
+ }, _callee12);
127502
127502
  }));
127503
127503
  return function modifySupply(_x24, _x25) {
127504
127504
  return _ref8.apply(this, arguments);
@@ -127507,196 +127507,196 @@ function src_client_computeLedgerEffect() {
127507
127507
  _i = 0, _Object$values = Object.values(effects);
127508
127508
  case 20:
127509
127509
  if (!(_i < _Object$values.length)) {
127510
- _context12.next = 179;
127510
+ _context13.next = 179;
127511
127511
  break;
127512
127512
  }
127513
127513
  _Object$values$_i = _Object$values[_i], _account = _Object$values$_i.account, fields = _Object$values$_i.fields;
127514
127514
  accountPubKey = _account.publicKeyString.get();
127515
127515
  _iterator3 = client_common_createForOfIteratorHelper((_fields$supply = fields.supply) !== null && _fields$supply !== void 0 ? _fields$supply : []);
127516
- _context12.prev = 24;
127516
+ _context13.prev = 24;
127517
127517
  _iterator3.s();
127518
127518
  case 26:
127519
127519
  if ((_step3 = _iterator3.n()).done) {
127520
- _context12.next = 34;
127520
+ _context13.next = 34;
127521
127521
  break;
127522
127522
  }
127523
127523
  supplyChange = _step3.value;
127524
127524
  if (_account.isToken()) {
127525
- _context12.next = 30;
127525
+ _context13.next = 30;
127526
127526
  break;
127527
127527
  }
127528
127528
  throw new Error('Cannot modify supply of non-token account');
127529
127529
  case 30:
127530
- _context12.next = 32;
127530
+ _context13.next = 32;
127531
127531
  return modifySupply(_account, supplyChange.value);
127532
127532
  case 32:
127533
- _context12.next = 26;
127533
+ _context13.next = 26;
127534
127534
  break;
127535
127535
  case 34:
127536
- _context12.next = 39;
127536
+ _context13.next = 39;
127537
127537
  break;
127538
127538
  case 36:
127539
- _context12.prev = 36;
127540
- _context12.t0 = _context12["catch"](24);
127541
- _iterator3.e(_context12.t0);
127539
+ _context13.prev = 36;
127540
+ _context13.t0 = _context13["catch"](24);
127541
+ _iterator3.e(_context13.t0);
127542
127542
  case 39:
127543
- _context12.prev = 39;
127543
+ _context13.prev = 39;
127544
127544
  _iterator3.f();
127545
- return _context12.finish(39);
127545
+ return _context13.finish(39);
127546
127546
  case 42:
127547
127547
  permissionUpdates = [];
127548
127548
  permissionsReadEntity = new client_lib_account.Set();
127549
127549
  if (!(computePermissions && fields.permissions)) {
127550
- _context12.next = 65;
127550
+ _context13.next = 65;
127551
127551
  break;
127552
127552
  }
127553
127553
  permissionUpdates = fields.permissions;
127554
127554
  _iterator4 = client_common_createForOfIteratorHelper((_fields$permissions = fields.permissions) !== null && _fields$permissions !== void 0 ? _fields$permissions : []);
127555
- _context12.prev = 47;
127555
+ _context13.prev = 47;
127556
127556
  _iterator4.s();
127557
127557
  case 49:
127558
127558
  if ((_step4 = _iterator4.n()).done) {
127559
- _context12.next = 57;
127559
+ _context13.next = 57;
127560
127560
  break;
127561
127561
  }
127562
127562
  permUpdate = _step4.value;
127563
127563
  if (!(permUpdate.method === src_client_Block.AdjustMethod.SET || permUpdate.permissions === null)) {
127564
- _context12.next = 54;
127564
+ _context13.next = 54;
127565
127565
  break;
127566
127566
  }
127567
127567
  permissionsReadEntity.delete(permUpdate.entity);
127568
- return _context12.abrupt("continue", 55);
127568
+ return _context13.abrupt("continue", 55);
127569
127569
  case 54:
127570
127570
  permissionsReadEntity.add(permUpdate.entity);
127571
127571
  case 55:
127572
- _context12.next = 49;
127572
+ _context13.next = 49;
127573
127573
  break;
127574
127574
  case 57:
127575
- _context12.next = 62;
127575
+ _context13.next = 62;
127576
127576
  break;
127577
127577
  case 59:
127578
- _context12.prev = 59;
127579
- _context12.t1 = _context12["catch"](47);
127580
- _iterator4.e(_context12.t1);
127578
+ _context13.prev = 59;
127579
+ _context13.t1 = _context13["catch"](47);
127580
+ _iterator4.e(_context13.t1);
127581
127581
  case 62:
127582
- _context12.prev = 62;
127582
+ _context13.prev = 62;
127583
127583
  _iterator4.f();
127584
- return _context12.finish(62);
127584
+ return _context13.finish(62);
127585
127585
  case 65:
127586
127586
  _iterator5 = client_common_createForOfIteratorHelper(permissionUpdates);
127587
- _context12.prev = 66;
127587
+ _context13.prev = 66;
127588
127588
  _iterator5.s();
127589
127589
  case 68:
127590
127590
  if ((_step5 = _iterator5.n()).done) {
127591
- _context12.next = 93;
127591
+ _context13.next = 93;
127592
127592
  break;
127593
127593
  }
127594
127594
  _permUpdate = _step5.value;
127595
127595
  if (_permUpdate.principal.comparePublicKey(_account)) {
127596
- _context12.next = 72;
127596
+ _context13.next = 72;
127597
127597
  break;
127598
127598
  }
127599
127599
  throw new Error('permUpdate.principal should not differ current account');
127600
127600
  case 72:
127601
127601
  if (!(_permUpdate.method === src_client_Block.AdjustMethod.SET || _permUpdate.permissions === null)) {
127602
- _context12.next = 75;
127602
+ _context13.next = 75;
127603
127603
  break;
127604
127604
  }
127605
127605
  permissions.push(_permUpdate);
127606
- return _context12.abrupt("continue", 91);
127606
+ return _context13.abrupt("continue", 91);
127607
127607
  case 75:
127608
127608
  newPermissions = void 0;
127609
- _context12.t2 = client_findPermissionMatch;
127610
- _context12.t3 = _permUpdate;
127611
- _context12.next = 80;
127609
+ _context13.t2 = client_findPermissionMatch;
127610
+ _context13.t3 = _permUpdate;
127611
+ _context13.next = 80;
127612
127612
  return getPermissions(_account, permissionsReadEntity.decodedArray);
127613
127613
  case 80:
127614
- _context12.t4 = _context12.sent;
127615
- _previousEntry = (0, _context12.t2)(_context12.t3, _context12.t4);
127614
+ _context13.t4 = _context13.sent;
127615
+ _previousEntry = (0, _context13.t2)(_context13.t3, _context13.t4);
127616
127616
  previousPermissions = (_previousEntry$permis = _previousEntry === null || _previousEntry === void 0 ? void 0 : _previousEntry.permissions) !== null && _previousEntry$permis !== void 0 ? _previousEntry$permis : new client_permissions_Permissions();
127617
- _context12.t5 = _permUpdate.method;
127618
- _context12.next = _context12.t5 === src_client_Block.AdjustMethod.ADD ? 86 : _context12.t5 === src_client_Block.AdjustMethod.SUBTRACT ? 88 : 90;
127617
+ _context13.t5 = _permUpdate.method;
127618
+ _context13.next = _context13.t5 === src_client_Block.AdjustMethod.ADD ? 86 : _context13.t5 === src_client_Block.AdjustMethod.SUBTRACT ? 88 : 90;
127619
127619
  break;
127620
127620
  case 86:
127621
127621
  newPermissions = previousPermissions.combine(_permUpdate.permissions);
127622
- return _context12.abrupt("break", 90);
127622
+ return _context13.abrupt("break", 90);
127623
127623
  case 88:
127624
127624
  newPermissions = previousPermissions.remove(_permUpdate.permissions);
127625
- return _context12.abrupt("break", 90);
127625
+ return _context13.abrupt("break", 90);
127626
127626
  case 90:
127627
127627
  permissions.push(client_common_objectSpread(client_common_objectSpread({}, _permUpdate), {}, {
127628
127628
  method: src_client_Block.AdjustMethod.SET,
127629
127629
  permissions: newPermissions
127630
127630
  }));
127631
127631
  case 91:
127632
- _context12.next = 68;
127632
+ _context13.next = 68;
127633
127633
  break;
127634
127634
  case 93:
127635
- _context12.next = 98;
127635
+ _context13.next = 98;
127636
127636
  break;
127637
127637
  case 95:
127638
- _context12.prev = 95;
127639
- _context12.t6 = _context12["catch"](66);
127640
- _iterator5.e(_context12.t6);
127638
+ _context13.prev = 95;
127639
+ _context13.t6 = _context13["catch"](66);
127640
+ _iterator5.e(_context13.t6);
127641
127641
  case 98:
127642
- _context12.prev = 98;
127642
+ _context13.prev = 98;
127643
127643
  _iterator5.f();
127644
- return _context12.finish(98);
127644
+ return _context13.finish(98);
127645
127645
  case 101:
127646
127646
  delegationField = (_effects$accountPubKe = effects[accountPubKey]) === null || _effects$accountPubKe === void 0 ? void 0 : _effects$accountPubKe.fields.delegation;
127647
127647
  isDelegating = delegationField !== undefined;
127648
127648
  if (!(isDelegating && _account.isAccount())) {
127649
- _context12.next = 115;
127649
+ _context13.next = 115;
127650
127650
  break;
127651
127651
  }
127652
- _context12.next = 106;
127652
+ _context13.next = 106;
127653
127653
  return getRep(_account, getFinalNumericValues);
127654
127654
  case 106:
127655
- currentDelegation = _context12.sent;
127656
- _context12.next = 109;
127655
+ currentDelegation = _context13.sent;
127656
+ _context13.next = 109;
127657
127657
  return getPreviousBalance(_account, baseToken);
127658
127658
  case 109:
127659
- previousBalance = _context12.sent;
127660
- _context12.next = 112;
127659
+ previousBalance = _context13.sent;
127660
+ _context13.next = 112;
127661
127661
  return modifyWeight(delegationField.delegateTo, previousBalance);
127662
127662
  case 112:
127663
127663
  if (!currentDelegation) {
127664
- _context12.next = 115;
127664
+ _context13.next = 115;
127665
127665
  break;
127666
127666
  }
127667
- _context12.next = 115;
127667
+ _context13.next = 115;
127668
127668
  return modifyWeight(currentDelegation, BigInt(-1) * previousBalance);
127669
127669
  case 115:
127670
127670
  receivable = {};
127671
- _context12.t7 = client_common_regeneratorRuntime().keys((_fields$balance = fields.balance) !== null && _fields$balance !== void 0 ? _fields$balance : {});
127671
+ _context13.t7 = client_common_regeneratorRuntime().keys((_fields$balance = fields.balance) !== null && _fields$balance !== void 0 ? _fields$balance : {});
127672
127672
  case 117:
127673
- if ((_context12.t8 = _context12.t7()).done) {
127674
- _context12.next = 176;
127673
+ if ((_context13.t8 = _context13.t7()).done) {
127674
+ _context13.next = 176;
127675
127675
  break;
127676
127676
  }
127677
- tokenPubKey = _context12.t8.value;
127677
+ tokenPubKey = _context13.t8.value;
127678
127678
  tokenAcct = client_lib_account.fromPublicKeyString(tokenPubKey).assertKeyType(client_account_AccountKeyAlgorithm.TOKEN);
127679
127679
  _iterator6 = client_common_createForOfIteratorHelper(((_fields$balance2 = fields.balance) !== null && _fields$balance2 !== void 0 ? _fields$balance2 : {})[tokenPubKey]);
127680
- _context12.prev = 121;
127680
+ _context13.prev = 121;
127681
127681
  _iterator6.s();
127682
127682
  case 123:
127683
127683
  if ((_step6 = _iterator6.n()).done) {
127684
- _context12.next = 166;
127684
+ _context13.next = 166;
127685
127685
  break;
127686
127686
  }
127687
127687
  balanceUpdate = _step6.value;
127688
127688
  isReceive = balanceUpdate.isReceive, value = balanceUpdate.value, otherAccount = balanceUpdate.otherAccount;
127689
127689
  if (!isReceive) {
127690
- _context12.next = 138;
127690
+ _context13.next = 138;
127691
127691
  break;
127692
127692
  }
127693
127693
  receiveFromPubKey = otherAccount.publicKeyString.get();
127694
127694
  previousEntry = getBalanceEntry(_account, tokenAcct);
127695
127695
  if (!(previousEntry.receiveValidated === false)) {
127696
- _context12.next = 131;
127696
+ _context13.next = 131;
127697
127697
  break;
127698
127698
  }
127699
- return _context12.abrupt("continue", 164);
127699
+ return _context13.abrupt("continue", 164);
127700
127700
  case 131:
127701
127701
  receivableAmount = void 0;
127702
127702
  if (receivable[receiveFromPubKey]) {
@@ -127712,27 +127712,27 @@ function src_client_computeLedgerEffect() {
127712
127712
  receiveValid = value <= receivableAmount;
127713
127713
  }
127714
127714
  balances[accountPubKey][tokenPubKey].receiveValidated = receiveValid;
127715
- return _context12.abrupt("continue", 164);
127715
+ return _context13.abrupt("continue", 164);
127716
127716
  case 138:
127717
127717
  balanceChange = void 0;
127718
127718
  if (!balanceUpdate.set) {
127719
- _context12.next = 147;
127719
+ _context13.next = 147;
127720
127720
  break;
127721
127721
  }
127722
- _context12.next = 142;
127722
+ _context13.next = 142;
127723
127723
  return modifyBalance(_account, tokenAcct, value, true);
127724
127724
  case 142:
127725
- balanceChange = _context12.sent;
127726
- _context12.next = 145;
127725
+ balanceChange = _context13.sent;
127726
+ _context13.next = 145;
127727
127727
  return modifyBalance(tokenAcct, tokenAcct, BigInt(-1) * balanceChange, false);
127728
127728
  case 145:
127729
- _context12.next = 150;
127729
+ _context13.next = 150;
127730
127730
  break;
127731
127731
  case 147:
127732
- _context12.next = 149;
127732
+ _context13.next = 149;
127733
127733
  return modifyBalance(_account, tokenAcct, value, false);
127734
127734
  case 149:
127735
- balanceChange = _context12.sent;
127735
+ balanceChange = _context13.sent;
127736
127736
  case 150:
127737
127737
  if (balanceUpdate.receivable) {
127738
127738
  otherAccountPubKey = otherAccount.publicKeyString.get(); // Make sure this is an object and not undefined
@@ -127744,49 +127744,49 @@ function src_client_computeLedgerEffect() {
127744
127744
  }
127745
127745
  isBaseToken = baseToken.comparePublicKey(tokenAcct);
127746
127746
  if (!(isBaseToken && _account.isAccount())) {
127747
- _context12.next = 164;
127747
+ _context13.next = 164;
127748
127748
  break;
127749
127749
  }
127750
127750
  if (!isDelegating) {
127751
- _context12.next = 158;
127751
+ _context13.next = 158;
127752
127752
  break;
127753
127753
  }
127754
- _context12.next = 156;
127754
+ _context13.next = 156;
127755
127755
  return modifyWeight(delegationField.delegateTo, balanceChange);
127756
127756
  case 156:
127757
- _context12.next = 164;
127757
+ _context13.next = 164;
127758
127758
  break;
127759
127759
  case 158:
127760
- _context12.next = 160;
127760
+ _context13.next = 160;
127761
127761
  return getRep(_account);
127762
127762
  case 160:
127763
- currentRep = _context12.sent;
127763
+ currentRep = _context13.sent;
127764
127764
  if (!currentRep) {
127765
- _context12.next = 164;
127765
+ _context13.next = 164;
127766
127766
  break;
127767
127767
  }
127768
- _context12.next = 164;
127768
+ _context13.next = 164;
127769
127769
  return modifyWeight(currentRep, balanceChange);
127770
127770
  case 164:
127771
- _context12.next = 123;
127771
+ _context13.next = 123;
127772
127772
  break;
127773
127773
  case 166:
127774
- _context12.next = 171;
127774
+ _context13.next = 171;
127775
127775
  break;
127776
127776
  case 168:
127777
- _context12.prev = 168;
127778
- _context12.t9 = _context12["catch"](121);
127779
- _iterator6.e(_context12.t9);
127777
+ _context13.prev = 168;
127778
+ _context13.t9 = _context13["catch"](121);
127779
+ _iterator6.e(_context13.t9);
127780
127780
  case 171:
127781
- _context12.prev = 171;
127781
+ _context13.prev = 171;
127782
127782
  _iterator6.f();
127783
- return _context12.finish(171);
127783
+ return _context13.finish(171);
127784
127784
  case 174:
127785
- _context12.next = 117;
127785
+ _context13.next = 117;
127786
127786
  break;
127787
127787
  case 176:
127788
127788
  _i++;
127789
- _context12.next = 20;
127789
+ _context13.next = 20;
127790
127790
  break;
127791
127791
  case 179:
127792
127792
  ret = {
@@ -127804,12 +127804,12 @@ function src_client_computeLedgerEffect() {
127804
127804
 
127805
127805
  // We know this type is correct because we only set those values if they are defined
127806
127806
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
127807
- return _context12.abrupt("return", ret);
127807
+ return _context13.abrupt("return", ret);
127808
127808
  case 183:
127809
127809
  case "end":
127810
- return _context12.stop();
127810
+ return _context13.stop();
127811
127811
  }
127812
- }, _callee12, null, [[24, 36, 39, 42], [47, 59, 62, 65], [66, 95, 98, 101], [121, 168, 171, 174]]);
127812
+ }, _callee13, null, [[24, 36, 39, 42], [47, 59, 62, 65], [66, 95, 98, 101], [121, 168, 171, 174]]);
127813
127813
  }));
127814
127814
  return src_client_computeLedgerEffect.apply(this, arguments);
127815
127815
  }
@@ -127832,7 +127832,7 @@ function client_addTimeStatistic(_x5, _x6, _x7, _x8, _x9) {
127832
127832
  return src_client_addTimeStatistic.apply(this, arguments);
127833
127833
  }
127834
127834
  function src_client_addTimeStatistic() {
127835
- src_client_addTimeStatistic = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee13(node, blocks, to, storageProvider, transaction) {
127835
+ src_client_addTimeStatistic = client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee14(node, blocks, to, storageProvider, transaction) {
127836
127836
  var skipPush,
127837
127837
  increases,
127838
127838
  ourPublicKey,
@@ -127850,118 +127850,118 @@ function src_client_addTimeStatistic() {
127850
127850
  blockVoteTime,
127851
127851
  settlementTime,
127852
127852
  addTimeResp,
127853
- _args13 = arguments;
127854
- return client_common_regeneratorRuntime().wrap(function _callee13$(_context13) {
127855
- while (1) switch (_context13.prev = _context13.next) {
127853
+ _args14 = arguments;
127854
+ return client_common_regeneratorRuntime().wrap(function _callee14$(_context14) {
127855
+ while (1) switch (_context14.prev = _context14.next) {
127856
127856
  case 0:
127857
- skipPush = _args13.length > 5 && _args13[5] !== undefined ? _args13[5] : false;
127857
+ skipPush = _args14.length > 5 && _args14[5] !== undefined ? _args14[5] : false;
127858
127858
  increases = [];
127859
127859
  if (!(node === undefined)) {
127860
- _context13.next = 4;
127860
+ _context14.next = 4;
127861
127861
  break;
127862
127862
  }
127863
- return _context13.abrupt("return", increases);
127863
+ return _context14.abrupt("return", increases);
127864
127864
  case 4:
127865
127865
  if (!(to !== 'main')) {
127866
- _context13.next = 6;
127866
+ _context14.next = 6;
127867
127867
  break;
127868
127868
  }
127869
- return _context13.abrupt("return", increases);
127869
+ return _context14.abrupt("return", increases);
127870
127870
  case 6:
127871
127871
  ourPublicKey = node.config.ledgerPrivateKey;
127872
127872
  if (!(ourPublicKey === undefined)) {
127873
- _context13.next = 9;
127873
+ _context14.next = 9;
127874
127874
  break;
127875
127875
  }
127876
- return _context13.abrupt("return", increases);
127876
+ return _context14.abrupt("return", increases);
127877
127877
  case 9:
127878
127878
  ourPublicKeyString = ourPublicKey.publicKeyString.get();
127879
127879
  now = Date.now();
127880
127880
  votePromises = blocks.map(function (block) {
127881
127881
  return storageProvider.getVotes(transaction, block.hash, 'side');
127882
127882
  });
127883
- _context13.next = 14;
127883
+ _context14.next = 14;
127884
127884
  return Promise.all(votePromises);
127885
127885
  case 14:
127886
- resolvedVotes = _context13.sent;
127886
+ resolvedVotes = _context14.sent;
127887
127887
  ourTemporaryVotes = [];
127888
127888
  _iterator7 = client_common_createForOfIteratorHelper(resolvedVotes);
127889
- _context13.prev = 17;
127889
+ _context14.prev = 17;
127890
127890
  _iterator7.s();
127891
127891
  case 19:
127892
127892
  if ((_step7 = _iterator7.n()).done) {
127893
- _context13.next = 50;
127893
+ _context14.next = 50;
127894
127894
  break;
127895
127895
  }
127896
127896
  checkVotes = _step7.value;
127897
127897
  if (checkVotes) {
127898
- _context13.next = 23;
127898
+ _context14.next = 23;
127899
127899
  break;
127900
127900
  }
127901
- return _context13.abrupt("continue", 48);
127901
+ return _context14.abrupt("continue", 48);
127902
127902
  case 23:
127903
127903
  _iterator8 = client_common_createForOfIteratorHelper(checkVotes);
127904
- _context13.prev = 24;
127904
+ _context14.prev = 24;
127905
127905
  _iterator8.s();
127906
127906
  case 26:
127907
127907
  if ((_step8 = _iterator8.n()).done) {
127908
- _context13.next = 40;
127908
+ _context14.next = 40;
127909
127909
  break;
127910
127910
  }
127911
127911
  toCheckVote = _step8.value;
127912
127912
  if (!toCheckVote.$permanent) {
127913
- _context13.next = 30;
127913
+ _context14.next = 30;
127914
127914
  break;
127915
127915
  }
127916
- return _context13.abrupt("continue", 38);
127916
+ return _context14.abrupt("continue", 38);
127917
127917
  case 30:
127918
127918
  if (toCheckVote.issuer.comparePublicKey(ourPublicKeyString)) {
127919
- _context13.next = 32;
127919
+ _context14.next = 32;
127920
127920
  break;
127921
127921
  }
127922
- return _context13.abrupt("continue", 38);
127922
+ return _context14.abrupt("continue", 38);
127923
127923
  case 32:
127924
127924
  ourTemporaryVotes.push(toCheckVote);
127925
127925
  blockVoteTime = toCheckVote.validityFrom.valueOf();
127926
127926
  settlementTime = now - blockVoteTime;
127927
127927
  addTimeResp = node.stats.addTimingPoint('ledger', 'settlementTime', settlementTime, skipPush);
127928
127928
  increases.push(addTimeResp);
127929
- return _context13.abrupt("break", 40);
127929
+ return _context14.abrupt("break", 40);
127930
127930
  case 38:
127931
- _context13.next = 26;
127931
+ _context14.next = 26;
127932
127932
  break;
127933
127933
  case 40:
127934
- _context13.next = 45;
127934
+ _context14.next = 45;
127935
127935
  break;
127936
127936
  case 42:
127937
- _context13.prev = 42;
127938
- _context13.t0 = _context13["catch"](24);
127939
- _iterator8.e(_context13.t0);
127937
+ _context14.prev = 42;
127938
+ _context14.t0 = _context14["catch"](24);
127939
+ _iterator8.e(_context14.t0);
127940
127940
  case 45:
127941
- _context13.prev = 45;
127941
+ _context14.prev = 45;
127942
127942
  _iterator8.f();
127943
- return _context13.finish(45);
127943
+ return _context14.finish(45);
127944
127944
  case 48:
127945
- _context13.next = 19;
127945
+ _context14.next = 19;
127946
127946
  break;
127947
127947
  case 50:
127948
- _context13.next = 55;
127948
+ _context14.next = 55;
127949
127949
  break;
127950
127950
  case 52:
127951
- _context13.prev = 52;
127952
- _context13.t1 = _context13["catch"](17);
127953
- _iterator7.e(_context13.t1);
127951
+ _context14.prev = 52;
127952
+ _context14.t1 = _context14["catch"](17);
127953
+ _iterator7.e(_context14.t1);
127954
127954
  case 55:
127955
- _context13.prev = 55;
127955
+ _context14.prev = 55;
127956
127956
  _iterator7.f();
127957
- return _context13.finish(55);
127957
+ return _context14.finish(55);
127958
127958
  case 58:
127959
- return _context13.abrupt("return", increases);
127959
+ return _context14.abrupt("return", increases);
127960
127960
  case 59:
127961
127961
  case "end":
127962
- return _context13.stop();
127962
+ return _context14.stop();
127963
127963
  }
127964
- }, _callee13, null, [[17, 52, 55, 58], [24, 42, 45, 48]]);
127964
+ }, _callee14, null, [[17, 52, 55, 58], [24, 42, 45, 48]]);
127965
127965
  }));
127966
127966
  return src_client_addTimeStatistic.apply(this, arguments);
127967
127967
  }
@@ -128169,6 +128169,42 @@ class client_LedgerStorageBase {
128169
128169
  }, _callee3);
128170
128170
  }))();
128171
128171
  }
128172
+ gc(transaction) {
128173
+ var _this4 = this;
128174
+ return client_common_asyncToGenerator(/*#__PURE__*/client_common_regeneratorRuntime().mark(function _callee4() {
128175
+ var lastGCResult, startTime, gcResult;
128176
+ return client_common_regeneratorRuntime().wrap(function _callee4$(_context4) {
128177
+ while (1) switch (_context4.prev = _context4.next) {
128178
+ case 0:
128179
+ lastGCResult = false;
128180
+ startTime = Date.now();
128181
+ case 2:
128182
+ if (!(Date.now() - startTime < 280000)) {
128183
+ _context4.next = 11;
128184
+ break;
128185
+ }
128186
+ _context4.next = 5;
128187
+ return _this4.gcBatch(transaction);
128188
+ case 5:
128189
+ gcResult = _context4.sent;
128190
+ lastGCResult = gcResult;
128191
+ if (gcResult) {
128192
+ _context4.next = 9;
128193
+ break;
128194
+ }
128195
+ return _context4.abrupt("return", false);
128196
+ case 9:
128197
+ _context4.next = 2;
128198
+ break;
128199
+ case 11:
128200
+ return _context4.abrupt("return", lastGCResult);
128201
+ case 12:
128202
+ case "end":
128203
+ return _context4.stop();
128204
+ }
128205
+ }, _callee4);
128206
+ }))();
128207
+ }
128172
128208
  }
128173
128209
  function client_log() {
128174
128210
  if (this.config !== null) {
@@ -129064,7 +129100,7 @@ class client_LedgerAtomicInterface {
129064
129100
  _context3.next = 3;
129065
129101
  break;
129066
129102
  }
129067
- throw new Error('May not issue votes in read-only mode');
129103
+ throw new Error("May not issue votes in read-only mode, in ".concat(client_ledger_classPrivateFieldGet(src_client_ledger, _this3).ledgerWriteMode, " mode"));
129068
129104
  case 3:
129069
129105
  if (client_ledger_classPrivateFieldGet(client_ledger_privateKey, _this3)) {
129070
129106
  _context3.next = 5;
@@ -129480,7 +129516,7 @@ class client_LedgerAtomicInterface {
129480
129516
  case 0:
129481
129517
  client_ledger_assertClassBrand(client_LedgerAtomicInterface_brand, _this4, client_assertTransaction).call(_this4);
129482
129518
  _context4.t0 = client_ledger_classPrivateFieldGet(src_client_ledger, _this4).ledgerWriteMode;
129483
- _context4.next = _context4.t0 === 'read-only' ? 4 : _context4.t0 === 'bootstrap-only' ? 5 : _context4.t0 === 'read-write' ? 8 : 9;
129519
+ _context4.next = _context4.t0 === 'read-only' ? 4 : _context4.t0 === 'bootstrap-only' ? 5 : _context4.t0 === 'read-write' ? 8 : _context4.t0 === 'no-voting' ? 8 : 9;
129484
129520
  break;
129485
129521
  case 4:
129486
129522
  throw new Error('Cannot add blocks to a read-only ledger');
@@ -130929,107 +130965,108 @@ class src_client_Ledger {
130929
130965
  run(identifier, code, readOnly) {
130930
130966
  var _this25 = this;
130931
130967
  return client_ledger_asyncToGenerator(/*#__PURE__*/client_ledger_regeneratorRuntime().mark(function _callee26() {
130932
- var retval, retryCount, runError, threw, transaction, txnError, retryDelay;
130968
+ var txnIdentifier, retval, retryCount, runError, threw, transaction, txnError, retryDelay;
130933
130969
  return client_ledger_regeneratorRuntime().wrap(function _callee26$(_context28) {
130934
130970
  while (1) switch (_context28.prev = _context28.next) {
130935
130971
  case 0:
130972
+ txnIdentifier = identifier;
130936
130973
  if (_this25.node !== undefined) {
130937
130974
  identifier = "".concat(identifier, "-").concat(_this25.node.timing.counter());
130938
130975
  _this25.node.timing.startTime(identifier);
130939
130976
  }
130940
130977
  retryCount = 0;
130941
- case 2:
130942
- _context28.prev = 2;
130978
+ case 3:
130979
+ _context28.prev = 3;
130943
130980
  runError = void 0;
130944
130981
  threw = false;
130945
- _context28.next = 7;
130946
- return _this25.beginTransaction(readOnly);
130947
- case 7:
130982
+ _context28.next = 8;
130983
+ return _this25.beginTransaction(txnIdentifier, readOnly);
130984
+ case 8:
130948
130985
  transaction = _context28.sent;
130949
- _context28.prev = 8;
130950
- _context28.next = 11;
130986
+ _context28.prev = 9;
130987
+ _context28.next = 12;
130951
130988
  return code(transaction);
130952
- case 11:
130989
+ case 12:
130953
130990
  retval = _context28.sent;
130954
- _context28.next = 18;
130991
+ _context28.next = 19;
130955
130992
  break;
130956
- case 14:
130957
- _context28.prev = 14;
130958
- _context28.t0 = _context28["catch"](8);
130993
+ case 15:
130994
+ _context28.prev = 15;
130995
+ _context28.t0 = _context28["catch"](9);
130959
130996
  threw = true;
130960
130997
  runError = _context28.t0;
130961
- case 18:
130998
+ case 19:
130962
130999
  if (!(threw === false)) {
130963
- _context28.next = 23;
131000
+ _context28.next = 24;
130964
131001
  break;
130965
131002
  }
130966
- _context28.next = 21;
131003
+ _context28.next = 22;
130967
131004
  return transaction.commit();
130968
- case 21:
130969
- _context28.next = 26;
131005
+ case 22:
131006
+ _context28.next = 27;
130970
131007
  break;
130971
- case 23:
130972
- _context28.next = 25;
131008
+ case 24:
131009
+ _context28.next = 26;
130973
131010
  return transaction.abort();
130974
- case 25:
130975
- throw runError;
130976
131011
  case 26:
130977
- _context28.next = 43;
131012
+ throw runError;
131013
+ case 27:
131014
+ _context28.next = 44;
130978
131015
  break;
130979
- case 28:
130980
- _context28.prev = 28;
130981
- _context28.t1 = _context28["catch"](2);
130982
- _context28.next = 32;
131016
+ case 29:
131017
+ _context28.prev = 29;
131018
+ _context28.t1 = _context28["catch"](3);
131019
+ _context28.next = 33;
130983
131020
  return client_ledger_classPrivateFieldGet(client_storage2, _this25).evaluateError(_context28.t1);
130984
- case 32:
131021
+ case 33:
130985
131022
  txnError = _context28.sent;
130986
131023
  if (!(retryCount < 128)) {
130987
- _context28.next = 41;
131024
+ _context28.next = 42;
130988
131025
  break;
130989
131026
  }
130990
131027
  if (!client_ledger.isInstance(txnError)) {
130991
- _context28.next = 41;
131028
+ _context28.next = 42;
130992
131029
  break;
130993
131030
  }
130994
131031
  if (!txnError.shouldRetry) {
130995
- _context28.next = 41;
131032
+ _context28.next = 42;
130996
131033
  break;
130997
131034
  }
130998
131035
  retryDelay = 20;
130999
131036
  if (txnError.retryDelay) {
131000
131037
  retryDelay = txnError.retryDelay;
131001
131038
  }
131002
- _context28.next = 40;
131039
+ _context28.next = 41;
131003
131040
  return client_asleep(retryDelay);
131004
- case 40:
131005
- return _context28.abrupt("continue", 44);
131006
131041
  case 41:
131042
+ return _context28.abrupt("continue", 45);
131043
+ case 42:
131007
131044
  if (_this25.node !== undefined) {
131008
131045
  _this25.node.timing.endTime(identifier, false);
131009
131046
  }
131010
131047
  throw txnError;
131011
- case 43:
131012
- return _context28.abrupt("break", 47);
131013
131048
  case 44:
131049
+ return _context28.abrupt("break", 48);
131050
+ case 45:
131014
131051
  retryCount++;
131015
- _context28.next = 2;
131052
+ _context28.next = 3;
131016
131053
  break;
131017
- case 47:
131054
+ case 48:
131018
131055
  if (!(retval === undefined)) {
131019
- _context28.next = 49;
131056
+ _context28.next = 50;
131020
131057
  break;
131021
131058
  }
131022
131059
  throw new Error('Return value for run() is undefined');
131023
- case 49:
131060
+ case 50:
131024
131061
  if (_this25.node !== undefined) {
131025
131062
  _this25.node.timing.endTime(identifier, false);
131026
131063
  }
131027
131064
  return _context28.abrupt("return", retval);
131028
- case 51:
131065
+ case 52:
131029
131066
  case "end":
131030
131067
  return _context28.stop();
131031
131068
  }
131032
- }, _callee26, null, [[2, 28], [8, 14]]);
131069
+ }, _callee26, null, [[3, 29], [9, 15]]);
131033
131070
  }))();
131034
131071
  }
131035
131072
  runReadOnly(identifier, code) {
@@ -131049,7 +131086,7 @@ class src_client_Ledger {
131049
131086
  }, _callee27);
131050
131087
  }))();
131051
131088
  }
131052
- beginTransaction(readOnly) {
131089
+ beginTransaction(identifier, readOnly) {
131053
131090
  var _this27 = this;
131054
131091
  return client_ledger_asyncToGenerator(/*#__PURE__*/client_ledger_regeneratorRuntime().mark(function _callee28() {
131055
131092
  var transaction;
@@ -131057,7 +131094,7 @@ class src_client_Ledger {
131057
131094
  while (1) switch (_context30.prev = _context30.next) {
131058
131095
  case 0:
131059
131096
  _context30.next = 2;
131060
- return client_ledger_classPrivateFieldGet(client_storage2, _this27).beginTransaction(readOnly);
131097
+ return client_ledger_classPrivateFieldGet(client_storage2, _this27).beginTransaction(identifier, readOnly);
131061
131098
  case 2:
131062
131099
  transaction = _context30.sent;
131063
131100
  return _context30.abrupt("return", new client_LedgerAtomicInterface(transaction, client_ledger_classPrivateFieldGet(client_storage2, _this27), client_ledger_classPrivateFieldGet(src_client_config, _this27), _this27));
@@ -133936,7 +133973,7 @@ class src_client_P2PSwitch {
133936
133973
  _iterator5.f();
133937
133974
  }
133938
133975
  _context15.next = 7;
133939
- return Promise.all(closePromises);
133976
+ return Promise.allSettled(closePromises);
133940
133977
  case 7:
133941
133978
  _context15.next = 9;
133942
133979
  return _this8.wait();
@@ -133966,7 +134003,7 @@ class src_client_P2PSwitch {
133966
134003
  return _context16.abrupt("return");
133967
134004
  case 3:
133968
134005
  _context16.next = 5;
133969
- return Promise.all(promises);
134006
+ return Promise.allSettled(promises);
133970
134007
  case 5:
133971
134008
  case "end":
133972
134009
  return _context16.stop();
@@ -135380,7 +135417,7 @@ function client_handleIncomingGreeting2() {
135380
135417
  */
135381
135418
  promises.push(client_p2p_assertClassBrand(client_P2PSwitch_brand, this, client_relayActiveState).call(this, from));
135382
135419
  _context38.next = 24;
135383
- return Promise.all(promises);
135420
+ return Promise.allSettled(promises);
135384
135421
  case 24:
135385
135422
  return _context38.abrupt("return", true);
135386
135423
  case 25:
@@ -138573,6 +138610,7 @@ function client_client_assertClassBrand(e, t, n) { if ("function" == typeof e ?
138573
138610
 
138574
138611
 
138575
138612
 
138613
+
138576
138614
 
138577
138615
  /*
138578
138616
  * Turn the nested API tree into a flat structure
@@ -138611,6 +138649,7 @@ if (typeof client_fetch !== 'function') {
138611
138649
  }
138612
138650
  }
138613
138651
  var client_reps = /*#__PURE__*/new WeakMap();
138652
+ var client_weightOrderedReps = /*#__PURE__*/new WeakMap();
138614
138653
  var client_agent = /*#__PURE__*/new WeakMap();
138615
138654
  var client_intervals = /*#__PURE__*/new WeakMap();
138616
138655
  var client_updateRepsPromise = /*#__PURE__*/new WeakMap();
@@ -138628,6 +138667,7 @@ class src_client_Client {
138628
138667
  client_client_classPrivateMethodInitSpec(this, client_Client_brand);
138629
138668
  client_src_client_defineProperty(this, "logger", src_client_Client.DefaultLogger);
138630
138669
  client_client_classPrivateFieldInitSpec(this, client_reps, void 0);
138670
+ client_client_classPrivateFieldInitSpec(this, client_weightOrderedReps, []);
138631
138671
  client_client_classPrivateFieldInitSpec(this, client_agent, void 0);
138632
138672
  client_client_classPrivateFieldInitSpec(this, client_intervals, void 0);
138633
138673
  client_client_classPrivateFieldInitSpec(this, client_updateRepsPromise, void 0);
@@ -138659,13 +138699,12 @@ class src_client_Client {
138659
138699
  client_client_classPrivateFieldSet(client_updateRepsPromise, this, undefined);
138660
138700
  client_client_classPrivateFieldSet(client_intervals, this, {});
138661
138701
  // Update Reps immediately and then every 5 minutes
138662
- // TODO - Remove this until reps peering is stable
138663
- // this.#updateRepsPromise = this.updateReps();
138664
- // if (this.#intervals.updateReps === undefined) {
138665
- // this.#intervals.updateReps = setInterval(() => {
138666
- // this.#updateRepsPromise = this.updateReps();
138667
- // }, 5 * 60 * 1000);
138668
- // }
138702
+ client_client_classPrivateFieldSet(client_updateRepsPromise, this, this.updateReps());
138703
+ if (client_client_classPrivateFieldGet(client_intervals, this).updateReps === undefined) {
138704
+ client_client_classPrivateFieldGet(client_intervals, this).updateReps = setInterval(() => {
138705
+ client_client_classPrivateFieldSet(client_updateRepsPromise, this, this.updateReps());
138706
+ }, 5 * 60 * 1000);
138707
+ }
138669
138708
  }
138670
138709
  destroy() {
138671
138710
  var _this = this;
@@ -138745,18 +138784,25 @@ class src_client_Client {
138745
138784
  }, _callee2);
138746
138785
  }))();
138747
138786
  }
138748
- transmitStaple(votesAndBlocks) {
138749
- var _arguments = arguments,
138750
- _this3 = this;
138787
+ transmitStaple(votesAndBlocks, reps) {
138788
+ var _this3 = this;
138751
138789
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee4() {
138752
- var reps, publishPromises, _iterator, _step, _loop, publishObjects, retval, publishError, _iterator2, _step2, publishObjectWrapperSettled;
138790
+ var publishPromises, _iterator, _step, _loop, publishObjects, retval, publishError, _iterator2, _step2, publishObjectWrapperSettled;
138753
138791
  return client_client_regeneratorRuntime().wrap(function _callee4$(_context5) {
138754
138792
  while (1) switch (_context5.prev = _context5.next) {
138755
138793
  case 0:
138756
- reps = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : client_client_classPrivateFieldGet(client_reps, _this3);
138794
+ if (!(!reps || reps.length === 0)) {
138795
+ _context5.next = 4;
138796
+ break;
138797
+ }
138798
+ _context5.next = 3;
138799
+ return client_client_classPrivateFieldGet(client_updateRepsPromise, _this3);
138800
+ case 3:
138801
+ reps = [client_client_classPrivateFieldGet(client_weightOrderedReps, _this3)[0]];
138802
+ case 4:
138757
138803
  publishPromises = [];
138758
138804
  _iterator = client_client_createForOfIteratorHelper(reps);
138759
- _context5.prev = 3;
138805
+ _context5.prev = 6;
138760
138806
  _loop = /*#__PURE__*/client_client_regeneratorRuntime().mark(function _loop() {
138761
138807
  var rep;
138762
138808
  return client_client_regeneratorRuntime().wrap(function _loop$(_context4) {
@@ -138790,78 +138836,78 @@ class src_client_Client {
138790
138836
  }, _loop);
138791
138837
  });
138792
138838
  _iterator.s();
138793
- case 6:
138839
+ case 9:
138794
138840
  if ((_step = _iterator.n()).done) {
138795
- _context5.next = 10;
138841
+ _context5.next = 13;
138796
138842
  break;
138797
138843
  }
138798
- return _context5.delegateYield(_loop(), "t0", 8);
138799
- case 8:
138800
- _context5.next = 6;
138844
+ return _context5.delegateYield(_loop(), "t0", 11);
138845
+ case 11:
138846
+ _context5.next = 9;
138801
138847
  break;
138802
- case 10:
138803
- _context5.next = 15;
138848
+ case 13:
138849
+ _context5.next = 18;
138804
138850
  break;
138805
- case 12:
138806
- _context5.prev = 12;
138807
- _context5.t1 = _context5["catch"](3);
138808
- _iterator.e(_context5.t1);
138809
138851
  case 15:
138810
138852
  _context5.prev = 15;
138811
- _iterator.f();
138812
- return _context5.finish(15);
138853
+ _context5.t1 = _context5["catch"](6);
138854
+ _iterator.e(_context5.t1);
138813
138855
  case 18:
138814
- _context5.next = 20;
138856
+ _context5.prev = 18;
138857
+ _iterator.f();
138858
+ return _context5.finish(18);
138859
+ case 21:
138860
+ _context5.next = 23;
138815
138861
  return Promise.allSettled(publishPromises);
138816
- case 20:
138862
+ case 23:
138817
138863
  publishObjects = _context5.sent;
138818
138864
  retval = false;
138819
138865
  _iterator2 = client_client_createForOfIteratorHelper(publishObjects);
138820
- _context5.prev = 23;
138866
+ _context5.prev = 26;
138821
138867
  _iterator2.s();
138822
- case 25:
138868
+ case 28:
138823
138869
  if ((_step2 = _iterator2.n()).done) {
138824
- _context5.next = 35;
138870
+ _context5.next = 38;
138825
138871
  break;
138826
138872
  }
138827
138873
  publishObjectWrapperSettled = _step2.value;
138828
138874
  if (!(publishObjectWrapperSettled.status === 'fulfilled')) {
138829
- _context5.next = 32;
138875
+ _context5.next = 35;
138830
138876
  break;
138831
138877
  }
138832
138878
  retval = true;
138833
- return _context5.abrupt("break", 35);
138834
- case 32:
138879
+ return _context5.abrupt("break", 38);
138880
+ case 35:
138835
138881
  publishError = publishObjectWrapperSettled.reason;
138836
- case 33:
138837
- _context5.next = 25;
138882
+ case 36:
138883
+ _context5.next = 28;
138838
138884
  break;
138839
- case 35:
138840
- _context5.next = 40;
138885
+ case 38:
138886
+ _context5.next = 43;
138841
138887
  break;
138842
- case 37:
138843
- _context5.prev = 37;
138844
- _context5.t2 = _context5["catch"](23);
138845
- _iterator2.e(_context5.t2);
138846
138888
  case 40:
138847
138889
  _context5.prev = 40;
138848
- _iterator2.f();
138849
- return _context5.finish(40);
138890
+ _context5.t2 = _context5["catch"](26);
138891
+ _iterator2.e(_context5.t2);
138850
138892
  case 43:
138893
+ _context5.prev = 43;
138894
+ _iterator2.f();
138895
+ return _context5.finish(43);
138896
+ case 46:
138851
138897
  if (!(!retval && publishError)) {
138852
- _context5.next = 45;
138898
+ _context5.next = 48;
138853
138899
  break;
138854
138900
  }
138855
138901
  throw new Error(publishError);
138856
- case 45:
138902
+ case 48:
138857
138903
  return _context5.abrupt("return", {
138858
138904
  publish: retval
138859
138905
  });
138860
- case 46:
138906
+ case 49:
138861
138907
  case "end":
138862
138908
  return _context5.stop();
138863
138909
  }
138864
- }, _callee4, null, [[3, 12, 15, 18], [23, 37, 40, 43]]);
138910
+ }, _callee4, null, [[6, 15, 18, 21], [26, 40, 43, 46]]);
138865
138911
  }))();
138866
138912
  }
138867
138913
  getNodeStats() {
@@ -138978,14 +139024,14 @@ class src_client_Client {
138978
139024
  }))();
138979
139025
  }
138980
139026
  listACLsByPrincipal(account) {
138981
- var _arguments2 = arguments,
139027
+ var _arguments = arguments,
138982
139028
  _this8 = this;
138983
139029
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee9() {
138984
139030
  var targets, joinedTargets, result;
138985
139031
  return client_client_regeneratorRuntime().wrap(function _callee9$(_context10) {
138986
139032
  while (1) switch (_context10.prev = _context10.next) {
138987
139033
  case 0:
138988
- targets = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : [];
139034
+ targets = _arguments.length > 1 && _arguments[1] !== undefined ? _arguments[1] : [];
138989
139035
  account = client_src_lib.Account.toPublicKeyString(account);
138990
139036
  joinedTargets = client_client_assertClassBrand(client_Client_brand, _this8, client_urlSeparatedAccounts).call(_this8, targets);
138991
139037
  _context10.next = 5;
@@ -139006,14 +139052,14 @@ class src_client_Client {
139006
139052
  }))();
139007
139053
  }
139008
139054
  listACLsByPrincipalWithInfo(account) {
139009
- var _arguments3 = arguments,
139055
+ var _arguments2 = arguments,
139010
139056
  _this9 = this;
139011
139057
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee10() {
139012
139058
  var targets, joinedTargets, response, parsed;
139013
139059
  return client_client_regeneratorRuntime().wrap(function _callee10$(_context11) {
139014
139060
  while (1) switch (_context11.prev = _context11.next) {
139015
139061
  case 0:
139016
- targets = _arguments3.length > 1 && _arguments3[1] !== undefined ? _arguments3[1] : [];
139062
+ targets = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : [];
139017
139063
  account = client_src_lib.Account.toPublicKeyString(account);
139018
139064
  joinedTargets = client_client_assertClassBrand(client_Client_brand, _this9, client_urlSeparatedAccounts).call(_this9, targets);
139019
139065
  _context11.next = 5;
@@ -139147,14 +139193,14 @@ class src_client_Client {
139147
139193
  }))();
139148
139194
  }
139149
139195
  getBlock(blockhash, side) {
139150
- var _arguments4 = arguments,
139196
+ var _arguments3 = arguments,
139151
139197
  _this14 = this;
139152
139198
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee15() {
139153
139199
  var rep, info, block;
139154
139200
  return client_client_regeneratorRuntime().wrap(function _callee15$(_context16) {
139155
139201
  while (1) switch (_context16.prev = _context16.next) {
139156
139202
  case 0:
139157
- rep = _arguments4.length > 2 && _arguments4[2] !== undefined ? _arguments4[2] : 'ANY';
139203
+ rep = _arguments3.length > 2 && _arguments3[2] !== undefined ? _arguments3[2] : 'ANY';
139158
139204
  if (typeof blockhash !== 'string') {
139159
139205
  blockhash = blockhash.toString('hex');
139160
139206
  }
@@ -139305,14 +139351,14 @@ class src_client_Client {
139305
139351
  }))();
139306
139352
  }
139307
139353
  getChain(account) {
139308
- var _arguments5 = arguments,
139354
+ var _arguments4 = arguments,
139309
139355
  _this16 = this;
139310
139356
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee17() {
139311
139357
  var options, _options$depth, depth, startBlock, query, retval, chain, _iterator7, _step7, blockInfo, blockJSON, blockBytes, block;
139312
139358
  return client_client_regeneratorRuntime().wrap(function _callee17$(_context18) {
139313
139359
  while (1) switch (_context18.prev = _context18.next) {
139314
139360
  case 0:
139315
- options = _arguments5.length > 1 && _arguments5[1] !== undefined ? _arguments5[1] : {};
139361
+ options = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : {};
139316
139362
  _options$depth = options.depth, depth = _options$depth === void 0 ? Infinity : _options$depth, startBlock = options.startBlock;
139317
139363
  account = client_lib_account.toPublicKeyString(account);
139318
139364
  query = {
@@ -139393,14 +139439,14 @@ class src_client_Client {
139393
139439
  }))();
139394
139440
  }
139395
139441
  getHistory(account) {
139396
- var _arguments6 = arguments,
139442
+ var _arguments5 = arguments,
139397
139443
  _this17 = this;
139398
139444
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee18() {
139399
139445
  var options, _options$depth2, depth, startBlocksHash, startVoteStapleID, retval, limit, query, history, _iterator8, _step8, historyEntry, voteStapleInfo, voteStapleBinary, voteStaple;
139400
139446
  return client_client_regeneratorRuntime().wrap(function _callee18$(_context19) {
139401
139447
  while (1) switch (_context19.prev = _context19.next) {
139402
139448
  case 0:
139403
- options = _arguments6.length > 1 && _arguments6[1] !== undefined ? _arguments6[1] : {};
139449
+ options = _arguments5.length > 1 && _arguments5[1] !== undefined ? _arguments5[1] : {};
139404
139450
  _options$depth2 = options.depth, depth = _options$depth2 === void 0 ? Infinity : _options$depth2, startBlocksHash = options.startBlocksHash;
139405
139451
  account = client_lib_account.toPublicKeyString(account);
139406
139452
  startVoteStapleID = undefined;
@@ -139613,14 +139659,14 @@ class src_client_Client {
139613
139659
  * @param timeout Maximum time to wait for a response from a representative in milliseconds
139614
139660
  */
139615
139661
  getNetworkStatus() {
139616
- var _arguments7 = arguments,
139662
+ var _arguments6 = arguments,
139617
139663
  _this21 = this;
139618
139664
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee25() {
139619
139665
  var timeout, reps, repsInfo, retval;
139620
139666
  return client_client_regeneratorRuntime().wrap(function _callee25$(_context26) {
139621
139667
  while (1) switch (_context26.prev = _context26.next) {
139622
139668
  case 0:
139623
- timeout = _arguments7.length > 0 && _arguments7[0] !== undefined ? _arguments7[0] : 5000;
139669
+ timeout = _arguments6.length > 0 && _arguments6[0] !== undefined ? _arguments6[0] : 5000;
139624
139670
  reps = client_client_classPrivateFieldGet(client_reps, _this21);
139625
139671
  repsInfo = reps.map(/*#__PURE__*/function () {
139626
139672
  var _ref3 = client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee24(rep) {
@@ -139690,18 +139736,21 @@ class src_client_Client {
139690
139736
  }))();
139691
139737
  }
139692
139738
  updateReps() {
139693
- var _this22 = this;
139739
+ var _arguments7 = arguments,
139740
+ _this22 = this;
139694
139741
  return client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee26() {
139695
- var repsResponse, _iterator9, _step9, _loop2;
139742
+ var addNewReps, repsResponse, weightedReps, _iterator9, _step9, _loop2;
139696
139743
  return client_client_regeneratorRuntime().wrap(function _callee26$(_context28) {
139697
139744
  while (1) switch (_context28.prev = _context28.next) {
139698
139745
  case 0:
139699
- _context28.next = 2;
139746
+ addNewReps = _arguments7.length > 0 && _arguments7[0] !== undefined ? _arguments7[0] : false;
139747
+ _context28.next = 3;
139700
139748
  return client_client_assertClassBrand(client_Client_brand, _this22, src_client_api).call(_this22, 'ANY', 'GET /node/ledger/representatives');
139701
- case 2:
139749
+ case 3:
139702
139750
  repsResponse = _context28.sent;
139751
+ weightedReps = [];
139703
139752
  _iterator9 = client_client_createForOfIteratorHelper(repsResponse.representatives);
139704
- _context28.prev = 4;
139753
+ _context28.prev = 6;
139705
139754
  _loop2 = /*#__PURE__*/client_client_regeneratorRuntime().mark(function _loop2() {
139706
139755
  var rep, repAccount, repIndex, repInfo;
139707
139756
  return client_client_regeneratorRuntime().wrap(function _loop2$(_context27) {
@@ -139714,12 +139763,18 @@ class src_client_Client {
139714
139763
  });
139715
139764
  repInfo = {
139716
139765
  key: repAccount,
139766
+ weight: BigInt(rep.weight),
139717
139767
  endpoints: rep.endpoints
139718
139768
  };
139719
139769
  if (repIndex === -1) {
139720
- client_client_classPrivateFieldGet(client_reps, _this22).push(repInfo);
139770
+ if (addNewReps) {
139771
+ // TODO - make addNewReps default true when rep tracking is stable
139772
+ // If we are adding new reps, also add them to weight sorted reps
139773
+ client_client_classPrivateFieldGet(client_reps, _this22).push(repInfo);
139774
+ weightedReps.push(repInfo);
139775
+ }
139721
139776
  } else {
139722
- client_client_classPrivateFieldGet(client_reps, _this22)[repIndex] = repInfo;
139777
+ weightedReps.push(repInfo);
139723
139778
  }
139724
139779
  case 5:
139725
139780
  case "end":
@@ -139728,31 +139783,42 @@ class src_client_Client {
139728
139783
  }, _loop2);
139729
139784
  });
139730
139785
  _iterator9.s();
139731
- case 7:
139786
+ case 9:
139732
139787
  if ((_step9 = _iterator9.n()).done) {
139733
- _context28.next = 11;
139788
+ _context28.next = 13;
139734
139789
  break;
139735
139790
  }
139736
- return _context28.delegateYield(_loop2(), "t0", 9);
139737
- case 9:
139738
- _context28.next = 7;
139739
- break;
139791
+ return _context28.delegateYield(_loop2(), "t0", 11);
139740
139792
  case 11:
139741
- _context28.next = 16;
139793
+ _context28.next = 9;
139742
139794
  break;
139743
139795
  case 13:
139744
- _context28.prev = 13;
139745
- _context28.t1 = _context28["catch"](4);
139796
+ _context28.next = 18;
139797
+ break;
139798
+ case 15:
139799
+ _context28.prev = 15;
139800
+ _context28.t1 = _context28["catch"](6);
139746
139801
  _iterator9.e(_context28.t1);
139747
- case 16:
139748
- _context28.prev = 16;
139802
+ case 18:
139803
+ _context28.prev = 18;
139749
139804
  _iterator9.f();
139750
- return _context28.finish(16);
139751
- case 19:
139805
+ return _context28.finish(18);
139806
+ case 21:
139807
+ weightedReps.sort((rep1, rep2) => {
139808
+ if (rep2.weight > rep1.weight) {
139809
+ return 1;
139810
+ }
139811
+ if (rep2.weight < rep1.weight) {
139812
+ return -1;
139813
+ }
139814
+ return 0;
139815
+ });
139816
+ client_client_classPrivateFieldSet(client_weightOrderedReps, _this22, weightedReps);
139817
+ case 23:
139752
139818
  case "end":
139753
139819
  return _context28.stop();
139754
139820
  }
139755
- }, _callee26, null, [[4, 13, 16, 19]]);
139821
+ }, _callee26, null, [[6, 15, 18, 21]]);
139756
139822
  }))();
139757
139823
  }
139758
139824
  getVoteStaplesAfter(moment, limit, bloomFilter) {
@@ -140211,6 +140277,7 @@ function client_apiRaw2() {
140211
140277
  result,
140212
140278
  resultThrow,
140213
140279
  retry,
140280
+ _classPrivateFieldGet5,
140214
140281
  repURL,
140215
140282
  fetchURL,
140216
140283
  shouldFail,
@@ -140237,17 +140304,27 @@ function client_apiRaw2() {
140237
140304
  retry = 0;
140238
140305
  case 5:
140239
140306
  if (!(retry < Number.MAX_SAFE_INTEGER)) {
140240
- _context59.next = 79;
140307
+ _context59.next = 83;
140308
+ break;
140309
+ }
140310
+ if (!(rep === 'ANY')) {
140311
+ _context59.next = 11;
140241
140312
  break;
140242
140313
  }
140243
- if (rep === 'ANY') {
140244
- rep = client_client_classPrivateFieldGet(client_reps, this)[0];
140314
+ if (!(client_client_classPrivateFieldGet(client_weightOrderedReps, this).length === 0)) {
140315
+ _context59.next = 10;
140316
+ break;
140245
140317
  }
140318
+ _context59.next = 10;
140319
+ return client_client_classPrivateFieldGet(client_updateRepsPromise, this);
140320
+ case 10:
140321
+ rep = (_classPrivateFieldGet5 = client_client_classPrivateFieldGet(client_weightOrderedReps, this)[0]) !== null && _classPrivateFieldGet5 !== void 0 ? _classPrivateFieldGet5 : client_client_classPrivateFieldGet(client_reps, this)[0];
140322
+ case 11:
140246
140323
  repURL = rep.endpoints.api;
140247
140324
  fetchURL = "".concat(repURL).concat(api);
140248
140325
  shouldFail = false;
140249
140326
  resultThrow = undefined;
140250
- _context59.prev = 11;
140327
+ _context59.prev = 15;
140251
140328
  this.stats.api.called++;
140252
140329
  requestBody = void 0;
140253
140330
  if (options.body !== undefined) {
@@ -140273,13 +140350,13 @@ function client_apiRaw2() {
140273
140350
  fetchURL = "".concat(fetchURL, "?").concat(urlParams.toString());
140274
140351
  }
140275
140352
  if (!(fetchURL.length > 8192)) {
140276
- _context59.next = 21;
140353
+ _context59.next = 25;
140277
140354
  break;
140278
140355
  }
140279
140356
  shouldFail = true;
140280
140357
  throw new Error('#api() URL Must not be over 8KiB');
140281
- case 21:
140282
- _context59.next = 23;
140358
+ case 25:
140359
+ _context59.next = 27;
140283
140360
  return client_fetch(fetchURL, {
140284
140361
  method: method,
140285
140362
  headers: {
@@ -140292,36 +140369,36 @@ function client_apiRaw2() {
140292
140369
  agent: client_client_classPrivateFieldGet(client_agent, this),
140293
140370
  body: requestBody
140294
140371
  });
140295
- case 23:
140372
+ case 27:
140296
140373
  response = _context59.sent;
140297
140374
  if (!(response === undefined)) {
140298
- _context59.next = 26;
140375
+ _context59.next = 30;
140299
140376
  break;
140300
140377
  }
140301
140378
  throw new Error('Failed to publish (undefined)');
140302
- case 26:
140379
+ case 30:
140303
140380
  if (response.ok) {
140304
- _context59.next = 51;
140381
+ _context59.next = 55;
140305
140382
  break;
140306
140383
  }
140307
- _context59.prev = 27;
140308
- _context59.next = 30;
140384
+ _context59.prev = 31;
140385
+ _context59.next = 34;
140309
140386
  return response.json();
140310
- case 30:
140387
+ case 34:
140311
140388
  errorInfo = _context59.sent;
140312
140389
  if (!(errorInfo.error === true)) {
140313
- _context59.next = 34;
140390
+ _context59.next = 38;
140314
140391
  break;
140315
140392
  }
140316
140393
  resultThrow = errorInfo;
140317
- return _context59.abrupt("break", 79);
140318
- case 34:
140319
- _context59.next = 38;
140320
- break;
140321
- case 36:
140322
- _context59.prev = 36;
140323
- _context59.t0 = _context59["catch"](27);
140394
+ return _context59.abrupt("break", 83);
140324
140395
  case 38:
140396
+ _context59.next = 42;
140397
+ break;
140398
+ case 40:
140399
+ _context59.prev = 40;
140400
+ _context59.t0 = _context59["catch"](31);
140401
+ case 42:
140325
140402
  /**
140326
140403
  * If we get a fatal error, give up
140327
140404
  */
@@ -140329,43 +140406,43 @@ function client_apiRaw2() {
140329
140406
  shouldFail = true;
140330
140407
  }
140331
140408
  errorMessage = 'Failed to make API call (not ok)';
140332
- _context59.prev = 40;
140409
+ _context59.prev = 44;
140333
140410
  _context59.t1 = "".concat(errorMessage, ": ");
140334
- _context59.next = 44;
140411
+ _context59.next = 48;
140335
140412
  return response.text();
140336
- case 44:
140413
+ case 48:
140337
140414
  _context59.t2 = _context59.sent;
140338
140415
  errorMessage = _context59.t1.concat.call(_context59.t1, _context59.t2);
140339
- _context59.next = 50;
140416
+ _context59.next = 54;
140340
140417
  break;
140341
- case 48:
140342
- _context59.prev = 48;
140343
- _context59.t3 = _context59["catch"](40);
140344
- case 50:
140418
+ case 52:
140419
+ _context59.prev = 52;
140420
+ _context59.t3 = _context59["catch"](44);
140421
+ case 54:
140345
140422
  throw new Error(errorMessage);
140346
- case 51:
140347
- _context59.next = 53;
140423
+ case 55:
140424
+ _context59.next = 57;
140348
140425
  return response.json();
140349
- case 53:
140426
+ case 57:
140350
140427
  data = _context59.sent;
140351
140428
  if (data) {
140352
- _context59.next = 56;
140429
+ _context59.next = 60;
140353
140430
  break;
140354
140431
  }
140355
140432
  throw new Error('Failed to make API call (no data)');
140356
- case 56:
140433
+ case 60:
140357
140434
  if (data instanceof Object) {
140358
- _context59.next = 58;
140435
+ _context59.next = 62;
140359
140436
  break;
140360
140437
  }
140361
140438
  throw new Error('Failed to make API call (malformed data)');
140362
- case 58:
140439
+ case 62:
140363
140440
  result = data;
140364
- _context59.next = 75;
140441
+ _context59.next = 79;
140365
140442
  break;
140366
- case 61:
140367
- _context59.prev = 61;
140368
- _context59.t4 = _context59["catch"](11);
140443
+ case 65:
140444
+ _context59.prev = 65;
140445
+ _context59.t4 = _context59["catch"](15);
140369
140446
  this.stats.api.failures++;
140370
140447
  now = Date.now();
140371
140448
  if (now - startTime > 5000) {
@@ -140377,49 +140454,49 @@ function client_apiRaw2() {
140377
140454
  }
140378
140455
  }
140379
140456
  if (!shouldFail) {
140380
- _context59.next = 70;
140457
+ _context59.next = 74;
140381
140458
  break;
140382
140459
  }
140383
140460
  if (!resultThrow) {
140384
140461
  resultThrow = _context59.t4;
140385
140462
  }
140386
- return _context59.abrupt("break", 79);
140387
- case 70:
140463
+ return _context59.abrupt("break", 83);
140464
+ case 74:
140388
140465
  delay *= 2;
140389
140466
  if (delay > 500) {
140390
140467
  delay = 500;
140391
140468
  }
140392
- _context59.next = 74;
140469
+ _context59.next = 78;
140393
140470
  return client_asleep(delay);
140394
- case 74:
140395
- return _context59.abrupt("continue", 76);
140396
- case 75:
140397
- return _context59.abrupt("break", 79);
140398
- case 76:
140471
+ case 78:
140472
+ return _context59.abrupt("continue", 80);
140473
+ case 79:
140474
+ return _context59.abrupt("break", 83);
140475
+ case 80:
140399
140476
  retry++;
140400
140477
  _context59.next = 5;
140401
140478
  break;
140402
- case 79:
140479
+ case 83:
140403
140480
  if (!resultThrow) {
140404
- _context59.next = 87;
140481
+ _context59.next = 91;
140405
140482
  break;
140406
140483
  }
140407
140484
  if (!(resultThrow.code && resultThrow.type)) {
140408
- _context59.next = 86;
140485
+ _context59.next = 90;
140409
140486
  break;
140410
140487
  }
140411
140488
  error = new src_client_KeetaNetError(resultThrow.code, resultThrow.message);
140412
140489
  error.type = resultThrow.type;
140413
140490
  throw error;
140414
- case 86:
140491
+ case 90:
140415
140492
  throw new Error(resultThrow.message);
140416
- case 87:
140493
+ case 91:
140417
140494
  return _context59.abrupt("return", result);
140418
- case 88:
140495
+ case 92:
140419
140496
  case "end":
140420
140497
  return _context59.stop();
140421
140498
  }
140422
- }, _callee57, this, [[11, 61], [27, 36], [40, 48]]);
140499
+ }, _callee57, this, [[15, 65], [31, 40], [44, 52]]);
140423
140500
  }));
140424
140501
  return client_apiRaw2.apply(this, arguments);
140425
140502
  }
@@ -140469,14 +140546,14 @@ function client_requestVotes2() {
140469
140546
  request,
140470
140547
  recentVotingError,
140471
140548
  votePromises,
140472
- _iterator18,
140473
- _step18,
140549
+ _iterator20,
140550
+ _step20,
140474
140551
  _loop3,
140475
140552
  votesObjects,
140476
140553
  retval,
140477
140554
  voteSettlementError,
140478
- _iterator19,
140479
- _step19,
140555
+ _iterator21,
140556
+ _step21,
140480
140557
  voteObjectWrapperSettled,
140481
140558
  voteObjectWrapper,
140482
140559
  voteObject,
@@ -140523,14 +140600,14 @@ function client_requestVotes2() {
140523
140600
  }
140524
140601
  case 7:
140525
140602
  votePromises = [];
140526
- _iterator18 = client_client_createForOfIteratorHelper(reps);
140603
+ _iterator20 = client_client_createForOfIteratorHelper(reps);
140527
140604
  _context63.prev = 9;
140528
140605
  _loop3 = /*#__PURE__*/client_client_regeneratorRuntime().mark(function _loop3() {
140529
140606
  var rep;
140530
140607
  return client_client_regeneratorRuntime().wrap(function _loop3$(_context62) {
140531
140608
  while (1) switch (_context62.prev = _context62.next) {
140532
140609
  case 0:
140533
- rep = _step18.value;
140610
+ rep = _step20.value;
140534
140611
  votePromises.push(client_client_asyncToGenerator(/*#__PURE__*/client_client_regeneratorRuntime().mark(function _callee59() {
140535
140612
  var apiResult;
140536
140613
  return client_client_regeneratorRuntime().wrap(function _callee59$(_context61) {
@@ -140568,9 +140645,9 @@ function client_requestVotes2() {
140568
140645
  }
140569
140646
  }, _loop3);
140570
140647
  });
140571
- _iterator18.s();
140648
+ _iterator20.s();
140572
140649
  case 12:
140573
- if ((_step18 = _iterator18.n()).done) {
140650
+ if ((_step20 = _iterator20.n()).done) {
140574
140651
  _context63.next = 16;
140575
140652
  break;
140576
140653
  }
@@ -140584,10 +140661,10 @@ function client_requestVotes2() {
140584
140661
  case 18:
140585
140662
  _context63.prev = 18;
140586
140663
  _context63.t1 = _context63["catch"](9);
140587
- _iterator18.e(_context63.t1);
140664
+ _iterator20.e(_context63.t1);
140588
140665
  case 21:
140589
140666
  _context63.prev = 21;
140590
- _iterator18.f();
140667
+ _iterator20.f();
140591
140668
  return _context63.finish(21);
140592
140669
  case 24:
140593
140670
  _context63.next = 26;
@@ -140595,15 +140672,15 @@ function client_requestVotes2() {
140595
140672
  case 26:
140596
140673
  votesObjects = _context63.sent;
140597
140674
  retval = [];
140598
- _iterator19 = client_client_createForOfIteratorHelper(votesObjects);
140675
+ _iterator21 = client_client_createForOfIteratorHelper(votesObjects);
140599
140676
  _context63.prev = 29;
140600
- _iterator19.s();
140677
+ _iterator21.s();
140601
140678
  case 31:
140602
- if ((_step19 = _iterator19.n()).done) {
140679
+ if ((_step21 = _iterator21.n()).done) {
140603
140680
  _context63.next = 44;
140604
140681
  break;
140605
140682
  }
140606
- voteObjectWrapperSettled = _step19.value;
140683
+ voteObjectWrapperSettled = _step21.value;
140607
140684
  if (!(voteObjectWrapperSettled.status === 'rejected')) {
140608
140685
  _context63.next = 36;
140609
140686
  break;
@@ -140630,10 +140707,10 @@ function client_requestVotes2() {
140630
140707
  case 46:
140631
140708
  _context63.prev = 46;
140632
140709
  _context63.t2 = _context63["catch"](29);
140633
- _iterator19.e(_context63.t2);
140710
+ _iterator21.e(_context63.t2);
140634
140711
  case 49:
140635
140712
  _context63.prev = 49;
140636
- _iterator19.f();
140713
+ _iterator21.f();
140637
140714
  return _context63.finish(49);
140638
140715
  case 52:
140639
140716
  if (!(retval.length === 0 && recentVotingError !== undefined)) {
@@ -140903,6 +140980,77 @@ class src_client_UserClient {
140903
140980
  });
140904
140981
  return new src_client_UserClient(config);
140905
140982
  }
140983
+ static filterStapleOperations(voteStaples, account) {
140984
+ var filteredOperations = {};
140985
+ // For each staple
140986
+ var _iterator17 = client_client_createForOfIteratorHelper(voteStaples),
140987
+ _step17;
140988
+ try {
140989
+ for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
140990
+ var staple = _step17.value;
140991
+ var stapleHash = staple.blocksHash.toString();
140992
+ filteredOperations[stapleHash] = [];
140993
+ // For each block
140994
+ var _iterator18 = client_client_createForOfIteratorHelper(staple.blocks),
140995
+ _step18;
140996
+ try {
140997
+ for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
140998
+ var block = _step18.value;
140999
+ var blockOperations = [];
141000
+ // If block is produced by the account being filtered, included all operations
141001
+ if (block.account.comparePublicKey(account)) {
141002
+ blockOperations.push(...block.operations);
141003
+ } else {
141004
+ // If the block is for another account then filter the operations for the given account
141005
+ for (var ops in block.operations) {
141006
+ var operation = block.operations[ops];
141007
+ var principals = [];
141008
+ switch (operation.type) {
141009
+ case client_OperationType.SEND:
141010
+ case client_OperationType.SET_REP:
141011
+ principals.push(operation.to);
141012
+ break;
141013
+ case client_OperationType.MODIFY_PERMISSIONS:
141014
+ principals.push(operation.principal);
141015
+ break;
141016
+ case client_OperationType.CREATE_IDENTIFIER:
141017
+ principals.push(operation.identifier);
141018
+ break;
141019
+ case client_OperationType.TOKEN_ADMIN_MODIFY_BALANCE:
141020
+ case client_OperationType.SET_INFO:
141021
+ case client_OperationType.TOKEN_ADMIN_SUPPLY:
141022
+ // Do nothing for these, they don't reference an account directly
141023
+ break;
141024
+ case client_OperationType.RECEIVE:
141025
+ principals.push(operation.from);
141026
+ if (operation.forward) {
141027
+ principals.push(operation.forward);
141028
+ }
141029
+ break;
141030
+ }
141031
+ if (principals.length > 0 && principals.some(principal => principal.comparePublicKey(account))) {
141032
+ blockOperations.push(operation);
141033
+ }
141034
+ }
141035
+ }
141036
+ filteredOperations[stapleHash].push({
141037
+ block,
141038
+ filteredOperations: blockOperations
141039
+ });
141040
+ }
141041
+ } catch (err) {
141042
+ _iterator18.e(err);
141043
+ } finally {
141044
+ _iterator18.f();
141045
+ }
141046
+ }
141047
+ } catch (err) {
141048
+ _iterator17.e(err);
141049
+ } finally {
141050
+ _iterator17.f();
141051
+ }
141052
+ return filteredOperations;
141053
+ }
140906
141054
  constructor(config) {
140907
141055
  client_client_classPrivateMethodInitSpec(this, client_UserClient_brand);
140908
141056
  client_client_classPrivateFieldInitSpec(this, client_client_config, void 0);
@@ -141328,6 +141476,11 @@ class src_client_UserClient {
141328
141476
  }, _callee48);
141329
141477
  }))();
141330
141478
  }
141479
+ filterStapleOperations(voteStaples) {
141480
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
141481
+ var account = client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options);
141482
+ return src_client_UserClient.filterStapleOperations(voteStaples, account);
141483
+ }
141331
141484
  state() {
141332
141485
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
141333
141486
  return client_client_classPrivateFieldGet(client_client, this).getAccountInfo(client_client_assertClassBrand(client_UserClient_brand, this, client_getAccount).call(this, options));
@@ -141739,11 +141892,11 @@ function client_emit(event) {
141739
141892
  for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
141740
141893
  data[_key - 1] = arguments[_key];
141741
141894
  }
141742
- var _iterator17 = client_client_createForOfIteratorHelper(handlers.values()),
141743
- _step17;
141895
+ var _iterator19 = client_client_createForOfIteratorHelper(handlers.values()),
141896
+ _step19;
141744
141897
  try {
141745
- for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
141746
- var handler = _step17.value;
141898
+ for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
141899
+ var handler = _step19.value;
141747
141900
  /*
141748
141901
  * TypeScript thinks the "data" types are incorrect but they are correct
141749
141902
  */
@@ -141751,9 +141904,9 @@ function client_emit(event) {
141751
141904
  handler(...data);
141752
141905
  }
141753
141906
  } catch (err) {
141754
- _iterator17.e(err);
141907
+ _iterator19.e(err);
141755
141908
  } finally {
141756
- _iterator17.f();
141909
+ _iterator19.f();
141757
141910
  }
141758
141911
  }
141759
141912
  function client_emitAccountInfoIfChanged() {