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

Allow updating token details

Fixes #2173
This commit is contained in:
Dan Finlay 2017-12-18 15:57:04 -08:00
parent 9bb701f063
commit 975f7279c7

View File

@ -26,23 +26,23 @@ class PreferencesController {
return this.store.getState().selectedAddress
}
addToken (rawAddress, symbol, decimals) {
async addToken (rawAddress, symbol, decimals) {
const address = normalizeAddress(rawAddress)
const newEntry = { address, symbol, decimals }
const tokens = this.store.getState().tokens
const previousIndex = tokens.find((token, index) => {
const previousEntry = tokens.find((token, index) => {
return token.address === address
})
const previousIndex = tokens.indexOf(previousEntry)
if (previousIndex) {
if (previousEntry) {
tokens[previousIndex] = newEntry
} else {
tokens.push(newEntry)
}
this.store.updateState({ tokens })
return Promise.resolve()
}
getTokens () {