Validate network and reloads on change

Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
Sebastian Martinez
2021-06-07 23:52:40 -03:00
parent 01585eaa39
commit 442515f056
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -35,6 +35,10 @@ export class Config {
signer: ethers.Signer & TypedDataSigner | null,
) {
let cfg = (<Record<string, any>> config)[network.name];
if(!config.hasOwnProperty(network.name.toLowerCase())) {
throw `Network ${network.name} is not supported`
}
this.network = network;
this.registrar = cfg.registrar;
+2
View File
@@ -164,6 +164,8 @@ export const session = derived(state, s => {
return null;
});
window.ethereum?.on('chainChanged', () => location.reload());
// Updates state when user changes accounts
window.ethereum?.on("accountsChanged", state.setChangedAccount);