Skip to content

Commit

Permalink
fix: Fix rpc/reload bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
OwshenNetwork committed Jan 22, 2024
1 parent 2900874 commit c34fc69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions client/src/components/SelectNetwork/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
import { useSelector, useDispatch } from "react-redux";
import axios from "axios";
import { useAccount } from "wagmi";
import { selectIsTest } from "../../store/containerSlice";
import { selectIsTest, selectNetwork } from "../../store/containerSlice";
import Dropdown from "../DropDown";
import { toast } from "react-toastify";
import { setNetworkDetails } from "../../store/containerSlice";
Expand All @@ -11,6 +11,7 @@ const SelectNetwork = () => {
const dispatch = useDispatch();
const coreEndpoint = process.env.REACT_APP_OWSHEN_ENDPOINT || "";
const accountData = useAccount();
const selectedNetwork = useSelector(selectNetwork);
const chainId = accountData ? accountData.chainId : undefined;
const [network, setNetWork] = useState("Select Network");

Expand Down Expand Up @@ -99,8 +100,11 @@ const SelectNetwork = () => {
};
useEffect(() => {
if (window.ethereum) {
window.ethereum.on("chainChanged", () => {
window.location.reload();
window.ethereum.on("chainChanged", (data) => {
let chain_id = parseInt(data, 16);
checkNetwork(chain_id);
handelChangeNetwork(selectedNetwork.name);
setChainId(chain_id.toString(), selectedNetwork.name);
});
}
}, []);
Expand Down
4 changes: 2 additions & 2 deletions src/apis/set_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ lazy_static! {
static ref NETWORK_CONFIG_MAP: HashMap<String, (String, String)> = [
(
"1337".into(),
("http://127.0.0.1:8545".into(), "localhost.json".into())
("http://127.0.0.1:8545".into(), "Localhost.json".into())
),
(
"0x5".into(),
(
"https://ethereum-goerli.publicnode.com".into(),
"goerli.json".into()
"Goerli.json".into()
)
),
(
Expand Down

0 comments on commit c34fc69

Please sign in to comment.