evernode-js-client 0.6.31 → 0.6.32

Sign up to get free protection for your applications and to get access to all the features.
Binary file
package/index.js CHANGED
@@ -52075,7 +52075,7 @@ class BaseEvernodeClient {
52075
52075
  }
52076
52076
 
52077
52077
  /**
52078
- * Extracts the transaction info from a given transaction.
52078
+ * Extracts the transaction info from a given transaction..
52079
52079
  * @param {object} tx Transaction to be deserialized and extracted.
52080
52080
  * @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.
52081
52081
  */
@@ -53355,6 +53355,7 @@ const VOTE_VALIDATION_ERR = "VOTE_VALIDATION_ERR";
53355
53355
  const IPV6_FAMILY = 6;
53356
53356
 
53357
53357
  const MAX_HOST_LEDGER_OFFSET = 30;
53358
+ const TX_RETRY_INTERVAL = 3000;
53358
53359
 
53359
53360
  class HostClient extends BaseEvernodeClient {
53360
53361
 
@@ -53395,6 +53396,14 @@ class HostClient extends BaseEvernodeClient {
53395
53396
  return null;
53396
53397
  }
53397
53398
 
53399
+ /**
53400
+ * Get offered and unoffered leases created by the host.
53401
+ * @returns Array of lease offer objects.
53402
+ */
53403
+ async getLeases() {
53404
+ return await EvernodeHelpers.getLeases(this.xrplAcc);
53405
+ }
53406
+
53398
53407
  /**
53399
53408
  * Get lease offers created by the host.
53400
53409
  * @returns Array of lease offer objects.
@@ -53403,6 +53412,14 @@ class HostClient extends BaseEvernodeClient {
53403
53412
  return await EvernodeHelpers.getLeaseOffers(this.xrplAcc);
53404
53413
  }
53405
53414
 
53415
+ /**
53416
+ * Get unoffered leases created by the host.
53417
+ * @returns Array of lease objects.
53418
+ */
53419
+ async getUnofferedLeases() {
53420
+ return await EvernodeHelpers.getUnofferedLeases(this.xrplAcc);
53421
+ }
53422
+
53406
53423
  /**
53407
53424
  * Check wether the host is registered.
53408
53425
  * @returns Boolean if the host is registered or not.
@@ -53411,11 +53428,32 @@ class HostClient extends BaseEvernodeClient {
53411
53428
  return (await this.getRegistration()) !== null;
53412
53429
  }
53413
53430
 
53431
+ async #submitWithRetry(callback, options = {}) {
53432
+ let attempt = 0;
53433
+ let feeUplift = 0;
53434
+ const maxAttempts = (options?.maxRetryAttempts || 1);
53435
+ while (attempt <= maxAttempts) {
53436
+ attempt++;
53437
+ try {
53438
+ return await callback(feeUplift);
53439
+ }
53440
+ catch (e) {
53441
+ if (attempt == maxAttempts || e.code === "tecDUPLICATE" || e.code === "tefPAST_SEQ" || e.code === "tefALREADY")
53442
+ throw e;
53443
+ else if (e.status === "TOOK_LONG") {
53444
+ feeUplift += (options?.feeUplift || 0);
53445
+ }
53446
+ console.error(`Submission attempt ${attempt} failed with ${e}. Retrying...`);
53447
+ await new Promise(resolve => setTimeout(resolve, TX_RETRY_INTERVAL));
53448
+ }
53449
+ }
53450
+ }
53451
+
53414
53452
  /**
53415
53453
  * Prepare the host account with account fields and trust lines.
53416
53454
  * @param {string} domain Domain which the host machine is reachable.
53417
53455
  */
53418
- async prepareAccount(domain) {
53456
+ async prepareAccount(domain, options = {}) {
53419
53457
  const [flags, trustLines, msgKey, curDomain] = await Promise.all([
53420
53458
  this.xrplAcc.getFlags(),
53421
53459
  this.xrplAcc.getTrustLines(EvernodeConstants.EVR, this.config.evrIssuerAddress),
@@ -53430,11 +53468,17 @@ class HostClient extends BaseEvernodeClient {
53430
53468
  accountSetFields = (!curDomain || curDomain !== domain) ?
53431
53469
  { ...accountSetFields, Domain: domain } : accountSetFields;
53432
53470
 
53433
- if (Object.keys(accountSetFields).length !== 0)
53434
- await this.xrplAcc.setAccountFields(accountSetFields, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53471
+ if (Object.keys(accountSetFields).length !== 0) {
53472
+ await this.#submitWithRetry(async (feeUplift) => {
53473
+ await this.xrplAcc.setAccountFields(accountSetFields, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53474
+ }, options.retryOptions);
53475
+ }
53435
53476
 
53436
- if (trustLines.length === 0)
53437
- await this.xrplAcc.setTrustLine(EvernodeConstants.EVR, this.config.evrIssuerAddress, "99999999999999", null, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53477
+ if (trustLines.length === 0) {
53478
+ await this.#submitWithRetry(async (feeUplift) => {
53479
+ await this.xrplAcc.setTrustLine(EvernodeConstants.EVR, this.config.evrIssuerAddress, "99999999999999", null, null, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53480
+ }, options.retryOptions);
53481
+ }
53438
53482
  }
53439
53483
 
53440
53484
  /**
@@ -53444,7 +53488,7 @@ class HostClient extends BaseEvernodeClient {
53444
53488
  * @param {string} tosHash Hex hash of the Terms Of Service text.
53445
53489
  * @param {string} outboundIPAddress Assigned IP Address.
53446
53490
  */
53447
- async offerLease(leaseIndex, leaseAmount, tosHash, outboundIPAddress = null) {
53491
+ async offerLease(leaseIndex, leaseAmount, tosHash, outboundIPAddress = null, options = {}) {
53448
53492
 
53449
53493
  // <prefix><version tag ("LTV"+uint8)><lease index (uint16)><half of tos hash><lease amount (int64)><identifier (uint32)><ip data>
53450
53494
  // Lengths of sub sections.
@@ -53496,7 +53540,9 @@ class HostClient extends BaseEvernodeClient {
53496
53540
  const uri = uriBuf.toString('base64');
53497
53541
 
53498
53542
  try {
53499
- await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false }, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53543
+ await this.#submitWithRetry(async (feeUplift) => {
53544
+ await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false }, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53545
+ }, options.retryOptions);
53500
53546
  } catch (e) {
53501
53547
  // Re-minting the URIToken after burning that sold URIToken.
53502
53548
  if (e.code === "tecDUPLICATE") {
@@ -53512,18 +53558,138 @@ class HostClient extends BaseEvernodeClient {
53512
53558
  if (!uriToken)
53513
53559
  throw "Offer lease NFT creation error.";
53514
53560
 
53515
- await this.xrplAcc.sellURIToken(uriToken.index,
53516
- leaseAmount.toString(),
53517
- EvernodeConstants.EVR,
53518
- this.config.evrIssuerAddress, null, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53561
+ await this.#submitWithRetry(async (feeUplift) => {
53562
+ await this.xrplAcc.sellURIToken(uriToken.index,
53563
+ leaseAmount.toString(),
53564
+ EvernodeConstants.EVR,
53565
+ this.config.evrIssuerAddress, null, null, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53566
+ }, options.retryOptions);
53567
+ }
53568
+
53569
+ /**
53570
+ * Mint a lease offer.
53571
+ * @param {number} leaseIndex Index number for the lease.
53572
+ * @param {number} leaseAmount Amount (EVRs) of the lease offer.
53573
+ * @param {string} tosHash Hex hash of the Terms Of Service text.
53574
+ * @param {string} outboundIPAddress Assigned IP Address.
53575
+ */
53576
+ async mintLease(leaseIndex, leaseAmount, tosHash, outboundIPAddress = null, options = {}) {
53577
+
53578
+ // <prefix><version tag ("LTV"+uint8)><lease index (uint16)><half of tos hash><lease amount (int64)><identifier (uint32)><ip data>
53579
+ // Lengths of sub sections.
53580
+ const prefixLen = EvernodeConstants.LEASE_TOKEN_PREFIX_HEX.length / 2;
53581
+ const versionPrefixLen = EvernodeConstants.LEASE_TOKEN_VERSION_PREFIX_HEX.length / 2;
53582
+ const versionLen = versionPrefixLen + 2; // ("LTV"<Version Number>)
53583
+ const indexLen = 2;
53584
+ const halfToSLen = tosHash.length / 4;
53585
+ const leaseAmountLen = 8;
53586
+ const identifierLen = 4;
53587
+ const ipDataLen = 17;
53588
+
53589
+ // Offsets of sub sections
53590
+ const versionPrefixOffset = prefixLen;
53591
+ const versionOffset = prefixLen + versionPrefixLen;
53592
+ const indexOffset = prefixLen + versionLen;
53593
+ const halfTosHashOffset = prefixLen + versionLen + indexLen;
53594
+ const leaseAmountOffset = prefixLen + versionLen + indexLen + halfToSLen;
53595
+ const identifierOffset = prefixLen + versionLen + indexLen + halfToSLen + leaseAmountLen;
53596
+ const ipDataOffset = prefixLen + versionLen + indexLen + halfToSLen + leaseAmountLen + identifierLen;
53597
+
53598
+ const uriBuf = Buffer.alloc((prefixLen + versionLen + indexLen + halfToSLen + leaseAmountLen + identifierLen + ipDataLen));
53599
+
53600
+ Buffer.from(EvernodeConstants.LEASE_TOKEN_PREFIX_HEX, 'hex').copy(uriBuf);
53601
+ Buffer.from(EvernodeConstants.LEASE_TOKEN_VERSION_PREFIX_HEX, 'hex').copy(uriBuf, versionPrefixOffset, 0, versionPrefixLen);
53602
+ uriBuf.writeUInt16BE(EvernodeConstants.LEASE_TOKEN_VERSION, versionOffset);
53603
+ uriBuf.writeUInt16BE(leaseIndex, indexOffset);
53604
+ Buffer.from(tosHash, 'hex').copy(uriBuf, halfTosHashOffset, 0, halfToSLen);
53605
+ uriBuf.writeBigInt64BE(XflHelpers.getXfl(leaseAmount.toString()), leaseAmountOffset);
53606
+ uriBuf.writeUInt32BE((await this.xrplAcc.getSequence()), identifierOffset);
53607
+
53608
+ if (outboundIPAddress) {
53609
+ if (outboundIPAddress.includes(":")) {
53610
+ uriBuf.writeUInt8(IPV6_FAMILY, ipDataOffset);
53611
+ const ipBuf = Buffer.from(outboundIPAddress.split(':').map(v => {
53612
+ const bytes = [];
53613
+ for (let i = 0; i < v.length; i += 2) {
53614
+ bytes.push(parseInt(v.substr(i, 2), 16));
53615
+ }
53616
+ return bytes;
53617
+ }).flat());
53618
+
53619
+ ipBuf.copy(uriBuf, ipDataOffset + 1, 0, ipDataLen);
53620
+ } else {
53621
+ throw "Invalid outbound IP address was provided";
53622
+ }
53623
+ }
53624
+
53625
+ const uri = uriBuf.toString('base64');
53626
+
53627
+ try {
53628
+ await this.#submitWithRetry(async (feeUplift) => {
53629
+ await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false }, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53630
+ }, options.retryOptions);
53631
+ } catch (e) {
53632
+ // Re-minting the URIToken after burning that sold URIToken.
53633
+ if (e.code === "tecDUPLICATE") {
53634
+ const uriTokenId = this.xrplAcc.generateIssuedURITokenId(uri);
53635
+ console.log(`Burning URIToken related to a previously sold lease.`);
53636
+ await this.xrplAcc.burnURIToken(uriTokenId, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53637
+ console.log("Re-mint the URIToken for the new lease offer.")
53638
+ await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false }, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53639
+ }
53640
+ }
53641
+ }
53642
+
53643
+ /**
53644
+ * Create a lease offer.
53645
+ * @param {number} uriTokenId Id of the token.
53646
+ * @param {number} leaseAmount Amount (EVRs) of the lease offer.
53647
+ */
53648
+ async offerMintedLease(uriTokenId, leaseAmount, options = {}) {
53649
+ await this.#submitWithRetry(async (feeUplift) => {
53650
+ await this.xrplAcc.sellURIToken(uriTokenId, leaseAmount.toString(),
53651
+ EvernodeConstants.EVR,
53652
+ this.config.evrIssuerAddress, null, null, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53653
+ }, options.retryOptions);
53519
53654
  }
53520
53655
 
53521
53656
  /**
53522
53657
  * Expire the lease offer.
53523
53658
  * @param {string} uriTokenId Hex URI token id of the lease.
53524
53659
  */
53525
- async expireLease(uriTokenId) {
53526
- await this.xrplAcc.burnURIToken(uriTokenId, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53660
+ async expireLease(uriTokenId, options = {}) {
53661
+ await this.#submitWithRetry(async (feeUplift) => {
53662
+ await this.xrplAcc.burnURIToken(uriTokenId, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53663
+ }, options.retryOptions);
53664
+ }
53665
+
53666
+ /**
53667
+ * Accepts if there's an available reg token.
53668
+ * @param {*} options [Optional] transaction options.
53669
+ * @returns True if there were reg token and it's accepted, Otherwise false.
53670
+ */
53671
+ async acceptRegToken(options = {}) {
53672
+ // Check whether is there any missed NFT sell offer that needs to be accepted
53673
+ // from the client-side in order to complete the registration.
53674
+ const registryAcc = new XrplAccount(this.config.registryAddress, null, { xrplApi: this.xrplApi });
53675
+ const regUriToken = await this.getRegistrationUriToken();
53676
+
53677
+ if (!regUriToken) {
53678
+ const regInfo = await this.getHostInfo(this.xrplAcc.address);
53679
+ if (regInfo) {
53680
+ const sellOffer = (await registryAcc.getURITokens()).find(o => o.index == regInfo.uriTokenId && o.Amount);
53681
+ console.log('Pending sell offer found.')
53682
+ if (sellOffer) {
53683
+ await this.#submitWithRetry(async (feeUplift) => {
53684
+ await this.xrplAcc.buyURIToken(sellOffer, null, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53685
+ }, options.retryOptions);
53686
+ console.log("Registration was successfully completed after acquiring the NFT.");
53687
+ return await this.isRegistered();
53688
+ }
53689
+ }
53690
+ }
53691
+
53692
+ return false;
53527
53693
  }
53528
53694
 
53529
53695
  /**
@@ -53577,27 +53743,14 @@ class HostClient extends BaseEvernodeClient {
53577
53743
  if (existingLeaseURITokens) {
53578
53744
  console.log("Burning unsold URITokens related to the previous leases.");
53579
53745
  for (const uriToken of existingLeaseURITokens) {
53580
- await this.xrplAcc.burnURIToken(uriToken.index, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53746
+ await this.#submitWithRetry(async (feeUplift) => {
53747
+ await this.xrplAcc.burnURIToken(uriToken.index, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53748
+ }, options.retryOptions);
53581
53749
  }
53582
53750
  }
53583
53751
 
53584
- // Check whether is there any missed NFT sell offer that needs to be accepted
53585
- // from the client-side in order to complete the registration.
53586
- const registryAcc = new XrplAccount(this.config.registryAddress, null, { xrplApi: this.xrplApi });
53587
- const regUriToken = await this.getRegistrationUriToken();
53588
-
53589
- if (!regUriToken) {
53590
- const regInfo = await this.getHostInfo(this.xrplAcc.address);
53591
- if (regInfo) {
53592
- const sellOffer = (await registryAcc.getURITokens()).find(o => o.index == regInfo.uriTokenId && o.Amount);
53593
- console.log('sell offer')
53594
- if (sellOffer) {
53595
- await this.xrplAcc.buyURIToken(sellOffer, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53596
- console.log("Registration was successfully completed after acquiring the NFT.");
53597
- return await this.isRegistered();
53598
- }
53599
- }
53600
- }
53752
+ if (await this.acceptRegToken())
53753
+ return true;
53601
53754
 
53602
53755
  // Check the availability of an initiated transfer.
53603
53756
  // Need to modify the amount accordingly.
@@ -53632,21 +53785,25 @@ class HostClient extends BaseEvernodeClient {
53632
53785
  Buffer.from(description.substr(0, 26), "utf-8").copy(paramBuf, HOST_DESCRIPTION_PARAM_OFFSET);
53633
53786
  Buffer.from(emailAddress.substr(0, 40), "utf-8").copy(paramBuf, HOST_EMAIL_ADDRESS_PARAM_OFFSET);
53634
53787
 
53635
- const tx = await this.xrplAcc.makePayment(this.config.registryAddress,
53636
- (transferredNFTokenId) ? EvernodeConstants.NOW_IN_EVRS : this.config.hostRegFee.toString(),
53637
- EvernodeConstants.EVR,
53638
- this.config.evrIssuerAddress,
53639
- null,
53640
- {
53641
- hookParams: [
53642
- { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_REG },
53643
- { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
53644
- ],
53645
- maxLedgerIndex: this.#getMaxLedgerSequence(),
53646
- ...options.transactionOptions
53647
- });
53788
+ const tx = await this.#submitWithRetry(async (feeUplift) => {
53789
+ return await this.xrplAcc.makePayment(this.config.registryAddress,
53790
+ (transferredNFTokenId) ? EvernodeConstants.NOW_IN_EVRS : this.config.hostRegFee.toString(),
53791
+ EvernodeConstants.EVR,
53792
+ this.config.evrIssuerAddress,
53793
+ null,
53794
+ {
53795
+ hookParams: [
53796
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_REG },
53797
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
53798
+ ],
53799
+ maxLedgerIndex: this.#getMaxLedgerSequence(),
53800
+ feeUplift: feeUplift,
53801
+ ...options.transactionOptions
53802
+ });
53803
+ }, options.retryOptions);
53648
53804
 
53649
53805
  console.log('Waiting for the sell offer', tx.id)
53806
+ const registryAcc = new XrplAccount(this.config.registryAddress, null, { xrplApi: this.xrplApi });
53650
53807
  let sellOffer = null;
53651
53808
  let attempts = 0;
53652
53809
  let offerLedgerIndex = 0;
@@ -53681,7 +53838,9 @@ class HostClient extends BaseEvernodeClient {
53681
53838
  resolve();
53682
53839
  });
53683
53840
 
53684
- await this.xrplAcc.buyURIToken(sellOffer, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
53841
+ await this.#submitWithRetry(async (feeUplift) => {
53842
+ await this.xrplAcc.buyURIToken(sellOffer, null, { maxLedgerIndex: this.#getMaxLedgerSequence(), feeUplift: feeUplift });
53843
+ }, options.retryOptions);
53685
53844
  return await this.isRegistered();
53686
53845
  }
53687
53846
 
@@ -53704,19 +53863,22 @@ class HostClient extends BaseEvernodeClient {
53704
53863
  paramBuf.writeUInt8(1, 32);
53705
53864
  }
53706
53865
 
53707
- await this.xrplAcc.makePayment(this.config.registryAddress,
53708
- XrplConstants.MIN_DROPS,
53709
- null,
53710
- null,
53711
- null,
53712
- {
53713
- hookParams: [
53714
- { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_DEREG },
53715
- { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
53716
- ],
53717
- maxLedgerIndex: this.#getMaxLedgerSequence(),
53718
- ...options.transactionOptions
53719
- });
53866
+ await this.#submitWithRetry(async (feeUplift) => {
53867
+ await this.xrplAcc.makePayment(this.config.registryAddress,
53868
+ XrplConstants.MIN_DROPS,
53869
+ null,
53870
+ null,
53871
+ null,
53872
+ {
53873
+ hookParams: [
53874
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_DEREG },
53875
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
53876
+ ],
53877
+ maxLedgerIndex: this.#getMaxLedgerSequence(),
53878
+ feeUplift: feeUplift,
53879
+ ...options.transactionOptions
53880
+ });
53881
+ }, options.retryOptions);
53720
53882
 
53721
53883
  return await this.isRegistered();
53722
53884
  }
@@ -53766,19 +53928,23 @@ class HostClient extends BaseEvernodeClient {
53766
53928
  paramBuf.writeUInt8(components[2], HOST_UPDATE_VERSION_PARAM_OFFSET + 2);
53767
53929
  }
53768
53930
 
53769
- return await this.xrplAcc.makePayment(this.config.registryAddress,
53770
- XrplConstants.MIN_DROPS,
53771
- null,
53772
- null,
53773
- null,
53774
- {
53775
- hookParams: [
53776
- { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_UPDATE_INFO },
53777
- { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex') }
53778
- ],
53779
- maxLedgerIndex: this.#getMaxLedgerSequence(),
53780
- ...options.transactionOptions
53781
- });
53931
+ return await this.#submitWithRetry(async (feeUplift) => {
53932
+ return await this.xrplAcc.makePayment(this.config.registryAddress,
53933
+ XrplConstants.MIN_DROPS,
53934
+ null,
53935
+ null,
53936
+ null,
53937
+ {
53938
+ hookParams: [
53939
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_UPDATE_INFO },
53940
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex') }
53941
+ ],
53942
+ maxLedgerIndex: this.#getMaxLedgerSequence(),
53943
+ feeUplift: feeUplift,
53944
+ ...options.transactionOptions
53945
+ });
53946
+ }, options.retryOptions);
53947
+
53782
53948
  }
53783
53949
 
53784
53950
  /**
@@ -54036,20 +54202,23 @@ class HostClient extends BaseEvernodeClient {
54036
54202
 
54037
54203
  const regUriToken = await this.getRegistrationUriToken();
54038
54204
 
54039
- await this.xrplAcc.sellURIToken(regUriToken.index,
54040
- XrplConstants.MIN_DROPS,
54041
- null,
54042
- null,
54043
- this.config.registryAddress,
54044
- null,
54045
- {
54046
- hookParams: [
54047
- { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_TRANSFER },
54048
- { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramData.toString('hex') }
54049
- ],
54050
- maxLedgerIndex: this.#getMaxLedgerSequence(),
54051
- ...options.transactionOptions
54052
- });
54205
+ await this.#submitWithRetry(async (feeUplift) => {
54206
+ await this.xrplAcc.sellURIToken(regUriToken.index,
54207
+ XrplConstants.MIN_DROPS,
54208
+ null,
54209
+ null,
54210
+ this.config.registryAddress,
54211
+ null,
54212
+ {
54213
+ hookParams: [
54214
+ { name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_TRANSFER },
54215
+ { name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramData.toString('hex') }
54216
+ ],
54217
+ maxLedgerIndex: this.#getMaxLedgerSequence(),
54218
+ feeUplift: feeUplift,
54219
+ ...options.transactionOptions
54220
+ });
54221
+ }, options.retryOptions);
54053
54222
 
54054
54223
  let token = null;
54055
54224
  let attempts = 0;
@@ -55181,11 +55350,21 @@ const { TransactionHelper } = __nccwpck_require__(7071);
55181
55350
  const NFT_PAGE_LEDGER_ENTRY_TYPE_HEX = '0050';
55182
55351
 
55183
55352
  class EvernodeHelpers {
55353
+ static async getLeases(xrplAcc) {
55354
+ const hostUriOffers = (await xrplAcc.getURITokens()).filter(uriToken => uriToken.Issuer == xrplAcc.address && this.isValidURI(uriToken.URI, EvernodeConstants.LEASE_TOKEN_PREFIX_HEX) && uriToken.Flags == 1);
55355
+ return hostUriOffers;
55356
+ }
55357
+
55184
55358
  static async getLeaseOffers(xrplAcc) {
55185
- const hostUriOffers = (await xrplAcc.getURITokens()).filter(uriToken => uriToken.Issuer == xrplAcc.address && this.isValidURI(uriToken.URI, EvernodeConstants.LEASE_TOKEN_PREFIX_HEX) && uriToken.Flags == 1 && uriToken.Amount);
55359
+ const hostUriOffers = (await this.getLeases(xrplAcc)).filter(uriToken => uriToken.Amount);
55186
55360
  return hostUriOffers;
55187
55361
  }
55188
55362
 
55363
+ static async getUnofferedLeases(xrplAcc) {
55364
+ const hostUriTokens = (await this.getLeases(xrplAcc)).filter(uriToken => !uriToken.Amount);
55365
+ return hostUriTokens
55366
+ }
55367
+
55189
55368
  static async getNFTPageAndLocation(nfTokenId, xrplAcc, xrplApi, buffer = true) {
55190
55369
 
55191
55370
  const nftPageApprxKeylet = xrplAcc.generateKeylet('nftPage', { nfTokenId: nfTokenId });
@@ -57939,8 +58118,11 @@ class XrplApi {
57939
58118
  const latestLedger = await this.#getLedgerIndex();
57940
58119
 
57941
58120
  if (lastLedger < latestLedger) {
57942
- throw `The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${lastLedger}).\n` +
57943
- `Preliminary result: ${JSON.stringify(submissionResult, null, 2)}`;
58121
+ throw {
58122
+ status: 'TOOK_LONG',
58123
+ error: `The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${lastLedger})`,
58124
+ ...submissionResult
58125
+ };
57944
58126
  }
57945
58127
 
57946
58128
  const txResponse = await this.getTxnInfo(txHash)
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.31",
9
+ "version": "0.6.32",
10
10
  "dependencies": {
11
11
  "elliptic": "6.5.4",
12
12
  "libsodium-wrappers": "0.7.10",