evernode-js-client 0.6.28 → 0.6.29

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -9149,7 +9149,7 @@ module.exports = { mask, unmask };
9149
9149
 
9150
9150
 
9151
9151
  try {
9152
- module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.node");
9152
+ module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
9153
9153
  } catch (e) {
9154
9154
  module.exports = __nccwpck_require__(2567);
9155
9155
  }
@@ -33340,7 +33340,7 @@ module.exports = isValidUTF8;
33340
33340
 
33341
33341
 
33342
33342
  try {
33343
- module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
33343
+ module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.node");
33344
33344
  } catch (e) {
33345
33345
  module.exports = __nccwpck_require__(9372);
33346
33346
  }
@@ -52510,6 +52510,40 @@ class BaseEvernodeClient {
52510
52510
  return (hosts.nextPageToken ? { ...hosts, data: res } : res);
52511
52511
  }
52512
52512
 
52513
+ /**
52514
+ * Get the hosts registered in Evernode.
52515
+ * @returns The list of hosts.
52516
+ */
52517
+ async getAllHostsFromLedger() {
52518
+ const states = await this.getHookStates();
52519
+ let hosts = {};
52520
+
52521
+ for (const state of states) {
52522
+ const stateKey = Buffer.from(state.key, 'hex');
52523
+ if (state.data) {
52524
+ const stateData = Buffer.from(state.data, 'hex');
52525
+ const decoded = StateHelpers.decodeStateData(stateKey, stateData);
52526
+ if (decoded.type == StateHelpers.StateTypes.HOST_ADDR || decoded.type == StateHelpers.StateTypes.TOKEN_ID) {
52527
+ hosts[decoded.address] = { ...(hosts[decoded.address] ?? {}), ...decoded };
52528
+ }
52529
+ }
52530
+ }
52531
+
52532
+ const hostList = Object.values(hosts);
52533
+
52534
+ const curMomentStartIdx = await this.getMomentStartIndex();
52535
+ await Promise.all((hostList).map(async host => {
52536
+ const hostAcc = new XrplAccount(host.address, null, { xrplApi: this.xrplApi });
52537
+ host.domain = await hostAcc.getDomain();
52538
+ host.active = (host.lastHeartbeatIndex > (this.config.hostHeartbeatFreq * this.config.momentSize) ?
52539
+ (host.lastHeartbeatIndex >= (curMomentStartIdx - (this.config.hostHeartbeatFreq * this.config.momentSize))) :
52540
+ (host.lastHeartbeatIndex > 0));
52541
+ return host;
52542
+ }));
52543
+
52544
+ return hostList;
52545
+ }
52546
+
52513
52547
  /**
52514
52548
  * Get the candidates proposed in Evernode. The result's are paginated. Default page size is 20. _Note: Specifying both filter and pagination does not supported._
52515
52549
  * @param {object} filters [Optional] Filter criteria to filter the candidates. The filter key can be a either property of the candidate.
@@ -53251,6 +53285,16 @@ class RegistryClient extends BaseEvernodeClient {
53251
53285
  // Filter only active hosts.
53252
53286
  return fullHostList.filter(h => h.active);
53253
53287
  }
53288
+
53289
+ /**
53290
+ * Gets all the active hosts registered in ledger.
53291
+ * @returns The list of active hosts.
53292
+ */
53293
+ async getActiveHostsFromLedger() {
53294
+ const hosts = await this.getAllHostsFromLedger();
53295
+ // Filter only active hosts.
53296
+ return hosts.filter(h => h.active);
53297
+ }
53254
53298
  }
53255
53299
 
53256
53300
  module.exports = {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  ],
7
7
  "homepage": "https://github.com/HotPocketDev/evernode-js-client",
8
8
  "license": "SEE LICENSE IN https://raw.githubusercontent.com/EvernodeXRPL/evernode-resources/main/license/evernode-license.pdf",
9
- "version": "0.6.28",
9
+ "version": "0.6.29",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",
Binary file
Binary file