fix listenning provider

pull/3454/head
yann300 2 years ago
parent beed0caf45
commit 7580bea28a
  1. 18
      apps/remix-ide/src/app/providers/injected-provider.tsx

@ -23,13 +23,23 @@ export abstract class InjectedProvider extends Plugin implements IProvider {
abstract notFound(): string
onActivation(): void {
(window as any).ethereum.on('accountsChanged', this.listenerAccountsChanged);
(window as any).ethereum.on('chainChanged', this.listenerChainChanged);
try {
const web3Provider = this.getInjectedProvider()
web3Provider.on('accountsChanged', this.listenerAccountsChanged);
web3Provider.on('chainChanged', this.listenerChainChanged);
} catch (error) {
console.log('unable to listen on context changed')
}
}
onDeactivation(): void {
(window as any).ethereum.removeListener('accountsChanged', this.listenerAccountsChanged)
(window as any).ethereum.removeListener('chainChanged', this.listenerChainChanged)
try {
const web3Provider = this.getInjectedProvider()
web3Provider.removeListener('accountsChanged', this.listenerAccountsChanged)
web3Provider.removeListener('chainChanged', this.listenerChainChanged)
} catch (error) {
console.log('unable to remove listener on context changed')
}
}
askPermission (throwIfNoInjectedProvider) {

Loading…
Cancel
Save