evernode-js-client 0.6.54 → 0.6.55
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +20 -6
- package/package.json +1 -1
package/index.js
CHANGED
@@ -60617,7 +60617,9 @@ class BaseEvernodeClient {
|
|
60617
60617
|
const addrStateData = addrLedgerEntry?.HookStateData;
|
60618
60618
|
|
60619
60619
|
if (addrStateData) {
|
60620
|
-
|
60620
|
+
let addrStateDecoded = StateHelpers.decodeReputationHostAddressState(Buffer.from(addrStateKey, 'hex'), Buffer.from(addrStateData, 'hex'));
|
60621
|
+
const curMoment = await this.getMoment();
|
60622
|
+
addrStateDecoded.valid = !!(addrStateDecoded.lastScoredMoment && (curMoment - addrStateDecoded.lastScoredMoment) <= ReputationConstants.SCORE_EXPIRY_MOMENT_COUNT);
|
60621
60623
|
return addrStateDecoded;
|
60622
60624
|
}
|
60623
60625
|
}
|
@@ -61685,19 +61687,21 @@ class HostClient extends BaseEvernodeClient {
|
|
61685
61687
|
* @param {object} scores [Optional] Score object in { host: score } format.
|
61686
61688
|
*/
|
61687
61689
|
async sendReputations(scores = null, options = {}) {
|
61688
|
-
let buffer =
|
61690
|
+
let buffer = Buffer.alloc(1);
|
61689
61691
|
if (scores) {
|
61690
61692
|
const preparedScores = await this.prepareHostReputationScores(scores);
|
61691
61693
|
if (preparedScores) {
|
61692
|
-
buffer = Buffer.alloc(
|
61694
|
+
buffer = Buffer.alloc(65, 0);
|
61693
61695
|
let i = 0;
|
61694
61696
|
for (const reputationScore of preparedScores) {
|
61695
|
-
buffer.writeUIntLE(Number(reputationScore.scoreValue), i, 1);
|
61697
|
+
buffer.writeUIntLE(Number(reputationScore.scoreValue), i + 1, 1);
|
61696
61698
|
i++;
|
61697
61699
|
}
|
61698
61700
|
}
|
61699
61701
|
}
|
61700
61702
|
|
61703
|
+
buffer.writeUIntLE(ReputationConstants.SCORE_VERSION, 0, 1);
|
61704
|
+
|
61701
61705
|
const paramData = codec.decodeAccountID(this.xrplAcc.address);
|
61702
61706
|
|
61703
61707
|
await this.reputationAcc.invoke(this.config.reputationAddress,
|
@@ -63573,10 +63577,12 @@ const ErrorReasons = {
|
|
63573
63577
|
}
|
63574
63578
|
|
63575
63579
|
const ReputationConstants = {
|
63580
|
+
SCORE_VERSION: 1,
|
63576
63581
|
REP_INFO_BUFFER_SIZE: 43,
|
63577
63582
|
REP_INFO_PUBKEY_OFFSET: 0,
|
63578
63583
|
REP_INFO_PEER_PORT_OFFSET: 33,
|
63579
|
-
REP_INFO_MOMENT_OFFSET: 35
|
63584
|
+
REP_INFO_MOMENT_OFFSET: 35,
|
63585
|
+
SCORE_EXPIRY_MOMENT_COUNT: 2
|
63580
63586
|
}
|
63581
63587
|
|
63582
63588
|
// All keys are prefixed with 'EVR' (0x455652)
|
@@ -63965,6 +63971,10 @@ const HOST_ACCUMULATED_REWARD_OFFSET = 116;
|
|
63965
63971
|
const HOST_REP_LAST_REG_MOMENT_OFFSET = 0;
|
63966
63972
|
const HOST_REP_SCORE_NUMERATOR_OFFSET = 8;
|
63967
63973
|
const HOST_REP_SCORE_DENOMINATOR_OFFSET = 16;
|
63974
|
+
const HOST_REP_SCORE_OFFSET = 24;
|
63975
|
+
const HOST_REP_LAST_RESET_MOMENT_OFFSET = 32;
|
63976
|
+
const HOST_REP_LAST_SCORED_MOMENT_OFFSET = 40;
|
63977
|
+
const HOST_REP_LAST_UNIVERSE_SIZE_OFFSET = 48;
|
63968
63978
|
|
63969
63979
|
const PREV_HOST_ADDRESS_OFFSET = 0;
|
63970
63980
|
const TRANSFER_LEDGER_IDX_OFFSET = 20;
|
@@ -64054,7 +64064,11 @@ class StateHelpers {
|
|
64054
64064
|
hostAddress: codec.encodeAccountID(stateKeyBuf.slice(keyOffset)),
|
64055
64065
|
lastRegisteredMoment: Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_REG_MOMENT_OFFSET)),
|
64056
64066
|
scoreNumerator: Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_NUMERATOR_OFFSET)),
|
64057
|
-
scoreDenominator: Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_DENOMINATOR_OFFSET))
|
64067
|
+
scoreDenominator: Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_DENOMINATOR_OFFSET)),
|
64068
|
+
score: stateDataBuf.length > HOST_REP_SCORE_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_SCORE_OFFSET)) : null,
|
64069
|
+
lastResetMoment: stateDataBuf.length > HOST_REP_LAST_RESET_MOMENT_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_RESET_MOMENT_OFFSET)) : null,
|
64070
|
+
lastScoredMoment: stateDataBuf.length > HOST_REP_LAST_SCORED_MOMENT_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_SCORED_MOMENT_OFFSET)) : null,
|
64071
|
+
lastUniverseSize: stateDataBuf.length > HOST_REP_LAST_UNIVERSE_SIZE_OFFSET ? Number(stateDataBuf.readBigUInt64LE(HOST_REP_LAST_UNIVERSE_SIZE_OFFSET)) : null,
|
64058
64072
|
}
|
64059
64073
|
return data;
|
64060
64074
|
}
|
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.
|
9
|
+
"version": "0.6.55",
|
10
10
|
"dependencies": {
|
11
11
|
"elliptic": "6.5.4",
|
12
12
|
"libsodium-wrappers": "0.7.10",
|