|
|
@ -1,7 +1,7 @@ |
|
|
|
const { Component } = require('react') |
|
|
|
const { Component } = require('react') |
|
|
|
const PropTypes = require('prop-types') |
|
|
|
const PropTypes = require('prop-types') |
|
|
|
const h = require('react-hyperscript') |
|
|
|
const h = require('react-hyperscript') |
|
|
|
const connect = require('./metamask-connect') |
|
|
|
const connect = require('react-redux').connect |
|
|
|
const actions = require('./actions') |
|
|
|
const actions = require('./actions') |
|
|
|
const infuraCurrencies = require('./infura-conversion.json') |
|
|
|
const infuraCurrencies = require('./infura-conversion.json') |
|
|
|
const validUrl = require('valid-url') |
|
|
|
const validUrl = require('valid-url') |
|
|
@ -55,8 +55,8 @@ class Settings extends Component { |
|
|
|
return h('div.settings__tabs', [ |
|
|
|
return h('div.settings__tabs', [ |
|
|
|
h(TabBar, { |
|
|
|
h(TabBar, { |
|
|
|
tabs: [ |
|
|
|
tabs: [ |
|
|
|
{ content: this.props.t('settings'), key: 'settings' }, |
|
|
|
{ content: this.context.t('settings'), key: 'settings' }, |
|
|
|
{ content: this.props.t('info'), key: 'info' }, |
|
|
|
{ content: this.context.t('info'), key: 'info' }, |
|
|
|
], |
|
|
|
], |
|
|
|
defaultTab: activeTab, |
|
|
|
defaultTab: activeTab, |
|
|
|
tabSelected: key => this.setState({ activeTab: key }), |
|
|
|
tabSelected: key => this.setState({ activeTab: key }), |
|
|
@ -69,7 +69,7 @@ class Settings extends Component { |
|
|
|
|
|
|
|
|
|
|
|
return h('div.settings__content-row', [ |
|
|
|
return h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('span', this.props.t('blockiesIdenticon')), |
|
|
|
h('span', this.context.t('blockiesIdenticon')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
@ -89,13 +89,13 @@ class Settings extends Component { |
|
|
|
|
|
|
|
|
|
|
|
return h('div.settings__content-row', [ |
|
|
|
return h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('span', this.props.t('currentConversion')), |
|
|
|
h('span', this.context.t('currentConversion')), |
|
|
|
h('span.settings__content-description', `Updated ${Date(conversionDate)}`), |
|
|
|
h('span.settings__content-description', `Updated ${Date(conversionDate)}`), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h(SimpleDropdown, { |
|
|
|
h(SimpleDropdown, { |
|
|
|
placeholder: this.props.t('selectCurrency'), |
|
|
|
placeholder: this.context.t('selectCurrency'), |
|
|
|
options: getInfuraCurrencyOptions(), |
|
|
|
options: getInfuraCurrencyOptions(), |
|
|
|
selectedOption: currentCurrency, |
|
|
|
selectedOption: currentCurrency, |
|
|
|
onSelect: newCurrency => setCurrentCurrency(newCurrency), |
|
|
|
onSelect: newCurrency => setCurrentCurrency(newCurrency), |
|
|
@ -136,31 +136,31 @@ class Settings extends Component { |
|
|
|
switch (provider.type) { |
|
|
|
switch (provider.type) { |
|
|
|
|
|
|
|
|
|
|
|
case 'mainnet': |
|
|
|
case 'mainnet': |
|
|
|
title = this.props.t('currentNetwork') |
|
|
|
title = this.context.t('currentNetwork') |
|
|
|
value = this.props.t('mainnet') |
|
|
|
value = this.context.t('mainnet') |
|
|
|
color = '#038789' |
|
|
|
color = '#038789' |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
case 'ropsten': |
|
|
|
case 'ropsten': |
|
|
|
title = this.props.t('currentNetwork') |
|
|
|
title = this.context.t('currentNetwork') |
|
|
|
value = this.props.t('ropsten') |
|
|
|
value = this.context.t('ropsten') |
|
|
|
color = '#e91550' |
|
|
|
color = '#e91550' |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
case 'kovan': |
|
|
|
case 'kovan': |
|
|
|
title = this.props.t('currentNetwork') |
|
|
|
title = this.context.t('currentNetwork') |
|
|
|
value = this.props.t('kovan') |
|
|
|
value = this.context.t('kovan') |
|
|
|
color = '#690496' |
|
|
|
color = '#690496' |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
case 'rinkeby': |
|
|
|
case 'rinkeby': |
|
|
|
title = this.props.t('currentNetwork') |
|
|
|
title = this.context.t('currentNetwork') |
|
|
|
value = this.props.t('rinkeby') |
|
|
|
value = this.context.t('rinkeby') |
|
|
|
color = '#ebb33f' |
|
|
|
color = '#ebb33f' |
|
|
|
break |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
|
title = this.props.t('currentRpc') |
|
|
|
title = this.context.t('currentRpc') |
|
|
|
value = provider.rpcTarget |
|
|
|
value = provider.rpcTarget |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -181,12 +181,12 @@ class Settings extends Component { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('span', this.props.t('newRPC')), |
|
|
|
h('span', this.context.t('newRPC')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('input.settings__input', { |
|
|
|
h('input.settings__input', { |
|
|
|
placeholder: this.props.t('newRPC'), |
|
|
|
placeholder: this.context.t('newRPC'), |
|
|
|
onChange: event => this.setState({ newRpc: event.target.value }), |
|
|
|
onChange: event => this.setState({ newRpc: event.target.value }), |
|
|
|
onKeyPress: event => { |
|
|
|
onKeyPress: event => { |
|
|
|
if (event.key === 'Enter') { |
|
|
|
if (event.key === 'Enter') { |
|
|
@ -199,7 +199,7 @@ class Settings extends Component { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
this.validateRpc(this.state.newRpc) |
|
|
|
this.validateRpc(this.state.newRpc) |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, this.props.t('save')), |
|
|
|
}, this.context.t('save')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
@ -215,9 +215,9 @@ class Settings extends Component { |
|
|
|
const appendedRpc = `http://${newRpc}` |
|
|
|
const appendedRpc = `http://${newRpc}` |
|
|
|
|
|
|
|
|
|
|
|
if (validUrl.isWebUri(appendedRpc)) { |
|
|
|
if (validUrl.isWebUri(appendedRpc)) { |
|
|
|
displayWarning(this.props.t('uriErrorMsg')) |
|
|
|
displayWarning(this.context.t('uriErrorMsg')) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
displayWarning(this.props.t('invalidRPC')) |
|
|
|
displayWarning(this.context.t('invalidRPC')) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -226,10 +226,10 @@ class Settings extends Component { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div', this.props.t('stateLogs')), |
|
|
|
h('div', this.context.t('stateLogs')), |
|
|
|
h( |
|
|
|
h( |
|
|
|
'div.settings__content-description', |
|
|
|
'div.settings__content-description', |
|
|
|
this.props.t('stateLogsDescription') |
|
|
|
this.context.t('stateLogsDescription') |
|
|
|
), |
|
|
|
), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
@ -238,13 +238,13 @@ class Settings extends Component { |
|
|
|
onClick (event) { |
|
|
|
onClick (event) { |
|
|
|
window.logStateString((err, result) => { |
|
|
|
window.logStateString((err, result) => { |
|
|
|
if (err) { |
|
|
|
if (err) { |
|
|
|
this.state.dispatch(actions.displayWarning(this.props.t('stateLogError'))) |
|
|
|
this.state.dispatch(actions.displayWarning(this.context.t('stateLogError'))) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
exportAsFile('MetaMask State Logs.json', result) |
|
|
|
exportAsFile('MetaMask State Logs.json', result) |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, this.props.t('downloadStateLogs')), |
|
|
|
}, this.context.t('downloadStateLogs')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
@ -256,7 +256,7 @@ class Settings extends Component { |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', this.props.t('revealSeedWords')), |
|
|
|
h('div.settings__content-item', this.context.t('revealSeedWords')), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('button.btn-primary--lg.settings__button--red', { |
|
|
|
h('button.btn-primary--lg.settings__button--red', { |
|
|
@ -264,7 +264,7 @@ class Settings extends Component { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
revealSeedConfirmation() |
|
|
|
revealSeedConfirmation() |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, this.props.t('revealSeedWords')), |
|
|
|
}, this.context.t('revealSeedWords')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
@ -276,7 +276,7 @@ class Settings extends Component { |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', this.props.t('useOldUI')), |
|
|
|
h('div.settings__content-item', this.context.t('useOldUI')), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('button.btn-primary--lg.settings__button--orange', { |
|
|
|
h('button.btn-primary--lg.settings__button--orange', { |
|
|
@ -284,7 +284,7 @@ class Settings extends Component { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
setFeatureFlagToBeta() |
|
|
|
setFeatureFlagToBeta() |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, this.props.t('useOldUI')), |
|
|
|
}, this.context.t('useOldUI')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
@ -295,7 +295,7 @@ class Settings extends Component { |
|
|
|
const { showResetAccountConfirmationModal } = this.props |
|
|
|
const { showResetAccountConfirmationModal } = this.props |
|
|
|
|
|
|
|
|
|
|
|
return h('div.settings__content-row', [ |
|
|
|
return h('div.settings__content-row', [ |
|
|
|
h('div.settings__content-item', this.props.t('resetAccount')), |
|
|
|
h('div.settings__content-item', this.context.t('resetAccount')), |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('div.settings__content-item-col', [ |
|
|
|
h('button.btn-primary--lg.settings__button--orange', { |
|
|
|
h('button.btn-primary--lg.settings__button--orange', { |
|
|
@ -303,7 +303,7 @@ class Settings extends Component { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
showResetAccountConfirmationModal() |
|
|
|
showResetAccountConfirmationModal() |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, this.props.t('resetAccount')), |
|
|
|
}, this.context.t('resetAccount')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
@ -339,13 +339,13 @@ class Settings extends Component { |
|
|
|
renderInfoLinks () { |
|
|
|
renderInfoLinks () { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('div.settings__content-item.settings__content-item--without-height', [ |
|
|
|
h('div.settings__content-item.settings__content-item--without-height', [ |
|
|
|
h('div.settings__info-link-header', this.props.t('links')), |
|
|
|
h('div.settings__info-link-header', this.context.t('links')), |
|
|
|
h('div.settings__info-link-item', [ |
|
|
|
h('div.settings__info-link-item', [ |
|
|
|
h('a', { |
|
|
|
h('a', { |
|
|
|
href: 'https://metamask.io/privacy.html', |
|
|
|
href: 'https://metamask.io/privacy.html', |
|
|
|
target: '_blank', |
|
|
|
target: '_blank', |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('span.settings__info-link', this.props.t('privacyMsg')), |
|
|
|
h('span.settings__info-link', this.context.t('privacyMsg')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__info-link-item', [ |
|
|
|
h('div.settings__info-link-item', [ |
|
|
@ -353,7 +353,7 @@ class Settings extends Component { |
|
|
|
href: 'https://metamask.io/terms.html', |
|
|
|
href: 'https://metamask.io/terms.html', |
|
|
|
target: '_blank', |
|
|
|
target: '_blank', |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('span.settings__info-link', this.props.t('terms')), |
|
|
|
h('span.settings__info-link', this.context.t('terms')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__info-link-item', [ |
|
|
|
h('div.settings__info-link-item', [ |
|
|
@ -361,7 +361,7 @@ class Settings extends Component { |
|
|
|
href: 'https://metamask.io/attributions.html', |
|
|
|
href: 'https://metamask.io/attributions.html', |
|
|
|
target: '_blank', |
|
|
|
target: '_blank', |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('span.settings__info-link', this.props.t('attributions')), |
|
|
|
h('span.settings__info-link', this.context.t('attributions')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('hr.settings__info-separator'), |
|
|
|
h('hr.settings__info-separator'), |
|
|
@ -370,7 +370,7 @@ class Settings extends Component { |
|
|
|
href: 'https://support.metamask.io', |
|
|
|
href: 'https://support.metamask.io', |
|
|
|
target: '_blank', |
|
|
|
target: '_blank', |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('span.settings__info-link', this.props.t('supportCenter')), |
|
|
|
h('span.settings__info-link', this.context.t('supportCenter')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__info-link-item', [ |
|
|
|
h('div.settings__info-link-item', [ |
|
|
@ -378,7 +378,7 @@ class Settings extends Component { |
|
|
|
href: 'https://metamask.io/', |
|
|
|
href: 'https://metamask.io/', |
|
|
|
target: '_blank', |
|
|
|
target: '_blank', |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('span.settings__info-link', this.props.t('visitWebSite')), |
|
|
|
h('span.settings__info-link', this.context.t('visitWebSite')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
h('div.settings__info-link-item', [ |
|
|
|
h('div.settings__info-link-item', [ |
|
|
@ -386,7 +386,7 @@ class Settings extends Component { |
|
|
|
target: '_blank', |
|
|
|
target: '_blank', |
|
|
|
href: 'mailto:help@metamask.io?subject=Feedback', |
|
|
|
href: 'mailto:help@metamask.io?subject=Feedback', |
|
|
|
}, [ |
|
|
|
}, [ |
|
|
|
h('span.settings__info-link', this.props.t('emailUs')), |
|
|
|
h('span.settings__info-link', this.context.t('emailUs')), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]) |
|
|
|
]) |
|
|
@ -408,7 +408,7 @@ class Settings extends Component { |
|
|
|
h('div.settings__info-item', [ |
|
|
|
h('div.settings__info-item', [ |
|
|
|
h( |
|
|
|
h( |
|
|
|
'div.settings__info-about', |
|
|
|
'div.settings__info-about', |
|
|
|
this.props.t('builtInCalifornia') |
|
|
|
this.context.t('builtInCalifornia') |
|
|
|
), |
|
|
|
), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
|
]), |
|
|
@ -485,4 +485,9 @@ const mapDispatchToProps = dispatch => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Settings.contextTypes = { |
|
|
|
|
|
|
|
t: PropTypes.func, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(Settings) |
|
|
|
module.exports = connect(mapStateToProps, mapDispatchToProps)(Settings) |
|
|
|
|
|
|
|
|
|
|
|