evernode-js-client 0.6.0 → 0.6.2

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.
Files changed (2) hide show
  1. package/index.js +10 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -12354,7 +12354,7 @@ class BaseEvernodeClient {
12354
12354
  const hosts = await this.#firestoreHandler.getHosts(filters, pageSize, nextPageToken);
12355
12355
  const curMomentStartIdx = await this.getMomentStartIndex();
12356
12356
  const res = await Promise.all((hosts.nextPageToken ? hosts.data : hosts).map(async host => {
12357
- const hostAcc = new XrplAccount(host.address);
12357
+ const hostAcc = new XrplAccount(host.address, null, { xrplApi: this.xrplApi });
12358
12358
  host.domain = await hostAcc.getDomain();
12359
12359
 
12360
12360
  host.active = (host.lastHeartbeatIndex > (this.config.hostHeartbeatFreq * this.config.momentSize) ?
@@ -13143,14 +13143,15 @@ class HostClient extends BaseEvernodeClient {
13143
13143
  }
13144
13144
 
13145
13145
  async offerLease(leaseIndex, leaseAmount, tosHash) {
13146
- // <prefix><lease index 16)><half of tos hash><lease amount (uint32)>
13146
+ // <prefix><lease index 16)><half of tos hash><lease amount (int64)><identifier (uint32)>
13147
13147
  const prefixLen = EvernodeConstants.LEASE_TOKEN_PREFIX_HEX.length / 2;
13148
13148
  const halfToSLen = tosHash.length / 4;
13149
- const uriBuf = Buffer.allocUnsafe(prefixLen + halfToSLen + 10);
13149
+ const uriBuf = Buffer.allocUnsafe(prefixLen + halfToSLen + 14);
13150
13150
  Buffer.from(EvernodeConstants.LEASE_TOKEN_PREFIX_HEX, 'hex').copy(uriBuf);
13151
13151
  uriBuf.writeUInt16BE(leaseIndex, prefixLen);
13152
13152
  Buffer.from(tosHash, 'hex').copy(uriBuf, prefixLen + 2, 0, halfToSLen);
13153
13153
  uriBuf.writeBigInt64BE(XflHelpers.getXfl(leaseAmount.toString()), prefixLen + 2 + halfToSLen);
13154
+ uriBuf.writeUInt32BE((await this.xrplAcc.getSequence()), prefixLen + 10 + halfToSLen);
13154
13155
  const uri = uriBuf.toString('base64');
13155
13156
 
13156
13157
  try {
@@ -13205,7 +13206,7 @@ class HostClient extends BaseEvernodeClient {
13205
13206
  else if (!/^((?![;])[\x00-\x7F]){0,26}$/.test(description))
13206
13207
  throw "description should consist of 0-26 ascii characters except ';'";
13207
13208
 
13208
- else if (!emailAddress || !(/[a-z0-9]+@[a-z]+.[a-z]{2,3}/.test(emailAddress)) || (emailAddress.length > 40))
13209
+ else if (!emailAddress || !(/.+@.+/.test(emailAddress)) || (emailAddress.length > 40))
13209
13210
  throw "Email address should be valid and can not have more than 40 characters.";
13210
13211
 
13211
13212
  if (await this.isRegistered())
@@ -13949,7 +13950,7 @@ module.exports = {
13949
13950
  /***/ ((module) => {
13950
13951
 
13951
13952
  const DefaultValues = {
13952
- governorAddress: 'r9keGGSTDRg58RuiWYAQYuAAA8nqMG7EP5',
13953
+ governorAddress: 'raVhw4Q8FQr296jdaDLDfZ4JDhh7tFG7SF',
13953
13954
  rippledServer: 'wss://hooks-testnet-v3.xrpl-labs.com',
13954
13955
  xrplApi: null,
13955
13956
  stateIndexId: 'evernodeindex',
@@ -15792,22 +15793,9 @@ const { TransactionHelper } = __nccwpck_require__(7071);
15792
15793
  // Utility helper functions.
15793
15794
  class UtilHelpers {
15794
15795
 
15795
- static decodeLeaseNftUri(hexUri) {
15796
- // Get the lease index from the nft URI.
15797
- // <prefix><lease index (uint16)><half of tos hash (16 bytes)><lease amount (uint32)>
15798
- const prefixLen = EvernodeConstants.LEASE_TOKEN_PREFIX_HEX.length / 2;
15799
- const halfToSLen = 16;
15800
- const uriBuf = Buffer.from(hexUri, 'hex');
15801
- return {
15802
- leaseIndex: uriBuf.readUint16BE(prefixLen),
15803
- halfTos: uriBuf.slice(prefixLen + 2, halfToSLen),
15804
- leaseAmount: parseFloat(XflHelpers.toString(uriBuf.readBigInt64BE(prefixLen + 2 + halfToSLen)))
15805
- }
15806
- }
15807
-
15808
15796
  static decodeLeaseTokenUri(hexUri) {
15809
15797
  // Get the lease index from the token's URI.
15810
- // <prefix><lease index (uint16)><half of tos hash (16 bytes)><lease amount (uint32)>
15798
+ // <prefix><lease index 16)><half of tos hash><lease amount (int64)><identifier (uint32)>
15811
15799
 
15812
15800
  const asciiUri = TransactionHelper.hexToASCII(hexUri);
15813
15801
  const uriBuf = Buffer.from(asciiUri, 'base64');
@@ -15816,7 +15804,8 @@ class UtilHelpers {
15816
15804
  return {
15817
15805
  leaseIndex: uriBuf.readUint16BE(prefixLen),
15818
15806
  halfTos: uriBuf.slice(prefixLen + 2, halfToSLen),
15819
- leaseAmount: parseFloat(XflHelpers.toString(uriBuf.readBigInt64BE(prefixLen + 2 + halfToSLen)))
15807
+ leaseAmount: parseFloat(XflHelpers.toString(uriBuf.readBigInt64BE(prefixLen + 2 + halfToSLen))),
15808
+ identifier: uriBuf.readUInt32BE(prefixLen + 10 + halfToSLen)
15820
15809
  }
15821
15810
  }
15822
15811
 
@@ -16750,7 +16739,7 @@ class XrplApi {
16750
16739
  if (data.transaction.TransactionType === 'URITokenBuy') {
16751
16740
  // We take all the offers created by subscribed accounts in previous ledger until we get the respective offer.
16752
16741
  for (const subscription of this.#addressSubscriptions) {
16753
- const acc = new XrplAccount(subscription.address, null);
16742
+ const acc = new XrplAccount(subscription.address, null, { xrplApi: this });
16754
16743
  // Here we access the offers that were there in this account based on the given ledger index.
16755
16744
  const offers = await acc.getURITokens({ ledger_index: data.ledger_index - 1 });
16756
16745
  // Filter out the matching URI token offer for the scenario.
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.0",
9
+ "version": "0.6.2",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",