@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.mjs CHANGED
@@ -936,6 +936,25 @@ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVA
936
936
  return tryRequest();
937
937
  };
938
938
 
939
+ // src/utils/indexer.ts
940
+ async function callMethodWithIndexerFallback(method, context, ...args) {
941
+ const indexer = args[args.length - 1];
942
+ if (indexer) {
943
+ try {
944
+ return await method.apply(context, args);
945
+ } catch (_e) {
946
+ console.warn("Indexer requests failed. Retrying without indexer..");
947
+ return await method.apply(context, [...args.slice(0, -1), false]);
948
+ }
949
+ }
950
+ return await method.apply(context, args);
951
+ }
952
+ function withIndexerFallback(method) {
953
+ return (...args) => {
954
+ return callMethodWithIndexerFallback(method, this, ...args);
955
+ };
956
+ }
957
+
939
958
  // src/models/scallopCache.ts
940
959
  var ScallopCache = class {
941
960
  constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
@@ -4306,7 +4325,8 @@ var ScallopUtils = class {
4306
4325
  this.address = instance?.address ?? new ScallopAddress(
4307
4326
  {
4308
4327
  id: params?.addressesId || ADDRESSES_ID,
4309
- network: params?.networkType
4328
+ network: params?.networkType,
4329
+ forceInterface: params?.forceAddressesInterface
4310
4330
  },
4311
4331
  {
4312
4332
  cache: this.cache
@@ -6626,7 +6646,8 @@ var ScallopQuery = class {
6626
6646
  this.address = new ScallopAddress(
6627
6647
  {
6628
6648
  id: params?.addressesId || ADDRESSES_ID,
6629
- network: params?.networkType
6649
+ network: params?.networkType,
6650
+ forceInterface: params?.forceAddressesInterface
6630
6651
  },
6631
6652
  {
6632
6653
  cache: this.cache
@@ -6637,7 +6658,36 @@ var ScallopQuery = class {
6637
6658
  });
6638
6659
  }
6639
6660
  this.indexer = instance?.indexer ?? new ScallopIndexer(this.params, { cache: this.cache });
6661
+ this.queryMarket = withIndexerFallback.call(this, this.queryMarket);
6662
+ this.getMarketPools = withIndexerFallback.call(this, this.getMarketPools);
6663
+ this.getMarketPool = withIndexerFallback.call(this, this.getMarketPool);
6664
+ this.getMarketCollaterals = withIndexerFallback.call(
6665
+ this,
6666
+ this.getMarketCollaterals
6667
+ );
6668
+ this.getMarketCollateral = withIndexerFallback.call(
6669
+ this,
6670
+ this.getMarketCollateral
6671
+ );
6672
+ this.getSpools = withIndexerFallback.call(this, this.getSpools);
6673
+ this.getSpool = withIndexerFallback.call(this, this.getSpool);
6674
+ this.getBorrowIncentivePools = withIndexerFallback.call(
6675
+ this,
6676
+ this.getBorrowIncentivePools
6677
+ );
6678
+ this.getLendings = withIndexerFallback.call(this, this.getLendings);
6679
+ this.getLending = withIndexerFallback.call(this, this.getLending);
6680
+ this.getObligationAccounts = withIndexerFallback.call(
6681
+ this,
6682
+ this.getObligationAccounts
6683
+ );
6684
+ this.getObligationAccount = withIndexerFallback.call(
6685
+ this,
6686
+ this.getObligationAccount
6687
+ );
6688
+ this.getTvl = withIndexerFallback.call(this, this.getTvl);
6640
6689
  }
6690
+ /* ========================================================== */
6641
6691
  /**
6642
6692
  * Request the scallop API to initialize data.
6643
6693
  *
@@ -7117,7 +7167,8 @@ var ScallopBuilder = class {
7117
7167
  this.address = new ScallopAddress(
7118
7168
  {
7119
7169
  id: params?.addressesId || ADDRESSES_ID,
7120
- network: params?.networkType
7170
+ network: params?.networkType,
7171
+ forceInterface: params?.forceAddressesInterface
7121
7172
  },
7122
7173
  {
7123
7174
  cache: this.cache
@@ -7264,8 +7315,8 @@ var ScallopClient = class {
7264
7315
  this.address = new ScallopAddress(
7265
7316
  {
7266
7317
  id: params?.addressesId || ADDRESSES_ID,
7267
- forceInterface: params?.forceAddressesInterface,
7268
- network: params?.networkType
7318
+ network: params?.networkType,
7319
+ forceInterface: params?.forceAddressesInterface
7269
7320
  },
7270
7321
  {
7271
7322
  cache: this.cache