@tradeport/sui-trading-sdk 0.5.5 → 0.5.6

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 (153) hide show
  1. package/dist/index.d.ts +194 -0
  2. package/dist/index.js +7420 -0
  3. package/dist/index.js.map +1 -0
  4. package/package.json +71 -66
  5. package/.babel.config.js +0 -3
  6. package/.claude/settings.json +0 -5
  7. package/.claude/settings.local.json +0 -5
  8. package/.env.demo +0 -5
  9. package/.eslintrc.json +0 -46
  10. package/.prettierignore +0 -4
  11. package/.prettierrc.json +0 -7
  12. package/.vscode/launch.json +0 -23
  13. package/CHANGELOG.md +0 -746
  14. package/jest.config.js +0 -12
  15. package/src/SuiTradingClient.ts +0 -442
  16. package/src/apiClients/createKioskClient.ts +0 -10
  17. package/src/apiClients/createSuiClient.ts +0 -5
  18. package/src/apiClients/graphqlClient.ts +0 -17
  19. package/src/bigNumberConfig.ts +0 -10
  20. package/src/constants.ts +0 -1052
  21. package/src/graphql/createChainGQLQuery.ts +0 -27
  22. package/src/graphql/gqlChainRequest.ts +0 -21
  23. package/src/graphql/queries/fetchAccountKiosks.ts +0 -12
  24. package/src/graphql/queries/fetchActiveLockStateByNftId.ts +0 -15
  25. package/src/graphql/queries/fetchBidsById.ts +0 -36
  26. package/src/graphql/queries/fetchCollectionBidById.ts +0 -21
  27. package/src/graphql/queries/fetchCollectionBidsAtSamePrice.ts +0 -29
  28. package/src/graphql/queries/fetchCollectionChainState.ts +0 -17
  29. package/src/graphql/queries/fetchCollectionFloorListingForMarket.ts +0 -28
  30. package/src/graphql/queries/fetchCollectionFloorListings.ts +0 -15
  31. package/src/graphql/queries/fetchCollectionsById.ts +0 -39
  32. package/src/graphql/queries/fetchCommissionByListingId.ts +0 -13
  33. package/src/graphql/queries/fetchCryptoToUsdRate.ts +0 -13
  34. package/src/graphql/queries/fetchKiosksByOwner.ts +0 -14
  35. package/src/graphql/queries/fetchListingsById.ts +0 -29
  36. package/src/graphql/queries/fetchListingsByNftId.ts +0 -23
  37. package/src/graphql/queries/fetchLockById.ts +0 -23
  38. package/src/graphql/queries/fetchMultibidById.ts +0 -34
  39. package/src/graphql/queries/fetchNftCollectionChainState.ts +0 -12
  40. package/src/graphql/queries/fetchNftsById.ts +0 -75
  41. package/src/graphql/queries/fetchNftsByKioskId.ts +0 -45
  42. package/src/graphql/queries/fetchOwnerCapByKiosk.ts +0 -10
  43. package/src/graphql/queries/fetchPersonalCapByKiosk.ts +0 -10
  44. package/src/graphql/queries/fetchSharedObjectsByType.ts +0 -12
  45. package/src/graphql/queries/fetchTransferPoliciesByType.ts +0 -12
  46. package/src/graphql/queries/fetchWalletKiosks.ts +0 -14
  47. package/src/graphql/queries/getCommissionByListingId.ts +0 -15
  48. package/src/helpers/addOneDollarFee.ts +0 -17
  49. package/src/helpers/addThirdPartyTxFee.ts +0 -17
  50. package/src/helpers/calculatePremium.ts +0 -9
  51. package/src/helpers/calculateRoyaltyFee.ts +0 -28
  52. package/src/helpers/destroyZeroCoin.ts +0 -14
  53. package/src/helpers/getActiveLockStateByNftId.ts +0 -15
  54. package/src/helpers/getCollectionChainState.ts +0 -31
  55. package/src/helpers/getCollectionFloorPrice.ts +0 -12
  56. package/src/helpers/getLockById.ts +0 -29
  57. package/src/helpers/getMarketFeePrice.ts +0 -82
  58. package/src/helpers/getNftType.ts +0 -38
  59. package/src/helpers/getRoyaltyRuleModule.ts +0 -7
  60. package/src/helpers/getSharedObjects.ts +0 -119
  61. package/src/helpers/getSuiToUsdRate.ts +0 -14
  62. package/src/helpers/getTradeportBiddingContractBidAmount.ts +0 -31
  63. package/src/helpers/getTransferPolicyRuleNamesFromSuiObject.ts +0 -24
  64. package/src/helpers/hasPersonalKioskRule.ts +0 -7
  65. package/src/helpers/hasRoyaltyRule.ts +0 -7
  66. package/src/helpers/hasTransferPolicyRules.ts +0 -6
  67. package/src/helpers/isExpiredListing.ts +0 -9
  68. package/src/helpers/isNonKioskListing.ts +0 -14
  69. package/src/helpers/isSIngleBid.ts +0 -13
  70. package/src/helpers/kiosk/assertNftInSharedKiosk.ts +0 -31
  71. package/src/helpers/kiosk/getKioskCollectionRoyaltyFeeAmount.ts +0 -71
  72. package/src/helpers/kiosk/getKioskIdFromKioskTx.ts +0 -29
  73. package/src/helpers/kiosk/getKioskPlaceBidCoin.ts +0 -59
  74. package/src/helpers/kiosk/getNativeKioskTransferPolicies.ts +0 -29
  75. package/src/helpers/kiosk/getNativeKioskTransferPoliciesByNftType.ts +0 -21
  76. package/src/helpers/kiosk/getRulePackageId.ts +0 -59
  77. package/src/helpers/kiosk/getTransferPoliciesToResolve.ts +0 -154
  78. package/src/helpers/kiosk/isBluemoveKioskBid.ts +0 -1
  79. package/src/helpers/kiosk/isTradePortKioskBid.ts +0 -4
  80. package/src/helpers/kiosk/kioskListingBcs.ts +0 -19
  81. package/src/helpers/kiosk/kioskTxWrapper.ts +0 -152
  82. package/src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts +0 -100
  83. package/src/helpers/kiosk/preProcessSharedBulkBuyingData.ts +0 -171
  84. package/src/helpers/kiosk/resolveCustomTransferPolicyRules.ts +0 -75
  85. package/src/helpers/kiosk/resolveFloorPriceRule.ts +0 -21
  86. package/src/helpers/kiosk/resolveKioskLockRule.ts +0 -47
  87. package/src/helpers/kiosk/resolvePersonalKioskRule.ts +0 -23
  88. package/src/helpers/kiosk/resolveRoyaltyRule.ts +0 -57
  89. package/src/helpers/kiosk/resolveTableAllowlistRule.ts +0 -34
  90. package/src/helpers/kiosk/resolveTransferPolicies.ts +0 -158
  91. package/src/helpers/kiosk/sharedKioskState.type.ts +0 -11
  92. package/src/helpers/kiosk/takeAndBorrowNftFromKiosk.ts +0 -50
  93. package/src/helpers/kiosk/takeLockedNftFromKiosk.ts +0 -73
  94. package/src/helpers/kiosk/upgradeKioskRulesPackageId.ts +0 -17
  95. package/src/helpers/originByte/confirmOBTranfer.ts +0 -33
  96. package/src/helpers/originByte/createOBKiosk.ts +0 -14
  97. package/src/helpers/originByte/depositNftIntoOBKiosk.ts +0 -16
  98. package/src/helpers/originByte/getOBBidderKiosk.ts +0 -12
  99. package/src/helpers/originByte/getOBKiosk.ts +0 -24
  100. package/src/helpers/originByte/getOrCreateOBKiosk.ts +0 -42
  101. package/src/helpers/originByte/isOBKiosk.ts +0 -13
  102. package/src/helpers/originByte/isOriginByteBid.ts +0 -30
  103. package/src/helpers/originByte/isOriginByteCollection.ts +0 -11
  104. package/src/helpers/originByte/shareOriginByteKiosk.ts +0 -14
  105. package/src/helpers/rpc/getAcountBalance.ts +0 -18
  106. package/src/helpers/rpc/getObjectType.ts +0 -25
  107. package/src/helpers/splitCoins.ts +0 -12
  108. package/src/helpers/track.ts +0 -20
  109. package/src/helpers/validateMinFloorPrice.ts +0 -22
  110. package/src/index.ts +0 -2
  111. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +0 -189
  112. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +0 -398
  113. package/src/methods/acceptNftBids/acceptNftBids.ts +0 -174
  114. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +0 -438
  115. package/src/methods/applyFtStrategy/applyFtStrategy.ts +0 -55
  116. package/src/methods/applyNftStrategy/applyNftStrategy.ts +0 -90
  117. package/src/methods/buyListings/addBuyListingTxs.ts +0 -806
  118. package/src/methods/buyListings/buyListings.ts +0 -230
  119. package/src/methods/cancelMultiBid/cancelMultiBid.ts +0 -51
  120. package/src/methods/cancelNftTransfers/addCancelNftTransfersTx.ts +0 -20
  121. package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +0 -118
  122. package/src/methods/claimNfts/addClaimNftsTxs.ts +0 -247
  123. package/src/methods/claimNfts/claimNfts.ts +0 -270
  124. package/src/methods/createMultiBid/createMultiBid.ts +0 -36
  125. package/src/methods/listNfts/addListTxs.ts +0 -210
  126. package/src/methods/listNfts/addRelistTxs.ts +0 -87
  127. package/src/methods/listNfts/listNfts.ts +0 -152
  128. package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +0 -226
  129. package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +0 -149
  130. package/src/methods/placeCollectionBids/placeCollectionBids.ts +0 -153
  131. package/src/methods/placeNftBids/addPlaceNftBidTxs.ts +0 -154
  132. package/src/methods/placeNftBids/placeNftBids.ts +0 -111
  133. package/src/methods/relistNft/relistNft.ts +0 -153
  134. package/src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts +0 -132
  135. package/src/methods/removeCollectionBids/removeCollectionBids.ts +0 -117
  136. package/src/methods/removeNftBids/addRemoveNftBidTxs.ts +0 -122
  137. package/src/methods/removeNftBids/removeNftBids.ts +0 -116
  138. package/src/methods/sponsorNftListing/addSponsorNftListingTx.ts +0 -40
  139. package/src/methods/sponsorNftListing/sponsorNftListing.ts +0 -60
  140. package/src/methods/transferNfts/addTransferNftTx.ts +0 -220
  141. package/src/methods/transferNfts/transferNfts.ts +0 -216
  142. package/src/methods/unlistListings/addUnlistListingTxs.ts +0 -399
  143. package/src/methods/unlistListings/unlistListings.ts +0 -158
  144. package/src/methods/updateMultiBid/updateMultiBid.ts +0 -66
  145. package/src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts +0 -100
  146. package/src/tests/SuiWallet.ts +0 -83
  147. package/src/utils/addHexPrefix.ts +0 -7
  148. package/src/utils/addLeadingZerosAfter0x.ts +0 -9
  149. package/src/utils/normalizeNftType.ts +0 -7
  150. package/src/utils/printTxBlockTxs.ts +0 -11
  151. package/src/utils/pureValues.ts +0 -13
  152. package/src/utils/toUint8Array.ts +0 -12
  153. package/tsconfig.json +0 -16
package/jest.config.js DELETED
@@ -1,12 +0,0 @@
1
- /** @type {import('ts-jest').JestConfigWithTsJest} */
2
- export default {
3
- preset: 'ts-jest/presets/default-esm',
4
- testEnvironment: 'node',
5
- extensionsToTreatAsEsm: ['.ts'],
6
- moduleNameMapper: {
7
- '^(\\.{1,2}/.*)\\.js$': '$1',
8
- },
9
- verbose: true,
10
- testTimeout: 1800000,
11
- setupFiles: ['dotenv/config'],
12
- };
@@ -1,442 +0,0 @@
1
- import { type Transaction } from '@mysten/sui/transactions';
2
- import { GraphQLClient } from 'graphql-request';
3
- import createKioskClient from './apiClients/createKioskClient';
4
- import createSuiClient from './apiClients/createSuiClient';
5
- import { getGraphqlClient, setGraphqlClient } from './apiClients/graphqlClient';
6
- import { gqlChainRequest } from './graphql/gqlChainRequest';
7
- import { fetchCollectionBidsById } from './graphql/queries/fetchCollectionBidById';
8
- import { fetchCollectionBidsAtSamePrice } from './graphql/queries/fetchCollectionBidsAtSamePrice';
9
- import {
10
- acceptCollectionBid,
11
- type AcceptCollectionBid,
12
- } from './methods/acceptCollectionBid/acceptCollectionBid';
13
- import { acceptNftBids, type AcceptNftBids } from './methods/acceptNftBids/acceptNftBids';
14
- import { applyFtStrategy, type ApplyFtStrategy } from './methods/applyFtStrategy/applyFtStrategy';
15
- import {
16
- type ApplyNftStrategy,
17
- applyTradeportNftStrategy,
18
- } from './methods/applyNftStrategy/applyNftStrategy';
19
- import { buyListings, type BuyListings } from './methods/buyListings/buyListings';
20
- import { cancelMultiBid, type CancelMultiBid } from './methods/cancelMultiBid/cancelMultiBid';
21
- import {
22
- cancelNftTransfers,
23
- type CancelNftTransfers,
24
- } from './methods/cancelNftTransfers/cancelNftTransfers';
25
- import { claimNfts, type ClaimNfts } from './methods/claimNfts/claimNfts';
26
- import { createMultiBid, type CreateMultiBid } from './methods/createMultiBid/createMultiBid';
27
- import { listNfts, type ListNfts } from './methods/listNfts/listNfts';
28
- import {
29
- migrateNftsFromUnsharedToSharedKiosks,
30
- type MigrateNftsFromUnsharedToSharedKiosks,
31
- } from './methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks';
32
- import {
33
- type PlaceCollectionBid,
34
- placeCollectionBids,
35
- } from './methods/placeCollectionBids/placeCollectionBids';
36
- import { placeNftBids, type PlaceNftBids } from './methods/placeNftBids/placeNftBids';
37
- import {
38
- removeCollectionBids,
39
- type RemoveCollectionBids,
40
- } from './methods/removeCollectionBids/removeCollectionBids';
41
- import { removeNftBids, type RemoveNftBids } from './methods/removeNftBids/removeNftBids';
42
- import {
43
- type SponsorNftListing,
44
- sponsorNftListing,
45
- } from './methods/sponsorNftListing/sponsorNftListing';
46
- import { transferNfts, type TransferNfts } from './methods/transferNfts/transferNfts';
47
- import { unlistListings, type UnlistListings } from './methods/unlistListings/unlistListings';
48
- import { updateMultiBid, type UpdateMultiBid } from './methods/updateMultiBid/updateMultiBid';
49
- import {
50
- withdrawProfitsFromKiosks,
51
- type WithdrawProfitsFromKiosks,
52
- } from './methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks';
53
- import { addLeadingZerosAfter0x } from './utils/addLeadingZerosAfter0x';
54
-
55
- const DEFAULT_SUI_GRPC_URL = 'https://fullnode.mainnet.sui.io:443';
56
- const DEFAULT_SUI_GRAPHQL_URL = 'https://graphql.mainnet.sui.io/';
57
-
58
- type ApiConfig = {
59
- apiUser: string;
60
- apiKey: string;
61
- apiUrl?: string;
62
- tradeportRouterUrl?: string;
63
- apiVercelId?: string;
64
- suiNodeUrl?: string;
65
- suiGraphqlUrl?: string;
66
- graphQLClient?: GraphQLClient;
67
- };
68
- export interface RequestContext {
69
- apiUser: string;
70
- apiKey: string;
71
- tradeportRouterUrl?: string;
72
- suiClient: ReturnType<typeof createSuiClient>;
73
- kioskClient: ReturnType<typeof createKioskClient>;
74
- }
75
-
76
- class SuiTradingClient {
77
- private readonly apiUser: string;
78
- private readonly apiKey: string;
79
- private readonly tradeportRouterUrl?: string;
80
- private readonly suiClient: ReturnType<typeof createSuiClient>;
81
- private readonly kioskClient: ReturnType<typeof createKioskClient>;
82
- private readonly allowedApiUsersForUnsharedKiosksMigration = ['tradeport.xyz', 'mercato.xyz'];
83
-
84
- constructor({
85
- apiUser,
86
- apiKey,
87
- apiVercelId,
88
- apiUrl,
89
- tradeportRouterUrl,
90
- suiNodeUrl,
91
- suiGraphqlUrl,
92
- graphQLClient,
93
- }: ApiConfig) {
94
- this.apiUser = apiUser;
95
- this.apiKey = apiKey;
96
- this.tradeportRouterUrl = tradeportRouterUrl;
97
- this.suiClient = createSuiClient(suiNodeUrl ?? DEFAULT_SUI_GRPC_URL);
98
- this.kioskClient = createKioskClient(suiGraphqlUrl ?? DEFAULT_SUI_GRAPHQL_URL);
99
-
100
- if (graphQLClient) {
101
- setGraphqlClient(graphQLClient);
102
- } else {
103
- setGraphqlClient(new GraphQLClient(apiUrl ?? 'https://graphql.tradeport.gg'));
104
- }
105
-
106
- getGraphqlClient().setHeaders({
107
- 'x-api-user': apiUser,
108
- 'x-api-key': apiKey,
109
- ...(apiVercelId && { 'x-vercel-id': apiVercelId }),
110
- });
111
-
112
- // trackMethodCall({ apiUser, apiKey, event: 'INITIALIZE_CLIENT' });
113
- }
114
-
115
- public async buyListings(args: BuyListings): Promise<Transaction> {
116
- const context: RequestContext = {
117
- apiUser: this.apiUser,
118
- apiKey: this.apiKey,
119
- tradeportRouterUrl: this.tradeportRouterUrl,
120
- suiClient: this.suiClient,
121
- kioskClient: this.kioskClient,
122
- };
123
- return buyListings(args, context);
124
- }
125
-
126
- public async listNfts({ nfts, walletAddress, tx }: ListNfts) {
127
- const context: RequestContext = {
128
- apiUser: this.apiUser,
129
- apiKey: this.apiKey,
130
- tradeportRouterUrl: this.tradeportRouterUrl,
131
- suiClient: this.suiClient,
132
- kioskClient: this.kioskClient,
133
- };
134
-
135
- return listNfts({ nfts, walletAddress, tx }, context);
136
- }
137
-
138
- public async unlistListings({ listingIds, walletAddress }: UnlistListings) {
139
- const context: RequestContext = {
140
- apiUser: this.apiUser,
141
- apiKey: this.apiKey,
142
- tradeportRouterUrl: this.tradeportRouterUrl,
143
- suiClient: this.suiClient,
144
- kioskClient: this.kioskClient,
145
- };
146
-
147
- return unlistListings({ listingIds, walletAddress }, context);
148
- }
149
-
150
- public async placeNftBids(data: PlaceNftBids) {
151
- const context: RequestContext = {
152
- apiUser: this.apiUser,
153
- apiKey: this.apiKey,
154
- tradeportRouterUrl: this.tradeportRouterUrl,
155
- suiClient: this.suiClient,
156
- kioskClient: this.kioskClient,
157
- };
158
-
159
- return placeNftBids(data, context);
160
- }
161
-
162
- public async removeNftBids({ bidIds, tx }: RemoveNftBids) {
163
- const context: RequestContext = {
164
- apiUser: this.apiUser,
165
- tradeportRouterUrl: this.tradeportRouterUrl,
166
- apiKey: this.apiKey,
167
- suiClient: this.suiClient,
168
- kioskClient: this.kioskClient,
169
- };
170
-
171
- return removeNftBids({ bidIds, tx }, context);
172
- }
173
-
174
- public async acceptNftBids({ bidIds, walletAddress }: AcceptNftBids) {
175
- const context: RequestContext = {
176
- apiUser: this.apiUser,
177
- apiKey: this.apiKey,
178
- tradeportRouterUrl: this.tradeportRouterUrl,
179
- suiClient: this.suiClient,
180
- kioskClient: this.kioskClient,
181
- };
182
-
183
- return acceptNftBids({ bidIds, walletAddress }, context);
184
- }
185
-
186
- public async placeCollectionBid({
187
- collectionId,
188
- bidAmountInMist,
189
- numOfBids,
190
- walletAddress,
191
- multiBidId,
192
- multiBidChainId,
193
- expireAt,
194
- tx,
195
- }: PlaceCollectionBid): Promise<Transaction> {
196
- const context: RequestContext = {
197
- apiUser: this.apiUser,
198
- apiKey: this.apiKey,
199
- tradeportRouterUrl: this.tradeportRouterUrl,
200
- suiClient: this.suiClient,
201
- kioskClient: this.kioskClient,
202
- };
203
-
204
- return placeCollectionBids(
205
- {
206
- collections: [
207
- {
208
- id: collectionId,
209
- bidAmountInMist,
210
- numOfBids,
211
- expireAt,
212
- },
213
- ],
214
- walletAddress,
215
- multiBidId,
216
- multiBidChainId,
217
- tx,
218
- },
219
- context,
220
- );
221
- }
222
-
223
- public async acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid) {
224
- const context: RequestContext = {
225
- apiUser: this.apiUser,
226
- apiKey: this.apiKey,
227
- tradeportRouterUrl: this.tradeportRouterUrl,
228
- suiClient: this.suiClient,
229
- kioskClient: this.kioskClient,
230
- };
231
-
232
- const collectionBidRes = await gqlChainRequest({
233
- chain: 'sui',
234
- query: fetchCollectionBidsById,
235
- variables: { bidIds: [bidId] },
236
- });
237
- const bid = collectionBidRes?.bids?.[0];
238
-
239
- if (!bid) {
240
- throw new Error('No bid found');
241
- }
242
-
243
- if (addLeadingZerosAfter0x(bid?.bidder) === addLeadingZerosAfter0x(walletAddress)) {
244
- throw new Error('Wallet cannot accept its own bid');
245
- }
246
-
247
- if (bid?.status !== 'active') {
248
- throw new Error('Bid not active');
249
- }
250
-
251
- if (bid?.type !== 'collection') {
252
- throw new Error('Bid is not a collection bid. Use acceptNftBid() instead.');
253
- }
254
-
255
- const allBidsWithSameHighestPriceRes = await gqlChainRequest({
256
- chain: 'sui',
257
- query: fetchCollectionBidsAtSamePrice,
258
- variables: {
259
- collectionId: bid?.collection_id,
260
- price: bid?.price,
261
- },
262
- });
263
- const allBidsWithSameHighestPrice = allBidsWithSameHighestPriceRes?.bids;
264
-
265
- // loop through all highest bids at same price until one succeeds
266
- for (let i = 0; i < (allBidsWithSameHighestPrice?.length ?? 0); i++) {
267
- const tx = await acceptCollectionBid(
268
- {
269
- bid: allBidsWithSameHighestPrice?.[i],
270
- nftId,
271
- walletAddress,
272
- },
273
- context,
274
- );
275
-
276
- tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
277
- let result = await this.suiClient.simulateTransaction({
278
- transaction: tx,
279
- include: { effects: true },
280
- });
281
-
282
- if (result.$kind === 'Transaction') {
283
- return tx;
284
- }
285
-
286
- if (i === allBidsWithSameHighestPrice.length - 1) {
287
- // next loop through all the same bids and try with splitting royalty from user gas coins in case royalty has changed and the amount in escrow is not ennough
288
- for (let j = 0; j < allBidsWithSameHighestPrice?.length; j++) {
289
- const tx = await acceptCollectionBid(
290
- {
291
- bid: allBidsWithSameHighestPrice?.[j],
292
- nftId,
293
- walletAddress,
294
- shouldSplitRoyaltyFromUserGasCoins: true,
295
- },
296
- context,
297
- );
298
-
299
- tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
300
- result = await this.suiClient.simulateTransaction({
301
- transaction: tx,
302
- include: { effects: true },
303
- });
304
-
305
- if (result?.$kind === 'Transaction') {
306
- return tx;
307
- }
308
- }
309
-
310
- throw new Error(
311
- `Failed to validate accept bid transaction: ${
312
- result?.FailedTransaction?.status?.error
313
- ? JSON.stringify(result.FailedTransaction.status.error)
314
- : 'Unknown error'
315
- }`,
316
- );
317
- }
318
- }
319
- }
320
-
321
- public async removeCollectionBids({ bidIds, tx }: RemoveCollectionBids) {
322
- const context: RequestContext = {
323
- apiUser: this.apiUser,
324
- apiKey: this.apiKey,
325
- tradeportRouterUrl: this.tradeportRouterUrl,
326
- suiClient: this.suiClient,
327
- kioskClient: this.kioskClient,
328
- };
329
-
330
- return removeCollectionBids({ bidIds, tx }, context);
331
- }
332
-
333
- public async transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts) {
334
- const context: RequestContext = {
335
- apiUser: this.apiUser,
336
- apiKey: this.apiKey,
337
- tradeportRouterUrl: this.tradeportRouterUrl,
338
- suiClient: this.suiClient,
339
- kioskClient: this.kioskClient,
340
- };
341
-
342
- return transferNfts({ nftIds, recipientAddress, walletAddress }, context);
343
- }
344
-
345
- public async cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers) {
346
- const context: RequestContext = {
347
- apiUser: this.apiUser,
348
- apiKey: this.apiKey,
349
- tradeportRouterUrl: this.tradeportRouterUrl,
350
- suiClient: this.suiClient,
351
- kioskClient: this.kioskClient,
352
- };
353
-
354
- try {
355
- return await cancelNftTransfers({ nftIds, walletAddress }, context);
356
- } catch (err) {
357
- throw new Error(
358
- 'Cannot cancel NFT transfer unless the NFT was transferred using kiosk_transfers::transfer_with_purchase_capability',
359
- );
360
- }
361
- }
362
-
363
- public async claimNfts({ nftIds, walletAddress }: ClaimNfts) {
364
- const context: RequestContext = {
365
- apiUser: this.apiUser,
366
- apiKey: this.apiKey,
367
- tradeportRouterUrl: this.tradeportRouterUrl,
368
- suiClient: this.suiClient,
369
- kioskClient: this.kioskClient,
370
- };
371
-
372
- try {
373
- const tx = await claimNfts({ nftIds, walletAddress }, context, true);
374
-
375
- tx.setSenderIfNotSet(addLeadingZerosAfter0x(walletAddress));
376
- const rawTransaction = await tx.build({ client: this.suiClient });
377
- await this.suiClient.simulateTransaction({
378
- transaction: rawTransaction,
379
- });
380
- return tx;
381
- } catch (err) {
382
- return claimNfts({ nftIds, walletAddress }, context);
383
- }
384
- }
385
-
386
- public async withdrawProfitsFromKiosks(args: WithdrawProfitsFromKiosks) {
387
- const context: RequestContext = {
388
- apiUser: this.apiUser,
389
- apiKey: this.apiKey,
390
- tradeportRouterUrl: this.tradeportRouterUrl,
391
- suiClient: this.suiClient,
392
- kioskClient: this.kioskClient,
393
- };
394
-
395
- return withdrawProfitsFromKiosks(args, context);
396
- }
397
-
398
- public async migrateNftsFromUnsharedToSharedKiosks(args: MigrateNftsFromUnsharedToSharedKiosks) {
399
- if (!this.allowedApiUsersForUnsharedKiosksMigration.includes(this.apiUser)) {
400
- throw new Error('This method is not available for your API user.');
401
- }
402
-
403
- const context: RequestContext = {
404
- apiUser: this.apiUser,
405
- apiKey: this.apiKey,
406
- tradeportRouterUrl: this.tradeportRouterUrl,
407
- suiClient: this.suiClient,
408
- kioskClient: this.kioskClient,
409
- };
410
-
411
- return migrateNftsFromUnsharedToSharedKiosks(args, context);
412
- }
413
-
414
- public async createMultiBid(args: CreateMultiBid) {
415
- return createMultiBid(args);
416
- }
417
-
418
- public async cancelMultiBid(args: CancelMultiBid) {
419
- return cancelMultiBid(args);
420
- }
421
-
422
- public async updateMultiBid(args: UpdateMultiBid) {
423
- return updateMultiBid(args, {
424
- suiClient: this.suiClient,
425
- tradeportRouterUrl: this.tradeportRouterUrl,
426
- });
427
- }
428
-
429
- public async sponsorNftListing(args: SponsorNftListing) {
430
- return sponsorNftListing(args);
431
- }
432
-
433
- public async applyFtStrategy(args: ApplyFtStrategy) {
434
- return applyFtStrategy(args);
435
- }
436
-
437
- public async applyTradeportNftStrategy(args: ApplyNftStrategy) {
438
- return applyTradeportNftStrategy(args);
439
- }
440
- }
441
-
442
- export default SuiTradingClient;
@@ -1,10 +0,0 @@
1
- import { KioskClient } from '@mysten/kiosk';
2
- import { SuiGraphQLClient } from '@mysten/sui/graphql';
3
-
4
- const createKioskClient = (graphqlUrl: string) =>
5
- new KioskClient({
6
- client: new SuiGraphQLClient({ url: graphqlUrl, network: 'mainnet' }),
7
- network: 'mainnet',
8
- });
9
-
10
- export default createKioskClient;
@@ -1,5 +0,0 @@
1
- import { SuiGrpcClient } from '@mysten/sui/grpc';
2
-
3
- const createSuiClient = (baseUrl: string) => new SuiGrpcClient({ network: 'mainnet', baseUrl });
4
-
5
- export default createSuiClient;
@@ -1,17 +0,0 @@
1
- import type { GraphQLClient } from 'graphql-request';
2
-
3
- let graphqlClient: GraphQLClient;
4
-
5
- export const getGraphqlClient = () => {
6
- if (!graphqlClient) {
7
- throw new Error(
8
- 'GraphQL client not initialized. Please provide apiUrl to SuiTradingClient constructor.',
9
- );
10
- }
11
-
12
- return graphqlClient;
13
- };
14
-
15
- export function setGraphqlClient(client: GraphQLClient) {
16
- graphqlClient = client;
17
- }
@@ -1,10 +0,0 @@
1
- import { BigNumber } from 'bignumber.js';
2
-
3
- BigNumber.set({
4
- POW_PRECISION: 64,
5
- });
6
-
7
- export const ZERO = new BigNumber(0);
8
- export const ONE = new BigNumber(1);
9
-
10
- export default BigNumber;