mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
add & delete tokens per network
This commit is contained in:
parent
1d3ad7cfbb
commit
2827e13caa
@ -204,20 +204,18 @@ class PreferencesController {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
setSelectedAddress (_address) {
|
setSelectedAddress (_address) {
|
||||||
return new Promise((resolve, reject) => {
|
const address = normalizeAddress(_address)
|
||||||
const address = normalizeAddress(_address)
|
const addressTokens = this.store.getState().addressTokens
|
||||||
const addressTokens = this.store.getState().addressTokens
|
const providerType = this.network.providerStore.getState().type
|
||||||
const providerType = this.network.providerStore.getState().type
|
|
||||||
|
|
||||||
if (!(providerType in addressTokens)) addressTokens[providerType] = {}
|
if (!(providerType in addressTokens)) addressTokens[providerType] = {}
|
||||||
|
|
||||||
if (!(address in addressTokens[providerType])) addressTokens[providerType][address] = []
|
if (!(address in addressTokens[providerType])) addressTokens[providerType][address] = []
|
||||||
|
|
||||||
const tokens = addressTokens[providerType][address]
|
const tokens = addressTokens[providerType][address]
|
||||||
|
|
||||||
this.store.updateState({ selectedAddress: address, tokens })
|
this.store.updateState({ selectedAddress: address, tokens })
|
||||||
resolve()
|
return Promise.resolve(tokens)
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1483,11 +1483,12 @@ function showAccountDetail (address) {
|
|||||||
return (dispatch) => {
|
return (dispatch) => {
|
||||||
dispatch(actions.showLoadingIndication())
|
dispatch(actions.showLoadingIndication())
|
||||||
log.debug(`background.setSelectedAddress`)
|
log.debug(`background.setSelectedAddress`)
|
||||||
background.setSelectedAddress(address, (err) => {
|
background.setSelectedAddress(address, (err, tokens) => {
|
||||||
dispatch(actions.hideLoadingIndication())
|
dispatch(actions.hideLoadingIndication())
|
||||||
if (err) {
|
if (err) {
|
||||||
return dispatch(actions.displayWarning(err.message))
|
return dispatch(actions.displayWarning(err.message))
|
||||||
}
|
}
|
||||||
|
dispatch(updateTokens(tokens))
|
||||||
dispatch({
|
dispatch({
|
||||||
type: actions.SHOW_ACCOUNT_DETAIL,
|
type: actions.SHOW_ACCOUNT_DETAIL,
|
||||||
value: address,
|
value: address,
|
||||||
|
Loading…
Reference in New Issue
Block a user