@scallop-io/sui-scallop-sdk 0.47.5 → 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 +70 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -6
- package/dist/index.mjs.map +1 -1
- package/dist/types/model.d.ts +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/package.json +1 -1
- package/src/models/scallop.ts +1 -0
- package/src/models/scallopAddress.ts +13 -1
- package/src/models/scallopBuilder.ts +1 -0
- package/src/models/scallopClient.ts +1 -0
- package/src/models/scallopQuery.ts +34 -0
- package/src/models/scallopUtils.ts +1 -0
- package/src/types/model.ts +3 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/indexer.ts +39 -0
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) {
|
|
@@ -1932,7 +1951,7 @@ var EMPTY_ADDRESSES = {
|
|
|
1932
1951
|
};
|
|
1933
1952
|
var ScallopAddress = class {
|
|
1934
1953
|
constructor(params, instance) {
|
|
1935
|
-
const { id, auth, network } = params;
|
|
1954
|
+
const { id, auth, network, forceInterface } = params;
|
|
1936
1955
|
this.cache = instance?.cache ?? new ScallopCache(
|
|
1937
1956
|
instance?.suiKit ?? new SuiKit({}),
|
|
1938
1957
|
void 0,
|
|
@@ -1953,6 +1972,17 @@ var ScallopAddress = class {
|
|
|
1953
1972
|
this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
|
|
1954
1973
|
if (USE_TEST_ADDRESS)
|
|
1955
1974
|
this._currentAddresses = TEST_ADDRESSES;
|
|
1975
|
+
if (forceInterface) {
|
|
1976
|
+
for (const [network2, addresses] of Object.entries(
|
|
1977
|
+
forceInterface
|
|
1978
|
+
)) {
|
|
1979
|
+
if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
|
|
1980
|
+
if (network2 === this._network)
|
|
1981
|
+
this._currentAddresses = addresses;
|
|
1982
|
+
this._addressesMap.set(network2, addresses);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1956
1986
|
}
|
|
1957
1987
|
/**
|
|
1958
1988
|
* Get addresses API id.
|
|
@@ -4295,7 +4325,8 @@ var ScallopUtils = class {
|
|
|
4295
4325
|
this.address = instance?.address ?? new ScallopAddress(
|
|
4296
4326
|
{
|
|
4297
4327
|
id: params?.addressesId || ADDRESSES_ID,
|
|
4298
|
-
network: params?.networkType
|
|
4328
|
+
network: params?.networkType,
|
|
4329
|
+
forceInterface: params?.forceAddressesInterface
|
|
4299
4330
|
},
|
|
4300
4331
|
{
|
|
4301
4332
|
cache: this.cache
|
|
@@ -6615,7 +6646,8 @@ var ScallopQuery = class {
|
|
|
6615
6646
|
this.address = new ScallopAddress(
|
|
6616
6647
|
{
|
|
6617
6648
|
id: params?.addressesId || ADDRESSES_ID,
|
|
6618
|
-
network: params?.networkType
|
|
6649
|
+
network: params?.networkType,
|
|
6650
|
+
forceInterface: params?.forceAddressesInterface
|
|
6619
6651
|
},
|
|
6620
6652
|
{
|
|
6621
6653
|
cache: this.cache
|
|
@@ -6626,7 +6658,36 @@ var ScallopQuery = class {
|
|
|
6626
6658
|
});
|
|
6627
6659
|
}
|
|
6628
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);
|
|
6629
6689
|
}
|
|
6690
|
+
/* ========================================================== */
|
|
6630
6691
|
/**
|
|
6631
6692
|
* Request the scallop API to initialize data.
|
|
6632
6693
|
*
|
|
@@ -7106,7 +7167,8 @@ var ScallopBuilder = class {
|
|
|
7106
7167
|
this.address = new ScallopAddress(
|
|
7107
7168
|
{
|
|
7108
7169
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7109
|
-
network: params?.networkType
|
|
7170
|
+
network: params?.networkType,
|
|
7171
|
+
forceInterface: params?.forceAddressesInterface
|
|
7110
7172
|
},
|
|
7111
7173
|
{
|
|
7112
7174
|
cache: this.cache
|
|
@@ -7253,7 +7315,8 @@ var ScallopClient = class {
|
|
|
7253
7315
|
this.address = new ScallopAddress(
|
|
7254
7316
|
{
|
|
7255
7317
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7256
|
-
network: params?.networkType
|
|
7318
|
+
network: params?.networkType,
|
|
7319
|
+
forceInterface: params?.forceAddressesInterface
|
|
7257
7320
|
},
|
|
7258
7321
|
{
|
|
7259
7322
|
cache: this.cache
|
|
@@ -7916,7 +7979,8 @@ var Scallop = class {
|
|
|
7916
7979
|
this.address = new ScallopAddress(
|
|
7917
7980
|
{
|
|
7918
7981
|
id: params?.addressesId || ADDRESSES_ID,
|
|
7919
|
-
network: params?.networkType
|
|
7982
|
+
network: params?.networkType,
|
|
7983
|
+
forceInterface: params?.forceAddressesInterface
|
|
7920
7984
|
},
|
|
7921
7985
|
{ cache: this.cache }
|
|
7922
7986
|
);
|