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 4d937cdc5eb..ac499e4a107 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/account.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/account.ts @@ -56,7 +56,7 @@ const _getProviderDropdownValue = (plugin: RunTab): string => { return plugin.blockchain.getProvider() } -export const setExecutionContext = (plugin: RunTab, dispatch: React.Dispatch, executionContext: { context: string, fork: string }) => { +export const setExecutionContext = (plugin: RunTab, dispatch: React.Dispatch, executionContext: { context: string, fork?: string }) => { plugin.blockchain.changeExecutionContext(executionContext, null, (alertMsg) => { plugin.call('notification', 'toast', alertMsg) }, () => { setFinalContext(plugin, dispatch) }) diff --git a/libs/remix-ui/run-tab/src/lib/actions/events.ts b/libs/remix-ui/run-tab/src/lib/actions/events.ts index 2e06963e11a..a82c64272be 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/events.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/events.ts @@ -127,8 +127,12 @@ export const setupEvents = (plugin: RunTab) => { if (activatedPlugin && activatedPlugin.name.startsWith('injected')) { plugin.on(activatedPlugin.name, 'accountsChanged', (accounts: Array) => { const accountsMap = {} + if (accounts.length > 0) { accounts.map(account => { accountsMap[account] = shortenAddress(account, '0')}) dispatch(fetchAccountsListSuccess(accountsMap)) + } else { + setExecutionContext(plugin, dispatch, { context: plugin.blockchain.defaultPinnedProviders[0] }) + } }) } else if (activatedPlugin && activatedPlugin.name === 'walletconnect') { plugin.on('walletconnect', 'accountsChanged', async (accounts: Array) => { diff --git a/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts b/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts index 428c782a8e1..c5dd7e31835 100644 --- a/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts +++ b/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts @@ -25,6 +25,7 @@ export class Blockchain extends Plugin { }; setupProviders(): void; providers: any; + defaultPinnedProviders: string[] getCurrentProvider(): any; /** Return the list of accounts */ getAccounts(cb?: any): any;