From 3692114dffd7d6f2b7f72d995a193f7a36cf574a Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Wed, 14 Jun 2023 12:41:16 +0300 Subject: [PATCH] Fetch open edition creation fee and minimum mint price from the factory --- pages/collections/create.tsx | 54 ++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index fbc9c6a..efa4391 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -30,6 +30,8 @@ import type { UploadDetailsDataProps } from 'components/collections/creation/Upl import type { WhitelistDetailsDataProps } from 'components/collections/creation/WhitelistDetails' import { Conditional } from 'components/Conditional' import { LoadingModal } from 'components/LoadingModal' +import type { OpenEditionMinterCreatorDataProps } from 'components/openEdition/OpenEditionMinterCreator' +import { OpenEditionMinterCreator } from 'components/openEdition/OpenEditionMinterCreator' import { useContracts } from 'contexts/contracts' import { addLogItem } from 'contexts/log' import { useWallet } from 'contexts/wallet' @@ -49,6 +51,7 @@ import { BLOCK_EXPLORER_URL, NETWORK, OPEN_EDITION_FACTORY_ADDRESS, + OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS, SG721_CODE_ID, SG721_UPDATABLE_CODE_ID, STARGAZE_URL, @@ -92,6 +95,9 @@ const CollectionCreationPage: NextPage = () => { const [uploadDetails, setUploadDetails] = useState(null) const [collectionDetails, setCollectionDetails] = useState(null) const [baseMinterDetails, setBaseMinterDetails] = useState(null) + const [openEditionMinterDetails, setOpenEditionMinterDetails] = useState( + null, + ) const [mintingDetails, setMintingDetails] = useState(null) const [whitelistDetails, setWhitelistDetails] = useState(null) const [royaltyDetails, setRoyaltyDetails] = useState(null) @@ -100,10 +106,16 @@ const CollectionCreationPage: NextPage = () => { const [vendingMinterCreationFee, setVendingMinterCreationFee] = useState(null) const [baseMinterCreationFee, setBaseMinterCreationFee] = useState(null) const [vendingMinterUpdatableCreationFee, setVendingMinterUpdatableCreationFee] = useState(null) + const [openEditionMinterCreationFee, setOpenEditionMinterCreationFee] = useState(null) + const [openEditionMinterUpdatableCreationFee, setOpenEditionMinterUpdatableCreationFee] = useState( + null, + ) const [vendingMinterFlexCreationFee, setVendingMinterFlexCreationFee] = useState(null) const [baseMinterUpdatableCreationFee, setBaseMinterUpdatableCreationFee] = useState(null) const [minimumMintPrice, setMinimumMintPrice] = useState('0') const [minimumUpdatableMintPrice, setMinimumUpdatableMintPrice] = useState('0') + const [minimumOpenEditionMintPrice, setMinimumOpenEditionMintPrice] = useState('0') + const [minimumOpenEditionUpdatableMintPrice, setMinimumOpenEditionUpdatableMintPrice] = useState('0') const [minimumFlexMintPrice, setMinimumFlexMintPrice] = useState('0') const [uploading, setUploading] = useState(false) @@ -1032,6 +1044,26 @@ const CollectionCreationPage: NextPage = () => { setVendingMinterFlexCreationFee(vendingFactoryFlexParameters?.params?.creation_fee?.amount) setMinimumFlexMintPrice(vendingFactoryFlexParameters?.params?.min_mint_price?.amount) } + if (OPEN_EDITION_FACTORY_ADDRESS) { + const openEditionFactoryParameters = await client + .queryContractSmart(OPEN_EDITION_FACTORY_ADDRESS, { params: {} }) + .catch((error) => { + toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) + addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) + }) + setOpenEditionMinterCreationFee(openEditionFactoryParameters?.params?.creation_fee?.amount) + setMinimumOpenEditionMintPrice(openEditionFactoryParameters?.params?.min_mint_price?.amount) + } + if (OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS) { + const openEditionUpdatableFactoryParameters = await client + .queryContractSmart(OPEN_EDITION_UPDATABLE_FACTORY_ADDRESS, { params: {} }) + .catch((error) => { + toast.error(`${error.message}`, { style: { maxWidth: 'none' } }) + addLogItem({ id: uid(), message: error.message, type: 'Error', timestamp: new Date() }) + }) + setOpenEditionMinterUpdatableCreationFee(openEditionUpdatableFactoryParameters?.params?.creation_fee?.amount) + setMinimumOpenEditionMintPrice(openEditionUpdatableFactoryParameters?.params?.min_mint_price?.amount) + } } const checkwalletBalance = () => { @@ -1374,13 +1406,23 @@ const CollectionCreationPage: NextPage = () => { )} - -
- + + +
+ + +