diff --git a/libs/remix-ui/run-tab/src/lib/actions/account.ts b/libs/remix-ui/run-tab/src/lib/actions/account.ts index d2b7c52ebb..b8279411bc 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/account.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/account.ts @@ -2,7 +2,7 @@ import { shortenAddress } from "@remix-ui/helper" import { RunTab } from "../types/run-tab" import { clearInstances, setAccount, setExecEnv } from "./actions" import { displayNotification, displayPopUp, fetchAccountsListFailed, fetchAccountsListRequest, fetchAccountsListSuccess, setMatchPassphrase, setPassphrase } from "./payload" -import { RunTabState } from "../types" +import { toChecksumAddress } from '@ethereumjs/util' export const updateAccountBalances = async (plugin: RunTab, dispatch: React.Dispatch) => { const accounts = plugin.REACT_API.accounts.loadedAccounts @@ -37,8 +37,7 @@ export const fillAccountsList = async (plugin: RunTab, dispatch: React.Dispatch< if (provider === 'injected') { const selectedAddress = plugin.blockchain.getInjectedWeb3Address() - - if (!(Object.keys(loadedAccounts).includes(selectedAddress))) setAccount(dispatch, null) + if (!(Object.keys(loadedAccounts).includes(toChecksumAddress(selectedAddress)))) setAccount(dispatch, null) } dispatch(fetchAccountsListSuccess(loadedAccounts)) }).catch((e) => { diff --git a/libs/remix-ui/run-tab/src/lib/components/account.tsx b/libs/remix-ui/run-tab/src/lib/components/account.tsx index 86e6132ca7..17a2e70394 100644 --- a/libs/remix-ui/run-tab/src/lib/components/account.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/account.tsx @@ -18,7 +18,9 @@ export function AccountUI(props: AccountProps) { const intl = useIntl() useEffect(() => { - if (!selectedAccount && accounts.length > 0) props.setAccount(accounts[0]) + if ((!selectedAccount || !accounts.includes(selectedAccount)) && accounts.length > 0) { + props.setAccount(accounts[0]) + } }, [accounts, selectedAccount]) useEffect(() => {