evernode-js-client 0.6.21-definition-1.2 → 0.6.21-definition-1.4

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 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.napi1.node");
9152
+ module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.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.napi.node");
33343
+ module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
33344
33344
  } catch (e) {
33345
33345
  module.exports = __nccwpck_require__(9372);
33346
33346
  }
@@ -51849,6 +51849,9 @@ const CANDIDATE_PROPOSE_PARAM_SIZE = 250;
51849
51849
 
51850
51850
  const DUD_HOST_CANDID_ADDRESS_OFFSET = 12;
51851
51851
 
51852
+ const REPUTATION_HOST_ADDRESS_PARAM_OFFSET = 0;
51853
+ const REPUTATION_VALUE_PARAM_OFFSET = 20;
51854
+
51852
51855
  const MAX_HOOK_PARAM_SIZE = 128;
51853
51856
 
51854
51857
  class BaseEvernodeClient {
@@ -52426,6 +52429,18 @@ class BaseEvernodeClient {
52426
52429
  }
52427
52430
  }
52428
52431
  }
52432
+ else if (eventType === EventTypes.HOST_UPDATE_REPUTATION && eventData) {
52433
+ const dataBuf = Buffer.from(eventData, 'hex');
52434
+
52435
+ return {
52436
+ name: EvernodeEvents.HostReputationUpdated,
52437
+ data: {
52438
+ transaction: tx,
52439
+ host: codec.encodeAccountID(dataBuf.slice(REPUTATION_HOST_ADDRESS_PARAM_OFFSET, 20)),
52440
+ reputation: dataBuf.readUInt8(REPUTATION_VALUE_PARAM_OFFSET)
52441
+ }
52442
+ }
52443
+ }
52429
52444
 
52430
52445
  return null;
52431
52446
  }
@@ -52881,6 +52896,7 @@ module.exports = {
52881
52896
  /***/ 2466:
52882
52897
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
52883
52898
 
52899
+ const codec = __nccwpck_require__(597);
52884
52900
  const { Buffer } = __nccwpck_require__(4300);
52885
52901
  const { EventTypes, HookParamKeys } = __nccwpck_require__(9849);
52886
52902
  const { StateHelpers } = __nccwpck_require__(3860);
@@ -52891,6 +52907,10 @@ const CANDIDATE_VOTE_UNIQUE_ID_PARAM_OFFSET = 0;
52891
52907
  const CANDIDATE_VOTE_VALUE_PARAM_OFFSET = 32;
52892
52908
  const CANDIDATE_VOTE_PARAM_SIZE = 33;
52893
52909
 
52910
+ const REPUTATION_HOST_ADDRESS_PARAM_OFFSET = 0;
52911
+ const REPUTATION_VALUE_PARAM_OFFSET = 20;
52912
+ const REPUTATION_PARAM_SIZE = 21;
52913
+
52894
52914
  const FoundationEvents = {}
52895
52915
 
52896
52916
  class FoundationClient extends BaseEvernodeClient {
@@ -52939,7 +52959,7 @@ class FoundationClient extends BaseEvernodeClient {
52939
52959
 
52940
52960
  const voteBuf = Buffer.alloc(CANDIDATE_VOTE_PARAM_SIZE);
52941
52961
  Buffer.from(candidateId, 'hex').copy(voteBuf, CANDIDATE_VOTE_UNIQUE_ID_PARAM_OFFSET);
52942
- voteBuf.writeUInt8(vote, CANDIDATE_VOTE_VALUE_PARAM_OFFSET)
52962
+ voteBuf.writeUInt8(vote, CANDIDATE_VOTE_VALUE_PARAM_OFFSET);
52943
52963
 
52944
52964
  return await this.xrplAcc.makePayment(this.config.heartbeatAddress,
52945
52965
  XrplConstants.MIN_XRP_AMOUNT,
@@ -53023,6 +53043,35 @@ class FoundationClient extends BaseEvernodeClient {
53023
53043
  ...options.transactionOptions
53024
53044
  });
53025
53045
  }
53046
+
53047
+ /**
53048
+ * Update the reputation of the host.
53049
+ * @param {string} hostAddress Address of the dud host.
53050
+ * @param {number} reputation Host reputation value.
53051
+ * @param {*} options [Optional] transaction options.
53052
+ * @returns Transaction result.
53053
+ */
53054
+ async updateHostReputation(hostAddress, reputation, options = {}) {
53055
+ if (this.xrplAcc.address !== this.config.foundationAddress)
53056
+ throw `Invalid foundation address ${this.xrplAcc.address}.`;
53057
+
53058
+ const reputationBuf = Buffer.alloc(REPUTATION_PARAM_SIZE);
53059
+ codec.decodeAccountID(hostAddress).copy(reputationBuf, REPUTATION_HOST_ADDRESS_PARAM_OFFSET);
53060
+ reputationBuf.writeUInt8(reputation, REPUTATION_VALUE_PARAM_OFFSET)
53061
+
53062
+ return await this.xrplAcc.makePayment(this.config.registryAddress,
53063
+ XrplConstants.MIN_XRP_AMOUNT,
53064
+ XrplConstants.XRP,
53065
+ null,
53066
+ null,
53067
+ {
53068
+ hookParams: [
53069
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_UPDATE_REPUTATION },
53070
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: reputationBuf.toString('hex').toUpperCase() }
53071
+ ],
53072
+ ...options.transactionOptions
53073
+ });
53074
+ }
53026
53075
  }
53027
53076
 
53028
53077
  module.exports = {
@@ -53169,7 +53218,8 @@ const RegistryEvents = {
53169
53218
  HostRegUpdated: EvernodeEvents.HostRegUpdated,
53170
53219
  DeadHostPrune: EvernodeEvents.DeadHostPrune,
53171
53220
  HostTransfer: EvernodeEvents.HostTransfer,
53172
- HostRebate: EvernodeEvents.HostRebate
53221
+ HostRebate: EvernodeEvents.HostRebate,
53222
+ HostReputationUpdated: EvernodeEvents.HostReputationUpdated
53173
53223
  }
53174
53224
 
53175
53225
  class RegistryClient extends BaseEvernodeClient {
@@ -54359,8 +54409,6 @@ module.exports = {
54359
54409
 
54360
54410
  const DefinitionsPath = './resources/definitions.json';
54361
54411
 
54362
- const Definitions = __nccwpck_require__(4626);
54363
-
54364
54412
  const DefaultValues = {
54365
54413
  xrplApi: null,
54366
54414
  }
@@ -54383,10 +54431,12 @@ class Defaults {
54383
54431
  * @param {string} network Network to choose the info.
54384
54432
  */
54385
54433
  static useNetwork(network) {
54386
- if (!Definitions[network])
54434
+ const definitions = __nccwpck_require__(4626);
54435
+
54436
+ if (!definitions[network])
54387
54437
  throw `Invalid network: ${network}`;
54388
54438
 
54389
- this.set(Definitions[network]);
54439
+ this.set(definitions[network]);
54390
54440
  }
54391
54441
 
54392
54442
  /**
@@ -54902,7 +54952,8 @@ const EventTypes = {
54902
54952
  DUD_HOST_REPORT: 'evnDudHostReport',
54903
54953
  HOOK_UPDATE_RES: 'evnHookUpdateRes',
54904
54954
  GOVERNANCE_MODE_CHANGE: 'evnGovernanceModeChange',
54905
- LINKED_CANDIDATE_REMOVE: 'evnRemoveLinkedCandidate'
54955
+ LINKED_CANDIDATE_REMOVE: 'evnRemoveLinkedCandidate',
54956
+ HOST_UPDATE_REPUTATION: 'evnHostUpdateReputation'
54906
54957
  }
54907
54958
 
54908
54959
  const MemoFormats = {
@@ -55000,7 +55051,8 @@ const EvernodeEvents = {
55000
55051
  DudHostStatusChanged: "DudHostStatusChanged",
55001
55052
  FallbackToPiloted: "FallbackToPiloted",
55002
55053
  NewHookStatusChanged: "NewHookStatusChanged",
55003
- LinkedDudHostCandidateRemoved: "LinkedDudHostCandidateRemoved"
55054
+ LinkedDudHostCandidateRemoved: "LinkedDudHostCandidateRemoved",
55055
+ HostReputationUpdated: "HostReputationUpdated"
55004
55056
  }
55005
55057
 
55006
55058
  const URITokenTypes = {
@@ -55534,6 +55586,7 @@ const FIRST_EPOCH_REWARD_QUOTA_OFFSET = 1;
55534
55586
  const EPOCH_REWARD_AMOUNT_OFFSET = 5;
55535
55587
  const REWARD_START_MOMENT_OFFSET = 9;
55536
55588
  const ACCUMULATED_REWARD_FREQUENCY_OFFSET = 13;
55589
+ const HOST_REPUTATION_THRESHOLD_OFFSET = 15;
55537
55590
 
55538
55591
  const TRANSIT_IDX_OFFSET = 0;
55539
55592
  const TRANSIT_MOMENT_SIZE_OFFSET = 8;
@@ -55578,6 +55631,7 @@ const HOST_TRANSFER_FLAG_OFFSET = 111;
55578
55631
  const HOST_LAST_VOTE_CANDIDATE_IDX_OFFSET = 112;
55579
55632
  const HOST_LAST_VOTE_TIMESTAMP_OFFSET = 116;
55580
55633
  const HOST_SUPPORT_VOTE_FLAG_OFFSET = 124;
55634
+ const HOST_REPUTATION_OFFSET = 125;
55581
55635
 
55582
55636
  const HOST_ADDRESS_OFFSET = 0;
55583
55637
  const HOST_CPU_MODEL_NAME_OFFSET = 20;
@@ -55675,7 +55729,8 @@ class StateHelpers {
55675
55729
  isATransferer: (stateDataBuf.readUInt8(HOST_TRANSFER_FLAG_OFFSET) === PENDING_TRANSFER) ? TRANSFER_STATES.HAS_A_TRANSFER : TRANSFER_STATES.NO_TRANSFER,
55676
55730
  lastVoteCandidateIdx: stateDataBuf.readUInt32LE(HOST_LAST_VOTE_CANDIDATE_IDX_OFFSET),
55677
55731
  lastVoteTimestamp: Number(stateDataBuf.readBigUInt64LE(HOST_LAST_VOTE_TIMESTAMP_OFFSET)),
55678
- supportVoteSent: stateDataBuf.readUInt8(HOST_SUPPORT_VOTE_FLAG_OFFSET)
55732
+ supportVoteSent: stateDataBuf.readUInt8(HOST_SUPPORT_VOTE_FLAG_OFFSET),
55733
+ hostReputation: stateDataBuf.readUInt8(HOST_REPUTATION_OFFSET)
55679
55734
  }
55680
55735
  if (stateDataBuf.length > HOST_REG_TIMESTAMP_OFFSET)
55681
55736
  data.registrationTimestamp = Number(stateDataBuf.readBigUInt64LE(HOST_REG_TIMESTAMP_OFFSET));
@@ -55875,7 +55930,8 @@ class StateHelpers {
55875
55930
  firstEpochRewardQuota: stateData.readUInt32LE(FIRST_EPOCH_REWARD_QUOTA_OFFSET),
55876
55931
  epochRewardAmount: stateData.readUInt32LE(EPOCH_REWARD_AMOUNT_OFFSET),
55877
55932
  rewardStartMoment: stateData.readUInt32LE(REWARD_START_MOMENT_OFFSET),
55878
- accumulatedRewardFrequency: stateData.readUInt16LE(ACCUMULATED_REWARD_FREQUENCY_OFFSET)
55933
+ accumulatedRewardFrequency: stateData.readUInt16LE(ACCUMULATED_REWARD_FREQUENCY_OFFSET),
55934
+ hostReputationThreshold: stateData.readUInt8(HOST_REPUTATION_THRESHOLD_OFFSET)
55879
55935
  }
55880
55936
  }
55881
55937
  }
@@ -57300,7 +57356,7 @@ class XrplApi {
57300
57356
  #xrplClientOptions;
57301
57357
  #autoReconnect;
57302
57358
 
57303
- constructor(rippledServer = '-', options = {}) {
57359
+ constructor(rippledServer = null, options = {}) {
57304
57360
  if (rippledServer == '-') {
57305
57361
  this.#primaryServer = null;
57306
57362
  } else {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  ],
7
7
  "homepage": "https://github.com/HotPocketDev/evernode-js-client",
8
8
  "license": "MIT",
9
- "version": "0.6.21-definition-1.2",
9
+ "version": "0.6.21-definition-1.4",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",
Binary file
Binary file