Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setExecutionContext for empty accounts list #5498

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/remix-ui/run-tab/src/lib/actions/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const _getProviderDropdownValue = (plugin: RunTab): string => {
return plugin.blockchain.getProvider()
}

export const setExecutionContext = (plugin: RunTab, dispatch: React.Dispatch<any>, executionContext: { context: string, fork: string }) => {
export const setExecutionContext = (plugin: RunTab, dispatch: React.Dispatch<any>, executionContext: { context: string, fork?: string }) => {
plugin.blockchain.changeExecutionContext(executionContext, null, (alertMsg) => {
plugin.call('notification', 'toast', alertMsg)
}, () => { setFinalContext(plugin, dispatch) })
Expand Down
4 changes: 4 additions & 0 deletions libs/remix-ui/run-tab/src/lib/actions/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,12 @@ export const setupEvents = (plugin: RunTab) => {
if (activatedPlugin && activatedPlugin.name.startsWith('injected')) {
plugin.on(activatedPlugin.name, 'accountsChanged', (accounts: Array<string>) => {
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<string>) => {
Expand Down
1 change: 1 addition & 0 deletions libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class Blockchain extends Plugin<any, any> {
};
setupProviders(): void;
providers: any;
defaultPinnedProviders: string[]
getCurrentProvider(): any;
/** Return the list of accounts */
getAccounts(cb?: any): any;
Expand Down