@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.js +21 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -25
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopCache.d.ts +1 -1
- package/package.json +1 -1
- package/src/models/scallopCache.ts +2 -7
- package/src/models/scallopUtils.ts +6 -1
- package/src/queries/spoolQuery.ts +12 -11
|
@@ -37,7 +37,7 @@ export declare class ScallopCache {
|
|
|
37
37
|
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
38
38
|
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
39
39
|
*/
|
|
40
|
-
invalidateAllCache(): Promise<void>[]
|
|
40
|
+
invalidateAllCache(): Promise<Promise<void>[]>;
|
|
41
41
|
/**
|
|
42
42
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
43
43
|
* @param QueryInspectTxnParams
|
package/package.json
CHANGED
|
@@ -97,10 +97,11 @@ export class ScallopCache {
|
|
|
97
97
|
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
98
98
|
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
99
99
|
*/
|
|
100
|
-
public invalidateAllCache() {
|
|
100
|
+
public async invalidateAllCache() {
|
|
101
101
|
return Object.values(queryKeys.rpc).map((t) =>
|
|
102
102
|
this.queryClient.invalidateQueries({
|
|
103
103
|
queryKey: t(),
|
|
104
|
+
type: 'all',
|
|
104
105
|
})
|
|
105
106
|
);
|
|
106
107
|
}
|
|
@@ -127,7 +128,6 @@ export class ScallopCache {
|
|
|
127
128
|
this.suiKit.inspectTxn(txBlock)
|
|
128
129
|
);
|
|
129
130
|
},
|
|
130
|
-
...DEFAULT_CACHE_OPTIONS.defaultOptions.queries,
|
|
131
131
|
});
|
|
132
132
|
return query;
|
|
133
133
|
}
|
|
@@ -152,7 +152,6 @@ export class ScallopCache {
|
|
|
152
152
|
})
|
|
153
153
|
);
|
|
154
154
|
},
|
|
155
|
-
...DEFAULT_CACHE_OPTIONS.defaultOptions.queries,
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
157
|
|
|
@@ -181,7 +180,6 @@ export class ScallopCache {
|
|
|
181
180
|
this.suiKit.getObjects(objectIds, options)
|
|
182
181
|
);
|
|
183
182
|
},
|
|
184
|
-
...DEFAULT_CACHE_OPTIONS.defaultOptions.queries,
|
|
185
183
|
});
|
|
186
184
|
}
|
|
187
185
|
|
|
@@ -198,7 +196,6 @@ export class ScallopCache {
|
|
|
198
196
|
this.client.getOwnedObjects(input)
|
|
199
197
|
);
|
|
200
198
|
},
|
|
201
|
-
...DEFAULT_CACHE_OPTIONS.defaultOptions.queries,
|
|
202
199
|
});
|
|
203
200
|
}
|
|
204
201
|
|
|
@@ -212,7 +209,6 @@ export class ScallopCache {
|
|
|
212
209
|
this.client.getDynamicFields(input)
|
|
213
210
|
);
|
|
214
211
|
},
|
|
215
|
-
...DEFAULT_CACHE_OPTIONS.defaultOptions.queries,
|
|
216
212
|
});
|
|
217
213
|
}
|
|
218
214
|
|
|
@@ -226,7 +222,6 @@ export class ScallopCache {
|
|
|
226
222
|
this.client.getDynamicFieldObject(input)
|
|
227
223
|
);
|
|
228
224
|
},
|
|
229
|
-
...DEFAULT_CACHE_OPTIONS.defaultOptions.queries,
|
|
230
225
|
});
|
|
231
226
|
}
|
|
232
227
|
|
|
@@ -524,6 +524,11 @@ export class ScallopUtils {
|
|
|
524
524
|
existPricesCoinNames.push(assetCoinName);
|
|
525
525
|
} else {
|
|
526
526
|
lackPricesCoinNames.push(assetCoinName);
|
|
527
|
+
this.cache.queryClient.invalidateQueries({
|
|
528
|
+
queryKey: queryKeys.oracle.getPythLatestPriceFeed(
|
|
529
|
+
this.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
|
|
530
|
+
),
|
|
531
|
+
});
|
|
527
532
|
}
|
|
528
533
|
});
|
|
529
534
|
|
|
@@ -558,7 +563,7 @@ export class ScallopUtils {
|
|
|
558
563
|
Object.entries(priceIds).map(async ([coinName, priceId]) => {
|
|
559
564
|
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
560
565
|
try {
|
|
561
|
-
const feed = await this.
|
|
566
|
+
const feed = await this.cache.queryClient.fetchQuery({
|
|
562
567
|
queryKey: queryKeys.oracle.getPythLatestPriceFeed(priceId),
|
|
563
568
|
queryFn: async () => {
|
|
564
569
|
return await pythConnection.getLatestPriceFeeds([priceId]);
|
|
@@ -254,6 +254,7 @@ export const getStakeAccounts = async (
|
|
|
254
254
|
filter: { StructType: stakeAccountType },
|
|
255
255
|
options: {
|
|
256
256
|
showContent: true,
|
|
257
|
+
showType: true,
|
|
257
258
|
},
|
|
258
259
|
cursor: nextCursor,
|
|
259
260
|
limit: 10,
|
|
@@ -304,17 +305,17 @@ export const getStakeAccounts = async (
|
|
|
304
305
|
{} as Record<string, SupportStakeMarketCoins>
|
|
305
306
|
);
|
|
306
307
|
|
|
307
|
-
const stakeObjectIds: string[] = stakeObjectsResponse
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const stakeObjects = await utils.cache.queryGetObjects(stakeObjectIds, {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
});
|
|
314
|
-
for (const stakeObject of
|
|
315
|
-
const id = stakeObject
|
|
316
|
-
const type = stakeObject
|
|
317
|
-
if (stakeObject
|
|
308
|
+
// const stakeObjectIds: string[] = stakeObjectsResponse
|
|
309
|
+
// .map((ref: any) => ref?.data?.objectId)
|
|
310
|
+
// .filter((id: any) => id !== undefined);
|
|
311
|
+
// const stakeObjects = await utils.cache.queryGetObjects(stakeObjectIds, {
|
|
312
|
+
// showContent: true,
|
|
313
|
+
// showType: true,
|
|
314
|
+
// });
|
|
315
|
+
for (const stakeObject of stakeObjectsResponse.map((ref) => ref.data)) {
|
|
316
|
+
const id = stakeObject?.objectId;
|
|
317
|
+
const type = stakeObject?.type!;
|
|
318
|
+
if (id && stakeObject?.content && 'fields' in stakeObject.content) {
|
|
318
319
|
const fields = stakeObject.content.fields as any;
|
|
319
320
|
const stakePoolId = String(fields.spool_id);
|
|
320
321
|
const stakeType = String(fields.stake_type.fields.name);
|