@tradeport/sui-trading-sdk 0.4.63 → 0.4.65
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/.claude/settings.local.json +5 -0
- package/dist/index.d.mts +50 -22
- package/dist/index.d.ts +50 -22
- package/dist/index.js +627 -256
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +615 -249
- package/dist/index.mjs.map +1 -1
- package/package.json +65 -59
- package/src/helpers/kiosk/getRulePackageId.ts +2 -1
- package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +3 -0
- package/src/helpers/kiosk/upgradeKioskRulesPackageId.ts +17 -0
- package/src/methods/listNfts/listNfts.ts +0 -1
- package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +14 -12
- package/src/methods/sponsorNftListing/sponsorNftListing.ts +0 -3
package/package.json
CHANGED
|
@@ -1,60 +1,66 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
2
|
+
"name": "@tradeport/sui-trading-sdk",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"version": "0.4.65",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsup src/index.ts --sourcemap --format cjs,esm --dts",
|
|
10
|
+
"release": "pnpm run build && changeset publish",
|
|
11
|
+
"lint": "tsc && eslint --fix src/* --ignore-path .gitignore --ext .js,.ts",
|
|
12
|
+
"format": "prettier --write \"**/*.+(js|ts|json)\"",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"prepare": "husky install",
|
|
15
|
+
"pre-commit": "lint-staged"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@babel/core": "^7.23.3",
|
|
19
|
+
"@babel/preset-env": "^7.23.3",
|
|
20
|
+
"@changesets/cli": "^2.26.2",
|
|
21
|
+
"@types/jest": "^29.5.10",
|
|
22
|
+
"@types/ms": "^2.1.0",
|
|
23
|
+
"@types/node": "^20.10.0",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
25
|
+
"@typescript-eslint/parser": "^6.13.1",
|
|
26
|
+
"babel-jest": "^29.7.0",
|
|
27
|
+
"dotenv": "^16.3.1",
|
|
28
|
+
"eslint": "^8.54.0",
|
|
29
|
+
"eslint-config-prettier": "^9.0.0",
|
|
30
|
+
"eslint-config-xo": "^0.43.1",
|
|
31
|
+
"eslint-config-xo-typescript": "^1.0.1",
|
|
32
|
+
"husky": "^8.0.0",
|
|
33
|
+
"jest": "^29.7.0",
|
|
34
|
+
"lint-staged": "^16.2.7",
|
|
35
|
+
"prettier": "^3.1.0",
|
|
36
|
+
"ts-jest": "^29.1.1",
|
|
37
|
+
"tsup": "^8.0.1",
|
|
38
|
+
"typescript": "^5.3.2"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@mysten/kiosk": "^0.7.13",
|
|
42
|
+
"@mysten/sui": "^1.17.0",
|
|
43
|
+
"@types/analytics-node": "^3.1.14",
|
|
44
|
+
"analytics-node": "^6.2.0",
|
|
45
|
+
"bignumber.js": "^9.3.1",
|
|
46
|
+
"graphql": "^16.12.0",
|
|
47
|
+
"graphql-request": "^6.1.0",
|
|
48
|
+
"ms": "^2.1.3"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"lint-staged": {
|
|
55
|
+
"*.ts": [
|
|
56
|
+
"eslint --fix",
|
|
57
|
+
"bash -c 'tsc --noEmit'",
|
|
58
|
+
"prettier --write"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
"pnpm": {
|
|
62
|
+
"overrides": {
|
|
63
|
+
"@mysten/sui": "^1.45.2"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -4,6 +4,7 @@ import { addHexPrefix } from '../../utils/addHexPrefix';
|
|
|
4
4
|
import { normalizedNftType } from '../../utils/normalizeNftType';
|
|
5
5
|
import { getTransferPolicyRuleNamesFromSuiObject } from '../getTransferPolicyRuleNamesFromSuiObject';
|
|
6
6
|
import { getNativeKioskTransferPolicies } from './getNativeKioskTransferPolicies';
|
|
7
|
+
import { upgradeKioskRulesPackageId } from './upgradeKioskRulesPackageId';
|
|
7
8
|
|
|
8
9
|
type RuleType = 'kiosk_royalty_rule' | 'royalty_rule' | 'personal_kiosk_rule' | 'kiosk_lock_rule';
|
|
9
10
|
|
|
@@ -54,5 +55,5 @@ export const getRulePackageId = async ({
|
|
|
54
55
|
rulePackageId = rule?.split('::')?.[0];
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
return addHexPrefix(rulePackageId);
|
|
58
|
+
return upgradeKioskRulesPackageId(addHexPrefix(rulePackageId));
|
|
58
59
|
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
getNativeKioskTransferPolicies,
|
|
7
7
|
knownTransferPolicyRules,
|
|
8
8
|
} from './getNativeKioskTransferPolicies';
|
|
9
|
+
import { upgradeKioskRulesPackageId } from './upgradeKioskRulesPackageId';
|
|
9
10
|
|
|
10
11
|
interface RuleData {
|
|
11
12
|
rule: string;
|
|
@@ -132,6 +133,8 @@ export const getTransferPoliciesToResolve = async ({
|
|
|
132
133
|
rulePackageId = ruleData?.rule?.split('::')?.[0];
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
rulePackageId = upgradeKioskRulesPackageId(rulePackageId);
|
|
137
|
+
|
|
135
138
|
const moduleName = ruleData?.rule?.split('::')?.[1];
|
|
136
139
|
|
|
137
140
|
if (originByteRuleModules.includes(moduleName)) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
2
|
+
|
|
3
|
+
// @mysten/kiosk's mainnet rule defaults still point at v1 of the kiosk rules
|
|
4
|
+
// package. The package has since been upgraded; newer collections (e.g. suirocks)
|
|
5
|
+
// have linkage constraints that require the upgraded version, so calling v1
|
|
6
|
+
// fails with InvalidLinkage. Remap the original packageId to the upgraded one
|
|
7
|
+
// when it shows up in rule lookups.
|
|
8
|
+
const KIOSK_RULES_ORIGINAL_PACKAGE_ID = normalizeSuiAddress(
|
|
9
|
+
'0x434b5bd8f6a7b05fede0ff46c6e511d71ea326ed38056e3bcd681d2d7c2a7879',
|
|
10
|
+
);
|
|
11
|
+
const KIOSK_RULES_UPGRADED_PACKAGE_ID =
|
|
12
|
+
'0xdfb4f1d4e43e0c3ad834dcd369f0d39005c872e118c9dc1c5da9765bb93ee5f3';
|
|
13
|
+
|
|
14
|
+
export const upgradeKioskRulesPackageId = (packageId: string): string =>
|
|
15
|
+
normalizeSuiAddress(packageId) === KIOSK_RULES_ORIGINAL_PACKAGE_ID
|
|
16
|
+
? KIOSK_RULES_UPGRADED_PACKAGE_ID
|
|
17
|
+
: packageId;
|
|
@@ -121,7 +121,6 @@ export const listNfts = async (
|
|
|
121
121
|
if (inputNft?.sponsorOptions?.shouldSponsor) {
|
|
122
122
|
await addSponsorListingTx({
|
|
123
123
|
tx,
|
|
124
|
-
coinToSplit: inputNft?.sponsorOptions?.coinToSplit,
|
|
125
124
|
nftTokenId: nft?.token_id,
|
|
126
125
|
nftType,
|
|
127
126
|
sponsorOptions: inputNft?.sponsorOptions,
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { coinWithBalance, type Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import BigNumber from '../../bigNumberConfig';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
TRADEPORT_LISTINGS_PACKAGE,
|
|
5
|
+
TRADEPORT_LISTINGS_STORE,
|
|
6
|
+
USDC_COIN_TYPE,
|
|
7
|
+
} from '../../constants';
|
|
4
8
|
import { type SponsorNftListingOptions } from './sponsorNftListing';
|
|
5
9
|
|
|
6
10
|
export const addSponsorListingTx = async ({
|
|
7
11
|
tx,
|
|
8
|
-
coinToSplit,
|
|
9
12
|
nftTokenId,
|
|
10
13
|
nftType,
|
|
11
14
|
sponsorOptions,
|
|
12
15
|
}: {
|
|
13
16
|
tx: Transaction;
|
|
14
|
-
coinToSplit: any;
|
|
15
17
|
nftTokenId: string;
|
|
16
18
|
nftType: string;
|
|
17
19
|
sponsorOptions: SponsorNftListingOptions;
|
|
18
20
|
}) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
|
|
21
|
+
const totalFee = new BigNumber(sponsorOptions?.usdcFeeAmountPerPeriod)
|
|
22
|
+
?.times(sponsorOptions?.numOfPeriods)
|
|
23
|
+
.toString();
|
|
24
|
+
|
|
25
|
+
const sponsorCoin = sponsorOptions.coinToSplit
|
|
26
|
+
? tx.splitCoins(sponsorOptions.coinToSplit, [tx.pure.u64(totalFee)])[0]
|
|
27
|
+
: coinWithBalance({ type: USDC_COIN_TYPE, balance: BigInt(totalFee) });
|
|
26
28
|
|
|
27
29
|
tx.moveCall({
|
|
28
30
|
target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::add_sponsored_listing`,
|
|
@@ -31,7 +33,7 @@ export const addSponsorListingTx = async ({
|
|
|
31
33
|
tx.object.clock(),
|
|
32
34
|
tx.pure.id(nftTokenId),
|
|
33
35
|
tx.pure.u64(sponsorOptions?.numOfPeriods),
|
|
34
|
-
tx.object(
|
|
36
|
+
tx.object(sponsorCoin),
|
|
35
37
|
],
|
|
36
38
|
typeArguments: [nftType],
|
|
37
39
|
});
|
|
@@ -14,14 +14,12 @@ export type SponsorNftListingOptions = {
|
|
|
14
14
|
|
|
15
15
|
export type SponsorNftListing = {
|
|
16
16
|
tx?: Transaction;
|
|
17
|
-
coinToSplit?: any;
|
|
18
17
|
nftTokenId: string;
|
|
19
18
|
options: SponsorNftListingOptions;
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
export const sponsorNftListing = async ({
|
|
23
22
|
tx: existingTx,
|
|
24
|
-
coinToSplit,
|
|
25
23
|
nftTokenId,
|
|
26
24
|
options,
|
|
27
25
|
}: SponsorNftListing): Promise<Transaction> => {
|
|
@@ -53,7 +51,6 @@ export const sponsorNftListing = async ({
|
|
|
53
51
|
|
|
54
52
|
await addSponsorListingTx({
|
|
55
53
|
tx,
|
|
56
|
-
coinToSplit,
|
|
57
54
|
nftTokenId,
|
|
58
55
|
nftType,
|
|
59
56
|
sponsorOptions: options,
|