mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Merge pull request #5465 from alextsg/fix-values
Fix token values being undefined
This commit is contained in:
commit
23fa223040
@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import CurrencyDisplay from '../currency-display/currency-display.component'
|
import CurrencyDisplay from '../currency-display/currency-display.component'
|
||||||
import { getTokenData } from '../../helpers/transactions.util'
|
import { getTokenData } from '../../helpers/transactions.util'
|
||||||
import { calcTokenAmount } from '../../token-util'
|
import { getTokenValue, calcTokenAmount } from '../../token-util'
|
||||||
|
|
||||||
export default class TokenCurrencyDisplay extends PureComponent {
|
export default class TokenCurrencyDisplay extends PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -34,8 +34,8 @@ export default class TokenCurrencyDisplay extends PureComponent {
|
|||||||
|
|
||||||
let displayValue
|
let displayValue
|
||||||
|
|
||||||
if (tokenData.params && tokenData.params.length === 2) {
|
if (tokenData.params && tokenData.params.length) {
|
||||||
const tokenValue = tokenData.params[1].value
|
const tokenValue = getTokenValue(tokenData.params)
|
||||||
const tokenAmount = calcTokenAmount(tokenValue, decimals)
|
const tokenAmount = calcTokenAmount(tokenValue, decimals)
|
||||||
displayValue = `${tokenAmount} ${symbol}`
|
displayValue = `${tokenAmount} ${symbol}`
|
||||||
}
|
}
|
||||||
|
@ -111,3 +111,8 @@ export function calcTokenAmount (value, decimals) {
|
|||||||
const multiplier = Math.pow(10, Number(decimals || 0))
|
const multiplier = Math.pow(10, Number(decimals || 0))
|
||||||
return new BigNumber(String(value)).div(multiplier).toNumber()
|
return new BigNumber(String(value)).div(multiplier).toNumber()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getTokenValue (tokenParams = []) {
|
||||||
|
const valueData = tokenParams.find(param => param.name === '_value')
|
||||||
|
return valueData && valueData.value
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user