aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
authorDan <danjm.com@gmail.com>2017-10-18 01:22:23 +0800
committerChi Kei Chan <chikeichan@gmail.com>2017-10-19 11:21:46 +0800
commitf81226fbe9f98d5a6c408e289fa0ea61a467e7dc (patch)
treed2aba01747012ad1eb7829521647b71f88c114fe /ui/app/components
parent4f9ac1c4fe67ec4c196ce1891ecc1743552d45ce (diff)
downloadtangerine-wallet-browser-f81226fbe9f98d5a6c408e289fa0ea61a467e7dc.tar.gz
tangerine-wallet-browser-f81226fbe9f98d5a6c408e289fa0ea61a467e7dc.tar.zst
tangerine-wallet-browser-f81226fbe9f98d5a6c408e289fa0ea61a467e7dc.zip
Move all of send state to metamask state.
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/customize-gas-modal/index.js11
-rw-r--r--ui/app/components/send/from-dropdown.js2
-rw-r--r--ui/app/components/send/gas-fee-display-v2.js17
-rw-r--r--ui/app/components/send/send-v2-container.js13
4 files changed, 24 insertions, 19 deletions
diff --git a/ui/app/components/customize-gas-modal/index.js b/ui/app/components/customize-gas-modal/index.js
index 2df24b4e1..0ba768893 100644
--- a/ui/app/components/customize-gas-modal/index.js
+++ b/ui/app/components/customize-gas-modal/index.js
@@ -5,7 +5,7 @@ const connect = require('react-redux').connect
const actions = require('../../actions')
const GasModalCard = require('./gas-modal-card')
-const { conversionUtil } = require('../../conversion-util')
+const { conversionUtil, multiplyCurrencies } = require('../../conversion-util')
const {
getGasPrice,
@@ -26,6 +26,7 @@ function mapDispatchToProps (dispatch) {
hideModal: () => dispatch(actions.hideModal()),
updateGasPrice: newGasPrice => dispatch(actions.updateGasPrice(newGasPrice)),
updateGasLimit: newGasLimit => dispatch(actions.updateGasLimit(newGasLimit)),
+ updateGasTotal: newGasTotal => dispatch(actions.updateGasTotal(newGasTotal)),
}
}
@@ -46,10 +47,18 @@ CustomizeGasModal.prototype.save = function (gasPrice, gasLimit) {
updateGasPrice,
updateGasLimit,
hideModal,
+ updateGasTotal
} = this.props
+ const newGasTotal = multiplyCurrencies(gasLimit, gasPrice, {
+ toNumericBase: 'hex',
+ multiplicandBase: 16,
+ multiplierBase: 16,
+ })
+
updateGasPrice(gasPrice)
updateGasLimit(gasLimit)
+ updateGasTotal(newGasTotal)
hideModal()
}
diff --git a/ui/app/components/send/from-dropdown.js b/ui/app/components/send/from-dropdown.js
index fd6fb7e64..6f2b9da68 100644
--- a/ui/app/components/send/from-dropdown.js
+++ b/ui/app/components/send/from-dropdown.js
@@ -38,7 +38,7 @@ FromDropdown.prototype.renderDropdown = function () {
...accounts.map(account => h(AccountListItem, {
account,
handleClick: () => {
- onSelect(account.address)
+ onSelect(account)
closeDropdown()
},
icon: this.getListItemIcon(account, selectedAccount),
diff --git a/ui/app/components/send/gas-fee-display-v2.js b/ui/app/components/send/gas-fee-display-v2.js
index 961d55610..7c3913c7f 100644
--- a/ui/app/components/send/gas-fee-display-v2.js
+++ b/ui/app/components/send/gas-fee-display-v2.js
@@ -1,9 +1,7 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
-const CurrencyDisplay = require('./currency-display');
-
-const { multiplyCurrencies } = require('../../conversion-util')
+const CurrencyDisplay = require('./currency-display')
module.exports = GasFeeDisplay
@@ -15,24 +13,17 @@ function GasFeeDisplay () {
GasFeeDisplay.prototype.render = function () {
const {
conversionRate,
- gasLimit,
- gasPrice,
+ gasTotal,
onClick,
} = this.props
- const readyToRender = Boolean(gasLimit && gasPrice)
-
return h('div', [
- readyToRender
+ gasTotal
? h(CurrencyDisplay, {
primaryCurrency: 'ETH',
convertedCurrency: 'USD',
- value: multiplyCurrencies(gasLimit, gasPrice, {
- toNumericBase: 'hex',
- multiplicandBase: 16,
- multiplierBase: 16,
- }),
+ value: gasTotal,
conversionRate,
convertedPrefix: '$',
readOnly: true,
diff --git a/ui/app/components/send/send-v2-container.js b/ui/app/components/send/send-v2-container.js
index 8ac5cc961..dcf764048 100644
--- a/ui/app/components/send/send-v2-container.js
+++ b/ui/app/components/send/send-v2-container.js
@@ -15,6 +15,7 @@ const {
getGasPrice,
getGasLimit,
getAddressBook,
+ getSendFrom,
} = require('../../selectors')
module.exports = connect(mapStateToProps, mapDispatchToProps)(SendEther)
@@ -46,16 +47,15 @@ function mapStateToProps (state) {
}
return {
- selectedAccount: getCurrentAccountWithSendEtherInfo(state),
+ ...state.metamask.send,
+ from: getSendFrom(state) || getCurrentAccountWithSendEtherInfo(state),
fromAccounts,
toAccounts: [...fromAccounts, ...getAddressBook(state)],
conversionRate,
selectedToken,
primaryCurrency,
data,
- tokenToUSDRate,
- gasPrice: getGasPrice(state),
- gasLimit: getGasLimit(state),
+ amountConversionRate: selectedToken ? tokenToUSDRate : conversionRate,
}
}
@@ -71,5 +71,10 @@ function mapDispatchToProps (dispatch) {
signTx: txParams => dispatch(actions.signTx(txParams)),
setSelectedAddress: address => dispatch(actions.setSelectedAddress(address)),
addToAddressBook: address => dispatch(actions.addToAddressBook(address)),
+ updateGasTotal: newTotal => dispatch(actions.updateGasTotal(newTotal)),
+ updateSendFrom: newFrom => dispatch(actions.updateSendFrom(newFrom)),
+ updateSendTo: newTo => dispatch(actions.updateSendTo(newTo)),
+ updateSendAmount: newAmount => dispatch(actions.updateSendAmount(newAmount)),
+ updateSendMemo: newMemo => dispatch(actions.updateSendMemo(newMemo)),
}
}