1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Update tokens after importing account (#8491)

Tokens are now updated when the account switches after a failed account
import. The usual account switching flow (via the account menu) already
updated tokens, but this step was omitted when the account switched
after a failed import.
This commit is contained in:
Mark Stacey 2020-05-01 13:56:46 -03:00 committed by GitHub
parent 5b5b67a985
commit 902ed3d649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1159,12 +1159,18 @@ export function setSelectedToken (tokenAddress) {
} }
} }
async function _setSelectedAddress (dispatch, address) {
log.debug(`background.setSelectedAddress`)
const tokens = await promisifiedBackground.setSelectedAddress(address)
dispatch(updateTokens(tokens))
}
export function setSelectedAddress (address) { export function setSelectedAddress (address) {
return async (dispatch) => { return async (dispatch) => {
dispatch(showLoadingIndication()) dispatch(showLoadingIndication())
log.debug(`background.setSelectedAddress`) log.debug(`background.setSelectedAddress`)
try { try {
await promisifiedBackground.setSelectedAddress(address) await _setSelectedAddress(dispatch, address)
} catch (error) { } catch (error) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
dispatch(displayWarning(error.message)) dispatch(displayWarning(error.message))
@ -1186,16 +1192,14 @@ export function showAccountDetail (address) {
const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address) const currentTabIsConnectedToNextAddress = permittedAccountsForCurrentTab.includes(address)
const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress const switchingToUnconnectedAddress = currentTabIsConnectedToPreviousAddress && !currentTabIsConnectedToNextAddress
let tokens
try { try {
tokens = await promisifiedBackground.setSelectedAddress(address) await _setSelectedAddress(dispatch, address)
} catch (error) { } catch (error) {
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
dispatch(displayWarning(error.message)) dispatch(displayWarning(error.message))
return return
} }
dispatch(hideLoadingIndication()) dispatch(hideLoadingIndication())
dispatch(updateTokens(tokens))
dispatch({ dispatch({
type: actionConstants.SHOW_ACCOUNT_DETAIL, type: actionConstants.SHOW_ACCOUNT_DETAIL,
value: address, value: address,