From 86e95b283bd64debe9ca888abef716bc1eecce9c Mon Sep 17 00:00:00 2001 From: Alexander Tseung Date: Mon, 2 Jul 2018 16:48:26 -0700 Subject: Fix notice screen incorrectly disabling Accept button after multiple notices --- old-ui/app/components/notice.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'old-ui/app') diff --git a/old-ui/app/components/notice.js b/old-ui/app/components/notice.js index 09d461c7b..1ec254555 100644 --- a/old-ui/app/components/notice.js +++ b/old-ui/app/components/notice.js @@ -116,12 +116,25 @@ Notice.prototype.render = function () { ) } +Notice.prototype.setInitialDisclaimerState = function () { + if (document.getElementsByClassName('notice-box')[0].clientHeight < 310) { + this.setState({disclaimerDisabled: false}) + } +} + Notice.prototype.componentDidMount = function () { // eslint-disable-next-line react/no-find-dom-node var node = findDOMNode(this) linker.setupListener(node) - if (document.getElementsByClassName('notice-box')[0].clientHeight < 310) { - this.setState({disclaimerDisabled: false}) + this.setInitialDisclaimerState() +} + +Notice.prototype.componentDidUpdate = function (prevProps) { + const { notice: { id } = {} } = this.props + const { notice: { id: prevNoticeId } = {} } = prevProps + + if (id !== prevNoticeId) { + this.setInitialDisclaimerState() } } -- cgit From 1f8a808a008fc4caaf7cb399d28bcbce3fa58e25 Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Tue, 7 Aug 2018 14:16:54 -0400 Subject: wip watch token old ui --- old-ui/app/account-detail.js | 1 + old-ui/app/add-suggested-token.js | 0 2 files changed, 1 insertion(+) create mode 100644 old-ui/app/add-suggested-token.js (limited to 'old-ui/app') diff --git a/old-ui/app/account-detail.js b/old-ui/app/account-detail.js index c67f0cf71..808619e46 100644 --- a/old-ui/app/account-detail.js +++ b/old-ui/app/account-detail.js @@ -32,6 +32,7 @@ function mapStateToProps (state) { currentCurrency: state.metamask.currentCurrency, currentAccountTab: state.metamask.currentAccountTab, tokens: state.metamask.tokens, + suggestedTokens: state.metamask.suggestedTokens, computedBalances: state.metamask.computedBalances, } } diff --git a/old-ui/app/add-suggested-token.js b/old-ui/app/add-suggested-token.js new file mode 100644 index 000000000..e69de29bb -- cgit From 00d1f6fec5457f05fb2e6aec1300dd2dbef51ec1 Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Tue, 7 Aug 2018 17:40:45 -0400 Subject: watch token on old ui --- old-ui/app/account-detail.js | 4 + old-ui/app/add-suggested-token.js | 193 ++++++++++++++++++++++++++++++++++++++ old-ui/app/app.js | 6 ++ 3 files changed, 203 insertions(+) (limited to 'old-ui/app') diff --git a/old-ui/app/account-detail.js b/old-ui/app/account-detail.js index 808619e46..d240fc38e 100644 --- a/old-ui/app/account-detail.js +++ b/old-ui/app/account-detail.js @@ -50,6 +50,10 @@ AccountDetailScreen.prototype.render = function () { var account = props.accounts[selected] const { network, conversionRate, currentCurrency } = props + if (Object.keys(props.suggestedTokens).length > 0) { + this.props.dispatch(actions.showAddSuggestedTokenPage()) + } + return ( h('.account-detail-section.full-flex-height', [ diff --git a/old-ui/app/add-suggested-token.js b/old-ui/app/add-suggested-token.js index e69de29bb..1a0fc0461 100644 --- a/old-ui/app/add-suggested-token.js +++ b/old-ui/app/add-suggested-token.js @@ -0,0 +1,193 @@ +const inherits = require('util').inherits +const Component = require('react').Component +const h = require('react-hyperscript') +const connect = require('react-redux').connect +const actions = require('../../ui/app/actions') +const Tooltip = require('./components/tooltip.js') +const ethUtil = require('ethereumjs-util') + +module.exports = connect(mapStateToProps)(AddSuggestedTokenScreen) + +function mapStateToProps (state) { + return { + identities: state.metamask.identities, + suggestedTokens: state.metamask.suggestedTokens, + } +} + +inherits(AddSuggestedTokenScreen, Component) +function AddSuggestedTokenScreen () { + this.state = { + warning: null, + } + Component.call(this) +} + +AddSuggestedTokenScreen.prototype.render = function () { + const state = this.state + const props = this.props + const { warning } = state + const key = Object.keys(props.suggestedTokens)[0] + const { address, symbol, decimals } = props.suggestedTokens[key] + + return ( + h('.flex-column.flex-grow', [ + + // subtitle and nav + h('.section-title.flex-row.flex-center', [ + h('h2.page-subtitle', 'Add Suggested Token'), + ]), + + h('.error', { + style: { + display: warning ? 'block' : 'none', + padding: '0 20px', + textAlign: 'center', + }, + }, warning), + + // conf view + h('.flex-column.flex-justify-center.flex-grow.select-none', [ + h('.flex-space-around', { + style: { + padding: '20px', + }, + }, [ + + h('div', [ + h(Tooltip, { + position: 'top', + title: 'The contract of the actual token contract. Click for more info.', + }, [ + h('a', { + style: { fontWeight: 'bold', paddingRight: '10px'}, + href: 'https://support.metamask.io/kb/article/24-what-is-a-token-contract-address', + target: '_blank', + }, [ + h('span', 'Token Contract Address '), + h('i.fa.fa-question-circle'), + ]), + ]), + ]), + + h('section.flex-row.flex-center', [ + h('p#token-address', { + name: 'address', + style: { + width: 'inherit', + flex: '1 0 auto', + height: '30px', + margin: '8px', + }, + }, address), + ]), + + h('div', [ + h('span', { + style: { fontWeight: 'bold', paddingRight: '10px'}, + }, 'Token Symbol'), + ]), + + h('div', { style: {display: 'flex'} }, [ + h('p#token_symbol', { + style: { + width: 'inherit', + flex: '1 0 auto', + height: '30px', + margin: '8px', + }, + }, symbol), + ]), + + h('div', [ + h('span', { + style: { fontWeight: 'bold', paddingRight: '10px'}, + }, 'Decimals of Precision'), + ]), + + h('div', { style: {display: 'flex'} }, [ + h('p#token_decimals', { + type: 'number', + style: { + width: 'inherit', + flex: '1 0 auto', + height: '30px', + margin: '8px', + }, + }, decimals), + ]), + + h('button', { + style: { + alignSelf: 'center', + margin: '8px', + }, + onClick: (event) => { + this.props.dispatch(actions.removeSuggestedTokens()) + }, + }, 'Cancel'), + + h('button', { + style: { + alignSelf: 'center', + margin: '8px', + }, + onClick: (event) => { + const valid = this.validateInputs({ address, symbol, decimals }) + if (!valid) return + + this.props.dispatch(actions.addToken(address.trim(), symbol.trim(), decimals)) + .then(() => { + this.props.dispatch(actions.removeSuggestedTokens()) + }) + }, + }, 'Add'), + ]), + ]), + ]) + ) +} + +AddSuggestedTokenScreen.prototype.componentWillMount = function () { + if (typeof global.ethereumProvider === 'undefined') return +} + +AddSuggestedTokenScreen.prototype.validateInputs = function (opts) { + let msg = '' + const identitiesList = Object.keys(this.props.identities) + const { address, symbol, decimals } = opts + const standardAddress = ethUtil.addHexPrefix(address).toLowerCase() + + const validAddress = ethUtil.isValidAddress(address) + if (!validAddress) { + msg += 'Address is invalid.' + } + + const validDecimals = decimals >= 0 && decimals < 36 + if (!validDecimals) { + msg += 'Decimals must be at least 0, and not over 36. ' + } + + const symbolLen = symbol.trim().length + const validSymbol = symbolLen > 0 && symbolLen < 10 + if (!validSymbol) { + msg += 'Symbol must be between 0 and 10 characters.' + } + + const ownAddress = identitiesList.includes(standardAddress) + if (ownAddress) { + msg = 'Personal address detected. Input the token contract address.' + } + + const isValid = validAddress && validDecimals && !ownAddress + + if (!isValid) { + this.setState({ + warning: msg, + }) + } else { + this.setState({ warning: null }) + } + + return isValid +} diff --git a/old-ui/app/app.js b/old-ui/app/app.js index 0637e3b5b..fb15d414d 100644 --- a/old-ui/app/app.js +++ b/old-ui/app/app.js @@ -22,6 +22,7 @@ const generateLostAccountsNotice = require('../lib/lost-accounts-notice') // other views const ConfigScreen = require('./config') const AddTokenScreen = require('./add-token') +const AddSuggestedTokenScreen = require('./add-suggested-token') const Import = require('./accounts/import') const InfoScreen = require('./info') const Loading = require('./components/loading') @@ -77,6 +78,7 @@ function mapStateToProps (state) { lostAccounts: state.metamask.lostAccounts, frequentRpcList: state.metamask.frequentRpcList || [], featureFlags, + suggestedTokens: state.metamask.suggestedTokens, // state needed to get account dropdown temporarily rendering from app bar identities, @@ -554,6 +556,10 @@ App.prototype.renderPrimary = function () { log.debug('rendering add-token screen from unlock screen.') return h(AddTokenScreen, {key: 'add-token'}) + case 'add-suggested-token': + log.debug('rendering add-token screen from unlock screen.') + return h(AddSuggestedTokenScreen, {key: 'add-suggested-token'}) + case 'config': log.debug('rendering config screen') return h(ConfigScreen, {key: 'config'}) -- cgit From 33357e3538b5157a852323d5f1e2db7f19b3303e Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Tue, 7 Aug 2018 19:12:16 -0400 Subject: refactor unused code --- old-ui/app/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'old-ui/app') diff --git a/old-ui/app/app.js b/old-ui/app/app.js index f60ee5beb..9be21ebad 100644 --- a/old-ui/app/app.js +++ b/old-ui/app/app.js @@ -239,7 +239,7 @@ App.prototype.renderPrimary = function () { return h(AddTokenScreen, {key: 'add-token'}) case 'add-suggested-token': - log.debug('rendering add-token screen from unlock screen.') + log.debug('rendering add-suggested-token screen from unlock screen.') return h(AddSuggestedTokenScreen, {key: 'add-suggested-token'}) case 'config': -- cgit From c245405acb2323239d079d574cbf4230ec068c35 Mon Sep 17 00:00:00 2001 From: Esteban MIno Date: Tue, 7 Aug 2018 20:07:26 -0400 Subject: show token address summary on old ui --- old-ui/app/add-suggested-token.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'old-ui/app') diff --git a/old-ui/app/add-suggested-token.js b/old-ui/app/add-suggested-token.js index 1a0fc0461..51be4c5f2 100644 --- a/old-ui/app/add-suggested-token.js +++ b/old-ui/app/add-suggested-token.js @@ -5,6 +5,9 @@ const connect = require('react-redux').connect const actions = require('../../ui/app/actions') const Tooltip = require('./components/tooltip.js') const ethUtil = require('ethereumjs-util') +const Copyable = require('./components/copyable') +const addressSummary = require('./util').addressSummary + module.exports = connect(mapStateToProps)(AddSuggestedTokenScreen) @@ -70,16 +73,22 @@ AddSuggestedTokenScreen.prototype.render = function () { ]), ]), - h('section.flex-row.flex-center', [ - h('p#token-address', { - name: 'address', - style: { - width: 'inherit', - flex: '1 0 auto', - height: '30px', - margin: '8px', - }, - }, address), + h('div', { + style: { display: 'flex' }, + }, [ + h(Copyable, { + value: ethUtil.toChecksumAddress(address), + }, [ + h('span#token-address', { + style: { + width: 'inherit', + flex: '1 0 auto', + height: '30px', + margin: '8px', + display: 'flex', + }, + }, addressSummary(address, 24, 4, false)), + ]), ]), h('div', [ -- cgit From 59ba2d2785b1742a7b1b4d6455a4662d9cd685c7 Mon Sep 17 00:00:00 2001 From: Anatoli Babenia Date: Thu, 16 Aug 2018 21:39:57 +0800 Subject: info.js Remove width element to fix email layout (#4588) Fix for #2855 which is gone from master for some reason --- old-ui/app/info.js | 1 - 1 file changed, 1 deletion(-) (limited to 'old-ui/app') diff --git a/old-ui/app/info.js b/old-ui/app/info.js index d79b8a3d2..936d270da 100644 --- a/old-ui/app/info.js +++ b/old-ui/app/info.js @@ -138,7 +138,6 @@ InfoScreen.prototype.render = function () { h('div.fa.fa-envelope', [ h('a.info', { target: '_blank', - style: { width: '85vw' }, href: 'mailto:help@metamask.io?subject=Feedback', }, 'Email us!'), ]), -- cgit From c0b5e8a088b7ed2ac557ad2b6bc6b55d9bae1919 Mon Sep 17 00:00:00 2001 From: Evgeniy Filatov Date: Sun, 19 Aug 2018 21:02:30 +0300 Subject: backported RPC improvements to oldui --- old-ui/app/components/app-bar.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'old-ui/app') diff --git a/old-ui/app/components/app-bar.js b/old-ui/app/components/app-bar.js index 8ab647efd..684dfbe19 100644 --- a/old-ui/app/components/app-bar.js +++ b/old-ui/app/components/app-bar.js @@ -350,11 +350,13 @@ module.exports = class AppBar extends Component { } } - renderCommonRpc (rpcList, {rpcTarget}) { + renderCommonRpc (rpcList, provider) { const {dispatch} = this.props return rpcList.map((rpc) => { - if ((rpc === LOCALHOST_RPC_URL) || (rpc === rpcTarget)) { + const currentRpcTarget = provider.type === 'rpc' && rpc === provider.rpcTarget + + if ((rpc === LOCALHOST_RPC_URL) || currentRpcTarget) { return null } else { return h(DropdownMenuItem, { @@ -364,7 +366,7 @@ module.exports = class AppBar extends Component { }, [ h('i.fa.fa-question-circle.fa-lg.menu-icon'), rpc, - rpcTarget === rpc + currentRpcTarget ? h('.check', '✓') : null, ]) -- cgit From 9a80d6e8598850fec00471c6101c194e90c30353 Mon Sep 17 00:00:00 2001 From: Evgeniy Filatov Date: Thu, 23 Aug 2018 01:26:30 +0300 Subject: updated docs, small improvement of recent RPC rendering --- old-ui/app/components/app-bar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'old-ui/app') diff --git a/old-ui/app/components/app-bar.js b/old-ui/app/components/app-bar.js index 684dfbe19..234c06a01 100644 --- a/old-ui/app/components/app-bar.js +++ b/old-ui/app/components/app-bar.js @@ -352,8 +352,9 @@ module.exports = class AppBar extends Component { renderCommonRpc (rpcList, provider) { const {dispatch} = this.props + const reversedRpcList = rpcList.slice().reverse() - return rpcList.map((rpc) => { + return reversedRpcList.map((rpc) => { const currentRpcTarget = provider.type === 'rpc' && rpc === provider.rpcTarget if ((rpc === LOCALHOST_RPC_URL) || currentRpcTarget) { -- cgit From c824418955bcda67181660873c6101e6a020cc35 Mon Sep 17 00:00:00 2001 From: bunoi Date: Mon, 3 Sep 2018 18:32:38 +0700 Subject: edit decimal check in old-ui/ --- old-ui/app/add-suggested-token.js | 2 +- old-ui/app/add-token.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'old-ui/app') diff --git a/old-ui/app/add-suggested-token.js b/old-ui/app/add-suggested-token.js index 51be4c5f2..ea534b7da 100644 --- a/old-ui/app/add-suggested-token.js +++ b/old-ui/app/add-suggested-token.js @@ -172,7 +172,7 @@ AddSuggestedTokenScreen.prototype.validateInputs = function (opts) { msg += 'Address is invalid.' } - const validDecimals = decimals >= 0 && decimals < 36 + const validDecimals = decimals >= 0 && decimals <= 36 if (!validDecimals) { msg += 'Decimals must be at least 0, and not over 36. ' } diff --git a/old-ui/app/add-token.js b/old-ui/app/add-token.js index e869ac39a..6cf211636 100644 --- a/old-ui/app/add-token.js +++ b/old-ui/app/add-token.js @@ -196,7 +196,7 @@ AddTokenScreen.prototype.validateInputs = function () { msg += 'Address is invalid.' } - const validDecimals = decimals >= 0 && decimals < 36 + const validDecimals = decimals >= 0 && decimals <= 36 if (!validDecimals) { msg += 'Decimals must be at least 0, and not over 36. ' } -- cgit From 36dd0354e777e6786ae0d2284ffcb1adbc6d85f7 Mon Sep 17 00:00:00 2001 From: bitpshr Date: Mon, 10 Sep 2018 17:11:57 -0400 Subject: Implement latest EIP-712 protocol --- old-ui/app/components/pending-typed-msg-details.js | 3 ++- old-ui/app/components/typed-message-renderer.js | 27 ++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) (limited to 'old-ui/app') diff --git a/old-ui/app/components/pending-typed-msg-details.js b/old-ui/app/components/pending-typed-msg-details.js index b5fd29f71..f95bf43a7 100644 --- a/old-ui/app/components/pending-typed-msg-details.js +++ b/old-ui/app/components/pending-typed-msg-details.js @@ -21,7 +21,7 @@ PendingMsgDetails.prototype.render = function () { var identity = state.identities[address] || { address: address } var account = state.accounts[address] || { address: address } - var { data } = msgParams + var { data, version } = msgParams return ( h('div', { @@ -48,6 +48,7 @@ PendingMsgDetails.prototype.render = function () { h('label.font-small', { style: { display: 'block' } }, 'YOU ARE SIGNING'), h(TypedMessageRenderer, { value: data, + version, style: { height: '215px', }, diff --git a/old-ui/app/components/typed-message-renderer.js b/old-ui/app/components/typed-message-renderer.js index 19e46f4fc..0eacb2129 100644 --- a/old-ui/app/components/typed-message-renderer.js +++ b/old-ui/app/components/typed-message-renderer.js @@ -2,6 +2,7 @@ const Component = require('react').Component const h = require('react-hyperscript') const inherits = require('util').inherits const extend = require('xtend') +const { ObjectInspector } = require('react-inspector') module.exports = TypedMessageRenderer @@ -12,8 +13,16 @@ function TypedMessageRenderer () { TypedMessageRenderer.prototype.render = function () { const props = this.props - const { value, style } = props - const text = renderTypedData(value) + const { value, version, style } = props + let text + switch (version) { + case 'V1': + text = renderTypedData(value) + break + case 'V2': + text = renderTypedDataV2(value) + break + } const defaultStyle = extend({ width: '315px', @@ -44,3 +53,17 @@ function renderTypedData (values) { ]) }) } + +function renderTypedDataV2 (values) { + const { domain, message } = JSON.parse(values) + return [ + domain ? h('div', [ + h('h1', 'Domain'), + h(ObjectInspector, { data: domain, expandLevel: 1, name: 'domain' }), + ]) : '', + message ? h('div', [ + h('h1', 'Message'), + h(ObjectInspector, { data: message, expandLevel: 1, name: 'message' }), + ]) : '', + ] +} -- cgit From 42fdcf6239fc9278cfa85b6ae6cc025cef0e35ae Mon Sep 17 00:00:00 2001 From: bitpshr Date: Thu, 13 Sep 2018 15:12:08 -0400 Subject: Update new method namespace from v2 to v3 --- old-ui/app/components/typed-message-renderer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'old-ui/app') diff --git a/old-ui/app/components/typed-message-renderer.js b/old-ui/app/components/typed-message-renderer.js index 0eacb2129..0dc673b8a 100644 --- a/old-ui/app/components/typed-message-renderer.js +++ b/old-ui/app/components/typed-message-renderer.js @@ -19,8 +19,8 @@ TypedMessageRenderer.prototype.render = function () { case 'V1': text = renderTypedData(value) break - case 'V2': - text = renderTypedDataV2(value) + case 'V3': + text = renderTypedDataV3(value) break } @@ -54,7 +54,7 @@ function renderTypedData (values) { }) } -function renderTypedDataV2 (values) { +function renderTypedDataV3 (values) { const { domain, message } = JSON.parse(values) return [ domain ? h('div', [ -- cgit