aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/conf-tx.js
diff options
context:
space:
mode:
authorFrankie <frankie.pangilinan@consensys.net>2016-09-16 05:31:45 +0800
committerFrankie <frankie.pangilinan@consensys.net>2016-09-16 05:31:45 +0800
commitcf484d735fab021a0dfe509243b957e8c6278532 (patch)
tree521c1baf581454c29b05c53a6598d5ec6fe8caa4 /ui/app/conf-tx.js
parent7293c67f686516485ea1a06fb3ee15094630da3e (diff)
downloadtangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.tar
tangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.tar.gz
tangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.tar.bz2
tangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.tar.lz
tangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.tar.xz
tangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.tar.zst
tangerine-wallet-browser-cf484d735fab021a0dfe509243b957e8c6278532.zip
Clean up some of the code
Diffstat (limited to 'ui/app/conf-tx.js')
-rw-r--r--ui/app/conf-tx.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index 8cbb1f44f..f4ca52860 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -41,6 +41,7 @@ ConfirmTxScreen.prototype.render = function () {
var unconfTxList = txHelper(unconfTxs, unconfMsgs, network)
var index = state.index !== undefined ? state.index : 0
var txData = unconfTxList[index] || unconfTxList[0] || {}
+ var txParams = txData.txParams || {}
var isNotification = isPopupOrNotification() === 'notification'
return (
@@ -92,7 +93,9 @@ ConfirmTxScreen.prototype.render = function () {
selectedAddress: state.selectedAddress,
accounts: state.accounts,
identities: state.identities,
+ insufficientBalance: this.checkBalnceAgainstTx(txData),
// Actions
+ buyEth: this.buyEth.bind(this, txParams.from || state.selectedAddress),
sendTransaction: this.sendTransaction.bind(this, txData),
cancelTransaction: this.cancelTransaction.bind(this, txData),
signMessage: this.signMessage.bind(this, txData),
@@ -113,8 +116,7 @@ function currentTxView (opts) {
return h(PendingMsg, opts)
}
}
-
-ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
+ConfirmTxScreen.prototype.checkBalnceAgainstTx = function (txData) {
var state = this.props
var txParams = txData.txParams || {}
@@ -129,12 +131,17 @@ ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
var maxCost = txValue.add(txFee)
var balanceBn = new BN(ethUtil.stripHexPrefix(balance), 16)
+ return maxCost.gt(balanceBn)
+}
+
+ConfirmTxScreen.prototype.buyEth = function (address, event) {
event.stopPropagation()
- if (maxCost.gt(balanceBn)) {
- this.props.dispatch(actions.buyEthView(address))
- } else {
- this.props.dispatch(actions.sendTx(txData))
- }
+ this.props.dispatch(actions.buyEthView(address))
+}
+
+ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
+ event.stopPropagation()
+ this.props.dispatch(actions.sendTx(txData))
}
ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {