@tradeport/sui-trading-sdk 0.1.74 → 0.1.76
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 +12 -0
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/graphql/queries/fetchCollectionFloorListings.ts +15 -0
- package/src/helpers/getCollectionFloorPrice.ts +12 -0
- package/src/methods/listNfts/addListTxs.ts +15 -0
- package/src/methods/placeCollectionBids/addPlaceCollectionBidTxs.ts +10 -0
- package/src/methods/transferNfts/addTransferNftTx.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @tradeport/sui-trading-sdk
|
|
2
2
|
|
|
3
|
+
## 0.1.76
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ac7c102: Fixed error for collection bid above floor price
|
|
8
|
+
|
|
9
|
+
## 0.1.75
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- f6e1d2a: Added errors for min floor price rule and bidding above floor
|
|
14
|
+
|
|
3
15
|
## 0.1.74
|
|
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: [
|
|
@@ -4099,6 +4118,32 @@ var fetchCollectionsBySlug = import_graphql_request19.gql`
|
|
|
4099
4118
|
}
|
|
4100
4119
|
`;
|
|
4101
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
|
+
|
|
4102
4147
|
// src/helpers/getTradeportBiddingContractBidAmount.ts
|
|
4103
4148
|
var getTradeportBiddingContractBidAmount = ({ bidAmount, collectionId }) => {
|
|
4104
4149
|
let amount = bidAmount;
|
|
@@ -4201,6 +4246,10 @@ async function addOriginByteCollectionBidTx({
|
|
|
4201
4246
|
sharedObjects,
|
|
4202
4247
|
bidderKiosk
|
|
4203
4248
|
}) {
|
|
4249
|
+
const collectionFloorPrice = await getCollectionFloorPrice(collectionId);
|
|
4250
|
+
if (collectionFloorPrice && collectionFloorPrice > 0 && Number(bidAmount) > Number(collectionFloorPrice)) {
|
|
4251
|
+
throw new Error("Bid amount must be less than the collection floor price");
|
|
4252
|
+
}
|
|
4204
4253
|
const { orderbook } = sharedObjects;
|
|
4205
4254
|
const marketFeePrice = getMarketFeePrice({ price: bidAmount, collectionId });
|
|
4206
4255
|
const [coin] = splitCoins({ tx, amounts: [tx.pure.u64(bidAmount + marketFeePrice)] });
|
|
@@ -4671,8 +4720,8 @@ var removeNftBids = async ({ bidIds }, context) => {
|
|
|
4671
4720
|
var import_transactions20 = require("@mysten/sui/transactions");
|
|
4672
4721
|
|
|
4673
4722
|
// src/graphql/queries/fetchCryptoToUsdRate.ts
|
|
4674
|
-
var
|
|
4675
|
-
var fetchCryptoToUsdRate =
|
|
4723
|
+
var import_graphql_request21 = require("graphql-request");
|
|
4724
|
+
var fetchCryptoToUsdRate = import_graphql_request21.gql`
|
|
4676
4725
|
query fetchCryptoToUsdRate($crypto: String!) {
|
|
4677
4726
|
crypto_rates(where: { crypto: { _eq: $crypto }, fiat: { _eq: "USD" } }) {
|
|
4678
4727
|
crypto
|