// Pages const pages = { home: "first-page", about: "about-us", contact: "contact", addCompany: "add-company", verifyCompany: "verify-company", addPerson: "add-person", }; State.init({ currentPage: pages["home"], }); console.log("state", state); //Settings for contract and chain const desiredChainId = 80001; const contractAddress = ""; //"0xdabd5E6060C1f951c7218D81B76e372d0aA8204f"; const explorerApiKey = "mLvMXKxgNYvVC1gMdStkcBn3xm3fCLZ7"; const contractABI = '[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"string","name":"ID","type":"string"}],"name":"add_Company","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"old_comapnies","outputs":[{"internalType":"contract Company","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"ID","type":"string"}],"name":"remove_Company","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"review_Request","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"verified_companies","outputs":[{"internalType":"contract Company","name":"","type":"address"}],"stateMutability":"view","type":"function"}]'; const ContentWrapper = styled.div` padding: 0px; text-align: center; `; const BodyContent = styled.div` padding: 32px; text-align: center; `; function checkNetwork() { // Connect to the the desired chain provider if ( state.chainId === undefined && ethers !== undefined && Ethers.send("eth_requestAccounts", [])[0] ) { Ethers.provider() .getNetwork() .then((chainIdData) => { if (chainIdData?.chainId) { State.update({ chainId: chainIdData.chainId }); } }); } if (state.chainId !== undefined && state.chainId !== desiredChainId) { return ( <Widget src="s-farshad-k.near/widget/header" props={{ value: "Switch to the proper Mainnet" }} /> ); } return true; } const haveProperNetwork = checkNetwork(); if (haveProperNetwork === true) { return ( <ContentWrapper> <Widget src="s-farshad-k.near/widget/header" props={{ home: homeLink, about: aboutLink, contact: contactLink, }} /> <BodyContent> <Widget src="s-farshad-k.near/widget/first-page" props={{}} /> </BodyContent> </ContentWrapper> ); } else { return haveProperNetwork; } // let iface; // if (!contractABI.length) { // const loadedABI = fetch( // `https://api-testnet.polygonscan.com/api?module=contract&action=getabi&address=${contractAddress}&apikey=${explorerApiKey}` // ); // if (!loadedABI.ok) { // return "Loading"; // } // iface = new ethers.utils.Interface(JSON.parse(loadedABI.body)); // } else { // iface = new ethers.utils.Interface(JSON.parse(contractABI)); // }