@tradeport/sui-trading-sdk 0.0.7 → 0.1.0

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +47 -0
  3. package/dist/index.d.ts +47 -0
  4. package/dist/index.js +466 -33
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +466 -33
  7. package/dist/index.mjs.map +1 -1
  8. package/jest.config.js +1 -0
  9. package/package.json +1 -1
  10. package/src/SuiTradingClient.ts +25 -0
  11. package/src/constants.ts +6 -1
  12. package/src/graphql/queries/fetchBidsById.ts +1 -0
  13. package/src/graphql/queries/fetchCollectionsById.ts +8 -0
  14. package/src/graphql/queries/fetchLockById.ts +22 -0
  15. package/src/helpers/calculatePremium.ts +9 -0
  16. package/src/helpers/calculateRoyaltyFee.ts +12 -0
  17. package/src/helpers/getLockById.ts +27 -0
  18. package/src/helpers/kiosk/kioskTxWrapper.ts +7 -1
  19. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +4 -4
  20. package/src/methods/acceptNftBids/acceptNftBids.ts +10 -2
  21. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +5 -4
  22. package/src/methods/buyAndExerciseLock/buyAndExerciseLock.ts +10 -0
  23. package/src/methods/buyListings/addBuyListingTxs.ts +6 -3
  24. package/src/methods/buyListings/buyListings.ts +7 -1
  25. package/src/methods/buyLock/buyLock.ts +38 -0
  26. package/src/methods/cancelLock/cancelLock.ts +39 -0
  27. package/src/methods/claimNfts/addClaimNftsTxs.ts +1 -1
  28. package/src/methods/claimNfts/claimNfts.ts +7 -2
  29. package/src/methods/createLock/createLock.ts +117 -0
  30. package/src/methods/exerciseLock/exerciseLock.ts +257 -0
  31. package/src/methods/listNfts/addRelistTxs.ts +3 -3
  32. package/src/methods/removeCollectionBid/addRemoveCollectionBidTxs.ts +3 -3
  33. package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +5 -5
  34. package/src/methods/unlistListings/addUnlistListingTxs.ts +4 -4
  35. package/src/tests/SuiWallet.ts +25 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b3943d9: Added Price Lock methods and migrated @mysten/sui.js to @mysten/sui
8
+
9
+ ## 0.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - 6fbc348: Switching back to @mysten/sui.js instead of @mysten/sui
14
+
3
15
  ## 0.0.7
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Transaction } from '@mysten/sui/transactions';
2
+ import { KioskTransaction } from '@mysten/kiosk';
2
3
 
3
4
  type AcceptCollectionBid = {
4
5
  bidId: string;
@@ -8,16 +9,21 @@ type AcceptCollectionBid = {
8
9
 
9
10
  type AcceptNftBids = {
10
11
  bidIds: string[];
12
+ tx?: Transaction;
13
+ kioskTx?: KioskTransaction;
11
14
  };
12
15
 
13
16
  type BuyListings = {
14
17
  listingIds: string[];
15
18
  walletAddress: string;
19
+ tx?: Transaction;
20
+ kioskTx?: KioskTransaction;
16
21
  };
17
22
 
18
23
  type ClaimNfts = {
19
24
  nftIds: string[];
20
25
  walletAddress: string;
26
+ tx?: Transaction;
21
27
  };
22
28
 
23
29
  type ListNfts = {
@@ -67,6 +73,42 @@ type WithdrawKioskProfits = {
67
73
  walletAddress: string;
68
74
  };
69
75
 
76
+ type CreateLockCommon = {
77
+ type: string;
78
+ nftType?: string;
79
+ collectionId?: string;
80
+ price: bigint;
81
+ };
82
+ type CreateLongLock = CreateLockCommon & {
83
+ type: 'long';
84
+ nftId: string;
85
+ walletAddress: string;
86
+ };
87
+ type CreateShortLock = CreateLockCommon & {
88
+ type: 'short';
89
+ nftType: string;
90
+ };
91
+ type CreateLock = CreateLongLock | CreateShortLock;
92
+
93
+ type CancelLock = {
94
+ lockId: string;
95
+ walletAddress: string;
96
+ };
97
+
98
+ type BuyLock = {
99
+ lockId: string;
100
+ tx?: Transaction;
101
+ };
102
+
103
+ type ExerciseLock = {
104
+ lockId: string;
105
+ walletAddress: string;
106
+ bidId?: string;
107
+ listingId?: string;
108
+ nftId?: string;
109
+ tx?: Transaction;
110
+ };
111
+
70
112
  type ApiConfig = {
71
113
  apiUser: string;
72
114
  apiKey: string;
@@ -85,6 +127,11 @@ declare class SuiTradingClient {
85
127
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
86
128
  claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
87
129
  withdrawKioskProfits({ amount, walletAddress }: WithdrawKioskProfits): Promise<Transaction>;
130
+ createLock(args: CreateLock): Promise<Transaction>;
131
+ cancelLock(args: CancelLock): Promise<Transaction>;
132
+ buyLock(args: BuyLock): Promise<Transaction>;
133
+ exerciseLock(args: ExerciseLock): Promise<Transaction>;
134
+ buyAndExerciseLock(args: BuyLock & ExerciseLock): Promise<Transaction>;
88
135
  }
89
136
 
90
137
  export { SuiTradingClient };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Transaction } from '@mysten/sui/transactions';
2
+ import { KioskTransaction } from '@mysten/kiosk';
2
3
 
3
4
  type AcceptCollectionBid = {
4
5
  bidId: string;
@@ -8,16 +9,21 @@ type AcceptCollectionBid = {
8
9
 
9
10
  type AcceptNftBids = {
10
11
  bidIds: string[];
12
+ tx?: Transaction;
13
+ kioskTx?: KioskTransaction;
11
14
  };
12
15
 
13
16
  type BuyListings = {
14
17
  listingIds: string[];
15
18
  walletAddress: string;
19
+ tx?: Transaction;
20
+ kioskTx?: KioskTransaction;
16
21
  };
17
22
 
18
23
  type ClaimNfts = {
19
24
  nftIds: string[];
20
25
  walletAddress: string;
26
+ tx?: Transaction;
21
27
  };
22
28
 
23
29
  type ListNfts = {
@@ -67,6 +73,42 @@ type WithdrawKioskProfits = {
67
73
  walletAddress: string;
68
74
  };
69
75
 
76
+ type CreateLockCommon = {
77
+ type: string;
78
+ nftType?: string;
79
+ collectionId?: string;
80
+ price: bigint;
81
+ };
82
+ type CreateLongLock = CreateLockCommon & {
83
+ type: 'long';
84
+ nftId: string;
85
+ walletAddress: string;
86
+ };
87
+ type CreateShortLock = CreateLockCommon & {
88
+ type: 'short';
89
+ nftType: string;
90
+ };
91
+ type CreateLock = CreateLongLock | CreateShortLock;
92
+
93
+ type CancelLock = {
94
+ lockId: string;
95
+ walletAddress: string;
96
+ };
97
+
98
+ type BuyLock = {
99
+ lockId: string;
100
+ tx?: Transaction;
101
+ };
102
+
103
+ type ExerciseLock = {
104
+ lockId: string;
105
+ walletAddress: string;
106
+ bidId?: string;
107
+ listingId?: string;
108
+ nftId?: string;
109
+ tx?: Transaction;
110
+ };
111
+
70
112
  type ApiConfig = {
71
113
  apiUser: string;
72
114
  apiKey: string;
@@ -85,6 +127,11 @@ declare class SuiTradingClient {
85
127
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
86
128
  claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
87
129
  withdrawKioskProfits({ amount, walletAddress }: WithdrawKioskProfits): Promise<Transaction>;
130
+ createLock(args: CreateLock): Promise<Transaction>;
131
+ cancelLock(args: CancelLock): Promise<Transaction>;
132
+ buyLock(args: BuyLock): Promise<Transaction>;
133
+ exerciseLock(args: ExerciseLock): Promise<Transaction>;
134
+ buyAndExerciseLock(args: BuyLock & ExerciseLock): Promise<Transaction>;
88
135
  }
89
136
 
90
137
  export { SuiTradingClient };