From 7d22328543c45ec43e7fdb36486bafe99579dd76 Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Sun, 11 Sep 2022 20:54:28 +0300 Subject: [PATCH] Include the whitelist contract address in the collection creation info box (#6) * Add whitelist contract address to the collection creation result box * Account for the no whitelist option --- .../collections/creation/UploadDetails.tsx | 4 ++-- pages/collections/create.tsx | 17 ++++++++++++++++- pages/contracts/whitelist/query.tsx | 3 ++- services/upload/nft-storage.ts | 2 +- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/components/collections/creation/UploadDetails.tsx b/components/collections/creation/UploadDetails.tsx index a5aa8cf..c501739 100644 --- a/components/collections/creation/UploadDetails.tsx +++ b/components/collections/creation/UploadDetails.tsx @@ -41,7 +41,7 @@ export const UploadDetails = ({ onChange }: UploadDetailsProps) => { const nftStorageApiKeyState = useInputState({ id: 'nft-storage-api-key', name: 'nftStorageApiKey', - title: 'NFT Storage API Key', + title: 'NFT.Storage API Key', placeholder: 'Enter NFT.Storage API Key', defaultValue: '', }) @@ -243,7 +243,7 @@ export const UploadDetails = ({ onChange }: UploadDetailsProps) => { Though Stargaze's sg721 contract allows for off-chain metadata storage, it is recommended to use a decentralized storage solution, such as IPFS.
You may head over to{' '} - NFT Storage + NFT.Storage {' '} or{' '} diff --git a/pages/collections/create.tsx b/pages/collections/create.tsx index 728818d..eeacfae 100644 --- a/pages/collections/create.tsx +++ b/pages/collections/create.tsx @@ -53,6 +53,7 @@ const CollectionCreationPage: NextPage = () => { const [readyToCreate, setReadyToCreate] = useState(false) const [minterContractAddress, setMinterContractAddress] = useState(null) const [sg721ContractAddress, setSg721ContractAddress] = useState(null) + const [whitelistContractAddress, setWhitelistContractAddress] = useState(null) const [baseTokenUri, setBaseTokenUri] = useState(null) const [coverImageUrl, setCoverImageUrl] = useState(null) const [transactionHash, setTransactionHash] = useState(null) @@ -80,6 +81,7 @@ const CollectionCreationPage: NextPage = () => { setCoverImageUrl(null) setMinterContractAddress(null) setSg721ContractAddress(null) + setWhitelistContractAddress(null) setTransactionHash(null) if (uploadDetails?.uploadMethod === 'new') { setUploading(true) @@ -103,6 +105,7 @@ const CollectionCreationPage: NextPage = () => { let whitelist: string | undefined if (whitelistDetails?.whitelistType === 'existing') whitelist = whitelistDetails.contractAddress else if (whitelistDetails?.whitelistType === 'new') whitelist = await instantiateWhitelist() + setWhitelistContractAddress(whitelist as string) await instantiate(baseUri, coverImageUri, whitelist) } else { @@ -112,6 +115,7 @@ const CollectionCreationPage: NextPage = () => { let whitelist: string | undefined if (whitelistDetails?.whitelistType === 'existing') whitelist = whitelistDetails.contractAddress else if (whitelistDetails?.whitelistType === 'new') whitelist = await instantiateWhitelist() + setWhitelistContractAddress(whitelist as string) await instantiate(baseTokenUri as string, coverImageUrl as string, whitelist) } @@ -269,7 +273,7 @@ const CollectionCreationPage: NextPage = () => { if (uploadDetails.uploadMethod === 'new') { if (uploadDetails.uploadService === 'nft-storage') { if (uploadDetails.nftStorageApiKey === '') { - throw new Error('Please enter a valid NFT Storage API key') + throw new Error('Please enter a valid NFT.Storage API key') } } else if (uploadDetails.pinataApiKey === '' || uploadDetails.pinataSecretKey === '') { throw new Error('Please enter Pinata API and secret keys') @@ -413,6 +417,17 @@ const CollectionCreationPage: NextPage = () => { {sg721ContractAddress}
+ + Whitelist Contract Address:{' '} + + {whitelistContractAddress} + +
+
Transaction Hash: {' '} { }) const address = addressState.value - const [type, setType] = useState('has_started') + const [type, setType] = useState('config') const addressVisible = type === 'has_member' @@ -98,6 +98,7 @@ const WhitelistQueryPage: NextPage = () => { 'placeholder:text-white/50', 'focus:ring focus:ring-plumbus-20', )} + defaultValue="config" id="contract-query-type" name="query-type" onChange={(e) => setType(e.target.value as QueryType)} diff --git a/services/upload/nft-storage.ts b/services/upload/nft-storage.ts index 4e6e807..af2160f 100644 --- a/services/upload/nft-storage.ts +++ b/services/upload/nft-storage.ts @@ -2,7 +2,7 @@ import type { CIDString } from 'nft.storage' import { NFTStorage } from 'nft.storage' export const uploadToNftStorage = async (fileArray: File[], nftStorageApiKey: string): Promise => { - console.log('Uploading to NFT Storage...') + console.log('Uploading to NFT.Storage...') const client = new NFTStorage({ token: nftStorageApiKey }) return client.storeDirectory(fileArray) }