From 3e8bda0a201e1fd125ca6989f7bcfdbba18c82ed Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Oct 2021 09:44:16 -0700 Subject: [PATCH] Add detailed minting progress indicator (#536) --- js/packages/web/src/actions/nft.tsx | 17 +++++++++- js/packages/web/src/views/artCreate/index.tsx | 33 +++++++++++++++---- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/js/packages/web/src/actions/nft.tsx b/js/packages/web/src/actions/nft.tsx index 83a3986..35e071c 100644 --- a/js/packages/web/src/actions/nft.tsx +++ b/js/packages/web/src/actions/nft.tsx @@ -16,7 +16,7 @@ import { WalletSigner, Attribute, } from '@oyster/common'; -import React from 'react'; +import React, { Dispatch, SetStateAction } from 'react'; import { MintLayout, Token } from '@solana/spl-token'; import { Keypair, @@ -86,6 +86,7 @@ export const mintNFT = async ( creators: Creator[] | null; sellerFeeBasisPoints: number; }, + progressCallback: Dispatch>, maxSupply?: number, ): Promise<{ metadataAccount: StringPublicKey; @@ -120,6 +121,8 @@ export const mintNFT = async ( const { instructions: pushInstructions, signers: pushSigners } = await prepPayForFilesTxn(wallet, realFiles, metadata); + progressCallback(1) + const TOKEN_PROGRAM_ID = programIds().token; // Allocate memory for the account @@ -183,6 +186,7 @@ export const mintNFT = async ( instructions, wallet.publicKey.toBase58(), ); + progressCallback(2) // TODO: enable when using payer account to avoid 2nd popup // const block = await connection.getRecentBlockhash('singleGossip'); @@ -194,6 +198,7 @@ export const mintNFT = async ( // }), // ); + const { txid } = await sendTransactionWithRetry( connection, wallet, @@ -201,9 +206,11 @@ export const mintNFT = async ( signers, 'single', ); + progressCallback(3) try { await connection.confirmTransaction(txid, 'max'); + progressCallback(4) } catch { // ignore } @@ -212,6 +219,8 @@ export const mintNFT = async ( // await connection.confirmTransaction(txid, 'max'); await connection.getParsedConfirmedTransaction(txid, 'confirmed'); + progressCallback(5) + // this means we're done getting AR txn setup. Ship it off to ARWeave! const data = new FormData(); data.append('transaction', txid); @@ -228,7 +237,9 @@ export const mintNFT = async ( realFiles.map(f => data.append('file[]', f)); // TODO: convert to absolute file name for image + const result: IArweaveResult = await uploadToArweave(data); + progressCallback(6) const metadataFile = result.messages?.find( m => m.filename === RESERVED_TXN_MANIFEST, @@ -265,6 +276,8 @@ export const mintNFT = async ( 1, ), ); + + progressCallback(7) // // In this instruction, mint authority will be removed from the main mint, while // // minting authority will be maintained for the Printing mint (which we want.) await createMasterEdition( @@ -296,6 +309,8 @@ export const mintNFT = async ( // updateInstructions, // ); + progressCallback(8) + const txid = await sendTransactionWithRetry( connection, wallet, diff --git a/js/packages/web/src/views/artCreate/index.tsx b/js/packages/web/src/views/artCreate/index.tsx index 07e9ceb..e95b57e 100644 --- a/js/packages/web/src/views/artCreate/index.tsx +++ b/js/packages/web/src/views/artCreate/index.tsx @@ -8,12 +8,12 @@ import { Input, Statistic, Slider, - Progress, Spin, InputNumber, Form, Typography, Space, + Card, } from 'antd'; import { ArtCard } from './../../components/ArtCard'; import { UserSearch, UserValue } from './../../components/UserSearch'; @@ -41,7 +41,7 @@ import { useHistory, useParams } from 'react-router-dom'; import { cleanName, getLast } from '../../utils/utils'; import { AmountLabel } from '../../components/AmountLabel'; import useWindowDimensions from '../../utils/layout'; -import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; +import { LoadingOutlined, MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; const { Step } = Steps; const { Dragger } = Upload; @@ -55,6 +55,7 @@ export const ArtCreateView = () => { const { step_param }: { step_param: string } = useParams(); const history = useHistory(); const { width } = useWindowDimensions(); + const [nftCreateProgress, setNFTcreateProgress] = useState(0) const [step, setStep] = useState(0); const [stepsVisible, setStepsVisible] = useState(true); @@ -118,6 +119,7 @@ export const ArtCreateView = () => { env, files, metadata, + setNFTcreateProgress, attributes.properties?.maxSupply, ); @@ -205,6 +207,7 @@ export const ArtCreateView = () => { gotoStep(6)} /> )} @@ -1139,6 +1142,7 @@ const WaitingStep = (props: { mint: Function; minting: boolean; confirm: Function; + step: number; }) => { useEffect(() => { const func = async () => { @@ -1148,6 +1152,13 @@ const WaitingStep = (props: { func(); }, []); + const setIconForStep = (currentStep: number, componentStep) => { + if (currentStep === componentStep) { + return + } + return null; + } + return (
-
- Your creation is being uploaded to the decentralized web... -
-
This can take up to 1 minute.
+ + + + + + + + + + + + +
); }; @@ -1188,6 +1208,7 @@ const Congrats = (props: { }; if (props.alert) { + // TODO - properly reset this components state on error return ( <>
Sorry, there was an error!