@tradeport/sui-trading-sdk 0.3.0 → 0.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 69418c0: Fixed serialization of Transaction in bulk remove bids
8
+
9
+ ## 0.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - f04f941: Added bulk remove bids
14
+
3
15
  ## 0.3.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -126,12 +126,14 @@ type PlaceNftBids = {
126
126
  walletAddress: string;
127
127
  };
128
128
 
129
- type RemoveCollectionBid = {
130
- bidId: string;
129
+ type RemoveCollectionBids = {
130
+ bidIds: string[];
131
+ tx?: Transaction | string;
131
132
  };
132
133
 
133
134
  type RemoveNftBids = {
134
135
  bidIds: string[];
136
+ tx?: Transaction | string;
135
137
  };
136
138
 
137
139
  type TransferNfts = {
@@ -166,11 +168,11 @@ declare class SuiTradingClient {
166
168
  listNfts({ nfts, walletAddress }: ListNfts): Promise<Transaction>;
167
169
  unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
168
170
  placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<Transaction>;
169
- removeNftBids({ bidIds }: RemoveNftBids): Promise<Transaction>;
171
+ removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
170
172
  acceptNftBids({ bidIds }: AcceptNftBids): Promise<Transaction>;
171
173
  placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<Transaction>;
172
174
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
173
- removeCollectionBid({ bidId }: RemoveCollectionBid): Promise<Transaction>;
175
+ removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
174
176
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
175
177
  cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers): Promise<Transaction>;
176
178
  claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
package/dist/index.d.ts CHANGED
@@ -126,12 +126,14 @@ type PlaceNftBids = {
126
126
  walletAddress: string;
127
127
  };
128
128
 
129
- type RemoveCollectionBid = {
130
- bidId: string;
129
+ type RemoveCollectionBids = {
130
+ bidIds: string[];
131
+ tx?: Transaction | string;
131
132
  };
132
133
 
133
134
  type RemoveNftBids = {
134
135
  bidIds: string[];
136
+ tx?: Transaction | string;
135
137
  };
136
138
 
137
139
  type TransferNfts = {
@@ -166,11 +168,11 @@ declare class SuiTradingClient {
166
168
  listNfts({ nfts, walletAddress }: ListNfts): Promise<Transaction>;
167
169
  unlistListings({ listingIds, walletAddress }: UnlistListings): Promise<Transaction>;
168
170
  placeNftBids({ nfts, walletAddress }: PlaceNftBids): Promise<Transaction>;
169
- removeNftBids({ bidIds }: RemoveNftBids): Promise<Transaction>;
171
+ removeNftBids({ bidIds, tx }: RemoveNftBids): Promise<Transaction>;
170
172
  acceptNftBids({ bidIds }: AcceptNftBids): Promise<Transaction>;
171
173
  placeCollectionBid({ collectionId, bidAmountInMist, numOfBids, walletAddress, }: PlaceCollectionBid): Promise<Transaction>;
172
174
  acceptCollectionBid({ bidId, nftId, walletAddress }: AcceptCollectionBid): Promise<Transaction>;
173
- removeCollectionBid({ bidId }: RemoveCollectionBid): Promise<Transaction>;
175
+ removeCollectionBids({ bidIds, tx }: RemoveCollectionBids): Promise<Transaction>;
174
176
  transferNfts({ nftIds, recipientAddress, walletAddress }: TransferNfts): Promise<Transaction>;
175
177
  cancelNftTransfers({ nftIds, walletAddress }: CancelNftTransfers): Promise<Transaction>;
176
178
  claimNfts({ nftIds, walletAddress }: ClaimNfts): Promise<Transaction>;
package/dist/index.js CHANGED
@@ -81,9 +81,9 @@ var gqlChainRequest = async ({ chain, query, variables }) => {
81
81
 
82
82
  // src/graphql/queries/fetchCollectionBidById.ts
83
83
  var import_graphql_request3 = require("graphql-request");
84
- var fetchCollectionBidById = import_graphql_request3.gql`
85
- query fetchCollectionBidById($bidId: uuid!) {
86
- bids(where: { id: { _eq: $bidId } }) {
84
+ var fetchCollectionBidsById = import_graphql_request3.gql`
85
+ query fetchCollectionBidsById($bidIds: [uuid!]) {
86
+ bids(where: { id: { _in: $bidIds } }) {
87
87
  nonce
88
88
  price
89
89
  bidder
@@ -5783,7 +5783,7 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
5783
5783
  return import_transactions18.Transaction.from(tx);
5784
5784
  };
5785
5785
 
5786
- // src/methods/removeCollectionBid/removeCollectionBid.ts
5786
+ // src/methods/removeCollectionBids/removeCollectionBids.ts
5787
5787
  var import_transactions19 = require("@mysten/sui/transactions");
5788
5788
 
5789
5789
  // src/methods/removeNftBids/addRemoveNftBidTxs.ts
@@ -5843,7 +5843,7 @@ async function addTradePortRemoveNftBidTxHandler(txData) {
5843
5843
  addTradeportRemoveNftBidTx(txData);
5844
5844
  }
5845
5845
 
5846
- // src/methods/removeCollectionBid/addRemoveCollectionBidTxs.ts
5846
+ // src/methods/removeCollectionBids/addRemoveCollectionBidsTxs.ts
5847
5847
  function addTradeportRemoveCollectionBidTx({
5848
5848
  tx,
5849
5849
  nftType,
@@ -5902,7 +5902,8 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
5902
5902
  objectId: txData?.bidNonce
5903
5903
  });
5904
5904
  if (isOriginByteBid(bidType)) {
5905
- addOriginByteRemoveCollectionBidTx(txData);
5905
+ const sharedObjects = await getSharedObjects(txData?.nftType);
5906
+ addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
5906
5907
  return;
5907
5908
  }
5908
5909
  if (isTradePortKioskBid(bidType)) {
@@ -5914,7 +5915,8 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
5914
5915
  async function addBluemoveRemoveCollectionBidTxHandler(txData) {
5915
5916
  const bidType = await getObjectType({ suiClient: txData?.suiClient, objectId: txData?.bidNonce });
5916
5917
  if (isOriginByteBid(bidType)) {
5917
- addOriginByteRemoveCollectionBidTx(txData);
5918
+ const sharedObjects = await getSharedObjects(txData?.nftType);
5919
+ addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
5918
5920
  return;
5919
5921
  }
5920
5922
  if (isBluemoveKioskBid(txData?.bidNonce)) {
@@ -5924,21 +5926,22 @@ async function addBluemoveRemoveCollectionBidTxHandler(txData) {
5924
5926
  addBluemoveRemoveCollectionBidTx(txData);
5925
5927
  }
5926
5928
  async function addClutchyRemoveCollectionBidTxHandler(txData) {
5927
- addOriginByteRemoveCollectionBidTx(txData);
5929
+ const sharedObjects = await getSharedObjects(txData?.nftType);
5930
+ addOriginByteRemoveCollectionBidTx({ ...txData, sharedObjects });
5928
5931
  }
5929
5932
 
5930
- // src/methods/removeCollectionBid/removeCollectionBid.ts
5931
- var removeCollectionBid = async ({ bidId }, context) => {
5933
+ // src/methods/removeCollectionBids/removeCollectionBids.ts
5934
+ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
5932
5935
  const res = await gqlChainRequest({
5933
5936
  chain: "sui",
5934
- query: fetchCollectionBidById,
5935
- variables: { bidId }
5937
+ query: fetchCollectionBidsById,
5938
+ variables: { bidIds }
5936
5939
  });
5937
5940
  if (res?.bids?.length === 0) {
5938
5941
  throw new Error("No bids found");
5939
5942
  }
5940
5943
  const bidsForTracking = [];
5941
- const tx = new import_transactions19.Transaction();
5944
+ const tx = import_transactions19.Transaction.from(existingTx) ?? new import_transactions19.Transaction();
5942
5945
  for (const bid of res.bids) {
5943
5946
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
5944
5947
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5953,11 +5956,9 @@ var removeCollectionBid = async ({ bidId }, context) => {
5953
5956
  collectionChainState: collectionWithOneNftRes?.collections?.[0]?.chain_state,
5954
5957
  nft: collectionWithOneNftRes?.collections?.[0]?.nfts?.[0]
5955
5958
  });
5956
- const sharedObjects = await getSharedObjects(nftType);
5957
5959
  const txData = {
5958
5960
  tx,
5959
5961
  suiClient: context.suiClient,
5960
- sharedObjects,
5961
5962
  bidNonce: bid?.nonce,
5962
5963
  bidder: bid?.bidder,
5963
5964
  nftType,
@@ -5992,7 +5993,7 @@ var removeCollectionBid = async ({ bidId }, context) => {
5992
5993
 
5993
5994
  // src/methods/removeNftBids/removeNftBids.ts
5994
5995
  var import_transactions20 = require("@mysten/sui/transactions");
5995
- var removeNftBids = async ({ bidIds }, context) => {
5996
+ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
5996
5997
  const res = await gqlChainRequest({
5997
5998
  chain: "sui",
5998
5999
  query: fetchBidsById,
@@ -6002,7 +6003,7 @@ var removeNftBids = async ({ bidIds }, context) => {
6002
6003
  throw new Error("No bids found");
6003
6004
  }
6004
6005
  const bidsForTracking = [];
6005
- const tx = new import_transactions20.Transaction();
6006
+ const tx = import_transactions20.Transaction.from(existingTx) ?? new import_transactions20.Transaction();
6006
6007
  for (const bid of res.bids) {
6007
6008
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
6008
6009
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6012,11 +6013,9 @@ var removeNftBids = async ({ bidIds }, context) => {
6012
6013
  collectionChainState: bid?.collection?.chain_state,
6013
6014
  nft: bid?.nft
6014
6015
  });
6015
- const sharedObjects = await getSharedObjects(nftType);
6016
6016
  const txData = {
6017
6017
  tx,
6018
6018
  suiClient: context.suiClient,
6019
- sharedObjects,
6020
6019
  bidNonce: bid?.nonce,
6021
6020
  nftType,
6022
6021
  nftTokenId: bid?.nft?.token_id,
@@ -6350,14 +6349,14 @@ var SuiTradingClient = class {
6350
6349
  };
6351
6350
  return placeNftBids({ nfts, walletAddress }, context);
6352
6351
  }
6353
- async removeNftBids({ bidIds }) {
6352
+ async removeNftBids({ bidIds, tx }) {
6354
6353
  const context = {
6355
6354
  apiUser: this.apiUser,
6356
6355
  apiKey: this.apiKey,
6357
6356
  suiClient: this.suiClient,
6358
6357
  kioskClient: this.kioskClient
6359
6358
  };
6360
- return removeNftBids({ bidIds }, context);
6359
+ return removeNftBids({ bidIds, tx }, context);
6361
6360
  }
6362
6361
  async acceptNftBids({ bidIds }) {
6363
6362
  const context = {
@@ -6403,8 +6402,8 @@ var SuiTradingClient = class {
6403
6402
  };
6404
6403
  const collectionBidRes = await gqlChainRequest({
6405
6404
  chain: "sui",
6406
- query: fetchCollectionBidById,
6407
- variables: { bidId }
6405
+ query: fetchCollectionBidsById,
6406
+ variables: { bidIds: [bidId] }
6408
6407
  });
6409
6408
  const bid = collectionBidRes?.bids?.[0];
6410
6409
  if (!bid) {
@@ -6466,14 +6465,14 @@ var SuiTradingClient = class {
6466
6465
  }
6467
6466
  }
6468
6467
  }
6469
- async removeCollectionBid({ bidId }) {
6468
+ async removeCollectionBids({ bidIds, tx }) {
6470
6469
  const context = {
6471
6470
  apiUser: this.apiUser,
6472
6471
  apiKey: this.apiKey,
6473
6472
  suiClient: this.suiClient,
6474
6473
  kioskClient: this.kioskClient
6475
6474
  };
6476
- return removeCollectionBid({ bidId }, context);
6475
+ return removeCollectionBids({ bidIds, tx }, context);
6477
6476
  }
6478
6477
  async transferNfts({ nftIds, recipientAddress, walletAddress }) {
6479
6478
  const context = {