diff --git a/.env.example b/.env.example index 7a49465..2084135 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_VERSION=0.3.1 +APP_VERSION=0.3.3 NEXT_PUBLIC_PINATA_ENDPOINT_URL=https://api.pinata.cloud/pinning/pinFileToIPFS NEXT_PUBLIC_SG721_CODE_ID=274 diff --git a/components/collections/actions/Action.tsx b/components/collections/actions/Action.tsx index 322edd9..2a9a3d4 100644 --- a/components/collections/actions/Action.tsx +++ b/components/collections/actions/Action.tsx @@ -247,6 +247,46 @@ export const CollectionActions = ({ throw new Error('Mint price must be at least 50 STARS') } + if (wallet.client && type === 'update_mint_price') { + const contractConfig = wallet.client.queryContractSmart(minterContractAddress, { + config: {}, + }) + await toast + .promise( + wallet.client.queryContractSmart(minterContractAddress, { + mint_price: {}, + }), + { + error: `Querying mint price failed!`, + loading: 'Querying current mint price...', + success: (price) => { + console.log(price) + return `Current mint price is ${Number(price.public_price.amount) / 1000000} STARS` + }, + }, + ) + .then(async (price) => { + if (Number(price.public_price.amount) / 1000000 <= priceState.value) { + await contractConfig + .then((config) => { + console.log(config.start_time, Date.now() * 1000000) + if (Number(config.start_time) < Date.now() * 1000000) { + throw new Error( + `Minting has already started on ${new Date( + Number(config.start_time) / 1000000, + ).toLocaleString()}. Updated mint price cannot be higher than the current price of ${ + Number(price.public_price.amount) / 1000000 + } STARS`, + ) + } + }) + .catch((error) => { + throw new Error(String(error).substring(String(error).lastIndexOf('Error:') + 7)) + }) + } + }) + } + if ( type === 'update_collection_info' && (royaltyShareState.value ? !royaltyPaymentAddressState.value : royaltyPaymentAddressState.value) @@ -265,7 +305,7 @@ export const CollectionActions = ({ }, { onError: (error) => { - toast.error(String(error)) + toast.error(String(error), { style: { maxWidth: 'none' } }) }, }, ) diff --git a/package.json b/package.json index 6b9b2b0..fceeca7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stargaze-studio", - "version": "0.3.2", + "version": "0.3.3", "workspaces": [ "packages/*" ], diff --git a/pages/contracts/vendingMinter/execute.tsx b/pages/contracts/vendingMinter/execute.tsx index ff6caf9..45ddf89 100644 --- a/pages/contracts/vendingMinter/execute.tsx +++ b/pages/contracts/vendingMinter/execute.tsx @@ -108,6 +108,52 @@ const VendingMinterExecutePage: NextPage = () => { if (!wallet.initialized) { throw new Error('Please connect your wallet.') } + 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, { + config: {}, + }) + await toast + .promise( + wallet.client.queryContractSmart(contractState.value, { + mint_price: {}, + }), + { + error: `Querying mint price failed!`, + loading: 'Querying current mint price...', + success: (price) => { + console.log(price) + return `Current mint price is ${Number(price.public_price.amount) / 1000000} STARS` + }, + }, + ) + .then(async (price) => { + if (Number(price.public_price.amount) / 1000000 <= priceState.value) { + await contractConfig + .then((config) => { + console.log(config.start_time, Date.now() * 1000000) + if (Number(config.start_time) < Date.now() * 1000000) { + throw new Error( + `Minting has already started on ${new Date( + Number(config.start_time) / 1000000, + ).toLocaleString()}. Updated mint price cannot be higher than the current price of ${ + Number(price.public_price.amount) / 1000000 + } STARS`, + ) + } + }) + .catch((error) => { + throw new Error(String(error).substring(String(error).lastIndexOf('Error:') + 7)) + }) + } + }) + } const txHash = await toast.promise(dispatchExecute(payload), { error: `${type.charAt(0).toUpperCase() + type.slice(1)} execute failed!`, loading: 'Executing message...',