@tradeport/sui-trading-sdk 0.4.62 → 0.4.64

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/package.json CHANGED
@@ -1,62 +1,60 @@
1
1
  {
2
- "name": "@tradeport/sui-trading-sdk",
3
- "license": "MIT",
4
- "version": "0.4.62",
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
- "@flowx-finance/sdk": "^1.15.0",
42
- "@mysten/kiosk": "^0.7.13",
43
- "@mysten/sui": "^1.17.0",
44
- "@types/analytics-node": "^3.1.14",
45
- "analytics-node": "^6.2.0",
46
- "bignumber.js": "^9.3.1",
47
- "graphql": "^16.12.0",
48
- "graphql-request": "^6.1.0",
49
- "ms": "^2.1.3"
50
- },
51
- "publishConfig": {
52
- "access": "public",
53
- "registry": "https://registry.npmjs.org/"
54
- },
55
- "lint-staged": {
56
- "*.ts": [
57
- "eslint --fix",
58
- "bash -c 'tsc --noEmit'",
59
- "prettier --write"
60
- ]
61
- }
62
- }
2
+ "name": "@tradeport/sui-trading-sdk",
3
+ "license": "MIT",
4
+ "version": "0.4.64",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "devDependencies": {
9
+ "@babel/core": "^7.23.3",
10
+ "@babel/preset-env": "^7.23.3",
11
+ "@changesets/cli": "^2.26.2",
12
+ "@types/jest": "^29.5.10",
13
+ "@types/ms": "^2.1.0",
14
+ "@types/node": "^20.10.0",
15
+ "@typescript-eslint/eslint-plugin": "^6.13.1",
16
+ "@typescript-eslint/parser": "^6.13.1",
17
+ "babel-jest": "^29.7.0",
18
+ "dotenv": "^16.3.1",
19
+ "eslint": "^8.54.0",
20
+ "eslint-config-prettier": "^9.0.0",
21
+ "eslint-config-xo": "^0.43.1",
22
+ "eslint-config-xo-typescript": "^1.0.1",
23
+ "husky": "^8.0.0",
24
+ "jest": "^29.7.0",
25
+ "lint-staged": "^16.2.7",
26
+ "prettier": "^3.1.0",
27
+ "ts-jest": "^29.1.1",
28
+ "tsup": "^8.0.1",
29
+ "typescript": "^5.3.2"
30
+ },
31
+ "dependencies": {
32
+ "@mysten/kiosk": "^0.7.13",
33
+ "@mysten/sui": "^1.17.0",
34
+ "@types/analytics-node": "^3.1.14",
35
+ "analytics-node": "^6.2.0",
36
+ "bignumber.js": "^9.3.1",
37
+ "graphql": "^16.12.0",
38
+ "graphql-request": "^6.1.0",
39
+ "ms": "^2.1.3"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "registry": "https://registry.npmjs.org/"
44
+ },
45
+ "lint-staged": {
46
+ "*.ts": [
47
+ "eslint --fix",
48
+ "bash -c 'tsc --noEmit'",
49
+ "prettier --write"
50
+ ]
51
+ },
52
+ "scripts": {
53
+ "build": "tsup src/index.ts --sourcemap --format cjs,esm --dts",
54
+ "release": "pnpm run build && changeset publish",
55
+ "lint": "tsc && eslint --fix src/* --ignore-path .gitignore --ext .js,.ts",
56
+ "format": "prettier --write \"**/*.+(js|ts|json)\"",
57
+ "test": "jest",
58
+ "pre-commit": "lint-staged"
59
+ }
60
+ }
@@ -13,6 +13,10 @@ import {
13
13
  } from './methods/acceptCollectionBid/acceptCollectionBid';
14
14
  import { acceptNftBids, type AcceptNftBids } from './methods/acceptNftBids/acceptNftBids';
15
15
  import { applyFtStrategy, type ApplyFtStrategy } from './methods/applyFtStrategy/applyFtStrategy';
16
+ import {
17
+ type ApplyNftStrategy,
18
+ applyTradeportNftStrategy,
19
+ } from './methods/applyNftStrategy/applyNftStrategy';
16
20
  import { buyListings, type BuyListings } from './methods/buyListings/buyListings';
17
21
  import { cancelMultiBid, type CancelMultiBid } from './methods/cancelMultiBid/cancelMultiBid';
18
22
  import {
@@ -27,8 +31,8 @@ import {
27
31
  type MigrateNftsFromUnsharedToSharedKiosks,
28
32
  } from './methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks';
29
33
  import {
30
- placeCollectionBids,
31
34
  type PlaceCollectionBid,
35
+ placeCollectionBids,
32
36
  } from './methods/placeCollectionBids/placeCollectionBids';
33
37
  import { placeNftBids, type PlaceNftBids } from './methods/placeNftBids/placeNftBids';
34
38
  import {
@@ -36,6 +40,10 @@ import {
36
40
  type RemoveCollectionBids,
37
41
  } from './methods/removeCollectionBids/removeCollectionBids';
38
42
  import { removeNftBids, type RemoveNftBids } from './methods/removeNftBids/removeNftBids';
43
+ import {
44
+ type SponsorNftListing,
45
+ sponsorNftListing,
46
+ } from './methods/sponsorNftListing/sponsorNftListing';
39
47
  import { transferNfts, type TransferNfts } from './methods/transferNfts/transferNfts';
40
48
  import { unlistListings, type UnlistListings } from './methods/unlistListings/unlistListings';
41
49
  import { updateMultiBid, type UpdateMultiBid } from './methods/updateMultiBid/updateMultiBid';
@@ -44,28 +52,12 @@ import {
44
52
  type WithdrawProfitsFromKiosks,
45
53
  } from './methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks';
46
54
  import { addLeadingZerosAfter0x } from './utils/addLeadingZerosAfter0x';
47
- import {
48
- type SponsorNftListing,
49
- sponsorNftListing,
50
- } from './methods/sponsorNftListing/sponsorNftListing';
51
- import {
52
- type ApplyNftStrategy,
53
- applyTradeportNftStrategy,
54
- } from './methods/applyNftStrategy/applyNftStrategy';
55
- import {
56
- buildSwapRoutes,
57
- calculateAmountToSwap,
58
- type SwapCoins,
59
- swapCoins,
60
- type SwapRoutesArgs,
61
- } from './methods/swapCoins/swapCoins';
62
- import { type Coin, type GetRoutesResult } from '@flowx-finance/sdk';
63
55
 
64
56
  type ApiConfig = {
65
57
  apiUser: string;
66
58
  apiKey: string;
67
59
  apiUrl?: string;
68
- defiRouterUrl?: string;
60
+ tradeportRouterUrl?: string;
69
61
  apiVercelId?: string;
70
62
  suiNodeUrl?: string;
71
63
  graphQLClient?: GraphQLClient;
@@ -73,7 +65,7 @@ type ApiConfig = {
73
65
  export interface RequestContext {
74
66
  apiUser: string;
75
67
  apiKey: string;
76
- defiRouterUrl?: string;
68
+ tradeportRouterUrl?: string;
77
69
  suiClient: ReturnType<typeof createSuiClient>;
78
70
  kioskClient: ReturnType<typeof createKioskClient>;
79
71
  }
@@ -81,7 +73,7 @@ export interface RequestContext {
81
73
  class SuiTradingClient {
82
74
  private readonly apiUser: string;
83
75
  private readonly apiKey: string;
84
- private readonly defiRouterUrl: string;
76
+ private readonly tradeportRouterUrl?: string;
85
77
  private readonly suiClient: ReturnType<typeof createSuiClient>;
86
78
  private readonly kioskClient: ReturnType<typeof createKioskClient>;
87
79
  private readonly allowedApiUsersForUnsharedKiosksMigration = ['tradeport.xyz', 'mercato.xyz'];
@@ -91,13 +83,13 @@ class SuiTradingClient {
91
83
  apiKey,
92
84
  apiVercelId,
93
85
  apiUrl,
94
- defiRouterUrl,
86
+ tradeportRouterUrl,
95
87
  suiNodeUrl,
96
88
  graphQLClient,
97
89
  }: ApiConfig) {
98
90
  this.apiUser = apiUser;
99
91
  this.apiKey = apiKey;
100
- this.defiRouterUrl = defiRouterUrl ?? 'https://api.indexer.xyz/router';
92
+ this.tradeportRouterUrl = tradeportRouterUrl;
101
93
  this.suiClient = createSuiClient(suiNodeUrl ?? getFullnodeUrl('mainnet'));
102
94
  this.kioskClient = createKioskClient(this.suiClient);
103
95
 
@@ -116,35 +108,34 @@ class SuiTradingClient {
116
108
  // trackMethodCall({ apiUser, apiKey, event: 'INITIALIZE_CLIENT' });
117
109
  }
118
110
 
119
- public async buyListings({ listingIds, walletAddress, tx }: BuyListings): Promise<Transaction> {
111
+ public async buyListings(args: BuyListings): Promise<Transaction> {
120
112
  const context: RequestContext = {
121
113
  apiUser: this.apiUser,
122
114
  apiKey: this.apiKey,
123
- defiRouterUrl: this.defiRouterUrl,
115
+ tradeportRouterUrl: this.tradeportRouterUrl,
124
116
  suiClient: this.suiClient,
125
117
  kioskClient: this.kioskClient,
126
118
  };
127
-
128
- return buyListings({ listingIds, walletAddress, tx }, context);
119
+ return buyListings(args, context);
129
120
  }
130
121
 
131
- public async listNfts({ nfts, walletAddress }: ListNfts) {
122
+ public async listNfts({ nfts, walletAddress, tx }: ListNfts) {
132
123
  const context: RequestContext = {
133
124
  apiUser: this.apiUser,
134
125
  apiKey: this.apiKey,
135
- defiRouterUrl: this.defiRouterUrl,
126
+ tradeportRouterUrl: this.tradeportRouterUrl,
136
127
  suiClient: this.suiClient,
137
128
  kioskClient: this.kioskClient,
138
129
  };
139
130
 
140
- return listNfts({ nfts, walletAddress }, context);
131
+ return listNfts({ nfts, walletAddress, tx }, context);
141
132
  }
142
133
 
143
134
  public async unlistListings({ listingIds, walletAddress }: UnlistListings) {
144
135
  const context: RequestContext = {
145
136
  apiUser: this.apiUser,
146
137
  apiKey: this.apiKey,
147
- defiRouterUrl: this.defiRouterUrl,
138
+ tradeportRouterUrl: this.tradeportRouterUrl,
148
139
  suiClient: this.suiClient,
149
140
  kioskClient: this.kioskClient,
150
141
  };
@@ -156,7 +147,7 @@ class SuiTradingClient {
156
147
  const context: RequestContext = {
157
148
  apiUser: this.apiUser,
158
149
  apiKey: this.apiKey,
159
- defiRouterUrl: this.defiRouterUrl,
150
+ tradeportRouterUrl: this.tradeportRouterUrl,
160
151
  suiClient: this.suiClient,
161
152
  kioskClient: this.kioskClient,
162
153
  };
@@ -167,7 +158,7 @@ class SuiTradingClient {
167
158
  public async removeNftBids({ bidIds, tx }: RemoveNftBids) {
168
159
  const context: RequestContext = {
169
160
  apiUser: this.apiUser,
170
- defiRouterUrl: this.defiRouterUrl,
161
+ tradeportRouterUrl: this.tradeportRouterUrl,
171
162
  apiKey: this.apiKey,
172
163
  suiClient: this.suiClient,
173
164
  kioskClient: this.kioskClient,
@@ -180,7 +171,7 @@ class SuiTradingClient {
180
171
  const context: RequestContext = {
181
172
  apiUser: this.apiUser,
182
173
  apiKey: this.apiKey,
183
- defiRouterUrl: this.defiRouterUrl,
174
+ tradeportRouterUrl: this.tradeportRouterUrl,
184
175
  suiClient: this.suiClient,
185
176
  kioskClient: this.kioskClient,
186
177
  };
@@ -201,7 +192,7 @@ class SuiTradingClient {
201
192
  const context: RequestContext = {
202
193
  apiUser: this.apiUser,
203
194
  apiKey: this.apiKey,
204
- defiRouterUrl: this.defiRouterUrl,
195
+ tradeportRouterUrl: this.tradeportRouterUrl,
205
196
  suiClient: this.suiClient,
206
197
  kioskClient: this.kioskClient,
207
198
  };
@@ -229,7 +220,7 @@ class SuiTradingClient {
229
220
  const context: RequestContext = {
230
221
  apiUser: this.apiUser,
231
222
  apiKey: this.apiKey,
232
- defiRouterUrl: this.defiRouterUrl,
223
+ tradeportRouterUrl: this.tradeportRouterUrl,
233
224
  suiClient: this.suiClient,
234
225
  kioskClient: this.kioskClient,
235
226
  };
@@ -321,7 +312,7 @@ class SuiTradingClient {
321
312
  const context: RequestContext = {
322
313
  apiUser: this.apiUser,
323
314
  apiKey: this.apiKey,
324
- defiRouterUrl: this.defiRouterUrl,
315
+ tradeportRouterUrl: this.tradeportRouterUrl,
325
316
  suiClient: this.suiClient,
326
317
  kioskClient: this.kioskClient,
327
318
  };
@@ -333,7 +324,7 @@ class SuiTradingClient {
333
324
  const context: RequestContext = {
334
325
  apiUser: this.apiUser,
335
326
  apiKey: this.apiKey,
336
- defiRouterUrl: this.defiRouterUrl,
327
+ tradeportRouterUrl: this.tradeportRouterUrl,
337
328
  suiClient: this.suiClient,
338
329
  kioskClient: this.kioskClient,
339
330
  };
@@ -345,7 +336,7 @@ class SuiTradingClient {
345
336
  const context: RequestContext = {
346
337
  apiUser: this.apiUser,
347
338
  apiKey: this.apiKey,
348
- defiRouterUrl: this.defiRouterUrl,
339
+ tradeportRouterUrl: this.tradeportRouterUrl,
349
340
  suiClient: this.suiClient,
350
341
  kioskClient: this.kioskClient,
351
342
  };
@@ -363,7 +354,7 @@ class SuiTradingClient {
363
354
  const context: RequestContext = {
364
355
  apiUser: this.apiUser,
365
356
  apiKey: this.apiKey,
366
- defiRouterUrl: this.defiRouterUrl,
357
+ tradeportRouterUrl: this.tradeportRouterUrl,
367
358
  suiClient: this.suiClient,
368
359
  kioskClient: this.kioskClient,
369
360
  };
@@ -386,7 +377,7 @@ class SuiTradingClient {
386
377
  const context: RequestContext = {
387
378
  apiUser: this.apiUser,
388
379
  apiKey: this.apiKey,
389
- defiRouterUrl: this.defiRouterUrl,
380
+ tradeportRouterUrl: this.tradeportRouterUrl,
390
381
  suiClient: this.suiClient,
391
382
  kioskClient: this.kioskClient,
392
383
  };
@@ -402,7 +393,7 @@ class SuiTradingClient {
402
393
  const context: RequestContext = {
403
394
  apiUser: this.apiUser,
404
395
  apiKey: this.apiKey,
405
- defiRouterUrl: this.defiRouterUrl,
396
+ tradeportRouterUrl: this.tradeportRouterUrl,
406
397
  suiClient: this.suiClient,
407
398
  kioskClient: this.kioskClient,
408
399
  };
@@ -419,19 +410,14 @@ class SuiTradingClient {
419
410
  }
420
411
 
421
412
  public async updateMultiBid(args: UpdateMultiBid) {
422
- return updateMultiBid(args);
413
+ return updateMultiBid(args, {
414
+ suiClient: this.suiClient,
415
+ tradeportRouterUrl: this.tradeportRouterUrl,
416
+ });
423
417
  }
424
418
 
425
419
  public async sponsorNftListing(args: SponsorNftListing) {
426
- const context: RequestContext = {
427
- apiUser: this.apiUser,
428
- apiKey: this.apiKey,
429
- defiRouterUrl: this.defiRouterUrl,
430
- suiClient: this.suiClient,
431
- kioskClient: this.kioskClient,
432
- };
433
-
434
- return sponsorNftListing(args, context);
420
+ return sponsorNftListing(args);
435
421
  }
436
422
 
437
423
  public async applyFtStrategy(args: ApplyFtStrategy) {
@@ -441,20 +427,6 @@ class SuiTradingClient {
441
427
  public async applyTradeportNftStrategy(args: ApplyNftStrategy) {
442
428
  return applyTradeportNftStrategy(args);
443
429
  }
444
-
445
- public async swapCoins(args: SwapCoins) {
446
- return swapCoins(args, { suiClient: this.suiClient, defiRouterUrl: this.defiRouterUrl });
447
- }
448
-
449
- public async buildSwapRoutes(args: SwapRoutesArgs): Promise<GetRoutesResult<Coin, Coin>> {
450
- return buildSwapRoutes(args, { defiRouterUrl: this.defiRouterUrl });
451
- }
452
-
453
- public async calculateAmountToSwap(
454
- args: Pick<SwapCoins, 'coinInType' | 'coinOutType' | 'coinInAmount'>,
455
- ): Promise<bigint> {
456
- return calculateAmountToSwap(args);
457
- }
458
430
  }
459
431
 
460
432
  export default SuiTradingClient;
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  import SuiTradingClient from './SuiTradingClient';
2
-
3
2
  export { SuiTradingClient };
@@ -9,8 +9,6 @@ import {
9
9
  import { gqlChainRequest } from '../../graphql/gqlChainRequest';
10
10
  import { fetchListingsById } from '../../graphql/queries/fetchListingsById';
11
11
  import { addThirdPartyTxFee } from '../../helpers/addThirdPartyTxFee';
12
- import { deserializeOrCreateTxBlock } from '../../helpers/deserializeOrCreateTxBlock';
13
- import { extractSwapResultCoinFromTxBlock } from '../../helpers/extractSwapResultCoin';
14
12
  import { getNftType } from '../../helpers/getNftType';
15
13
  import {
16
14
  preProcessSharedBulkBuyingData,
@@ -74,7 +72,7 @@ export type BuyListing = {
74
72
  export type BuyListings = {
75
73
  listingIds: string[];
76
74
  walletAddress: string;
77
- tx?: Transaction | string;
75
+ tx?: Transaction;
78
76
  kioskTx?: KioskTransaction;
79
77
  coinToSplit?: any;
80
78
  beforeResolveKioskTransferRequest?: (transferRequest: any) => void | Promise<void>;
@@ -103,8 +101,7 @@ export const buyListings = async (
103
101
  }
104
102
 
105
103
  const listingsForTracking = [];
106
- const tx = deserializeOrCreateTxBlock({ existingTx });
107
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
104
+ const tx = existingTx ?? new Transaction();
108
105
 
109
106
  const tocenTokenIds: string[] = [];
110
107
  let tocenNftType = '';
@@ -157,7 +154,7 @@ export const buyListings = async (
157
154
  sellerKiosk: listing.nft?.chain_state?.kiosk_id,
158
155
  collectionId: listing?.nft?.collection_id,
159
156
  nftContractId: listing?.nft?.contract_id,
160
- coinToSplit: swapResultCoin ? swapResultCoin : coinToSplit,
157
+ coinToSplit,
161
158
  marketFeeDecimalPercent,
162
159
  beforeResolveKioskTransferRequest,
163
160
  sharedKioskState,
@@ -211,10 +208,6 @@ export const buyListings = async (
211
208
 
212
209
  sharedKioskState?.kioskTx?.finalize();
213
210
 
214
- if (swapResultCoin) {
215
- tx.transferObjects([swapResultCoin], walletAddress);
216
- }
217
-
218
211
  if (tocenTokenIds?.length > 0) {
219
212
  addTocenBuyTxHandler({
220
213
  tx,
@@ -233,5 +226,5 @@ export const buyListings = async (
233
226
  // });
234
227
  // }
235
228
 
236
- return Transaction.from(tx);
229
+ return tx;
237
230
  };
@@ -1,13 +1,12 @@
1
- import { type Transaction } from '@mysten/sui/transactions';
1
+ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { TRADEPORT_MULTI_BID_PACKAGE, TRADEPORT_MULTI_BID_STORE } from '../../constants';
3
- import { deserializeOrCreateTxBlock } from '../../helpers/deserializeOrCreateTxBlock';
4
3
  import { updateMultiBid } from '../updateMultiBid/updateMultiBid';
5
4
 
6
5
  export interface CreateMultiBid {
7
6
  walletAddress: string;
8
7
  name?: string;
9
8
  amount?: bigint;
10
- tx?: Transaction | string;
9
+ tx?: Transaction;
11
10
  }
12
11
 
13
12
  export async function createMultiBid({
@@ -16,7 +15,7 @@ export async function createMultiBid({
16
15
  amount,
17
16
  tx: existingTx,
18
17
  }: CreateMultiBid): Promise<{ multiBidChainId: any; tx: Transaction }> {
19
- const tx = deserializeOrCreateTxBlock({ existingTx });
18
+ const tx = existingTx ?? new Transaction();
20
19
 
21
20
  const multiBidChainId = tx.moveCall({
22
21
  target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
@@ -9,13 +9,13 @@ import {
9
9
  import { gqlChainRequest } from '../../graphql/gqlChainRequest';
10
10
  import { fetchNftsWithListingsById } from '../../graphql/queries/fetchNftsById';
11
11
  import { getNftType } from '../../helpers/getNftType';
12
+ import { isExpiredListing } from '../../helpers/isExpiredListing';
12
13
  import { type SharedKioskState } from '../../helpers/kiosk/sharedKioskState.type';
13
- import { relistNft } from '../relistNft/relistNft';
14
- import { addTradePortListTxHandler } from './addListTxs';
15
14
  import { isOriginByteCollection } from '../../helpers/originByte/isOriginByteCollection';
15
+ import { relistNft } from '../relistNft/relistNft';
16
16
  import { addSponsorListingTx } from '../sponsorNftListing/addSponsorNftListingTx';
17
17
  import { type SponsorNftListingOptions } from '../sponsorNftListing/sponsorNftListing';
18
- import { isExpiredListing } from '../../helpers/isExpiredListing';
18
+ import { addTradePortListTxHandler } from './addListTxs';
19
19
 
20
20
  export type ListNftTx = {
21
21
  tx: Transaction;
@@ -41,10 +41,11 @@ export type ListNfts = {
41
41
  sponsorOptions?: SponsorNftListingOptions;
42
42
  }>;
43
43
  walletAddress: string;
44
+ tx?: Transaction;
44
45
  };
45
46
 
46
47
  export const listNfts = async (
47
- { nfts, walletAddress }: ListNfts,
48
+ { nfts, walletAddress, tx: existingTx }: ListNfts,
48
49
  context: RequestContext,
49
50
  ): Promise<Transaction> => {
50
51
  const res = await gqlChainRequest({
@@ -58,7 +59,7 @@ export const listNfts = async (
58
59
  }
59
60
 
60
61
  const nftsForTracking = [];
61
- const tx = new Transaction();
62
+ const tx = existingTx ?? new Transaction();
62
63
 
63
64
  const sharedKioskState: SharedKioskState = {
64
65
  kioskTx: undefined,
@@ -120,12 +121,9 @@ export const listNfts = async (
120
121
  if (inputNft?.sponsorOptions?.shouldSponsor) {
121
122
  await addSponsorListingTx({
122
123
  tx,
123
- suiClient: context.suiClient,
124
124
  nftTokenId: nft?.token_id,
125
125
  nftType,
126
- walletAddress,
127
126
  sponsorOptions: inputNft?.sponsorOptions,
128
- defiRouterUrl: context.defiRouterUrl,
129
127
  });
130
128
  }
131
129
 
@@ -150,5 +148,5 @@ export const listNfts = async (
150
148
  // });
151
149
  // }
152
150
 
153
- return tx instanceof Transaction ? tx : Transaction.from(tx);
151
+ return tx;
154
152
  };
@@ -5,8 +5,6 @@ import { type RequestContext } from '../../SuiTradingClient';
5
5
  import { ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK } from '../../constants';
6
6
  import { gqlChainRequest } from '../../graphql/gqlChainRequest';
7
7
  import { fetchCollectionsByIdWithOneNft } from '../../graphql/queries/fetchCollectionsById';
8
- import { deserializeOrCreateTxBlock } from '../../helpers/deserializeOrCreateTxBlock';
9
- import { extractSwapResultCoinFromTxBlock } from '../../helpers/extractSwapResultCoin';
10
8
  import { getNftType } from '../../helpers/getNftType';
11
9
  import { getSharedObjects } from '../../helpers/getSharedObjects';
12
10
  import { getOrCreateOBKiosk } from '../../helpers/originByte/getOrCreateOBKiosk';
@@ -43,7 +41,7 @@ export type PlaceCollectionBid = {
43
41
  multiBidId?: string;
44
42
  multiBidChainId?: any;
45
43
  expireAt?: Date;
46
- tx?: Transaction | string;
44
+ tx?: Transaction;
47
45
  };
48
46
 
49
47
  export type PlaceCollectionBids = {
@@ -56,11 +54,19 @@ export type PlaceCollectionBids = {
56
54
  walletAddress: string;
57
55
  multiBidId?: string;
58
56
  multiBidChainId?: any;
59
- tx?: Transaction | string;
57
+ tx?: Transaction;
58
+ coinToSplit?: any;
60
59
  };
61
60
 
62
61
  export const placeCollectionBids = async (
63
- { collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }: PlaceCollectionBids,
62
+ {
63
+ collections,
64
+ walletAddress,
65
+ multiBidId,
66
+ multiBidChainId,
67
+ tx: existingTx,
68
+ coinToSplit,
69
+ }: PlaceCollectionBids,
64
70
  context: RequestContext,
65
71
  ): Promise<Transaction> => {
66
72
  const res = await gqlChainRequest({
@@ -74,8 +80,7 @@ export const placeCollectionBids = async (
74
80
  }
75
81
 
76
82
  const collectionsForTracking = [];
77
- const tx = deserializeOrCreateTxBlock({ existingTx });
78
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
83
+ const tx = existingTx ?? new Transaction();
79
84
 
80
85
  for (const collection of res.collections) {
81
86
  const nftType = getNftType({
@@ -98,7 +103,7 @@ export const placeCollectionBids = async (
98
103
  multiBidId,
99
104
  multiBidChainId,
100
105
  expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt,
101
- coinToSplit: swapResultCoin,
106
+ coinToSplit,
102
107
  };
103
108
 
104
109
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
@@ -135,10 +140,6 @@ export const placeCollectionBids = async (
135
140
  });
136
141
  }
137
142
 
138
- if (swapResultCoin) {
139
- tx.transferObjects([swapResultCoin], walletAddress);
140
- }
141
-
142
143
  // if (process.env.ENABLE_SEGMENT_TRACKING === 'true' && collectionsForTracking.length > 0) {
143
144
  // trackMethodCall({
144
145
  // apiUser: context.apiUser,
@@ -148,5 +149,5 @@ export const placeCollectionBids = async (
148
149
  // });
149
150
  // }
150
151
 
151
- return Transaction.from(tx);
152
+ return tx;
152
153
  };
@@ -7,8 +7,6 @@ import {
7
7
  } from '../../constants';
8
8
  import { gqlChainRequest } from '../../graphql/gqlChainRequest';
9
9
  import { fetchNftsById } from '../../graphql/queries/fetchNftsById';
10
- import { deserializeOrCreateTxBlock } from '../../helpers/deserializeOrCreateTxBlock';
11
- import { extractSwapResultCoinFromTxBlock } from '../../helpers/extractSwapResultCoin';
12
10
  import { getNftType } from '../../helpers/getNftType';
13
11
  import { addTradePortPlaceNftBidTxHandler } from './addPlaceNftBidTxs';
14
12
 
@@ -38,15 +36,15 @@ export type PlaceNftBids = {
38
36
  walletAddress: string;
39
37
  multiBidId?: string;
40
38
  multiBidChainId?: any;
41
- tx?: Transaction | string;
39
+ tx?: Transaction;
40
+ coinToSplit?: any;
42
41
  };
43
42
 
44
43
  export const placeNftBids = async (
45
- { bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }: PlaceNftBids,
44
+ { bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx, coinToSplit }: PlaceNftBids,
46
45
  context: RequestContext,
47
46
  ): Promise<Transaction> => {
48
- const tx = deserializeOrCreateTxBlock({ existingTx });
49
- const swapResultCoin = extractSwapResultCoinFromTxBlock(tx);
47
+ const tx = existingTx ?? new Transaction();
50
48
 
51
49
  const res = await gqlChainRequest({
52
50
  chain: 'sui',
@@ -87,7 +85,7 @@ export const placeNftBids = async (
87
85
  multiBidId,
88
86
  multiBidChainId,
89
87
  expireAt: bid?.expireAt,
90
- coinToSplit: swapResultCoin,
88
+ coinToSplit,
91
89
  };
92
90
 
93
91
  await addTradePortPlaceNftBidTxHandler(txData);
@@ -100,10 +98,6 @@ export const placeNftBids = async (
100
98
  });
101
99
  }
102
100
 
103
- if (swapResultCoin) {
104
- tx.transferObjects([swapResultCoin], walletAddress);
105
- }
106
-
107
101
  // if (process.env.ENABLE_SEGMENT_TRACKING === 'true' && nftsForTracking.length > 0) {
108
102
  // trackMethodCall({
109
103
  // apiUser: context.apiUser,
@@ -113,5 +107,5 @@ export const placeNftBids = async (
113
107
  // });
114
108
  // }
115
109
 
116
- return Transaction.from(tx);
110
+ return tx;
117
111
  };