evernode-js-client 0.5.17-beta-v3.4 → 0.5.17-beta-v3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +377 -244
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -11725,7 +11725,7 @@ const { Buffer } = __nccwpck_require__(4300);
11725
11725
  const { XrplApi } = __nccwpck_require__(1850);
11726
11726
  const { XrplAccount } = __nccwpck_require__(9329);
11727
11727
  const { XrplApiEvents, XrplConstants } = __nccwpck_require__(3307);
11728
- const { EvernodeEvents, MemoTypes, MemoFormats, EvernodeConstants, HookStateKeys } = __nccwpck_require__(9849);
11728
+ const { EvernodeEvents, EventTypes, MemoFormats, EvernodeConstants, HookStateKeys, HookParamKeys } = __nccwpck_require__(9849);
11729
11729
  const { DefaultValues } = __nccwpck_require__(8262);
11730
11730
  const { EncryptionHelper } = __nccwpck_require__(4832);
11731
11731
  const { EventEmitter } = __nccwpck_require__(6170);
@@ -11735,13 +11735,16 @@ const { StateHelpers } = __nccwpck_require__(3860);
11735
11735
  const { EvernodeHelpers } = __nccwpck_require__(2523);
11736
11736
  const { HookHelpers } = __nccwpck_require__(4675);
11737
11737
 
11738
- const CANDIDATE_PROPOSE_UNIQUE_ID_MEMO_OFFSET = 0;
11739
- const CANDIDATE_PROPOSE_SHORT_NAME_MEMO_OFFSET = 32;
11740
- const CANDIDATE_PROPOSE_KEYLETS_MEMO_OFFSET = 52;
11741
- const CANDIDATE_PROPOSE_MEMO_SIZE = 154;
11738
+ const CANDIDATE_PROPOSE_HASHES_PARAM_OFFSET = 0;
11739
+ const CANDIDATE_PROPOSE_KEYLETS_PARAM_OFFSET = 96;
11740
+ const CANDIDATE_PROPOSE_UNIQUE_ID_PARAM_OFFSET = 198;
11741
+ const CANDIDATE_PROPOSE_SHORT_NAME_PARAM_OFFSET = 230;
11742
+ const CANDIDATE_PROPOSE_PARAM_SIZE = 250;
11742
11743
 
11743
11744
  const DUD_HOST_CANDID_ADDRESS_OFFSET = 12;
11744
11745
 
11746
+ const MAX_HOOK_PARAM_SIZE = 128;
11747
+
11745
11748
  class BaseEvernodeClient {
11746
11749
 
11747
11750
  #watchEvents;
@@ -11959,11 +11962,18 @@ class BaseEvernodeClient {
11959
11962
  /**
11960
11963
  * Extracts the transaction info from a given transaction.
11961
11964
  * @param {object} tx Transaction to be deserialized and extracted.
11962
- * @returns The event object in the format {name: '', data: {}}. Returns null if not handled. Note: You need to deserialize memos before passing the transaction to this function.
11965
+ * @returns The event object in the format {name: '', data: {}}. Returns null if not handled. Note: You need to deserialize HookParameters before passing the transaction to this function.
11963
11966
  */
11964
11967
  async extractEvernodeEvent(tx) {
11965
- if (tx.TransactionType === 'URITokenBuy' && tx.Memos.length >= 1 &&
11966
- tx.Memos[0].type === MemoTypes.ACQUIRE_LEASE && tx.Memos[0].format === MemoFormats.BASE64 && tx.Memos[0].data) {
11968
+ let eventType;
11969
+ let eventData;
11970
+ if (tx.HookParameters.length) {
11971
+ eventType = tx.HookParameters.find(p => p.name === HookParamKeys.PARAM_EVENT_TYPE_KEY)?.value;
11972
+ eventData = tx.HookParameters.find(p => p.name === HookParamKeys.PARAM_EVENT_DATA1_KEY)?.value;
11973
+ eventData += tx.HookParameters.find(p => p.name === HookParamKeys.PARAM_EVENT_DATA2_KEY)?.value ?? '';
11974
+ }
11975
+ if (tx.TransactionType === 'URITokenBuy' && eventType === EventTypes.ACQUIRE_LEASE && tx.Memos.length &&
11976
+ tx.Memos[0].type === EventTypes.ACQUIRE_LEASE && tx.Memos[0].format === MemoFormats.BASE64 && tx.Memos[0].data) {
11967
11977
 
11968
11978
  // If our account is the destination host account, then decrypt the payload.
11969
11979
  let payload = tx.Memos[0].data;
@@ -11989,12 +11999,11 @@ class BaseEvernodeClient {
11989
11999
  }
11990
12000
  }
11991
12001
 
11992
- else if (tx.Memos.length >= 2 &&
11993
- tx.Memos[0].type === MemoTypes.ACQUIRE_SUCCESS && tx.Memos[0].data &&
11994
- tx.Memos[1].type === MemoTypes.ACQUIRE_REF && tx.Memos[1].data) {
12002
+ else if (eventType === EventTypes.ACQUIRE_SUCCESS && eventData && tx.Memos.length &&
12003
+ tx.Memos[0].type === EventTypes.ACQUIRE_SUCCESS && tx.Memos[0].data) {
11995
12004
 
11996
12005
  let payload = tx.Memos[0].data;
11997
- const acquireRefId = tx.Memos[1].data;
12006
+ const acquireRefId = eventData;
11998
12007
 
11999
12008
  // If our account is the destination user account, then decrypt the payload.
12000
12009
  if (tx.Memos[0].format === MemoFormats.BASE64 && tx.Destination === this.xrplAcc.address) {
@@ -12015,12 +12024,11 @@ class BaseEvernodeClient {
12015
12024
  }
12016
12025
 
12017
12026
  }
12018
- else if (tx.Memos.length >= 2 &&
12019
- tx.Memos[0].type === MemoTypes.ACQUIRE_ERROR && tx.Memos[0].data &&
12020
- tx.Memos[1].type === MemoTypes.ACQUIRE_REF && tx.Memos[1].data) {
12027
+ else if (eventType === EventTypes.ACQUIRE_ERROR && eventData && tx.Memos.length &&
12028
+ tx.Memos[0].type === EventTypes.ACQUIRE_ERROR && tx.Memos[0].data) {
12021
12029
 
12022
12030
  let error = tx.Memos[0].data;
12023
- const acquireRefId = tx.Memos[1].data;
12031
+ const acquireRefId = eventData;
12024
12032
 
12025
12033
  if (tx.Memos[0].format === MemoFormats.JSON)
12026
12034
  error = JSON.parse(error).reason;
@@ -12034,8 +12042,7 @@ class BaseEvernodeClient {
12034
12042
  }
12035
12043
  }
12036
12044
  }
12037
- else if (tx.Memos.length >= 1 &&
12038
- tx.Memos[0].type === MemoTypes.HOST_REG && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12045
+ else if (eventType === EventTypes.HOST_REG && eventData) {
12039
12046
 
12040
12047
  return {
12041
12048
  name: EvernodeEvents.HostRegistered,
@@ -12045,7 +12052,7 @@ class BaseEvernodeClient {
12045
12052
  }
12046
12053
  }
12047
12054
  }
12048
- else if (tx.Memos.length >= 1 && tx.Memos[0].type === MemoTypes.HOST_DEREG) {
12055
+ else if (eventType === EventTypes.HOST_DEREG && eventData) {
12049
12056
  return {
12050
12057
  name: EvernodeEvents.HostDeregistered,
12051
12058
  data: {
@@ -12054,14 +12061,13 @@ class BaseEvernodeClient {
12054
12061
  }
12055
12062
  }
12056
12063
  }
12057
- else if (tx.Memos.length >= 1 &&
12058
- tx.Memos[0].type === MemoTypes.HEARTBEAT) {
12064
+ else if (eventType === EventTypes.HEARTBEAT) {
12059
12065
 
12060
- const voteInfo = (tx.Memos[0].data && tx.Memos[0].data.length) ?
12066
+ const voteInfo = (eventData && eventData.length) ?
12061
12067
  {
12062
12068
  voteInfo: {
12063
- candidateId: tx.Memos[0].data.substr(0, 64),
12064
- vote: Buffer.from(tx.Memos[0].data, 'hex').slice(32, 33).readUInt8()
12069
+ candidateId: eventData.substr(0, 64),
12070
+ vote: Buffer.from(eventData, 'hex').slice(32, 33).readUInt8()
12065
12071
  }
12066
12072
  } : {};
12067
12073
 
@@ -12074,10 +12080,9 @@ class BaseEvernodeClient {
12074
12080
  }
12075
12081
  }
12076
12082
  }
12077
- else if (tx.Memos.length >= 1 &&
12078
- tx.Memos[0].type === MemoTypes.EXTEND_LEASE && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12083
+ else if (eventType === EventTypes.EXTEND_LEASE && eventData) {
12079
12084
 
12080
- let uriTokenId = tx.Memos[0].data;
12085
+ let uriTokenId = eventData;
12081
12086
 
12082
12087
  return {
12083
12088
  name: EvernodeEvents.ExtendLease,
@@ -12091,12 +12096,11 @@ class BaseEvernodeClient {
12091
12096
  }
12092
12097
  }
12093
12098
  }
12094
- else if (tx.Memos.length >= 2 &&
12095
- tx.Memos[0].type === MemoTypes.EXTEND_SUCCESS && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data &&
12096
- tx.Memos[1].type === MemoTypes.EXTEND_REF && tx.Memos[1].format === MemoFormats.HEX && tx.Memos[1].data) {
12099
+ else if (eventType === EventTypes.EXTEND_SUCCESS && eventData && tx.Memos.length &&
12100
+ tx.Memos[0].type === EventTypes.EXTEND_SUCCESS && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12097
12101
 
12098
12102
  const extendResBuf = Buffer.from(tx.Memos[0].data, 'hex');
12099
- const extendRefId = tx.Memos[1].data;
12103
+ const extendRefId = eventData;
12100
12104
 
12101
12105
  return {
12102
12106
  name: EvernodeEvents.ExtendSuccess,
@@ -12108,12 +12112,11 @@ class BaseEvernodeClient {
12108
12112
  }
12109
12113
 
12110
12114
  }
12111
- else if (tx.Memos.length >= 2 &&
12112
- tx.Memos[0].type === MemoTypes.EXTEND_ERROR && tx.Memos[0].data &&
12113
- tx.Memos[1].type === MemoTypes.EXTEND_REF && tx.Memos[1].data) {
12115
+ else if (eventType === EventTypes.EXTEND_ERROR && eventData && tx.Memos.length &&
12116
+ tx.Memos[0].type === EventTypes.EXTEND_ERROR && tx.Memos[0].data) {
12114
12117
 
12115
12118
  let error = tx.Memos[0].data;
12116
- const extendRefId = tx.Memos[1].data;
12119
+ const extendRefId = eventData;
12117
12120
 
12118
12121
  if (tx.Memos[0].format === MemoFormats.JSON)
12119
12122
  error = JSON.parse(error).reason;
@@ -12127,8 +12130,7 @@ class BaseEvernodeClient {
12127
12130
  }
12128
12131
  }
12129
12132
  }
12130
- else if (tx.Memos.length >= 1 &&
12131
- tx.Memos[0].type === MemoTypes.INIT && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12133
+ else if (eventType === EventTypes.INIT && eventData) {
12132
12134
 
12133
12135
  return {
12134
12136
  name: EvernodeEvents.Initialized,
@@ -12137,8 +12139,7 @@ class BaseEvernodeClient {
12137
12139
  }
12138
12140
  }
12139
12141
  }
12140
- else if (tx.Memos.length >= 1 &&
12141
- tx.Memos[0].type === MemoTypes.HOST_UPDATE_INFO && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12142
+ else if (eventType === EventTypes.HOST_UPDATE_INFO && eventData) {
12142
12143
 
12143
12144
  return {
12144
12145
  name: EvernodeEvents.HostRegUpdated,
@@ -12148,10 +12149,9 @@ class BaseEvernodeClient {
12148
12149
  }
12149
12150
  }
12150
12151
  }
12151
- else if (tx.Memos.length >= 1 &&
12152
- tx.Memos[0].type === MemoTypes.DEAD_HOST_PRUNE && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12152
+ else if (eventType === EventTypes.DEAD_HOST_PRUNE && eventData) {
12153
12153
 
12154
- const addrsBuf = Buffer.from(tx.Memos[0].data, 'hex');
12154
+ const addrsBuf = Buffer.from(eventData, 'hex');
12155
12155
 
12156
12156
  return {
12157
12157
  name: EvernodeEvents.DeadHostPrune,
@@ -12161,8 +12161,7 @@ class BaseEvernodeClient {
12161
12161
  }
12162
12162
  }
12163
12163
  }
12164
- else if (tx.Memos.length >= 1 &&
12165
- tx.Memos[0].type === MemoTypes.HOST_REBATE) {
12164
+ else if (eventType === EventTypes.HOST_REBATE) {
12166
12165
 
12167
12166
  return {
12168
12167
  name: EvernodeEvents.HostRebate,
@@ -12172,10 +12171,9 @@ class BaseEvernodeClient {
12172
12171
  }
12173
12172
  }
12174
12173
  }
12175
- else if (tx.Memos.length >= 1 &&
12176
- tx.Memos[0].type === MemoTypes.HOST_TRANSFER && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12174
+ else if (eventType === EventTypes.HOST_TRANSFER && eventData) {
12177
12175
 
12178
- const addrsBuf = Buffer.from(tx.Memos[0].data, 'hex');
12176
+ const addrsBuf = Buffer.from(eventData, 'hex');
12179
12177
 
12180
12178
  return {
12181
12179
  name: EvernodeEvents.HostTransfer,
@@ -12185,40 +12183,36 @@ class BaseEvernodeClient {
12185
12183
  }
12186
12184
  }
12187
12185
  }
12188
- else if (tx.Memos.length >= 2 &&
12189
- tx.Memos[0].type === MemoTypes.CANDIDATE_PROPOSE && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data &&
12190
- tx.Memos[1].type === MemoTypes.CANDIDATE_PROPOSE_REF && tx.Memos[1].format === MemoFormats.HEX && tx.Memos[1].data) {
12186
+ else if (eventType === EventTypes.CANDIDATE_PROPOSE && eventData) {
12191
12187
 
12192
12188
  return {
12193
12189
  name: EvernodeEvents.CandidateProposed,
12194
12190
  data: {
12195
12191
  transaction: tx,
12196
12192
  owner: tx.Account,
12197
- candidateId: tx.Memos[1].data.substr(0, 64)
12193
+ candidateId: eventData.substr(CANDIDATE_PROPOSE_UNIQUE_ID_PARAM_OFFSET * 2, 64)
12198
12194
  }
12199
12195
  }
12200
12196
  }
12201
- else if (tx.Memos.length >= 1 &&
12202
- tx.Memos[0].type === MemoTypes.CANDIDATE_WITHDRAW && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12197
+ else if (eventType === EventTypes.CANDIDATE_WITHDRAW && eventData) {
12203
12198
  return {
12204
12199
  name: EvernodeEvents.CandidateWithdrew,
12205
12200
  data: {
12206
12201
  transaction: tx,
12207
12202
  owner: tx.Account,
12208
- candidateId: tx.Memos[0].data.substr(0, 64)
12203
+ candidateId: eventData.substr(0, 64)
12209
12204
  }
12210
12205
  }
12211
12206
  }
12212
- else if (tx.Memos.length >= 1 &&
12213
- tx.Memos[0].type === MemoTypes.CANDIDATE_STATUS_CHANGE && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12214
- const memoBuf = Buffer.from(tx.Memos[0].data, 'hex');
12215
- const candidateId = memoBuf.slice(0, 32).toString('hex');
12207
+ else if (eventType === EventTypes.CANDIDATE_STATUS_CHANGE && eventData) {
12208
+ const eventDataBuf = Buffer.from(eventData, 'hex');
12209
+ const candidateId = eventDataBuf.slice(0, 32).toString('hex');
12216
12210
  const candidateType = StateHelpers.getCandidateType(candidateId);
12217
12211
 
12218
12212
  switch (candidateType) {
12219
12213
  case (EvernodeConstants.CandidateTypes.DudHost):
12220
12214
  return {
12221
- name: memoBuf.readUInt8(32) === EvernodeConstants.CandidateStatuses.CANDIDATE_ELECTED ? EvernodeEvents.DudHostRemoved : EvernodeEvents.DudHostStatusChanged,
12215
+ name: eventDataBuf.readUInt8(32) === EvernodeConstants.CandidateStatuses.CANDIDATE_ELECTED ? EvernodeEvents.DudHostRemoved : EvernodeEvents.DudHostStatusChanged,
12222
12216
  data: {
12223
12217
  transaction: tx,
12224
12218
  candidateId: candidateId,
@@ -12246,20 +12240,18 @@ class BaseEvernodeClient {
12246
12240
  }
12247
12241
 
12248
12242
  }
12249
- else if (tx.Memos.length >= 1 &&
12250
- tx.Memos[0].type === MemoTypes.HOOK_UPDATE_RES && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12243
+ else if (eventType === EventTypes.HOOK_UPDATE_RES && eventData) {
12251
12244
  return {
12252
12245
  name: EvernodeEvents.ChildHookUpdated,
12253
12246
  data: {
12254
12247
  transaction: tx,
12255
12248
  account: tx.Account,
12256
- candidateId: tx.Memos[0].data.substr(0, 64)
12249
+ candidateId: eventData.substr(0, 64)
12257
12250
  }
12258
12251
  }
12259
12252
  }
12260
- else if (tx.Memos.length >= 1 &&
12261
- tx.Memos[0].type === MemoTypes.GOVERNANCE_MODE_CHANGE && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12262
- const mode = Buffer.from(tx.Memos[0].data, 'hex').slice(0, 1).readUInt8();
12253
+ else if (eventType === EventTypes.GOVERNANCE_MODE_CHANGE && eventData) {
12254
+ const mode = Buffer.from(eventData, 'hex').slice(0, 1).readUInt8();
12263
12255
 
12264
12256
  return {
12265
12257
  name: EvernodeEvents.GovernanceModeChanged,
@@ -12269,22 +12261,20 @@ class BaseEvernodeClient {
12269
12261
  }
12270
12262
  }
12271
12263
  }
12272
- else if (tx.Memos.length >= 1 &&
12273
- tx.Memos[0].type === MemoTypes.CANDIDATE_VOTE && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12274
- const vote = Buffer.from(tx.Memos[0].data, 'hex').slice(32, 33).readUInt8();
12264
+ else if (eventType === EventTypes.CANDIDATE_VOTE && eventData) {
12265
+ const vote = Buffer.from(eventData, 'hex').slice(32, 33).readUInt8();
12275
12266
 
12276
12267
  return {
12277
12268
  name: EvernodeEvents.FoundationVoted,
12278
12269
  data: {
12279
12270
  transaction: tx,
12280
- candidateId: tx.Memos[0].data.substr(0, 64),
12271
+ candidateId: eventData.substr(0, 64),
12281
12272
  vote: vote
12282
12273
  }
12283
12274
  }
12284
12275
  }
12285
- else if (tx.Memos.length >= 1 &&
12286
- tx.Memos[0].type === MemoTypes.DUD_HOST_REPORT && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
12287
- const candidateId = tx.Memos[0].data.substr(0, 64);
12276
+ else if (eventType === EventTypes.DUD_HOST_REPORT && eventData) {
12277
+ const candidateId = eventData.substr(0, 64);
12288
12278
 
12289
12279
  return {
12290
12280
  name: EvernodeEvents.DudHostReported,
@@ -12449,8 +12439,8 @@ class BaseEvernodeClient {
12449
12439
  if (this.xrplAcc.address === this.config.registryAddress)
12450
12440
  throw 'Invalid function call';
12451
12441
 
12452
- let memoData = Buffer.allocUnsafe(20);
12453
- codec.decodeAccountID(hostAddress).copy(memoData);
12442
+ let paramData = Buffer.allocUnsafe(20);
12443
+ codec.decodeAccountID(hostAddress).copy(paramData);
12454
12444
 
12455
12445
  // To obtain registration NFT Page Keylet and index.
12456
12446
  const hostAcc = new XrplAccount(hostAddress, null, { xrplApi: this.xrplApi });
@@ -12460,9 +12450,13 @@ class BaseEvernodeClient {
12460
12450
  XrplConstants.MIN_XRP_AMOUNT,
12461
12451
  XrplConstants.XRP,
12462
12452
  null,
12463
- [
12464
- { type: MemoTypes.DEAD_HOST_PRUNE, format: MemoFormats.HEX, data: memoData.toString('hex') }
12465
- ]);
12453
+ null,
12454
+ {
12455
+ hookParams: [
12456
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.DEAD_HOST_PRUNE },
12457
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramData.toString('hex') }
12458
+ ]
12459
+ });
12466
12460
  } else
12467
12461
  throw "No Registration URI token was found for the Host account."
12468
12462
 
@@ -12615,10 +12609,11 @@ class BaseEvernodeClient {
12615
12609
  }
12616
12610
 
12617
12611
  const uniqueId = StateHelpers.getNewHookCandidateId(hashesBuf);
12618
- const memoBuf = Buffer.alloc(CANDIDATE_PROPOSE_MEMO_SIZE);
12619
- Buffer.from(uniqueId, 'hex').copy(memoBuf, CANDIDATE_PROPOSE_UNIQUE_ID_MEMO_OFFSET);
12620
- Buffer.from(shortName.substr(0, 20), "utf-8").copy(memoBuf, CANDIDATE_PROPOSE_SHORT_NAME_MEMO_OFFSET);
12621
- Buffer.from(keylets.join(''), 'hex').copy(memoBuf, CANDIDATE_PROPOSE_KEYLETS_MEMO_OFFSET);
12612
+ const paramBuf = Buffer.alloc(CANDIDATE_PROPOSE_PARAM_SIZE);
12613
+ hashesBuf.copy(paramBuf, CANDIDATE_PROPOSE_HASHES_PARAM_OFFSET);
12614
+ Buffer.from(keylets.join(''), 'hex').copy(paramBuf, CANDIDATE_PROPOSE_KEYLETS_PARAM_OFFSET);
12615
+ Buffer.from(uniqueId, 'hex').copy(paramBuf, CANDIDATE_PROPOSE_UNIQUE_ID_PARAM_OFFSET);
12616
+ Buffer.from(shortName.substr(0, 20), "utf-8").copy(paramBuf, CANDIDATE_PROPOSE_SHORT_NAME_PARAM_OFFSET);
12622
12617
 
12623
12618
  // Get the proposal fee. Proposal fee is current epochs moment worth of rewards.
12624
12619
  const proposalFee = EvernodeHelpers.getEpochRewardQuota(this.config.rewardInfo.epoch, this.config.rewardConfiguration.firstEpochRewardQuota);
@@ -12627,11 +12622,15 @@ class BaseEvernodeClient {
12627
12622
  proposalFee.toString(),
12628
12623
  EvernodeConstants.EVR,
12629
12624
  this.config.evrIssuerAddress,
12630
- [
12631
- { type: MemoTypes.CANDIDATE_PROPOSE, format: MemoFormats.HEX, data: hashesBuf.toString('hex').toUpperCase() },
12632
- { type: MemoTypes.CANDIDATE_PROPOSE_REF, format: MemoFormats.HEX, data: memoBuf.toString('hex').toUpperCase() }
12633
- ],
12634
- options.transactionOptions);
12625
+ null,
12626
+ {
12627
+ hookParams: [
12628
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.CANDIDATE_PROPOSE },
12629
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.slice(0, MAX_HOOK_PARAM_SIZE).toString('hex').toUpperCase() },
12630
+ { name: HookParamKeys.PARAM_EVENT_DATA2_KEY, value: paramBuf.slice(MAX_HOOK_PARAM_SIZE).toString('hex').toUpperCase() }
12631
+ ],
12632
+ ...options.transactionOptions
12633
+ });
12635
12634
 
12636
12635
  return uniqueId;
12637
12636
  }
@@ -12648,10 +12647,14 @@ class BaseEvernodeClient {
12648
12647
  XrplConstants.MIN_XRP_AMOUNT,
12649
12648
  XrplConstants.XRP,
12650
12649
  null,
12651
- [
12652
- { type: MemoTypes.CANDIDATE_WITHDRAW, format: MemoFormats.HEX, data: candidateIdBuf.toString('hex').toUpperCase() }
12653
- ],
12654
- options.transactionOptions);
12650
+ null,
12651
+ {
12652
+ hookParams: [
12653
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.CANDIDATE_WITHDRAW },
12654
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: candidateIdBuf.toString('hex').toUpperCase() }
12655
+ ],
12656
+ ...options.transactionOptions
12657
+ });
12655
12658
  }
12656
12659
 
12657
12660
  /**
@@ -12670,10 +12673,14 @@ class BaseEvernodeClient {
12670
12673
  proposalFee.toString(),
12671
12674
  EvernodeConstants.EVR,
12672
12675
  this.config.evrIssuerAddress,
12673
- [
12674
- { type: MemoTypes.DUD_HOST_REPORT, format: MemoFormats.HEX, data: candidateId }
12675
- ],
12676
- options.transactionOptions);
12676
+ null,
12677
+ {
12678
+ hookParams: [
12679
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.DUD_HOST_REPORT },
12680
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: candidateId }
12681
+ ],
12682
+ ...options.transactionOptions
12683
+ });
12677
12684
  }
12678
12685
  }
12679
12686
 
@@ -12688,14 +12695,14 @@ module.exports = {
12688
12695
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
12689
12696
 
12690
12697
  const { Buffer } = __nccwpck_require__(4300);
12691
- const { MemoTypes, MemoFormats } = __nccwpck_require__(9849);
12698
+ const { EventTypes, HookParamKeys } = __nccwpck_require__(9849);
12692
12699
  const { StateHelpers } = __nccwpck_require__(3860);
12693
12700
  const { XrplConstants } = __nccwpck_require__(3307);
12694
12701
  const { BaseEvernodeClient } = __nccwpck_require__(6263);
12695
12702
 
12696
- const CANDIDATE_VOTE_UNIQUE_ID_MEMO_OFFSET = 0;
12697
- const CANDIDATE_VOTE_VALUE_MEMO_OFFSET = 32;
12698
- const CANDIDATE_VOTE_MEMO_SIZE = 33;
12703
+ const CANDIDATE_VOTE_UNIQUE_ID_PARAM_OFFSET = 0;
12704
+ const CANDIDATE_VOTE_VALUE_PARAM_OFFSET = 32;
12705
+ const CANDIDATE_VOTE_PARAM_SIZE = 33;
12699
12706
 
12700
12707
  const FoundationEvents = {}
12701
12708
 
@@ -12736,18 +12743,22 @@ class FoundationClient extends BaseEvernodeClient {
12736
12743
  if (this.xrplAcc.address !== this.config.foundationAddress)
12737
12744
  throw `Invalid foundation address ${this.xrplAcc.address}.`;
12738
12745
 
12739
- const voteBuf = Buffer.alloc(CANDIDATE_VOTE_MEMO_SIZE);
12740
- Buffer.from(candidateId, 'hex').copy(voteBuf, CANDIDATE_VOTE_UNIQUE_ID_MEMO_OFFSET);
12741
- voteBuf.writeUInt8(vote, CANDIDATE_VOTE_VALUE_MEMO_OFFSET)
12746
+ const voteBuf = Buffer.alloc(CANDIDATE_VOTE_PARAM_SIZE);
12747
+ Buffer.from(candidateId, 'hex').copy(voteBuf, CANDIDATE_VOTE_UNIQUE_ID_PARAM_OFFSET);
12748
+ voteBuf.writeUInt8(vote, CANDIDATE_VOTE_VALUE_PARAM_OFFSET)
12742
12749
 
12743
12750
  return await this.xrplAcc.makePayment(this.config.heartbeatAddress,
12744
12751
  XrplConstants.MIN_XRP_AMOUNT,
12745
12752
  XrplConstants.XRP,
12746
12753
  null,
12747
- [
12748
- { type: MemoTypes.CANDIDATE_VOTE, format: MemoFormats.HEX, data: voteBuf.toString('hex').toUpperCase() }
12749
- ],
12750
- options.transactionOptions);
12754
+ null,
12755
+ {
12756
+ hookParams: [
12757
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.CANDIDATE_VOTE },
12758
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: voteBuf.toString('hex').toUpperCase() }
12759
+ ],
12760
+ ...options.transactionOptions
12761
+ });
12751
12762
  }
12752
12763
 
12753
12764
  async reportDudHost(hostAddress, options = {}) {
@@ -12803,10 +12814,14 @@ class FoundationClient extends BaseEvernodeClient {
12803
12814
  XrplConstants.MIN_XRP_AMOUNT,
12804
12815
  XrplConstants.XRP,
12805
12816
  null,
12806
- [
12807
- { type: MemoTypes.GOVERNANCE_MODE_CHANGE, format: MemoFormats.HEX, data: modeBuf.toString('hex').toUpperCase() }
12808
- ],
12809
- options.transactionOptions);
12817
+ null,
12818
+ {
12819
+ hookParams: [
12820
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.GOVERNANCE_MODE_CHANGE },
12821
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: modeBuf.toString('hex').toUpperCase() }
12822
+ ],
12823
+ ...options.transactionOptions
12824
+ });
12810
12825
  }
12811
12826
  }
12812
12827
 
@@ -12993,7 +13008,7 @@ module.exports = {
12993
13008
 
12994
13009
  const { XrplConstants } = __nccwpck_require__(3307);
12995
13010
  const { BaseEvernodeClient } = __nccwpck_require__(6263);
12996
- const { EvernodeEvents, EvernodeConstants, MemoFormats, MemoTypes, ErrorCodes } = __nccwpck_require__(9849);
13011
+ const { EvernodeEvents, EvernodeConstants, MemoFormats, EventTypes, ErrorCodes, HookParamKeys } = __nccwpck_require__(9849);
12997
13012
  const { XrplAccount } = __nccwpck_require__(9329);
12998
13013
  const { EncryptionHelper } = __nccwpck_require__(4832);
12999
13014
  const { Buffer } = __nccwpck_require__(4300);
@@ -13010,28 +13025,28 @@ const HostEvents = {
13010
13025
  ExtendLease: EvernodeEvents.ExtendLease
13011
13026
  }
13012
13027
 
13013
- const HOST_COUNTRY_CODE_MEMO_OFFSET = 0;
13014
- const HOST_CPU_MICROSEC_MEMO_OFFSET = 2;
13015
- const HOST_RAM_MB_MEMO_OFFSET = 6;
13016
- const HOST_DISK_MB_MEMO_OFFSET = 10;
13017
- const HOST_TOT_INS_COUNT_MEMO_OFFSET = 14;
13018
- const HOST_CPU_MODEL_NAME_MEMO_OFFSET = 18;
13019
- const HOST_CPU_COUNT_MEMO_OFFSET = 58;
13020
- const HOST_CPU_SPEED_MEMO_OFFSET = 60;
13021
- const HOST_DESCRIPTION_MEMO_OFFSET = 62;
13022
- const HOST_EMAIL_ADDRESS_MEMO_OFFSET = 88;
13023
- const HOST_REG_MEMO_SIZE = 128;
13024
-
13025
- const HOST_UPDATE_TOKEN_ID_MEMO_OFFSET = 0;
13026
- const HOST_UPDATE_COUNTRY_CODE_MEMO_OFFSET = 32;
13027
- const HOST_UPDATE_CPU_MICROSEC_MEMO_OFFSET = 34;
13028
- const HOST_UPDATE_RAM_MB_MEMO_OFFSET = 38;
13029
- const HOST_UPDATE_DISK_MB_MEMO_OFFSET = 42;
13030
- const HOST_UPDATE_TOT_INS_COUNT_MEMO_OFFSET = 46;
13031
- const HOST_UPDATE_ACT_INS_COUNT_MEMO_OFFSET = 50;
13032
- const HOST_UPDATE_DESCRIPTION_MEMO_OFFSET = 54;
13033
- const HOST_UPDATE_VERSION_MEMO_OFFSET = 80;
13034
- const HOST_UPDATE_MEMO_SIZE = 83;
13028
+ const HOST_COUNTRY_CODE_PARAM_OFFSET = 0;
13029
+ const HOST_CPU_MICROSEC_PARAM_OFFSET = 2;
13030
+ const HOST_RAM_MB_PARAM_OFFSET = 6;
13031
+ const HOST_DISK_MB_PARAM_OFFSET = 10;
13032
+ const HOST_TOT_INS_COUNT_PARAM_OFFSET = 14;
13033
+ const HOST_CPU_MODEL_NAME_PARAM_OFFSET = 18;
13034
+ const HOST_CPU_COUNT_PARAM_OFFSET = 58;
13035
+ const HOST_CPU_SPEED_PARAM_OFFSET = 60;
13036
+ const HOST_DESCRIPTION_PARAM_OFFSET = 62;
13037
+ const HOST_EMAIL_ADDRESS_PARAM_OFFSET = 88;
13038
+ const HOST_REG_PARAM_SIZE = 128;
13039
+
13040
+ const HOST_UPDATE_TOKEN_ID_PARAM_OFFSET = 0;
13041
+ const HOST_UPDATE_COUNTRY_CODE_PARAM_OFFSET = 32;
13042
+ const HOST_UPDATE_CPU_MICROSEC_PARAM_OFFSET = 34;
13043
+ const HOST_UPDATE_RAM_MB_PARAM_OFFSET = 38;
13044
+ const HOST_UPDATE_DISK_MB_PARAM_OFFSET = 42;
13045
+ const HOST_UPDATE_TOT_INS_COUNT_PARAM_OFFSET = 46;
13046
+ const HOST_UPDATE_ACT_INS_COUNT_PARAM_OFFSET = 50;
13047
+ const HOST_UPDATE_DESCRIPTION_PARAM_OFFSET = 54;
13048
+ const HOST_UPDATE_VERSION_PARAM_OFFSET = 80;
13049
+ const HOST_UPDATE_PARAM_SIZE = 83;
13035
13050
 
13036
13051
  const VOTE_VALIDATION_ERR = "VOTE_VALIDATION_ERR";
13037
13052
 
@@ -13209,24 +13224,30 @@ class HostClient extends BaseEvernodeClient {
13209
13224
  }
13210
13225
 
13211
13226
  // <country_code(2)><cpu_microsec(4)><ram_mb(4)><disk_mb(4)><no_of_total_instances(4)><cpu_model(40)><cpu_count(2)><cpu_speed(2)><description(26)><email_address(40)>
13212
- const memoBuf = Buffer.alloc(HOST_REG_MEMO_SIZE, 0);
13213
- Buffer.from(countryCode.substr(0, 2), "utf-8").copy(memoBuf, HOST_COUNTRY_CODE_MEMO_OFFSET);
13214
- memoBuf.writeUInt32LE(cpuMicroSec, HOST_CPU_MICROSEC_MEMO_OFFSET);
13215
- memoBuf.writeUInt32LE(ramMb, HOST_RAM_MB_MEMO_OFFSET);
13216
- memoBuf.writeUInt32LE(diskMb, HOST_DISK_MB_MEMO_OFFSET);
13217
- memoBuf.writeUInt32LE(totalInstanceCount, HOST_TOT_INS_COUNT_MEMO_OFFSET);
13218
- Buffer.from(cpuModel.substr(0, 40), "utf-8").copy(memoBuf, HOST_CPU_MODEL_NAME_MEMO_OFFSET);
13219
- memoBuf.writeUInt16LE(cpuCount, HOST_CPU_COUNT_MEMO_OFFSET);
13220
- memoBuf.writeUInt16LE(cpuSpeed, HOST_CPU_SPEED_MEMO_OFFSET);
13221
- Buffer.from(description.substr(0, 26), "utf-8").copy(memoBuf, HOST_DESCRIPTION_MEMO_OFFSET);
13222
- Buffer.from(emailAddress.substr(0, 40), "utf-8").copy(memoBuf, HOST_EMAIL_ADDRESS_MEMO_OFFSET);
13227
+ const paramBuf = Buffer.alloc(HOST_REG_PARAM_SIZE, 0);
13228
+ Buffer.from(countryCode.substr(0, 2), "utf-8").copy(paramBuf, HOST_COUNTRY_CODE_PARAM_OFFSET);
13229
+ paramBuf.writeUInt32LE(cpuMicroSec, HOST_CPU_MICROSEC_PARAM_OFFSET);
13230
+ paramBuf.writeUInt32LE(ramMb, HOST_RAM_MB_PARAM_OFFSET);
13231
+ paramBuf.writeUInt32LE(diskMb, HOST_DISK_MB_PARAM_OFFSET);
13232
+ paramBuf.writeUInt32LE(totalInstanceCount, HOST_TOT_INS_COUNT_PARAM_OFFSET);
13233
+ Buffer.from(cpuModel.substr(0, 40), "utf-8").copy(paramBuf, HOST_CPU_MODEL_NAME_PARAM_OFFSET);
13234
+ paramBuf.writeUInt16LE(cpuCount, HOST_CPU_COUNT_PARAM_OFFSET);
13235
+ paramBuf.writeUInt16LE(cpuSpeed, HOST_CPU_SPEED_PARAM_OFFSET);
13236
+ Buffer.from(description.substr(0, 26), "utf-8").copy(paramBuf, HOST_DESCRIPTION_PARAM_OFFSET);
13237
+ Buffer.from(emailAddress.substr(0, 40), "utf-8").copy(paramBuf, HOST_EMAIL_ADDRESS_PARAM_OFFSET);
13223
13238
 
13224
13239
  const tx = await this.xrplAcc.makePayment(this.config.registryAddress,
13225
13240
  (transferredNFTokenId) ? EvernodeConstants.NOW_IN_EVRS : this.config.hostRegFee.toString(),
13226
13241
  EvernodeConstants.EVR,
13227
13242
  this.config.evrIssuerAddress,
13228
- [{ type: MemoTypes.HOST_REG, format: MemoFormats.HEX, data: memoBuf.toString('hex') }],
13229
- options.transactionOptions);
13243
+ null,
13244
+ {
13245
+ hookParams: [
13246
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_REG },
13247
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
13248
+ ],
13249
+ ...options.transactionOptions
13250
+ });
13230
13251
 
13231
13252
  console.log('Waiting for the sell offer', tx.id)
13232
13253
  let sellOffer = null;
@@ -13278,54 +13299,62 @@ class HostClient extends BaseEvernodeClient {
13278
13299
  XrplConstants.MIN_XRP_AMOUNT,
13279
13300
  XrplConstants.XRP,
13280
13301
  null,
13281
- [
13282
- { type: MemoTypes.HOST_DEREG, format: MemoFormats.HEX, data: regUriToken.index }
13283
- ],
13284
- options.transactionOptions);
13302
+ null,
13303
+ {
13304
+ hookParams: [
13305
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_DEREG },
13306
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: regUriToken.index }
13307
+ ],
13308
+ ...options.transactionOptions
13309
+ });
13285
13310
 
13286
13311
  return await this.isRegistered();
13287
13312
  }
13288
13313
 
13289
13314
  async updateRegInfo(activeInstanceCount = null, version = null, totalInstanceCount = null, tokenID = null, countryCode = null, cpuMicroSec = null, ramMb = null, diskMb = null, description = null, options = {}) {
13290
13315
  // <token_id(32)><country_code(2)><cpu_microsec(4)><ram_mb(4)><disk_mb(4)><total_instance_count(4)><active_instances(4)><description(26)><version(3)>
13291
- const memoBuf = Buffer.alloc(HOST_UPDATE_MEMO_SIZE, 0);
13316
+ const paramBuf = Buffer.alloc(HOST_UPDATE_PARAM_SIZE, 0);
13292
13317
  if (tokenID)
13293
- Buffer.from(tokenID.substr(0, 32), "hex").copy(memoBuf, HOST_UPDATE_TOKEN_ID_MEMO_OFFSET);
13318
+ Buffer.from(tokenID.substr(0, 32), "hex").copy(paramBuf, HOST_UPDATE_TOKEN_ID_PARAM_OFFSET);
13294
13319
  if (countryCode)
13295
- Buffer.from(countryCode.substr(0, 2), "utf-8").copy(memoBuf, HOST_UPDATE_COUNTRY_CODE_MEMO_OFFSET);
13320
+ Buffer.from(countryCode.substr(0, 2), "utf-8").copy(paramBuf, HOST_UPDATE_COUNTRY_CODE_PARAM_OFFSET);
13296
13321
  if (cpuMicroSec)
13297
- memoBuf.writeUInt32LE(cpuMicroSec, HOST_UPDATE_CPU_MICROSEC_MEMO_OFFSET);
13322
+ paramBuf.writeUInt32LE(cpuMicroSec, HOST_UPDATE_CPU_MICROSEC_PARAM_OFFSET);
13298
13323
  if (ramMb)
13299
- memoBuf.writeUInt32LE(ramMb, HOST_UPDATE_RAM_MB_MEMO_OFFSET);
13324
+ paramBuf.writeUInt32LE(ramMb, HOST_UPDATE_RAM_MB_PARAM_OFFSET);
13300
13325
  if (diskMb)
13301
- memoBuf.writeUInt32LE(diskMb, HOST_UPDATE_DISK_MB_MEMO_OFFSET);
13326
+ paramBuf.writeUInt32LE(diskMb, HOST_UPDATE_DISK_MB_PARAM_OFFSET);
13302
13327
  if (totalInstanceCount)
13303
- memoBuf.writeUInt32LE(totalInstanceCount, HOST_UPDATE_TOT_INS_COUNT_MEMO_OFFSET);
13328
+ paramBuf.writeUInt32LE(totalInstanceCount, HOST_UPDATE_TOT_INS_COUNT_PARAM_OFFSET);
13304
13329
  if (activeInstanceCount)
13305
- memoBuf.writeUInt32LE(activeInstanceCount, HOST_UPDATE_ACT_INS_COUNT_MEMO_OFFSET);
13330
+ paramBuf.writeUInt32LE(activeInstanceCount, HOST_UPDATE_ACT_INS_COUNT_PARAM_OFFSET);
13306
13331
  if (description)
13307
- Buffer.from(description.substr(0, 26), "utf-8").copy(memoBuf, HOST_UPDATE_DESCRIPTION_MEMO_OFFSET);
13332
+ Buffer.from(description.substr(0, 26), "utf-8").copy(paramBuf, HOST_UPDATE_DESCRIPTION_PARAM_OFFSET);
13308
13333
  if (version) {
13309
13334
  const components = version.split('.').map(v => parseInt(v));
13310
13335
  if (components.length != 3)
13311
13336
  throw 'Invalid version format.';
13312
- memoBuf.writeUInt8(components[0], HOST_UPDATE_VERSION_MEMO_OFFSET);
13313
- memoBuf.writeUInt8(components[1], HOST_UPDATE_VERSION_MEMO_OFFSET + 1);
13314
- memoBuf.writeUInt8(components[2], HOST_UPDATE_VERSION_MEMO_OFFSET + 2);
13337
+ paramBuf.writeUInt8(components[0], HOST_UPDATE_VERSION_PARAM_OFFSET);
13338
+ paramBuf.writeUInt8(components[1], HOST_UPDATE_VERSION_PARAM_OFFSET + 1);
13339
+ paramBuf.writeUInt8(components[2], HOST_UPDATE_VERSION_PARAM_OFFSET + 2);
13315
13340
  }
13316
13341
 
13317
13342
  return await this.xrplAcc.makePayment(this.config.registryAddress,
13318
13343
  XrplConstants.MIN_XRP_AMOUNT,
13319
13344
  XrplConstants.XRP,
13320
13345
  null,
13321
- [
13322
- { type: MemoTypes.HOST_UPDATE_INFO, format: MemoFormats.HEX, data: memoBuf.toString('hex') }
13323
- ],
13324
- options.transactionOptions);
13346
+ null,
13347
+ {
13348
+ hookParams: [
13349
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_UPDATE_INFO },
13350
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex') }
13351
+ ],
13352
+ ...options.transactionOptions
13353
+ });
13325
13354
  }
13326
13355
 
13327
13356
  async heartbeat(voteInfo = {}, options = {}) {
13328
- let data = "";
13357
+ let data;
13329
13358
  // Prepare voteInfo
13330
13359
  if (Object.keys(voteInfo).length > 1) {
13331
13360
  let voteBuf = Buffer.alloc(33);
@@ -13339,10 +13368,14 @@ class HostClient extends BaseEvernodeClient {
13339
13368
  XrplConstants.MIN_XRP_AMOUNT,
13340
13369
  XrplConstants.XRP,
13341
13370
  null,
13342
- [
13343
- { type: MemoTypes.HEARTBEAT, format: MemoFormats.HEX, data: data }
13344
- ],
13345
- options.transactionOptions);
13371
+ null,
13372
+ {
13373
+ hookParams: [
13374
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HEARTBEAT },
13375
+ ...(data ? [{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: data }] : [])
13376
+ ],
13377
+ ...options.transactionOptions
13378
+ });
13346
13379
  return res;
13347
13380
  }
13348
13381
  catch (e) {
@@ -13367,74 +13400,94 @@ class HostClient extends BaseEvernodeClient {
13367
13400
  throw "Tenant encryption key not set.";
13368
13401
 
13369
13402
  const encrypted = await EncryptionHelper.encrypt(encKey, instanceInfo);
13370
- const memos = [
13371
- { type: MemoTypes.ACQUIRE_SUCCESS, format: MemoFormats.BASE64, data: encrypted },
13372
- { type: MemoTypes.ACQUIRE_REF, format: MemoFormats.HEX, data: txHash }];
13373
-
13374
13403
  return this.xrplAcc.makePayment(tenantAddress,
13375
13404
  XrplConstants.MIN_XRP_AMOUNT,
13376
13405
  XrplConstants.XRP,
13377
13406
  null,
13378
- memos,
13379
- options.transactionOptions);
13407
+ [
13408
+ { type: EventTypes.ACQUIRE_SUCCESS, format: MemoFormats.BASE64, data: encrypted }
13409
+ ],
13410
+ {
13411
+ hookParams: [
13412
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.ACQUIRE_SUCCESS },
13413
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
13414
+ ],
13415
+ ...options.transactionOptions
13416
+ });
13380
13417
  }
13381
13418
 
13382
13419
  async acquireError(txHash, tenantAddress, leaseAmount, reason, options = {}) {
13383
13420
 
13384
- const memos = [
13385
- { type: MemoTypes.ACQUIRE_ERROR, format: MemoFormats.JSON, data: { type: ErrorCodes.ACQUIRE_ERR, reason: reason } },
13386
- { type: MemoTypes.ACQUIRE_REF, format: MemoFormats.HEX, data: txHash }];
13387
-
13388
13421
  return this.xrplAcc.makePayment(tenantAddress,
13389
13422
  leaseAmount.toString(),
13390
13423
  EvernodeConstants.EVR,
13391
13424
  this.config.evrIssuerAddress,
13392
- memos,
13393
- options.transactionOptions);
13425
+ [
13426
+ { type: EventTypes.ACQUIRE_ERROR, format: MemoFormats.JSON, data: { type: ErrorCodes.ACQUIRE_ERR, reason: reason } }
13427
+ ],
13428
+ {
13429
+ hookParams: [
13430
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.ACQUIRE_ERROR },
13431
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
13432
+ ],
13433
+ ...options.transactionOptions
13434
+ });
13394
13435
  }
13395
13436
 
13396
13437
  async extendSuccess(txHash, tenantAddress, expiryMoment, options = {}) {
13397
13438
  let buf = Buffer.allocUnsafe(4);
13398
13439
  buf.writeUInt32BE(expiryMoment);
13399
13440
 
13400
- const memos = [
13401
- { type: MemoTypes.EXTEND_SUCCESS, format: MemoFormats.HEX, data: buf.toString('hex') },
13402
- { type: MemoTypes.EXTEND_REF, format: MemoFormats.HEX, data: txHash }];
13403
-
13404
13441
  return this.xrplAcc.makePayment(tenantAddress,
13405
13442
  XrplConstants.MIN_XRP_AMOUNT,
13406
13443
  XrplConstants.XRP,
13407
13444
  null,
13408
- memos,
13409
- options.transactionOptions);
13445
+ [
13446
+ { type: EventTypes.EXTEND_SUCCESS, format: MemoFormats.HEX, data: buf.toString('hex') }
13447
+ ],
13448
+ {
13449
+ hookParams: [
13450
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.EXTEND_SUCCESS },
13451
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
13452
+ ],
13453
+ ...options.transactionOptions
13454
+ });
13410
13455
  }
13411
13456
 
13412
13457
  async extendError(txHash, tenantAddress, reason, refund, options = {}) {
13413
13458
 
13414
- const memos = [
13415
- { type: MemoTypes.EXTEND_ERROR, format: MemoFormats.JSON, data: { type: ErrorCodes.EXTEND_ERR, reason: reason } },
13416
- { type: MemoTypes.EXTEND_REF, format: MemoFormats.HEX, data: txHash }];
13417
-
13418
13459
  // Required to refund the paid EVR amount as the offer extention is not successfull.
13419
13460
  return this.xrplAcc.makePayment(tenantAddress,
13420
13461
  refund.toString(),
13421
13462
  EvernodeConstants.EVR,
13422
13463
  this.config.evrIssuerAddress,
13423
- memos,
13424
- options.transactionOptions);
13464
+ [
13465
+ { type: EventTypes.EXTEND_ERROR, format: MemoFormats.JSON, data: { type: ErrorCodes.EXTEND_ERR, reason: reason } }
13466
+ ],
13467
+ {
13468
+ hookParams: [
13469
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.EXTEND_ERROR },
13470
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
13471
+ ],
13472
+ ...options.transactionOptions
13473
+ });
13425
13474
  }
13426
13475
 
13427
13476
  async refundTenant(txHash, tenantAddress, refundAmount, options = {}) {
13428
- const memos = [
13429
- { type: MemoTypes.REFUND, format: '', data: '' },
13430
- { type: MemoTypes.REFUND_REF, format: MemoFormats.HEX, data: txHash }];
13431
-
13432
13477
  return this.xrplAcc.makePayment(tenantAddress,
13433
13478
  refundAmount.toString(),
13434
13479
  EvernodeConstants.EVR,
13435
13480
  this.config.evrIssuerAddress,
13436
- memos,
13437
- options.transactionOptions);
13481
+ [
13482
+ { type: EventTypes.REFUND, format: '', data: '' }
13483
+ ],
13484
+ {
13485
+ hookParams: [
13486
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.REFUND },
13487
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
13488
+ ],
13489
+ ...options.transactionOptions
13490
+ });
13438
13491
  }
13439
13492
 
13440
13493
  async requestRebate(options = {}) {
@@ -13443,9 +13496,14 @@ class HostClient extends BaseEvernodeClient {
13443
13496
  XrplConstants.XRP,
13444
13497
  null,
13445
13498
  [
13446
- { type: MemoTypes.HOST_REBATE, format: "", data: "" }
13499
+ { type: EventTypes.HOST_REBATE, format: "", data: "" }
13447
13500
  ],
13448
- options.transactionOptions);
13501
+ {
13502
+ hookParams: [
13503
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_REBATE }
13504
+ ],
13505
+ ...options.transactionOptions
13506
+ });
13449
13507
  }
13450
13508
 
13451
13509
  getLeaseNFTokenIdPrefix() {
@@ -13469,8 +13527,7 @@ class HostClient extends BaseEvernodeClient {
13469
13527
  throw "The transferee is already registered in Evernode.";
13470
13528
  }
13471
13529
 
13472
- let memoData = Buffer.allocUnsafe(20);
13473
- codec.decodeAccountID(transfereeAddress).copy(memoData);
13530
+ const paramData = codec.decodeAccountID(transfereeAddress);
13474
13531
 
13475
13532
  const regUriToken = await this.getRegistrationUriToken();
13476
13533
 
@@ -13479,10 +13536,14 @@ class HostClient extends BaseEvernodeClient {
13479
13536
  XrplConstants.XRP,
13480
13537
  null,
13481
13538
  this.config.registryAddress,
13482
- [
13483
- { type: MemoTypes.HOST_TRANSFER, format: MemoFormats.HEX, data: memoData.toString('hex') }
13484
- ],
13485
- options.transactionOptions);
13539
+ null,
13540
+ {
13541
+ hookParams: [
13542
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_TRANSFER },
13543
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramData.toString('hex') }
13544
+ ],
13545
+ ...options.transactionOptions
13546
+ });
13486
13547
 
13487
13548
  let token = null;
13488
13549
  let attempts = 0;
@@ -13546,7 +13607,7 @@ module.exports = {
13546
13607
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
13547
13608
 
13548
13609
  const { BaseEvernodeClient } = __nccwpck_require__(6263);
13549
- const { EvernodeEvents, MemoFormats, MemoTypes, ErrorCodes, ErrorReasons, EvernodeConstants } = __nccwpck_require__(9849);
13610
+ const { EvernodeEvents, MemoFormats, EventTypes, ErrorCodes, ErrorReasons, EvernodeConstants, HookParamKeys } = __nccwpck_require__(9849);
13550
13611
  const { EncryptionHelper } = __nccwpck_require__(4832);
13551
13612
  const { XrplAccount } = __nccwpck_require__(9329);
13552
13613
  const { UtilHelpers } = __nccwpck_require__(6687);
@@ -13642,7 +13703,17 @@ class TenantClient extends BaseEvernodeClient {
13642
13703
  ephemPrivateKey: options.ephemPrivateKey // Must be null or 32 bytes.
13643
13704
  });
13644
13705
 
13645
- return this.xrplAcc.buyURIToken(buyUriOffer, [{ type: MemoTypes.ACQUIRE_LEASE, format: MemoFormats.BASE64, data: ecrypted }], options.transactionOptions);
13706
+ return this.xrplAcc.buyURIToken(
13707
+ buyUriOffer,
13708
+ [
13709
+ { type: EventTypes.ACQUIRE_LEASE, format: MemoFormats.BASE64, data: ecrypted }
13710
+ ],
13711
+ {
13712
+ hookParams: [
13713
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.ACQUIRE_LEASE }
13714
+ ],
13715
+ ...options.transactionOptions
13716
+ });
13646
13717
  }
13647
13718
 
13648
13719
  /**
@@ -13666,6 +13737,7 @@ class TenantClient extends BaseEvernodeClient {
13666
13737
  const txList = await this.xrplAcc.getAccountTrx(tx.details.ledger_index);
13667
13738
  for (let t of txList) {
13668
13739
  t.tx.Memos = TransactionHelper.deserializeMemos(t.tx?.Memos);
13740
+ t.tx.HookParameters = TransactionHelper.deserializeHookParams(t.tx?.HookParameters);
13669
13741
  const res = await this.extractEvernodeEvent(t.tx);
13670
13742
  if ((res?.name === EvernodeEvents.AcquireSuccess || res?.name === EvernodeEvents.AcquireError) && res?.data?.acquireRefId === tx.id) {
13671
13743
  clearTimeout(failTimeout);
@@ -13728,8 +13800,18 @@ class TenantClient extends BaseEvernodeClient {
13728
13800
  */
13729
13801
  async extendLeaseSubmit(hostAddress, amount, tokenID, options = {}) {
13730
13802
  const host = await this.getLeaseHost(hostAddress);
13731
- return this.xrplAcc.makePayment(host.address, amount.toString(), EvernodeConstants.EVR, this.config.evrIssuerAddress,
13732
- [{ type: MemoTypes.EXTEND_LEASE, format: MemoFormats.HEX, data: tokenID }], options.transactionOptions);
13803
+ return this.xrplAcc.makePayment(
13804
+ host.address, amount.toString(),
13805
+ EvernodeConstants.EVR,
13806
+ this.config.evrIssuerAddress,
13807
+ null,
13808
+ {
13809
+ hookParams: [
13810
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.EXTEND_LEASE },
13811
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: tokenID }
13812
+ ],
13813
+ ...options.transactionOptions
13814
+ });
13733
13815
  }
13734
13816
 
13735
13817
  /**
@@ -13753,6 +13835,7 @@ class TenantClient extends BaseEvernodeClient {
13753
13835
  const txList = await this.xrplAcc.getAccountTrx(tx.details.ledger_index);
13754
13836
  for (let t of txList) {
13755
13837
  t.tx.Memos = TransactionHelper.deserializeMemos(t.tx.Memos);
13838
+ t.tx.HookParameters = TransactionHelper.deserializeHookParams(t.tx?.HookParameters);
13756
13839
  const res = await this.extractEvernodeEvent(t.tx);
13757
13840
  if ((res?.name === TenantEvents.ExtendSuccess || res?.name === TenantEvents.ExtendError) && res?.data?.extendRefId === tx.id) {
13758
13841
  clearTimeout(failTimeout);
@@ -13795,7 +13878,7 @@ class TenantClient extends BaseEvernodeClient {
13795
13878
  const uriToken = (await this.xrplAcc.getURITokens())?.find(n => n.index == tokenID);
13796
13879
 
13797
13880
  if (!uriToken) {
13798
- reject({ error: ErrorCodes.EXTEND_ERR, reason: ErrorReasons.NO_NFT, content: 'Could not find the uri token for lease extend request.' });
13881
+ reject({ error: ErrorCodes.EXTEND_ERR, reason: ErrorReasons.NO_TOKEN, content: 'Could not find the uri token for lease extend request.' });
13799
13882
  return;
13800
13883
  }
13801
13884
 
@@ -14316,7 +14399,7 @@ const EvernodeConstants = {
14316
14399
  }
14317
14400
  }
14318
14401
 
14319
- const MemoTypes = {
14402
+ const EventTypes = {
14320
14403
  ACQUIRE_LEASE: 'evnAcquireLease',
14321
14404
  ACQUIRE_SUCCESS: 'evnAcquireSuccess',
14322
14405
  ACQUIRE_ERROR: 'evnAcquireError',
@@ -14361,7 +14444,7 @@ const ErrorCodes = {
14361
14444
  const ErrorReasons = {
14362
14445
  TRANSACTION_FAILURE: 'TRANSACTION_FAILURE',
14363
14446
  NO_OFFER: 'NO_OFFER',
14364
- NO_NFT: 'NO_NFT',
14447
+ NO_TOKEN: 'NO_TOKEN',
14365
14448
  INTERNAL_ERR: 'INTERNAL_ERR',
14366
14449
  TIMEOUT: 'TIMEOUT',
14367
14450
  HOST_INVALID: 'HOST_INVALID',
@@ -14404,6 +14487,14 @@ const HookStateKeys = {
14404
14487
  PREFIX_CANDIDATE_ID: "45565206",
14405
14488
  }
14406
14489
 
14490
+ // All keys are prefixed with 'EVR' (0x455652)
14491
+ const HookParamKeys = {
14492
+ PARAM_STATE_HOOK_KEY: "4556520100000000000000000000000000000000000000000000000000000001",
14493
+ PARAM_EVENT_TYPE_KEY: "4556520100000000000000000000000000000000000000000000000000000002",
14494
+ PARAM_EVENT_DATA1_KEY: "4556520100000000000000000000000000000000000000000000000000000003",
14495
+ PARAM_EVENT_DATA2_KEY: "4556520100000000000000000000000000000000000000000000000000000004",
14496
+ }
14497
+
14407
14498
  const EvernodeEvents = {
14408
14499
  HostRegistered: "HostRegistered",
14409
14500
  HostDeregistered: "HostDeregistered",
@@ -14439,13 +14530,14 @@ const URITokenTypes = {
14439
14530
 
14440
14531
  module.exports = {
14441
14532
  EvernodeConstants,
14442
- MemoTypes,
14533
+ EventTypes,
14443
14534
  MemoFormats,
14444
14535
  ErrorCodes,
14445
14536
  ErrorReasons,
14446
14537
  HookStateKeys,
14447
14538
  EvernodeEvents,
14448
- URITokenTypes
14539
+ URITokenTypes,
14540
+ HookParamKeys
14449
14541
  }
14450
14542
 
14451
14543
  /***/ }),
@@ -14888,7 +14980,7 @@ const { FoundationClient, FoundationEvents } = __nccwpck_require__(2466);
14888
14980
  const { XrplApi } = __nccwpck_require__(1850);
14889
14981
  const { XrplApiEvents, XrplConstants } = __nccwpck_require__(3307);
14890
14982
  const { XrplAccount } = __nccwpck_require__(9329);
14891
- const { EvernodeConstants, HookStateKeys, MemoTypes } = __nccwpck_require__(9849);
14983
+ const { EvernodeConstants, HookStateKeys, HookParamKeys, EventTypes } = __nccwpck_require__(9849);
14892
14984
  const { XflHelpers } = __nccwpck_require__(3243);
14893
14985
  const { FirestoreHandler } = __nccwpck_require__(9718);
14894
14986
  const { StateHelpers } = __nccwpck_require__(3860);
@@ -14924,7 +15016,8 @@ module.exports = {
14924
15016
  TransactionHelper,
14925
15017
  EncryptionHelper,
14926
15018
  HookStateKeys,
14927
- MemoTypes,
15019
+ HookParamKeys,
15020
+ EventTypes,
14928
15021
  HookTypes,
14929
15022
  HookClientFactory,
14930
15023
  EvernodeHelpers
@@ -15553,7 +15646,7 @@ module.exports = {
15553
15646
  /***/ 7071:
15554
15647
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
15555
15648
 
15556
- const { MemoFormats } = __nccwpck_require__(9849);
15649
+ const { MemoFormats, HookParamKeys } = __nccwpck_require__(9849);
15557
15650
 
15558
15651
  class TransactionHelper {
15559
15652
 
@@ -15589,26 +15682,47 @@ class TransactionHelper {
15589
15682
  })
15590
15683
  }
15591
15684
 
15685
+ // Convert hook params from our object type to xrpl lib object type.
15686
+ static formatHookParams(params) {
15687
+ return params ? params.filter(m => m.name).map(m => {
15688
+ return {
15689
+ HookParameter: {
15690
+ HookParameterName: m.name,
15691
+ HookParameterValue: m.value ?
15692
+ (m.name === HookParamKeys.PARAM_EVENT_TYPE_KEY ? TransactionHelper.asciiToHex(m.value) :
15693
+ m.value.toUpperCase()) : ''
15694
+ }
15695
+ }
15696
+ }) : [];
15697
+ }
15698
+
15699
+ // Convert hook params from xrpl lib object type to our object type.
15700
+ static deserializeHookParams(params) {
15701
+ if (!params)
15702
+ return [];
15703
+
15704
+ return params.filter(m => m.HookParameter).map(m => {
15705
+ return {
15706
+ name: m.HookParameter.HookParameterName,
15707
+ value: m.HookParameter.HookParameterValue ?
15708
+ (m.HookParameter.HookParameterName === HookParamKeys.PARAM_EVENT_TYPE_KEY ? TransactionHelper.hexToASCII(m.HookParameter.HookParameterValue) :
15709
+ m.HookParameter.HookParameterValue.toUpperCase()) : '',
15710
+ }
15711
+ })
15712
+ }
15713
+
15592
15714
  static hexToASCII(hex) {
15593
15715
  if (!hex)
15594
15716
  return "";
15595
15717
 
15596
- let str = "";
15597
- for (let n = 0; n < hex.length; n += 2) {
15598
- str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
15599
- }
15600
- return str;
15718
+ return Buffer.from(hex, 'hex').toString();
15601
15719
  }
15602
15720
 
15603
15721
  static asciiToHex(str) {
15604
15722
  if (!str)
15605
15723
  return "";
15606
15724
 
15607
- let hex = "";
15608
- for (let n = 0; n < str.length; n++) {
15609
- hex += str.charCodeAt(n).toString(16)
15610
- }
15611
- return hex;
15725
+ return Buffer.from(str).toString('hex').toUpperCase();
15612
15726
  }
15613
15727
  }
15614
15728
 
@@ -16046,7 +16160,8 @@ class XrplAccount {
16046
16160
  Account: this.address,
16047
16161
  Amount: amountObj,
16048
16162
  Destination: toAddr,
16049
- Memos: TransactionHelper.formatMemos(memos)
16163
+ Memos: TransactionHelper.formatMemos(memos),
16164
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16050
16165
  }, options);
16051
16166
  }
16052
16167
 
@@ -16063,7 +16178,8 @@ class XrplAccount {
16063
16178
  issuer: issuer,
16064
16179
  value: limit
16065
16180
  },
16066
- Memos: TransactionHelper.formatMemos(memos)
16181
+ Memos: TransactionHelper.formatMemos(memos),
16182
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16067
16183
  };
16068
16184
 
16069
16185
  if (!allowRippling)
@@ -16078,7 +16194,8 @@ class XrplAccount {
16078
16194
  TransactionType: 'SetRegularKey',
16079
16195
  Account: this.address,
16080
16196
  RegularKey: regularKey,
16081
- Memos: TransactionHelper.formatMemos(memos)
16197
+ Memos: TransactionHelper.formatMemos(memos),
16198
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16082
16199
  }, options);
16083
16200
  }
16084
16201
 
@@ -16115,7 +16232,8 @@ class XrplAccount {
16115
16232
  TakerGets: sellAmountObj,
16116
16233
  TakerPays: forAmountObj,
16117
16234
  Expiration: expiration,
16118
- Memos: TransactionHelper.formatMemos(memos)
16235
+ Memos: TransactionHelper.formatMemos(memos),
16236
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16119
16237
  }, options);
16120
16238
  }
16121
16239
 
@@ -16130,7 +16248,8 @@ class XrplAccount {
16130
16248
  TakerGets: forAmountObj,
16131
16249
  TakerPays: buyAmountObj,
16132
16250
  Expiration: expiration,
16133
- Memos: TransactionHelper.formatMemos(memos)
16251
+ Memos: TransactionHelper.formatMemos(memos),
16252
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16134
16253
  }, options);
16135
16254
  }
16136
16255
 
@@ -16139,7 +16258,8 @@ class XrplAccount {
16139
16258
  TransactionType: 'OfferCancel',
16140
16259
  Account: this.address,
16141
16260
  OfferSequence: offerSequence,
16142
- Memos: TransactionHelper.formatMemos(memos)
16261
+ Memos: TransactionHelper.formatMemos(memos),
16262
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16143
16263
  }, options);
16144
16264
  }
16145
16265
 
@@ -16151,7 +16271,8 @@ class XrplAccount {
16151
16271
  NFTokenTaxon: taxon,
16152
16272
  TransferFee: transferFee,
16153
16273
  Flags: (flags.isBurnable ? 1 : 0) | (flags.isOnlyXRP ? 2 : 0) | (flags.isTrustLine ? 4 : 0) | (flags.isTransferable ? 8 : 0),
16154
- Memos: TransactionHelper.formatMemos(memos)
16274
+ Memos: TransactionHelper.formatMemos(memos),
16275
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16155
16276
  }, options);
16156
16277
  }
16157
16278
 
@@ -16165,7 +16286,8 @@ class XrplAccount {
16165
16286
  Amount: amountObj,
16166
16287
  Expiration: expiration,
16167
16288
  Flags: 1, // tfSellToken
16168
- Memos: TransactionHelper.formatMemos(memos)
16289
+ Memos: TransactionHelper.formatMemos(memos),
16290
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16169
16291
  };
16170
16292
 
16171
16293
  return this.#submitAndVerifyTransaction(destination ? { ...tx, Destination: destination } : tx, options);
@@ -16183,7 +16305,8 @@ class XrplAccount {
16183
16305
  Amount: amountObj,
16184
16306
  Expiration: expiration,
16185
16307
  Flags: 0, // Buy offer
16186
- Memos: TransactionHelper.formatMemos(memos)
16308
+ Memos: TransactionHelper.formatMemos(memos),
16309
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16187
16310
  }, options);
16188
16311
  }
16189
16312
 
@@ -16193,7 +16316,8 @@ class XrplAccount {
16193
16316
  TransactionType: 'NFTokenAcceptOffer',
16194
16317
  Account: this.address,
16195
16318
  NFTokenBuyOffer: offerId,
16196
- Memos: TransactionHelper.formatMemos(memos)
16319
+ Memos: TransactionHelper.formatMemos(memos),
16320
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16197
16321
  }, options);
16198
16322
  }
16199
16323
 
@@ -16203,7 +16327,8 @@ class XrplAccount {
16203
16327
  TransactionType: 'NFTokenAcceptOffer',
16204
16328
  Account: this.address,
16205
16329
  NFTokenSellOffer: offerId,
16206
- Memos: TransactionHelper.formatMemos(memos)
16330
+ Memos: TransactionHelper.formatMemos(memos),
16331
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16207
16332
  }, options);
16208
16333
  }
16209
16334
 
@@ -16213,7 +16338,8 @@ class XrplAccount {
16213
16338
  TransactionType: 'NFTokenBurn',
16214
16339
  Account: this.address,
16215
16340
  NFTokenID: nfTokenId,
16216
- Memos: TransactionHelper.formatMemos(memos)
16341
+ Memos: TransactionHelper.formatMemos(memos),
16342
+ HookParameters: TransactionHelper.formatHookParams(options.hookParams)
16217
16343
  };
16218
16344
 
16219
16345
  return this.#submitAndVerifyTransaction(owner ? { ...tx, Owner: owner } : tx, options);
@@ -16301,7 +16427,7 @@ class XrplAccount {
16301
16427
  const hookExecRes = txResult.details?.meta?.HookExecutions?.map(o => {
16302
16428
  return {
16303
16429
  result: o.HookExecution?.HookResult,
16304
- returnCode: o.HookExecution?.HookReturnCode,
16430
+ returnCode: parseInt(o.HookExecution?.HookReturnCode, 16),
16305
16431
  message: TransactionHelper.hexToASCII(o.HookExecution?.HookReturnString).replace(/\x00+$/, '')
16306
16432
  }
16307
16433
  });
@@ -16346,7 +16472,7 @@ class XrplAccount {
16346
16472
  const hookExecRes = txResult.details?.meta?.HookExecutions?.map(o => {
16347
16473
  return {
16348
16474
  result: o.HookExecution?.HookResult,
16349
- returnCode: o.HookExecution?.HookReturnCode,
16475
+ returnCode: parseInt(o.HookExecution?.HookReturnCode, 16),
16350
16476
  message: TransactionHelper.hexToASCII(o.HookExecution?.HookReturnString).replace(/\x00+$/, '')
16351
16477
  }
16352
16478
  });
@@ -16414,6 +16540,9 @@ class XrplAccount {
16414
16540
  if (memos)
16415
16541
  tx.Memos = TransactionHelper.formatMemos(memos);
16416
16542
 
16543
+ if (options.hookParams)
16544
+ tx.HookParameters = TransactionHelper.formatHookParams(options.hookParams);
16545
+
16417
16546
  return this.#submitAndVerifyTransaction(tx, options);
16418
16547
  }
16419
16548
 
@@ -16428,6 +16557,9 @@ class XrplAccount {
16428
16557
  if (memos)
16429
16558
  tx.Memos = TransactionHelper.formatMemos(memos);
16430
16559
 
16560
+ if (options.hookParams)
16561
+ tx.HookParameters = TransactionHelper.formatHookParams(options.hookParams);
16562
+
16431
16563
  return this.#submitAndVerifyTransaction(tx, options);
16432
16564
  }
16433
16565
 
@@ -16596,6 +16728,7 @@ class XrplApi {
16596
16728
  // Emit the event only for successful transactions, Otherwise emit error.
16597
16729
  if (data.engine_result === "tesSUCCESS") {
16598
16730
  tx.Memos = TransactionHelper.deserializeMemos(tx.Memos);
16731
+ tx.HookParameters = TransactionHelper.deserializeHookParams(tx.HookParameters);
16599
16732
  matches.forEach(s => s.handler(eventName, tx));
16600
16733
  }
16601
16734
  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.5.17-beta-v3.4",
9
+ "version": "0.5.17-beta-v3.5",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",