@scallop-io/sui-scallop-sdk 2.1.3-merge-split-ve-sca-alpha.3 → 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.js +13 -13
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
- package/src/builders/loyaltyProgramBuilder.ts +2 -17
- package/src/builders/vescaBuilder.ts +12 -5
- package/src/constants/testAddress.ts +5 -5
package/package.json
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import {
|
|
3
|
-
normalizeSuiAddress,
|
|
4
|
-
MOVE_STDLIB_ADDRESS,
|
|
5
|
-
SuiTxBlock as SuiKitTxBlock,
|
|
6
|
-
} from '@scallop-io/sui-kit';
|
|
2
|
+
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
7
3
|
import { ScallopBuilder } from 'src/models';
|
|
8
4
|
import {
|
|
9
5
|
GenerateLoyaltyProgramNormalMethod,
|
|
@@ -44,7 +40,7 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
|
|
|
44
40
|
);
|
|
45
41
|
},
|
|
46
42
|
claimVeScaLoyaltyReward: (veScaKey) => {
|
|
47
|
-
|
|
43
|
+
return builder.moveCall(
|
|
48
44
|
txBlock,
|
|
49
45
|
`${veScaLoyaltyProgramIds.pkgId}::ve_sca_reward::redeem_reward`,
|
|
50
46
|
[
|
|
@@ -55,17 +51,6 @@ const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
|
|
|
55
51
|
veScaProgramIds.subsTable,
|
|
56
52
|
]
|
|
57
53
|
);
|
|
58
|
-
|
|
59
|
-
// Extract from option
|
|
60
|
-
const veScaKeyType = `${veScaProgramIds.object}::ve_sca::VeScaKey`;
|
|
61
|
-
const rewardVeScaKey = builder.moveCall(
|
|
62
|
-
txBlock,
|
|
63
|
-
`${normalizeSuiAddress(MOVE_STDLIB_ADDRESS)}::option::destroy_some`,
|
|
64
|
-
[optionVeScaKey],
|
|
65
|
-
[veScaKeyType]
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
return rewardVeScaKey;
|
|
69
54
|
},
|
|
70
55
|
};
|
|
71
56
|
};
|
|
@@ -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 (
|
|
@@ -290,9 +297,9 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
|
|
|
290
297
|
veSca?.unlockAt
|
|
291
298
|
);
|
|
292
299
|
|
|
293
|
-
const isInitialLock = !veSca
|
|
300
|
+
const isInitialLock = !veSca;
|
|
294
301
|
const isLockExpired =
|
|
295
|
-
!isInitialLock && veSca.unlockAt
|
|
302
|
+
!isInitialLock && veSca.unlockAt <= new Date().getTime();
|
|
296
303
|
if (isInitialLock || isLockExpired) {
|
|
297
304
|
if (scaCoin) {
|
|
298
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',
|