Update contract dashboard landing page

This commit is contained in:
Serkan Reis 2022-12-15 13:58:38 +03:00
parent 2edbea9245
commit eab5a4a36c
3 changed files with 41 additions and 24 deletions

View File

@ -92,16 +92,18 @@ export const UploadDetails = ({ onChange, minterType, minterAcquisitionMethod }:
setAssetFilesArray([]) setAssetFilesArray([])
setMetadataFilesArray([]) setMetadataFilesArray([])
if (event.target.files === null) return if (event.target.files === null) return
//sort the files if (minterType === 'vending') {
const sortedFiles = Array.from(event.target.files).sort((a, b) => naturalCompare(a.name, b.name)) //sort the files
//check if the sorted file names are in numerical order const sortedFiles = Array.from(event.target.files).sort((a, b) => naturalCompare(a.name, b.name))
const sortedFileNames = sortedFiles.map((file) => file.name.split('.')[0]) //check if the sorted file names are in numerical order
for (let i = 0; i < sortedFileNames.length; i++) { const sortedFileNames = sortedFiles.map((file) => file.name.split('.')[0])
if (isNaN(Number(sortedFileNames[i])) || parseInt(sortedFileNames[i]) !== i + 1) { for (let i = 0; i < sortedFileNames.length; i++) {
toast.error('The file names should be in numerical order starting from 1.') if (isNaN(Number(sortedFileNames[i])) || parseInt(sortedFileNames[i]) !== i + 1) {
//clear the input toast.error('The file names should be in numerical order starting from 1.')
event.target.value = '' //clear the input
return event.target.value = ''
return
}
} }
} }
let loadedFileCount = 0 let loadedFileCount = 0
@ -133,16 +135,18 @@ export const UploadDetails = ({ onChange, minterType, minterAcquisitionMethod }:
event.target.value = '' event.target.value = ''
return toast.error('The number of metadata files should be equal to the number of asset files.') return toast.error('The number of metadata files should be equal to the number of asset files.')
} }
//sort the files if (minterType === 'vending') {
const sortedFiles = Array.from(event.target.files).sort((a, b) => naturalCompare(a.name, b.name)) //sort the files
//check if the sorted file names are in numerical order const sortedFiles = Array.from(event.target.files).sort((a, b) => naturalCompare(a.name, b.name))
const sortedFileNames = sortedFiles.map((file) => file.name.split('.')[0]) //check if the sorted file names are in numerical order
for (let i = 0; i < sortedFileNames.length; i++) { const sortedFileNames = sortedFiles.map((file) => file.name.split('.')[0])
if (isNaN(Number(sortedFileNames[i])) || parseInt(sortedFileNames[i]) !== i + 1) { for (let i = 0; i < sortedFileNames.length; i++) {
toast.error('The file names should be in numerical order starting from 1.') if (isNaN(Number(sortedFileNames[i])) || parseInt(sortedFileNames[i]) !== i + 1) {
//clear the input toast.error('The file names should be in numerical order starting from 1.')
event.target.value = '' //clear the input
return event.target.value = ''
return
}
} }
} }
let loadedFileCount = 0 let loadedFileCount = 0

View File

@ -276,7 +276,8 @@ const CollectionCreationPage: NextPage = () => {
setBaseTokenUri(baseUri) setBaseTokenUri(baseUri)
const result = await baseMinterContract const result = await baseMinterContract
.use(minterDetails?.existingMinter as string) .use(minterDetails?.existingMinter as string)
?.mint(wallet.address, `ipfs://${baseUri}`) // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
?.mint(wallet.address, `ipfs://${baseUri}/${uploadDetails?.metadataFiles[0].name.split('.')[0]}`)
console.log(result) console.log(result)
return result return result
}) })
@ -521,7 +522,8 @@ const CollectionCreationPage: NextPage = () => {
if (uploadDetails.uploadMethod === 'new' && uploadDetails.metadataFiles.length === 0) { if (uploadDetails.uploadMethod === 'new' && uploadDetails.metadataFiles.length === 0) {
throw new Error('Please select the metadata files') throw new Error('Please select the metadata files')
} }
if (uploadDetails.uploadMethod === 'new') compareFileArrays(uploadDetails.assetFiles, uploadDetails.metadataFiles) if (uploadDetails.uploadMethod === 'new' && minterType === 'vending')
compareFileArrays(uploadDetails.assetFiles, uploadDetails.metadataFiles)
if (uploadDetails.uploadMethod === 'new') { if (uploadDetails.uploadMethod === 'new') {
if (uploadDetails.uploadService === 'nft-storage') { if (uploadDetails.uploadService === 'nft-storage') {
if (uploadDetails.nftStorageApiKey === '') { if (uploadDetails.nftStorageApiKey === '') {

View File

@ -20,8 +20,19 @@ const HomePage: NextPage = () => {
<br /> <br />
<div className="grid gap-8 md:grid-cols-2"> <div className="grid gap-8 md:grid-cols-2">
<HomeCard className="p-4 -m-4 hover:bg-gray-500/10 rounded" link="/contracts/minter" title="Minter contract"> <HomeCard
Execute messages and run queries on Stargaze&apos;s minter contract. className="p-4 -m-4 hover:bg-gray-500/10 rounded"
link="/contracts/baseMinter"
title="Base Minter contract"
>
Execute messages and run queries on Stargaze&apos;s Base Minter contract.
</HomeCard>
<HomeCard
className="p-4 -m-4 hover:bg-gray-500/10 rounded"
link="/contracts/vendingMinter"
title="Vending Minter contract"
>
Execute messages and run queries on Stargaze&apos;s Vending Minter contract.
</HomeCard> </HomeCard>
<HomeCard className="p-4 -m-4 hover:bg-gray-500/10 rounded" link="/contracts/sg721" title="Sg721 Contract"> <HomeCard className="p-4 -m-4 hover:bg-gray-500/10 rounded" link="/contracts/sg721" title="Sg721 Contract">
Execute messages and run queries on Stargaze&apos;s sg721 contract. Execute messages and run queries on Stargaze&apos;s sg721 contract.