evernode-js-client 0.4.46 → 0.4.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +19 -12
- package/package.json +1 -1
package/index.js
CHANGED
@@ -12061,17 +12061,24 @@ class BaseEvernodeClient {
|
|
12061
12061
|
|
12062
12062
|
// To get Host details from Hook States.
|
12063
12063
|
async getHostInfo(hostAddress = this.xrplAcc.address) {
|
12064
|
-
|
12065
|
-
|
12066
|
-
|
12067
|
-
|
12068
|
-
|
12069
|
-
|
12070
|
-
|
12071
|
-
|
12072
|
-
|
12073
|
-
|
12074
|
-
|
12064
|
+
try {
|
12065
|
+
const hostAddrStatekey = StateHelpers.generateHostAddrStateKey(hostAddress);
|
12066
|
+
const stateLedgerIndex = StateHelpers.getHookStateIndex(this.registryAddress, hostAddrStatekey);
|
12067
|
+
const ledgerEntry = await this.xrplApi.getLedgerEntry(stateLedgerIndex);
|
12068
|
+
const curMomentStartIdx = await this.getMomentStartIndex();
|
12069
|
+
if (ledgerEntry?.HookStateData) {
|
12070
|
+
const hostAddrStateData = ledgerEntry.HookStateData;
|
12071
|
+
const hostInfo = StateHelpers.decodeHostAddressState(Buffer.from(hostAddrStatekey, 'hex'), Buffer.from(hostAddrStateData, 'hex'));
|
12072
|
+
hostInfo.active = (hostInfo.lastHeartbeatLedger > (this.config.hostHeartbeatFreq * this.config.momentSize) ?
|
12073
|
+
(hostInfo.lastHeartbeatLedger >= (curMomentStartIdx - (this.config.hostHeartbeatFreq * this.config.momentSize))) :
|
12074
|
+
(hostInfo.lastHeartbeatLedger > 0))
|
12075
|
+
return hostInfo;
|
12076
|
+
}
|
12077
|
+
}
|
12078
|
+
catch (e) {
|
12079
|
+
// If the exeption is entryNotFound from Rippled there's no entry for the host, So return null.
|
12080
|
+
if (e?.data?.error !== 'entryNotFound')
|
12081
|
+
throw e;
|
12075
12082
|
}
|
12076
12083
|
|
12077
12084
|
return null;
|
@@ -14798,7 +14805,7 @@ class XrplApi {
|
|
14798
14805
|
|
14799
14806
|
async getLedgerEntry(index, options) {
|
14800
14807
|
const resp = (await this.#client.request({ command: 'ledger_entry', index: index, ledger_index: "validated", ...options }));
|
14801
|
-
|
14808
|
+
return resp?.result?.node;
|
14802
14809
|
}
|
14803
14810
|
|
14804
14811
|
async submitAndVerify(tx, options) {
|