-
Notifications
You must be signed in to change notification settings - Fork 28
Mint
The MintComponent
is a React component that provides the functionality for minting a digital asset. In layman's terms, it's like a factory machine interface where you can create your own unique digital item (like a character in a game). This component handles the process of creating the item, showing the status of the creation process, and providing buttons to navigate to other parts of the application.
The component imports several dependencies, including styles, contexts, a custom button component, and a utility function for minting assets.
import React from "react"
import styles from "./Mint.module.scss"
import { ViewMode, ViewContext } from "../context/ViewContext"
import { SceneContext } from "../context/SceneContext"
import CustomButton from "../components/custom-button"
import { SoundContext } from "../context/SoundContext"
import { AudioContext } from "../context/AudioContext"
import { mintAsset } from "../library/mint-utils"
The MintComponent
is a functional component that takes a getFaceScreenshot
prop. It uses several contexts to get and set various application states.
function MintComponent({getFaceScreenshot}) {
const { templateInfo, model, avatar } = React.useContext(SceneContext)
const { setViewMode } = React.useContext(ViewContext)
const { playSound } = React.useContext(SoundContext)
const { isMute } = React.useContext(AudioContext)
...
}
The component uses two state variables: status
to store the current status of the minting process, and minting
to store whether the minting process is currently ongoing.
const [status, setStatus] = React.useState("")
const [minting, setMinting]= React.useState(false)
The component defines several functions:
-
back
andnext
are used to navigate to other views in the application. -
MenuTitle
is a sub-component that renders the title of the menu. -
Mint
is an asynchronous function that handles the minting process.
const back = () => {...}
const next = () => {...}
function MenuTitle() {...}
async function Mint(){...}
The component returns a JSX structure that includes:
- A title for the section.
- A container for the minting process, which includes the
MenuTitle
sub-component, twoCustomButton
components for the minting options, and a status message. - A container for navigation buttons.
return (
<div className={styles.container}>
...
</div>
)
Finally, the MintComponent
is exported for use in other parts of the application.
export default MintComponent