Merge pull request #324 from public-awesome/factory-validation

Check if a valid factory exists for the selected parameters prior to collection creation
This commit is contained in:
Serkan Reis
2024-02-02 09:02:45 +02:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ NEXT_PUBLIC_VENDING_FACTORY_ADDRESS="stars18h7ugh8eaug7wr0w4yjw0ls5s937z35pnkg93
NEXT_PUBLIC_FEATURED_VENDING_FACTORY_ADDRESS="stars14pd96yk3t6gq9l6uyrkg0n5dr09n8rt5y9v3at8x4wl4lrkxhlzq4trqmh"
NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_ADDRESS="stars1h65nms9gwg4vdktyqj84tu50gwlm34e0eczl5w2ezllxuzfxy9esa9qlt0"
NEXT_PUBLIC_VENDING_FACTORY_FLEX_ADDRESS="stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftslp2rwkkkcxy269a35a9pq60ug2q"
NEXT_PUBLIC_FEATURED_VENDING_FACTORY_FLEX_ADDRESS="stars1hvu2ghqkcnvhtj2fc6wuazxt4dqcftslp2rwkkkcxy269a35a9pq60ug2q"
NEXT_PUBLIC_FEATURED_VENDING_FACTORY_FLEX_ADDRESS="stars1udlmmnmmnnqamh36hy6d7azn3ycv23yymkmg6558ntalvyt2pz7s8lhgcd"
NEXT_PUBLIC_VENDING_FACTORY_UPDATABLE_FLEX_ADDRESS=
# NEXT_PUBLIC_VENDING_IBC_ATOM_FACTORY_ADDRESS=
+9
View File
@@ -161,6 +161,7 @@ const CollectionCreationPage: NextPage = () => {
const [baseTokenUri, setBaseTokenUri] = useState<string | null>(null)
const [coverImageUrl, setCoverImageUrl] = useState<string | null>(null)
const [transactionHash, setTransactionHash] = useState<string | null>(null)
const [isMatchingVendingFactoryPresent, setIsMatchingVendingFactoryPresent] = useState<boolean>(false)
const performVendingMinterChecks = () => {
try {
@@ -1030,6 +1031,10 @@ const CollectionCreationPage: NextPage = () => {
(!isValidAddress(mintingDetails.paymentAddress) || !mintingDetails.paymentAddress.startsWith('stars1'))
)
throw new Error('Invalid payment address')
if (!isMatchingVendingFactoryPresent)
throw new Error(
`No matching vending factory contract found for the selected parameters (Mint Price Denom: ${mintingDetails.selectedMintToken?.displayName}, Whitelist Type: ${whitelistDetails?.whitelistType}, Featured Collection: ${isFeaturedCollection})`,
)
}
const checkWhitelistDetails = async () => {
@@ -1278,7 +1283,9 @@ const CollectionCreationPage: NextPage = () => {
minter.flexible === (whitelistDetails?.whitelistType === 'flex') &&
minter.featured === isFeaturedCollection,
)?.factoryAddress
if (vendingFactoryForSelectedDenom) {
setIsMatchingVendingFactoryPresent(true)
setVendingFactoryAddress(vendingFactoryForSelectedDenom)
const vendingFactoryParameters = await client
.queryContractSmart(vendingFactoryForSelectedDenom, { params: {} })
@@ -1300,6 +1307,8 @@ const CollectionCreationPage: NextPage = () => {
setMintTokenFromVendingFactory(
tokensList.find((token) => token.denom === vendingFactoryParameters?.params?.min_mint_price?.denom),
)
} else {
setIsMatchingVendingFactoryPresent(false)
}
}, [
collectionDetails?.updatable,