@tradeport/sui-trading-sdk 0.4.1 → 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.1",
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
  );
@@ -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
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({
@@ -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;
@@ -36,26 +36,27 @@ export type PlaceNftBid = {
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
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
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
  }