|
|
@ -4,11 +4,13 @@ const h = require('react-hyperscript') |
|
|
|
const connect = require('react-redux').connect |
|
|
|
const connect = require('react-redux').connect |
|
|
|
const actions = require('./actions') |
|
|
|
const actions = require('./actions') |
|
|
|
const currencies = require('./conversion.json').rows |
|
|
|
const currencies = require('./conversion.json').rows |
|
|
|
|
|
|
|
const validUrl = require('valid-url') |
|
|
|
module.exports = connect(mapStateToProps)(ConfigScreen) |
|
|
|
module.exports = connect(mapStateToProps)(ConfigScreen) |
|
|
|
|
|
|
|
|
|
|
|
function mapStateToProps (state) { |
|
|
|
function mapStateToProps (state) { |
|
|
|
return { |
|
|
|
return { |
|
|
|
metamask: state.metamask, |
|
|
|
metamask: state.metamask, |
|
|
|
|
|
|
|
warning: state.appState.warning, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -20,6 +22,7 @@ function ConfigScreen () { |
|
|
|
ConfigScreen.prototype.render = function () { |
|
|
|
ConfigScreen.prototype.render = function () { |
|
|
|
var state = this.props |
|
|
|
var state = this.props |
|
|
|
var metamaskState = state.metamask |
|
|
|
var metamaskState = state.metamask |
|
|
|
|
|
|
|
var warning = state.warning |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
h('.flex-column.flex-grow', [ |
|
|
|
h('.flex-column.flex-grow', [ |
|
|
@ -34,6 +37,14 @@ ConfigScreen.prototype.render = function () { |
|
|
|
h('h2.page-subtitle', 'Settings'), |
|
|
|
h('h2.page-subtitle', 'Settings'), |
|
|
|
]), |
|
|
|
]), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
h('.error', { |
|
|
|
|
|
|
|
style: { |
|
|
|
|
|
|
|
display: warning ? 'block' : 'none', |
|
|
|
|
|
|
|
padding: '0 20px', |
|
|
|
|
|
|
|
textAlign: 'center', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, warning), |
|
|
|
|
|
|
|
|
|
|
|
// conf view
|
|
|
|
// conf view
|
|
|
|
h('.flex-column.flex-justify-center.flex-grow.select-none', [ |
|
|
|
h('.flex-column.flex-justify-center.flex-grow.select-none', [ |
|
|
|
h('.flex-space-around', { |
|
|
|
h('.flex-space-around', { |
|
|
@ -57,7 +68,7 @@ ConfigScreen.prototype.render = function () { |
|
|
|
if (event.key === 'Enter') { |
|
|
|
if (event.key === 'Enter') { |
|
|
|
var element = event.target |
|
|
|
var element = event.target |
|
|
|
var newRpc = element.value |
|
|
|
var newRpc = element.value |
|
|
|
state.dispatch(actions.setRpcTarget(newRpc)) |
|
|
|
rpcValidation(newRpc, state) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}), |
|
|
|
}), |
|
|
@ -69,7 +80,7 @@ ConfigScreen.prototype.render = function () { |
|
|
|
event.preventDefault() |
|
|
|
event.preventDefault() |
|
|
|
var element = document.querySelector('input#new_rpc') |
|
|
|
var element = document.querySelector('input#new_rpc') |
|
|
|
var newRpc = element.value |
|
|
|
var newRpc = element.value |
|
|
|
state.dispatch(actions.setRpcTarget(newRpc)) |
|
|
|
rpcValidation(newRpc, state) |
|
|
|
}, |
|
|
|
}, |
|
|
|
}, 'Save'), |
|
|
|
}, 'Save'), |
|
|
|
]), |
|
|
|
]), |
|
|
@ -99,6 +110,19 @@ ConfigScreen.prototype.render = function () { |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function rpcValidation (newRpc, state) { |
|
|
|
|
|
|
|
if (validUrl.isWebUri(newRpc)) { |
|
|
|
|
|
|
|
state.dispatch(actions.setRpcTarget(newRpc)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
var appendedRpc = `http://${newRpc}` |
|
|
|
|
|
|
|
if (validUrl.isWebUri(appendedRpc)) { |
|
|
|
|
|
|
|
state.dispatch(actions.displayWarning('URIs require the appropriate HTTP/HTTPS prefix.')) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
state.dispatch(actions.displayWarning('Invalid RPC URI')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function currentConversionInformation (metamaskState, state) { |
|
|
|
function currentConversionInformation (metamaskState, state) { |
|
|
|
var currentFiat = metamaskState.currentFiat |
|
|
|
var currentFiat = metamaskState.currentFiat |
|
|
|
var conversionDate = metamaskState.conversionDate |
|
|
|
var conversionDate = metamaskState.conversionDate |
|
|
|