Display collection creation results (#35)
* Display collection creation results * Add links for collection creation details * Update link appearance
This commit is contained in:
parent
2c04539894
commit
cceb2c1d08
@ -3,6 +3,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
|
|
||||||
import { coin } from '@cosmjs/proto-signing'
|
import { coin } from '@cosmjs/proto-signing'
|
||||||
|
import { Alert } from 'components/Alert'
|
||||||
import { Anchor } from 'components/Anchor'
|
import { Anchor } from 'components/Anchor'
|
||||||
import Button from 'components/Button'
|
import Button from 'components/Button'
|
||||||
import {
|
import {
|
||||||
@ -23,7 +24,7 @@ import { useContracts } from 'contexts/contracts'
|
|||||||
import { useWallet } from 'contexts/wallet'
|
import { useWallet } from 'contexts/wallet'
|
||||||
import type { NextPage } from 'next'
|
import type { NextPage } from 'next'
|
||||||
import { NextSeo } from 'next-seo'
|
import { NextSeo } from 'next-seo'
|
||||||
import { useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import useCollapse from 'react-collapsed'
|
import useCollapse from 'react-collapsed'
|
||||||
import { toast } from 'react-hot-toast'
|
import { toast } from 'react-hot-toast'
|
||||||
import type { UploadServiceType } from 'services/upload'
|
import type { UploadServiceType } from 'services/upload'
|
||||||
@ -42,6 +43,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
const { getCollapseProps, getToggleProps, isExpanded } = useCollapse()
|
const { getCollapseProps, getToggleProps, isExpanded } = useCollapse()
|
||||||
const toggleProps = getToggleProps()
|
const toggleProps = getToggleProps()
|
||||||
const collapseProps = getCollapseProps()
|
const collapseProps = getCollapseProps()
|
||||||
|
const scrollRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
const [uploadDetails, setUploadDetails] = useState<UploadDetailsDataProps | null>(null)
|
const [uploadDetails, setUploadDetails] = useState<UploadDetailsDataProps | null>(null)
|
||||||
const [collectionDetails, setCollectionDetails] = useState<CollectionDetailsDataProps | null>(null)
|
const [collectionDetails, setCollectionDetails] = useState<CollectionDetailsDataProps | null>(null)
|
||||||
@ -50,11 +52,17 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
const [royaltyDetails, setRoyaltyDetails] = useState<RoyaltyDetailsDataProps | null>(null)
|
const [royaltyDetails, setRoyaltyDetails] = useState<RoyaltyDetailsDataProps | null>(null)
|
||||||
|
|
||||||
const [uploading, setUploading] = useState(false)
|
const [uploading, setUploading] = useState(false)
|
||||||
const [contractAddress, setContractAddress] = useState<string | null>(null)
|
const [minterContractAddress, setMinterContractAddress] = useState<string | null>(null)
|
||||||
|
const [sg721ContractAddress, setSg721ContractAddress] = useState<string | null>(null)
|
||||||
|
const [baseTokenUri, setBaseTokenUri] = useState<string | null>(null)
|
||||||
const [transactionHash, setTransactionHash] = useState<string | null>(null)
|
const [transactionHash, setTransactionHash] = useState<string | null>(null)
|
||||||
|
|
||||||
const createCollection = async () => {
|
const createCollection = async () => {
|
||||||
try {
|
try {
|
||||||
|
setBaseTokenUri(null)
|
||||||
|
setMinterContractAddress(null)
|
||||||
|
setSg721ContractAddress(null)
|
||||||
|
setTransactionHash(null)
|
||||||
checkUploadDetails()
|
checkUploadDetails()
|
||||||
checkCollectionDetails()
|
checkCollectionDetails()
|
||||||
checkMintingDetails()
|
checkMintingDetails()
|
||||||
@ -64,6 +72,7 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
setUploading(true)
|
setUploading(true)
|
||||||
|
|
||||||
const baseUri = await uploadFiles()
|
const baseUri = await uploadFiles()
|
||||||
|
setBaseTokenUri(baseUri)
|
||||||
//upload coverImageUri and append the file name
|
//upload coverImageUri and append the file name
|
||||||
const coverImageUri = await upload(
|
const coverImageUri = await upload(
|
||||||
collectionDetails?.imageFile as File[],
|
collectionDetails?.imageFile as File[],
|
||||||
@ -148,7 +157,8 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
|
|
||||||
const data = await minterContract.instantiate(MINTER_CODE_ID, msg, 'Stargaze Minter Contract', wallet.address)
|
const data = await minterContract.instantiate(MINTER_CODE_ID, msg, 'Stargaze Minter Contract', wallet.address)
|
||||||
setTransactionHash(data.transactionHash)
|
setTransactionHash(data.transactionHash)
|
||||||
setContractAddress(data.contractAddress)
|
setMinterContractAddress(data.contractAddress)
|
||||||
|
setSg721ContractAddress(data.logs[0].events[3].attributes[2].value)
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadFiles = async (): Promise<string> => {
|
const uploadFiles = async (): Promise<string> => {
|
||||||
@ -274,6 +284,9 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
if (royaltyDetails.paymentAddress === '') throw new Error('Royalty payment address is required')
|
if (royaltyDetails.paymentAddress === '') throw new Error('Royalty payment address is required')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
useEffect(() => {
|
||||||
|
if (minterContractAddress !== null) scrollRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||||
|
}, [minterContractAddress])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -288,13 +301,55 @@ const CollectionCreationPage: NextPage = () => {
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
Make sure you check our{' '}
|
Make sure you check our{' '}
|
||||||
<Anchor className="font-bold text-plumbus hover:underline" href={links['Docs']}>
|
<Anchor className="font-bold text-plumbus hover:underline" external href={links['Docs']}>
|
||||||
documentation
|
documentation
|
||||||
</Anchor>{' '}
|
</Anchor>{' '}
|
||||||
on how to create your collection
|
on how to create your collection
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="mx-10" ref={scrollRef}>
|
||||||
|
<Conditional test={minterContractAddress !== null}>
|
||||||
|
<Alert className="mt-5" type="info">
|
||||||
|
<div>
|
||||||
|
Base Token URI:{' '}
|
||||||
|
<Anchor
|
||||||
|
className="text-stargaze hover:underline"
|
||||||
|
external
|
||||||
|
href={`https://ipfs.stargaze.zone/ipfs/${baseTokenUri as string}/`}
|
||||||
|
>
|
||||||
|
ipfs://{baseTokenUri as string}/
|
||||||
|
</Anchor>
|
||||||
|
<br />
|
||||||
|
Minter Contract Address:{' '}
|
||||||
|
<Anchor
|
||||||
|
className="text-stargaze hover:underline"
|
||||||
|
external
|
||||||
|
href={`/contracts/minter/query/?contractAddress=${minterContractAddress as string}`}
|
||||||
|
>
|
||||||
|
{minterContractAddress}
|
||||||
|
</Anchor>
|
||||||
|
<br />
|
||||||
|
SG721 Contract Address:{' '}
|
||||||
|
<Anchor
|
||||||
|
className="text-stargaze hover:underline"
|
||||||
|
external
|
||||||
|
href={`/contracts/sg721/query/?contractAddress=${sg721ContractAddress as string}`}
|
||||||
|
>
|
||||||
|
{sg721ContractAddress}
|
||||||
|
</Anchor>
|
||||||
|
<br />
|
||||||
|
Transaction Hash: {' '}
|
||||||
|
<Anchor
|
||||||
|
className="text-stargaze hover:underline"
|
||||||
|
external
|
||||||
|
href={`https://testnet-explorer.publicawesome.dev/stargaze/tx/${transactionHash as string}`}
|
||||||
|
>
|
||||||
|
{transactionHash}
|
||||||
|
</Anchor>
|
||||||
|
</div>
|
||||||
|
</Alert>
|
||||||
|
</Conditional>
|
||||||
|
</div>
|
||||||
<div className="mx-10">
|
<div className="mx-10">
|
||||||
<UploadDetails onChange={setUploadDetails} />
|
<UploadDetails onChange={setUploadDetails} />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user