@tradeport/sui-trading-sdk 0.4.0 → 0.4.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tradeport/sui-trading-sdk",
3
3
  "license": "MIT",
4
- "version": "0.4.0",
4
+ "version": "0.4.2",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
@@ -23,12 +23,14 @@ import {
23
23
  import { buyListings, type BuyListings } from './methods/buyListings/buyListings';
24
24
  import { buyLocks, type BuyLocks } from './methods/buyLocks/buyLocks';
25
25
  import { cancelLocks, type CancelLocks } from './methods/cancelLocks/cancelLocks';
26
+ import { cancelMultiBid, type CancelMultiBid } from './methods/cancelMultiBid/cancelMultiBid';
26
27
  import {
27
28
  cancelNftTransfers,
28
29
  type CancelNftTransfers,
29
30
  } from './methods/cancelNftTransfers/cancelNftTransfers';
30
31
  import { claimNfts, type ClaimNfts } from './methods/claimNfts/claimNfts';
31
32
  import { createLongLocks, type CreateLongLocks } from './methods/createLongLocks/createLongLocks';
33
+ import { createMultiBid, type CreateMultiBid } from './methods/createMultiBid/createMultiBid';
32
34
  import {
33
35
  createShortLocks,
34
36
  type CreateShortLocks,
@@ -58,14 +60,12 @@ import {
58
60
  import { removeNftBids, type RemoveNftBids } from './methods/removeNftBids/removeNftBids';
59
61
  import { transferNfts, type TransferNfts } from './methods/transferNfts/transferNfts';
60
62
  import { unlistListings, type UnlistListings } from './methods/unlistListings/unlistListings';
63
+ import { updateMultiBid, type UpdateMultiBid } from './methods/updateMultiBid/updateMultiBid';
61
64
  import {
62
65
  withdrawProfitsFromKiosks,
63
66
  type WithdrawProfitsFromKiosks,
64
67
  } from './methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks';
65
68
  import { addLeadingZerosAfter0x } from './utils/addLeadingZerosAfter0x';
66
- import { createMultiBid, type CreateMultiBid } from './methods/createMultiBid/createMultiBid';
67
- import { cancelMultiBid, type CancelMultiBid } from './methods/cancelMultiBid/cancelMultiBid';
68
- import { updateMultiBid, type UpdateMultiBid } from './methods/updateMultiBid/updateMultiBid';
69
69
 
70
70
  type ApiConfig = {
71
71
  apiUser: string;
@@ -179,6 +179,7 @@ class SuiTradingClient {
179
179
  multiBidId,
180
180
  multiBidChainId,
181
181
  expireAt,
182
+ tx,
182
183
  }: PlaceCollectionBid): Promise<Transaction> {
183
184
  const context: RequestContext = {
184
185
  apiUser: this.apiUser,
@@ -194,12 +195,13 @@ class SuiTradingClient {
194
195
  id: collectionId,
195
196
  bidAmountInMist,
196
197
  numOfBids,
198
+ expireAt,
197
199
  },
198
200
  ],
199
201
  walletAddress,
200
202
  multiBidId,
201
203
  multiBidChainId,
202
- expireAt,
204
+ tx,
203
205
  },
204
206
  context,
205
207
  );
package/src/constants.ts CHANGED
@@ -15,8 +15,8 @@ export const TRADEPORT_KIOSK_BID_NONCE_TYPE = '0xec175e537be9e48f75fa6929291de64
15
15
  export const TRADEPORT_PRICE_LOCK_PACKAGE = '0x3cb532a2548290780a3d70ad6f4f06abc5bebb75ec6f8dd0197d4d2b2860c5d8';
16
16
  export const TRADEPORT_PRICE_LOCK_STORE = '0x4b705de46a79b29276baf45009bc7d6f70cc0f1407f0c9e03cac5729c0c47946';
17
17
 
18
- export const TRADEPORT_MULTI_BID_PACKAGE = '0xb32c899d9fb0d79a7e384bfbf2830a19ee26ccf51d6cadaaf1a14c4a2817886a'; // Upgrade Cap 0x7fdc0ebfd6265f7642e68269eb085fb551f02a9953d38f1872370d59613207c7
19
- export const TRADEPORT_MULTI_BID_STORE = '0x2617658a6b03dcf6df2df4d256341bc4690d3a3d299c9552ca6ac9799ceb0ed7';
18
+ export const TRADEPORT_MULTI_BID_PACKAGE = '0x53134eb544c5a0b5085e99efaf7eab13b28ad123de35d61f941f8c8c40b72033';
19
+ export const TRADEPORT_MULTI_BID_STORE = '0x8aaed7e884343fb8b222c721d02eaac2c6ae2abbb4ddcdf16cb55cf8754ee860';
20
20
 
21
21
  export const COLLECTION_IDS_WITH_ZERO_COMMISSION = [
22
22
  '',
@@ -1,4 +1,5 @@
1
1
  import { type KioskClient } from '@mysten/kiosk';
2
+ import { type SuiClient } from '@mysten/sui/client';
2
3
  import { Transaction } from '@mysten/sui/transactions';
3
4
  import { type RequestContext } from '../../SuiTradingClient';
4
5
  import { ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK } from '../../constants';
@@ -10,9 +11,8 @@ import { getOrCreateOBKiosk } from '../../helpers/originByte/getOrCreateOBKiosk'
10
11
  import { isOriginByteTx } from '../../helpers/originByte/isOriginByteTx';
11
12
  import { shareOriginByteKiosk } from '../../helpers/originByte/shareOriginByteKiosk';
12
13
  import { normalizedNftType } from '../../utils/normalizeNftType';
13
- import { addOriginByteCollectionBidTx } from './addPlaceCollectionBidTxs';
14
- import { type SuiClient } from '@mysten/sui/client';
15
14
  import { addTradePortPlaceNftBidTxHandler } from '../placeNftBids/addPlaceNftBidTxs';
15
+ import { addOriginByteCollectionBidTx } from './addPlaceCollectionBidTxs';
16
16
 
17
17
  export type PlaceCollectionBidTx = {
18
18
  tx: Transaction;
@@ -39,7 +39,7 @@ export type PlaceCollectionBid = {
39
39
  multiBidId?: string;
40
40
  multiBidChainId?: any;
41
41
  expireAt?: Date;
42
- tx?: Transaction;
42
+ tx?: Transaction | string;
43
43
  };
44
44
 
45
45
  export type PlaceCollectionBids = {
@@ -47,23 +47,16 @@ export type PlaceCollectionBids = {
47
47
  id: string;
48
48
  bidAmountInMist: number;
49
49
  numOfBids: number;
50
+ expireAt?: Date;
50
51
  }>;
51
52
  walletAddress: string;
52
53
  multiBidId?: string;
53
54
  multiBidChainId?: any;
54
- expireAt?: Date;
55
- tx?: Transaction;
55
+ tx?: Transaction | string;
56
56
  };
57
57
 
58
58
  export const placeCollectionBids = async (
59
- {
60
- collections,
61
- walletAddress,
62
- multiBidId,
63
- multiBidChainId,
64
- expireAt,
65
- tx: existingTx,
66
- }: PlaceCollectionBids,
59
+ { collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }: PlaceCollectionBids,
67
60
  context: RequestContext,
68
61
  ): Promise<Transaction> => {
69
62
  const res = await gqlChainRequest({
@@ -77,7 +70,7 @@ export const placeCollectionBids = async (
77
70
  }
78
71
 
79
72
  const collectionsForTracking = [];
80
- const tx = existingTx ?? new Transaction();
73
+ const tx = existingTx ? Transaction.from(existingTx) : new Transaction();
81
74
 
82
75
  for (const collection of res.collections) {
83
76
  const nftType = getNftType({
@@ -99,7 +92,7 @@ export const placeCollectionBids = async (
99
92
  bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist,
100
93
  multiBidId,
101
94
  multiBidChainId,
102
- expireAt,
95
+ expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt,
103
96
  };
104
97
 
105
98
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
@@ -1,15 +1,15 @@
1
1
  import { type SuiClient } from '@mysten/sui/client';
2
2
  import { Transaction } from '@mysten/sui/transactions';
3
3
  import { type RequestContext } from '../../SuiTradingClient';
4
+ import {
5
+ DELOREAN_TOKEN_IDS_TO_DISABLE,
6
+ DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE,
7
+ } from '../../constants';
4
8
  import { gqlChainRequest } from '../../graphql/gqlChainRequest';
5
9
  import { fetchNftsById } from '../../graphql/queries/fetchNftsById';
6
10
  import { getNftType } from '../../helpers/getNftType';
7
11
  import { getSharedObjects } from '../../helpers/getSharedObjects';
8
12
  import { addTradePortPlaceNftBidTxHandler } from './addPlaceNftBidTxs';
9
- import {
10
- DELOREAN_TOKEN_IDS_TO_DISABLE,
11
- DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE,
12
- } from '../../constants';
13
13
 
14
14
  export type PlaceNftBidTx = {
15
15
  tx: Transaction;
@@ -32,30 +32,31 @@ export type PlaceNftBid = {
32
32
  walletAddress: string;
33
33
  multiBidId?: string;
34
34
  multiBidChainId?: any;
35
- tx?: Transaction;
35
+ tx?: Transaction | string;
36
36
  };
37
37
 
38
38
  export type PlaceNftBids = {
39
- nfts: Array<{
40
- id: string;
39
+ bids: Array<{
40
+ nftId: string;
41
41
  bidAmountInMist: number;
42
+ expireAt?: Date;
42
43
  }>;
43
44
  walletAddress: string;
44
45
  multiBidId?: string;
45
46
  multiBidChainId?: any;
46
- expireAt?: Date;
47
- tx?: Transaction;
47
+ tx?: Transaction | string;
48
48
  };
49
49
 
50
50
  export const placeNftBids = async (
51
- { nfts, walletAddress, multiBidId, multiBidChainId, expireAt, tx: existingTx }: PlaceNftBids,
51
+ { bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }: PlaceNftBids,
52
52
  context: RequestContext,
53
53
  ): Promise<Transaction> => {
54
- const tx = existingTx ?? new Transaction();
54
+ const tx = existingTx ? Transaction.from(existingTx) : new Transaction();
55
+
55
56
  const res = await gqlChainRequest({
56
57
  chain: 'sui',
57
58
  query: fetchNftsById,
58
- variables: { nftIds: nfts.map((nft) => nft.id) },
59
+ variables: { nftIds: bids.map((bid) => bid.nftId) },
59
60
  });
60
61
 
61
62
  if (res?.nfts?.length === 0) {
@@ -63,7 +64,9 @@ export const placeNftBids = async (
63
64
  }
64
65
 
65
66
  const nftsForTracking = [];
66
- for (const nft of res.nfts) {
67
+ for (const bid of bids) {
68
+ const nft = res.nfts?.find((nft: any) => nft.id === bid.nftId);
69
+
67
70
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
68
71
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
69
72
  }
@@ -84,11 +87,11 @@ export const placeNftBids = async (
84
87
  collectionId: nft?.collection_id,
85
88
  nftTokenId: nft?.token_id,
86
89
  nftType,
87
- bidAmount: BigInt(nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist ?? 0n),
90
+ bidAmount: BigInt(bid?.bidAmountInMist ?? 0n),
88
91
  bcsHex: nft.chain_state?.bcs?.bcsHex,
89
92
  multiBidId,
90
93
  multiBidChainId,
91
- expireAt,
94
+ expireAt: bid?.expireAt,
92
95
  };
93
96
 
94
97
  await addTradePortPlaceNftBidTxHandler(txData);
@@ -96,7 +99,7 @@ export const placeNftBids = async (
96
99
  nftsForTracking.push({
97
100
  nftType,
98
101
  collectionId: nft?.collection_id,
99
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
102
+ bidAmount: bid?.bidAmountInMist,
100
103
  bidder: walletAddress,
101
104
  });
102
105
  }