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