mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Refresh balance after network change
Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
committed by
Alexis Sellier
parent
2b5efedfbd
commit
7a130baa24
+6
-2
@@ -2,7 +2,7 @@ import { get, writable, derived, Readable } from "svelte/store";
|
||||
import { ethers } from "ethers";
|
||||
import type { BigNumber } from 'ethers';
|
||||
import type { TransactionReceipt, TransactionResponse } from '@ethersproject/providers';
|
||||
import type { Config } from "@app/config";
|
||||
import { Config, getConfig } from "@app/config";
|
||||
import { Unreachable, assert, assertEq } from "@app/error";
|
||||
|
||||
export enum Connection {
|
||||
@@ -188,7 +188,11 @@ export const session = derived(state, s => {
|
||||
window.ethereum?.on('chainChanged', () => location.reload());
|
||||
|
||||
// Updates state when user changes accounts
|
||||
window.ethereum?.on("accountsChanged", state.setChangedAccount);
|
||||
window.ethereum?.on("accountsChanged", async (address: string[]) => {
|
||||
const config = await getConfig();
|
||||
state.setChangedAccount(address);
|
||||
state.refreshBalance(config);
|
||||
});
|
||||
|
||||
state.subscribe(s => {
|
||||
console.log("session.state", s);
|
||||
|
||||
Reference in New Issue
Block a user