diff --git a/.env.example b/.env.example index 2136b8d..51989e5 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_VERSION=0.5.7 +APP_VERSION=0.5.8 NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS NEXT_PUBLIC_SG721_CODE_ID=1911 diff --git a/components/collections/actions/Action.tsx b/components/collections/actions/Action.tsx index 40f6dee..c628b30 100644 --- a/components/collections/actions/Action.tsx +++ b/components/collections/actions/Action.tsx @@ -297,9 +297,6 @@ export const CollectionActions = ({ if (minterContractAddress === '' && sg721ContractAddress === '') { throw new Error('Please enter minter and sg721 contract addresses!') } - if (type === 'update_mint_price' && priceState.value < 50) { - throw new Error('Mint price must be at least 50 STARS') - } if (wallet.client && type === 'update_mint_price') { const contractConfig = wallet.client.queryContractSmart(minterContractAddress, { @@ -337,6 +334,22 @@ export const CollectionActions = ({ .catch((error) => { throw new Error(String(error).substring(String(error).lastIndexOf('Error:') + 7)) }) + } else { + await contractConfig.then(async (config) => { + const factoryParameters = await wallet.client?.queryContractSmart(config.factory, { + params: {}, + }) + if ( + factoryParameters.params.min_mint_price.amount && + priceState.value < Number(factoryParameters.params.min_mint_price.amount) / 1000000 + ) { + throw new Error( + `Updated mint price cannot be lower than the minimum mint price of ${ + Number(factoryParameters.params.min_mint_price.amount) / 1000000 + } STARS`, + ) + } + }) } }) } diff --git a/components/collections/creation/MintingDetails.tsx b/components/collections/creation/MintingDetails.tsx index e7042ff..7f6d806 100644 --- a/components/collections/creation/MintingDetails.tsx +++ b/components/collections/creation/MintingDetails.tsx @@ -13,6 +13,7 @@ interface MintingDetailsProps { onChange: (data: MintingDetailsDataProps) => void numberOfTokens: number | undefined uploadMethod: UploadMethod + minimumMintPrice: number } export interface MintingDetailsDataProps { @@ -23,7 +24,7 @@ export interface MintingDetailsDataProps { paymentAddress?: string } -export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: MintingDetailsProps) => { +export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod, minimumMintPrice }: MintingDetailsProps) => { const wallet = useWallet() const [timestamp, setTimestamp] = useState() @@ -40,7 +41,7 @@ export const MintingDetails = ({ onChange, numberOfTokens, uploadMethod }: Minti id: 'unitPrice', name: 'unitPrice', title: 'Unit Price', - subtitle: 'Price of each token (min. 50 STARS)', + subtitle: `Price of each token (min. ${minimumMintPrice} STARS)`, placeholder: '50', }) diff --git a/components/collections/creation/WhitelistDetails.tsx b/components/collections/creation/WhitelistDetails.tsx index 1418aa0..66fde9e 100644 --- a/components/collections/creation/WhitelistDetails.tsx +++ b/components/collections/creation/WhitelistDetails.tsx @@ -49,7 +49,7 @@ export const WhitelistDetails = ({ onChange }: WhitelistDetailsProps) => { id: 'unit-price', name: 'unitPrice', title: 'Unit Price', - subtitle: 'Token price for whitelisted addresses \n (min. 25 STARS)', + subtitle: 'Token price for whitelisted addresses \n (min. 0 STARS)', placeholder: '25', }) diff --git a/package.json b/package.json index 766941c..daa9b97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stargaze-studio", - "version": "0.5.7", + "version": "0.5.8", "workspaces": [ "packages/*" ], diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index 17e4db7..54b67a4 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -94,6 +94,8 @@ const CollectionCreationPage: NextPage = () => { const [baseMinterCreationFee, setBaseMinterCreationFee] = useState(null) const [vendingMinterUpdatableCreationFee, setVendingMinterUpdatableCreationFee] = useState(null) const [baseMinterUpdatableCreationFee, setBaseMinterUpdatableCreationFee] = useState(null) + const [minimumMintPrice, setMinimumMintPrice] = useState('0') + const [minimumUpdatableMintPrice, setMinimumUpdatableMintPrice] = useState('0') const [uploading, setUploading] = useState(false) const [isMintingComplete, setIsMintingComplete] = useState(false) @@ -784,8 +786,13 @@ const CollectionCreationPage: NextPage = () => { const checkMintingDetails = () => { if (!mintingDetails) throw new Error('Please fill out the minting details') if (mintingDetails.numTokens < 1 || mintingDetails.numTokens > 10000) throw new Error('Invalid number of tokens') - if (Number(mintingDetails.unitPrice) < 50000000) - throw new Error('Invalid unit price: The minimum unit price is 50 STARS') + if (collectionDetails?.updatable) { + if (Number(mintingDetails.unitPrice) < Number(minimumUpdatableMintPrice)) + throw new Error( + `Invalid unit price: The minimum unit price is ${Number(minimumUpdatableMintPrice) / 1000000} STARS`, + ) + } else if (Number(mintingDetails.unitPrice) < Number(minimumMintPrice)) + throw new Error(`Invalid unit price: The minimum unit price is ${Number(minimumMintPrice) / 1000000} STARS`) if ( !mintingDetails.perAddressLimit || mintingDetails.perAddressLimit < 1 || @@ -848,8 +855,8 @@ const CollectionCreationPage: NextPage = () => { } else if (whitelistDetails.whitelistType === 'new') { if (whitelistDetails.members?.length === 0) throw new Error('Whitelist member list cannot be empty') if (whitelistDetails.unitPrice === '') throw new Error('Whitelist unit price is required') - if (Number(whitelistDetails.unitPrice) < 25000000) - throw new Error('Invalid unit price: The minimum unit price for whitelisted addresses is 25 STARS') + if (Number(whitelistDetails.unitPrice) < 0) + throw new Error('Invalid unit price: The unit price cannot be negative') if (whitelistDetails.startTime === '') throw new Error('Start time is required') if (whitelistDetails.endTime === '') throw new Error('End time is required') if (!whitelistDetails.perAddressLimit || whitelistDetails.perAddressLimit === 0) @@ -929,12 +936,14 @@ const CollectionCreationPage: NextPage = () => { if (VENDING_FACTORY_ADDRESS) { const vendingFactoryParameters = await client.queryContractSmart(VENDING_FACTORY_ADDRESS, { params: {} }) setVendingMinterCreationFee(vendingFactoryParameters?.params?.creation_fee?.amount) + setMinimumMintPrice(vendingFactoryParameters?.params?.min_mint_price?.amount) } if (VENDING_FACTORY_UPDATABLE_ADDRESS) { const vendingFactoryUpdatableParameters = await client.queryContractSmart(VENDING_FACTORY_UPDATABLE_ADDRESS, { params: {}, }) setVendingMinterUpdatableCreationFee(vendingFactoryUpdatableParameters?.params?.creation_fee?.amount) + setMinimumUpdatableMintPrice(vendingFactoryUpdatableParameters?.params?.min_mint_price?.amount) } } @@ -1285,6 +1294,11 @@ const CollectionCreationPage: NextPage = () => { { if (contractState.value === '') { throw new Error('Please enter the contract address.') } - if (type === 'update_mint_price' && priceState.value < 50) { - throw new Error('Mint price must be at least 50 STARS') - } if (wallet.client && type === 'update_mint_price') { const contractConfig = wallet.client.queryContractSmart(contractState.value, { @@ -153,6 +150,22 @@ const VendingMinterExecutePage: NextPage = () => { .catch((error) => { throw new Error(String(error).substring(String(error).lastIndexOf('Error:') + 7)) }) + } else { + await contractConfig.then(async (config) => { + const factoryParameters = await wallet.client?.queryContractSmart(config.factory, { + params: {}, + }) + if ( + factoryParameters.params.min_mint_price.amount && + priceState.value < Number(factoryParameters.params.min_mint_price.amount) / 1000000 + ) { + throw new Error( + `Updated mint price cannot be lower than the minimum mint price of ${ + Number(factoryParameters.params.min_mint_price.amount) / 1000000 + } STARS`, + ) + } + }) } }) }