@tradeport/sui-trading-sdk 0.1.81 → 0.1.83

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,18 @@
1
1
  # @tradeport/sui-trading-sdk
2
2
 
3
+ ## 0.1.83
4
+
5
+ ### Patch Changes
6
+
7
+ - 6d0fdea: Fixed locking items in kiosks in accept collection bid
8
+
9
+ ## 0.1.82
10
+
11
+ ### Patch Changes
12
+
13
+ - 506f1f9: Converts kiosks to personal kiosks in accept bids if has personal kiosk rule
14
+ - 5e654f0: Converts kiosks to personal kiosks in accept bids if has personal kiosk rule
15
+
3
16
  ## 0.1.81
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -402,6 +402,14 @@ var getKioskTransferPolicies = async (nftType) => {
402
402
  return transferPolicies;
403
403
  };
404
404
 
405
+ // src/helpers/hasPersonalKioskRule.ts
406
+ var hasPersonalKioskRule = async (nftType) => {
407
+ const transferPolicies = await getKioskTransferPolicies(nftType);
408
+ return transferPolicies?.some(
409
+ (policy) => policy?.rules?.filter((rule) => rule?.type?.includes("personal_kiosk_rule"))?.length > 0
410
+ );
411
+ };
412
+
405
413
  // src/helpers/hasTransferPolicyRules.ts
406
414
  var hasTransferPolicyRules = async (nftType) => {
407
415
  const transferPolicies = await getKioskTransferPolicies(nftType);
@@ -716,6 +724,36 @@ var getObjectType = async ({
716
724
  }
717
725
  };
718
726
 
727
+ // src/helpers/kiosk/lockNftInsideKioskIfNotLocked.ts
728
+ var lockNftInsideKioskIfNotLocked = async ({
729
+ tx,
730
+ kioskClient,
731
+ kioskTx,
732
+ sellerKiosk,
733
+ nftTokenId,
734
+ nftType,
735
+ transferPolicyId
736
+ }) => {
737
+ const res = await kioskClient.getKiosk({ id: sellerKiosk });
738
+ const isLocked = res?.items?.find((i) => i.objectId === nftTokenId)?.isLocked;
739
+ if (!isLocked) {
740
+ const item = kioskTx.take({
741
+ itemId: nftTokenId,
742
+ itemType: nftType
743
+ });
744
+ tx.moveCall({
745
+ target: "0x2::kiosk::lock",
746
+ typeArguments: [nftType],
747
+ arguments: [
748
+ tx.object(kioskTx.kiosk.value ?? kioskTx.kiosk),
749
+ tx.object(kioskTx.kioskCap.value ?? kioskTx.kioskCap),
750
+ tx.object(transferPolicyId),
751
+ tx.object(item)
752
+ ]
753
+ });
754
+ }
755
+ };
756
+
719
757
  // src/helpers/kiosk/resolveTransferPolicies.ts
720
758
  var import_kiosk4 = require("@mysten/kiosk");
721
759
 
@@ -964,11 +1002,6 @@ var getOBBidderKiosk = async ({
964
1002
  return bidObject.data?.content?.fields?.kiosk;
965
1003
  };
966
1004
 
967
- // src/utils/printTxBlockTxs.ts
968
- var printTxBlockTxs = async (tx) => {
969
- console.log(JSON.stringify(tx?.getData(), null, 2));
970
- };
971
-
972
1005
  // src/methods/acceptNftBids/addAcceptNftBidTxs.ts
973
1006
  function addTradeportAcceptNftBidTx({
974
1007
  tx,
@@ -1013,11 +1046,11 @@ async function addTradeportKioskAcceptNftBidTx({
1013
1046
  royaltyRulePackageId,
1014
1047
  royaltyRuleModule,
1015
1048
  bidAmount,
1049
+ sellerKiosk,
1016
1050
  shouldSplitRoyaltyFromUserGasCoins,
1017
1051
  beforeResolveKioskTransferRequest
1018
1052
  }) {
1019
1053
  const transferPolicyId = (await getKioskTransferPolicies(nftType))?.at(0)?.id;
1020
- console.log("transferPolicyId", transferPolicyId);
1021
1054
  if (beforeResolveKioskTransferRequest) {
1022
1055
  const [feeCoin, transferRequest] = tx.moveCall({
1023
1056
  target: "0x6468e232af988cd8be608b1901863f0d7dbaa16764c1834daa39b023cb3b2fc8::kiosk_biddings::accept_bid_with_price_lock",
@@ -1043,6 +1076,15 @@ async function addTradeportKioskAcceptNftBidTx({
1043
1076
  });
1044
1077
  tx.transferObjects([tx.object(feeCoin)], tx.pure.address(addLeadingZerosAfter0x(seller)));
1045
1078
  } else {
1079
+ await lockNftInsideKioskIfNotLocked({
1080
+ tx,
1081
+ kioskClient,
1082
+ kioskTx,
1083
+ sellerKiosk,
1084
+ nftTokenId,
1085
+ nftType,
1086
+ transferPolicyId
1087
+ });
1046
1088
  const [feeCoin, transferRequest] = tx.moveCall({
1047
1089
  target: "0xf527efa4c02d079f15389fb596b04688cd5767948d953942e494ff455f11aa7b::kiosk_biddings::accept_bid_with_purchase_cap",
1048
1090
  arguments: [
@@ -1054,7 +1096,6 @@ async function addTradeportKioskAcceptNftBidTx({
1054
1096
  ],
1055
1097
  typeArguments: [nftType]
1056
1098
  });
1057
- console.log("1");
1058
1099
  if (!shouldSplitRoyaltyFromUserGasCoins) {
1059
1100
  tx.moveCall({
1060
1101
  target: `${royaltyRulePackageId}::${royaltyRuleModule}::pay`,
@@ -1072,11 +1113,9 @@ async function addTradeportKioskAcceptNftBidTx({
1072
1113
  shouldSkipKioskLocking: true,
1073
1114
  shouldSkipResolvingRoyaltyRule: !shouldSplitRoyaltyFromUserGasCoins
1074
1115
  });
1075
- console.log("2");
1076
1116
  if (shouldSplitRoyaltyFromUserGasCoins) {
1077
1117
  tx.transferObjects([tx.object(feeCoin)], tx.pure.address(addLeadingZerosAfter0x(seller)));
1078
1118
  }
1079
- await printTxBlockTxs(tx);
1080
1119
  }
1081
1120
  }
1082
1121
  async function addOriginByteAcceptNftBidTx({
@@ -1170,6 +1209,7 @@ async function addTradePortAcceptNftBidTxHandler(txData) {
1170
1209
  kioskTx: txData?.kioskTx,
1171
1210
  kioskOwner: txData?.itemOwner,
1172
1211
  kiosk: txData?.sellerKiosk,
1212
+ shouldConvertToPersonalKiosk: Boolean(await hasPersonalKioskRule(txData?.nftType)),
1173
1213
  shouldAssertNftInSharedKiosk: true,
1174
1214
  async runCommands(kioskTx) {
1175
1215
  await addTradeportKioskAcceptNftBidTx({
@@ -1609,9 +1649,7 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
1609
1649
  }
1610
1650
  });
1611
1651
  }
1612
- console.log("bidType", bidType);
1613
1652
  if (isTradePortKioskBid(bidType)) {
1614
- console.log("1");
1615
1653
  if (txData?.sellerKiosk) {
1616
1654
  const royaltyRuleModule = getRoyaltyRuleModule(txData?.nftType);
1617
1655
  const royaltyRulePackageId = await getRulePackageId({
@@ -1619,13 +1657,13 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
1619
1657
  ruleType: "royalty_rule",
1620
1658
  kioskClient: txData?.kioskClient
1621
1659
  });
1622
- console.log("2");
1623
1660
  return kioskTxWrapper({
1624
1661
  tx: txData?.tx,
1625
1662
  kioskClient: txData?.kioskClient,
1626
1663
  kioskTx: txData?.kioskTx,
1627
1664
  kioskOwner: txData?.itemOwner,
1628
1665
  kiosk: txData?.sellerKiosk,
1666
+ shouldConvertToPersonalKiosk: Boolean(await hasPersonalKioskRule(txData?.nftType)),
1629
1667
  shouldAssertNftInSharedKiosk: true,
1630
1668
  async runCommands(kioskTx) {
1631
1669
  await addTradeportKioskAcceptCollectionBidTx({
@@ -1650,6 +1688,7 @@ async function addTradePortAcceptCollectionBidTxHandler(txData) {
1650
1688
  kioskTx: txData?.kioskTx,
1651
1689
  kioskOwner: txData?.seller,
1652
1690
  kiosk: txData?.sellerKiosk,
1691
+ shouldConvertToPersonalKiosk: Boolean(await hasPersonalKioskRule(txData?.nftType)),
1653
1692
  async runCommands(kioskTx) {
1654
1693
  kioskTx.place({
1655
1694
  item: txData?.nftTokenId,
@@ -1774,7 +1813,6 @@ var acceptCollectionBid = async ({
1774
1813
  shouldSplitRoyaltyFromUserGasCoins,
1775
1814
  beforeResolveKioskTransferRequest
1776
1815
  };
1777
- console.log("txData", txData);
1778
1816
  switch (txData.bidMarketName) {
1779
1817
  case "tradeport":
1780
1818
  if (txData?.listingPrice && txData?.listingPrice > 0) {
@@ -4666,7 +4704,6 @@ async function addTradePortRemoveCollectionBidTxHandler(txData) {
4666
4704
  suiClient: txData?.suiClient,
4667
4705
  objectId: txData?.bidNonce
4668
4706
  });
4669
- console.log("bidType", bidType);
4670
4707
  if (isOriginByteBid(bidType)) {
4671
4708
  addOriginByteRemoveCollectionBidTx(txData);
4672
4709
  return;
@@ -4729,7 +4766,6 @@ var removeCollectionBid = async ({ bidId }, context) => {
4729
4766
  sellerKiosk: bid?.nft?.chain_state?.kiosk_id,
4730
4767
  bidMarketName: bid?.market_contract?.name
4731
4768
  };
4732
- console.log("txData", txData);
4733
4769
  switch (txData.bidMarketName) {
4734
4770
  case "tradeport":
4735
4771
  await addTradePortRemoveCollectionBidTxHandler(txData);
@@ -4977,7 +5013,6 @@ var unlistListings = async ({ listingIds, walletAddress }, context) => {
4977
5013
  collectionId: listing?.nft?.collection_id,
4978
5014
  seller: walletAddress
4979
5015
  };
4980
- console.log("txData", txData);
4981
5016
  switch (listing?.market_name) {
4982
5017
  case "tradeport":
4983
5018
  await addTradePortUnlistTxHandler(txData);