@tradeport/sui-trading-sdk 0.5.1 → 0.5.3

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 (154) hide show
  1. package/dist/index.js +19 -1
  2. package/dist/index.js.map +1 -1
  3. package/package.json +71 -66
  4. package/.babel.config.js +0 -3
  5. package/.claude/settings.json +0 -5
  6. package/.env.demo +0 -5
  7. package/.eslintrc.json +0 -46
  8. package/.prettierignore +0 -4
  9. package/.prettierrc.json +0 -7
  10. package/.vscode/launch.json +0 -23
  11. package/CHANGELOG.md +0 -746
  12. package/dist/index.d.mts +0 -193
  13. package/dist/index.mjs +0 -7386
  14. package/dist/index.mjs.map +0 -1
  15. package/jest.config.js +0 -12
  16. package/src/SuiTradingClient.ts +0 -442
  17. package/src/apiClients/createKioskClient.ts +0 -10
  18. package/src/apiClients/createSuiClient.ts +0 -5
  19. package/src/apiClients/graphqlClient.ts +0 -17
  20. package/src/bigNumberConfig.ts +0 -10
  21. package/src/constants.ts +0 -1052
  22. package/src/graphql/createChainGQLQuery.ts +0 -27
  23. package/src/graphql/gqlChainRequest.ts +0 -21
  24. package/src/graphql/queries/fetchAccountKiosks.ts +0 -12
  25. package/src/graphql/queries/fetchActiveLockStateByNftId.ts +0 -15
  26. package/src/graphql/queries/fetchBidsById.ts +0 -36
  27. package/src/graphql/queries/fetchCollectionBidById.ts +0 -21
  28. package/src/graphql/queries/fetchCollectionBidsAtSamePrice.ts +0 -29
  29. package/src/graphql/queries/fetchCollectionChainState.ts +0 -17
  30. package/src/graphql/queries/fetchCollectionFloorListingForMarket.ts +0 -28
  31. package/src/graphql/queries/fetchCollectionFloorListings.ts +0 -15
  32. package/src/graphql/queries/fetchCollectionsById.ts +0 -39
  33. package/src/graphql/queries/fetchCommissionByListingId.ts +0 -13
  34. package/src/graphql/queries/fetchCryptoToUsdRate.ts +0 -13
  35. package/src/graphql/queries/fetchKiosksByOwner.ts +0 -14
  36. package/src/graphql/queries/fetchListingsById.ts +0 -29
  37. package/src/graphql/queries/fetchListingsByNftId.ts +0 -23
  38. package/src/graphql/queries/fetchLockById.ts +0 -23
  39. package/src/graphql/queries/fetchMultibidById.ts +0 -34
  40. package/src/graphql/queries/fetchNftCollectionChainState.ts +0 -12
  41. package/src/graphql/queries/fetchNftsById.ts +0 -75
  42. package/src/graphql/queries/fetchNftsByKioskId.ts +0 -45
  43. package/src/graphql/queries/fetchOwnerCapByKiosk.ts +0 -10
  44. package/src/graphql/queries/fetchPersonalCapByKiosk.ts +0 -10
  45. package/src/graphql/queries/fetchSharedObjectsByType.ts +0 -12
  46. package/src/graphql/queries/fetchTransferPoliciesByType.ts +0 -12
  47. package/src/graphql/queries/fetchWalletKiosks.ts +0 -14
  48. package/src/graphql/queries/getCommissionByListingId.ts +0 -15
  49. package/src/helpers/addOneDollarFee.ts +0 -17
  50. package/src/helpers/addThirdPartyTxFee.ts +0 -17
  51. package/src/helpers/calculatePremium.ts +0 -9
  52. package/src/helpers/calculateRoyaltyFee.ts +0 -28
  53. package/src/helpers/destroyZeroCoin.ts +0 -14
  54. package/src/helpers/getActiveLockStateByNftId.ts +0 -15
  55. package/src/helpers/getCollectionChainState.ts +0 -31
  56. package/src/helpers/getCollectionFloorPrice.ts +0 -12
  57. package/src/helpers/getLockById.ts +0 -29
  58. package/src/helpers/getMarketFeePrice.ts +0 -82
  59. package/src/helpers/getNftType.ts +0 -38
  60. package/src/helpers/getRoyaltyRuleModule.ts +0 -7
  61. package/src/helpers/getSharedObjects.ts +0 -119
  62. package/src/helpers/getSuiToUsdRate.ts +0 -14
  63. package/src/helpers/getTradeportBiddingContractBidAmount.ts +0 -31
  64. package/src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts +0 -24
  65. package/src/helpers/hasPersonalKioskRule.ts +0 -7
  66. package/src/helpers/hasRoyaltyRule.ts +0 -7
  67. package/src/helpers/hasTransferPolicyRules.ts +0 -6
  68. package/src/helpers/isExpiredListing.ts +0 -9
  69. package/src/helpers/isNonKioskListing.ts +0 -14
  70. package/src/helpers/isSIngleBid.ts +0 -13
  71. package/src/helpers/kiosk/assertNftInSharedKiosk.ts +0 -31
  72. package/src/helpers/kiosk/getKioskCollectionRoyaltyFeeAmount.ts +0 -71
  73. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +0 -29
  74. package/src/helpers/kiosk/getKioskPlaceBidCoin.ts +0 -59
  75. package/src/helpers/kiosk/getNativeKioskTransferPolicies.ts +0 -29
  76. package/src/helpers/kiosk/getNativeKioskTransferPoliciesByNftType.ts +0 -21
  77. package/src/helpers/kiosk/getRulePackageId.ts +0 -59
  78. package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +0 -154
  79. package/src/helpers/kiosk/isBluemoveKioskBid.ts +0 -1
  80. package/src/helpers/kiosk/isTradePortKioskBid.ts +0 -4
  81. package/src/helpers/kiosk/kioskListingBcs.ts +0 -19
  82. package/src/helpers/kiosk/kioskTxWrapper.ts +0 -152
  83. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +0 -100
  84. package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +0 -171
  85. package/src/helpers/kiosk/resolveCustomTransferPolicyRules.ts +0 -75
  86. package/src/helpers/kiosk/resolveFloorPriceRule.ts +0 -21
  87. package/src/helpers/kiosk/resolveKioskLockRule.ts +0 -47
  88. package/src/helpers/kiosk/resolvePersonalKioskRule.ts +0 -23
  89. package/src/helpers/kiosk/resolveRoyaltyRule.ts +0 -57
  90. package/src/helpers/kiosk/resolveTableAllowlistRule.ts +0 -34
  91. package/src/helpers/kiosk/resolveTransferPolicies.ts +0 -158
  92. package/src/helpers/kiosk/sharedKioskState.type.ts +0 -11
  93. package/src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts +0 -50
  94. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +0 -73
  95. package/src/helpers/kiosk/upgradeKioskRulesPackageId.ts +0 -17
  96. package/src/helpers/originByte/confirmOBTranfer.ts +0 -33
  97. package/src/helpers/originByte/createOBKiosk.ts +0 -14
  98. package/src/helpers/originByte/depositNftIntoOBKiosk.ts +0 -16
  99. package/src/helpers/originByte/getOBBidderKiosk.ts +0 -12
  100. package/src/helpers/originByte/getOBKiosk.ts +0 -24
  101. package/src/helpers/originByte/getOrCreateOBKiosk.ts +0 -42
  102. package/src/helpers/originByte/isOBKiosk.ts +0 -13
  103. package/src/helpers/originByte/isOriginByteBid.ts +0 -6
  104. package/src/helpers/originByte/isOriginByteCollection.ts +0 -11
  105. package/src/helpers/originByte/shareOriginByteKiosk.ts +0 -14
  106. package/src/helpers/rpc/getAcountBalance.ts +0 -18
  107. package/src/helpers/rpc/getObjectType.ts +0 -25
  108. package/src/helpers/splitCoins.ts +0 -12
  109. package/src/helpers/track.ts +0 -20
  110. package/src/helpers/validateMinFloorPrice.ts +0 -22
  111. package/src/index.ts +0 -2
  112. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +0 -189
  113. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +0 -398
  114. package/src/methods/acceptNftBids/acceptNftBids.ts +0 -174
  115. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +0 -438
  116. package/src/methods/applyFtStrategy/applyFtStrategy.ts +0 -55
  117. package/src/methods/applyNftStrategy/applyNftStrategy.ts +0 -90
  118. package/src/methods/buyListings/addBuyListingTxs.ts +0 -803
  119. package/src/methods/buyListings/buyListings.ts +0 -230
  120. package/src/methods/cancelMultiBid/cancelMultiBid.ts +0 -51
  121. package/src/methods/cancelNftTransfers/addCancelNftTransfersTx.ts +0 -20
  122. package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +0 -118
  123. package/src/methods/claimNfts/addClaimNftsTxs.ts +0 -247
  124. package/src/methods/claimNfts/claimNfts.ts +0 -270
  125. package/src/methods/createMultiBid/createMultiBid.ts +0 -36
  126. package/src/methods/listNfts/addListTxs.ts +0 -210
  127. package/src/methods/listNfts/addRelistTxs.ts +0 -87
  128. package/src/methods/listNfts/listNfts.ts +0 -152
  129. package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +0 -226
  130. package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +0 -149
  131. package/src/methods/placeCollectionBids/placeCollectionBids.ts +0 -153
  132. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +0 -154
  133. package/src/methods/placeNftBids/placeNftBids.ts +0 -111
  134. package/src/methods/relistNft/relistNft.ts +0 -153
  135. package/src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts +0 -132
  136. package/src/methods/removeCollectionBids/removeCollectionBids.ts +0 -117
  137. package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +0 -122
  138. package/src/methods/removeNftBids/removeNftBids.ts +0 -116
  139. package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +0 -40
  140. package/src/methods/sponsorNftListing/sponsorNftListing.ts +0 -60
  141. package/src/methods/transferNfts/addTransferNftTx.ts +0 -220
  142. package/src/methods/transferNfts/transferNfts.ts +0 -216
  143. package/src/methods/unlistListings/addUnlistListingTxs.ts +0 -399
  144. package/src/methods/unlistListings/unlistListings.ts +0 -158
  145. package/src/methods/updateMultiBid/updateMultiBid.ts +0 -66
  146. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +0 -100
  147. package/src/tests/SuiWallet.ts +0 -83
  148. package/src/utils/addHexPrefix.ts +0 -7
  149. package/src/utils/addLeadingZerosAfter0x.ts +0 -9
  150. package/src/utils/normalizeNftType.ts +0 -7
  151. package/src/utils/printTxBlockTxs.ts +0 -11
  152. package/src/utils/pureValues.ts +0 -13
  153. package/src/utils/toUint8Array.ts +0 -12
  154. package/tsconfig.json +0 -16
@@ -1,270 +0,0 @@
1
- import type { KioskClient } from '@mysten/kiosk';
2
- import { type SuiGrpcClient } from '@mysten/sui/grpc';
3
- import { Transaction } from '@mysten/sui/transactions';
4
- import { type RequestContext } from '../../SuiTradingClient';
5
- import {
6
- BLUEMOVE_CLAIMABLE_CONTRACT_KEYS,
7
- DELOREAN_TOKEN_IDS_TO_DISABLE,
8
- DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE,
9
- } from '../../constants';
10
- import { gqlChainRequest } from '../../graphql/gqlChainRequest';
11
- import { fetchNftsById } from '../../graphql/queries/fetchNftsById';
12
- import { getNftType } from '../../helpers/getNftType';
13
- import { getSharedObjects } from '../../helpers/getSharedObjects';
14
- import { kioskTxWrapper } from '../../helpers/kiosk/kioskTxWrapper';
15
- import { type SharedKioskState } from '../../helpers/kiosk/sharedKioskState.type';
16
- import {
17
- addBluemoveClaimAcceptedBidNft,
18
- addClaimAcceptedBidNftTx,
19
- addClaimAcceptedBidNftWithPurchaseCapTx,
20
- addClaimTradeHoldTx,
21
- addClaimTransferredNftTx,
22
- addClaimTransferredNftWithPurchaseCapTx,
23
- } from './addClaimNftsTxs';
24
-
25
- export type ClaimTradeHoldTx = {
26
- tx: Transaction;
27
- kioskClient: KioskClient;
28
- sharedKioskState?: SharedKioskState;
29
- sharedObjects?: any;
30
- transferPolicies: any;
31
- nftType: string;
32
- claimableTradeId: string;
33
- claimableSellerKiosk: string;
34
- claimableBuyerKiosk: string;
35
- };
36
-
37
- export type ClaimTransferredNftTx = {
38
- tx: Transaction;
39
- suiClient?: SuiGrpcClient;
40
- kioskTx?: any;
41
- kioskClient: KioskClient;
42
- sharedKioskState?: SharedKioskState;
43
- sharedObjects?: any;
44
- transferPolicies: any;
45
- claimer: string;
46
- nftTokenId: string;
47
- nftType: string;
48
- sellerKiosk: string;
49
- seller: string;
50
- preloadedTransferPolicyId?: string;
51
- };
52
-
53
- export type ClaimAcceptedBidNftTx = {
54
- tx: Transaction;
55
- suiClient: SuiGrpcClient;
56
- kioskTx?: any;
57
- kioskClient: KioskClient;
58
- sharedKioskState?: SharedKioskState;
59
- sharedObjects?: any;
60
- transferPolicies: any;
61
- claimer: string;
62
- nftTokenId: string;
63
- nftType: string;
64
- sellerKiosk: string;
65
- seller: string;
66
- };
67
-
68
- export type ClaimNfts = {
69
- nftIds: string[];
70
- walletAddress: string;
71
- tx?: Transaction;
72
- };
73
- export const claimNfts = async (
74
- { nftIds, walletAddress, tx: existingTx }: ClaimNfts,
75
- context: RequestContext,
76
- useOldClaim?: boolean,
77
- ): Promise<Transaction> => {
78
- const res = await gqlChainRequest({
79
- chain: 'sui',
80
- query: fetchNftsById,
81
- variables: { nftIds },
82
- });
83
-
84
- if (res?.nfts?.length === 0) {
85
- throw new Error('No nfts found');
86
- }
87
-
88
- const nftsForTracking = [];
89
- const tx = existingTx ?? new Transaction();
90
-
91
- const sharedKioskState: SharedKioskState = {
92
- kioskTx: undefined,
93
- };
94
-
95
- for (const nft of res.nfts) {
96
- if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
97
- throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
98
- }
99
-
100
- if (!nft) {
101
- throw new Error('No nft found');
102
- }
103
-
104
- if (!nft?.chain_state?.claimable) {
105
- throw new Error(`Nft ID: ${nft?.id} is not claimable`);
106
- }
107
-
108
- const nftType = getNftType({
109
- collectionId: nft?.collection?.id,
110
- collectionChainState: nft?.collection?.chain_state,
111
- nft,
112
- });
113
-
114
- const transferPolicies = nft?.collection?.chain_state?.transfer_policies;
115
-
116
- // claim trade hold nft
117
- if (nft?.chain_state?.claimable_trade_id) {
118
- const txData: ClaimTradeHoldTx = {
119
- tx,
120
- kioskClient: context.kioskClient,
121
- transferPolicies,
122
- nftType,
123
- claimableTradeId: nft?.chain_state?.claimable_trade_id,
124
- claimableSellerKiosk: nft?.chain_state?.claimable_seller_kiosk,
125
- claimableBuyerKiosk: nft?.chain_state?.claimable_buyer_kiosk,
126
- sharedKioskState,
127
- };
128
-
129
- const sharedObjects = await getSharedObjects(nftType);
130
- addClaimTradeHoldTx({ ...txData, sharedObjects });
131
- continue;
132
- }
133
-
134
- // claim accepted bid nft
135
- if (
136
- ['accept-token-offer', 'accept-collection-offer']?.includes(
137
- nft?.chain_state?.claimable_reason,
138
- )
139
- ) {
140
- const txData: ClaimAcceptedBidNftTx = {
141
- tx,
142
- suiClient: context.suiClient,
143
- kioskClient: context.kioskClient,
144
- sharedKioskState,
145
- transferPolicies,
146
- claimer: walletAddress,
147
- nftType,
148
- nftTokenId: nft?.token_id,
149
- sellerKiosk: nft?.chain_state?.kiosk_id,
150
- seller: nft?.owner,
151
- };
152
-
153
- if (BLUEMOVE_CLAIMABLE_CONTRACT_KEYS?.includes(nft?.chain_state?.claimable_contract_key)) {
154
- await kioskTxWrapper({
155
- tx,
156
- kioskClient: context.kioskClient,
157
- kioskOwner: txData?.claimer,
158
- kiosk: txData?.sellerKiosk,
159
- shouldConvertToPersonalKiosk: true,
160
- shouldAllowNftUnsharedKiosk: true,
161
- sharedKioskState,
162
- async runCommands(kioskTx) {
163
- await addBluemoveClaimAcceptedBidNft({
164
- ...txData,
165
- suiClient: context.suiClient,
166
- kioskTx,
167
- });
168
- },
169
- });
170
-
171
- continue;
172
- }
173
-
174
- if (useOldClaim) {
175
- await kioskTxWrapper({
176
- tx,
177
- kioskClient: context.kioskClient,
178
- kioskOwner: txData?.claimer,
179
- kiosk: txData?.sellerKiosk,
180
- shouldConvertToPersonalKiosk: true,
181
- shouldAllowNftUnsharedKiosk: true,
182
- sharedKioskState,
183
- async runCommands(kioskTx) {
184
- await addClaimAcceptedBidNftTx({ ...txData, kioskTx });
185
- },
186
- });
187
- } else {
188
- await kioskTxWrapper({
189
- tx,
190
- kioskClient: context.kioskClient,
191
- kioskOwner: txData?.claimer,
192
- kiosk: txData?.sellerKiosk,
193
- shouldConvertToPersonalKiosk: true,
194
- shouldAssertNftInSharedKiosk: true,
195
- sharedKioskState,
196
- async runCommands(kioskTx) {
197
- await addClaimAcceptedBidNftWithPurchaseCapTx({ ...txData, kioskTx });
198
- },
199
- });
200
- }
201
-
202
- continue;
203
- }
204
-
205
- // claim transferred nft
206
- if (nft?.chain_state?.claimable_reason === 'offer-transfer') {
207
- const txData: ClaimTransferredNftTx = {
208
- tx,
209
- suiClient: context.suiClient,
210
- kioskClient: context.kioskClient,
211
- transferPolicies,
212
- claimer: walletAddress,
213
- nftType,
214
- nftTokenId: nft?.token_id,
215
- sellerKiosk: nft?.chain_state?.kiosk_id,
216
- seller: nft?.owner,
217
- sharedKioskState,
218
- };
219
-
220
- if (useOldClaim) {
221
- await kioskTxWrapper({
222
- tx,
223
- kioskClient: context.kioskClient,
224
- kioskOwner: txData?.claimer,
225
- kiosk: txData?.sellerKiosk,
226
- kioskStrategy: 'exclude',
227
- shouldConvertToPersonalKiosk: true,
228
- shouldAllowNftUnsharedKiosk: true,
229
- sharedKioskState,
230
- async runCommands(kioskTx) {
231
- await addClaimTransferredNftTx({ ...txData, kioskTx });
232
- },
233
- });
234
- } else {
235
- await kioskTxWrapper({
236
- tx,
237
- kioskClient: context.kioskClient,
238
- kioskOwner: txData?.claimer,
239
- kiosk: txData?.sellerKiosk,
240
- kioskStrategy: 'exclude',
241
- shouldConvertToPersonalKiosk: true,
242
- shouldAllowNftUnsharedKiosk: true,
243
- sharedKioskState,
244
- async runCommands(kioskTx) {
245
- await addClaimTransferredNftWithPurchaseCapTx({ ...txData, kioskTx });
246
- },
247
- });
248
- }
249
- }
250
-
251
- // nftsForTracking.push({
252
- // nftType,
253
- // claimer: walletAddress,
254
- // claimReason: nft?.chain_state?.claimable_reason,
255
- // });
256
- }
257
-
258
- sharedKioskState?.kioskTx?.finalize();
259
-
260
- // if (process.env.ENABLE_SEGMENT_TRACKING === 'true' && nftsForTracking.length > 0) {
261
- // trackMethodCall({
262
- // apiUser: context.apiUser,
263
- // apiKey: context.apiKey,
264
- // event: 'CLAIM_NFTS',
265
- // items: nftsForTracking,
266
- // });
267
- // }
268
-
269
- return Transaction.from(tx);
270
- };
@@ -1,36 +0,0 @@
1
- import { Transaction } from '@mysten/sui/transactions';
2
- import { TRADEPORT_MULTI_BID_PACKAGE, TRADEPORT_MULTI_BID_STORE } from '../../constants';
3
- import { updateMultiBid } from '../updateMultiBid/updateMultiBid';
4
-
5
- export interface CreateMultiBid {
6
- walletAddress: string;
7
- name?: string;
8
- amount?: bigint;
9
- tx?: Transaction;
10
- }
11
-
12
- export async function createMultiBid({
13
- walletAddress,
14
- name,
15
- amount,
16
- tx: existingTx,
17
- }: CreateMultiBid): Promise<{ multiBidChainId: any; tx: Transaction }> {
18
- const tx = existingTx ?? new Transaction();
19
-
20
- const multiBidChainId = tx.moveCall({
21
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
22
- arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option('string', name)],
23
- });
24
-
25
- if (amount > 0n) {
26
- await updateMultiBid({
27
- walletAddress,
28
- multiBidChainId,
29
- amount,
30
- name,
31
- tx,
32
- });
33
- }
34
-
35
- return { multiBidChainId, tx };
36
- }
@@ -1,210 +0,0 @@
1
- import {
2
- ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK,
3
- TRADEPORT_BENEFICIARY_ADDRESS,
4
- TRADEPORT_LISTINGS_PACKAGE,
5
- TRADEPORT_LISTINGS_STORE,
6
- TRADEPORT_ORDERBOOK_STORE,
7
- } from '../../constants';
8
- import { getMarketFeePrice } from '../../helpers/getMarketFeePrice';
9
- import { getSharedObjects } from '../../helpers/getSharedObjects';
10
- import { hasNativeKioskTransferPolicyRules } from '../../helpers/hasTransferPolicyRules';
11
- import { assertNftInSharedKiosk } from '../../helpers/kiosk/assertNftInSharedKiosk';
12
- import { kioskTxWrapper } from '../../helpers/kiosk/kioskTxWrapper';
13
- import { takeAndBorrowNftFromKiosk } from '../../helpers/kiosk/takeAndBorrowNftFromKiosk';
14
- import { depositItemIntoOBKiosk } from '../../helpers/originByte/depositNftIntoOBKiosk';
15
- import { getOrCreateOBKiosk } from '../../helpers/originByte/getOrCreateOBKiosk';
16
- import { isOriginByteCollection } from '../../helpers/originByte/isOriginByteCollection';
17
- import { shareOriginByteKiosk } from '../../helpers/originByte/shareOriginByteKiosk';
18
- import { normalizedNftType } from '../../utils/normalizeNftType';
19
- import { validateMinFloorPrice } from '../../helpers/validateMinFloorPrice';
20
- import { type ListNftTx } from './listNfts';
21
-
22
- export async function addOriginByteListTx({
23
- tx,
24
- sharedObjects,
25
- nftTokenId,
26
- nftType,
27
- seller,
28
- listPrice,
29
- collectionId,
30
- sellerKiosk,
31
- sharedKioskState,
32
- }: ListNftTx) {
33
- const { orderbook } = sharedObjects;
34
-
35
- await assertNftInSharedKiosk({
36
- kioskId: sellerKiosk,
37
- walletAddress: seller,
38
- sharedKioskState,
39
- });
40
-
41
- const { kiosk, isNewKiosk } = await getOrCreateOBKiosk({
42
- tx,
43
- address: seller,
44
- kioskToUseIfExists: sellerKiosk,
45
- sharedKioskState,
46
- });
47
-
48
- if (isNewKiosk) {
49
- depositItemIntoOBKiosk({
50
- tx,
51
- kiosk: sellerKiosk,
52
- nftTokenId,
53
- nftType,
54
- });
55
- }
56
-
57
- const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
58
-
59
- tx.moveCall({
60
- target:
61
- '0x8534e4cdfd28709c94330a9783c3d5fe6f5daba0bffb69102ce303c5b38aed5a::orderbook::create_ask_with_commission',
62
- arguments: [
63
- tx.object(orderbook),
64
- tx.object(kiosk),
65
- tx.pure.u64(listPrice),
66
- tx.pure.address(nftTokenId),
67
- tx.pure.address(TRADEPORT_BENEFICIARY_ADDRESS),
68
- tx.pure.u64(marketFeePrice),
69
- ],
70
- typeArguments: [nftType, '0x2::sui::SUI'],
71
- });
72
-
73
- if (isNewKiosk) {
74
- shareOriginByteKiosk({ tx, kiosk });
75
- }
76
- }
77
-
78
- export function addTradePortListTx({
79
- tx,
80
- nftTokenId,
81
- borrowedItem,
82
- nftType,
83
- listPrice,
84
- }: ListNftTx) {
85
- tx.moveCall({
86
- target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::create_ob_listing_without_transfer_policy`,
87
- arguments: [
88
- tx.object(TRADEPORT_LISTINGS_STORE),
89
- tx.object(TRADEPORT_ORDERBOOK_STORE),
90
- borrowedItem ? tx.object(borrowedItem) : tx.object(nftTokenId),
91
- tx.pure.u64(listPrice),
92
- ],
93
- typeArguments: [nftType],
94
- });
95
- }
96
-
97
- export async function addKioskTradePortListTx({
98
- tx,
99
- kioskTx,
100
- transferPolicies,
101
- nftTokenId,
102
- nftType,
103
- listPrice,
104
- seller,
105
- }: ListNftTx) {
106
- validateMinFloorPrice({ transferPolicies, listPrice });
107
-
108
- tx.moveCall({
109
- target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::create_ob_listing_with_transfer_policy`,
110
- arguments: [
111
- tx.object(TRADEPORT_LISTINGS_STORE),
112
- tx.object(TRADEPORT_ORDERBOOK_STORE),
113
- tx.object(kioskTx.kiosk),
114
- tx.object(kioskTx.kioskCap),
115
- tx.pure.address(seller),
116
- tx.pure.id(nftTokenId),
117
- tx.pure.u64(listPrice),
118
- ],
119
- typeArguments: [nftType],
120
- });
121
- }
122
-
123
- export async function addTradePortListTxHandler(txData: ListNftTx) {
124
- // If NFT is an Origin Byte collection, create an Origin Byte listing
125
- if (
126
- isOriginByteCollection(txData?.transferPolicies) &&
127
- !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))
128
- ) {
129
- const sharedObjects = await getSharedObjects(txData?.nftType);
130
- await addOriginByteListTx({ ...txData, sharedObjects });
131
-
132
- return;
133
- }
134
-
135
- // If nft has no transfer policy rule but is inside a kiosk, take it out of the kiosk
136
- if (
137
- !hasNativeKioskTransferPolicyRules(txData?.transferPolicies) &&
138
- txData?.sellerKiosk &&
139
- txData?.nftType !==
140
- '0xbf1431324a4a6eadd70e0ac6c5a16f36492f255ed4d011978b2cf34ad738efe6::day_one::DayOne'
141
- ) {
142
- return kioskTxWrapper({
143
- tx: txData?.tx,
144
- kioskClient: txData?.kioskClient,
145
- kioskOwner: txData?.seller,
146
- kiosk: txData?.sellerKiosk,
147
- shouldAssertNftInSharedKiosk: true,
148
- sharedKioskState: txData?.sharedKioskState,
149
- shouldUseSharedKioskTx: false,
150
- async runCommands(kioskTx) {
151
- const borrowedItem = await takeAndBorrowNftFromKiosk({
152
- tx: txData?.tx,
153
- transferPolicies: txData?.transferPolicies,
154
- kioskTx,
155
- kioskClient: txData?.kioskClient,
156
- nftTokenId: txData?.nftTokenId,
157
- nftType: txData?.nftType,
158
- suiClient: txData?.suiClient,
159
- kioskOwner: txData?.seller,
160
- });
161
-
162
- addTradePortListTx({ ...txData, borrowedItem });
163
- },
164
- });
165
- }
166
-
167
- // If NFT is in a kiosk, create a kiosk listing
168
- if (txData?.sellerKiosk) {
169
- return kioskTxWrapper({
170
- tx: txData?.tx,
171
- kioskClient: txData?.kioskClient,
172
- kioskOwner: txData?.seller,
173
- kiosk: txData?.sellerKiosk,
174
- shouldAssertNftInSharedKiosk: true,
175
- sharedKioskState: txData?.sharedKioskState,
176
- shouldUseSharedKioskTx: false,
177
- async runCommands(kioskTx) {
178
- await addKioskTradePortListTx({
179
- ...txData,
180
- kioskTx,
181
- });
182
- },
183
- });
184
- }
185
-
186
- // If NFT is not in a kiosk, but nft type has a transfer policy rule, create kiosk and place NFT in kiosk first
187
- if (!txData?.sellerKiosk && hasNativeKioskTransferPolicyRules(txData?.transferPolicies)) {
188
- return kioskTxWrapper({
189
- tx: txData?.tx,
190
- kioskClient: txData?.kioskClient,
191
- kioskOwner: txData?.seller,
192
- kiosk: txData?.sellerKiosk,
193
- sharedKioskState: txData?.sharedKioskState,
194
- shouldUseSharedKioskTx: false,
195
- async runCommands(kioskTx) {
196
- kioskTx.place({
197
- item: txData?.nftTokenId,
198
- itemType: txData?.nftType,
199
- });
200
- await addKioskTradePortListTx({
201
- ...txData,
202
- kioskTx,
203
- });
204
- },
205
- });
206
- }
207
-
208
- // Fallback to non-kiosk listing
209
- addTradePortListTx(txData);
210
- }
@@ -1,87 +0,0 @@
1
- import { type KioskClient, type ObjectArgument } from '@mysten/kiosk';
2
- import { type Transaction, type TransactionObjectArgument } from '@mysten/sui/transactions';
3
- import {
4
- BLUEMOVE_MARKET_CONFIG_OBJECT,
5
- TOCEN_MARKETPLACE_OBJECT,
6
- TRADEPORT_LISTINGS_PACKAGE,
7
- TRADEPORT_LISTINGS_STORE,
8
- TRADEPORT_ORDERBOOK_STORE,
9
- } from '../../constants';
10
- import { addTradePortListTx } from './addListTxs';
11
- import { type SuiGrpcClient } from '@mysten/sui/grpc';
12
-
13
- export type RelistNftTx = {
14
- tx: Transaction;
15
- suiClient: SuiGrpcClient;
16
- kioskTx?: any;
17
- kioskClient: KioskClient;
18
- transferPolicies: any;
19
- seller: string;
20
- collectionId: string;
21
- nftTokenId?: string;
22
- borrowedItem?: ObjectArgument;
23
- nftType: string;
24
- listPrice: number;
25
- listingNonce: string;
26
- sellerKiosk: string;
27
- };
28
-
29
- export function addTradePortRelistTx({ tx, nftTokenId, nftType, listPrice }: RelistNftTx) {
30
- tx.moveCall({
31
- target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::relist_ob_listing_without_transfer_policy`,
32
- arguments: [
33
- tx.object(TRADEPORT_LISTINGS_STORE),
34
- tx.object(TRADEPORT_ORDERBOOK_STORE),
35
- tx.pure.id(nftTokenId),
36
- tx.pure.u64(listPrice),
37
- ],
38
- typeArguments: [nftType],
39
- });
40
- }
41
-
42
- export async function addKioskTradePortRelistTx({
43
- tx,
44
- kioskTx,
45
- nftTokenId,
46
- nftType,
47
- listPrice,
48
- }: RelistNftTx) {
49
- tx.moveCall({
50
- target: `${TRADEPORT_LISTINGS_PACKAGE}::tradeport_listings::relist_ob_listing_with_transfer_policy`,
51
- arguments: [
52
- tx.object(TRADEPORT_LISTINGS_STORE),
53
- tx.object(TRADEPORT_ORDERBOOK_STORE),
54
- tx.object(kioskTx.kiosk),
55
- tx.object(kioskTx.kioskCap),
56
- tx.pure.id(nftTokenId),
57
- tx.pure.u64(listPrice),
58
- ],
59
- typeArguments: [nftType],
60
- });
61
- }
62
-
63
- export function addBlueMoveRelistTx(txData: RelistNftTx) {
64
- const { tx, nftTokenId, nftType, listPrice } = txData;
65
-
66
- const borrowedItem = tx.moveCall({
67
- target:
68
- '0xd5dd28cc24009752905689b2ba2bf90bfc8de4549b9123f93519bb8ba9bf9981::marketplace::delist',
69
- arguments: [tx.object(BLUEMOVE_MARKET_CONFIG_OBJECT), tx.pure.address(nftTokenId)],
70
- typeArguments: [nftType, nftType],
71
- }) as TransactionObjectArgument;
72
-
73
- addTradePortListTx({ ...txData, listPrice, borrowedItem });
74
- }
75
-
76
- export function addTocenRelistTx(txData: RelistNftTx) {
77
- const { tx, nftTokenId, nftType, listPrice } = txData;
78
-
79
- const borrowedItem = tx.moveCall({
80
- target:
81
- '0x3605d91c559e80cf8fdeabae9abaccb0bc38f96eac0b32bf47e95a9159a5277f::tocen_marketplace::delist',
82
- arguments: [tx.object(TOCEN_MARKETPLACE_OBJECT), tx.pure.address(nftTokenId)],
83
- typeArguments: [nftType],
84
- }) as any;
85
-
86
- addTradePortListTx({ ...txData, listPrice, borrowedItem });
87
- }