aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-03-02 02:01:21 +0800
committerKevin Serrano <kevgagser@gmail.com>2017-03-02 02:01:21 +0800
commit0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66 (patch)
treecb569b1419363928282cd9ae0b4862d436c8fa58 /ui
parent930dafc4b0648353f847c529cdc19e2d762553ad (diff)
parentf162a11585392df5e593018a02549f8b03018d22 (diff)
downloadtangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.tar
tangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.tar.gz
tangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.tar.bz2
tangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.tar.lz
tangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.tar.xz
tangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.tar.zst
tangerine-wallet-browser-0a3849ec8477b4a61c50d715bd72b3e8f1ea8b66.zip
Fix merge conflicts.
Diffstat (limited to 'ui')
-rw-r--r--ui/app/actions.js120
-rw-r--r--ui/app/app.js2
-rw-r--r--ui/app/components/hex-as-decimal-input.js76
-rw-r--r--ui/app/components/pending-personal-msg-details.js61
-rw-r--r--ui/app/components/pending-personal-msg.js47
-rw-r--r--ui/app/components/pending-tx-details.js145
-rw-r--r--ui/app/components/pending-tx.js26
-rw-r--r--ui/app/components/transaction-list-item-icon.js6
-rw-r--r--ui/app/conf-tx.js97
-rw-r--r--ui/app/css/index.css7
-rw-r--r--ui/app/reducers/app.js35
-rw-r--r--ui/app/send.js73
-rw-r--r--ui/index.js5
-rw-r--r--ui/lib/tx-helper.js14
14 files changed, 534 insertions, 180 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 7e5add1d0..337f05248 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -90,8 +90,11 @@ var actions = {
PREVIOUS_TX: 'PREV_TX',
signMsg: signMsg,
cancelMsg: cancelMsg,
+ signPersonalMsg,
+ cancelPersonalMsg,
sendTx: sendTx,
signTx: signTx,
+ updateAndApproveTx,
cancelTx: cancelTx,
completedTx: completedTx,
txError: txError,
@@ -178,7 +181,7 @@ function tryUnlockMetamask (password) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
dispatch(actions.unlockInProgress())
- if (global.METAMASK_DEBUG) console.log(`background.submitPassword`)
+ log.debug(`background.submitPassword`)
background.submitPassword(password, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
@@ -206,7 +209,7 @@ function transitionBackward () {
function confirmSeedWords () {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.clearSeedWordCache`)
+ log.debug(`background.clearSeedWordCache`)
background.clearSeedWordCache((err, account) => {
dispatch(actions.hideLoadingIndication())
if (err) {
@@ -222,7 +225,7 @@ function confirmSeedWords () {
function createNewVaultAndRestore (password, seed) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.createNewVaultAndRestore`)
+ log.debug(`background.createNewVaultAndRestore`)
background.createNewVaultAndRestore(password, seed, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) return dispatch(actions.displayWarning(err.message))
@@ -234,12 +237,12 @@ function createNewVaultAndRestore (password, seed) {
function createNewVaultAndKeychain (password) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.createNewVaultAndKeychain`)
+ log.debug(`background.createNewVaultAndKeychain`)
background.createNewVaultAndKeychain(password, (err) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
}
- if (global.METAMASK_DEBUG) console.log(`background.placeSeedWords`)
+ log.debug(`background.placeSeedWords`)
background.placeSeedWords((err) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
@@ -260,10 +263,10 @@ function revealSeedConfirmation () {
function requestRevealSeed (password) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.submitPassword`)
+ log.debug(`background.submitPassword`)
background.submitPassword(password, (err) => {
if (err) return dispatch(actions.displayWarning(err.message))
- if (global.METAMASK_DEBUG) console.log(`background.placeSeedWords`)
+ log.debug(`background.placeSeedWords`)
background.placeSeedWords((err) => {
if (err) return dispatch(actions.displayWarning(err.message))
dispatch(actions.hideLoadingIndication())
@@ -275,7 +278,7 @@ function requestRevealSeed (password) {
function addNewKeyring (type, opts) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.addNewKeyring`)
+ log.debug(`background.addNewKeyring`)
background.addNewKeyring(type, opts, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) return dispatch(actions.displayWarning(err.message))
@@ -287,11 +290,11 @@ function addNewKeyring (type, opts) {
function importNewAccount (strategy, args) {
return (dispatch) => {
dispatch(actions.showLoadingIndication('This may take a while, be patient.'))
- if (global.METAMASK_DEBUG) console.log(`background.importAccountWithStrategy`)
+ log.debug(`background.importAccountWithStrategy`)
background.importAccountWithStrategy(strategy, args, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) return dispatch(actions.displayWarning(err.message))
- if (global.METAMASK_DEBUG) console.log(`background.getState`)
+ log.debug(`background.getState`)
background.getState((err, newState) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
@@ -313,7 +316,7 @@ function navigateToNewAccountScreen() {
}
function addNewAccount () {
- if (global.METAMASK_DEBUG) console.log(`background.addNewAccount`)
+ log.debug(`background.addNewAccount`)
return callBackgroundThenUpdate(background.addNewAccount)
}
@@ -326,7 +329,7 @@ function showInfoPage () {
function setCurrentFiat (currencyCode) {
return (dispatch) => {
dispatch(this.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.setCurrentFiat`)
+ log.debug(`background.setCurrentFiat`)
background.setCurrentCurrency(currencyCode, (err, data) => {
dispatch(this.hideLoadingIndication())
if (err) {
@@ -346,14 +349,38 @@ function setCurrentFiat (currencyCode) {
}
function signMsg (msgData) {
+ log.debug('action - signMsg')
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.signMessage`)
- background.signMessage(msgData, (err) => {
+ log.debug(`actions calling background.signMessage`)
+ background.signMessage(msgData, (err, newState) => {
+ log.debug('signMessage called back')
+ dispatch(actions.updateMetamaskState(newState))
dispatch(actions.hideLoadingIndication())
+ if (err) log.error(err)
if (err) return dispatch(actions.displayWarning(err.message))
+
+ dispatch(actions.completedTx(msgData.metamaskId))
+ })
+ }
+}
+
+function signPersonalMsg (msgData) {
+ log.debug('action - signPersonalMsg')
+ return (dispatch) => {
+ dispatch(actions.showLoadingIndication())
+
+ log.debug(`actions calling background.signPersonalMessage`)
+ background.signPersonalMessage(msgData, (err, newState) => {
+ log.debug('signPersonalMessage called back')
+ dispatch(actions.updateMetamaskState(newState))
+ dispatch(actions.hideLoadingIndication())
+
+ if (err) log.error(err)
+ if (err) return dispatch(actions.displayWarning(err.message))
+
dispatch(actions.completedTx(msgData.metamaskId))
})
}
@@ -361,23 +388,20 @@ function signMsg (msgData) {
function signTx (txData) {
return (dispatch) => {
- if (global.METAMASK_DEBUG) console.log(`background.setGasMultiplier`)
- background.setGasMultiplier(txData.gasMultiplier, (err) => {
+ web3.eth.sendTransaction(txData, (err, data) => {
+ dispatch(actions.hideLoadingIndication())
if (err) return dispatch(actions.displayWarning(err.message))
- web3.eth.sendTransaction(txData, (err, data) => {
- dispatch(actions.hideLoadingIndication())
- if (err) return dispatch(actions.displayWarning(err.message))
- dispatch(actions.hideWarning())
- dispatch(actions.goHome())
- })
- dispatch(this.showConfTxPage())
+ dispatch(actions.hideWarning())
+ dispatch(actions.goHome())
})
+ dispatch(this.showConfTxPage())
}
}
function sendTx (txData) {
+ log.info(`actions - sendTx: ${JSON.stringify(txData.txParams)}`)
return (dispatch) => {
- if (global.METAMASK_DEBUG) console.log(`background.approveTransaction`)
+ log.debug(`actions calling background.approveTransaction`)
background.approveTransaction(txData.id, (err) => {
if (err) {
dispatch(actions.txError(err))
@@ -388,10 +412,24 @@ function sendTx (txData) {
}
}
+function updateAndApproveTx (txData) {
+ log.info('actions: updateAndApproveTx: ' + JSON.stringify(txData))
+ return (dispatch) => {
+ log.debug(`actions calling background.updateAndApproveTx`)
+ background.updateAndApproveTransaction(txData, (err) => {
+ if (err) {
+ dispatch(actions.txError(err))
+ return console.error(err.message)
+ }
+ dispatch(actions.completedTx(txData.id))
+ })
+ }
+}
+
function completedTx (id) {
return {
type: actions.COMPLETED_TX,
- id,
+ value: id,
}
}
@@ -403,13 +441,19 @@ function txError (err) {
}
function cancelMsg (msgData) {
- if (global.METAMASK_DEBUG) console.log(`background.cancelMessage`)
+ log.debug(`background.cancelMessage`)
background.cancelMessage(msgData.id)
return actions.completedTx(msgData.id)
}
+function cancelPersonalMsg (msgData) {
+ const id = msgData.id
+ background.cancelPersonalMessage(id)
+ return actions.completedTx(id)
+}
+
function cancelTx (txData) {
- if (global.METAMASK_DEBUG) console.log(`background.cancelTransaction`)
+ log.debug(`background.cancelTransaction`)
background.cancelTransaction(txData.id)
return actions.completedTx(txData.id)
}
@@ -505,14 +549,14 @@ function updateMetamaskState (newState) {
}
function lockMetamask () {
- if (global.METAMASK_DEBUG) console.log(`background.setLocked`)
+ log.debug(`background.setLocked`)
return callBackgroundThenUpdate(background.setLocked)
}
function showAccountDetail (address) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.setSelectedAddress`)
+ log.debug(`background.setSelectedAddress`)
background.setSelectedAddress(address, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
@@ -585,7 +629,7 @@ function goBackToInitView () {
function markNoticeRead (notice) {
return (dispatch) => {
dispatch(this.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.markNoticeRead`)
+ log.debug(`background.markNoticeRead`)
background.markNoticeRead(notice, (err, notice) => {
dispatch(this.hideLoadingIndication())
if (err) {
@@ -617,7 +661,7 @@ function clearNotices () {
}
function markAccountsFound() {
- if (global.METAMASK_DEBUG) console.log(`background.markAccountsFound`)
+ log.debug(`background.markAccountsFound`)
return callBackgroundThenUpdate(background.markAccountsFound)
}
@@ -643,7 +687,7 @@ function setRpcTarget (newRpc) {
}
function setProviderType (type) {
- if (global.METAMASK_DEBUG) console.log(`background.setProviderType`)
+ log.debug(`background.setProviderType`)
background.setProviderType(type)
return {
type: actions.SET_PROVIDER_TYPE,
@@ -652,7 +696,7 @@ function setProviderType (type) {
}
function useEtherscanProvider () {
- if (global.METAMASK_DEBUG) console.log(`background.useEtherscanProvider`)
+ log.debug(`background.useEtherscanProvider`)
background.useEtherscanProvider()
return {
type: actions.USE_ETHERSCAN_PROVIDER,
@@ -709,7 +753,7 @@ function exportAccount (address) {
return function (dispatch) {
dispatch(self.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.exportAccount`)
+ log.debug(`background.exportAccount`)
background.exportAccount(address, function (err, result) {
dispatch(self.hideLoadingIndication())
@@ -733,7 +777,7 @@ function showPrivateKey (key) {
function saveAccountLabel (account, label) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
- if (global.METAMASK_DEBUG) console.log(`background.saveAccountLabel`)
+ log.debug(`background.saveAccountLabel`)
background.saveAccountLabel(account, label, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
@@ -755,7 +799,7 @@ function showSendPage () {
function buyEth (address, amount) {
return (dispatch) => {
- if (global.METAMASK_DEBUG) console.log(`background.buyEth`)
+ log.debug(`background.buyEth`)
background.buyEth(address, amount)
dispatch({
type: actions.BUY_ETH,
@@ -835,7 +879,7 @@ function coinShiftRquest (data, marketData) {
if (response.error) return dispatch(actions.displayWarning(response.error))
var message = `
Deposit your ${response.depositType} to the address bellow:`
- if (global.METAMASK_DEBUG) console.log(`background.createShapeShiftTx`)
+ log.debug(`background.createShapeShiftTx`)
background.createShapeShiftTx(response.deposit, response.depositType)
dispatch(actions.showQrView(response.deposit, [message].concat(marketData)))
})
@@ -915,7 +959,7 @@ function callBackgroundThenUpdate (method, ...args) {
}
function forceUpdateMetamaskState(dispatch){
- if (global.METAMASK_DEBUG) console.log(`background.getState`)
+ log.debug(`background.getState`)
background.getState((err, newState) => {
if (err) {
return dispatch(actions.displayWarning(err.message))
diff --git a/ui/app/app.js b/ui/app/app.js
index cf865f23f..d8519def7 100644
--- a/ui/app/app.js
+++ b/ui/app/app.js
@@ -65,6 +65,7 @@ function mapStateToProps (state) {
App.prototype.render = function () {
var props = this.props
const { isLoading, loadingMessage, transForward } = props
+ log.debug('Main ui render function')
return (
@@ -352,6 +353,7 @@ App.prototype.renderBackButton = function (style, justArrow = false) {
}
App.prototype.renderPrimary = function () {
+ log.debug('rendering primary')
var props = this.props
// notices
diff --git a/ui/app/components/hex-as-decimal-input.js b/ui/app/components/hex-as-decimal-input.js
new file mode 100644
index 000000000..523c1264b
--- /dev/null
+++ b/ui/app/components/hex-as-decimal-input.js
@@ -0,0 +1,76 @@
+const Component = require('react').Component
+const h = require('react-hyperscript')
+const inherits = require('util').inherits
+const ethUtil = require('ethereumjs-util')
+const BN = ethUtil.BN
+const extend = require('xtend')
+
+module.exports = HexAsDecimalInput
+
+inherits(HexAsDecimalInput, Component)
+function HexAsDecimalInput () {
+ Component.call(this)
+}
+
+/* Hex as Decimal Input
+ *
+ * A component for allowing easy, decimal editing
+ * of a passed in hex string value.
+ *
+ * On change, calls back its `onChange` function parameter
+ * and passes it an updated hex string.
+ */
+
+HexAsDecimalInput.prototype.render = function () {
+ const props = this.props
+ const { value, onChange } = props
+ const toEth = props.toEth
+ const suffix = props.suffix
+ const decimalValue = decimalize(value, toEth)
+ const style = props.style
+
+ return (
+ h('.flex-row', {
+ style: {
+ alignItems: 'flex-end',
+ lineHeight: '13px',
+ fontFamily: 'Montserrat Light',
+ textRendering: 'geometricPrecision',
+ },
+ }, [
+ h('input.ether-balance.ether-balance-amount', {
+ style: extend({
+ display: 'block',
+ textAlign: 'right',
+ backgroundColor: 'transparent',
+ border: '1px solid #bdbdbd',
+ }, style),
+ value: decimalValue,
+ onChange: (event) => {
+ const hexString = hexify(event.target.value)
+ onChange(hexString)
+ },
+ }),
+ h('div', {
+ style: {
+ color: ' #AEAEAE',
+ fontSize: '12px',
+ marginLeft: '5px',
+ marginRight: '6px',
+ width: '20px',
+ },
+ }, suffix),
+ ])
+ )
+}
+
+function hexify (decimalString) {
+ const hexBN = new BN(decimalString, 10)
+ return '0x' + hexBN.toString('hex')
+}
+
+function decimalize (input, toEth) {
+ const strippedInput = ethUtil.stripHexPrefix(input)
+ const inputBN = new BN(strippedInput, 'hex')
+ return inputBN.toString(10)
+}
diff --git a/ui/app/components/pending-personal-msg-details.js b/ui/app/components/pending-personal-msg-details.js
new file mode 100644
index 000000000..ffd11ca0b
--- /dev/null
+++ b/ui/app/components/pending-personal-msg-details.js
@@ -0,0 +1,61 @@
+const Component = require('react').Component
+const h = require('react-hyperscript')
+const inherits = require('util').inherits
+
+const AccountPanel = require('./account-panel')
+
+module.exports = PendingMsgDetails
+
+inherits(PendingMsgDetails, Component)
+function PendingMsgDetails () {
+ Component.call(this)
+}
+
+PendingMsgDetails.prototype.render = function () {
+ var state = this.props
+ var msgData = state.txData
+
+ var msgParams = msgData.msgParams || {}
+ var address = msgParams.from || state.selectedAddress
+ var identity = state.identities[address] || { address: address }
+ var account = state.accounts[address] || { address: address }
+
+ var { data } = msgParams
+
+ return (
+ h('div', {
+ key: msgData.id,
+ style: {
+ margin: '10px 20px',
+ },
+ }, [
+
+ // account that will sign
+ h(AccountPanel, {
+ showFullAddress: true,
+ identity: identity,
+ account: account,
+ imageifyIdenticons: state.imageifyIdenticons,
+ }),
+
+ // message data
+ h('div', [
+ h('label.font-small', { style: { display: 'block' } }, 'MESSAGE'),
+ h('textarea.font-small', {
+ readOnly: true,
+ style: {
+ width: '315px',
+ maxHeight: '210px',
+ resize: 'none',
+ border: 'none',
+ background: 'white',
+ padding: '3px',
+ },
+ defaultValue: data,
+ }),
+ ]),
+
+ ])
+ )
+}
+
diff --git a/ui/app/components/pending-personal-msg.js b/ui/app/components/pending-personal-msg.js
new file mode 100644
index 000000000..4542adb28
--- /dev/null
+++ b/ui/app/components/pending-personal-msg.js
@@ -0,0 +1,47 @@
+const Component = require('react').Component
+const h = require('react-hyperscript')
+const inherits = require('util').inherits
+const PendingTxDetails = require('./pending-personal-msg-details')
+
+module.exports = PendingMsg
+
+inherits(PendingMsg, Component)
+function PendingMsg () {
+ Component.call(this)
+}
+
+PendingMsg.prototype.render = function () {
+ var state = this.props
+ var msgData = state.txData
+
+ return (
+
+ h('div', {
+ key: msgData.id,
+ }, [
+
+ // header
+ h('h3', {
+ style: {
+ fontWeight: 'bold',
+ textAlign: 'center',
+ },
+ }, 'Sign Message'),
+
+ // message details
+ h(PendingTxDetails, state),
+
+ // sign + cancel
+ h('.flex-row.flex-space-around', [
+ h('button', {
+ onClick: state.cancelPersonalMessage,
+ }, 'Cancel'),
+ h('button', {
+ onClick: state.signPersonalMessage,
+ }, 'Sign'),
+ ]),
+ ])
+
+ )
+}
+
diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js
index e8615404e..b1ab9576b 100644
--- a/ui/app/components/pending-tx-details.js
+++ b/ui/app/components/pending-tx-details.js
@@ -1,12 +1,16 @@
const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
+const extend = require('xtend')
+const ethUtil = require('ethereumjs-util')
+const BN = ethUtil.BN
const MiniAccountPanel = require('./mini-account-panel')
const EthBalance = require('./eth-balance')
const util = require('../util')
const addressSummary = util.addressSummary
const nameForAddress = require('../../lib/contract-namer')
+const HexInput = require('./hex-as-decimal-input')
module.exports = PendingTxDetails
@@ -19,7 +23,8 @@ const PTXP = PendingTxDetails.prototype
PTXP.render = function () {
var props = this.props
- var txData = props.txData
+ var state = this.state || {}
+ var txData = state.txMeta || props.txData
var txParams = txData.txParams || {}
var address = txParams.from || props.selectedAddress
@@ -27,11 +32,18 @@ PTXP.render = function () {
var account = props.accounts[address]
var balance = account ? account.balance : '0x0'
- var txFee = txData.txFee || ''
- var maxCost = txData.maxCost || ''
+ const gas = state.gas || txParams.gas
+ const gasPrice = state.gasPrice || txData.gasPrice
+ const gasDefault = txParams.gas
+ const gasPriceDefault = txData.gasPrice
+
+ var txFee = state.txFee || txData.txFee || ''
+ var maxCost = state.maxCost || txData.maxCost || ''
var dataLength = txParams.data ? (txParams.data.length - 2) / 2 : 0
var imageify = props.imageifyIdenticons === undefined ? true : props.imageifyIdenticons
+ log.debug(`rendering gas: ${gas}, gasPrice: ${gasPrice}, txFee: ${txFee}, maxCost: ${maxCost}`)
+
return (
h('div', [
@@ -97,11 +109,63 @@ PTXP.render = function () {
h('.table-box', [
+ // Ether Value
+ // Currently not customizable, but easily modified
+ // in the way that gas and gasLimit currently are.
h('.row', [
h('.cell.label', 'Amount'),
h(EthBalance, { value: txParams.value }),
]),
+ // Gas Limit (customizable)
+ h('.cell.row', [
+ h('.cell.label', 'Gas Limit'),
+ h('.cell.value', {
+ }, [
+ h(HexInput, {
+ value: gas,
+ suffix: 'UNITS',
+ style: {
+ position: 'relative',
+ top: '5px',
+ },
+ onChange: (newHex) => {
+ log.info(`Gas limit changed to ${newHex}`)
+ if (newHex === '0x0') {
+ this.setState({gas: gasDefault})
+ } else {
+ this.setState({ gas: newHex })
+ }
+ },
+ }),
+ ]),
+ ]),
+
+ // Gas Price (customizable)
+ h('.cell.row', [
+ h('.cell.label', 'Gas Price'),
+ h('.cell.value', {
+ }, [
+ h(HexInput, {
+ value: gasPrice,
+ suffix: 'WEI',
+ style: {
+ position: 'relative',
+ top: '5px',
+ },
+ onChange: (newHex) => {
+ log.info(`Gas price changed to: ${newHex}`)
+ if (newHex === '0x0') {
+ this.setState({gasPrice: gasPriceDefault})
+ } else {
+ this.setState({ gasPrice: newHex })
+ }
+ },
+ }),
+ ]),
+ ]),
+
+ // Max Transaction Fee (calculated)
h('.cell.row', [
h('.cell.label', 'Max Transaction Fee'),
h(EthBalance, { value: txFee.toString(16) }),
@@ -130,6 +194,7 @@ PTXP.render = function () {
]),
]),
+ // Data size row:
h('.cell.row', {
style: {
background: '#f7f7f7',
@@ -191,6 +256,80 @@ PTXP.miniAccountPanelForRecipient = function () {
}
}
+PTXP.componentDidUpdate = function (prevProps, previousState) {
+ log.debug(`pending-tx-details componentDidUpdate`)
+ const state = this.state || {}
+ const prevState = previousState || {}
+ const { gas, gasPrice } = state
+
+ // Only if gas or gasPrice changed:
+ if (!prevState ||
+ (gas !== prevState.gas ||
+ gasPrice !== prevState.gasPrice)) {
+ log.debug(`recalculating gas since prev state change: ${JSON.stringify({ prevState, state })}`)
+ this.calculateGas()
+ }
+}
+
+PTXP.calculateGas = function () {
+ const txMeta = this.gatherParams()
+ log.debug(`pending-tx-details calculating gas for ${JSON.stringify(txMeta)}`)
+
+ var txParams = txMeta.txParams
+ var gasCost = new BN(ethUtil.stripHexPrefix(txParams.gas || txMeta.estimatedGas), 16)
+ var gasPrice = new BN(ethUtil.stripHexPrefix(txParams.gasPrice || '0x4a817c800'), 16)
+ var txFee = gasCost.mul(gasPrice)
+ var txValue = new BN(ethUtil.stripHexPrefix(txParams.value || '0x0'), 16)
+ var maxCost = txValue.add(txFee)
+
+ const txFeeHex = '0x' + txFee.toString('hex')
+ const maxCostHex = '0x' + maxCost.toString('hex')
+ const gasPriceHex = '0x' + gasPrice.toString('hex')
+
+ txMeta.txFee = txFeeHex
+ txMeta.maxCost = maxCostHex
+ txMeta.txParams.gasPrice = gasPriceHex
+
+ this.setState({
+ txFee: '0x' + txFee.toString('hex'),
+ maxCost: '0x' + maxCost.toString('hex'),
+ })
+
+ if (this.props.onTxChange) {
+ this.props.onTxChange(txMeta)
+ }
+}
+
+PTXP.resetGasFields = function () {
+ log.debug(`pending-tx-details#resetGasFields`)
+ const txData = this.props.txData
+ this.setState({
+ gas: txData.txParams.gas,
+ gasPrice: txData.gasPrice,
+ })
+}
+
+// After a customizable state value has been updated,
+PTXP.gatherParams = function () {
+ log.debug(`pending-tx-details#gatherParams`)
+ const props = this.props
+ const state = this.state || {}
+ const txData = state.txData || props.txData
+ const txParams = txData.txParams
+
+ const gas = state.gas || txParams.gas
+ const gasPrice = state.gasPrice || txParams.gasPrice
+ const resultTx = extend(txParams, {
+ gas,
+ gasPrice,
+ })
+ const resultTxMeta = extend(txData, {
+ txParams: resultTx,
+ })
+ log.debug(`UI has computed tx params ${JSON.stringify(resultTx)}`)
+ return resultTxMeta
+}
+
function forwardCarrat () {
return (
diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js
index 96f968929..d39cbc0f8 100644
--- a/ui/app/components/pending-tx.js
+++ b/ui/app/components/pending-tx.js
@@ -2,6 +2,7 @@ const Component = require('react').Component
const h = require('react-hyperscript')
const inherits = require('util').inherits
const PendingTxDetails = require('./pending-tx-details')
+const extend = require('xtend')
module.exports = PendingTx
@@ -11,8 +12,9 @@ function PendingTx () {
}
PendingTx.prototype.render = function () {
- var state = this.props
- var txData = state.txData
+ const props = this.props
+ const newProps = extend(props, {ref: 'details'})
+ const txData = props.txData
return (
@@ -21,7 +23,7 @@ PendingTx.prototype.render = function () {
}, [
// tx info
- h(PendingTxDetails, state),
+ h(PendingTxDetails, newProps),
h('style', `
.conf-buttons button {
@@ -39,7 +41,7 @@ PendingTx.prototype.render = function () {
}, 'Transaction Error. Exception thrown in contract code.')
: null,
- state.insufficientBalance ?
+ props.insufficientBalance ?
h('span.error', {
style: {
marginLeft: 50,
@@ -57,20 +59,26 @@ PendingTx.prototype.render = function () {
},
}, [
- state.insufficientBalance ?
+ props.insufficientBalance ?
h('button.btn-green', {
- onClick: state.buyEth,
+ onClick: props.buyEth,
}, 'Buy Ether')
: null,
h('button.confirm', {
- disabled: state.insufficientBalance,
- onClick: state.sendTransaction,
+ disabled: props.insufficientBalance,
+ onClick: props.sendTransaction,
}, 'Accept'),
h('button.cancel.btn-red', {
- onClick: state.cancelTransaction,
+ onClick: props.cancelTransaction,
}, 'Reject'),
+
+ h('button', {
+ onClick: () => {
+ this.refs.details.resetGasFields()
+ },
+ }, 'Reset'),
]),
])
)
diff --git a/ui/app/components/transaction-list-item-icon.js b/ui/app/components/transaction-list-item-icon.js
index 90b4ec094..ca2781451 100644
--- a/ui/app/components/transaction-list-item-icon.js
+++ b/ui/app/components/transaction-list-item-icon.js
@@ -15,11 +15,7 @@ TransactionIcon.prototype.render = function () {
const { transaction, txParams, isMsg } = this.props
switch (transaction.status) {
case 'unapproved':
- return h( !isMsg ? '.unapproved-tx-icon' : 'i.fa.fa-certificate.fa-lg', {
- style: {
- width: '24px',
- },
- })
+ return h( !isMsg ? '.unapproved-tx-icon' : 'i.fa.fa-certificate.fa-lg')
case 'rejected':
return h('i.fa.fa-exclamation-triangle.fa-lg.warning', {
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index 646dbb602..7e93ea29f 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -12,6 +12,8 @@ const BN = ethUtil.BN
const PendingTx = require('./components/pending-tx')
const PendingMsg = require('./components/pending-msg')
+const PendingPersonalMsg = require('./components/pending-personal-msg')
+const Loading = require('./components/loading')
module.exports = connect(mapStateToProps)(ConfirmTxScreen)
@@ -22,6 +24,7 @@ function mapStateToProps (state) {
selectedAddress: state.metamask.selectedAddress,
unapprovedTxs: state.metamask.unapprovedTxs,
unapprovedMsgs: state.metamask.unapprovedMsgs,
+ unapprovedPersonalMsgs: state.metamask.unapprovedPersonalMsgs,
index: state.appState.currentView.context,
warning: state.appState.warning,
network: state.metamask.network,
@@ -35,21 +38,18 @@ function ConfirmTxScreen () {
}
ConfirmTxScreen.prototype.render = function () {
- var state = this.props
+ const props = this.props
+ const { network, provider, unapprovedTxs,
+ unapprovedMsgs, unapprovedPersonalMsgs } = props
- var network = state.network
- var provider = state.provider
- var unapprovedTxs = state.unapprovedTxs
- var unapprovedMsgs = state.unapprovedMsgs
-
- var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, network)
- var index = state.index !== undefined && unconfTxList[index] ? state.index : 0
+ var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
+ var index = props.index !== undefined && unconfTxList[index] ? props.index : 0
var txData = unconfTxList[index] || {}
var txParams = txData.params || {}
var isNotification = isPopupOrNotification() === 'notification'
log.info(`rendering a combined ${unconfTxList.length} unconf msg & txs`)
- if (unconfTxList.length === 0) return null
+ if (unconfTxList.length === 0) return h(Loading)
return (
@@ -75,20 +75,20 @@ ConfirmTxScreen.prototype.render = function () {
}, [
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
style: {
- display: state.index === 0 ? 'none' : 'inline-block',
+ display: props.index === 0 ? 'none' : 'inline-block',
},
- onClick: () => state.dispatch(actions.previousTx()),
+ onClick: () => props.dispatch(actions.previousTx()),
}),
- ` ${state.index + 1} of ${unconfTxList.length} `,
+ ` ${props.index + 1} of ${unconfTxList.length} `,
h('i.fa.fa-arrow-right.fa-lg.cursor-pointer', {
style: {
- display: state.index + 1 === unconfTxList.length ? 'none' : 'inline-block',
+ display: props.index + 1 === unconfTxList.length ? 'none' : 'inline-block',
},
- onClick: () => state.dispatch(actions.nextTx()),
+ onClick: () => props.dispatch(actions.nextTx()),
}),
]),
- warningIfExists(state.warning),
+ warningIfExists(props.warning),
h(ReactCSSTransitionGroup, {
className: 'css-transition-group',
@@ -101,16 +101,20 @@ ConfirmTxScreen.prototype.render = function () {
// Properties
txData: txData,
key: txData.id,
- selectedAddress: state.selectedAddress,
- accounts: state.accounts,
- identities: state.identities,
+ selectedAddress: props.selectedAddress,
+ accounts: props.accounts,
+ identities: props.identities,
insufficientBalance: this.checkBalanceAgainstTx(txData),
+ // State actions
+ onTxChange: this.onTxChange.bind(this),
// Actions
- buyEth: this.buyEth.bind(this, txParams.from || state.selectedAddress),
+ buyEth: this.buyEth.bind(this, txParams.from || props.selectedAddress),
sendTransaction: this.sendTransaction.bind(this, txData),
cancelTransaction: this.cancelTransaction.bind(this, txData),
signMessage: this.signMessage.bind(this, txData),
+ signPersonalMessage: this.signPersonalMessage.bind(this, txData),
cancelMessage: this.cancelMessage.bind(this, txData),
+ cancelPersonalMessage: this.cancelPersonalMessage.bind(this, txData),
}),
]),
@@ -119,25 +123,33 @@ ConfirmTxScreen.prototype.render = function () {
}
function currentTxView (opts) {
+ log.info('rendering current tx view')
const { txData } = opts
- const { txParams, msgParams } = txData
+ const { txParams, msgParams, type } = txData
- log.info('rendering current tx view')
if (txParams) {
- // This is a pending transaction
log.debug('txParams detected, rendering pending tx')
return h(PendingTx, opts)
+
} else if (msgParams) {
- // This is a pending message to sign
log.debug('msgParams detected, rendering pending msg')
- return h(PendingMsg, opts)
+
+ if (type === 'eth_sign') {
+ log.debug('rendering eth_sign message')
+ return h(PendingMsg, opts)
+
+ } else if (type === 'personal_sign') {
+ log.debug('rendering personal_sign message')
+ return h(PendingPersonalMsg, opts)
+ }
}
}
+
ConfirmTxScreen.prototype.checkBalanceAgainstTx = function (txData) {
if (!txData.txParams) return false
- var state = this.props
- var address = txData.txParams.from || state.selectedAddress
- var account = state.accounts[address]
+ var props = this.props
+ var address = txData.txParams.from || props.selectedAddress
+ var account = props.accounts[address]
var balance = account ? account.balance : '0x0'
var maxCost = new BN(txData.maxCost, 16)
@@ -150,9 +162,20 @@ ConfirmTxScreen.prototype.buyEth = function (address, event) {
this.props.dispatch(actions.buyEthView(address))
}
+// Allows the detail view to update the gas calculations,
+// for manual gas controls.
+ConfirmTxScreen.prototype.onTxChange = function (txData) {
+ log.debug(`conf-tx onTxChange triggered with ${JSON.stringify(txData)}`)
+ this.setState({ txData })
+}
+
+// Must default to any local state txData,
+// to allow manual override of gas calculations.
ConfirmTxScreen.prototype.sendTransaction = function (txData, event) {
event.stopPropagation()
- this.props.dispatch(actions.sendTx(txData))
+ const state = this.state || {}
+ const txMeta = state.txData
+ this.props.dispatch(actions.updateAndApproveTx(txMeta || txData))
}
ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {
@@ -161,17 +184,33 @@ ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {
}
ConfirmTxScreen.prototype.signMessage = function (msgData, event) {
+ log.info('conf-tx.js: signing message')
var params = msgData.msgParams
params.metamaskId = msgData.id
event.stopPropagation()
this.props.dispatch(actions.signMsg(params))
}
+ConfirmTxScreen.prototype.signPersonalMessage = function (msgData, event) {
+ log.info('conf-tx.js: signing personal message')
+ var params = msgData.msgParams
+ params.metamaskId = msgData.id
+ event.stopPropagation()
+ this.props.dispatch(actions.signPersonalMsg(params))
+}
+
ConfirmTxScreen.prototype.cancelMessage = function (msgData, event) {
+ log.info('canceling message')
event.stopPropagation()
this.props.dispatch(actions.cancelMsg(msgData))
}
+ConfirmTxScreen.prototype.cancelPersonalMessage = function (msgData, event) {
+ log.info('canceling personal message')
+ event.stopPropagation()
+ this.props.dispatch(actions.cancelPersonalMsg(msgData))
+}
+
ConfirmTxScreen.prototype.goHome = function (event) {
event.stopPropagation()
this.props.dispatch(actions.goHome())
@@ -179,7 +218,7 @@ ConfirmTxScreen.prototype.goHome = function (event) {
function warningIfExists (warning) {
if (warning &&
- // Do not display user rejections on this screen:
+ // Do not display user rejections on this screen:
warning.indexOf('User denied transaction signature') === -1) {
return h('.error', {
style: {
diff --git a/ui/app/css/index.css b/ui/app/css/index.css
index 4b9b5b67d..8c6ff29d3 100644
--- a/ui/app/css/index.css
+++ b/ui/app/css/index.css
@@ -410,11 +410,10 @@ input.large-input {
}
.unapproved-tx-icon {
- height: 24px;
- background: #4dffff;
- border: solid;
+ height: 16px;
+ width: 16px;
+ background: rgb(47, 174, 244);
border-color: #AEAEAE;
- border-width: 0.5px;
border-radius: 13px;
}
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index de6536c2e..7ea1e1d7c 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -6,14 +6,16 @@ const notification = require('../../../app/scripts/lib/notifications')
module.exports = reduceApp
function reduceApp (state, action) {
+ log.debug('App Reducer got ' + action.type)
// clone and defaults
const selectedAddress = state.metamask.selectedAddress
- const pendingTxs = hasPendingTxs(state)
+ let pendingTxs = hasPendingTxs(state)
let name = 'accounts'
if (selectedAddress) {
name = 'accountDetail'
}
if (pendingTxs) {
+ log.debug('pending txs detected, defaulting to conf-tx view.')
name = 'confTx'
}
@@ -294,27 +296,32 @@ function reduceApp (state, action) {
},
transForward: action.transForward,
warning: null,
+ isLoading: false,
})
case actions.SHOW_CONF_MSG_PAGE:
return extend(appState, {
currentView: {
- name: 'confTx',
+ name: pendingTxs ? 'confTx' : 'account-detail',
context: 0,
},
transForward: true,
warning: null,
+ isLoading: false,
})
case actions.COMPLETED_TX:
- var unapprovedTxs = state.metamask.unapprovedTxs
- var unapprovedMsgs = state.metamask.unapprovedMsgs
- var network = state.metamask.network
+ log.debug('reducing COMPLETED_TX for tx ' + action.value)
+ var { unapprovedTxs, unapprovedMsgs,
+ unapprovedPersonalMsgs, network } = state.metamask
- var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, network)
- .filter(tx => tx !== tx.id)
+ var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
+ .filter(tx => tx.id !== action.value )
- if (unconfTxList && unconfTxList.length > 0) {
+ pendingTxs = unconfTxList.length > 0
+
+ if (pendingTxs) {
+ log.debug('reducer detected txs - rendering confTx view')
return extend(appState, {
transForward: false,
currentView: {
@@ -324,6 +331,7 @@ function reduceApp (state, action) {
warning: null,
})
} else {
+ log.debug('attempting to close popup')
notification.closePopup()
return extend(appState, {
@@ -572,11 +580,12 @@ function reduceApp (state, action) {
}
function hasPendingTxs (state) {
- var unapprovedTxs = state.metamask.unapprovedTxs
- var unapprovedMsgs = state.metamask.unapprovedMsgs
- var network = state.metamask.network
- var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, network)
- return unconfTxList.length > 0
+ var { unapprovedTxs, unapprovedMsgs,
+ unapprovedPersonalMsgs, network } = state.metamask
+
+ var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
+ var has = unconfTxList.length > 0
+ return has
}
function indexForPending (state, txId) {
diff --git a/ui/app/send.js b/ui/app/send.js
index d16270b41..581e3afa0 100644
--- a/ui/app/send.js
+++ b/ui/app/send.js
@@ -10,8 +10,6 @@ const addressSummary = require('./util').addressSummary
const isHex = require('./util').isHex
const EthBalance = require('./components/eth-balance')
const ethUtil = require('ethereumjs-util')
-const RangeSlider = require('./components/range-slider')
-const Tooltip = require('./components/tooltip')
module.exports = connect(mapStateToProps)(SendTransactionScreen)
function mapStateToProps (state) {
@@ -208,73 +206,6 @@ SendTransactionScreen.prototype.render = function () {
},
}),
]),
- // custom gasPrice field
- h('h3.flex-center.text-transform-uppercase', {
- style: {
- background: '#EBEBEB',
- color: '#AEAEAE',
- marginBottom: '5px',
- },
- }, [
- 'Transaction Fee (optional)',
- h(Tooltip, {
- title: `
- This is used to set the transaction's gas price.
- Setting it to 100% will use the full recommended value. `,
- }, [
- h('i.fa.fa-question-circle', {
- style: {
- marginLeft: '5px',
- },
- }),
- ]),
- ]),
-
- h('section.flex-column.flex-center', [
- h('.flex-row', [
- h(RangeSlider, {
- name: 'gasInput',
- options: {
- mirrorInput: true,
- defaultValue: 100,
- min: 80,
- max: 220,
- },
- style: {
- container: {
- marginBottom: '16px',
- },
- range: {
- width: '68vw',
- },
- input: {
- width: '5em',
- marginLeft: '5px',
- },
- },
- }),
-
- h('div', {
- style: {
- fontSize: '12px',
- paddingTop: '8px',
- paddingLeft: '5px',
- },
- }, '%'),
- ]),
- h('.flex-row', {
- style: {
- justifyContent: 'space-between',
- width: '243px',
- position: 'relative',
- fontSize: '12px',
- right: '42px',
- bottom: '30px',
- },
- }, [
- h('span', 'Cheaper'), h('span', 'Faster'),
- ]),
- ]),
])
)
}
@@ -289,12 +220,11 @@ SendTransactionScreen.prototype.back = function () {
this.props.dispatch(actions.backToAccountDetail(address))
}
-SendTransactionScreen.prototype.onSubmit = function (gasPrice) {
+SendTransactionScreen.prototype.onSubmit = function () {
const recipient = document.querySelector('input[name="address"]').value
const input = document.querySelector('input[name="amount"]').value
const value = util.normalizeEthStringToWei(input)
const txData = document.querySelector('input[name="txData"]').value
- const gasMultiplier = document.querySelector('input[name="gasInput"]').value
const balance = this.props.balance
let message
@@ -323,7 +253,6 @@ SendTransactionScreen.prototype.onSubmit = function (gasPrice) {
var txParams = {
from: this.props.address,
value: '0x' + value.toString(16),
- gasMultiplier: gasMultiplier * 0.01,
}
if (recipient) txParams.to = ethUtil.addHexPrefix(recipient)
diff --git a/ui/index.js b/ui/index.js
index 844e6c417..1a65f813c 100644
--- a/ui/index.js
+++ b/ui/index.js
@@ -6,9 +6,10 @@ const configureStore = require('./app/store')
const txHelper = require('./lib/tx-helper')
module.exports = launchApp
+let debugMode = window.METAMASK_DEBUG
const log = require('loglevel')
window.log = log
-log.setLevel('warn')
+log.setLevel(debugMode ? 'debug' : 'warn')
function launchApp (opts) {
var accountManager = opts.accountManager
@@ -36,7 +37,7 @@ function startApp (metamaskState, accountManager, opts) {
})
// if unconfirmed txs, start on txConf page
- var unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.network)
+ var unapprovedTxsAll = txHelper(metamaskState.unapprovedTxs, metamaskState.unapprovedMsgs, metamaskState.unapprovedPersonalMsgs, metamaskState.network)
if (unapprovedTxsAll.length > 0) {
store.dispatch(actions.showConfTxPage())
}
diff --git a/ui/lib/tx-helper.js b/ui/lib/tx-helper.js
index 7f64f9fbe..2eefdff68 100644
--- a/ui/lib/tx-helper.js
+++ b/ui/lib/tx-helper.js
@@ -1,13 +1,17 @@
const valuesFor = require('../app/util').valuesFor
-module.exports = function (unapprovedTxs, unapprovedMsgs, network) {
+module.exports = function (unapprovedTxs, unapprovedMsgs, personalMsgs, network) {
log.debug('tx-helper called with params:')
- log.debug({ unapprovedTxs, unapprovedMsgs, network })
+ log.debug({ unapprovedTxs, unapprovedMsgs, personalMsgs, network })
- var txValues = network ? valuesFor(unapprovedTxs).filter(tx => tx.txParams.metamaskNetworkId === network) : valuesFor(unapprovedTxs)
+ const txValues = network ? valuesFor(unapprovedTxs).filter(tx => tx.txParams.metamaskNetworkId === network) : valuesFor(unapprovedTxs)
log.debug(`tx helper found ${txValues.length} unapproved txs`)
- var msgValues = valuesFor(unapprovedMsgs)
+ const msgValues = valuesFor(unapprovedMsgs)
log.debug(`tx helper found ${msgValues.length} unsigned messages`)
- var allValues = txValues.concat(msgValues)
+ let allValues = txValues.concat(msgValues)
+ const personalValues = valuesFor(personalMsgs)
+ log.debug(`tx helper found ${personalValues.length} unsigned personal messages`)
+ allValues = allValues.concat(personalValues)
+
return allValues.sort(tx => tx.time)
}