mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
4c87c05a02
* Fix rounding issue when sending max tokens * Ensure amount row shows exact amount of max tokens on send screen (#2) * Fix tests * Change stored redux value from BigNumber to hex string. Fix TokenInput default value
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
import { connect } from 'react-redux'
|
|
import CurrencyDisplay from './currency-display.component'
|
|
import { getValueFromWeiHex, formatCurrency } from '../../helpers/confirm-transaction/util'
|
|
|
|
const mapStateToProps = state => {
|
|
const { metamask: { nativeCurrency, currentCurrency, conversionRate } } = state
|
|
|
|
return {
|
|
currentCurrency,
|
|
conversionRate,
|
|
nativeCurrency,
|
|
}
|
|
}
|
|
|
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
|
const { nativeCurrency, currentCurrency, conversionRate, ...restStateProps } = stateProps
|
|
const {
|
|
value,
|
|
numberOfDecimals = 2,
|
|
currency,
|
|
denomination,
|
|
hideLabel,
|
|
displayValue: propsDisplayValue,
|
|
suffix: propsSuffix,
|
|
...restOwnProps
|
|
} = ownProps
|
|
|
|
const toCurrency = currency || currentCurrency
|
|
|
|
const displayValue = propsDisplayValue || formatCurrency(
|
|
getValueFromWeiHex({
|
|
value,
|
|
fromCurrency: nativeCurrency,
|
|
toCurrency, conversionRate,
|
|
numberOfDecimals,
|
|
toDenomination: denomination,
|
|
}),
|
|
toCurrency
|
|
)
|
|
const suffix = propsSuffix || (hideLabel ? undefined : toCurrency.toUpperCase())
|
|
|
|
return {
|
|
...restStateProps,
|
|
...dispatchProps,
|
|
...restOwnProps,
|
|
displayValue,
|
|
suffix,
|
|
}
|
|
}
|
|
|
|
export default connect(mapStateToProps, null, mergeProps)(CurrencyDisplay)
|