@scallop-io/sui-scallop-sdk 2.1.3-merge-split-ve-sca-alpha.2 → 2.1.3-merge-split-ve-sca-alpha.4
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/builders/loyaltyProgramBuilder.ts +1 -0
- package/src/builders/vescaBuilder.ts +19 -7
- package/src/constants/testAddress.ts +5 -5
- package/src/types/builder/vesca.ts +1 -0
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const veScaProgramIds = {
|
|
21
|
+
object: builder.address.get('vesca.object'),
|
|
21
22
|
protocolConfig: builder.address.get('vesca.config'),
|
|
22
23
|
veScaTable: builder.address.get('vesca.table'),
|
|
23
24
|
subsTable: builder.address.get('vesca.subsTable'),
|
|
@@ -28,6 +28,7 @@ import type {
|
|
|
28
28
|
SuiTxBlockWithVeScaNormalMethods,
|
|
29
29
|
VeScaTxBlock,
|
|
30
30
|
} from 'src/types';
|
|
31
|
+
import { SuiObjectData } from '@mysten/sui/client';
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Check and get veSCA data from transaction block.
|
|
@@ -46,11 +47,11 @@ export const requireVeSca = async (
|
|
|
46
47
|
...params: [
|
|
47
48
|
builder: ScallopBuilder,
|
|
48
49
|
SuiTxBlock: SuiTxBlock,
|
|
49
|
-
veScaKey?:
|
|
50
|
+
veScaKey?: SuiObjectData,
|
|
50
51
|
]
|
|
51
52
|
) => {
|
|
52
53
|
const [builder, txBlock, veScaKey] = params;
|
|
53
|
-
if (params.length === 3 && veScaKey && typeof veScaKey
|
|
54
|
+
if (params.length === 3 && veScaKey && typeof veScaKey !== 'undefined') {
|
|
54
55
|
const veSca = await getVeSca(builder.utils, veScaKey);
|
|
55
56
|
|
|
56
57
|
if (!veSca) {
|
|
@@ -67,7 +68,13 @@ export const requireVeSca = async (
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
// return veSCA with the same veScaKey or the highest veSCA balance
|
|
70
|
-
return veScaKey
|
|
71
|
+
return veScaKey
|
|
72
|
+
? veScas.find(
|
|
73
|
+
({ keyId }) =>
|
|
74
|
+
(typeof veScaKey === 'string' ? veScaKey : veScaKey.objectId) ===
|
|
75
|
+
keyId
|
|
76
|
+
)
|
|
77
|
+
: veScas[0];
|
|
71
78
|
};
|
|
72
79
|
|
|
73
80
|
export const isInSubsTable = async (
|
|
@@ -248,9 +255,14 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
|
|
|
248
255
|
txBlock,
|
|
249
256
|
}) => {
|
|
250
257
|
return {
|
|
251
|
-
lockScaQuick: async (
|
|
258
|
+
lockScaQuick: async (
|
|
259
|
+
amountOrCoin,
|
|
260
|
+
lockPeriodInDays,
|
|
261
|
+
veScaKey,
|
|
262
|
+
autoCheck = true
|
|
263
|
+
) => {
|
|
252
264
|
const sender = requireSender(txBlock);
|
|
253
|
-
const veSca = await requireVeSca(builder, txBlock);
|
|
265
|
+
const veSca = await requireVeSca(builder, txBlock, veScaKey);
|
|
254
266
|
|
|
255
267
|
let scaCoin: TransactionObjectArgument | SuiObjectArg | undefined =
|
|
256
268
|
undefined;
|
|
@@ -285,9 +297,9 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
|
|
|
285
297
|
veSca?.unlockAt
|
|
286
298
|
);
|
|
287
299
|
|
|
288
|
-
const isInitialLock = !veSca
|
|
300
|
+
const isInitialLock = !veSca;
|
|
289
301
|
const isLockExpired =
|
|
290
|
-
!isInitialLock && veSca.unlockAt
|
|
302
|
+
!isInitialLock && veSca.unlockAt <= new Date().getTime();
|
|
291
303
|
if (isInitialLock || isLockExpired) {
|
|
292
304
|
if (scaCoin) {
|
|
293
305
|
if (isInitialLock) {
|
|
@@ -308,15 +308,15 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
308
308
|
'0x574a11f8a0fbaa05b8f559cb65634e8eb20f26b1ec29e7d58de9167f3cedd0f7',
|
|
309
309
|
},
|
|
310
310
|
veScaLoyaltyProgram: {
|
|
311
|
-
id: '
|
|
311
|
+
id: '0x51bd8c455caedad9d7fd47f9ee75876668c4d6bbede95af39c0aebde46043f00',
|
|
312
312
|
object:
|
|
313
|
-
'
|
|
313
|
+
'0x51bd8c455caedad9d7fd47f9ee75876668c4d6bbede95af39c0aebde46043f00',
|
|
314
314
|
adminCap:
|
|
315
|
-
'
|
|
315
|
+
'0xb2d52e0ebb260cb42699be6a9804e12d6fa17b79ef1e43f9996df5ca71bac0ae',
|
|
316
316
|
veScaRewardPool:
|
|
317
|
-
'
|
|
317
|
+
'0x4fe34992bf2261c3c6c14b2dbf9606ce65a505c45ff778ac129ce7dea9b0cadf',
|
|
318
318
|
veScaRewardTableId:
|
|
319
|
-
'
|
|
319
|
+
'0x85d3e557d9bbed617b9cbc09982a0c9a6f6f4fc9ecce49b59124206c409c4774',
|
|
320
320
|
},
|
|
321
321
|
scoin: {
|
|
322
322
|
id: '0x826a4934bee9487e558eed603cf42f30cdc4321d6f31083930791b95f903b9f9',
|