From dd18684a5d682f48528f278284619983f13bf82f Mon Sep 17 00:00:00 2001 From: tmashuang Date: Mon, 25 Jun 2018 15:01:14 -0700 Subject: [PATCH 1/7] Remove unsued nonce tracker function --- .../controllers/transactions/nonce-tracker.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/app/scripts/controllers/transactions/nonce-tracker.js b/app/scripts/controllers/transactions/nonce-tracker.js index 35ca08d6c..06f336eaa 100644 --- a/app/scripts/controllers/transactions/nonce-tracker.js +++ b/app/scripts/controllers/transactions/nonce-tracker.js @@ -129,19 +129,6 @@ class NonceTracker { return Number.isInteger(highest) ? highest + 1 : 0 } - _reduceTxListToUniqueNonces (txList) { - const reducedTxList = txList.reduce((reducedList, txMeta, index) => { - if (!index) return [txMeta] - const nonceMatches = txList.filter((txData) => { - return txMeta.txParams.nonce === txData.txParams.nonce - }) - if (nonceMatches.length > 1) return reducedList - reducedList.push(txMeta) - return reducedList - }, []) - return reducedTxList - } - _getHighestNonce (txList) { const nonces = txList.map((txMeta) => { const nonce = txMeta.txParams.nonce From 2526f8a1d8f59758b7bc04bb088fab6ad74b16a1 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Mon, 9 Jul 2018 17:24:12 -0230 Subject: [PATCH 2/7] Inline locale variable in fetchLocale fn --- ui/i18n-helper.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index 79aa93116..269f6e1a4 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -29,8 +29,7 @@ const getMessage = (locale, key, substitutions) => { async function fetchLocale (localeName) { try { const response = await fetch(`./_locales/${localeName}/messages.json`) - const locale = await response.json() - return locale + return await response.json() } catch (error) { log.error(`failed to fetch ${localeName} locale because of ${error}`) return {} From 94489b544ad4a68ddd961f8b549aaac8507266e6 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Mon, 9 Jul 2018 17:37:06 -0230 Subject: [PATCH 3/7] Fallback to English and then the key for I18nProvider#t --- ui/app/i18n-provider.js | 5 ++++- ui/i18n-helper.js | 22 ++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/ui/app/i18n-provider.js b/ui/app/i18n-provider.js index 2856e0ed6..d46911f7c 100644 --- a/ui/app/i18n-provider.js +++ b/ui/app/i18n-provider.js @@ -8,8 +8,11 @@ const t = require('../i18n-helper').getMessage class I18nProvider extends Component { getChildContext () { const { localeMessages } = this.props + const { current, en } = localeMessages return { - t: t.bind(null, localeMessages), + t (key, ...args) { + return t(current, key, ...args) || t(en, key, ...args) || `[${key}]` + }, } } diff --git a/ui/i18n-helper.js b/ui/i18n-helper.js index 269f6e1a4..bc927ee65 100644 --- a/ui/i18n-helper.js +++ b/ui/i18n-helper.js @@ -1,20 +1,22 @@ // cross-browser connection to extension i18n API const log = require('loglevel') +/** + * Returns a localized message for the given key + * @param {object} locale The locale + * @param {string} key The message key + * @param {string[]} substitutions A list of message substitution replacements + * @return {null|string} The localized message + */ const getMessage = (locale, key, substitutions) => { - // check locale is loaded if (!locale) { - // throw new Error('Translator - has not loaded a locale yet.') - return '' + return null } - // check entry is present - const { current, en } = locale - const entry = current[key] || en[key] - if (!entry) { - // throw new Error(`Translator - Unable to find value for "${key}"`) - log.error(`Translator - Unable to find value for "${key}"`) - return `[${key}]` + if (!locale[key]) { + log.error(`Translator - Unable to find value for key "${key}"`) + return null } + const entry = locale[key] let phrase = entry.message // perform substitutions if (substitutions && substitutions.length) { From 9bfcb9c505595cb2e539700433835f30c8bcf049 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Mon, 9 Jul 2018 17:51:55 -0230 Subject: [PATCH 4/7] Remove unneeded MetaMaskConnect connect wrapper --- ui/app/components/pages/home.js | 2 +- ui/app/metamask-connect.js | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) delete mode 100644 ui/app/metamask-connect.js diff --git a/ui/app/components/pages/home.js b/ui/app/components/pages/home.js index c53413d3b..d24d5cc55 100644 --- a/ui/app/components/pages/home.js +++ b/ui/app/components/pages/home.js @@ -1,6 +1,6 @@ const { Component } = require('react') +const { connect } = require('react-redux') const PropTypes = require('prop-types') -const connect = require('../../metamask-connect') const { Redirect, withRouter } = require('react-router-dom') const { compose } = require('recompose') const h = require('react-hyperscript') diff --git a/ui/app/metamask-connect.js b/ui/app/metamask-connect.js deleted file mode 100644 index 81fa7e403..000000000 --- a/ui/app/metamask-connect.js +++ /dev/null @@ -1,27 +0,0 @@ -const connect = require('react-redux').connect -const t = require('../i18n-helper').getMessage - -const metamaskConnect = (mapStateToProps, mapDispatchToProps) => { - return connect( - _higherOrderMapStateToProps(mapStateToProps), - mapDispatchToProps - ) -} - -const _higherOrderMapStateToProps = (mapStateToProps) => { - let _t - let currentLocale - return (state, ownProps = {}) => { - const stateProps = mapStateToProps - ? mapStateToProps(state, ownProps) - : ownProps - if (currentLocale !== state.metamask.currentLocale) { - currentLocale = state.metamask.currentLocale - _t = t.bind(null, state.localeMessages) - } - stateProps.t = _t - return stateProps - } -} - -module.exports = metamaskConnect From 7581a4906f25c22ee773bd8537f277b28600d6cf Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 12 Jul 2018 10:51:42 -0230 Subject: [PATCH 5/7] Add tooltip to menu icon in tx-view --- app/_locales/en/messages.json | 3 +++ ui/app/components/tx-view.js | 25 ++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 897f16f04..4b03c6747 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -515,6 +515,9 @@ "mainnet": { "message": "Main Ethereum Network" }, + "menu": { + "message": "Menu" + }, "message": { "message": "Message" }, diff --git a/ui/app/components/tx-view.js b/ui/app/components/tx-view.js index 014497fcd..e848297e7 100644 --- a/ui/app/components/tx-view.js +++ b/ui/app/components/tx-view.js @@ -11,6 +11,7 @@ const { SEND_ROUTE } = require('../routes') const { checksumAddress: toChecksumAddress } = require('../util') const BalanceComponent = require('./balance-component') +const Tooltip = require('./tooltip') const TxList = require('./tx-list') const SelectedAccount = require('./selected-account') @@ -103,7 +104,8 @@ TxView.prototype.renderButtons = function () { } TxView.prototype.render = function () { - const { isMascara } = this.props + const { hideSidebar, isMascara, showSidebar, sidebarOpen } = this.props + const { t } = this.context return h('div.tx-view.flex-column', { style: {}, @@ -120,14 +122,19 @@ TxView.prototype.render = function () { }, }, [ - h('div.fa.fa-bars', { - style: { - fontSize: '1.3em', - cursor: 'pointer', - padding: '10px', - }, - onClick: () => this.props.sidebarOpen ? this.props.hideSidebar() : this.props.showSidebar(), - }), + h(Tooltip, { + title: t('menu'), + position: 'bottom', + }, [ + h('div.fa.fa-bars', { + style: { + fontSize: '1.3em', + cursor: 'pointer', + padding: '10px', + }, + onClick: () => sidebarOpen ? hideSidebar() : showSidebar(), + }), + ]), h(SelectedAccount), From d9f98a704e33e1c626196bb490be66deba0dda69 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Thu, 12 Jul 2018 10:58:47 -0230 Subject: [PATCH 6/7] Add tooltip to new tab icon in tx-view --- app/_locales/en/messages.json | 3 +++ ui/app/components/tx-view.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 4b03c6747..35e28c087 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -599,6 +599,9 @@ "oldUIMessage": { "message": "You have returned to the old UI. You can switch back to the New UI through the option in the top right dropdown menu." }, + "openInTab": { + "message": "Open in tab" + }, "or": { "message": "or", "description": "choice between creating or importing a new account" diff --git a/ui/app/components/tx-view.js b/ui/app/components/tx-view.js index e848297e7..654090da6 100644 --- a/ui/app/components/tx-view.js +++ b/ui/app/components/tx-view.js @@ -138,10 +138,14 @@ TxView.prototype.render = function () { h(SelectedAccount), - !isMascara && h('div.open-in-browser', { - onClick: () => global.platform.openExtensionInBrowser(), - }, [h('img', { src: 'images/popout.svg' })]), - + !isMascara && h(Tooltip, { + title: t('openInTab'), + position: 'bottom', + }, [ + h('div.open-in-browser', { + onClick: () => global.platform.openExtensionInBrowser(), + }, [h('img', { src: 'images/popout.svg' })]), + ]), ]), this.renderHeroBalance(), From c4ae3995778436f44a5465586cd37aa1addc143a Mon Sep 17 00:00:00 2001 From: Dan Finlay <542863+danfinlay@users.noreply.github.com> Date: Thu, 12 Jul 2018 14:21:32 -0700 Subject: [PATCH 7/7] Add harbourair.com to injection block list This site was getting unexpected results when MetaMask was installed. https://consensys.zendesk.com/agent/tickets/2312 --- app/scripts/contentscript.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js index b35a70dd2..04dd51b01 100644 --- a/app/scripts/contentscript.js +++ b/app/scripts/contentscript.js @@ -177,6 +177,7 @@ function blacklistedDomainCheck () { 'cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html', 'adyen.com', 'gravityforms.com', + 'harbourair.com', ] var currentUrl = window.location.href var currentRegex