evernode-js-client 0.6.31 → 0.6.33

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