From 17a7436602191d11bb02771a87bd74f7baeb49ea Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 21 Feb 2017 12:51:56 -0800 Subject: Connect to actions. --- ui/app/actions.js | 1 + ui/app/config.js | 1 + 2 files changed, 2 insertions(+) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 6552e7f5c..a39646f33 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -628,6 +628,7 @@ function markAccountsFound() { function setRpcTarget (newRpc) { if (global.METAMASK_DEBUG) console.log(`background.setRpcTarget`) background.setRpcTarget(newRpc) + background.addToFrequentRpcList(newRpc) return { type: actions.SET_RPC_TARGET, value: newRpc, diff --git a/ui/app/config.js b/ui/app/config.js index 65b1ed712..00a4cba88 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -5,6 +5,7 @@ const connect = require('react-redux').connect const actions = require('./actions') const currencies = require('./conversion.json').rows const validUrl = require('valid-url') + module.exports = connect(mapStateToProps)(ConfigScreen) function mapStateToProps (state) { -- cgit v1.2.3 From 7a0ce31bd31a3d6f1a92bbaded71b040ca765065 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 22 Feb 2017 15:12:56 -0800 Subject: Implemented functionality for displaying recent custom RPCs --- ui/app/actions.js | 5 +++-- ui/app/app.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index a39646f33..86638fc91 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -627,8 +627,9 @@ function markAccountsFound() { function setRpcTarget (newRpc) { if (global.METAMASK_DEBUG) console.log(`background.setRpcTarget`) - background.setRpcTarget(newRpc) - background.addToFrequentRpcList(newRpc) + background.addToFrequentRpcList(newRpc, () => { + background.setRpcTarget(newRpc) + }) return { type: actions.SET_RPC_TARGET, value: newRpc, diff --git a/ui/app/app.js b/ui/app/app.js index 6e249b09e..08a4326fe 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -58,6 +58,7 @@ function mapStateToProps (state) { forgottenPassword: state.appState.forgottenPassword, lastUnreadNotice: state.metamask.lastUnreadNotice, lostAccounts: state.metamask.lostAccounts, + frequentRpcList: state.metamask.frequentRpcList } } @@ -210,6 +211,7 @@ App.prototype.renderAppBar = function () { App.prototype.renderNetworkDropdown = function () { const props = this.props + const rpcList = props.frequentRpcList const state = this.state || {} const isOpen = state.isNetworkMenuOpen @@ -261,6 +263,7 @@ App.prototype.renderNetworkDropdown = function () { }), this.renderCustomOption(props.provider), + this.renderCommonRpc(rpcList, props.provider), props.isUnlocked && h(DropMenuItem, { label: 'Custom RPC', @@ -508,3 +511,23 @@ App.prototype.renderCustomOption = function (provider) { }) } } + +App.prototype.renderCommonRpc = function (rpcList, provider) { + const { rpcTarget } = provider + const props = this.props + + return rpcList.map((rpc) => { + if ((rpc === 'http://localhost:8545') || (rpc === rpcTarget)) { + return null + } else { + return h(DropMenuItem, { + label: rpc, + closeMenu: () => this.setState({ isNetworkMenuOpen: false }), + action: () => props.dispatch(actions.setRpcTarget(rpc)), + icon: h('i.fa.fa-question-circle.fa-lg'), + activeNetworkRender: rpc, + }) + } + }) + +} -- cgit v1.2.3 From 1d0f5fb51c355e6833d2e935a63d4957f0971f1e Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 22 Feb 2017 15:13:59 -0800 Subject: Linto --- ui/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/app') diff --git a/ui/app/app.js b/ui/app/app.js index 08a4326fe..c1358f50f 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -58,7 +58,7 @@ function mapStateToProps (state) { forgottenPassword: state.appState.forgottenPassword, lastUnreadNotice: state.metamask.lastUnreadNotice, lostAccounts: state.metamask.lostAccounts, - frequentRpcList: state.metamask.frequentRpcList + frequentRpcList: state.metamask.frequentRpcList, } } -- cgit v1.2.3 From 3be6ee5f6cc5e7b79a8eeea182f91a15eb9ed989 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 22 Feb 2017 15:32:01 -0800 Subject: Make the UI play nice with empty RPC lists. --- ui/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/app') diff --git a/ui/app/app.js b/ui/app/app.js index c1358f50f..d61f93dd2 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -58,7 +58,7 @@ function mapStateToProps (state) { forgottenPassword: state.appState.forgottenPassword, lastUnreadNotice: state.metamask.lastUnreadNotice, lostAccounts: state.metamask.lostAccounts, - frequentRpcList: state.metamask.frequentRpcList, + frequentRpcList: state.metamask.frequentRpcList || [], } } -- cgit v1.2.3 From 62854398f1d3c72a82ae9d4feb03d9a1a947534e Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 23 Feb 2017 13:56:58 -0800 Subject: Tested against code to play nice with unit tests. --- ui/app/actions.js | 18 ++++++++++++------ ui/app/app.js | 4 +++- ui/app/reducers/metamask.js | 3 ++- 3 files changed, 17 insertions(+), 8 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 86638fc91..7e5add1d0 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -626,13 +626,19 @@ function markAccountsFound() { // function setRpcTarget (newRpc) { - if (global.METAMASK_DEBUG) console.log(`background.setRpcTarget`) - background.addToFrequentRpcList(newRpc, () => { + return (dispatch) => { + if (global.METAMASK_DEBUG) console.log(`background.setRpcTarget`) background.setRpcTarget(newRpc) - }) - return { - type: actions.SET_RPC_TARGET, - value: newRpc, + background.updateFrequentRpcList(newRpc, (frequentRpcList) => { + const value = { + rpcTarget: newRpc, + frequentRpcList, + } + dispatch({ + type: actions.SET_RPC_TARGET, + value, + }) + }) } } diff --git a/ui/app/app.js b/ui/app/app.js index d61f93dd2..cf865f23f 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -257,7 +257,9 @@ App.prototype.renderNetworkDropdown = function () { h(DropMenuItem, { label: 'Localhost 8545', closeMenu: () => this.setState({ isNetworkMenuOpen: false }), - action: () => props.dispatch(actions.setRpcTarget('http://localhost:8545')), + action: () => { + props.dispatch(actions.setRpcTarget('http://localhost:8545')) + }, icon: h('i.fa.fa-question-circle.fa-lg'), activeNetworkRender: props.provider.rpcTarget, }), diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 3875cf6d1..7bf2969e7 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -55,9 +55,10 @@ function reduceMetamask (state, action) { case actions.SET_RPC_TARGET: return extend(metamaskState, { + frequentRpcList: action.value.frequentRpcList, provider: { type: 'rpc', - rpcTarget: action.value, + rpcTarget: action.value.rpcTarget, }, }) -- cgit v1.2.3 From ca5cf06ae9e3e417dd3488bb0d94cdeec74ca18c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 27 Feb 2017 10:25:10 -0800 Subject: Concatenate custom RPC labels that are too long --- ui/app/app.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'ui/app') diff --git a/ui/app/app.js b/ui/app/app.js index cf865f23f..a05a42516 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -499,6 +499,12 @@ App.prototype.renderCustomOption = function (provider) { const { rpcTarget, type } = provider if (type !== 'rpc') return null + // Concatenate long URLs + let label = rpcTarget + if (rpcTarget.length > 31) { + label = label.substr(0, 34) + '...' + } + switch (rpcTarget) { case 'http://localhost:8545': @@ -506,7 +512,8 @@ App.prototype.renderCustomOption = function (provider) { default: return h(DropMenuItem, { - label: `${rpcTarget}`, + label, + key: rpcTarget, closeMenu: () => this.setState({ isNetworkMenuOpen: false }), icon: h('i.fa.fa-question-circle.fa-lg'), activeNetworkRender: 'custom', @@ -524,6 +531,7 @@ App.prototype.renderCommonRpc = function (rpcList, provider) { } else { return h(DropMenuItem, { label: rpc, + key: rpc, closeMenu: () => this.setState({ isNetworkMenuOpen: false }), action: () => props.dispatch(actions.setRpcTarget(rpc)), icon: h('i.fa.fa-question-circle.fa-lg'), -- cgit v1.2.3 From 5f378d382e008ef577223055c9674c25e2e6bba4 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 1 Mar 2017 13:01:23 -0800 Subject: Only allow numbers in gas inputs --- ui/app/components/hex-as-decimal-input.js | 1 + 1 file changed, 1 insertion(+) (limited to 'ui/app') diff --git a/ui/app/components/hex-as-decimal-input.js b/ui/app/components/hex-as-decimal-input.js index 523c1264b..ecf232640 100644 --- a/ui/app/components/hex-as-decimal-input.js +++ b/ui/app/components/hex-as-decimal-input.js @@ -44,6 +44,7 @@ HexAsDecimalInput.prototype.render = function () { textAlign: 'right', backgroundColor: 'transparent', border: '1px solid #bdbdbd', + type: 'number', }, style), value: decimalValue, onChange: (event) => { -- cgit v1.2.3 From 0ac1f749fd68244682d0f2c763028cdf6aa29486 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 1 Mar 2017 14:37:51 -0800 Subject: Various improvements to gas input. --- ui/app/components/hex-as-decimal-input.js | 15 ++++++++++----- ui/app/components/pending-tx-details.js | 18 ++++-------------- ui/app/components/pending-tx.js | 16 ++++++++-------- 3 files changed, 22 insertions(+), 27 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/hex-as-decimal-input.js b/ui/app/components/hex-as-decimal-input.js index ecf232640..c89ed0416 100644 --- a/ui/app/components/hex-as-decimal-input.js +++ b/ui/app/components/hex-as-decimal-input.js @@ -39,16 +39,17 @@ HexAsDecimalInput.prototype.render = function () { }, }, [ h('input.ether-balance.ether-balance-amount', { + type: 'number', style: extend({ display: 'block', textAlign: 'right', backgroundColor: 'transparent', border: '1px solid #bdbdbd', - type: 'number', + }, style), value: decimalValue, onChange: (event) => { - const hexString = hexify(event.target.value) + const hexString = (event.target.value === '') ? '' : hexify(event.target.value) onChange(hexString) }, }), @@ -71,7 +72,11 @@ function hexify (decimalString) { } function decimalize (input, toEth) { - const strippedInput = ethUtil.stripHexPrefix(input) - const inputBN = new BN(strippedInput, 'hex') - return inputBN.toString(10) + if (input === '') { + return '' + } else { + const strippedInput = ethUtil.stripHexPrefix(input) + const inputBN = new BN(strippedInput, 'hex') + return inputBN.toString(10) + } } diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js index b1ab9576b..fc8d65454 100644 --- a/ui/app/components/pending-tx-details.js +++ b/ui/app/components/pending-tx-details.js @@ -32,10 +32,8 @@ PTXP.render = function () { var account = props.accounts[address] var balance = account ? account.balance : '0x0' - const gas = state.gas || txParams.gas - const gasPrice = state.gasPrice || txData.gasPrice - const gasDefault = txParams.gas - const gasPriceDefault = txData.gasPrice + const gas = (state.gas === undefined) ? txParams.gas : state.gas + const gasPrice = (state.gasPrice === undefined) ? txData.gasPrice : state.gasPrice var txFee = state.txFee || txData.txFee || '' var maxCost = state.maxCost || txData.maxCost || '' @@ -131,11 +129,7 @@ PTXP.render = function () { }, onChange: (newHex) => { log.info(`Gas limit changed to ${newHex}`) - if (newHex === '0x0') { - this.setState({gas: gasDefault}) - } else { - this.setState({ gas: newHex }) - } + this.setState({ gas: newHex }) }, }), ]), @@ -155,11 +149,7 @@ PTXP.render = function () { }, onChange: (newHex) => { log.info(`Gas price changed to: ${newHex}`) - if (newHex === '0x0') { - this.setState({gasPrice: gasPriceDefault}) - } else { - this.setState({ gasPrice: newHex }) - } + this.setState({ gasPrice: newHex }) }, }), ]), diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index d39cbc0f8..ed366aa45 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -60,12 +60,18 @@ PendingTx.prototype.render = function () { }, [ props.insufficientBalance ? - h('button.btn-green', { + h('button', { onClick: props.buyEth, }, 'Buy Ether') : null, - h('button.confirm', { + h('button', { + onClick: () => { + this.refs.details.resetGasFields() + }, + }, 'Reset'), + + h('button.confirm.btn-green', { disabled: props.insufficientBalance, onClick: props.sendTransaction, }, 'Accept'), @@ -73,12 +79,6 @@ PendingTx.prototype.render = function () { h('button.cancel.btn-red', { onClick: props.cancelTransaction, }, 'Reject'), - - h('button', { - onClick: () => { - this.refs.details.resetGasFields() - }, - }, 'Reset'), ]), ]) ) -- cgit v1.2.3 From 72932bdcba10bd9d47724f271d0c14f84d12b759 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 1 Mar 2017 17:03:55 -0800 Subject: Prevent submission of invalid gas parameters. --- ui/app/components/pending-tx-details.js | 11 ++++++++++- ui/app/components/pending-tx.js | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'ui/app') diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js index fc8d65454..e92ce575f 100644 --- a/ui/app/components/pending-tx-details.js +++ b/ui/app/components/pending-tx-details.js @@ -306,7 +306,6 @@ PTXP.gatherParams = function () { 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, { @@ -320,6 +319,16 @@ PTXP.gatherParams = function () { return resultTxMeta } +PTXP.verifyGasParams = function () { + // We call this in case the gas has not been modified at all + if (!this.state) { return true } + return this._notZeroOrEmptyString(this.state.gas) && this._notZeroOrEmptyString(this.state.gasPrice) +} + +PTXP._notZeroOrEmptyString = function (obj) { + return obj !== '' && obj !== '0x0' +} + function forwardCarrat () { return ( diff --git a/ui/app/components/pending-tx.js b/ui/app/components/pending-tx.js index ed366aa45..2ab6f25a9 100644 --- a/ui/app/components/pending-tx.js +++ b/ui/app/components/pending-tx.js @@ -1,10 +1,18 @@ const Component = require('react').Component +const connect = require('react-redux').connect const h = require('react-hyperscript') const inherits = require('util').inherits const PendingTxDetails = require('./pending-tx-details') const extend = require('xtend') +const actions = require('../actions') -module.exports = PendingTx +module.exports = connect(mapStateToProps)(PendingTx) + +function mapStateToProps (state) { + return { + + } +} inherits(PendingTx, Component) function PendingTx () { @@ -73,7 +81,13 @@ PendingTx.prototype.render = function () { h('button.confirm.btn-green', { disabled: props.insufficientBalance, - onClick: props.sendTransaction, + onClick: (txData, event) => { + if (this.refs.details.verifyGasParams()) { + props.sendTransaction(txData, event) + } else { + this.props.dispatch(actions.displayWarning('Invalid Gas Parameters')) + } + }, }, 'Accept'), h('button.cancel.btn-red', { -- cgit v1.2.3 From 9bd8c5f723abef25b8864457df7207eb361be8e3 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 6 Mar 2017 15:03:49 -0800 Subject: Render personal_sign messages as utf-8 text Calls to `personal_sign` are now: - When hex encoded, preserved as hex encoded, but displayed as utf-8 text. - When not hex encoded, decoded as utf-8 text as hex for signing. - The messages proposed for signing are displayed as UTF-8 text. - When the message cannot be rendered as UTF-8 text, it is displayed as hexadecimal. Fixes #1173 --- ui/app/components/binary-renderer.js | 43 +++++++++++++++++++++++ ui/app/components/pending-personal-msg-details.js | 15 ++------ 2 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 ui/app/components/binary-renderer.js (limited to 'ui/app') diff --git a/ui/app/components/binary-renderer.js b/ui/app/components/binary-renderer.js new file mode 100644 index 000000000..a9d49b128 --- /dev/null +++ b/ui/app/components/binary-renderer.js @@ -0,0 +1,43 @@ +const Component = require('react').Component +const h = require('react-hyperscript') +const inherits = require('util').inherits +const ethUtil = require('ethereumjs-util') + +module.exports = BinaryRenderer + +inherits(BinaryRenderer, Component) +function BinaryRenderer () { + Component.call(this) +} + +BinaryRenderer.prototype.render = function () { + const props = this.props + const { value } = props + const text = this.hexToText(value) + + return ( + h('textarea.font-small', { + readOnly: true, + style: { + width: '315px', + maxHeight: '210px', + resize: 'none', + border: 'none', + background: 'white', + padding: '3px', + }, + defaultValue: text, + }) + ) +} + +BinaryRenderer.prototype.hexToText = function (hex) { + try { + const stripped = ethUtil.stripHexPrefix(hex) + const buff = Buffer.from(stripped, 'hex') + return buff.toString('utf8') + } catch (e) { + return hex + } +} + diff --git a/ui/app/components/pending-personal-msg-details.js b/ui/app/components/pending-personal-msg-details.js index ffd11ca0b..afd04fc51 100644 --- a/ui/app/components/pending-personal-msg-details.js +++ b/ui/app/components/pending-personal-msg-details.js @@ -3,6 +3,7 @@ const h = require('react-hyperscript') const inherits = require('util').inherits const AccountPanel = require('./account-panel') +const BinaryRenderer = require('./binary-renderer') module.exports = PendingMsgDetails @@ -21,6 +22,7 @@ PendingMsgDetails.prototype.render = function () { var account = state.accounts[address] || { address: address } var { data } = msgParams + console.dir({ msgParams }) return ( h('div', { @@ -41,18 +43,7 @@ PendingMsgDetails.prototype.render = function () { // 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, - }), + h(BinaryRenderer, { value: data }), ]), ]) -- cgit v1.2.3 From 26ea5993a9dffa687b50446bbffd0d2310a796bc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 6 Mar 2017 15:36:16 -0800 Subject: Remove log --- ui/app/components/pending-personal-msg-details.js | 1 - 1 file changed, 1 deletion(-) (limited to 'ui/app') diff --git a/ui/app/components/pending-personal-msg-details.js b/ui/app/components/pending-personal-msg-details.js index afd04fc51..fa2c6416c 100644 --- a/ui/app/components/pending-personal-msg-details.js +++ b/ui/app/components/pending-personal-msg-details.js @@ -22,7 +22,6 @@ PendingMsgDetails.prototype.render = function () { var account = state.accounts[address] || { address: address } var { data } = msgParams - console.dir({ msgParams }) return ( h('div', { -- cgit v1.2.3 From 2a98beb87877619ad123281facab3e22dec64fab Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 7 Mar 2017 10:25:50 -0800 Subject: Break out rpc update and rpclist into two reducers. --- ui/app/actions.js | 30 ++++++++++++++++++++++++------ ui/app/app.js | 4 +--- ui/app/reducers/metamask.js | 8 ++++++-- 3 files changed, 31 insertions(+), 11 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index cda987cad..4172ea5df 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -112,11 +112,13 @@ var actions = { // config screen SHOW_CONFIG_PAGE: 'SHOW_CONFIG_PAGE', SET_RPC_TARGET: 'SET_RPC_TARGET', + SET_DEFAULT_RPC_TARGET: 'SET_DEFAULT_RPC_TARGET', SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE', USE_ETHERSCAN_PROVIDER: 'USE_ETHERSCAN_PROVIDER', useEtherscanProvider: useEtherscanProvider, showConfigPage: showConfigPage, setRpcTarget: setRpcTarget, + setDefaultRpcTarget: setDefaultRpcTarget, setProviderType: setProviderType, // loading overlay SHOW_LOADING: 'SHOW_LOADING_INDICATION', @@ -669,18 +671,34 @@ function markAccountsFound() { // config // +// default rpc target refers to localhost:8545 in this instance. +function setDefaultRpcTarget (rpcList) { + log.debug(`background.setDefaultRpcTarget`) + background.setRpcTarget('http://localhost:8545') + return (dispatch) => { + dispatch({ + type: actions.SET_RPC_TARGET, + value: 'http://localhost:8545', + }) + dispatch({ + type: actions.SET_RPC_LIST, + value: rpcList, + }) + } +} + function setRpcTarget (newRpc) { return (dispatch) => { log.debug(`background.setRpcTarget`) background.setRpcTarget(newRpc) - background.updateFrequentRpcList(newRpc, (frequentRpcList) => { - const value = { - rpcTarget: newRpc, - frequentRpcList, - } + background.updateFrequentRpcList(newRpc, (rpcList) => { dispatch({ type: actions.SET_RPC_TARGET, - value, + value: newRpc, + }) + dispatch({ + type: actions.SET_RPC_LIST, + value: rpcList, }) }) } diff --git a/ui/app/app.js b/ui/app/app.js index 20f948770..2bc92b54c 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -258,9 +258,7 @@ App.prototype.renderNetworkDropdown = function () { h(DropMenuItem, { label: 'Localhost 8545', closeMenu: () => this.setState({ isNetworkMenuOpen: false }), - action: () => { - props.dispatch(actions.setRpcTarget('http://localhost:8545')) - }, + action: () => props.dispatch(actions.setDefaultRpcTarget(rpcList)), icon: h('i.fa.fa-question-circle.fa-lg'), activeNetworkRender: props.provider.rpcTarget, }), diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 7bf2969e7..c09556c91 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -53,12 +53,16 @@ function reduceMetamask (state, action) { isUnlocked: false, }) + case actions.SET_RPC_LIST: + return extend(metamaskState, { + frequentRpcList: action.value, + }) + case actions.SET_RPC_TARGET: return extend(metamaskState, { - frequentRpcList: action.value.frequentRpcList, provider: { type: 'rpc', - rpcTarget: action.value.rpcTarget, + rpcTarget: action.value, }, }) -- cgit v1.2.3 From e7e024bcdd2c93b34a0baf8bc27e6c571c098476 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Tue, 7 Mar 2017 16:01:51 -0800 Subject: Refactor of code into separate reducers and actions. --- ui/app/actions.js | 30 +++++++++--------------------- ui/app/reducers/metamask.js | 1 + 2 files changed, 10 insertions(+), 21 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 4172ea5df..2fc0d3523 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -674,33 +674,21 @@ function markAccountsFound() { // default rpc target refers to localhost:8545 in this instance. function setDefaultRpcTarget (rpcList) { log.debug(`background.setDefaultRpcTarget`) - background.setRpcTarget('http://localhost:8545') - return (dispatch) => { - dispatch({ - type: actions.SET_RPC_TARGET, - value: 'http://localhost:8545', - }) - dispatch({ - type: actions.SET_RPC_LIST, - value: rpcList, - }) + background.setDefaultRpc() + return { + type: actions.SET_RPC_TARGET, + value: 'http://localhost:8545', } } function setRpcTarget (newRpc) { return (dispatch) => { log.debug(`background.setRpcTarget`) - background.setRpcTarget(newRpc) - background.updateFrequentRpcList(newRpc, (rpcList) => { - dispatch({ - type: actions.SET_RPC_TARGET, - value: newRpc, - }) - dispatch({ - type: actions.SET_RPC_LIST, - value: rpcList, - }) - }) + background.setCustomRpc(newRpc) + return { + type: actions.SET_RPC_TARGET, + value: newRpc, + } } } diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index c09556c91..a3c07d977 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -18,6 +18,7 @@ function reduceMetamask (state, action) { conversionDate: 'N/A', noActiveNotices: true, lastUnreadNotice: undefined, + frequentRpcList: [], }, state.metamask) switch (action.type) { -- cgit v1.2.3 From cf2268c3d29d97afa22cd11663bb6e3e74c09b5a Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 8 Mar 2017 09:06:41 -0800 Subject: Nodeify and promisify calls to background. --- ui/app/actions.js | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 2fc0d3523..062a691e2 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -674,21 +674,37 @@ function markAccountsFound() { // default rpc target refers to localhost:8545 in this instance. function setDefaultRpcTarget (rpcList) { log.debug(`background.setDefaultRpcTarget`) - background.setDefaultRpc() - return { - type: actions.SET_RPC_TARGET, - value: 'http://localhost:8545', + return (dispatch) => { + background.setDefaultRpc((err, result) => { + if (err) { + console.error(err) + return dispatch(self.displayWarning('Had a problem changing networks.')) + } + dispatch(self.setRpc(result)) + }) } + } function setRpcTarget (newRpc) { - return (dispatch) => { log.debug(`background.setRpcTarget`) - background.setCustomRpc(newRpc) - return { - type: actions.SET_RPC_TARGET, - value: newRpc, + return (dispatch) => { + background.setCustomRpc(newRpc, (err, result) => { + if (err) { + console.err(err) + return dispatch(self.displayWarning('Had a problem changing networks!')) + } + dispatch(self.setRpc(result)) + }) } + + +} + +function setRpc (newRpc) { + return { + type: actions.SET_RPC_TARGET, + value: 'http://localhost:8545', } } -- cgit v1.2.3 From 0ee8ca178e9240ab25454bafc88c58ebef6b69c3 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 8 Mar 2017 09:08:28 -0800 Subject: Remove unneeded setrpc method. --- ui/app/actions.js | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 062a691e2..82b6fac18 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -680,31 +680,19 @@ function setDefaultRpcTarget (rpcList) { console.error(err) return dispatch(self.displayWarning('Had a problem changing networks.')) } - dispatch(self.setRpc(result)) }) } - } function setRpcTarget (newRpc) { - log.debug(`background.setRpcTarget`) - return (dispatch) => { - background.setCustomRpc(newRpc, (err, result) => { - if (err) { - console.err(err) - return dispatch(self.displayWarning('Had a problem changing networks!')) - } - dispatch(self.setRpc(result)) - }) - } - - -} - -function setRpc (newRpc) { - return { - type: actions.SET_RPC_TARGET, - value: 'http://localhost:8545', + log.debug(`background.setRpcTarget`) + return (dispatch) => { + background.setCustomRpc(newRpc, (err, result) => { + if (err) { + console.err(err) + return dispatch(self.displayWarning('Had a problem changing networks!')) + } + }) } } -- cgit v1.2.3 From 21769a008ccc5fdc2ac5d23a37d401a1d2a20694 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 8 Mar 2017 09:35:31 -0800 Subject: Fix typo, switch to log.error --- ui/app/actions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'ui/app') diff --git a/ui/app/actions.js b/ui/app/actions.js index 82b6fac18..d4fd7553b 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -677,7 +677,7 @@ function setDefaultRpcTarget (rpcList) { return (dispatch) => { background.setDefaultRpc((err, result) => { if (err) { - console.error(err) + log.error(err) return dispatch(self.displayWarning('Had a problem changing networks.')) } }) @@ -689,7 +689,7 @@ function setRpcTarget (newRpc) { return (dispatch) => { background.setCustomRpc(newRpc, (err, result) => { if (err) { - console.err(err) + log.error(err) return dispatch(self.displayWarning('Had a problem changing networks!')) } }) @@ -768,7 +768,7 @@ function exportAccount (address) { dispatch(self.hideLoadingIndication()) if (err) { - console.error(err) + log.error(err) return dispatch(self.displayWarning('Had a problem exporting the account.')) } -- cgit v1.2.3 From 6f980cfe10d32ddc276b737df42005ef7cf4cd96 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Wed, 8 Mar 2017 10:46:17 -0800 Subject: Add more informative message --- ui/app/css/lib.css | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ui/app') diff --git a/ui/app/css/lib.css b/ui/app/css/lib.css index a8df1d115..99c6f1b9d 100644 --- a/ui/app/css/lib.css +++ b/ui/app/css/lib.css @@ -256,3 +256,9 @@ hr.horizontal-line { text-overflow: ellipsis; white-space: nowrap; } + +.critical-error { + text-align: center; + margin-top: 20px; + color: red; +} -- cgit v1.2.3