@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/dist/index.js CHANGED
@@ -4208,8 +4208,30 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4208
4208
  return tx;
4209
4209
  }
4210
4210
 
4211
- // src/methods/cancelNftTransfers/cancelNftTransfers.ts
4211
+ // src/methods/cancelMultiBid/cancelMultiBid.ts
4212
4212
  var import_transactions11 = require("@mysten/sui/transactions");
4213
+ async function cancelMultiBid({ multiBidId }) {
4214
+ const { chain_id: multiBidChainId, cancelled_at } = (await gqlChainRequest({
4215
+ chain: "sui",
4216
+ query: fetchMultibidChainIdById,
4217
+ variables: { multiBidId }
4218
+ }))?.multi_bids?.[0] ?? {};
4219
+ if (!multiBidChainId) {
4220
+ throw new Error(`MultiBid ${multiBidId} not found`);
4221
+ }
4222
+ if (cancelled_at) {
4223
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
4224
+ }
4225
+ const tx = new import_transactions11.Transaction();
4226
+ tx.moveCall({
4227
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_multi_bid`,
4228
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.id(multiBidChainId)]
4229
+ });
4230
+ return tx;
4231
+ }
4232
+
4233
+ // src/methods/cancelNftTransfers/cancelNftTransfers.ts
4234
+ var import_transactions12 = require("@mysten/sui/transactions");
4213
4235
 
4214
4236
  // src/graphql/queries/fetchAccountKiosks.ts
4215
4237
  var import_graphql_request17 = require("graphql-request");
@@ -4263,7 +4285,7 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
4263
4285
  throw new Error("No nfts found");
4264
4286
  }
4265
4287
  const nftsForTracking = [];
4266
- const tx = new import_transactions11.Transaction();
4288
+ const tx = new import_transactions12.Transaction();
4267
4289
  for (const nft of res.nfts) {
4268
4290
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
4269
4291
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -4300,11 +4322,11 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
4300
4322
  }
4301
4323
  });
4302
4324
  }
4303
- return import_transactions11.Transaction.from(tx);
4325
+ return import_transactions12.Transaction.from(tx);
4304
4326
  };
4305
4327
 
4306
4328
  // src/methods/claimNfts/claimNfts.ts
4307
- var import_transactions12 = require("@mysten/sui/transactions");
4329
+ var import_transactions13 = require("@mysten/sui/transactions");
4308
4330
 
4309
4331
  // src/methods/claimNfts/addClaimNftsTxs.ts
4310
4332
  var addClaimTradeHoldTx = ({
@@ -4513,7 +4535,7 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
4513
4535
  throw new Error("No nfts found");
4514
4536
  }
4515
4537
  const nftsForTracking = [];
4516
- const tx = existingTx ?? new import_transactions12.Transaction();
4538
+ const tx = existingTx ?? new import_transactions13.Transaction();
4517
4539
  const kiosksByOwnerRes = await gqlChainRequest({
4518
4540
  chain: "sui",
4519
4541
  query: fetchKiosksByOwner,
@@ -4652,11 +4674,11 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
4652
4674
  }
4653
4675
  }
4654
4676
  }
4655
- return import_transactions12.Transaction.from(tx);
4677
+ return import_transactions13.Transaction.from(tx);
4656
4678
  };
4657
4679
 
4658
4680
  // src/methods/createLongLocks/createLongLocks.ts
4659
- var import_transactions13 = require("@mysten/sui/transactions");
4681
+ var import_transactions14 = require("@mysten/sui/transactions");
4660
4682
 
4661
4683
  // src/graphql/queries/fetchActiveLockStateByNftId.ts
4662
4684
  var import_graphql_request18 = require("graphql-request");
@@ -4687,7 +4709,7 @@ var getActiveLockStateByNftId = async (nftId) => {
4687
4709
  // src/methods/createLongLocks/createLongLocks.ts
4688
4710
  async function createLongLocks({ walletAddress, nfts }, context) {
4689
4711
  const expireIn = 7 * 24 * 3600 * 1e3;
4690
- const tx = new import_transactions13.Transaction();
4712
+ const tx = new import_transactions14.Transaction();
4691
4713
  for (const argNft of nfts) {
4692
4714
  const existingLock = await getActiveLockStateByNftId(argNft.id);
4693
4715
  if (existingLock) {
@@ -4746,11 +4768,77 @@ async function createLongLocks({ walletAddress, nfts }, context) {
4746
4768
  return tx;
4747
4769
  }
4748
4770
 
4771
+ // src/methods/createMultiBid/createMultiBid.ts
4772
+ var import_transactions16 = require("@mysten/sui/transactions");
4773
+
4774
+ // src/methods/updateMultiBid/updateMultiBid.ts
4775
+ var import_transactions15 = require("@mysten/sui/transactions");
4776
+ async function updateMultiBid({
4777
+ multiBidId,
4778
+ name,
4779
+ amount,
4780
+ amountToWithdraw,
4781
+ tx: existingTx,
4782
+ multiBidChainId
4783
+ }) {
4784
+ const tx = existingTx ?? new import_transactions15.Transaction();
4785
+ if (!multiBidChainId) {
4786
+ const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
4787
+ chain: "sui",
4788
+ query: fetchMultibidChainIdById,
4789
+ variables: { multiBidId }
4790
+ }))?.multi_bids?.[0] ?? {};
4791
+ if (!chainId) {
4792
+ throw new Error(`MultiBid ${multiBidId} not found`);
4793
+ }
4794
+ if (cancelled_at) {
4795
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
4796
+ }
4797
+ multiBidChainId = chainId;
4798
+ }
4799
+ const [coin] = tx.splitCoins(tx.gas, [amount ?? 0n]);
4800
+ tx.moveCall({
4801
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
4802
+ arguments: [
4803
+ tx.object(TRADEPORT_MULTI_BID_STORE),
4804
+ typeof multiBidChainId === "string" ? tx.pure.id(multiBidChainId) : multiBidChainId,
4805
+ tx.pure.option("string", name),
4806
+ coin,
4807
+ tx.pure.option("u64", amountToWithdraw)
4808
+ ]
4809
+ });
4810
+ return tx;
4811
+ }
4812
+
4813
+ // src/methods/createMultiBid/createMultiBid.ts
4814
+ async function createMultiBid({
4815
+ walletAddress,
4816
+ name,
4817
+ amount,
4818
+ tx: existingTx
4819
+ }) {
4820
+ const tx = existingTx ?? new import_transactions16.Transaction();
4821
+ const multiBidChainId = tx.moveCall({
4822
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
4823
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
4824
+ });
4825
+ if (amount > 0n) {
4826
+ await updateMultiBid({
4827
+ walletAddress,
4828
+ multiBidChainId,
4829
+ amount,
4830
+ name,
4831
+ tx
4832
+ });
4833
+ }
4834
+ return { multiBidChainId, tx };
4835
+ }
4836
+
4749
4837
  // src/methods/createShortLocks/createShortLocks.ts
4750
- var import_transactions14 = require("@mysten/sui/transactions");
4838
+ var import_transactions17 = require("@mysten/sui/transactions");
4751
4839
  async function createShortLocks({ nfts }, context) {
4752
4840
  const expireIn = 7 * 24 * 3600 * 1e3;
4753
- const tx = new import_transactions14.Transaction();
4841
+ const tx = new import_transactions17.Transaction();
4754
4842
  for (const argNft of nfts) {
4755
4843
  const premium = calculatePremium(BigInt(argNft.priceInMist));
4756
4844
  if (!argNft.type) {
@@ -4788,7 +4876,7 @@ async function createShortLocks({ nfts }, context) {
4788
4876
  }
4789
4877
 
4790
4878
  // src/methods/listNfts/listNfts.ts
4791
- var import_transactions15 = require("@mysten/sui/transactions");
4879
+ var import_transactions18 = require("@mysten/sui/transactions");
4792
4880
 
4793
4881
  // src/methods/listNfts/addListTxs.ts
4794
4882
  async function addOriginByteListTx({
@@ -5093,7 +5181,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5093
5181
  throw new Error("No nfts found");
5094
5182
  }
5095
5183
  const nftsForTracking = [];
5096
- const tx = new import_transactions15.Transaction();
5184
+ const tx = new import_transactions18.Transaction();
5097
5185
  for (const nft of res.nfts) {
5098
5186
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
5099
5187
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5137,11 +5225,11 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5137
5225
  marketRelistedFrom: nft?.listings?.[0]?.market_name
5138
5226
  });
5139
5227
  }
5140
- return import_transactions15.Transaction.from(tx);
5228
+ return import_transactions18.Transaction.from(tx);
5141
5229
  };
5142
5230
 
5143
5231
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5144
- var import_transactions16 = require("@mysten/sui/transactions");
5232
+ var import_transactions19 = require("@mysten/sui/transactions");
5145
5233
 
5146
5234
  // src/graphql/queries/fetchNftsByKioskId.ts
5147
5235
  var import_graphql_request19 = require("graphql-request");
@@ -5301,7 +5389,7 @@ function getTransferPolicyForDirectTransfer(collectionChainState) {
5301
5389
 
5302
5390
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5303
5391
  async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 }, context) {
5304
- const tx = new import_transactions16.Transaction();
5392
+ const tx = new import_transactions19.Transaction();
5305
5393
  const res = await gqlChainRequest({
5306
5394
  chain: "sui",
5307
5395
  query: fetchKiosksByOwner,
@@ -5423,11 +5511,11 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 },
5423
5511
  });
5424
5512
  }
5425
5513
  }
5426
- return import_transactions16.Transaction.from(tx);
5514
+ return import_transactions19.Transaction.from(tx);
5427
5515
  }
5428
5516
 
5429
5517
  // src/methods/placeCollectionBids/placeCollectionBids.ts
5430
- var import_transactions17 = require("@mysten/sui/transactions");
5518
+ var import_transactions20 = require("@mysten/sui/transactions");
5431
5519
 
5432
5520
  // src/graphql/queries/fetchCollectionsById.ts
5433
5521
  var import_graphql_request20 = require("graphql-request");
@@ -5621,14 +5709,7 @@ async function addOriginByteCollectionBidTx({
5621
5709
  }
5622
5710
 
5623
5711
  // src/methods/placeCollectionBids/placeCollectionBids.ts
5624
- var placeCollectionBids = async ({
5625
- collections,
5626
- walletAddress,
5627
- multiBidId,
5628
- multiBidChainId,
5629
- expireAt,
5630
- tx: existingTx
5631
- }, context) => {
5712
+ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
5632
5713
  const res = await gqlChainRequest({
5633
5714
  chain: "sui",
5634
5715
  query: fetchCollectionsByIdWithOneNft,
@@ -5638,7 +5719,7 @@ var placeCollectionBids = async ({
5638
5719
  throw new Error("No collection found");
5639
5720
  }
5640
5721
  const collectionsForTracking = [];
5641
- const tx = existingTx ? import_transactions17.Transaction.from(existingTx) : new import_transactions17.Transaction();
5722
+ const tx = existingTx ? import_transactions20.Transaction.from(existingTx) : new import_transactions20.Transaction();
5642
5723
  for (const collection of res.collections) {
5643
5724
  const nftType = getNftType({
5644
5725
  collectionId: collection?.id,
@@ -5657,7 +5738,7 @@ var placeCollectionBids = async ({
5657
5738
  bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist,
5658
5739
  multiBidId,
5659
5740
  multiBidChainId,
5660
- expireAt
5741
+ expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt
5661
5742
  };
5662
5743
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
5663
5744
  if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -5683,23 +5764,24 @@ var placeCollectionBids = async ({
5683
5764
  bidder: walletAddress
5684
5765
  });
5685
5766
  }
5686
- return import_transactions17.Transaction.from(tx);
5767
+ return import_transactions20.Transaction.from(tx);
5687
5768
  };
5688
5769
 
5689
5770
  // src/methods/placeNftBids/placeNftBids.ts
5690
- var import_transactions18 = require("@mysten/sui/transactions");
5691
- var placeNftBids = async ({ nfts, walletAddress, multiBidId, multiBidChainId, expireAt, tx: existingTx }, context) => {
5692
- const tx = existingTx ? import_transactions18.Transaction.from(existingTx) : new import_transactions18.Transaction();
5771
+ var import_transactions21 = require("@mysten/sui/transactions");
5772
+ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
5773
+ const tx = existingTx ? import_transactions21.Transaction.from(existingTx) : new import_transactions21.Transaction();
5693
5774
  const res = await gqlChainRequest({
5694
5775
  chain: "sui",
5695
5776
  query: fetchNftsById,
5696
- variables: { nftIds: nfts.map((nft) => nft.id) }
5777
+ variables: { nftIds: bids.map((bid) => bid.nftId) }
5697
5778
  });
5698
5779
  if (res?.nfts?.length === 0) {
5699
5780
  throw new Error("No nfts found");
5700
5781
  }
5701
5782
  const nftsForTracking = [];
5702
- for (const nft of res.nfts) {
5783
+ for (const bid of bids) {
5784
+ const nft = res.nfts?.find((nft2) => nft2.id === bid.nftId);
5703
5785
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
5704
5786
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
5705
5787
  }
@@ -5717,25 +5799,25 @@ var placeNftBids = async ({ nfts, walletAddress, multiBidId, multiBidChainId, ex
5717
5799
  collectionId: nft?.collection_id,
5718
5800
  nftTokenId: nft?.token_id,
5719
5801
  nftType,
5720
- bidAmount: BigInt(nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist ?? 0n),
5802
+ bidAmount: BigInt(bid?.bidAmountInMist ?? 0n),
5721
5803
  bcsHex: nft.chain_state?.bcs?.bcsHex,
5722
5804
  multiBidId,
5723
5805
  multiBidChainId,
5724
- expireAt
5806
+ expireAt: bid?.expireAt
5725
5807
  };
5726
5808
  await addTradePortPlaceNftBidTxHandler(txData);
5727
5809
  nftsForTracking.push({
5728
5810
  nftType,
5729
5811
  collectionId: nft?.collection_id,
5730
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
5812
+ bidAmount: bid?.bidAmountInMist,
5731
5813
  bidder: walletAddress
5732
5814
  });
5733
5815
  }
5734
- return import_transactions18.Transaction.from(tx);
5816
+ return import_transactions21.Transaction.from(tx);
5735
5817
  };
5736
5818
 
5737
5819
  // src/methods/removeCollectionBids/removeCollectionBids.ts
5738
- var import_transactions19 = require("@mysten/sui/transactions");
5820
+ var import_transactions22 = require("@mysten/sui/transactions");
5739
5821
 
5740
5822
  // src/methods/removeNftBids/addRemoveNftBidTxs.ts
5741
5823
  function addTradeportRemoveNftBidTx({ tx, bidNonce, nftType }) {
@@ -5915,7 +5997,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
5915
5997
  throw new Error("No bids found");
5916
5998
  }
5917
5999
  const bidsForTracking = [];
5918
- const tx = existingTx ? import_transactions19.Transaction.from(existingTx) : new import_transactions19.Transaction();
6000
+ const tx = existingTx ? import_transactions22.Transaction.from(existingTx) : new import_transactions22.Transaction();
5919
6001
  for (const bid of res.bids) {
5920
6002
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
5921
6003
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5962,11 +6044,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
5962
6044
  bidder: bid?.bidder
5963
6045
  });
5964
6046
  }
5965
- return import_transactions19.Transaction.from(tx);
6047
+ return import_transactions22.Transaction.from(tx);
5966
6048
  };
5967
6049
 
5968
6050
  // src/methods/removeNftBids/removeNftBids.ts
5969
- var import_transactions20 = require("@mysten/sui/transactions");
6051
+ var import_transactions23 = require("@mysten/sui/transactions");
5970
6052
  var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
5971
6053
  const res = await gqlChainRequest({
5972
6054
  chain: "sui",
@@ -5977,7 +6059,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
5977
6059
  throw new Error("No bids found");
5978
6060
  }
5979
6061
  const bidsForTracking = [];
5980
- const tx = existingTx ? import_transactions20.Transaction.from(existingTx) : new import_transactions20.Transaction();
6062
+ const tx = existingTx ? import_transactions23.Transaction.from(existingTx) : new import_transactions23.Transaction();
5981
6063
  for (const bid of res.bids) {
5982
6064
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
5983
6065
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6022,11 +6104,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
6022
6104
  bidder: bid?.bidder
6023
6105
  });
6024
6106
  }
6025
- return import_transactions20.Transaction.from(tx);
6107
+ return import_transactions23.Transaction.from(tx);
6026
6108
  };
6027
6109
 
6028
6110
  // src/methods/transferNfts/transferNfts.ts
6029
- var import_transactions21 = require("@mysten/sui/transactions");
6111
+ var import_transactions24 = require("@mysten/sui/transactions");
6030
6112
 
6031
6113
  // src/helpers/rpc/getAcountBalance.ts
6032
6114
  var getAccountBalance = async ({ suiClient, owner }) => {
@@ -6062,7 +6144,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6062
6144
  }
6063
6145
  const nftsForTracking = [];
6064
6146
  const nftsToTransferDirectly = [];
6065
- const tx = new import_transactions21.Transaction();
6147
+ const tx = new import_transactions24.Transaction();
6066
6148
  for (const nft of res.nfts) {
6067
6149
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
6068
6150
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6122,11 +6204,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6122
6204
  { tx, kioskClient: context.kioskClient, senderAddress: walletAddress, recipientAddress },
6123
6205
  nftsToTransferDirectly
6124
6206
  );
6125
- return import_transactions21.Transaction.from(tx);
6207
+ return import_transactions24.Transaction.from(tx);
6126
6208
  };
6127
6209
 
6128
6210
  // src/methods/unlistListings/unlistListings.ts
6129
- var import_transactions22 = require("@mysten/sui/transactions");
6211
+ var import_transactions25 = require("@mysten/sui/transactions");
6130
6212
  var unlistListings = async ({ listingIds, walletAddress }, context) => {
6131
6213
  const res = await gqlChainRequest({
6132
6214
  chain: "sui",
@@ -6137,7 +6219,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6137
6219
  throw new Error("No listings found");
6138
6220
  }
6139
6221
  const listingsForTracking = [];
6140
- const tx = new import_transactions22.Transaction();
6222
+ const tx = new import_transactions25.Transaction();
6141
6223
  for (const listing of res.listings) {
6142
6224
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(listing?.nft?.token_id)) {
6143
6225
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6201,12 +6283,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6201
6283
  marketName: listing?.market_name
6202
6284
  });
6203
6285
  }
6204
- return import_transactions22.Transaction.from(tx);
6286
+ return import_transactions25.Transaction.from(tx);
6205
6287
  };
6206
6288
 
6207
6289
  // src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
6208
6290
  var import_kiosk5 = require("@mysten/kiosk");
6209
- var import_transactions23 = require("@mysten/sui/transactions");
6291
+ var import_transactions26 = require("@mysten/sui/transactions");
6210
6292
  async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6211
6293
  const res = await gqlChainRequest({
6212
6294
  chain: "sui",
@@ -6223,7 +6305,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6223
6305
  if (kiosksWithProfit.length === 0) {
6224
6306
  throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
6225
6307
  }
6226
- const tx = new import_transactions23.Transaction();
6308
+ const tx = new import_transactions26.Transaction();
6227
6309
  try {
6228
6310
  for (const kiosk of kiosksWithProfit) {
6229
6311
  let kioskTx;
@@ -6269,95 +6351,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6269
6351
  } catch (err) {
6270
6352
  console.log("err", err);
6271
6353
  }
6272
- return import_transactions23.Transaction.from(tx);
6273
- }
6274
-
6275
- // src/methods/createMultiBid/createMultiBid.ts
6276
- var import_transactions25 = require("@mysten/sui/transactions");
6277
-
6278
- // src/methods/updateMultiBid/updateMultiBid.ts
6279
- var import_transactions24 = require("@mysten/sui/transactions");
6280
- async function updateMultiBid({
6281
- multiBidId,
6282
- name,
6283
- amount,
6284
- amountToWithdraw,
6285
- tx: existingTx,
6286
- multiBidChainId
6287
- }) {
6288
- const tx = existingTx ?? new import_transactions24.Transaction();
6289
- if (!multiBidChainId) {
6290
- const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
6291
- chain: "sui",
6292
- query: fetchMultibidChainIdById,
6293
- variables: { multiBidId }
6294
- }))?.multi_bids?.[0] ?? {};
6295
- if (!chainId) {
6296
- throw new Error(`MultiBid ${multiBidId} not found`);
6297
- }
6298
- if (cancelled_at) {
6299
- throw new Error(`MultiBid ${multiBidId} already cancelled`);
6300
- }
6301
- multiBidChainId = chainId;
6302
- }
6303
- const [coin] = tx.splitCoins(tx.gas, [amount ?? 0n]);
6304
- tx.moveCall({
6305
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
6306
- arguments: [
6307
- tx.object(TRADEPORT_MULTI_BID_STORE),
6308
- typeof multiBidChainId === "string" ? tx.pure.id(multiBidChainId) : multiBidChainId,
6309
- tx.pure.option("string", name),
6310
- coin,
6311
- tx.pure.option("u64", amountToWithdraw)
6312
- ]
6313
- });
6314
- return tx;
6315
- }
6316
-
6317
- // src/methods/createMultiBid/createMultiBid.ts
6318
- async function createMultiBid({
6319
- walletAddress,
6320
- name,
6321
- amount,
6322
- tx: existingTx
6323
- }) {
6324
- const tx = existingTx ?? new import_transactions25.Transaction();
6325
- const multiBidChainId = tx.moveCall({
6326
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
6327
- arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
6328
- });
6329
- if (amount > 0n) {
6330
- await updateMultiBid({
6331
- walletAddress,
6332
- multiBidChainId,
6333
- amount,
6334
- name,
6335
- tx
6336
- });
6337
- }
6338
- return { multiBidChainId, tx };
6339
- }
6340
-
6341
- // src/methods/cancelMultiBid/cancelMultiBid.ts
6342
- var import_transactions26 = require("@mysten/sui/transactions");
6343
- async function cancelMultiBid({ multiBidId }) {
6344
- const { chain_id: multiBidChainId, cancelled_at } = (await gqlChainRequest({
6345
- chain: "sui",
6346
- query: fetchMultibidChainIdById,
6347
- variables: { multiBidId }
6348
- }))?.multi_bids?.[0] ?? {};
6349
- if (!multiBidChainId) {
6350
- throw new Error(`MultiBid ${multiBidId} not found`);
6351
- }
6352
- if (cancelled_at) {
6353
- throw new Error(`MultiBid ${multiBidId} already cancelled`);
6354
- }
6355
- const tx = new import_transactions26.Transaction();
6356
- tx.moveCall({
6357
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_multi_bid`,
6358
- arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.id(multiBidChainId)]
6359
- });
6360
- return tx;
6354
+ return import_transactions26.Transaction.from(tx);
6361
6355
  }
6362
6356
 
6363
6357
  // src/SuiTradingClient.ts
@@ -6437,7 +6431,8 @@ var SuiTradingClient = class {
6437
6431
  walletAddress,
6438
6432
  multiBidId,
6439
6433
  multiBidChainId,
6440
- expireAt
6434
+ expireAt,
6435
+ tx
6441
6436
  }) {
6442
6437
  const context = {
6443
6438
  apiUser: this.apiUser,
@@ -6451,13 +6446,14 @@ var SuiTradingClient = class {
6451
6446
  {
6452
6447
  id: collectionId,
6453
6448
  bidAmountInMist,
6454
- numOfBids
6449
+ numOfBids,
6450
+ expireAt
6455
6451
  }
6456
6452
  ],
6457
6453
  walletAddress,
6458
6454
  multiBidId,
6459
6455
  multiBidChainId,
6460
- expireAt
6456
+ tx
6461
6457
  },
6462
6458
  context
6463
6459
  );