aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-09-14 10:20:13 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-09-16 07:23:23 +0800
commit54bbf8d8590014b92e7857f30bdc2d8f3779431a (patch)
tree0d9a5939fad15afe90b61de390fffb5f2d9ba9cd /ui
parentb0f1fba2e5fbde573b46a284285985e63f1a3618 (diff)
downloadtangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.tar
tangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.tar.gz
tangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.tar.bz2
tangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.tar.lz
tangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.tar.xz
tangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.tar.zst
tangerine-wallet-browser-54bbf8d8590014b92e7857f30bdc2d8f3779431a.zip
Handle transaction totals in WEI in tx-list, send and pending.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/components/pending-tx.js4
-rw-r--r--ui/app/components/tx-list-item.js2
-rw-r--r--ui/app/conversion-util.js6
-rw-r--r--ui/app/send.js5
4 files changed, 15 insertions, 2 deletions
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 6eb2fb2b2..c1b079a25 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -88,6 +88,7 @@ PendingTx.prototype.getTotal = function () {
fromCurrency: 'ETH',
toCurrency: 'USD',
numberOfDecimals: 2,
+ fromDenomination: 'WEI',
conversionRate,
})
const ETH = conversionUtil(amountBn, {
@@ -95,6 +96,7 @@ PendingTx.prototype.getTotal = function () {
toNumericBase: 'dec',
fromCurrency: 'ETH',
toCurrency: 'ETH',
+ fromDenomination: 'WEI',
conversionRate,
numberOfDecimals: 6,
})
@@ -109,6 +111,7 @@ PendingTx.prototype.getTotal = function () {
fromCurrency: 'ETH',
toCurrency: 'USD',
numberOfDecimals: 2,
+ fromDenomination: 'WEI',
conversionRate,
})
const ETH = conversionUtil(amountBn, {
@@ -116,6 +119,7 @@ PendingTx.prototype.getTotal = function () {
toNumericBase: 'dec',
fromCurrency: 'ETH',
toCurrency: 'ETH',
+ fromDenomination: 'WEI',
conversionRate,
numberOfDecimals: 6,
})
diff --git a/ui/app/components/tx-list-item.js b/ui/app/components/tx-list-item.js
index d45aea964..8422c02b9 100644
--- a/ui/app/components/tx-list-item.js
+++ b/ui/app/components/tx-list-item.js
@@ -60,6 +60,7 @@ TxListItem.prototype.getSendEtherTotal = function () {
toNumericBase: 'dec',
fromCurrency: 'ETH',
toCurrency: 'USD',
+ fromDenomination: 'WEI',
numberOfDecimals: 2,
conversionRate,
})
@@ -68,6 +69,7 @@ TxListItem.prototype.getSendEtherTotal = function () {
toNumericBase: 'dec',
fromCurrency: 'ETH',
toCurrency: 'ETH',
+ fromDenomination: 'WEI',
conversionRate,
numberOfDecimals: 6,
})
diff --git a/ui/app/conversion-util.js b/ui/app/conversion-util.js
index 847650758..b440aea7f 100644
--- a/ui/app/conversion-util.js
+++ b/ui/app/conversion-util.js
@@ -46,6 +46,9 @@ const toBigNumber = {
const toNormalizedDenomination = {
WEI: bigNumber => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER)
}
+const toSpecifiedDenomination = {
+ WEI: bigNumber => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER)
+}
const baseChange = {
hex: n => n.toString(16),
dec: n => n.toString(10),
@@ -80,6 +83,7 @@ const whenPropApplySetterMap = (prop, setterMap) => whenPredSetWithPropAndSetter
const converter = R.pipe(
whenPropApplySetterMap('fromNumericBase', toBigNumber),
whenPropApplySetterMap('fromDenomination', toNormalizedDenomination),
+ whenPropApplySetterMap('toDenomination', toSpecifiedDenomination),
whenPredSetWithPropAndSetter(fromAndToCurrencyPropsNotEqual, 'conversionRate', convert),
whenPredSetWithPropAndSetter(R.prop('ethToUSDRate'), 'ethToUSDRate', convert),
whenPredSetWithPropAndSetter(R.prop('numberOfDecimals'), 'numberOfDecimals', round),
@@ -93,6 +97,7 @@ const conversionUtil = (value, {
fromNumericBase,
toNumericBase,
fromDenomination,
+ toDenomination,
numberOfDecimals,
conversionRate,
ethToUSDRate,
@@ -102,6 +107,7 @@ const conversionUtil = (value, {
fromNumericBase,
toNumericBase,
fromDenomination,
+ toDenomination,
numberOfDecimals,
conversionRate,
ethToUSDRate,
diff --git a/ui/app/send.js b/ui/app/send.js
index 4e7fdb705..b14c48e56 100644
--- a/ui/app/send.js
+++ b/ui/app/send.js
@@ -400,15 +400,16 @@ SendTransactionScreen.prototype.onSubmit = function (event) {
this.props.dispatch(addToAddressBook(recipient, nickname))
// TODO: need a clean way to integrate this into conversionUtil
- const sendConversionRate = this.props.currentCurrency === 'ETH'
+ const sendConversionRate = state.activeCurrency === 'ETH'
? this.props.conversionRate
: new BigNumber(1.0).div(this.props.conversionRate)
const sendAmount = conversionUtil(this.state.newTx.amount, {
fromNumericBase: 'dec',
toNumericBase: 'hex',
- fromCurrency: this.props.currentCurrency,
+ fromCurrency: state.activeCurrency,
toCurrency: 'ETH',
+ toDenomination: 'WEI',
conversionRate: sendConversionRate,
})