@scallop-io/sui-scallop-sdk 0.47.6 → 1.3.0-alpha.2
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/builders/borrowIncentiveBuilder.d.ts +2 -2
- package/dist/builders/coreBuilder.d.ts +2 -2
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/loyaltyProgramBuilder.d.ts +2 -2
- package/dist/builders/referralBuilder.d.ts +2 -2
- package/dist/builders/sCoinBuilder.d.ts +2 -2
- package/dist/builders/spoolBuilder.d.ts +2 -2
- package/dist/builders/vescaBuilder.d.ts +2 -2
- package/dist/constants/common.d.ts +4 -4
- package/dist/constants/index.d.ts +1 -1
- package/dist/constants/vesca.d.ts +3 -3
- package/dist/index.js +149 -83
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -89
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +6 -4
- package/dist/models/scallopCache.d.ts +5 -9
- package/dist/models/scallopClient.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +1 -1
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/loyaltyProgramQuery.d.ts +1 -1
- package/dist/queries/priceQuery.d.ts +1 -1
- package/dist/queries/vescaQuery.d.ts +1 -1
- package/dist/test.d.ts +1 -0
- package/dist/types/builder/borrowIncentive.d.ts +1 -1
- package/dist/types/builder/core.d.ts +16 -16
- package/dist/types/builder/spool.d.ts +3 -3
- package/dist/types/builder/vesca.d.ts +5 -5
- package/dist/types/model.d.ts +6 -6
- package/dist/types/query/vesca.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +4 -3
- package/package.json +15 -11
- package/src/builders/borrowIncentiveBuilder.ts +6 -6
- package/src/builders/coreBuilder.ts +17 -17
- package/src/builders/index.ts +2 -2
- package/src/builders/loyaltyProgramBuilder.ts +5 -5
- package/src/builders/oracle.ts +5 -4
- package/src/builders/referralBuilder.ts +7 -7
- package/src/builders/sCoinBuilder.ts +5 -8
- package/src/builders/spoolBuilder.ts +10 -10
- package/src/builders/vescaBuilder.ts +5 -5
- package/src/constants/common.ts +4 -4
- package/src/constants/index.ts +1 -1
- package/src/constants/vesca.ts +5 -6
- package/src/models/scallopBuilder.ts +15 -7
- package/src/models/scallopCache.ts +43 -34
- package/src/models/scallopClient.ts +10 -9
- package/src/models/scallopQuery.ts +36 -2
- package/src/models/scallopUtils.ts +5 -4
- package/src/queries/borrowIncentiveQuery.ts +1 -1
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/loyaltyProgramQuery.ts +1 -1
- package/src/queries/priceQuery.ts +1 -1
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +4 -5
- package/src/queries/vescaQuery.ts +6 -3
- package/src/test.ts +26 -0
- package/src/types/address.ts +26 -26
- package/src/types/builder/borrowIncentive.ts +1 -1
- package/src/types/builder/core.ts +26 -28
- package/src/types/builder/spool.ts +2 -3
- package/src/types/builder/vesca.ts +5 -9
- package/src/types/model.ts +6 -9
- package/src/types/query/vesca.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/indexer.ts +39 -0
- package/src/utils/query.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeStructTag } from '@mysten/sui
|
|
1
|
+
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
2
2
|
import { SUPPORT_SPOOLS } from '../constants';
|
|
3
3
|
import {
|
|
4
4
|
parseOriginSpoolData,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
calculateSpoolRewardPoolData,
|
|
8
8
|
isMarketCoin,
|
|
9
9
|
} from '../utils';
|
|
10
|
-
import type { SuiObjectResponse } from '@mysten/sui
|
|
10
|
+
import type { SuiObjectResponse } from '@mysten/sui/client';
|
|
11
11
|
import type { ScallopQuery, ScallopUtils } from '../models';
|
|
12
12
|
import type {
|
|
13
13
|
MarketPool,
|
|
@@ -287,9 +287,8 @@ export const getStakeAccounts = async (
|
|
|
287
287
|
utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
|
|
288
288
|
const marketCoinType = utils.parseMarketCoinType(stakeCoinName);
|
|
289
289
|
|
|
290
|
-
types[
|
|
291
|
-
|
|
292
|
-
] = `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
|
|
290
|
+
types[stakeMarketCoinName as SupportStakeMarketCoins] =
|
|
291
|
+
`${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
|
|
293
292
|
return types;
|
|
294
293
|
},
|
|
295
294
|
{} as Record<SupportStakeMarketCoins, string>
|
|
@@ -4,12 +4,13 @@ import {
|
|
|
4
4
|
type SuiObjectResponse,
|
|
5
5
|
type SuiObjectData,
|
|
6
6
|
DevInspectResults,
|
|
7
|
-
} from '@mysten/sui
|
|
7
|
+
} from '@mysten/sui/client';
|
|
8
8
|
import type { ScallopUtils } from '../models';
|
|
9
9
|
import { MAX_LOCK_DURATION } from 'src/constants';
|
|
10
10
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
11
|
-
import { bcs } from '@mysten/sui
|
|
11
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
12
12
|
import { z as zod } from 'zod';
|
|
13
|
+
import assert from 'assert';
|
|
13
14
|
/**
|
|
14
15
|
* Query all owned veSca key.
|
|
15
16
|
*
|
|
@@ -213,6 +214,7 @@ const getTotalVeScaTreasuryAmount = async (
|
|
|
213
214
|
);
|
|
214
215
|
|
|
215
216
|
const txb = new SuiTxBlock();
|
|
217
|
+
|
|
216
218
|
// refresh first
|
|
217
219
|
txb.moveCall(refreshQueryTarget, resolvedRefreshArgs);
|
|
218
220
|
txb.moveCall(veScaAmountQueryTarget, resolvedVeScaAmountArgs);
|
|
@@ -237,7 +239,8 @@ const getTotalVeScaTreasuryAmount = async (
|
|
|
237
239
|
if (results && results[1].returnValues) {
|
|
238
240
|
const value = Uint8Array.from(results[1].returnValues[0][0]);
|
|
239
241
|
const type = results[1].returnValues[0][1];
|
|
240
|
-
|
|
242
|
+
assert(type === 'u64', 'Result type is not u64');
|
|
243
|
+
return bcs.u64().parse(value);
|
|
241
244
|
}
|
|
242
245
|
|
|
243
246
|
return '0';
|
package/src/test.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ScallopQuery } from './models';
|
|
2
|
+
|
|
3
|
+
const query = new ScallopQuery({
|
|
4
|
+
walletAddress:
|
|
5
|
+
'0xe78704e7c188b1902dbb630dc4c3ef7f46740c8cf121e38b3438ac1daea09f2d',
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
const main = async () => {
|
|
9
|
+
try {
|
|
10
|
+
await query.init();
|
|
11
|
+
const result = await query.suiKit.client().getObject({
|
|
12
|
+
id: '0xaa72bd551b25715b8f9d72f226fa02526bdf2e085a86faec7184230c5209bb6e',
|
|
13
|
+
options: {
|
|
14
|
+
showContent: true,
|
|
15
|
+
showType: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
console.dir(result.data, { depth: null });
|
|
19
|
+
} catch (e) {
|
|
20
|
+
console.error(e);
|
|
21
|
+
} finally {
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
main();
|
package/src/types/address.ts
CHANGED
|
@@ -27,13 +27,13 @@ export interface AddressesInterface {
|
|
|
27
27
|
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
28
28
|
? string
|
|
29
29
|
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
? string
|
|
31
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
32
|
+
? {
|
|
33
|
+
feed: string;
|
|
34
|
+
feedObject: string;
|
|
35
|
+
}
|
|
36
|
+
: never;
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
>
|
|
@@ -46,19 +46,19 @@ export interface AddressesInterface {
|
|
|
46
46
|
holder: string;
|
|
47
47
|
}
|
|
48
48
|
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
? {
|
|
50
|
+
registry: string;
|
|
51
|
+
registryCap: string;
|
|
52
|
+
}
|
|
53
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
54
|
+
? {
|
|
55
|
+
registry: string;
|
|
56
|
+
registryCap: string;
|
|
57
|
+
state: string;
|
|
58
|
+
wormhole: string;
|
|
59
|
+
wormholeState: string;
|
|
60
|
+
}
|
|
61
|
+
: never;
|
|
62
62
|
} & { xOracle: string; xOracleCap: string };
|
|
63
63
|
packages: Partial<
|
|
64
64
|
Record<
|
|
@@ -145,12 +145,12 @@ type AddressPathsProps<T> = T extends string
|
|
|
145
145
|
type Join<T extends string[], D extends string> = T extends []
|
|
146
146
|
? never
|
|
147
147
|
: T extends [infer F]
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
? F
|
|
149
|
+
: T extends [infer F, ...infer R]
|
|
150
|
+
? F extends string
|
|
151
|
+
? `${F}${D}${Join<Extract<R, string[]>, D>}`
|
|
152
|
+
: never
|
|
153
|
+
: string;
|
|
154
154
|
|
|
155
155
|
export type AddressStringPath = Join<
|
|
156
156
|
AddressPathsProps<AddressesInterface>,
|
|
@@ -2,7 +2,7 @@ import type {
|
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
3
|
SuiObjectArg,
|
|
4
4
|
} from '@scallop-io/sui-kit';
|
|
5
|
-
import type { TransactionResult } from '@mysten/sui
|
|
5
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
6
6
|
import type { ScallopBuilder } from '../../models';
|
|
7
7
|
import type {
|
|
8
8
|
SupportBorrowIncentiveCoins,
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
|
-
SuiAddressArg,
|
|
4
3
|
SuiObjectArg,
|
|
5
|
-
SuiTxArg,
|
|
6
4
|
} from '@scallop-io/sui-kit';
|
|
7
5
|
import type {
|
|
8
6
|
TransactionArgument,
|
|
9
7
|
TransactionResult,
|
|
10
|
-
} from '@mysten/sui
|
|
8
|
+
} from '@mysten/sui/transactions';
|
|
11
9
|
import type { ScallopBuilder } from '../../models';
|
|
12
10
|
import type {
|
|
13
11
|
SupportCollateralCoins,
|
|
@@ -35,19 +33,19 @@ type ObligationHotPotato = NestedResult;
|
|
|
35
33
|
export type CoreNormalMethods = {
|
|
36
34
|
openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
|
|
37
35
|
returnObligation: (
|
|
38
|
-
obligation:
|
|
36
|
+
obligation: SuiObjectArg,
|
|
39
37
|
obligationHotPotato: SuiObjectArg
|
|
40
38
|
) => void;
|
|
41
39
|
openObligationEntry: () => void;
|
|
42
40
|
addCollateral: (
|
|
43
|
-
obligation:
|
|
41
|
+
obligation: SuiObjectArg,
|
|
44
42
|
coin: SuiObjectArg,
|
|
45
43
|
collateralCoinName: SupportCollateralCoins
|
|
46
44
|
) => void;
|
|
47
45
|
takeCollateral: (
|
|
48
|
-
obligation:
|
|
49
|
-
obligationKey:
|
|
50
|
-
amount:
|
|
46
|
+
obligation: SuiObjectArg,
|
|
47
|
+
obligationKey: SuiObjectArg,
|
|
48
|
+
amount: number,
|
|
51
49
|
collateralCoinName: SupportCollateralCoins
|
|
52
50
|
) => TransactionResult;
|
|
53
51
|
deposit: (
|
|
@@ -64,36 +62,36 @@ export type CoreNormalMethods = {
|
|
|
64
62
|
poolCoinName: SupportPoolCoins
|
|
65
63
|
) => void;
|
|
66
64
|
borrow: (
|
|
67
|
-
obligation:
|
|
68
|
-
obligationKey:
|
|
69
|
-
amount:
|
|
65
|
+
obligation: SuiObjectArg,
|
|
66
|
+
obligationKey: SuiObjectArg,
|
|
67
|
+
amount: number,
|
|
70
68
|
poolCoinName: SupportPoolCoins
|
|
71
69
|
) => TransactionResult;
|
|
72
70
|
borrowWithReferral: (
|
|
73
|
-
obligation:
|
|
74
|
-
obligationKey:
|
|
71
|
+
obligation: SuiObjectArg,
|
|
72
|
+
obligationKey: SuiObjectArg,
|
|
75
73
|
borrowReferral: SuiObjectArg,
|
|
76
|
-
amount:
|
|
74
|
+
amount: number,
|
|
77
75
|
poolCoinName: SupportPoolCoins
|
|
78
76
|
) => TransactionResult;
|
|
79
77
|
borrowEntry: (
|
|
80
|
-
obligation:
|
|
81
|
-
obligationKey:
|
|
82
|
-
amount:
|
|
78
|
+
obligation: SuiObjectArg,
|
|
79
|
+
obligationKey: SuiObjectArg,
|
|
80
|
+
amount: number,
|
|
83
81
|
poolCoinName: SupportPoolCoins
|
|
84
82
|
) => void;
|
|
85
83
|
repay: (
|
|
86
|
-
obligation:
|
|
84
|
+
obligation: SuiObjectArg,
|
|
87
85
|
coin: SuiObjectArg,
|
|
88
86
|
poolCoinName: SupportPoolCoins
|
|
89
87
|
) => void;
|
|
90
88
|
borrowFlashLoan: (
|
|
91
|
-
amount:
|
|
89
|
+
amount: number,
|
|
92
90
|
poolCoinName: SupportPoolCoins
|
|
93
91
|
) => TransactionResult;
|
|
94
92
|
repayFlashLoan: (
|
|
95
93
|
coin: SuiObjectArg,
|
|
96
|
-
loan:
|
|
94
|
+
loan: SuiObjectArg,
|
|
97
95
|
poolCoinName: SupportPoolCoins
|
|
98
96
|
) => void;
|
|
99
97
|
};
|
|
@@ -102,26 +100,26 @@ export type CoreQuickMethods = {
|
|
|
102
100
|
addCollateralQuick: (
|
|
103
101
|
amount: number,
|
|
104
102
|
collateralCoinName: SupportCollateralCoins,
|
|
105
|
-
obligationId?:
|
|
103
|
+
obligationId?: SuiObjectArg
|
|
106
104
|
) => Promise<void>;
|
|
107
105
|
takeCollateralQuick: (
|
|
108
106
|
amount: number,
|
|
109
107
|
collateralCoinName: SupportCollateralCoins,
|
|
110
|
-
obligationId?:
|
|
111
|
-
obligationKey?:
|
|
108
|
+
obligationId?: SuiObjectArg,
|
|
109
|
+
obligationKey?: SuiObjectArg
|
|
112
110
|
) => Promise<TransactionResult>;
|
|
113
111
|
borrowQuick: (
|
|
114
112
|
amount: number,
|
|
115
113
|
poolCoinName: SupportPoolCoins,
|
|
116
|
-
obligationId?:
|
|
117
|
-
obligationKey?:
|
|
114
|
+
obligationId?: SuiObjectArg,
|
|
115
|
+
obligationKey?: SuiObjectArg
|
|
118
116
|
) => Promise<TransactionResult>;
|
|
119
117
|
borrowWithReferralQuick: (
|
|
120
118
|
amount: number,
|
|
121
119
|
poolCoinName: SupportPoolCoins,
|
|
122
120
|
borrowReferral: SuiObjectArg,
|
|
123
|
-
obligationId?:
|
|
124
|
-
obligationKey?:
|
|
121
|
+
obligationId?: SuiObjectArg,
|
|
122
|
+
obligationKey?: SuiObjectArg
|
|
125
123
|
) => Promise<TransactionResult>;
|
|
126
124
|
depositQuick: (
|
|
127
125
|
amount: number,
|
|
@@ -135,7 +133,7 @@ export type CoreQuickMethods = {
|
|
|
135
133
|
repayQuick: (
|
|
136
134
|
amount: number,
|
|
137
135
|
poolCoinName: SupportPoolCoins,
|
|
138
|
-
obligationId?:
|
|
136
|
+
obligationId?: SuiObjectArg
|
|
139
137
|
) => Promise<void>;
|
|
140
138
|
updateAssetPricesQuick: (
|
|
141
139
|
assetCoinNames?: SupportAssetCoins[]
|
|
@@ -2,9 +2,8 @@ import type {
|
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
3
|
SuiAddressArg,
|
|
4
4
|
SuiObjectArg,
|
|
5
|
-
SuiTxArg,
|
|
6
5
|
} from '@scallop-io/sui-kit';
|
|
7
|
-
import type { TransactionResult } from '@mysten/sui
|
|
6
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
8
7
|
import type { ScallopBuilder } from '../../models';
|
|
9
8
|
import type { SupportStakeMarketCoins } from '../constant';
|
|
10
9
|
import { SuiTxBlockWithSCoin } from '.';
|
|
@@ -24,7 +23,7 @@ export type SpoolNormalMethods = {
|
|
|
24
23
|
) => void;
|
|
25
24
|
unstake: (
|
|
26
25
|
stakeAccount: SuiAddressArg,
|
|
27
|
-
amount:
|
|
26
|
+
amount: number,
|
|
28
27
|
stakeMarketCoinName: SupportStakeMarketCoins
|
|
29
28
|
) => TransactionResult;
|
|
30
29
|
claim: (
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
SuiObjectArg,
|
|
4
|
-
SuiTxArg,
|
|
5
|
-
} from '@scallop-io/sui-kit';
|
|
6
|
-
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
1
|
+
import { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
7
3
|
import { ScallopBuilder } from 'src/models';
|
|
8
4
|
|
|
9
5
|
export type VescaIds = {
|
|
@@ -16,17 +12,17 @@ export type VescaIds = {
|
|
|
16
12
|
export type VeScaNormalMethods = {
|
|
17
13
|
lockSca: (
|
|
18
14
|
scaCoin: SuiObjectArg,
|
|
19
|
-
unlockAtInSecondTimestamp:
|
|
15
|
+
unlockAtInSecondTimestamp: number
|
|
20
16
|
) => TransactionResult;
|
|
21
17
|
extendLockPeriod: (
|
|
22
18
|
veScaKey: SuiObjectArg,
|
|
23
|
-
newUnlockAtInSecondTimestamp:
|
|
19
|
+
newUnlockAtInSecondTimestamp: number
|
|
24
20
|
) => void;
|
|
25
21
|
extendLockAmount: (veScaKey: SuiObjectArg, scaCoin: SuiObjectArg) => void;
|
|
26
22
|
renewExpiredVeSca: (
|
|
27
23
|
veScaKey: SuiObjectArg,
|
|
28
24
|
scaCoin: SuiObjectArg,
|
|
29
|
-
newUnlockAtInSecondTimestamp:
|
|
25
|
+
newUnlockAtInSecondTimestamp: number
|
|
30
26
|
) => void;
|
|
31
27
|
redeemSca: (veScaKey: SuiObjectArg) => TransactionResult;
|
|
32
28
|
mintEmptyVeSca: () => TransactionResult;
|
package/src/types/model.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { SuiTransactionBlockResponse } from '@mysten/sui
|
|
2
|
-
import type {
|
|
3
|
-
TransactionBlock,
|
|
4
|
-
TransactionResult,
|
|
5
|
-
} from '@mysten/sui.js/transactions';
|
|
1
|
+
import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
2
|
+
import type { Transaction, TransactionResult } from '@mysten/sui/transactions';
|
|
6
3
|
import type { SuiKit, SuiKitParams, NetworkType } from '@scallop-io/sui-kit';
|
|
7
4
|
import type {
|
|
8
5
|
ScallopAddress,
|
|
@@ -16,12 +13,12 @@ import { AddressesInterface } from './address';
|
|
|
16
13
|
|
|
17
14
|
export type ScallopClientFnReturnType<T extends boolean> = T extends true
|
|
18
15
|
? SuiTransactionBlockResponse
|
|
19
|
-
:
|
|
16
|
+
: Transaction;
|
|
20
17
|
|
|
21
18
|
export type ScallopClientVeScaReturnType<T extends boolean> = T extends true
|
|
22
19
|
? SuiTransactionBlockResponse
|
|
23
20
|
: {
|
|
24
|
-
tx:
|
|
21
|
+
tx: Transaction;
|
|
25
22
|
scaCoin: TransactionResult;
|
|
26
23
|
};
|
|
27
24
|
|
|
@@ -60,12 +57,12 @@ export type ScallopAddressParams = {
|
|
|
60
57
|
id: string;
|
|
61
58
|
auth?: string;
|
|
62
59
|
network?: NetworkType;
|
|
63
|
-
forceInterface?: Record<NetworkType, AddressesInterface
|
|
60
|
+
forceInterface?: Partial<Record<NetworkType, AddressesInterface>>;
|
|
64
61
|
};
|
|
65
62
|
|
|
66
63
|
export type ScallopParams = {
|
|
67
64
|
addressesId?: string;
|
|
68
|
-
forceAddressesInterface?: Record<NetworkType, AddressesInterface
|
|
65
|
+
forceAddressesInterface?: Partial<Record<NetworkType, AddressesInterface>>;
|
|
69
66
|
walletAddress?: string;
|
|
70
67
|
} & SuiKitParams;
|
|
71
68
|
|
package/src/types/query/vesca.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic wrapper for methods with indexer fallback.
|
|
3
|
+
*
|
|
4
|
+
* @param method - The method to call with fallback behavior.
|
|
5
|
+
* @param context - The context (`this`) of the class instance.
|
|
6
|
+
* @param args - The arguments to pass to the method.
|
|
7
|
+
* @returns The result of the method call.
|
|
8
|
+
*/
|
|
9
|
+
export async function callMethodWithIndexerFallback(
|
|
10
|
+
method: Function,
|
|
11
|
+
context: any,
|
|
12
|
+
...args: any[]
|
|
13
|
+
) {
|
|
14
|
+
const indexer = args[args.length - 1]; // Assume last argument is always `indexer`
|
|
15
|
+
|
|
16
|
+
if (indexer) {
|
|
17
|
+
try {
|
|
18
|
+
return await method.apply(context, args);
|
|
19
|
+
} catch (_e) {
|
|
20
|
+
console.warn('Indexer requests failed. Retrying without indexer..');
|
|
21
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return await method.apply(context, args);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This function creates a wrapper for methods that have an indexer parameter.
|
|
29
|
+
* It ensures fallback behavior if indexer fails.
|
|
30
|
+
*
|
|
31
|
+
* @param method - The method to wrap.
|
|
32
|
+
* @returns A function that applies indexer fallback.
|
|
33
|
+
*/
|
|
34
|
+
export function withIndexerFallback(method: Function) {
|
|
35
|
+
return (...args: any[]) => {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
return callMethodWithIndexerFallback(method, this, ...args); // Preserve `this` with arrow function
|
|
38
|
+
};
|
|
39
|
+
}
|
package/src/utils/query.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { normalizeStructTag, parseStructTag } from '@mysten/sui
|
|
2
|
+
import { normalizeStructTag, parseStructTag } from '@mysten/sui/utils';
|
|
3
3
|
import type { ScallopUtils } from '../models';
|
|
4
4
|
import type {
|
|
5
5
|
OriginMarketPoolData,
|