Merge pull request #2038 from ethereum/fix-import

Reset selected account when account changes on injectedWeb3.
pull/2044/head
David Disu 3 years ago committed by GitHub
commit de96b524ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      apps/remix-ide/src/blockchain/blockchain.js
  2. 4
      apps/remix-ide/src/blockchain/execution-context.js
  3. 7
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  4. 1
      libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts

@ -226,6 +226,10 @@ export class Blockchain extends Plugin {
return this.executionContext.getProvider()
}
getInjectedWeb3Address () {
return this.executionContext.getSelectedAddress()
}
/**
* return the fork name applied to the current envionment
* @return {String} - fork name

@ -50,6 +50,10 @@ export class ExecutionContext {
return this.executionContext
}
getSelectedAddress () {
return injectedProvider ? injectedProvider.selectedAddress : null
}
getCurrentFork () {
return this.currentFork
}

@ -145,6 +145,13 @@ const fillAccountsList = async () => {
})
})
}))
const provider = plugin.blockchain.getProvider()
if (provider === 'injected') {
const selectedAddress = plugin.blockchain.getInjectedWeb3Address()
if (!(Object.keys(loadedAccounts).includes(selectedAddress))) setAccount(null)
}
dispatch(fetchAccountsListSuccess(loadedAccounts))
}).catch((e) => {
dispatch(fetchAccountsListFailed(e.message))

@ -37,6 +37,7 @@ export class Blockchain extends Plugin<any, any> {
setProviderFromEndpoint(target: any, context: any, cb: any): void;
detectNetwork(cb: any): void;
getProvider(): any;
getInjectedWeb3Address(): any;
/**
* return the fork name applied to the current envionment
* @return {String} - fork name

Loading…
Cancel
Save