{"version":3,"sources":["redux/blockchain/blockchainReducer.js","redux/data/dataReducer.js","redux/store.js","redux/data/dataActions.js","redux/blockchain/blockchainActions.js","styles/globalStyles.js","styles/bg.png","styles/logo.png","App.js","reportWebVitals.js","index.js"],"names":["initialState","loading","account","smartContract","web3","errorMsg","blockchainReducer","state","action","type","payload","totalSupply","cost","error","dataReducer","rootReducer","combineReducers","blockchain","data","middleware","thunk","composeEnhancers","compose","applyMiddleware","store","createStore","fetchDataFailed","fetchData","dispatch","a","getState","methods","call","console","log","connectFailed","updateAccount","styled","div","image","flex","fd","jc","ai","test","p","dotenv","config","App","useDispatch","useSelector","useState","isConnected","setIsConnected","mintAmount","setMintAmount","setFeedback","claimingNft","setClaimingNft","connectText","setConnectText","useRef","CONTRACT_ADDRESS","SCAN_LINK","NETWORK","NAME","SYMBOL","ID","NFT_NAME","MAX_SUPPLY","WEI_COST","DISPLAY_COST","GAS_LIMIT","MARKETPLACE","MARKETPLACE_LINK","SHOW_BACKGROUND","CONFIG","SET_CONFIG","useEffect","mint","calculateDynamicPrice","send","value","toString","to","from","once","err","then","receipt","getData","getConfig","fetch","headers","Accept","configResponse","json","getConfigAndData","currentSupply","mintQty","numCurrentSupply","Number","totalCost","ethers","BigNumber","i","add","utils","parseEther","className","src","bg","alt","style","marginBottom","costWei","costEth","formatEther","getCost","onClick","e","preventDefault","newMintAmount","decrementMintAmount","disabled","incrementMintAmount","abiResponse","abi","window","ethereum","isMetaMask","Web3EthContract","setProvider","Web3","request","method","accounts","SmartContractObj","on","location","reload","reportWebVitals","onPerfEntry","Function","getCLS","getFID","getFCP","getLCP","getTTFB","ReactDOM","render","document","getElementById"],"mappings":"kuBAAMA,EAAe,CACnBC,SAAS,EACTC,QAAS,KACTC,cAAe,KACfC,KAAM,KACNC,SAAU,IAkCGC,EA/BW,WAAmC,IAAlCC,EAAiC,uDAAzBP,EAAcQ,EAAW,uCAC1D,OAAQA,EAAOC,MACb,IAAK,qBACH,OAAO,2BACFT,GADL,IAEE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AKJ,GApBjB,oBAsBsBA,EAASK,QAAQ,CACtCC,OAAQ,wBAvBT,eAsBKC,EAtBL,iBAyBuBP,EAASK,QAAQ,CACvCC,OAAQ,gBA1BT,gBA4BgB3D,EAAOZ,QAAQG,IACxBsE,EAAmB,IAAIN,IAC3BJ,EACAnD,EAAOd,kBAETlC,EAtDD,CACLnB,KAAM,qBACNC,QAqDuB,CACbR,QAASsI,EAAS,GAClBrI,cAAesI,EACfrI,KAAMA,KAIV6H,EAASS,GAAG,mBAAmB,SAACF,GAC9B5G,EAASQ,EAAcoG,EAAS,QAElCP,EAASS,GAAG,gBAAgB,WAC1BV,OAAOW,SAASC,aAIlBhH,EAASO,EAAc,qBAAD,OAAsByC,EAAOZ,QAAQC,KAArC,OAjDvB,mDAoDDrC,EAASO,EAAc,0BApDtB,gCAuDHP,EAASO,EAAc,sBAvDpB,2DAAP,uDIoM8BuD,IA5L5BrC,GAAe,GACfO,EAAe,eAwLA,cAKgBD,QAGvB,4BC/NGkF,EAZS,SAAAC,GAClBA,GAAeA,aAAuBC,UACxC,8BAAqBvD,MAAK,YAAkD,IAA/CwD,EAA8C,EAA9CA,OAAQC,EAAsC,EAAtCA,OAAQC,EAA8B,EAA9BA,OAAQC,EAAsB,EAAtBA,OAAQC,EAAc,EAAdA,QAC3DJ,EAAOF,GACPG,EAAOH,GACPI,EAAOJ,GACPK,EAAOL,GACPM,EAAQN,O,OCCdO,IAASC,OACP,cAAC,IAAD,CAAU9H,MAAOA,EAAjB,SACE,cAAC,EAAD,MAEF+H,SAASC,eAAe,SAM1BX,M","file":"static/js/main.e226af47.chunk.js","sourcesContent":["const initialState = {\n loading: false,\n account: null,\n smartContract: null,\n web3: null,\n errorMsg: \"\",\n};\n\nconst blockchainReducer = (state = initialState, action) => {\n switch (action.type) {\n case \"CONNECTION_REQUEST\":\n return {\n ...initialState,\n loading: true,\n };\n case \"CONNECTION_SUCCESS\":\n return {\n ...state,\n loading: false,\n account: action.payload.account,\n smartContract: action.payload.smartContract,\n web3: action.payload.web3,\n };\n case \"CONNECTION_FAILED\":\n return {\n ...initialState,\n loading: false,\n errorMsg: action.payload,\n };\n case \"UPDATE_ACCOUNT\":\n return {\n ...state,\n account: action.payload.account,\n };\n default:\n return state;\n }\n};\n\nexport default blockchainReducer;\n","const initialState = {\n loading: false,\n totalSupply: 0,\n cost: 0,\n error: false,\n errorMsg: \"\",\n};\n\nconst dataReducer = (state = initialState, action) => {\n switch (action.type) {\n case \"CHECK_DATA_REQUEST\":\n return {\n ...state,\n loading: true,\n error: false,\n errorMsg: \"\",\n };\n case \"CHECK_DATA_SUCCESS\":\n return {\n ...state,\n loading: false,\n totalSupply: action.payload.totalSupply,\n // cost: action.payload.cost,\n error: false,\n errorMsg: \"\",\n };\n case \"CHECK_DATA_FAILED\":\n return {\n ...initialState,\n loading: false,\n error: true,\n errorMsg: action.payload,\n };\n default:\n return state;\n }\n};\n\nexport default dataReducer;\n","import { applyMiddleware, compose, createStore, combineReducers } from \"redux\";\nimport thunk from \"redux-thunk\";\nimport blockchainReducer from \"./blockchain/blockchainReducer\";\nimport dataReducer from \"./data/dataReducer\";\n\nconst rootReducer = combineReducers({\n blockchain: blockchainReducer,\n data: dataReducer,\n});\n\nconst middleware = [thunk];\nconst composeEnhancers = compose(applyMiddleware(...middleware));\n\nconst configureStore = () => {\n return createStore(rootReducer, composeEnhancers);\n};\n\nconst store = configureStore();\n\nexport default store;\n","// log\nimport store from \"../store\";\n\nconst fetchDataRequest = () => {\n return {\n type: \"CHECK_DATA_REQUEST\",\n };\n};\n\nconst fetchDataSuccess = (payload) => {\n return {\n type: \"CHECK_DATA_SUCCESS\",\n payload: payload,\n };\n};\n\nconst fetchDataFailed = (payload) => {\n return {\n type: \"CHECK_DATA_FAILED\",\n payload: payload,\n };\n};\n\nexport const fetchData = () => {\n return async (dispatch) => {\n dispatch(fetchDataRequest());\n try {\n let totalSupply = await store\n .getState()\n .blockchain.smartContract.methods.totalSupply()\n .call();\n // let cost = await store\n // .getState()\n // .blockchain.smartContract.methods.cost()\n // .call();\n\n dispatch(\n fetchDataSuccess({\n totalSupply,\n // cost,\n })\n );\n } catch (err) {\n console.log(err);\n dispatch(fetchDataFailed(\"Could not load data from contract.\"));\n }\n };\n};\n","// constants\nimport Web3EthContract from \"web3-eth-contract\";\nimport Web3 from \"web3\";\n// log\nimport { fetchData } from \"../data/dataActions\";\n\nconst connectRequest = () => {\n return {\n type: \"CONNECTION_REQUEST\",\n };\n};\n\nconst connectSuccess = (payload) => {\n return {\n type: \"CONNECTION_SUCCESS\",\n payload: payload,\n };\n};\n\nconst connectFailed = (payload) => {\n return {\n type: \"CONNECTION_FAILED\",\n payload: payload,\n };\n};\n\nconst updateAccountRequest = (payload) => {\n return {\n type: \"UPDATE_ACCOUNT\",\n payload: payload,\n };\n};\n\nexport const connect = () => {\n return async (dispatch) => {\n dispatch(connectRequest());\n const abiResponse = await fetch(\"/config/abi.json\", {\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n });\n const abi = await abiResponse.json();\n const configResponse = await fetch(\"/config/config.json\", {\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n });\n const CONFIG = await configResponse.json();\n const { ethereum } = window;\n const metamaskIsInstalled = ethereum && ethereum.isMetaMask;\n if (metamaskIsInstalled) {\n Web3EthContract.setProvider(ethereum);\n let web3 = new Web3(ethereum);\n try {\n const accounts = await ethereum.request({\n method: \"eth_requestAccounts\",\n });\n const networkId = await ethereum.request({\n method: \"net_version\",\n });\n if (networkId == CONFIG.NETWORK.ID) {\n const SmartContractObj = new Web3EthContract(\n abi,\n CONFIG.CONTRACT_ADDRESS\n );\n dispatch(\n connectSuccess({\n account: accounts[0],\n smartContract: SmartContractObj,\n web3: web3,\n })\n );\n // Add listeners start\n ethereum.on(\"accountsChanged\", (accounts) => {\n dispatch(updateAccount(accounts[0]));\n });\n ethereum.on(\"chainChanged\", () => {\n window.location.reload();\n });\n // Add listeners end\n } else {\n dispatch(connectFailed(`Change network to ${CONFIG.NETWORK.NAME}.`));\n }\n } catch (err) {\n dispatch(connectFailed(\"Something went wrong.\"));\n }\n } else {\n dispatch(connectFailed(\"Install Metamask.\"));\n }\n };\n};\n\nexport const updateAccount = (account) => {\n return async (dispatch) => {\n dispatch(updateAccountRequest({ account: account }));\n dispatch(fetchData(account));\n };\n};\n","import styled from \"styled-components\";\n\n// Used for wrapping a page component\nexport const Screen = styled.div`\n background-color: var(--primary);\n background-image: ${({ image }) => (image ? `url(${image})` : \"none\")};\n background-size: cover;\n background-position: center;\n width: 100%;\n min-height: 100vh;\n display: flex;\n flex-direction: column;\n`;\n\n// Used for providing space between components\nexport const SpacerXSmall = styled.div`\n height: 8px;\n width: 8px;\n`;\n\n// Used for providing space between components\nexport const SpacerSmall = styled.div`\n height: 16px;\n width: 16px;\n`;\n\n// Used for providing space between components\nexport const SpacerMedium = styled.div`\n height: 24px;\n width: 24px;\n`;\n\n// Used for providing space between components\nexport const SpacerLarge = styled.div`\n height: 32px;\n width: 32px;\n`;\n\n// Used for providing a wrapper around a component\nexport const Container = styled.div`\n display: flex;\n flex: ${({ flex }) => (flex ? flex : 0)};\n flex-direction: ${({ fd }) => (fd ? fd : \"column\")};\n justify-content: ${({ jc }) => (jc ? jc : \"flex-start\")};\n align-items: ${({ ai }) => (ai ? ai : \"flex-start\")};\n background-color: ${({ test }) => (test ? \"pink\" : \"none\")};\n width: 100%;\n background-image: ${({ image }) => (image ? `url(${image})` : \"none\")};\n background-size: cover;\n background-position: center;\n`;\n\nexport const TextTitle = styled.p`\n color: var(--primary-text);\n font-size: 22px;\n font-weight: 500;\n line-height: 1.6;\n`;\n\nexport const TextSubTitle = styled.p`\n color: var(--primary-text);\n font-size: 18px;\n line-height: 1.6;\n`;\n\nexport const TextDescription = styled.p`\n color: var(--primary-text);\n font-size: 16px;\n line-height: 1.6;\n`;\n\nexport const StyledClickable = styled.div`\n :active {\n opacity: 0.6;\n }\n`;\n","export default __webpack_public_path__ + \"static/media/bg.d90154a8.png\";","export default __webpack_public_path__ + \"static/media/logo.08b926ef.png\";","import React, { useEffect, useState, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { connect } from \"./redux/blockchain/blockchainActions\";\nimport { Box, CircularProgress, TextField} from '@mui/material';\nimport { fetchData } from \"./redux/data/dataActions\";\nimport * as s from \"./styles/globalStyles\";\nimport styled from \"styled-components\";\nimport { NFTStorage, File } from \"nft.storage\"\nimport fs from 'fs'\nimport dotenv from 'dotenv'\nimport FadeIn from 'react-fade-in';\nimport { SocialIcon } from 'react-social-icons';\nimport \"./styles.css\";\nimport ConnectButton from './ConnectButton.js'\nimport logo from './styles/logo.png'\nimport bg from './styles/bg.png'\nimport { margin } from \"@mui/system\";\nimport { ethers } from \"ethers\";\ndotenv.config()\n\nconst truncate = (input, len) =>\n input.length > len ? `${input.substring(0, len)}...` : input;\n\n \n\n\nfunction App() {\n const dispatch = useDispatch();\n const blockchain = useSelector((state) => state.blockchain);\n const [isConnected, setIsConnected] = useState(false);\n const [address, setAddress] = useState(\"\")\n const data = useSelector((state) => state.data);\n const [mintAmount, setMintAmount] = useState(1);\n const [feedback, setFeedback] = useState('')\n const [totalSupply, setTotalSupply] = useState()\n const [claimingNft,setClaimingNft] = useState(false)\n const [connectText, setConnectText] = useState('CONNECT')\n \n // Create a reference for totalSupply\n const totalSupplyRef = useRef(data.totalSupply);\n\n const connectBut = () => {\n setIsConnected(true);\n setConnectText('DISCONNECT');\n };\n\n const getTotalSupply = () => {\n const totalSupplys = blockchain.smartContract.methods.totalSupply().call();\n setTotalSupply(totalSupplys);\n };\n\n\n const [CONFIG, SET_CONFIG] = useState({\n \n CONTRACT_ADDRESS: \"\",\n SCAN_LINK: \"\",\n NETWORK: {\n NAME: \"\",\n SYMBOL: \"\",\n ID: 0,\n },\n NFT_NAME: \"\",\n SYMBOL: \"\",\n MAX_SUPPLY: 1,\n WEI_COST: 0,\n DISPLAY_COST: 0,\n GAS_LIMIT: 0,\n MARKETPLACE: \"\",\n MARKETPLACE_LINK: \"\",\n SHOW_BACKGROUND: false,\n });\n useEffect(async () => {\n // Fetch data when component mounts and when the account changes\n await dispatch(fetchData(blockchain.account));\n }, [blockchain.account]);\n\n \n \n const mint = async () => {\n try {\n const totalSupply = await blockchain.smartContract.methods.totalSupply().call();\n const cost = calculateDynamicPrice(totalSupply, mintAmount);\n\n setClaimingNft(true);\n setFeedback(`Proceeding to mint...`);\n\n await blockchain.smartContract.methods\n .mint(mintAmount)\n .send({\n value: cost.toString(),\n to: CONFIG.CONTRACT_ADDRESS,\n from: blockchain.account,\n })\n .once(\"error\", (err) => {\n console.log(err);\n setFeedback(\"Sorry, something went wrong. Please try again later.\");\n setClaimingNft(false);\n })\n .then((receipt) => {\n console.log(receipt);\n setFeedback();\n setClaimingNft(false);\n dispatch(fetchData(blockchain.account));\n });\n } catch (error) {\n console.error(\"An error occurred:\", error);\n }\n};\n\n \n \n\n const getData = async () => {\n if (blockchain.account !== \"\" && blockchain.smartContract !== null) {\n dispatch(fetchData(blockchain.account));\n }\n\n };\n\n const getConfig = async () => {\n const configResponse = await fetch(\"/config/config.json\", {\n headers: {\n \"Content-Type\": \"application/json\",\n Accept: \"application/json\",\n },\n });\n const config = await configResponse.json();\n SET_CONFIG(config);\n };\n\n \n useEffect(async() => {\n const getConfigAndData = async () => {\n await getConfig();\n await getData();\n };\n getConfigAndData();\n \n }, []);\n\n\n const decrementMintAmount = () => {\n let newMintAmount = mintAmount - 1;\n if (newMintAmount < 1) {\n newMintAmount = 1;\n }\n setMintAmount(newMintAmount);\n };\n\n const incrementMintAmount = () => {\n let newMintAmount = mintAmount + 1;\n \n if (newMintAmount > 2) {\n newMintAmount = 2;\n }\n \n setMintAmount(newMintAmount);\n };\n\n const getCost = () => {\n \n const costWei = calculateDynamicPrice(data.totalSupply, mintAmount);\n const costEth = ethers.utils.formatEther(costWei);\n return Number(costEth);\n};\n\n\n const calculateDynamicPrice = (currentSupply, mintQty) => {\n console.log(\"Current Total Supply:\", data.totalSupply);\n const numCurrentSupply = Number(currentSupply);\n\n let totalCost = ethers.BigNumber.from(\"0\");\n for (let i = 0; i < mintQty; i++) {\n if (numCurrentSupply + i < 250) {\n totalCost = totalCost.add(ethers.BigNumber.from(\"0\"));\n } else if (numCurrentSupply + i < 270) {\n totalCost = totalCost.add(ethers.utils.parseEther(\"1\"));\n } else if (numCurrentSupply + i < 350) {\n totalCost = totalCost.add(ethers.utils.parseEther(\"10\"));\n } else if (numCurrentSupply + i < 450) {\n totalCost = totalCost.add(ethers.utils.parseEther(\"100\"));\n } else if (numCurrentSupply + i < 550) {\n totalCost = totalCost.add(ethers.utils.parseEther(\"1000\"));\n } else if (numCurrentSupply + i < 750) {\n totalCost = totalCost.add(ethers.utils.parseEther(\"10000\"));\n } else {\n totalCost = totalCost.add(ethers.utils.parseEther(\"100000\"));\n }\n }\n console.log(\"Total cost:\", totalCost.toString());\n return totalCost;\n};\n\n \n return (\n \n
{data.totalSupply} / {CONFIG.MAX_SUPPLY}
Price: {getCost()} BROCK