evernode-js-client 0.6.21-definition-1.3 → 0.6.21-definition-1.5

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 {
@@ -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 = {
@@ -55580,6 +55632,7 @@ const HOST_LAST_VOTE_CANDIDATE_IDX_OFFSET = 112;
55580
55632
  const HOST_LAST_VOTE_TIMESTAMP_OFFSET = 116;
55581
55633
  const HOST_SUPPORT_VOTE_FLAG_OFFSET = 124;
55582
55634
  const HOST_REPUTATION_OFFSET = 125;
55635
+ const HOST_FLAGS_OFFSET = 125;
55583
55636
 
55584
55637
  const HOST_ADDRESS_OFFSET = 0;
55585
55638
  const HOST_CPU_MODEL_NAME_OFFSET = 20;
@@ -55631,6 +55684,10 @@ const TRANSFER_STATES = {
55631
55684
  HAS_A_TRANSFER: 1
55632
55685
  }
55633
55686
 
55687
+ const HOST_FLAGS = {
55688
+ REPUTED_ON_HEARTBEAT: 1
55689
+ }
55690
+
55634
55691
  const EVERNODE_PREFIX = 'EVR';
55635
55692
  const HOST_ADDR_KEY_ZERO_COUNT = 8;
55636
55693
  const TRANSFEREE_ADDR_KEY_ZERO_COUNT = 8;
@@ -55677,11 +55734,16 @@ class StateHelpers {
55677
55734
  isATransferer: (stateDataBuf.readUInt8(HOST_TRANSFER_FLAG_OFFSET) === PENDING_TRANSFER) ? TRANSFER_STATES.HAS_A_TRANSFER : TRANSFER_STATES.NO_TRANSFER,
55678
55735
  lastVoteCandidateIdx: stateDataBuf.readUInt32LE(HOST_LAST_VOTE_CANDIDATE_IDX_OFFSET),
55679
55736
  lastVoteTimestamp: Number(stateDataBuf.readBigUInt64LE(HOST_LAST_VOTE_TIMESTAMP_OFFSET)),
55680
- supportVoteSent: stateDataBuf.readUInt8(HOST_SUPPORT_VOTE_FLAG_OFFSET),
55681
- hostReputation: stateDataBuf.readUInt8(HOST_REPUTATION_OFFSET)
55737
+ supportVoteSent: stateDataBuf.readUInt8(HOST_SUPPORT_VOTE_FLAG_OFFSET)
55682
55738
  }
55683
55739
  if (stateDataBuf.length > HOST_REG_TIMESTAMP_OFFSET)
55684
55740
  data.registrationTimestamp = Number(stateDataBuf.readBigUInt64LE(HOST_REG_TIMESTAMP_OFFSET));
55741
+ if (stateDataBuf.length > HOST_REPUTATION_OFFSET)
55742
+ data.hostReputation = stateDataBuf.readUInt8(HOST_REPUTATION_OFFSET);
55743
+ if (stateDataBuf.length > HOST_FLAGS_OFFSET) {
55744
+ const flags = stateDataBuf.readUInt8(HOST_FLAGS_OFFSET);
55745
+ data.reputedOnHeartbeat = !!(flags & HOST_FLAGS.REPUTED_ON_HEARTBEAT);
55746
+ }
55685
55747
  return data;
55686
55748
  }
55687
55749
 
@@ -55870,17 +55932,20 @@ class StateHelpers {
55870
55932
  }
55871
55933
  }
55872
55934
  else if (Buffer.from(HookStateKeys.REWARD_CONFIGURATION, 'hex').compare(stateKey) === 0) {
55935
+ let value = {
55936
+ epochCount: stateData.readUInt8(EPOCH_COUNT_OFFSET),
55937
+ firstEpochRewardQuota: stateData.readUInt32LE(FIRST_EPOCH_REWARD_QUOTA_OFFSET),
55938
+ epochRewardAmount: stateData.readUInt32LE(EPOCH_REWARD_AMOUNT_OFFSET),
55939
+ rewardStartMoment: stateData.readUInt32LE(REWARD_START_MOMENT_OFFSET),
55940
+ accumulatedRewardFrequency: stateData.readUInt16LE(ACCUMULATED_REWARD_FREQUENCY_OFFSET),
55941
+ hostReputationThreshold: stateData.readUInt8(HOST_REPUTATION_THRESHOLD_OFFSET)
55942
+ };
55943
+ if (stateData.length > HOST_REPUTATION_THRESHOLD_OFFSET)
55944
+ value.hostReputationThreshold = stateData.readUInt8(HOST_REPUTATION_THRESHOLD_OFFSET);
55873
55945
  return {
55874
55946
  type: this.StateTypes.CONFIGURATION,
55875
55947
  key: hexKey,
55876
- value: {
55877
- epochCount: stateData.readUInt8(EPOCH_COUNT_OFFSET),
55878
- firstEpochRewardQuota: stateData.readUInt32LE(FIRST_EPOCH_REWARD_QUOTA_OFFSET),
55879
- epochRewardAmount: stateData.readUInt32LE(EPOCH_REWARD_AMOUNT_OFFSET),
55880
- rewardStartMoment: stateData.readUInt32LE(REWARD_START_MOMENT_OFFSET),
55881
- accumulatedRewardFrequency: stateData.readUInt16LE(ACCUMULATED_REWARD_FREQUENCY_OFFSET),
55882
- hostReputationThreshold: stateData.readUInt8(HOST_REPUTATION_THRESHOLD_OFFSET)
55883
- }
55948
+ value: value
55884
55949
  }
55885
55950
  }
55886
55951
  else if (Buffer.from(HookStateKeys.REWARD_INFO, 'hex').compare(stateKey) === 0) {
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.3",
9
+ "version": "0.6.21-definition-1.5",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",
Binary file
Binary file