@scallop-io/sui-scallop-sdk 1.3.2-alpha.1 → 1.3.2-alpha.3

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
@@ -1068,10 +1068,11 @@ var ScallopCache = class {
1068
1068
  * - `all`: All queries that match the refetch predicate will be refetched in the background.
1069
1069
  * - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
1070
1070
  */
1071
- invalidateAllCache() {
1071
+ async invalidateAllCache() {
1072
1072
  return Object.values(queryKeys.rpc).map(
1073
1073
  (t) => this.queryClient.invalidateQueries({
1074
- queryKey: t()
1074
+ queryKey: t(),
1075
+ type: "all"
1075
1076
  })
1076
1077
  );
1077
1078
  }
@@ -1095,8 +1096,7 @@ var ScallopCache = class {
1095
1096
  this.tokenBucket,
1096
1097
  () => this.suiKit.inspectTxn(txBlock)
1097
1098
  );
1098
- },
1099
- ...DEFAULT_CACHE_OPTIONS.defaultOptions.queries
1099
+ }
1100
1100
  });
1101
1101
  return query;
1102
1102
  }
@@ -1117,8 +1117,7 @@ var ScallopCache = class {
1117
1117
  options
1118
1118
  })
1119
1119
  );
1120
- },
1121
- ...DEFAULT_CACHE_OPTIONS.defaultOptions.queries
1120
+ }
1122
1121
  });
1123
1122
  }
1124
1123
  /**
@@ -1142,8 +1141,7 @@ var ScallopCache = class {
1142
1141
  this.tokenBucket,
1143
1142
  () => this.suiKit.getObjects(objectIds, options)
1144
1143
  );
1145
- },
1146
- ...DEFAULT_CACHE_OPTIONS.defaultOptions.queries
1144
+ }
1147
1145
  });
1148
1146
  }
1149
1147
  /**
@@ -1159,8 +1157,7 @@ var ScallopCache = class {
1159
1157
  this.tokenBucket,
1160
1158
  () => this.client.getOwnedObjects(input)
1161
1159
  );
1162
- },
1163
- ...DEFAULT_CACHE_OPTIONS.defaultOptions.queries
1160
+ }
1164
1161
  });
1165
1162
  }
1166
1163
  async queryGetDynamicFields(input) {
@@ -1171,8 +1168,7 @@ var ScallopCache = class {
1171
1168
  this.tokenBucket,
1172
1169
  () => this.client.getDynamicFields(input)
1173
1170
  );
1174
- },
1175
- ...DEFAULT_CACHE_OPTIONS.defaultOptions.queries
1171
+ }
1176
1172
  });
1177
1173
  }
1178
1174
  async queryGetDynamicFieldObject(input) {
@@ -1183,8 +1179,7 @@ var ScallopCache = class {
1183
1179
  this.tokenBucket,
1184
1180
  () => this.client.getDynamicFieldObject(input)
1185
1181
  );
1186
- },
1187
- ...DEFAULT_CACHE_OPTIONS.defaultOptions.queries
1182
+ }
1188
1183
  });
1189
1184
  }
1190
1185
  async queryGetAllCoinBalances(owner) {
@@ -3174,7 +3169,8 @@ var getStakeAccounts = async ({
3174
3169
  owner,
3175
3170
  filter: { StructType: stakeAccountType },
3176
3171
  options: {
3177
- showContent: true
3172
+ showContent: true,
3173
+ showType: true
3178
3174
  },
3179
3175
  cursor: nextCursor,
3180
3176
  limit: 10
@@ -3212,15 +3208,10 @@ var getStakeAccounts = async ({
3212
3208
  },
3213
3209
  {}
3214
3210
  );
3215
- const stakeObjectIds = stakeObjectsResponse.map((ref) => ref?.data?.objectId).filter((id) => id !== void 0);
3216
- const stakeObjects = await utils.cache.queryGetObjects(stakeObjectIds, {
3217
- showContent: true,
3218
- showType: true
3219
- });
3220
- for (const stakeObject of stakeObjects) {
3221
- const id = stakeObject.objectId;
3222
- const type = stakeObject.type;
3223
- if (stakeObject.content && "fields" in stakeObject.content) {
3211
+ for (const stakeObject of stakeObjectsResponse.map((ref) => ref.data)) {
3212
+ const id = stakeObject?.objectId;
3213
+ const type = stakeObject?.type;
3214
+ if (id && stakeObject?.content && "fields" in stakeObject.content) {
3224
3215
  const fields = stakeObject.content.fields;
3225
3216
  const stakePoolId = String(fields.spool_id);
3226
3217
  const stakeType = String(fields.stake_type.fields.name);
@@ -4717,6 +4708,11 @@ var ScallopUtils = class {
4717
4708
  existPricesCoinNames.push(assetCoinName);
4718
4709
  } else {
4719
4710
  lackPricesCoinNames.push(assetCoinName);
4711
+ this.cache.queryClient.invalidateQueries({
4712
+ queryKey: queryKeys.oracle.getPythLatestPriceFeed(
4713
+ this.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
4714
+ )
4715
+ });
4720
4716
  }
4721
4717
  });
4722
4718
  if (existPricesCoinNames.length > 0) {
@@ -4744,7 +4740,7 @@ var ScallopUtils = class {
4744
4740
  Object.entries(priceIds).map(async ([coinName, priceId]) => {
4745
4741
  const pythConnection = new SuiPriceServiceConnection(endpoint);
4746
4742
  try {
4747
- const feed = await this.address.cache.queryClient.fetchQuery({
4743
+ const feed = await this.cache.queryClient.fetchQuery({
4748
4744
  queryKey: queryKeys.oracle.getPythLatestPriceFeed(priceId),
4749
4745
  queryFn: async () => {
4750
4746
  return await pythConnection.getLatestPriceFeeds([priceId]);