@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.mjs CHANGED
@@ -4184,8 +4184,30 @@ async function cancelLocks({ lockIds, walletAddress, tx: existingTx }, context)
4184
4184
  return tx;
4185
4185
  }
4186
4186
 
4187
- // src/methods/cancelNftTransfers/cancelNftTransfers.ts
4187
+ // src/methods/cancelMultiBid/cancelMultiBid.ts
4188
4188
  import { Transaction as Transaction11 } from "@mysten/sui/transactions";
4189
+ async function cancelMultiBid({ multiBidId }) {
4190
+ const { chain_id: multiBidChainId, cancelled_at } = (await gqlChainRequest({
4191
+ chain: "sui",
4192
+ query: fetchMultibidChainIdById,
4193
+ variables: { multiBidId }
4194
+ }))?.multi_bids?.[0] ?? {};
4195
+ if (!multiBidChainId) {
4196
+ throw new Error(`MultiBid ${multiBidId} not found`);
4197
+ }
4198
+ if (cancelled_at) {
4199
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
4200
+ }
4201
+ const tx = new Transaction11();
4202
+ tx.moveCall({
4203
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_multi_bid`,
4204
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.id(multiBidChainId)]
4205
+ });
4206
+ return tx;
4207
+ }
4208
+
4209
+ // src/methods/cancelNftTransfers/cancelNftTransfers.ts
4210
+ import { Transaction as Transaction12 } from "@mysten/sui/transactions";
4189
4211
 
4190
4212
  // src/graphql/queries/fetchAccountKiosks.ts
4191
4213
  import { gql as gql16 } from "graphql-request";
@@ -4239,7 +4261,7 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
4239
4261
  throw new Error("No nfts found");
4240
4262
  }
4241
4263
  const nftsForTracking = [];
4242
- const tx = new Transaction11();
4264
+ const tx = new Transaction12();
4243
4265
  for (const nft of res.nfts) {
4244
4266
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
4245
4267
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -4276,11 +4298,11 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
4276
4298
  }
4277
4299
  });
4278
4300
  }
4279
- return Transaction11.from(tx);
4301
+ return Transaction12.from(tx);
4280
4302
  };
4281
4303
 
4282
4304
  // src/methods/claimNfts/claimNfts.ts
4283
- import { Transaction as Transaction12 } from "@mysten/sui/transactions";
4305
+ import { Transaction as Transaction13 } from "@mysten/sui/transactions";
4284
4306
 
4285
4307
  // src/methods/claimNfts/addClaimNftsTxs.ts
4286
4308
  var addClaimTradeHoldTx = ({
@@ -4489,7 +4511,7 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
4489
4511
  throw new Error("No nfts found");
4490
4512
  }
4491
4513
  const nftsForTracking = [];
4492
- const tx = existingTx ?? new Transaction12();
4514
+ const tx = existingTx ?? new Transaction13();
4493
4515
  const kiosksByOwnerRes = await gqlChainRequest({
4494
4516
  chain: "sui",
4495
4517
  query: fetchKiosksByOwner,
@@ -4628,11 +4650,11 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
4628
4650
  }
4629
4651
  }
4630
4652
  }
4631
- return Transaction12.from(tx);
4653
+ return Transaction13.from(tx);
4632
4654
  };
4633
4655
 
4634
4656
  // src/methods/createLongLocks/createLongLocks.ts
4635
- import { Transaction as Transaction13 } from "@mysten/sui/transactions";
4657
+ import { Transaction as Transaction14 } from "@mysten/sui/transactions";
4636
4658
 
4637
4659
  // src/graphql/queries/fetchActiveLockStateByNftId.ts
4638
4660
  import { gql as gql17 } from "graphql-request";
@@ -4663,7 +4685,7 @@ var getActiveLockStateByNftId = async (nftId) => {
4663
4685
  // src/methods/createLongLocks/createLongLocks.ts
4664
4686
  async function createLongLocks({ walletAddress, nfts }, context) {
4665
4687
  const expireIn = 7 * 24 * 3600 * 1e3;
4666
- const tx = new Transaction13();
4688
+ const tx = new Transaction14();
4667
4689
  for (const argNft of nfts) {
4668
4690
  const existingLock = await getActiveLockStateByNftId(argNft.id);
4669
4691
  if (existingLock) {
@@ -4722,11 +4744,77 @@ async function createLongLocks({ walletAddress, nfts }, context) {
4722
4744
  return tx;
4723
4745
  }
4724
4746
 
4747
+ // src/methods/createMultiBid/createMultiBid.ts
4748
+ import { Transaction as Transaction16 } from "@mysten/sui/transactions";
4749
+
4750
+ // src/methods/updateMultiBid/updateMultiBid.ts
4751
+ import { Transaction as Transaction15 } from "@mysten/sui/transactions";
4752
+ async function updateMultiBid({
4753
+ multiBidId,
4754
+ name,
4755
+ amount,
4756
+ amountToWithdraw,
4757
+ tx: existingTx,
4758
+ multiBidChainId
4759
+ }) {
4760
+ const tx = existingTx ?? new Transaction15();
4761
+ if (!multiBidChainId) {
4762
+ const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
4763
+ chain: "sui",
4764
+ query: fetchMultibidChainIdById,
4765
+ variables: { multiBidId }
4766
+ }))?.multi_bids?.[0] ?? {};
4767
+ if (!chainId) {
4768
+ throw new Error(`MultiBid ${multiBidId} not found`);
4769
+ }
4770
+ if (cancelled_at) {
4771
+ throw new Error(`MultiBid ${multiBidId} already cancelled`);
4772
+ }
4773
+ multiBidChainId = chainId;
4774
+ }
4775
+ const [coin] = tx.splitCoins(tx.gas, [amount ?? 0n]);
4776
+ tx.moveCall({
4777
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
4778
+ arguments: [
4779
+ tx.object(TRADEPORT_MULTI_BID_STORE),
4780
+ typeof multiBidChainId === "string" ? tx.pure.id(multiBidChainId) : multiBidChainId,
4781
+ tx.pure.option("string", name),
4782
+ coin,
4783
+ tx.pure.option("u64", amountToWithdraw)
4784
+ ]
4785
+ });
4786
+ return tx;
4787
+ }
4788
+
4789
+ // src/methods/createMultiBid/createMultiBid.ts
4790
+ async function createMultiBid({
4791
+ walletAddress,
4792
+ name,
4793
+ amount,
4794
+ tx: existingTx
4795
+ }) {
4796
+ const tx = existingTx ?? new Transaction16();
4797
+ const multiBidChainId = tx.moveCall({
4798
+ target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
4799
+ arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
4800
+ });
4801
+ if (amount > 0n) {
4802
+ await updateMultiBid({
4803
+ walletAddress,
4804
+ multiBidChainId,
4805
+ amount,
4806
+ name,
4807
+ tx
4808
+ });
4809
+ }
4810
+ return { multiBidChainId, tx };
4811
+ }
4812
+
4725
4813
  // src/methods/createShortLocks/createShortLocks.ts
4726
- import { Transaction as Transaction14 } from "@mysten/sui/transactions";
4814
+ import { Transaction as Transaction17 } from "@mysten/sui/transactions";
4727
4815
  async function createShortLocks({ nfts }, context) {
4728
4816
  const expireIn = 7 * 24 * 3600 * 1e3;
4729
- const tx = new Transaction14();
4817
+ const tx = new Transaction17();
4730
4818
  for (const argNft of nfts) {
4731
4819
  const premium = calculatePremium(BigInt(argNft.priceInMist));
4732
4820
  if (!argNft.type) {
@@ -4764,7 +4852,7 @@ async function createShortLocks({ nfts }, context) {
4764
4852
  }
4765
4853
 
4766
4854
  // src/methods/listNfts/listNfts.ts
4767
- import { Transaction as Transaction15 } from "@mysten/sui/transactions";
4855
+ import { Transaction as Transaction18 } from "@mysten/sui/transactions";
4768
4856
 
4769
4857
  // src/methods/listNfts/addListTxs.ts
4770
4858
  async function addOriginByteListTx({
@@ -5069,7 +5157,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5069
5157
  throw new Error("No nfts found");
5070
5158
  }
5071
5159
  const nftsForTracking = [];
5072
- const tx = new Transaction15();
5160
+ const tx = new Transaction18();
5073
5161
  for (const nft of res.nfts) {
5074
5162
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
5075
5163
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5113,11 +5201,11 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
5113
5201
  marketRelistedFrom: nft?.listings?.[0]?.market_name
5114
5202
  });
5115
5203
  }
5116
- return Transaction15.from(tx);
5204
+ return Transaction18.from(tx);
5117
5205
  };
5118
5206
 
5119
5207
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5120
- import { Transaction as Transaction16 } from "@mysten/sui/transactions";
5208
+ import { Transaction as Transaction19 } from "@mysten/sui/transactions";
5121
5209
 
5122
5210
  // src/graphql/queries/fetchNftsByKioskId.ts
5123
5211
  import { gql as gql18 } from "graphql-request";
@@ -5277,7 +5365,7 @@ function getTransferPolicyForDirectTransfer(collectionChainState) {
5277
5365
 
5278
5366
  // src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts
5279
5367
  async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 }, context) {
5280
- const tx = new Transaction16();
5368
+ const tx = new Transaction19();
5281
5369
  const res = await gqlChainRequest({
5282
5370
  chain: "sui",
5283
5371
  query: fetchKiosksByOwner,
@@ -5399,11 +5487,11 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress, max = 5 },
5399
5487
  });
5400
5488
  }
5401
5489
  }
5402
- return Transaction16.from(tx);
5490
+ return Transaction19.from(tx);
5403
5491
  }
5404
5492
 
5405
5493
  // src/methods/placeCollectionBids/placeCollectionBids.ts
5406
- import { Transaction as Transaction17 } from "@mysten/sui/transactions";
5494
+ import { Transaction as Transaction20 } from "@mysten/sui/transactions";
5407
5495
 
5408
5496
  // src/graphql/queries/fetchCollectionsById.ts
5409
5497
  import { gql as gql19 } from "graphql-request";
@@ -5597,14 +5685,7 @@ async function addOriginByteCollectionBidTx({
5597
5685
  }
5598
5686
 
5599
5687
  // src/methods/placeCollectionBids/placeCollectionBids.ts
5600
- var placeCollectionBids = async ({
5601
- collections,
5602
- walletAddress,
5603
- multiBidId,
5604
- multiBidChainId,
5605
- expireAt,
5606
- tx: existingTx
5607
- }, context) => {
5688
+ var placeCollectionBids = async ({ collections, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
5608
5689
  const res = await gqlChainRequest({
5609
5690
  chain: "sui",
5610
5691
  query: fetchCollectionsByIdWithOneNft,
@@ -5614,7 +5695,7 @@ var placeCollectionBids = async ({
5614
5695
  throw new Error("No collection found");
5615
5696
  }
5616
5697
  const collectionsForTracking = [];
5617
- const tx = existingTx ? Transaction17.from(existingTx) : new Transaction17();
5698
+ const tx = existingTx ? Transaction20.from(existingTx) : new Transaction20();
5618
5699
  for (const collection of res.collections) {
5619
5700
  const nftType = getNftType({
5620
5701
  collectionId: collection?.id,
@@ -5633,7 +5714,7 @@ var placeCollectionBids = async ({
5633
5714
  bidAmount: collections?.find((c) => c.id === collection?.id)?.bidAmountInMist,
5634
5715
  multiBidId,
5635
5716
  multiBidChainId,
5636
- expireAt
5717
+ expireAt: collections?.find((c) => c.id === collection?.id)?.expireAt
5637
5718
  };
5638
5719
  const numOfBids = collections?.find((c) => c.id === collection?.id)?.numOfBids;
5639
5720
  if (isOriginByteTx(txData?.sharedObjects) && !ORIGIN_BYTE_NFT_TYPES_MISSING_ORDERBOOK?.includes(normalizedNftType(txData?.nftType))) {
@@ -5659,23 +5740,24 @@ var placeCollectionBids = async ({
5659
5740
  bidder: walletAddress
5660
5741
  });
5661
5742
  }
5662
- return Transaction17.from(tx);
5743
+ return Transaction20.from(tx);
5663
5744
  };
5664
5745
 
5665
5746
  // src/methods/placeNftBids/placeNftBids.ts
5666
- import { Transaction as Transaction18 } from "@mysten/sui/transactions";
5667
- var placeNftBids = async ({ nfts, walletAddress, multiBidId, multiBidChainId, expireAt, tx: existingTx }, context) => {
5668
- const tx = existingTx ? Transaction18.from(existingTx) : new Transaction18();
5747
+ import { Transaction as Transaction21 } from "@mysten/sui/transactions";
5748
+ var placeNftBids = async ({ bids, walletAddress, multiBidId, multiBidChainId, tx: existingTx }, context) => {
5749
+ const tx = existingTx ? Transaction21.from(existingTx) : new Transaction21();
5669
5750
  const res = await gqlChainRequest({
5670
5751
  chain: "sui",
5671
5752
  query: fetchNftsById,
5672
- variables: { nftIds: nfts.map((nft) => nft.id) }
5753
+ variables: { nftIds: bids.map((bid) => bid.nftId) }
5673
5754
  });
5674
5755
  if (res?.nfts?.length === 0) {
5675
5756
  throw new Error("No nfts found");
5676
5757
  }
5677
5758
  const nftsForTracking = [];
5678
- for (const nft of res.nfts) {
5759
+ for (const bid of bids) {
5760
+ const nft = res.nfts?.find((nft2) => nft2.id === bid.nftId);
5679
5761
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
5680
5762
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
5681
5763
  }
@@ -5693,25 +5775,25 @@ var placeNftBids = async ({ nfts, walletAddress, multiBidId, multiBidChainId, ex
5693
5775
  collectionId: nft?.collection_id,
5694
5776
  nftTokenId: nft?.token_id,
5695
5777
  nftType,
5696
- bidAmount: BigInt(nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist ?? 0n),
5778
+ bidAmount: BigInt(bid?.bidAmountInMist ?? 0n),
5697
5779
  bcsHex: nft.chain_state?.bcs?.bcsHex,
5698
5780
  multiBidId,
5699
5781
  multiBidChainId,
5700
- expireAt
5782
+ expireAt: bid?.expireAt
5701
5783
  };
5702
5784
  await addTradePortPlaceNftBidTxHandler(txData);
5703
5785
  nftsForTracking.push({
5704
5786
  nftType,
5705
5787
  collectionId: nft?.collection_id,
5706
- bidAmount: nfts?.find((n) => n.id === nft?.id)?.bidAmountInMist,
5788
+ bidAmount: bid?.bidAmountInMist,
5707
5789
  bidder: walletAddress
5708
5790
  });
5709
5791
  }
5710
- return Transaction18.from(tx);
5792
+ return Transaction21.from(tx);
5711
5793
  };
5712
5794
 
5713
5795
  // src/methods/removeCollectionBids/removeCollectionBids.ts
5714
- import { Transaction as Transaction19 } from "@mysten/sui/transactions";
5796
+ import { Transaction as Transaction22 } from "@mysten/sui/transactions";
5715
5797
 
5716
5798
  // src/methods/removeNftBids/addRemoveNftBidTxs.ts
5717
5799
  function addTradeportRemoveNftBidTx({ tx, bidNonce, nftType }) {
@@ -5891,7 +5973,7 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
5891
5973
  throw new Error("No bids found");
5892
5974
  }
5893
5975
  const bidsForTracking = [];
5894
- const tx = existingTx ? Transaction19.from(existingTx) : new Transaction19();
5976
+ const tx = existingTx ? Transaction22.from(existingTx) : new Transaction22();
5895
5977
  for (const bid of res.bids) {
5896
5978
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
5897
5979
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5938,11 +6020,11 @@ var removeCollectionBids = async ({ bidIds, tx: existingTx }, context) => {
5938
6020
  bidder: bid?.bidder
5939
6021
  });
5940
6022
  }
5941
- return Transaction19.from(tx);
6023
+ return Transaction22.from(tx);
5942
6024
  };
5943
6025
 
5944
6026
  // src/methods/removeNftBids/removeNftBids.ts
5945
- import { Transaction as Transaction20 } from "@mysten/sui/transactions";
6027
+ import { Transaction as Transaction23 } from "@mysten/sui/transactions";
5946
6028
  var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
5947
6029
  const res = await gqlChainRequest({
5948
6030
  chain: "sui",
@@ -5953,7 +6035,7 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
5953
6035
  throw new Error("No bids found");
5954
6036
  }
5955
6037
  const bidsForTracking = [];
5956
- const tx = existingTx ? Transaction20.from(existingTx) : new Transaction20();
6038
+ const tx = existingTx ? Transaction23.from(existingTx) : new Transaction23();
5957
6039
  for (const bid of res.bids) {
5958
6040
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(bid?.nft?.token_id)) {
5959
6041
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -5998,11 +6080,11 @@ var removeNftBids = async ({ bidIds, tx: existingTx }, context) => {
5998
6080
  bidder: bid?.bidder
5999
6081
  });
6000
6082
  }
6001
- return Transaction20.from(tx);
6083
+ return Transaction23.from(tx);
6002
6084
  };
6003
6085
 
6004
6086
  // src/methods/transferNfts/transferNfts.ts
6005
- import { Transaction as Transaction21 } from "@mysten/sui/transactions";
6087
+ import { Transaction as Transaction24 } from "@mysten/sui/transactions";
6006
6088
 
6007
6089
  // src/helpers/rpc/getAcountBalance.ts
6008
6090
  var getAccountBalance = async ({ suiClient, owner }) => {
@@ -6038,7 +6120,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6038
6120
  }
6039
6121
  const nftsForTracking = [];
6040
6122
  const nftsToTransferDirectly = [];
6041
- const tx = new Transaction21();
6123
+ const tx = new Transaction24();
6042
6124
  for (const nft of res.nfts) {
6043
6125
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(nft?.token_id)) {
6044
6126
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6098,11 +6180,11 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
6098
6180
  { tx, kioskClient: context.kioskClient, senderAddress: walletAddress, recipientAddress },
6099
6181
  nftsToTransferDirectly
6100
6182
  );
6101
- return Transaction21.from(tx);
6183
+ return Transaction24.from(tx);
6102
6184
  };
6103
6185
 
6104
6186
  // src/methods/unlistListings/unlistListings.ts
6105
- import { Transaction as Transaction22 } from "@mysten/sui/transactions";
6187
+ import { Transaction as Transaction25 } from "@mysten/sui/transactions";
6106
6188
  var unlistListings = async ({ listingIds, walletAddress }, context) => {
6107
6189
  const res = await gqlChainRequest({
6108
6190
  chain: "sui",
@@ -6113,7 +6195,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6113
6195
  throw new Error("No listings found");
6114
6196
  }
6115
6197
  const listingsForTracking = [];
6116
- const tx = new Transaction22();
6198
+ const tx = new Transaction25();
6117
6199
  for (const listing of res.listings) {
6118
6200
  if (DELOREAN_TOKEN_IDS_TO_DISABLE?.includes(listing?.nft?.token_id)) {
6119
6201
  throw new Error(DELOREAN_TOKEN_IDS_TO_DISABLE_MESSAGE);
@@ -6177,12 +6259,12 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
6177
6259
  marketName: listing?.market_name
6178
6260
  });
6179
6261
  }
6180
- return Transaction22.from(tx);
6262
+ return Transaction25.from(tx);
6181
6263
  };
6182
6264
 
6183
6265
  // src/methods/withdrawProfitsFromKiosks/withdrawProfitsFromKiosks.ts
6184
6266
  import { KioskTransaction as KioskTransaction2 } from "@mysten/kiosk";
6185
- import { Transaction as Transaction23 } from "@mysten/sui/transactions";
6267
+ import { Transaction as Transaction26 } from "@mysten/sui/transactions";
6186
6268
  async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6187
6269
  const res = await gqlChainRequest({
6188
6270
  chain: "sui",
@@ -6199,7 +6281,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6199
6281
  if (kiosksWithProfit.length === 0) {
6200
6282
  throw new Error(`No kiosks with profit to withdraw found for ${walletAddress}`);
6201
6283
  }
6202
- const tx = new Transaction23();
6284
+ const tx = new Transaction26();
6203
6285
  try {
6204
6286
  for (const kiosk of kiosksWithProfit) {
6205
6287
  let kioskTx;
@@ -6245,95 +6327,7 @@ async function withdrawProfitsFromKiosks({ walletAddress }, context) {
6245
6327
  } catch (err) {
6246
6328
  console.log("err", err);
6247
6329
  }
6248
- return Transaction23.from(tx);
6249
- }
6250
-
6251
- // src/methods/createMultiBid/createMultiBid.ts
6252
- import { Transaction as Transaction25 } from "@mysten/sui/transactions";
6253
-
6254
- // src/methods/updateMultiBid/updateMultiBid.ts
6255
- import { Transaction as Transaction24 } from "@mysten/sui/transactions";
6256
- async function updateMultiBid({
6257
- multiBidId,
6258
- name,
6259
- amount,
6260
- amountToWithdraw,
6261
- tx: existingTx,
6262
- multiBidChainId
6263
- }) {
6264
- const tx = existingTx ?? new Transaction24();
6265
- if (!multiBidChainId) {
6266
- const { chain_id: chainId, cancelled_at } = (await gqlChainRequest({
6267
- chain: "sui",
6268
- query: fetchMultibidChainIdById,
6269
- variables: { multiBidId }
6270
- }))?.multi_bids?.[0] ?? {};
6271
- if (!chainId) {
6272
- throw new Error(`MultiBid ${multiBidId} not found`);
6273
- }
6274
- if (cancelled_at) {
6275
- throw new Error(`MultiBid ${multiBidId} already cancelled`);
6276
- }
6277
- multiBidChainId = chainId;
6278
- }
6279
- const [coin] = tx.splitCoins(tx.gas, [amount ?? 0n]);
6280
- tx.moveCall({
6281
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::update_multi_bid`,
6282
- arguments: [
6283
- tx.object(TRADEPORT_MULTI_BID_STORE),
6284
- typeof multiBidChainId === "string" ? tx.pure.id(multiBidChainId) : multiBidChainId,
6285
- tx.pure.option("string", name),
6286
- coin,
6287
- tx.pure.option("u64", amountToWithdraw)
6288
- ]
6289
- });
6290
- return tx;
6291
- }
6292
-
6293
- // src/methods/createMultiBid/createMultiBid.ts
6294
- async function createMultiBid({
6295
- walletAddress,
6296
- name,
6297
- amount,
6298
- tx: existingTx
6299
- }) {
6300
- const tx = existingTx ?? new Transaction25();
6301
- const multiBidChainId = tx.moveCall({
6302
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::create_multi_bid`,
6303
- arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.option("string", name)]
6304
- });
6305
- if (amount > 0n) {
6306
- await updateMultiBid({
6307
- walletAddress,
6308
- multiBidChainId,
6309
- amount,
6310
- name,
6311
- tx
6312
- });
6313
- }
6314
- return { multiBidChainId, tx };
6315
- }
6316
-
6317
- // src/methods/cancelMultiBid/cancelMultiBid.ts
6318
- import { Transaction as Transaction26 } from "@mysten/sui/transactions";
6319
- async function cancelMultiBid({ multiBidId }) {
6320
- const { chain_id: multiBidChainId, cancelled_at } = (await gqlChainRequest({
6321
- chain: "sui",
6322
- query: fetchMultibidChainIdById,
6323
- variables: { multiBidId }
6324
- }))?.multi_bids?.[0] ?? {};
6325
- if (!multiBidChainId) {
6326
- throw new Error(`MultiBid ${multiBidId} not found`);
6327
- }
6328
- if (cancelled_at) {
6329
- throw new Error(`MultiBid ${multiBidId} already cancelled`);
6330
- }
6331
- const tx = new Transaction26();
6332
- tx.moveCall({
6333
- target: `${TRADEPORT_MULTI_BID_PACKAGE}::tradeport_biddings::cancel_multi_bid`,
6334
- arguments: [tx.object(TRADEPORT_MULTI_BID_STORE), tx.pure.id(multiBidChainId)]
6335
- });
6336
- return tx;
6330
+ return Transaction26.from(tx);
6337
6331
  }
6338
6332
 
6339
6333
  // src/SuiTradingClient.ts
@@ -6413,7 +6407,8 @@ var SuiTradingClient = class {
6413
6407
  walletAddress,
6414
6408
  multiBidId,
6415
6409
  multiBidChainId,
6416
- expireAt
6410
+ expireAt,
6411
+ tx
6417
6412
  }) {
6418
6413
  const context = {
6419
6414
  apiUser: this.apiUser,
@@ -6427,13 +6422,14 @@ var SuiTradingClient = class {
6427
6422
  {
6428
6423
  id: collectionId,
6429
6424
  bidAmountInMist,
6430
- numOfBids
6425
+ numOfBids,
6426
+ expireAt
6431
6427
  }
6432
6428
  ],
6433
6429
  walletAddress,
6434
6430
  multiBidId,
6435
6431
  multiBidChainId,
6436
- expireAt
6432
+ tx
6437
6433
  },
6438
6434
  context
6439
6435
  );