@tradeport/sui-trading-sdk 0.1.80 → 0.1.81

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.js +38 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +38 -0
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +1 -1
  7. package/src/graphql/queries/fetchBidsById.ts +1 -0
  8. package/src/graphql/queries/fetchListingsById.ts +1 -0
  9. package/src/graphql/queries/fetchNftsById.ts +3 -0
  10. package/src/graphql/queries/fetchNftsByKioskId.ts +1 -0
  11. package/src/helpers/getNftType.ts +7 -0
  12. package/src/helpers/rpc/getObjectType.ts +2 -0
  13. package/src/methods/acceptCollectionBid/acceptCollectionBid.ts +3 -0
  14. package/src/methods/acceptCollectionBid/addAcceptCollectionBIdTxs.ts +6 -0
  15. package/src/methods/acceptNftBids/acceptNftBids.ts +1 -0
  16. package/src/methods/acceptNftBids/addAcceptNftBidTxs.ts +6 -0
  17. package/src/methods/buyListings/buyListings.ts +1 -0
  18. package/src/methods/cancelNftTransfers/cancelNftTransfers.ts +1 -0
  19. package/src/methods/claimNfts/claimNfts.ts +1 -0
  20. package/src/methods/createLongLocks/createLongLocks.ts +1 -0
  21. package/src/methods/listNfts/listNfts.ts +1 -0
  22. package/src/methods/migrateNftsFromUnsharedToSharedKiosks/migrateNftsFromUnsharedToSharedKiosks.ts +2 -0
  23. package/src/methods/placeCollectionBids/placeCollectionBids.ts +1 -0
  24. package/src/methods/placeNftBids/placeNftBids.ts +1 -0
  25. package/src/methods/relistNft/relistNft.ts +1 -0
  26. package/src/methods/removeCollectionBid/addRemoveCollectionBidTxs.ts +2 -0
  27. package/src/methods/removeCollectionBid/removeCollectionBid.ts +3 -0
  28. package/src/methods/removeNftBids/removeNftBids.ts +1 -0
  29. package/src/methods/transferNfts/transferNfts.ts +1 -0
  30. package/src/methods/unlistListings/unlistListings.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.1.81
4
+
5
+ ### Patch Changes
6
+
7
+ - 7661409: Fix Dungeon Move by using nft type from nft properties
8
+
3
9
  ## 0.1.80
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -151,6 +151,7 @@ var fetchNftById = import_graphql_request5.gql`
151
151
  market_name
152
152
  }
153
153
  collection {
154
+ id
154
155
  chain_state
155
156
  }
156
157
  }
@@ -170,6 +171,7 @@ var fetchNftsById = import_graphql_request5.gql`
170
171
  properties
171
172
  }
172
173
  collection {
174
+ id
173
175
  chain_state
174
176
  }
175
177
  }
@@ -194,6 +196,7 @@ var fetchNftsWithListingsById = import_graphql_request5.gql`
194
196
  nonce
195
197
  }
196
198
  collection {
199
+ id
197
200
  chain_state
198
201
  }
199
202
  }
@@ -202,9 +205,13 @@ var fetchNftsWithListingsById = import_graphql_request5.gql`
202
205
 
203
206
  // src/helpers/getNftType.ts
204
207
  var getNftType = ({
208
+ collectionId,
205
209
  collectionChainState,
206
210
  nft
207
211
  }) => {
212
+ if (collectionId === "a6fabb11-4713-4203-bce8-a3c4f673b5a7") {
213
+ return nft?.properties?.nft_type;
214
+ }
208
215
  if (collectionChainState?.nft_type)
209
216
  return collectionChainState.nft_type;
210
217
  let nftType = nft?.properties?.nft_type;
@@ -701,8 +708,10 @@ var getObjectType = async ({
701
708
  }) => {
702
709
  try {
703
710
  const res = await suiClient.getObject({ id: objectId, options: { showType: true } });
711
+ console.log("res", res);
704
712
  return res?.data?.type;
705
713
  } catch (err) {
714
+ console.log("err", err);
706
715
  return "";
707
716
  }
708
717
  };
@@ -1008,6 +1017,7 @@ async function addTradeportKioskAcceptNftBidTx({
1008
1017
  beforeResolveKioskTransferRequest
1009
1018
  }) {
1010
1019
  const transferPolicyId = (await getKioskTransferPolicies(nftType))?.at(0)?.id;
1020
+ console.log("transferPolicyId", transferPolicyId);
1011
1021
  if (beforeResolveKioskTransferRequest) {
1012
1022
  const [feeCoin, transferRequest] = tx.moveCall({
1013
1023
  target: "0x6468e232af988cd8be608b1901863f0d7dbaa16764c1834daa39b023cb3b2fc8::kiosk_biddings::accept_bid_with_price_lock",
@@ -1044,6 +1054,7 @@ async function addTradeportKioskAcceptNftBidTx({
1044
1054
  ],
1045
1055
  typeArguments: [nftType]
1046
1056
  });
1057
+ console.log("1");
1047
1058
  if (!shouldSplitRoyaltyFromUserGasCoins) {
1048
1059
  tx.moveCall({
1049
1060
  target: `${royaltyRulePackageId}::${royaltyRuleModule}::pay`,
@@ -1061,6 +1072,7 @@ async function addTradeportKioskAcceptNftBidTx({
1061
1072
  shouldSkipKioskLocking: true,
1062
1073
  shouldSkipResolvingRoyaltyRule: !shouldSplitRoyaltyFromUserGasCoins
1063
1074
  });
1075
+ console.log("2");
1064
1076
  if (shouldSplitRoyaltyFromUserGasCoins) {
1065
1077
  tx.transferObjects([tx.object(feeCoin)], tx.pure.address(addLeadingZerosAfter0x(seller)));
1066
1078
  }
@@ -1597,7 +1609,9 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
1597
1609
  }
1598
1610
  });
1599
1611
  }
1612
+ console.log("bidType", bidType);
1600
1613
  if (isTradePortKioskBid(bidType)) {
1614
+ console.log("1");
1601
1615
  if (txData?.sellerKiosk) {
1602
1616
  const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
1603
1617
  const royaltyRulePackageId = await getRulePackageId({
@@ -1605,6 +1619,7 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
1605
1619
  ruleType: "royalty_rule",
1606
1620
  kioskClient: txData?.kioskClient
1607
1621
  });
1622
+ console.log("2");
1608
1623
  return kioskTxWrapper({
1609
1624
  tx: txData?.tx,
1610
1625
  kioskClient: txData?.kioskClient,
@@ -1732,6 +1747,7 @@ var acceptCollectionBid = async ({
1732
1747
  const bidsForTracking = [];
1733
1748
  const tx = existingTx ?? new import_transactions.Transaction();
1734
1749
  const nftType = getNftType({
1750
+ collectionId: nft?.collection_id,
1735
1751
  collectionChainState: nft?.collection?.chain_state,
1736
1752
  nft
1737
1753
  });
@@ -1758,6 +1774,7 @@ var acceptCollectionBid = async ({
1758
1774
  shouldSplitRoyaltyFromUserGasCoins,
1759
1775
  beforeResolveKioskTransferRequest
1760
1776
  };
1777
+ console.log("txData", txData);
1761
1778
  switch (txData.bidMarketName) {
1762
1779
  case "tradeport":
1763
1780
  if (txData?.listingPrice && txData?.listingPrice > 0) {
@@ -1826,6 +1843,7 @@ var fetchBidsById = import_graphql_request12.gql`
1826
1843
  name
1827
1844
  }
1828
1845
  collection {
1846
+ id
1829
1847
  chain_state
1830
1848
  }
1831
1849
  }
@@ -1853,6 +1871,7 @@ var acceptNftBids = async ({ bidIds, tx: existingTx, kioskTx, beforeResolveKiosk
1853
1871
  throw new Error("Bid is not an individual item bid. Use acceptCollectionBid() instead.");
1854
1872
  }
1855
1873
  const nftType = getNftType({
1874
+ collectionId: bid?.collection?.id,
1856
1875
  collectionChainState: bid?.collection?.chain_state,
1857
1876
  nft: bid?.nft
1858
1877
  });
@@ -2242,6 +2261,7 @@ var fetchListingsById = import_graphql_request14.gql`
2242
2261
  }
2243
2262
  }
2244
2263
  collection {
2264
+ id
2245
2265
  chain_state
2246
2266
  }
2247
2267
  }
@@ -2777,6 +2797,7 @@ var buyListings = async ({
2777
2797
  throw new Error(`Listing ${listing?.id} is not listed`);
2778
2798
  }
2779
2799
  const nftType = getNftType({
2800
+ collectionId: listing?.collection?.id,
2780
2801
  collectionChainState: listing?.collection?.chain_state,
2781
2802
  nft: listing?.nft
2782
2803
  });
@@ -3093,6 +3114,7 @@ var cancelNftTransfers = async ({ nftIds, walletAddress }, context) => {
3093
3114
  throw new Error("Cannot cancel transfer of NFT that is not currently transferring");
3094
3115
  }
3095
3116
  const nftType = getNftType({
3117
+ collectionId: nft?.collection?.id,
3096
3118
  collectionChainState: nft?.collection?.chain_state,
3097
3119
  nft
3098
3120
  });
@@ -3301,6 +3323,7 @@ var claimNfts = async ({ nftIds, walletAddress, tx: existingTx }, context, useOl
3301
3323
  throw new Error(`Nft ID: ${nft?.id} is not claimable`);
3302
3324
  }
3303
3325
  const nftType = getNftType({
3326
+ collectionId: nft?.collection?.id,
3304
3327
  collectionChainState: nft?.collection?.chain_state,
3305
3328
  nft
3306
3329
  });
@@ -3498,6 +3521,7 @@ async function createLongLocks({ walletAddress, nfts }, context) {
3498
3521
  variables: { nftId: argNft.id }
3499
3522
  }))?.nfts?.[0];
3500
3523
  const nftType = getNftType({
3524
+ collectionId: nft?.collection?.id,
3501
3525
  collectionChainState: nft?.collection?.chain_state,
3502
3526
  nft
3503
3527
  });
@@ -3800,6 +3824,7 @@ async function relistNft({
3800
3824
  sharedObjects,
3801
3825
  nftTokenId: nft?.token_id,
3802
3826
  nftType: getNftType({
3827
+ collectionId: nft?.collection?.id,
3803
3828
  collectionChainState: nft?.collection?.chain_state,
3804
3829
  nft
3805
3830
  }),
@@ -3889,6 +3914,7 @@ var listNfts = async ({ nfts, walletAddress }, context) => {
3889
3914
  const tx = new import_transactions14.Transaction();
3890
3915
  for (const nft of res.nfts) {
3891
3916
  const nftType = getNftType({
3917
+ collectionId: nft?.collection?.id,
3892
3918
  collectionChainState: nft?.collection?.chain_state,
3893
3919
  nft
3894
3920
  });
@@ -3949,6 +3975,7 @@ var fetchNftsByKioskId = import_graphql_request18.gql`
3949
3975
  properties
3950
3976
  }
3951
3977
  collection {
3978
+ id
3952
3979
  chain_state
3953
3980
  }
3954
3981
  }
@@ -4039,6 +4066,7 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress }, context)
4039
4066
  continue;
4040
4067
  }
4041
4068
  const nftType = getNftType({
4069
+ collectionId: nft?.collection?.id,
4042
4070
  collectionChainState: nft?.collection?.chain_state,
4043
4071
  nft
4044
4072
  });
@@ -4079,6 +4107,7 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress }, context)
4079
4107
  continue;
4080
4108
  }
4081
4109
  const nftType = getNftType({
4110
+ collectionId: nft?.collection?.id,
4082
4111
  collectionChainState: nft?.collection?.chain_state,
4083
4112
  nft
4084
4113
  });
@@ -4349,6 +4378,7 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
4349
4378
  const tx = new import_transactions16.Transaction();
4350
4379
  for (const collection of res.collections) {
4351
4380
  const nftType = getNftType({
4381
+ collectionId: collection?.id,
4352
4382
  collectionChainState: collection?.chain_state,
4353
4383
  nft: collection?.nfts?.[0]
4354
4384
  });
@@ -4491,6 +4521,7 @@ var placeNftBids = async ({ nfts, walletAddress }, context) => {
4491
4521
  const tx = new import_transactions17.Transaction();
4492
4522
  for (const nft of res.nfts) {
4493
4523
  const nftType = getNftType({
4524
+ collectionId: nft?.collection_id,
4494
4525
  collectionChainState: nft?.collection?.chain_state,
4495
4526
  nft
4496
4527
  });
@@ -4635,6 +4666,7 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
4635
4666
  suiClient: txData?.suiClient,
4636
4667
  objectId: txData?.bidNonce
4637
4668
  });
4669
+ console.log("bidType", bidType);
4638
4670
  if (isOriginByteBid(bidType)) {
4639
4671
  addOriginByteRemoveCollectionBidTx(txData);
4640
4672
  return;
@@ -4680,6 +4712,7 @@ var removeCollectionBid = async ({ bidId }, context) => {
4680
4712
  variables: { collectionIds: [bid?.collection_id] }
4681
4713
  });
4682
4714
  const nftType = getNftType({
4715
+ collectionId: collectionWithOneNftRes?.collections?.[0]?.id,
4683
4716
  collectionChainState: collectionWithOneNftRes?.collections?.[0]?.chain_state,
4684
4717
  nft: collectionWithOneNftRes?.collections?.[0]?.nfts?.[0]
4685
4718
  });
@@ -4696,6 +4729,7 @@ var removeCollectionBid = async ({ bidId }, context) => {
4696
4729
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
4697
4730
  bidMarketName: bid?.market_contract?.name
4698
4731
  };
4732
+ console.log("txData", txData);
4699
4733
  switch (txData.bidMarketName) {
4700
4734
  case "tradeport":
4701
4735
  await addTradePortRemoveCollectionBidTxHandler(txData);
@@ -4735,6 +4769,7 @@ var removeNftBids = async ({ bidIds }, context) => {
4735
4769
  const tx = new import_transactions19.Transaction();
4736
4770
  for (const bid of res.bids) {
4737
4771
  const nftType = getNftType({
4772
+ collectionId: bid?.collection?.id,
4738
4773
  collectionChainState: bid?.collection?.chain_state,
4739
4774
  nft: bid?.nft
4740
4775
  });
@@ -4857,6 +4892,7 @@ var transferNfts = async ({ nftIds, recipientAddress, walletAddress }, context)
4857
4892
  throw new Error("Cannot transfer a listed NFT");
4858
4893
  }
4859
4894
  const nftType = getNftType({
4895
+ collectionId: nft?.collection?.id,
4860
4896
  collectionChainState: nft?.collection?.chain_state,
4861
4897
  nft
4862
4898
  });
@@ -4923,6 +4959,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
4923
4959
  throw new Error(`Listing ${listing?.id} is not listed`);
4924
4960
  }
4925
4961
  const nftType = getNftType({
4962
+ collectionId: listing?.collection?.id,
4926
4963
  collectionChainState: listing?.collection?.chain_state,
4927
4964
  nft: listing?.nft
4928
4965
  });
@@ -4940,6 +4977,7 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
4940
4977
  collectionId: listing?.nft?.collection_id,
4941
4978
  seller: walletAddress
4942
4979
  };
4980
+ console.log("txData", txData);
4943
4981
  switch (listing?.market_name) {
4944
4982
  case "tradeport":
4945
4983
  await addTradePortUnlistTxHandler(txData);