diff --git a/src/assets/logo.png b/src/assets/logo.png new file mode 100644 index 0000000..964199b Binary files /dev/null and b/src/assets/logo.png differ diff --git a/src/components/Minter.js b/src/components/Minter.js index feea610..c77a1ee 100644 --- a/src/components/Minter.js +++ b/src/components/Minter.js @@ -2,6 +2,7 @@ import { useEffect, useState } from "react"; import Web3 from "web3"; import contract from "../contracts/contract.json"; import Hero from "../assets/hero.png"; +import Logo from "../assets/logo.png"; const initialInfoState = { connected: false, @@ -15,10 +16,11 @@ const initialInfoState = { const initialMintState = { loading: false, - status: `Mint your ${contract.name}`, + status: `Mint your ${contract.name} NFT`, amount: 1, supply: "0", cost: "0", + paused: 1, }; function Minter() { @@ -90,7 +92,7 @@ function Minter() { try { const result = await window.ethereum.request({ method: "eth_call", - params: [params], + params: [params, "latest"], }); console.log(info.web3.utils.hexToNumberString(result)); setMintInfo((prevState) => ({ @@ -114,7 +116,7 @@ function Minter() { try { const result = await window.ethereum.request({ method: "eth_call", - params: [params], + params: [params, "latest"], }); console.log(info.web3.utils.hexToNumberString(result)); setMintInfo((prevState) => ({ @@ -129,16 +131,43 @@ function Minter() { } }; + const getPaused = async () => { + const params = { + to: info.contractJSON.address, + from: info.account, + data: info.contract.methods.paused().encodeABI(), + }; + try { + const result = await window.ethereum.request({ + method: "eth_call", + params: [params, "latest"], + }); + console.log(info.web3.utils.hexToNumber(result)); + setMintInfo((prevState) => ({ + ...prevState, + paused: info.web3.utils.hexToNumber(result), + })); + } catch (err) { + setMintInfo((prevState) => ({ + ...prevState, + paused: 1, + })); + } + }; + const mint = async () => { const params = { to: info.contractJSON.address, from: info.account, + gas: String( + info.web3.utils.toHex( + contract.gas_limit + contract.gas_multiplier * mintInfo.amount + ) + ), value: String( info.web3.utils.toHex(Number(mintInfo.cost) * mintInfo.amount) ), - data: info.contract.methods - .mint(info.account, mintInfo.amount) - .encodeABI(), + data: info.contract.methods.mint(mintInfo.amount).encodeABI(), }; try { setMintInfo((prevState) => ({ @@ -156,7 +185,6 @@ function Minter() { status: "Nice! Your NFT will show up on Opensea, once the transaction is successful.", })); - getSupply(); } catch (err) { setMintInfo((prevState) => ({ ...prevState, @@ -188,6 +216,7 @@ function Minter() { if (info.connected) { getSupply(); getCost(); + getPaused(); } }, [info.connected]); @@ -197,7 +226,18 @@ function Minter() {
{info.status}
+ ) : ( ++ You can not mint yet. Please wait for the announcement to start + minting. +
+ )} +- {info.web3?.utils.fromWei(mintInfo.cost, "ether") * - mintInfo.amount}{" "} + {Number( + info.web3?.utils.fromWei(mintInfo.cost, "ether") * + mintInfo.amount + ).toFixed(3)}{" "} {contract.chain_symbol}
@@ -247,9 +290,11 @@ function Minter() {{mintInfo.status}
) : null} + {info.status ? ({info.status} @@ -262,7 +307,7 @@ function Minter() { {mintInfo.supply}/{contract.total_supply}
- We've sold out! .You can still buy and trade the {contract.name}{" "} + We've sold out!. You can still buy and trade the {contract.name}{" "} on marketplaces such as Opensea.