@tradeport/sui-trading-sdk 0.5.1 → 0.5.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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "permissions": {
3
+ "allow": ["Bash(xxd:*)", "Bash(pnpm tsc:*)", "Bash(npx tsc:*)"]
4
+ }
5
+ }
package/package.json CHANGED
@@ -1,67 +1,68 @@
1
1
  {
2
- "name": "@tradeport/sui-trading-sdk",
3
- "license": "MIT",
4
- "version": "0.5.1",
5
- "type": "module",
6
- "module": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "default": "./dist/index.js"
13
- }
14
- },
15
- "devDependencies": {
16
- "@babel/core": "^7.23.3",
17
- "@babel/preset-env": "^7.23.3",
18
- "@changesets/cli": "^2.26.2",
19
- "@types/jest": "^29.5.10",
20
- "@types/ms": "^2.1.0",
21
- "@types/node": "^20.10.0",
22
- "@typescript-eslint/eslint-plugin": "^6.13.1",
23
- "@typescript-eslint/parser": "^6.13.1",
24
- "babel-jest": "^29.7.0",
25
- "dotenv": "^16.3.1",
26
- "eslint": "^8.54.0",
27
- "eslint-config-prettier": "^9.0.0",
28
- "eslint-config-xo": "^0.43.1",
29
- "eslint-config-xo-typescript": "^1.0.1",
30
- "husky": "^8.0.0",
31
- "jest": "^29.7.0",
32
- "lint-staged": "^16.2.7",
33
- "prettier": "^3.1.0",
34
- "ts-jest": "^29.1.1",
35
- "tsup": "^8.0.1",
36
- "typescript": "^5.3.2"
37
- },
38
- "dependencies": {
39
- "@mysten/kiosk": "^1.3.1",
40
- "@mysten/sui": "^2.20.0",
41
- "@types/analytics-node": "^3.1.14",
42
- "analytics-node": "^6.2.0",
43
- "bignumber.js": "^9.3.1",
44
- "graphql": "^16.12.0",
45
- "graphql-request": "^6.1.0",
46
- "ms": "^2.1.3"
47
- },
48
- "publishConfig": {
49
- "access": "public",
50
- "registry": "https://registry.npmjs.org/"
51
- },
52
- "lint-staged": {
53
- "*.ts": [
54
- "eslint --fix",
55
- "bash -c 'tsc --noEmit'",
56
- "prettier --write"
57
- ]
58
- },
59
- "scripts": {
60
- "build": "tsup src/index.ts --sourcemap --format esm --dts",
61
- "release": "pnpm run build && changeset publish",
62
- "lint": "tsc && eslint --fix src/* --ignore-path .gitignore --ext .js,.ts",
63
- "format": "prettier --write \"**/*.+(js|ts|json)\"",
64
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
65
- "pre-commit": "lint-staged"
66
- }
67
- }
2
+ "name": "@tradeport/sui-trading-sdk",
3
+ "license": "MIT",
4
+ "version": "0.5.2",
5
+ "type": "module",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup src/index.ts --sourcemap --format esm --dts",
17
+ "release": "pnpm run build && changeset publish",
18
+ "lint": "tsc && eslint --fix src/* --ignore-path .gitignore --ext .js,.ts",
19
+ "format": "prettier --write \"**/*.+(js|ts|json)\"",
20
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
21
+ "prepare": "husky install",
22
+ "pre-commit": "lint-staged"
23
+ },
24
+ "devDependencies": {
25
+ "@babel/core": "^7.23.3",
26
+ "@babel/preset-env": "^7.23.3",
27
+ "@changesets/cli": "^2.26.2",
28
+ "@types/jest": "^29.5.10",
29
+ "@types/ms": "^2.1.0",
30
+ "@types/node": "^20.10.0",
31
+ "@typescript-eslint/eslint-plugin": "^6.13.1",
32
+ "@typescript-eslint/parser": "^6.13.1",
33
+ "babel-jest": "^29.7.0",
34
+ "dotenv": "^16.3.1",
35
+ "eslint": "^8.54.0",
36
+ "eslint-config-prettier": "^9.0.0",
37
+ "eslint-config-xo": "^0.43.1",
38
+ "eslint-config-xo-typescript": "^1.0.1",
39
+ "husky": "^8.0.0",
40
+ "jest": "^29.7.0",
41
+ "lint-staged": "^16.2.7",
42
+ "prettier": "^3.1.0",
43
+ "ts-jest": "^29.1.1",
44
+ "tsup": "^8.0.1",
45
+ "typescript": "^5.3.2"
46
+ },
47
+ "dependencies": {
48
+ "@mysten/kiosk": "^1.3.1",
49
+ "@mysten/sui": "^2.20.0",
50
+ "@types/analytics-node": "^3.1.14",
51
+ "analytics-node": "^6.2.0",
52
+ "bignumber.js": "^9.3.1",
53
+ "graphql": "^16.12.0",
54
+ "graphql-request": "^6.1.0",
55
+ "ms": "^2.1.3"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public",
59
+ "registry": "https://registry.npmjs.org/"
60
+ },
61
+ "lint-staged": {
62
+ "*.ts": [
63
+ "eslint --fix",
64
+ "bash -c 'tsc --noEmit'",
65
+ "prettier --write"
66
+ ]
67
+ }
68
+ }
@@ -1,6 +1,30 @@
1
+ import { normalizeStructTag } from '@mysten/sui/utils';
1
2
  import { ORIGIN_BYTE_BID_NONCE_TYPE } from '../../constants';
2
3
 
3
- export const isOriginByteBid = (bidType: string): boolean =>
4
- bidType === ORIGIN_BYTE_BID_NONCE_TYPE ||
5
- bidType === '0x2::Kiosk::Kiosk' ||
6
- bidType === '0x2::kiosk::Kiosk';
4
+ // The gRPC client returns Move types with fully-padded addresses
5
+ // (e.g. `0x0000…0002::kiosk::Kiosk`), while the JSON-RPC client used the
6
+ // abbreviated form (`0x2::kiosk::Kiosk`). Normalize both sides so the
7
+ // comparison is independent of address format / type-argument padding.
8
+ const safeNormalizeStructTag = (type: string): string => {
9
+ try {
10
+ return normalizeStructTag(type);
11
+ } catch {
12
+ return type;
13
+ }
14
+ };
15
+
16
+ // Precomputed once. `normalizeStructTag` preserves module-name casing, so the
17
+ // legacy capitalized `Kiosk` variant is kept alongside the canonical lowercase one.
18
+ const ORIGIN_BYTE_BID_TYPES = new Set(
19
+ [ORIGIN_BYTE_BID_NONCE_TYPE, '0x2::kiosk::Kiosk', '0x2::Kiosk::Kiosk'].map(
20
+ safeNormalizeStructTag,
21
+ ),
22
+ );
23
+
24
+ export const isOriginByteBid = (bidType: string): boolean => {
25
+ if (!bidType) {
26
+ return false;
27
+ }
28
+
29
+ return ORIGIN_BYTE_BID_TYPES.has(safeNormalizeStructTag(bidType));
30
+ };
package/dist/index.d.mts DELETED
@@ -1,193 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { GraphQLClient } from 'graphql-request';
3
- import { KioskTransaction } from '@mysten/kiosk';
4
-
5
- type AcceptCollectionBid = {
6
- bidId: string;
7
- nftId: string;
8
- walletAddress: string;
9
- };
10
-
11
- type AcceptNftBids = {
12
- bidIds: string[];
13
- walletAddress: string;
14
- tx?: Transaction;
15
- kioskTx?: KioskTransaction;
16
- beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
17
- };
18
-
19
- type ApplyFtStrategy = {
20
- collectionId: string;
21
- strategyFtType?: string;
22
- tx?: Transaction;
23
- collectionChainState?: Record<string, unknown>;
24
- };
25
-
26
- type ApplyNftStrategy = {
27
- collectionId: string;
28
- strategyFtType?: string;
29
- tx?: Transaction;
30
- };
31
-
32
- type BuyListings = {
33
- listingIds: string[];
34
- walletAddress: string;
35
- tx?: Transaction;
36
- kioskTx?: KioskTransaction;
37
- coinToSplit?: any;
38
- beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
39
- };
40
-
41
- interface CancelMultiBid {
42
- walletAddress: string;
43
- multiBidId: string;
44
- }
45
-
46
- type CancelNftTransfers = {
47
- nftIds: string[];
48
- walletAddress: string;
49
- };
50
-
51
- type ClaimNfts = {
52
- nftIds: string[];
53
- walletAddress: string;
54
- tx?: Transaction;
55
- };
56
-
57
- interface CreateMultiBid {
58
- walletAddress: string;
59
- name?: string;
60
- amount?: bigint;
61
- tx?: Transaction;
62
- }
63
-
64
- type SponsorNftListingOptions = {
65
- shouldSponsor?: boolean;
66
- numOfPeriods?: number;
67
- usdcFeeAmountPerPeriod?: number;
68
- coinToSplit?: any;
69
- };
70
- type SponsorNftListing = {
71
- tx?: Transaction;
72
- nftTokenId: string;
73
- options: SponsorNftListingOptions;
74
- };
75
-
76
- type ListNfts = {
77
- nfts: Array<{
78
- id: string;
79
- listPriceInMist: number;
80
- sponsorOptions?: SponsorNftListingOptions;
81
- }>;
82
- walletAddress: string;
83
- tx?: Transaction;
84
- };
85
-
86
- type MigrateNftsFromUnsharedToSharedKiosks = {
87
- walletAddress: string;
88
- max?: number;
89
- };
90
-
91
- type PlaceCollectionBid = {
92
- collectionId: string;
93
- bidAmountInMist: number;
94
- numOfBids: number;
95
- walletAddress: string;
96
- multiBidId?: string;
97
- multiBidChainId?: any;
98
- expireAt?: Date;
99
- tx?: Transaction;
100
- };
101
-
102
- type PlaceNftBids = {
103
- bids: Array<{
104
- nftId: string;
105
- bidAmountInMist: number;
106
- expireAt?: Date;
107
- }>;
108
- walletAddress: string;
109
- multiBidId?: string;
110
- multiBidChainId?: any;
111
- tx?: Transaction;
112
- coinToSplit?: any;
113
- };
114
-
115
- type RemoveCollectionBids = {
116
- bidIds: string[];
117
- tx?: Transaction | string;
118
- };
119
-
120
- type RemoveNftBids = {
121
- bidIds: string[];
122
- tx?: Transaction | string;
123
- };
124
-
125
- type TransferNfts = {
126
- nftIds: string[];
127
- recipientAddress: string;
128
- walletAddress: string;
129
- };
130
-
131
- type UnlistListings = {
132
- listingIds: string[];
133
- walletAddress: string;
134
- };
135
-
136
- interface UpdateMultiBid {
137
- walletAddress: string;
138
- multiBidId?: string;
139
- name?: string;
140
- amount?: bigint;
141
- amountToWithdraw?: bigint;
142
- tx?: Transaction;
143
- multiBidChainId?: any;
144
- coinToSplit?: any;
145
- }
146
-
147
- type WithdrawProfitsFromKiosks = {
148
- walletAddress: string;
149
- };
150
-
151
- type ApiConfig = {
152
- apiUser: string;
153
- apiKey: string;
154
- apiUrl?: string;
155
- tradeportRouterUrl?: string;
156
- apiVercelId?: string;
157
- suiNodeUrl?: string;
158
- graphQLClient?: GraphQLClient;
159
- };
160
- declare class SuiTradingClient {
161
- private readonly apiUser;
162
- private readonly apiKey;
163
- private readonly tradeportRouterUrl?;
164
- private readonly suiClient;
165
- private readonly kioskClient;
166
- private readonly allowedApiUsersForUnsharedKiosksMigration;
167
- constructor({ apiUser, apiKey, apiVercelId, apiUrl, tradeportRouterUrl, suiNodeUrl, graphQLClient, }: ApiConfig);
168
- buyListings(args: BuyListings): Promise<Transaction>;
169
- listNfts({ nfts, walletAddress, tx }: ListNfts): Promise<Transaction>;
170
- unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
171
- placeNftBids(data: PlaceNftBids): Promise<Transaction>;
172
- removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
173
- acceptNftBids({ bidIds, walletAddress }: AcceptNftBids): Promise<Transaction>;
174
- placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, multiBidId, multiBidChainId, expireAt, tx, }: PlaceCollectionBid): Promise<Transaction>;
175
- acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
176
- removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
177
- transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
178
- cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers): Promise<Transaction>;
179
- claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
180
- withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks): Promise<Transaction>;
181
- migrateNftsFromUnsharedToSharedKiosks(args: MigrateNftsFromUnsharedToSharedKiosks): Promise<Transaction>;
182
- createMultiBid(args: CreateMultiBid): Promise<{
183
- multiBidChainId: any;
184
- tx: Transaction;
185
- }>;
186
- cancelMultiBid(args: CancelMultiBid): Promise<Transaction>;
187
- updateMultiBid(args: UpdateMultiBid): Promise<Transaction>;
188
- sponsorNftListing(args: SponsorNftListing): Promise<Transaction>;
189
- applyFtStrategy(args: ApplyFtStrategy): Promise<Transaction>;
190
- applyTradeportNftStrategy(args: ApplyNftStrategy): Promise<Transaction>;
191
- }
192
-
193
- export { SuiTradingClient };
package/dist/index.d.ts DELETED
@@ -1,194 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { GraphQLClient } from 'graphql-request';
3
- import { KioskTransaction } from '@mysten/kiosk';
4
-
5
- type AcceptCollectionBid = {
6
- bidId: string;
7
- nftId: string;
8
- walletAddress: string;
9
- };
10
-
11
- type AcceptNftBids = {
12
- bidIds: string[];
13
- walletAddress: string;
14
- tx?: Transaction;
15
- kioskTx?: KioskTransaction;
16
- beforeResolveKioskTransferRequest?: (coin: any, transferRequest: any) => void | Promise<void>;
17
- };
18
-
19
- type ApplyFtStrategy = {
20
- collectionId: string;
21
- strategyFtType?: string;
22
- tx?: Transaction;
23
- collectionChainState?: Record<string, unknown>;
24
- };
25
-
26
- type ApplyNftStrategy = {
27
- collectionId: string;
28
- strategyFtType?: string;
29
- tx?: Transaction;
30
- };
31
-
32
- type BuyListings = {
33
- listingIds: string[];
34
- walletAddress: string;
35
- tx?: Transaction;
36
- kioskTx?: KioskTransaction;
37
- coinToSplit?: any;
38
- beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
39
- };
40
-
41
- interface CancelMultiBid {
42
- walletAddress: string;
43
- multiBidId: string;
44
- }
45
-
46
- type CancelNftTransfers = {
47
- nftIds: string[];
48
- walletAddress: string;
49
- };
50
-
51
- type ClaimNfts = {
52
- nftIds: string[];
53
- walletAddress: string;
54
- tx?: Transaction;
55
- };
56
-
57
- interface CreateMultiBid {
58
- walletAddress: string;
59
- name?: string;
60
- amount?: bigint;
61
- tx?: Transaction;
62
- }
63
-
64
- type SponsorNftListingOptions = {
65
- shouldSponsor?: boolean;
66
- numOfPeriods?: number;
67
- usdcFeeAmountPerPeriod?: number;
68
- coinToSplit?: any;
69
- };
70
- type SponsorNftListing = {
71
- tx?: Transaction;
72
- nftTokenId: string;
73
- options: SponsorNftListingOptions;
74
- };
75
-
76
- type ListNfts = {
77
- nfts: Array<{
78
- id: string;
79
- listPriceInMist: number;
80
- sponsorOptions?: SponsorNftListingOptions;
81
- }>;
82
- walletAddress: string;
83
- tx?: Transaction;
84
- };
85
-
86
- type MigrateNftsFromUnsharedToSharedKiosks = {
87
- walletAddress: string;
88
- max?: number;
89
- };
90
-
91
- type PlaceCollectionBid = {
92
- collectionId: string;
93
- bidAmountInMist: number;
94
- numOfBids: number;
95
- walletAddress: string;
96
- multiBidId?: string;
97
- multiBidChainId?: any;
98
- expireAt?: Date;
99
- tx?: Transaction;
100
- };
101
-
102
- type PlaceNftBids = {
103
- bids: Array<{
104
- nftId: string;
105
- bidAmountInMist: number;
106
- expireAt?: Date;
107
- }>;
108
- walletAddress: string;
109
- multiBidId?: string;
110
- multiBidChainId?: any;
111
- tx?: Transaction;
112
- coinToSplit?: any;
113
- };
114
-
115
- type RemoveCollectionBids = {
116
- bidIds: string[];
117
- tx?: Transaction | string;
118
- };
119
-
120
- type RemoveNftBids = {
121
- bidIds: string[];
122
- tx?: Transaction | string;
123
- };
124
-
125
- type TransferNfts = {
126
- nftIds: string[];
127
- recipientAddress: string;
128
- walletAddress: string;
129
- };
130
-
131
- type UnlistListings = {
132
- listingIds: string[];
133
- walletAddress: string;
134
- };
135
-
136
- interface UpdateMultiBid {
137
- walletAddress: string;
138
- multiBidId?: string;
139
- name?: string;
140
- amount?: bigint;
141
- amountToWithdraw?: bigint;
142
- tx?: Transaction;
143
- multiBidChainId?: any;
144
- coinToSplit?: any;
145
- }
146
-
147
- type WithdrawProfitsFromKiosks = {
148
- walletAddress: string;
149
- };
150
-
151
- type ApiConfig = {
152
- apiUser: string;
153
- apiKey: string;
154
- apiUrl?: string;
155
- tradeportRouterUrl?: string;
156
- apiVercelId?: string;
157
- suiNodeUrl?: string;
158
- suiGraphqlUrl?: string;
159
- graphQLClient?: GraphQLClient;
160
- };
161
- declare class SuiTradingClient {
162
- private readonly apiUser;
163
- private readonly apiKey;
164
- private readonly tradeportRouterUrl?;
165
- private readonly suiClient;
166
- private readonly kioskClient;
167
- private readonly allowedApiUsersForUnsharedKiosksMigration;
168
- constructor({ apiUser, apiKey, apiVercelId, apiUrl, tradeportRouterUrl, suiNodeUrl, suiGraphqlUrl, graphQLClient, }: ApiConfig);
169
- buyListings(args: BuyListings): Promise<Transaction>;
170
- listNfts({ nfts, walletAddress, tx }: ListNfts): Promise<Transaction>;
171
- unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
172
- placeNftBids(data: PlaceNftBids): Promise<Transaction>;
173
- removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
174
- acceptNftBids({ bidIds, walletAddress }: AcceptNftBids): Promise<Transaction>;
175
- placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, multiBidId, multiBidChainId, expireAt, tx, }: PlaceCollectionBid): Promise<Transaction>;
176
- acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
177
- removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
178
- transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
179
- cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers): Promise<Transaction>;
180
- claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
181
- withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks): Promise<Transaction>;
182
- migrateNftsFromUnsharedToSharedKiosks(args: MigrateNftsFromUnsharedToSharedKiosks): Promise<Transaction>;
183
- createMultiBid(args: CreateMultiBid): Promise<{
184
- multiBidChainId: any;
185
- tx: Transaction;
186
- }>;
187
- cancelMultiBid(args: CancelMultiBid): Promise<Transaction>;
188
- updateMultiBid(args: UpdateMultiBid): Promise<Transaction>;
189
- sponsorNftListing(args: SponsorNftListing): Promise<Transaction>;
190
- applyFtStrategy(args: ApplyFtStrategy): Promise<Transaction>;
191
- applyTradeportNftStrategy(args: ApplyNftStrategy): Promise<Transaction>;
192
- }
193
-
194
- export { SuiTradingClient };