From 00c7e780a025685d8f9129927f1e9259a8122392 Mon Sep 17 00:00:00 2001
From: Ritvik Puranik <ritvik@Ritviks-Mac-mini.local>
Date: Wed, 29 Jan 2025 03:27:59 +0530
Subject: [PATCH] fixed issue#5674 - for injected providers, it was looking for
 a selected account by default. if there's no selected account(-null),
 toChecksumAddress() was throwing an error, causing the dispatcher to
 propagate the error. My fix sets the first account as default selected
 account - once the user explicitly sets an account, it behaves as usual

---
 libs/remix-ui/run-tab/src/lib/actions/account.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 503471b9e30..fca9c5c45bb 100644
--- a/libs/remix-ui/run-tab/src/lib/actions/account.ts
+++ b/libs/remix-ui/run-tab/src/lib/actions/account.ts
@@ -31,7 +31,7 @@ export const fillAccountsList = async (plugin: RunTab, dispatch: React.Dispatch<
       const provider = plugin.blockchain.getProvider()
 
       if (provider && provider.startsWith('injected')) {
-        const selectedAddress = plugin.blockchain.getInjectedWeb3Address()
+        const selectedAddress = plugin.blockchain.getInjectedWeb3Address() || Object.keys(loadedAccounts)[0]; //Setting default account to first account
         if (!(Object.keys(loadedAccounts).includes(toChecksumAddress(selectedAddress)))) setAccount(dispatch, null)
       }
       dispatch(fetchAccountsListSuccess(loadedAccounts))