@tradeport/sui-trading-sdk 0.1.73 → 0.1.75

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.1.75
4
+
5
+ ### Patch Changes
6
+
7
+ - f6e1d2a: Added errors for min floor price rule and bidding above floor
8
+
9
+ ## 0.1.74
10
+
11
+ ### Patch Changes
12
+
13
+ - 73c2740: enable migrating for novagen
14
+
3
15
  ## 0.1.73
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -3625,6 +3625,18 @@ async function addTradePortKioskListTx({
3625
3625
  collectionId,
3626
3626
  listPrice
3627
3627
  }) {
3628
+ const transferPolicy = (await getKioskTransferPolicies(nftType))?.at(0);
3629
+ const minFloorPrice = transferPolicy?.rules?.filter(
3630
+ (rule) => rule?.type === "floor_price_rule"
3631
+ )?.[0]?.floor_price;
3632
+ if (minFloorPrice) {
3633
+ if (listPrice < minFloorPrice) {
3634
+ const formattedMinFloorPrice = Number(minFloorPrice) / 1e9;
3635
+ throw new Error(
3636
+ `NFT Transfer Policy has a miminum floor price rule. Item cannot be listed for less than ${formattedMinFloorPrice} SUI`
3637
+ );
3638
+ }
3639
+ }
3628
3640
  const marketFeePrice = getMarketFeePrice({ price: listPrice, collectionId });
3629
3641
  tx.moveCall({
3630
3642
  target: "0xf527efa4c02d079f15389fb596b04688cd5767948d953942e494ff455f11aa7b::kiosk_listings::list",
@@ -3941,6 +3953,13 @@ async function addTradeportKioskTransferTx({
3941
3953
  nftType,
3942
3954
  recipientAddress
3943
3955
  }) {
3956
+ const transferPolicy = (await getKioskTransferPolicies(nftType))?.at(0);
3957
+ const hasFloorPriceRule = transferPolicy?.rules?.some(
3958
+ (rule) => rule.type === "floor_price_rule"
3959
+ );
3960
+ if (hasFloorPriceRule) {
3961
+ throw new Error("Cannot transfer NFT with a minimum floor price rule");
3962
+ }
3944
3963
  tx.moveCall({
3945
3964
  target: "0x49642273ca7db3d942f9fd810c93467974c40e73ea7f03e8e7a632f1222aca73::kiosk_transfers::transfer_with_purchase_capability",
3946
3965
  arguments: [
@@ -3975,9 +3994,6 @@ async function migrateNftsFromUnsharedToSharedKiosks({ walletAddress }, context)
3975
3994
  if (nft?.chain_state?.claimable_trade_id) {
3976
3995
  continue;
3977
3996
  }
3978
- if (nft?.collection_id === "67ded9ed-4dcc-4d15-9e6f-04dded46f419") {
3979
- continue;
3980
- }
3981
3997
  const nftType = getNftTypeFromNft(nft);
3982
3998
  const nftTokenId = nft?.token_id;
3983
3999
  if (sharedOBKiosk) {
@@ -4102,6 +4118,32 @@ var fetchCollectionsBySlug = import_graphql_request19.gql`
4102
4118
  }
4103
4119
  `;
4104
4120
 
4121
+ // src/graphql/queries/fetchCollectionFloorListings.ts
4122
+ var import_graphql_request20 = require("graphql-request");
4123
+ var fetchCollectionFloorListings = import_graphql_request20.gql`
4124
+ query fetchCollectionFloorListings($collectionId: uuid!) {
4125
+ listings(
4126
+ where: { collection_id: { _eq: $collectionId }, listed: { _eq: true }, nft: {} }
4127
+ order_by: { price: asc_nulls_last, market_name: desc_nulls_last }
4128
+ limit: 3
4129
+ ) {
4130
+ id
4131
+ price
4132
+ market_name
4133
+ }
4134
+ }
4135
+ `;
4136
+
4137
+ // src/helpers/getCollectionFloorPrice.ts
4138
+ var getCollectionFloorPrice = async (collectionId) => {
4139
+ const res = await gqlChainRequest({
4140
+ chain: "sui",
4141
+ query: fetchCollectionFloorListings,
4142
+ variables: { collectionId }
4143
+ });
4144
+ return res?.listings?.[0]?.price;
4145
+ };
4146
+
4105
4147
  // src/helpers/getTradeportBiddingContractBidAmount.ts
4106
4148
  var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
4107
4149
  let amount = bidAmount;
@@ -4251,6 +4293,10 @@ var placeCollectionBids = async ({ collections, walletAddress }, context) => {
4251
4293
  const collectionsForTracking = [];
4252
4294
  const tx = new import_transactions16.Transaction();
4253
4295
  for (const collection of res.collections) {
4296
+ const collectionFloorPrice = await getCollectionFloorPrice(collection?.id);
4297
+ if (collectionFloorPrice && collectionFloorPrice > 0 && Number(collections?.find((c) => c.id === collection?.id)?.bidAmountInMist) > Number(collectionFloorPrice)) {
4298
+ throw new Error("Bid amount must be less than the collection floor price");
4299
+ }
4254
4300
  const nftType = collection.id === "07231735-96de-4710-8e11-52c61a482578" ? "0x034c162f6b594cb5a1805264dd01ca5d80ce3eca6522e6ee37fd9ebfb9d3ddca::factory::PrimeMachin" : getNftTypeFromNft(collection?.nfts?.[0]);
4255
4301
  const sharedObjects = await getSharedObjects(nftType);
4256
4302
  const txData = {
@@ -4674,8 +4720,8 @@ var removeNftBids = async ({ bidIds }, context) => {
4674
4720
  var import_transactions20 = require("@mysten/sui/transactions");
4675
4721
 
4676
4722
  // src/graphql/queries/fetchCryptoToUsdRate.ts
4677
- var import_graphql_request20 = require("graphql-request");
4678
- var fetchCryptoToUsdRate = import_graphql_request20.gql`
4723
+ var import_graphql_request21 = require("graphql-request");
4724
+ var fetchCryptoToUsdRate = import_graphql_request21.gql`
4679
4725
  query fetchCryptoToUsdRate($crypto: String!) {
4680
4726
  crypto_rates(where: { crypto: { _eq: $crypto }, fiat: { _eq: "USD" } }) {
4681
4727
  crypto