@scallop-io/sui-scallop-sdk 2.3.8 → 2.3.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.3.8",
3
+ "version": "2.3.9",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -33,6 +33,7 @@ type QueryInspectTxnParams = {
33
33
  args: SuiObjectArg[];
34
34
  typeArgs?: any[];
35
35
  txBlock?: SuiTxBlock;
36
+ keys?: QueryKey;
36
37
  };
37
38
 
38
39
  export type ScallopSuiKitParams = {
@@ -354,6 +355,7 @@ class ScallopSuiKit extends ScallopQueryClient {
354
355
  args,
355
356
  typeArgs,
356
357
  txBlock = new SuiTxBlock(),
358
+ keys,
357
359
  }: QueryInspectTxnParams): Promise<DevInspectResults | null> {
358
360
  const resolvedQueryTarget =
359
361
  await this.queryGetNormalizedMoveFunction(queryTarget);
@@ -372,12 +374,15 @@ class ScallopSuiKit extends ScallopQueryClient {
372
374
  txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
373
375
 
374
376
  return await this.callWithRateLimiter(
375
- queryKeys.rpc.getInspectTxn({
376
- queryTarget,
377
- args,
378
- typeArgs,
379
- node: this.currentFullNode,
380
- }),
377
+ keys ??
378
+ queryKeys.rpc.getInspectTxn({
379
+ queryTarget,
380
+ args: args.map((arg) =>
381
+ typeof arg === 'object' && 'objectId' in arg ? arg.objectId : arg
382
+ ),
383
+ typeArgs,
384
+ node: this.currentFullNode,
385
+ }),
381
386
  () => this.suiKit.inspectTxn(txBlock)
382
387
  );
383
388
  }
@@ -24,6 +24,7 @@ import type {
24
24
  import BigNumber from 'bignumber.js';
25
25
  import { SuiObjectRef } from '@mysten/sui/client';
26
26
  import { SuiTxBlock } from '@scallop-io/sui-kit';
27
+ import { queryKeys } from 'src/constants';
27
28
 
28
29
  /**
29
30
  * Query borrow incentive pools data using moveCall
@@ -53,6 +54,11 @@ export const queryBorrowIncentivePools = async ({
53
54
  queryTarget,
54
55
  args,
55
56
  txBlock,
57
+ keys: queryKeys.rpc.getInspectTxn({
58
+ queryTarget,
59
+ args: [incentivePoolsId],
60
+ node: scallopSuiKit.currentFullNode,
61
+ }),
56
62
  });
57
63
  const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson as
58
64
  | BorrowIncentivePoolsQueryInterface
@@ -188,7 +194,7 @@ export const queryBorrowIncentiveAccounts = async (
188
194
  mutable: true,
189
195
  }),
190
196
  txBlock.sharedObjectRef({
191
- ...(await getSharedObjectData(obligationId)),
197
+ ...(await getSharedObjectData(obligationId, utils.scallopSuiKit.client)),
192
198
  mutable: true,
193
199
  }),
194
200
  ];
@@ -197,6 +203,11 @@ export const queryBorrowIncentiveAccounts = async (
197
203
  queryTarget,
198
204
  args,
199
205
  txBlock,
206
+ keys: queryKeys.rpc.getInspectTxn({
207
+ queryTarget,
208
+ args: [incentiveAccountsId, obligationId],
209
+ node: utils.scallopSuiKit.currentFullNode,
210
+ }),
200
211
  });
201
212
  const borrowIncentiveAccountsQueryData = queryResult?.events[0]
202
213
  ?.parsedJson as BorrowIncentiveAccountsQueryInterface | undefined;
@@ -47,6 +47,7 @@ import {
47
47
  ScallopAddress,
48
48
  } from 'src/models';
49
49
  import { getSharedObjectData } from 'src/utils/object';
50
+ import { queryKeys } from 'src/constants';
50
51
 
51
52
  /**
52
53
  * Query market data.
@@ -120,6 +121,11 @@ export const queryMarket = async (
120
121
  queryTarget,
121
122
  args,
122
123
  txBlock,
124
+ keys: queryKeys.rpc.getInspectTxn({
125
+ queryTarget,
126
+ args: [marketId],
127
+ node: utils.scallopSuiKit.currentFullNode,
128
+ }),
123
129
  });
124
130
  const marketData = queryResult?.events[0]?.parsedJson as
125
131
  | MarketQueryInterface
@@ -963,7 +969,7 @@ export const queryObligation = async (
963
969
  mutable: true,
964
970
  }),
965
971
  txBlock.sharedObjectRef({
966
- ...(await getSharedObjectData(obligationId)),
972
+ ...(await getSharedObjectData(obligationId, scallopSuiKit.client)),
967
973
  mutable: true,
968
974
  }),
969
975
  {
@@ -974,7 +980,16 @@ export const queryObligation = async (
974
980
  ];
975
981
 
976
982
  const queryResult = await scallopSuiKit.queryInspectTxn(
977
- { queryTarget, args, txBlock }
983
+ {
984
+ queryTarget,
985
+ args,
986
+ txBlock,
987
+ keys: queryKeys.rpc.getInspectTxn({
988
+ queryTarget,
989
+ args: [version, market, obligationId],
990
+ node: scallopSuiKit.currentFullNode,
991
+ }),
992
+ }
978
993
  // txBlock
979
994
  );
980
995
  return queryResult?.events[0]?.parsedJson as
@@ -2,6 +2,7 @@ import { bcs } from '@mysten/sui/bcs';
2
2
  import { SuiTxBlock } from '@scallop-io/sui-kit';
3
3
  import assert from 'assert';
4
4
  import BigNumber from 'bignumber.js';
5
+ import { queryKeys } from 'src/constants';
5
6
  import { ScallopQuery, ScallopUtils } from 'src/models';
6
7
  import { OptionalKeys, sCoinBalance } from 'src/types';
7
8
  import { getSharedObjectData } from 'src/utils';
@@ -23,9 +24,10 @@ export const getSCoinTotalSupply = async (
23
24
  const txBlock = new SuiTxBlock();
24
25
  const sCoinPkgId = utils.address.get('scoin.id');
25
26
  // get treasury
27
+ const treasury = utils.getSCoinTreasury(sCoinName);
26
28
  const args = [
27
29
  txBlock.sharedObjectRef({
28
- ...(await getSharedObjectData(utils.getSCoinTreasury(sCoinName))),
30
+ ...(await getSharedObjectData(treasury, utils.scallopSuiKit.client)),
29
31
  mutable: false,
30
32
  }),
31
33
  ];
@@ -39,6 +41,11 @@ export const getSCoinTotalSupply = async (
39
41
  args,
40
42
  typeArgs,
41
43
  txBlock,
44
+ keys: queryKeys.rpc.getInspectTxn({
45
+ queryTarget,
46
+ args: [treasury],
47
+ node: utils.scallopSuiKit.currentFullNode,
48
+ }),
42
49
  });
43
50
  const results = queryResults?.results;
44
51
  if (results && results[0]?.returnValues) {
@@ -191,13 +191,34 @@ const getTotalVeScaTreasuryAmount = async (
191
191
  initialSharedVersion: '1',
192
192
  });
193
193
 
194
+ const treasuryRef =
195
+ typeof veScaTreasury === 'string'
196
+ ? txb.sharedObjectRef({
197
+ objectId: veScaTreasury,
198
+ initialSharedVersion: '75353922',
199
+ mutable: true,
200
+ })
201
+ : txb.sharedObjectRef({
202
+ objectId: veScaTreasury.objectId,
203
+ initialSharedVersion: '75353922',
204
+ mutable: true,
205
+ });
206
+
194
207
  // refresh query
195
208
  const refreshQueryTarget = `${veScaPkgId}::treasury::refresh`;
196
- const refreshArgs = [veScaConfig, veScaTreasury, clockObjectRef];
209
+ const refreshArgs = [
210
+ txb.sharedObjectRef({
211
+ objectId: veScaConfig,
212
+ initialSharedVersion: '75353922',
213
+ mutable: false,
214
+ }),
215
+ treasuryRef,
216
+ clockObjectRef,
217
+ ];
197
218
 
198
219
  // query total veSca amount
199
220
  const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`;
200
- const vescaAmountArgs = [veScaTreasury, clockObjectRef];
221
+ const vescaAmountArgs = [treasuryRef, clockObjectRef];
201
222
 
202
223
  // resolve each args
203
224
  const resolvedRefreshArgs = await Promise.all(