mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Adding one or more tokens sets the selected token before returning the user to the main screen. (#2995)
This commit is contained in:
parent
77eb7b2db6
commit
d7a1019a2c
@ -1,5 +1,6 @@
|
|||||||
const abi = require('human-standard-token-abi')
|
const abi = require('human-standard-token-abi')
|
||||||
const getBuyEthUrl = require('../../app/scripts/lib/buy-eth-url')
|
const getBuyEthUrl = require('../../app/scripts/lib/buy-eth-url')
|
||||||
|
const { getTokenAddressFromTokenObject } = require('./util')
|
||||||
const ethUtil = require('ethereumjs-util')
|
const ethUtil = require('ethereumjs-util')
|
||||||
|
|
||||||
var actions = {
|
var actions = {
|
||||||
@ -1094,10 +1095,12 @@ function removeToken (address) {
|
|||||||
function addTokens (tokens) {
|
function addTokens (tokens) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
if (Array.isArray(tokens)) {
|
if (Array.isArray(tokens)) {
|
||||||
|
dispatch(actions.setSelectedToken(getTokenAddressFromTokenObject(tokens[0])))
|
||||||
return Promise.all(tokens.map(({ address, symbol, decimals }) => (
|
return Promise.all(tokens.map(({ address, symbol, decimals }) => (
|
||||||
dispatch(addToken(address, symbol, decimals))
|
dispatch(addToken(address, symbol, decimals))
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
|
dispatch(actions.setSelectedToken(getTokenAddressFromTokenObject(tokens)))
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
Object
|
Object
|
||||||
.entries(tokens)
|
.entries(tokens)
|
||||||
|
@ -56,6 +56,7 @@ module.exports = {
|
|||||||
exportAsFile: exportAsFile,
|
exportAsFile: exportAsFile,
|
||||||
isInvalidChecksumAddress,
|
isInvalidChecksumAddress,
|
||||||
allNull,
|
allNull,
|
||||||
|
getTokenAddressFromTokenObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
function valuesFor (obj) {
|
function valuesFor (obj) {
|
||||||
@ -281,3 +282,7 @@ function exportAsFile (filename, data) {
|
|||||||
function allNull (obj) {
|
function allNull (obj) {
|
||||||
return Object.entries(obj).every(([key, value]) => value === null)
|
return Object.entries(obj).every(([key, value]) => value === null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTokenAddressFromTokenObject (token) {
|
||||||
|
return Object.values(token)[0].address.toLowerCase()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user