@scallop-io/sui-scallop-sdk 0.47.6 → 0.47.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1013,6 +1013,25 @@ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVA
1013
1013
  return tryRequest();
1014
1014
  };
1015
1015
 
1016
+ // src/utils/indexer.ts
1017
+ async function callMethodWithIndexerFallback(method, context, ...args) {
1018
+ const indexer = args[args.length - 1];
1019
+ if (indexer) {
1020
+ try {
1021
+ return await method.apply(context, args);
1022
+ } catch (_e) {
1023
+ console.warn("Indexer requests failed. Retrying without indexer..");
1024
+ return await method.apply(context, [...args.slice(0, -1), false]);
1025
+ }
1026
+ }
1027
+ return await method.apply(context, args);
1028
+ }
1029
+ function withIndexerFallback(method) {
1030
+ return (...args) => {
1031
+ return callMethodWithIndexerFallback(method, this, ...args);
1032
+ };
1033
+ }
1034
+
1016
1035
  // src/models/scallopCache.ts
1017
1036
  var ScallopCache = class {
1018
1037
  constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
@@ -4383,7 +4402,8 @@ var ScallopUtils = class {
4383
4402
  this.address = instance?.address ?? new ScallopAddress(
4384
4403
  {
4385
4404
  id: params?.addressesId || ADDRESSES_ID,
4386
- network: params?.networkType
4405
+ network: params?.networkType,
4406
+ forceInterface: params?.forceAddressesInterface
4387
4407
  },
4388
4408
  {
4389
4409
  cache: this.cache
@@ -6689,7 +6709,8 @@ var ScallopQuery = class {
6689
6709
  this.address = new ScallopAddress(
6690
6710
  {
6691
6711
  id: params?.addressesId || ADDRESSES_ID,
6692
- network: params?.networkType
6712
+ network: params?.networkType,
6713
+ forceInterface: params?.forceAddressesInterface
6693
6714
  },
6694
6715
  {
6695
6716
  cache: this.cache
@@ -6700,7 +6721,36 @@ var ScallopQuery = class {
6700
6721
  });
6701
6722
  }
6702
6723
  this.indexer = instance?.indexer ?? new ScallopIndexer(this.params, { cache: this.cache });
6724
+ this.queryMarket = withIndexerFallback.call(this, this.queryMarket);
6725
+ this.getMarketPools = withIndexerFallback.call(this, this.getMarketPools);
6726
+ this.getMarketPool = withIndexerFallback.call(this, this.getMarketPool);
6727
+ this.getMarketCollaterals = withIndexerFallback.call(
6728
+ this,
6729
+ this.getMarketCollaterals
6730
+ );
6731
+ this.getMarketCollateral = withIndexerFallback.call(
6732
+ this,
6733
+ this.getMarketCollateral
6734
+ );
6735
+ this.getSpools = withIndexerFallback.call(this, this.getSpools);
6736
+ this.getSpool = withIndexerFallback.call(this, this.getSpool);
6737
+ this.getBorrowIncentivePools = withIndexerFallback.call(
6738
+ this,
6739
+ this.getBorrowIncentivePools
6740
+ );
6741
+ this.getLendings = withIndexerFallback.call(this, this.getLendings);
6742
+ this.getLending = withIndexerFallback.call(this, this.getLending);
6743
+ this.getObligationAccounts = withIndexerFallback.call(
6744
+ this,
6745
+ this.getObligationAccounts
6746
+ );
6747
+ this.getObligationAccount = withIndexerFallback.call(
6748
+ this,
6749
+ this.getObligationAccount
6750
+ );
6751
+ this.getTvl = withIndexerFallback.call(this, this.getTvl);
6703
6752
  }
6753
+ /* ========================================================== */
6704
6754
  /**
6705
6755
  * Request the scallop API to initialize data.
6706
6756
  *
@@ -7180,7 +7230,8 @@ var ScallopBuilder = class {
7180
7230
  this.address = new ScallopAddress(
7181
7231
  {
7182
7232
  id: params?.addressesId || ADDRESSES_ID,
7183
- network: params?.networkType
7233
+ network: params?.networkType,
7234
+ forceInterface: params?.forceAddressesInterface
7184
7235
  },
7185
7236
  {
7186
7237
  cache: this.cache
@@ -7327,8 +7378,8 @@ var ScallopClient = class {
7327
7378
  this.address = new ScallopAddress(
7328
7379
  {
7329
7380
  id: params?.addressesId || ADDRESSES_ID,
7330
- forceInterface: params?.forceAddressesInterface,
7331
- network: params?.networkType
7381
+ network: params?.networkType,
7382
+ forceInterface: params?.forceAddressesInterface
7332
7383
  },
7333
7384
  {
7334
7385
  cache: this.cache