diff --git a/client/src/constants.js b/client/src/constants.js index 7a636004c..1ee464d11 100644 --- a/client/src/constants.js +++ b/client/src/constants.js @@ -119,6 +119,26 @@ export const NETWORKS_INGAME = { }, }; +// Deprectated networks +// status: {deprecated | deprecation-planned} +export const NETWORKS_DEPRECATION = { + GOERLI: { + id: "5", + status: "deprecation-planned", + date: "jan-2024" + }, + OPTIMISM_GOERLI: { + id: "420", + status: "deprecation-planned", + date: "jan-2024" + }, + ARBITRUM_GOERLI: { + id: "421613", + status: "deprecation-planned", + date: "jan-2024" + } +}; + // Web3 export const Web3 = pkgWeb3; diff --git a/client/src/containers/App.js b/client/src/containers/App.js index 9d6135b3d..bb0f09634 100644 --- a/client/src/containers/App.js +++ b/client/src/containers/App.js @@ -8,12 +8,26 @@ import parse from "html-react-parser"; import { connect } from "react-redux"; import { bindActionCreators } from "redux"; import { withRouter } from "../hoc/withRouter"; -import { randGoodIcon } from "../utils/^^"; -import { deployAdminContracts } from '../utils/deploycontract'; +import { randGoodIcon, randBadIcon } from "../utils/^^"; +import { deployAdminContracts } from "../utils/deploycontract"; +import { + networkOnDeprecationOrDeprecated, + isDeprecatedNetwork, + deprecationStatus, + deprecationDate +} from "../utils/networkDeprecation"; class App extends React.Component { constructor() { super(); + this.state = { + chainId: 0, + }; + if (window.ethereum) { + window.ethereum.request({ method: "eth_chainId" }).then((id) => { + this.setState({ chainId: Number(id) }); + }); + } // Analytics ReactGA.initialize(constants.GOOGLE_ANALYTICS_ID); @@ -31,7 +45,7 @@ class App extends React.Component { let target = this.props.levels[0].deployedAddress; for (let i = 0; i < this.props.levels.length; i++) { const level = this.props.levels[i]; - if (!level.deployedAddress) { + if (!level.deployedAddress) { return this.props.navigate(`${constants.PATH_LEVEL_ROOT}${i}`); } const completed = this.props.completedLevels[level.deployedAddress]; @@ -54,41 +68,58 @@ class App extends React.Component { // change the network to Sepolia network async function switchToSepolia() { - let elements = document.querySelectorAll('.progress-bar-wrapper'); - const deployWindow = document.querySelectorAll('.deploy-window-bg'); + let elements = document.querySelectorAll(".progress-bar-wrapper"); + const deployWindow = document.querySelectorAll(".deploy-window-bg"); try { await window.ethereum.request({ - method: 'wallet_switchEthereumChain', - params: [{ chainId: `0x${Number(constants.NETWORKS.SEPOLIA.id).toString(16)}` }],//if on wrong network giving option to switch to sepolia network. + method: "wallet_switchEthereumChain", + params: [ + { + chainId: `0x${Number(constants.NETWORKS.SEPOLIA.id).toString( + 16 + )}`, + }, + ], //if on wrong network giving option to switch to sepolia network. }); - deployWindow[0].style.display = 'none'; + deployWindow[0].style.display = "none"; } catch (switchError) { // This error code indicates that the chain has not been added to MetaMask. if (switchError.code === 4902) { try { await window.ethereum.request({ - method: 'wallet_addEthereumChain', + method: "wallet_addEthereumChain", params: [ { - chainId: [{ chainId: `0x${Number(constants.NETWORKS.SEPOLIA.id).toString(16)}` }] + chainId: [ + { + chainId: `0x${Number( + constants.NETWORKS.SEPOLIA.id + ).toString(16)}`, + }, + ], }, ], }); - deployWindow[0].style.display = 'none'; + deployWindow[0].style.display = "none"; } catch (addError) { if (addError.code === 4001) { //User has rejected changing the request - elements[0].style.display = 'none'; + elements[0].style.display = "none"; } - console.error("Can't add nor switch to the selected network") + console.error("Can't add nor switch to the selected network"); } } else if (switchError.code === 4001) { //User has rejected changing the request - if (elements[0]) elements[0].style.display = 'none'; + if (elements[0]) elements[0].style.display = "none"; } } } + async function continueAnyway() { + const deployWindow = document.querySelectorAll(".deploy-window-bg"); + deployWindow[0].style.display = "none"; + } + return (
{strings.deployConfirmation}
-{strings.deployConfirmation}
+{strings.deployNote}
{strings.deployNote}
-