Handle transaction totals in WEI in tx-list, send and pending.

feature/default_network_editable
Dan 7 years ago committed by Chi Kei Chan
parent b0f1fba2e5
commit 54bbf8d859
  1. 4
      ui/app/components/pending-tx.js
  2. 2
      ui/app/components/tx-list-item.js
  3. 6
      ui/app/conversion-util.js
  4. 5
      ui/app/send.js

@ -88,6 +88,7 @@ PendingTx.prototype.getTotal = function () {
fromCurrency: 'ETH', fromCurrency: 'ETH',
toCurrency: 'USD', toCurrency: 'USD',
numberOfDecimals: 2, numberOfDecimals: 2,
fromDenomination: 'WEI',
conversionRate, conversionRate,
}) })
const ETH = conversionUtil(amountBn, { const ETH = conversionUtil(amountBn, {
@ -95,6 +96,7 @@ PendingTx.prototype.getTotal = function () {
toNumericBase: 'dec', toNumericBase: 'dec',
fromCurrency: 'ETH', fromCurrency: 'ETH',
toCurrency: 'ETH', toCurrency: 'ETH',
fromDenomination: 'WEI',
conversionRate, conversionRate,
numberOfDecimals: 6, numberOfDecimals: 6,
}) })
@ -109,6 +111,7 @@ PendingTx.prototype.getTotal = function () {
fromCurrency: 'ETH', fromCurrency: 'ETH',
toCurrency: 'USD', toCurrency: 'USD',
numberOfDecimals: 2, numberOfDecimals: 2,
fromDenomination: 'WEI',
conversionRate, conversionRate,
}) })
const ETH = conversionUtil(amountBn, { const ETH = conversionUtil(amountBn, {
@ -116,6 +119,7 @@ PendingTx.prototype.getTotal = function () {
toNumericBase: 'dec', toNumericBase: 'dec',
fromCurrency: 'ETH', fromCurrency: 'ETH',
toCurrency: 'ETH', toCurrency: 'ETH',
fromDenomination: 'WEI',
conversionRate, conversionRate,
numberOfDecimals: 6, numberOfDecimals: 6,
}) })

@ -60,6 +60,7 @@ TxListItem.prototype.getSendEtherTotal = function () {
toNumericBase: 'dec', toNumericBase: 'dec',
fromCurrency: 'ETH', fromCurrency: 'ETH',
toCurrency: 'USD', toCurrency: 'USD',
fromDenomination: 'WEI',
numberOfDecimals: 2, numberOfDecimals: 2,
conversionRate, conversionRate,
}) })
@ -68,6 +69,7 @@ TxListItem.prototype.getSendEtherTotal = function () {
toNumericBase: 'dec', toNumericBase: 'dec',
fromCurrency: 'ETH', fromCurrency: 'ETH',
toCurrency: 'ETH', toCurrency: 'ETH',
fromDenomination: 'WEI',
conversionRate, conversionRate,
numberOfDecimals: 6, numberOfDecimals: 6,
}) })

@ -46,6 +46,9 @@ const toBigNumber = {
const toNormalizedDenomination = { const toNormalizedDenomination = {
WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER) WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER)
} }
const toSpecifiedDenomination = {
WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER)
}
const baseChange = { const baseChange = {
hex: n => n.toString(16), hex: n => n.toString(16),
dec: n => n.toString(10), dec: n => n.toString(10),
@ -80,6 +83,7 @@ const whenPropApplySetterMap = (prop, setterMap) => whenPredSetWithPropAndSetter
const converter = R.pipe( const converter = R.pipe(
whenPropApplySetterMap('fromNumericBase', toBigNumber), whenPropApplySetterMap('fromNumericBase', toBigNumber),
whenPropApplySetterMap('fromDenomination', toNormalizedDenomination), whenPropApplySetterMap('fromDenomination', toNormalizedDenomination),
whenPropApplySetterMap('toDenomination', toSpecifiedDenomination),
whenPredSetWithPropAndSetter(fromAndToCurrencyPropsNotEqual, 'conversionRate', convert), whenPredSetWithPropAndSetter(fromAndToCurrencyPropsNotEqual, 'conversionRate', convert),
whenPredSetWithPropAndSetter(R.prop('ethToUSDRate'), 'ethToUSDRate', convert), whenPredSetWithPropAndSetter(R.prop('ethToUSDRate'), 'ethToUSDRate', convert),
whenPredSetWithPropAndSetter(R.prop('numberOfDecimals'), 'numberOfDecimals', round), whenPredSetWithPropAndSetter(R.prop('numberOfDecimals'), 'numberOfDecimals', round),
@ -93,6 +97,7 @@ const conversionUtil = (value, {
fromNumericBase, fromNumericBase,
toNumericBase, toNumericBase,
fromDenomination, fromDenomination,
toDenomination,
numberOfDecimals, numberOfDecimals,
conversionRate, conversionRate,
ethToUSDRate, ethToUSDRate,
@ -102,6 +107,7 @@ const conversionUtil = (value, {
fromNumericBase, fromNumericBase,
toNumericBase, toNumericBase,
fromDenomination, fromDenomination,
toDenomination,
numberOfDecimals, numberOfDecimals,
conversionRate, conversionRate,
ethToUSDRate, ethToUSDRate,

@ -400,15 +400,16 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
this.props.dispatch(addToAddressBook(recipient, nickname)) this.props.dispatch(addToAddressBook(recipient, nickname))
// TODO: need a clean way to integrate this into conversionUtil // TODO: need a clean way to integrate this into conversionUtil
const sendConversionRate = this.props.currentCurrency === 'ETH' const sendConversionRate = state.activeCurrency === 'ETH'
? this.props.conversionRate ? this.props.conversionRate
: new BigNumber(1.0).div(this.props.conversionRate) : new BigNumber(1.0).div(this.props.conversionRate)
const sendAmount = conversionUtil(this.state.newTx.amount, { const sendAmount = conversionUtil(this.state.newTx.amount, {
fromNumericBase: 'dec', fromNumericBase: 'dec',
toNumericBase: 'hex', toNumericBase: 'hex',
fromCurrency: this.props.currentCurrency, fromCurrency: state.activeCurrency,
toCurrency: 'ETH', toCurrency: 'ETH',
toDenomination: 'WEI',
conversionRate: sendConversionRate, conversionRate: sendConversionRate,
}) })

Loading…
Cancel
Save