evernode-js-client 0.6.57 → 0.6.58
Sign up to get free protection for your applications and to get access to all the features.
package/index.js
CHANGED
@@ -9189,7 +9189,7 @@ module.exports = { mask, unmask };
|
|
9189
9189
|
|
9190
9190
|
|
9191
9191
|
try {
|
9192
|
-
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.
|
9192
|
+
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
|
9193
9193
|
} catch (e) {
|
9194
9194
|
module.exports = __nccwpck_require__(9467);
|
9195
9195
|
}
|
@@ -38321,7 +38321,7 @@ module.exports = isValidUTF8;
|
|
38321
38321
|
|
38322
38322
|
|
38323
38323
|
try {
|
38324
|
-
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.
|
38324
|
+
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.node");
|
38325
38325
|
} catch (e) {
|
38326
38326
|
module.exports = __nccwpck_require__(6982);
|
38327
38327
|
}
|
@@ -61103,11 +61103,8 @@ module.exports = {
|
|
61103
61103
|
/***/ 538:
|
61104
61104
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
61105
61105
|
|
61106
|
-
const codec = __nccwpck_require__(597);
|
61107
61106
|
const { StateHelpers } = __nccwpck_require__(3390);
|
61108
|
-
const { XrplAccount } = __nccwpck_require__(6099);
|
61109
61107
|
const { BaseEvernodeClient } = __nccwpck_require__(4438);
|
61110
|
-
const { ReputationConstants } = __nccwpck_require__(5732);
|
61111
61108
|
|
61112
61109
|
const ReputationEvents = {}
|
61113
61110
|
|
@@ -61645,58 +61642,43 @@ class HostClient extends BaseEvernodeClient {
|
|
61645
61642
|
|
61646
61643
|
/**
|
61647
61644
|
* Prepare host reputation score to a common format for submission.
|
61648
|
-
* @param {object} collectedScores
|
61649
|
-
* @returns Unified reputation score array.
|
61650
|
-
*/
|
61651
|
-
async prepareHostReputationScores(collectedScores = {}) {
|
61652
|
-
const myReputationInfo = await this.getReputationOrderByAddress(this.xrplAcc.address);
|
61653
|
-
if (!("orderedId" in (myReputationInfo ?? {})))
|
61654
|
-
return null;
|
61655
|
-
|
61656
|
-
const myOrderId = myReputationInfo.orderedId;
|
61657
|
-
|
61658
|
-
// Deciding universe.
|
61659
|
-
const universeStartIndex = Math.floor(myOrderId / 64) * 64;
|
61660
|
-
|
61661
|
-
const reputationClient = await HookClientFactory.create(HookTypes.reputation);
|
61662
|
-
await reputationClient.connect();
|
61663
|
-
let data = {};
|
61664
|
-
await Promise.all(Array.from({ length: 64 }, (_, i) => i + universeStartIndex).map(async (i) => {
|
61665
|
-
try {
|
61666
|
-
const hostReputationInfo = await reputationClient.getReputationContractInfoByOrderedId(i);
|
61667
|
-
if (!hostReputationInfo)
|
61668
|
-
throw 'No reputation info for this order id';
|
61669
|
-
data[i.toString()] = {
|
61670
|
-
publicKey: hostReputationInfo.contract?.pubkey ?? "-1",
|
61671
|
-
orderId: i
|
61672
|
-
};
|
61673
|
-
} catch (error) {
|
61674
|
-
data[i.toString()] = { publicKey: "-1", orderId: i };
|
61675
|
-
}
|
61676
|
-
}));
|
61677
|
-
await reputationClient.disconnect();
|
61678
|
-
|
61679
|
-
return Object.entries(data).map(e => ({
|
61680
|
-
...e[1],
|
61681
|
-
scoreValue: collectedScores[e[1]?.publicKey] || 0
|
61682
|
-
}));
|
61683
|
-
}
|
61684
|
-
|
61685
|
-
/**
|
61686
|
-
* Send reputation scores to the reputation hook.
|
61687
61645
|
* @param {number} scoreVersion Version of the scores.
|
61688
61646
|
* @param {number} clusterSize Size of the cluster.
|
61689
|
-
* @param {object}
|
61647
|
+
* @param {object} collectedScores [Optional] Score object in { host: score } format.
|
61648
|
+
* @returns Unified reputation score buffer.
|
61690
61649
|
*/
|
61691
|
-
async
|
61650
|
+
async prepareHostReputationScores(scoreVersion, clusterSize, collectedScores = null) {
|
61692
61651
|
let buffer = Buffer.alloc(1);
|
61693
|
-
if (
|
61694
|
-
const
|
61695
|
-
if (
|
61652
|
+
if (collectedScores) {
|
61653
|
+
const myReputationInfo = await this.getReputationOrderByAddress(this.xrplAcc.address);
|
61654
|
+
if (("orderedId" in (myReputationInfo ?? {}))) {
|
61655
|
+
const myOrderId = myReputationInfo.orderedId;
|
61656
|
+
|
61657
|
+
// Deciding universe.
|
61658
|
+
const universeStartIndex = Math.floor(myOrderId / 64) * 64;
|
61659
|
+
|
61660
|
+
const reputationClient = await HookClientFactory.create(HookTypes.reputation);
|
61661
|
+
await reputationClient.connect();
|
61662
|
+
let data = {};
|
61663
|
+
await Promise.all(Array.from({ length: 64 }, (_, i) => i + universeStartIndex).map(async (i) => {
|
61664
|
+
try {
|
61665
|
+
const hostReputationInfo = await reputationClient.getReputationContractInfoByOrderedId(i);
|
61666
|
+
if (!hostReputationInfo)
|
61667
|
+
throw 'No reputation info for this order id';
|
61668
|
+
data[i.toString()] = {
|
61669
|
+
publicKey: hostReputationInfo.contract?.pubkey ?? "-1",
|
61670
|
+
orderId: i
|
61671
|
+
};
|
61672
|
+
} catch (error) {
|
61673
|
+
data[i.toString()] = { publicKey: "-1", orderId: i };
|
61674
|
+
}
|
61675
|
+
}));
|
61676
|
+
await reputationClient.disconnect();
|
61677
|
+
|
61696
61678
|
buffer = Buffer.alloc(66, 0);
|
61697
61679
|
let i = 0;
|
61698
|
-
for (const
|
61699
|
-
buffer.writeUIntLE(Number(
|
61680
|
+
for (const e of Object.entries(data)) {
|
61681
|
+
buffer.writeUIntLE(Number(collectedScores[e[1]?.publicKey] || 0), i + 1, 1);
|
61700
61682
|
i++;
|
61701
61683
|
}
|
61702
61684
|
buffer.writeUIntLE(clusterSize, 65, 1);
|
@@ -61705,10 +61687,18 @@ class HostClient extends BaseEvernodeClient {
|
|
61705
61687
|
|
61706
61688
|
buffer.writeUIntLE(scoreVersion, 0, 1);
|
61707
61689
|
|
61690
|
+
return buffer;
|
61691
|
+
}
|
61692
|
+
|
61693
|
+
/**
|
61694
|
+
* Send reputation scores to the reputation hook.
|
61695
|
+
* @param {string} bufferHex Prepared score buffer as hex string.
|
61696
|
+
*/
|
61697
|
+
async sendReputations(bufferHex, options = {}) {
|
61708
61698
|
const paramData = codec.decodeAccountID(this.xrplAcc.address);
|
61709
61699
|
|
61710
61700
|
await this.reputationAcc.invoke(this.config.reputationAddress,
|
61711
|
-
|
61701
|
+
bufferHex ? { isHex: true, data: bufferHex } : null,
|
61712
61702
|
{
|
61713
61703
|
hookParams: [
|
61714
61704
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_SEND_REPUTATION },
|
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.58",
|
10
10
|
"dependencies": {
|
11
11
|
"elliptic": "6.5.4",
|
12
12
|
"libsodium-wrappers": "0.7.10",
|
Binary file
|
Binary file
|