fix chain detection
This commit is contained in:
parent
d794064a91
commit
ce3fc962d6
@ -48,7 +48,7 @@ const network2Chain: { [key: string]: string } = {
|
||||
};
|
||||
|
||||
const isPossibleNetwork = (networkChain: string): boolean => {
|
||||
if (Object.keys(possibleChains).includes(networkChain)) {
|
||||
if (Object.keys(possibleChains).includes(networkChain.toString())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useEtherStore } from "@/store/ether";
|
||||
|
||||
import { getContract, getProvider } from "./provider";
|
||||
import { getTokenAddress, possibleChains } from "./addresses";
|
||||
import { getTokenAddress, possibleChains, isPossibleNetwork } from "./addresses";
|
||||
|
||||
import mockToken from "@/utils/smart_contract_files/MockToken.json";
|
||||
|
||||
@ -21,6 +21,10 @@ const updateWalletStatus = async (): Promise<void> => {
|
||||
const signer = provider.getSigner();
|
||||
|
||||
const { chainId } = await provider.getNetwork();
|
||||
if(!isPossibleNetwork(chainId.toString())){
|
||||
window.alert("Invalid chain!:"+chainId);
|
||||
return;
|
||||
}
|
||||
etherStore.setNetworkName(possibleChains[chainId]);
|
||||
|
||||
const mockTokenContract = new ethers.Contract(
|
||||
|
Loading…
x
Reference in New Issue
Block a user