1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge branch 'develop' of github.com:MetaMask/metamask-extension into initial-trezor-support

This commit is contained in:
brunobar79 2018-07-13 20:53:22 -04:00
commit d21d408d64
8 changed files with 49 additions and 67 deletions

View File

@ -554,6 +554,9 @@
"mainnet": { "mainnet": {
"message": "Main Ethereum Network" "message": "Main Ethereum Network"
}, },
"menu": {
"message": "Menu"
},
"message": { "message": {
"message": "Message" "message": "Message"
}, },
@ -635,6 +638,9 @@
"oldUIMessage": { "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." "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": { "or": {
"message": "or", "message": "or",
"description": "choice between creating or importing a new account" "description": "choice between creating or importing a new account"

View File

@ -177,6 +177,7 @@ function blacklistedDomainCheck () {
'cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html', 'cdn.shopify.com/s/javascripts/tricorder/xtld-read-only-frame.html',
'adyen.com', 'adyen.com',
'gravityforms.com', 'gravityforms.com',
'harbourair.com',
] ]
var currentUrl = window.location.href var currentUrl = window.location.href
var currentRegex var currentRegex

View File

@ -129,19 +129,6 @@ class NonceTracker {
return Number.isInteger(highest) ? highest + 1 : 0 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) { _getHighestNonce (txList) {
const nonces = txList.map((txMeta) => { const nonces = txList.map((txMeta) => {
const nonce = txMeta.txParams.nonce const nonce = txMeta.txParams.nonce

View File

@ -1,6 +1,6 @@
const { Component } = require('react') const { Component } = require('react')
const { connect } = require('react-redux')
const PropTypes = require('prop-types') const PropTypes = require('prop-types')
const connect = require('../../metamask-connect')
const { Redirect, withRouter } = require('react-router-dom') const { Redirect, withRouter } = require('react-router-dom')
const { compose } = require('recompose') const { compose } = require('recompose')
const h = require('react-hyperscript') const h = require('react-hyperscript')

View File

@ -11,6 +11,7 @@ const { SEND_ROUTE } = require('../routes')
const { checksumAddress: toChecksumAddress } = require('../util') const { checksumAddress: toChecksumAddress } = require('../util')
const BalanceComponent = require('./balance-component') const BalanceComponent = require('./balance-component')
const Tooltip = require('./tooltip')
const TxList = require('./tx-list') const TxList = require('./tx-list')
const SelectedAccount = require('./selected-account') const SelectedAccount = require('./selected-account')
@ -103,7 +104,8 @@ TxView.prototype.renderButtons = function () {
} }
TxView.prototype.render = 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', { return h('div.tx-view.flex-column', {
style: {}, style: {},
@ -120,21 +122,30 @@ TxView.prototype.render = function () {
}, },
}, [ }, [
h(Tooltip, {
title: t('menu'),
position: 'bottom',
}, [
h('div.fa.fa-bars', { h('div.fa.fa-bars', {
style: { style: {
fontSize: '1.3em', fontSize: '1.3em',
cursor: 'pointer', cursor: 'pointer',
padding: '10px', padding: '10px',
}, },
onClick: () => this.props.sidebarOpen ? this.props.hideSidebar() : this.props.showSidebar(), onClick: () => sidebarOpen ? hideSidebar() : showSidebar(),
}), }),
]),
h(SelectedAccount), h(SelectedAccount),
!isMascara && h('div.open-in-browser', { !isMascara && h(Tooltip, {
title: t('openInTab'),
position: 'bottom',
}, [
h('div.open-in-browser', {
onClick: () => global.platform.openExtensionInBrowser(), onClick: () => global.platform.openExtensionInBrowser(),
}, [h('img', { src: 'images/popout.svg' })]), }, [h('img', { src: 'images/popout.svg' })]),
]),
]), ]),
this.renderHeroBalance(), this.renderHeroBalance(),

View File

@ -8,8 +8,11 @@ const t = require('../i18n-helper').getMessage
class I18nProvider extends Component { class I18nProvider extends Component {
getChildContext () { getChildContext () {
const { localeMessages } = this.props const { localeMessages } = this.props
const { current, en } = localeMessages
return { return {
t: t.bind(null, localeMessages), t (key, ...args) {
return t(current, key, ...args) || t(en, key, ...args) || `[${key}]`
},
} }
} }

View File

@ -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

View File

@ -1,20 +1,22 @@
// cross-browser connection to extension i18n API // cross-browser connection to extension i18n API
const log = require('loglevel') 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) => { const getMessage = (locale, key, substitutions) => {
// check locale is loaded
if (!locale) { if (!locale) {
// throw new Error('Translator - has not loaded a locale yet.') return null
return ''
} }
// check entry is present if (!locale[key]) {
const { current, en } = locale log.error(`Translator - Unable to find value for key "${key}"`)
const entry = current[key] || en[key] return null
if (!entry) {
// throw new Error(`Translator - Unable to find value for "${key}"`)
log.error(`Translator - Unable to find value for "${key}"`)
return `[${key}]`
} }
const entry = locale[key]
let phrase = entry.message let phrase = entry.message
// perform substitutions // perform substitutions
if (substitutions && substitutions.length) { if (substitutions && substitutions.length) {
@ -29,8 +31,7 @@ const getMessage = (locale, key, substitutions) => {
async function fetchLocale (localeName) { async function fetchLocale (localeName) {
try { try {
const response = await fetch(`./_locales/${localeName}/messages.json`) const response = await fetch(`./_locales/${localeName}/messages.json`)
const locale = await response.json() return await response.json()
return locale
} catch (error) { } catch (error) {
log.error(`failed to fetch ${localeName} locale because of ${error}`) log.error(`failed to fetch ${localeName} locale because of ${error}`)
return {} return {}