wip
This commit is contained in:
parent
6ed22a7c6e
commit
0c2e0ca9b3
|
@ -8,12 +8,13 @@ const createBlockTrackerInspectorMiddleware = require('eth-json-rpc-middleware/b
|
||||||
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware')
|
const providerFromMiddleware = require('eth-json-rpc-middleware/providerFromMiddleware')
|
||||||
const createPocketMiddleware = require('json-rpc-pocket')
|
const createPocketMiddleware = require('json-rpc-pocket')
|
||||||
const BlockTracker = require('eth-block-tracker')
|
const BlockTracker = require('eth-block-tracker')
|
||||||
|
const devid = 'DEVO7QQqPHCK2h3cGXhh2rY'
|
||||||
|
|
||||||
module.exports = createPocketClient
|
module.exports = createPocketClient
|
||||||
|
|
||||||
function createPocketClient ({ network }) {
|
function createPocketClient ({ network }) {
|
||||||
const pocketMiddleware = createPocketMiddleware('DEVO7QQqPHCK2h3cGXhh2rY', {
|
const pocketMiddleware = createPocketMiddleware(devid, {
|
||||||
netID: getNetworkIds(network).netId,
|
netID: getNetworkIds({ network }).netId,
|
||||||
})
|
})
|
||||||
const pocketProvider = providerFromMiddleware(pocketMiddleware)
|
const pocketProvider = providerFromMiddleware(pocketMiddleware)
|
||||||
const blockTracker = new BlockTracker({ provider: pocketProvider })
|
const blockTracker = new BlockTracker({ provider: pocketProvider })
|
||||||
|
@ -33,8 +34,7 @@ function createPocketClient ({ network }) {
|
||||||
function getNetworkIds ({ network }) {
|
function getNetworkIds ({ network }) {
|
||||||
let chainId
|
let chainId
|
||||||
let netId
|
let netId
|
||||||
|
|
||||||
console.log(network)
|
|
||||||
switch (network) {
|
switch (network) {
|
||||||
case 'mainnet':
|
case 'mainnet':
|
||||||
netId = '1'
|
netId = '1'
|
||||||
|
@ -65,7 +65,7 @@ function getNetworkIds ({ network }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNetworkAndChainIdMiddleware ({ network }) {
|
function createNetworkAndChainIdMiddleware ({ network }) {
|
||||||
const networkIds = getNetworkIds(network)
|
const networkIds = getNetworkIds({network})
|
||||||
|
|
||||||
return createScaffoldMiddleware({
|
return createScaffoldMiddleware({
|
||||||
eth_chainId: networkIds.chainId,
|
eth_chainId: networkIds.chainId,
|
||||||
|
|
|
@ -10,7 +10,7 @@ const createMetamaskMiddleware = require('./createMetamaskMiddleware')
|
||||||
const createInfuraClient = require('./createInfuraClient')
|
const createInfuraClient = require('./createInfuraClient')
|
||||||
const createJsonRpcClient = require('./createJsonRpcClient')
|
const createJsonRpcClient = require('./createJsonRpcClient')
|
||||||
const createLocalhostClient = require('./createLocalhostClient')
|
const createLocalhostClient = require('./createLocalhostClient')
|
||||||
//const createPocketClient = require('./createPocketClient')
|
const createPocketClient = require('./createPocketClient')
|
||||||
const { createSwappableProxy, createEventEmitterProxy } = require('swappable-obj-proxy')
|
const { createSwappableProxy, createEventEmitterProxy } = require('swappable-obj-proxy')
|
||||||
const ethNetProps = require('eth-net-props')
|
const ethNetProps = require('eth-net-props')
|
||||||
const parse = require('url-parse')
|
const parse = require('url-parse')
|
||||||
|
@ -56,7 +56,8 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
// create stores
|
// create stores
|
||||||
this.providerStore = new ObservableStore(providerConfig)
|
this.providerStore = new ObservableStore(providerConfig)
|
||||||
this.networkStore = new ObservableStore('loading')
|
this.networkStore = new ObservableStore('loading')
|
||||||
this.store = new ComposedStore({ provider: this.providerStore, network: this.networkStore, dProvider: false })
|
this.dProviderStore = new ObservableStore({dProvider: false})
|
||||||
|
this.store = new ComposedStore({ provider: this.providerStore, network: this.networkStore, dProviderStore: this.dProviderStore })
|
||||||
this.on('networkDidChange', this.lookupNetwork)
|
this.on('networkDidChange', this.lookupNetwork)
|
||||||
// provider and block tracker
|
// provider and block tracker
|
||||||
this._provider = null
|
this._provider = null
|
||||||
|
@ -154,12 +155,13 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
getDProvider(){
|
getDProvider(){
|
||||||
return this.store.getState().dProvider
|
return this.dProviderStore.getState().dProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
setDProvider(key){
|
setDProvider(key){
|
||||||
this.store.updateState({
|
console.log("UPDATING STATE TO " + key)
|
||||||
dProvider: key
|
this.dProviderStore.updateState({
|
||||||
|
dProvider: key,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,11 +180,10 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
// infura type-based endpoints
|
// infura type-based endpoints
|
||||||
const isInfura = INFURA_PROVIDER_TYPES.includes(type)
|
const isInfura = INFURA_PROVIDER_TYPES.includes(type)
|
||||||
if (isInfura) {
|
if (isInfura) {
|
||||||
if (this.store.dProvider) {
|
console.log(this.dProviderStore.getState())
|
||||||
// log.debug("IS POCKET")
|
if (this.dProviderStore.getState().dProvider) {
|
||||||
this._configurePocketProvider(opts)
|
this._configurePocketProvider(opts)
|
||||||
} else {
|
} else {
|
||||||
// log.debug("IS INFURA")
|
|
||||||
this._configureInfuraProvider(opts)
|
this._configureInfuraProvider(opts)
|
||||||
}
|
}
|
||||||
// other type-based rpc endpoints
|
// other type-based rpc endpoints
|
||||||
|
@ -218,8 +219,7 @@ module.exports = class NetworkController extends EventEmitter {
|
||||||
|
|
||||||
_configurePocketProvider ({ type }) {
|
_configurePocketProvider ({ type }) {
|
||||||
log.info('NetworkController - configurePocketProvider', type)
|
log.info('NetworkController - configurePocketProvider', type)
|
||||||
//const networkClient = createPocketClient({ network: type })
|
const networkClient = createPocketClient({ network: type })
|
||||||
const networkClient = createInfuraClient({ network: type })
|
|
||||||
this._setNetworkClient(networkClient)
|
this._setNetworkClient(networkClient)
|
||||||
// setup networkConfig
|
// setup networkConfig
|
||||||
var settings = {
|
var settings = {
|
||||||
|
|
|
@ -1757,6 +1757,7 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||||
* @param {Function} cb - A callback function called when complete.
|
* @param {Function} cb - A callback function called when complete.
|
||||||
*/
|
*/
|
||||||
setDProvider (key, cb) {
|
setDProvider (key, cb) {
|
||||||
|
console.log("SETDPROVIDER CALLED ON METAMASK CONTROLLER" + key)
|
||||||
try {
|
try {
|
||||||
this.networkController.setDProvider(key)
|
this.networkController.setDProvider(key)
|
||||||
cb(null)
|
cb(null)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
const inherits = require('util').inherits
|
||||||
const Component = require('react').Component
|
const Component = require('react').Component
|
||||||
const h = require('react-hyperscript')
|
const h = require('react-hyperscript')
|
||||||
const connect = require('react-redux').connect
|
const connect = require('react-redux').connect
|
||||||
import PropTypes from 'prop-types'
|
|
||||||
const actions = require('../../ui/app/actions')
|
const actions = require('../../ui/app/actions')
|
||||||
const LoadingIndicator = require('./components/loading')
|
const LoadingIndicator = require('./components/loading')
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
|
@ -14,22 +14,18 @@ const Modal = require('../../ui/app/components/modals/index').Modal
|
||||||
const ethNetProps = require('eth-net-props')
|
const ethNetProps = require('eth-net-props')
|
||||||
const { networks } = require('../../app/scripts/controllers/network/util')
|
const { networks } = require('../../app/scripts/controllers/network/util')
|
||||||
|
|
||||||
class ConfigScreen extends Component {
|
module.exports = connect(mapStateToProps)(ConfigScreen)
|
||||||
|
|
||||||
constructor (props) {
|
function mapStateToProps (state) {
|
||||||
super(props)
|
return {
|
||||||
this.state = {
|
metamask: state.metamask,
|
||||||
loading: false,
|
warning: state.appState.warning,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<<<<<<< ef400f8d291b983ac5a95bb2d4a3287dae588f76
|
|
||||||
static propTypes = {
|
|
||||||
dispatch: PropTypes.func,
|
|
||||||
=======
|
|
||||||
inherits(ConfigScreen, Component)
|
inherits(ConfigScreen, Component)
|
||||||
function ConfigScreen (props) {
|
function ConfigScreen (props) {
|
||||||
if (props.metamask.dProvider){
|
if (props.metamask.dProviderStore.dProvider){
|
||||||
this.state = {
|
this.state = {
|
||||||
loading: false,
|
loading: false,
|
||||||
provider: "Decentralized"
|
provider: "Decentralized"
|
||||||
|
@ -39,110 +35,167 @@ function ConfigScreen (props) {
|
||||||
loading: false,
|
loading: false,
|
||||||
provider: "Centralized"
|
provider: "Centralized"
|
||||||
}
|
}
|
||||||
>>>>>>> wip
|
|
||||||
}
|
}
|
||||||
|
Component.call(this)
|
||||||
|
}
|
||||||
|
|
||||||
render () {
|
ConfigScreen.prototype.render = function () {
|
||||||
const state = this.props
|
const state = this.props
|
||||||
const metamaskState = state.metamask
|
const metamaskState = state.metamask
|
||||||
const warning = state.warning
|
const warning = state.warning
|
||||||
|
|
||||||
return (
|
return (
|
||||||
h('.flex-column.flex-grow', {
|
h('.flex-column.flex-grow', {
|
||||||
|
style: {
|
||||||
|
maxHeight: '585px',
|
||||||
|
overflowY: 'auto',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
|
||||||
|
h(LoadingIndicator, {
|
||||||
|
isLoading: this.state.loading,
|
||||||
|
}),
|
||||||
|
|
||||||
|
h(Modal, {}, []),
|
||||||
|
|
||||||
|
// subtitle and nav
|
||||||
|
h('.section-title.flex-row.flex-center', [
|
||||||
|
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
||||||
|
onClick: () => {
|
||||||
|
state.dispatch(actions.goHome())
|
||||||
|
},
|
||||||
|
style: {
|
||||||
|
position: 'absolute',
|
||||||
|
left: '30px',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
h('h2', 'Settings'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('div', {
|
||||||
style: {
|
style: {
|
||||||
maxHeight: '585px',
|
margin: '0 30px',
|
||||||
overflowY: 'auto',
|
|
||||||
},
|
},
|
||||||
}, [
|
}, [
|
||||||
|
h('.error', {
|
||||||
h(LoadingIndicator, {
|
|
||||||
isLoading: this.state.loading,
|
|
||||||
}),
|
|
||||||
|
|
||||||
h(Modal, {}, []),
|
|
||||||
|
|
||||||
// subtitle and nav
|
|
||||||
h('.section-title.flex-row.flex-center', [
|
|
||||||
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
|
|
||||||
onClick: () => {
|
|
||||||
state.dispatch(actions.goHome())
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
position: 'absolute',
|
|
||||||
left: '30px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
h('h2', 'Settings'),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('div', {
|
|
||||||
style: {
|
style: {
|
||||||
margin: '0 30px',
|
display: warning ? 'block' : 'none',
|
||||||
|
},
|
||||||
|
}, warning),
|
||||||
|
]),
|
||||||
|
|
||||||
|
// conf view
|
||||||
|
h('.flex-column.flex-justify-center.flex-grow.select-none', [
|
||||||
|
h('.flex-space-around', {
|
||||||
|
style: {
|
||||||
|
padding: '30px',
|
||||||
|
overflow: 'auto',
|
||||||
},
|
},
|
||||||
}, [
|
}, [
|
||||||
h('.error', {
|
|
||||||
style: {
|
|
||||||
display: warning ? 'block' : 'none',
|
|
||||||
},
|
|
||||||
}, warning),
|
|
||||||
]),
|
|
||||||
|
|
||||||
// conf view
|
currentProviderDisplay(metamaskState, state),
|
||||||
h('.flex-column.flex-justify-center.flex-grow.select-none', [
|
|
||||||
h('.flex-space-around', {
|
|
||||||
style: {
|
|
||||||
padding: '30px',
|
|
||||||
overflow: 'auto',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
|
|
||||||
this.currentProviderDisplay(metamaskState, state),
|
h('div', { style: {display: 'flex'} }, [
|
||||||
|
h('input#new_rpc', {
|
||||||
<<<<<<< ef400f8d291b983ac5a95bb2d4a3287dae588f76
|
placeholder: 'New RPC URL',
|
||||||
h('div', { style: {display: 'flex'} }, [
|
style: {
|
||||||
h('input#new_rpc', {
|
width: 'inherit',
|
||||||
placeholder: 'New RPC URL',
|
flex: '1 0 auto',
|
||||||
style: {
|
height: '32px',
|
||||||
width: 'inherit',
|
margin: '20px 20px 0 0',
|
||||||
flex: '1 0 auto',
|
borderRadius: '3px',
|
||||||
height: '32px',
|
border: '1px solid #e2e2e2',
|
||||||
margin: '20px 20px 0 0',
|
padding: '10px',
|
||||||
borderRadius: '3px',
|
},
|
||||||
border: '1px solid #e2e2e2',
|
onKeyPress: (event) => {
|
||||||
padding: '10px',
|
if (event.key === 'Enter') {
|
||||||
},
|
const element = event.target
|
||||||
onKeyPress: (event) => {
|
|
||||||
if (event.key === 'Enter') {
|
|
||||||
const element = event.target
|
|
||||||
const newRpc = element.value
|
|
||||||
this.rpcValidation(newRpc, state)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
h('button', {
|
|
||||||
style: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
marginTop: '20px',
|
|
||||||
},
|
|
||||||
onClick: (event) => {
|
|
||||||
event.preventDefault()
|
|
||||||
const element = document.querySelector('input#new_rpc')
|
|
||||||
const newRpc = element.value
|
const newRpc = element.value
|
||||||
this.rpcValidation(newRpc, state)
|
this.rpcValidation(newRpc, state)
|
||||||
},
|
}
|
||||||
}, 'Save'),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('hr.horizontal-line'),
|
|
||||||
|
|
||||||
this.currentConversionInformation(metamaskState, state),
|
|
||||||
|
|
||||||
h('hr.horizontal-line', {
|
|
||||||
style: {
|
|
||||||
marginTop: '20px',
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
=======
|
h('button', {
|
||||||
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
onClick: (event) => {
|
||||||
|
event.preventDefault()
|
||||||
|
const element = document.querySelector('input#new_rpc')
|
||||||
|
const newRpc = element.value
|
||||||
|
this.rpcValidation(newRpc, state)
|
||||||
|
},
|
||||||
|
}, 'Save'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('hr.horizontal-line'),
|
||||||
|
|
||||||
|
currentConversionInformation(metamaskState, state),
|
||||||
|
|
||||||
|
h('hr.horizontal-line', {
|
||||||
|
style: {
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
h('div', {
|
||||||
|
style: {
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('p', {
|
||||||
|
style: {
|
||||||
|
fontFamily: 'Nunito Regular',
|
||||||
|
fontSize: '14px',
|
||||||
|
lineHeight: '18px',
|
||||||
|
},
|
||||||
|
}, `State logs contain your public account addresses and sent transactions.`),
|
||||||
|
h('br'),
|
||||||
|
h('button', {
|
||||||
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
},
|
||||||
|
onClick (event) {
|
||||||
|
window.logStateString((err, result) => {
|
||||||
|
if (err) {
|
||||||
|
state.dispatch(actions.displayWarning('Error in retrieving state logs.'))
|
||||||
|
} else {
|
||||||
|
exportAsFile('Nifty Wallet State Logs.json', result)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, 'Download State Logs'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('hr.horizontal-line', {
|
||||||
|
style: {
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
|
h('div', {
|
||||||
|
style: {
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
}, [
|
||||||
|
h('button', {
|
||||||
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
},
|
||||||
|
onClick (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
state.dispatch(actions.revealSeedConfirmation())
|
||||||
|
},
|
||||||
|
}, 'Reveal Seed Words'),
|
||||||
|
]),
|
||||||
|
|
||||||
|
h('hr.horizontal-line', {
|
||||||
|
style: {
|
||||||
|
marginTop: '20px',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
|
||||||
// POCKET NETWORK UI CHANGES START
|
// POCKET NETWORK UI CHANGES START
|
||||||
h('p', {
|
h('p', {
|
||||||
style: {
|
style: {
|
||||||
|
@ -177,220 +230,137 @@ function ConfigScreen (props) {
|
||||||
marginTop: '20px',
|
marginTop: '20px',
|
||||||
},
|
},
|
||||||
}, [
|
}, [
|
||||||
>>>>>>> wip
|
|
||||||
|
|
||||||
h('div', {
|
h('p', {
|
||||||
style: {
|
style: {
|
||||||
marginTop: '20px',
|
fontFamily: 'Nunito Regular',
|
||||||
|
fontSize: '14px',
|
||||||
|
lineHeight: '18px',
|
||||||
},
|
},
|
||||||
}, [
|
}, [
|
||||||
h('p', {
|
'Resetting is for developer use only. ',
|
||||||
style: {
|
|
||||||
fontFamily: 'Nunito Regular',
|
|
||||||
fontSize: '14px',
|
|
||||||
lineHeight: '18px',
|
|
||||||
},
|
|
||||||
}, `State logs contain your public account addresses and sent transactions.`),
|
|
||||||
h('br'),
|
|
||||||
h('button', {
|
|
||||||
style: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
},
|
|
||||||
onClick (event) {
|
|
||||||
window.logStateString((err, result) => {
|
|
||||||
if (err) {
|
|
||||||
state.dispatch(actions.displayWarning('Error in retrieving state logs.'))
|
|
||||||
} else {
|
|
||||||
exportAsFile('Nifty Wallet State Logs.json', result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}, 'Download State Logs'),
|
|
||||||
]),
|
]),
|
||||||
|
h('br'),
|
||||||
|
|
||||||
h('hr.horizontal-line', {
|
|
||||||
style: {
|
|
||||||
marginTop: '20px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
h('div', {
|
|
||||||
style: {
|
|
||||||
marginTop: '20px',
|
|
||||||
},
|
|
||||||
}, [
|
|
||||||
h('button', {
|
|
||||||
style: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
},
|
|
||||||
onClick (event) {
|
|
||||||
event.preventDefault()
|
|
||||||
state.dispatch(actions.revealSeedConfirmation())
|
|
||||||
},
|
|
||||||
}, 'Reveal Seed Words'),
|
|
||||||
]),
|
|
||||||
|
|
||||||
h('hr.horizontal-line', {
|
|
||||||
style: {
|
|
||||||
marginTop: '20px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
<<<<<<< ef400f8d291b983ac5a95bb2d4a3287dae588f76
|
|
||||||
|
|
||||||
h('div', {
|
|
||||||
=======
|
|
||||||
h('button', {
|
h('button', {
|
||||||
>>>>>>> wip
|
style: {
|
||||||
|
alignSelf: 'center',
|
||||||
|
},
|
||||||
|
onClick (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
state.dispatch(actions.resetAccount())
|
||||||
|
},
|
||||||
|
}, 'Reset Account'),
|
||||||
|
|
||||||
|
h('hr.horizontal-line', {
|
||||||
style: {
|
style: {
|
||||||
marginTop: '20px',
|
marginTop: '20px',
|
||||||
},
|
},
|
||||||
}, [
|
}),
|
||||||
|
h('button', {
|
||||||
h('p', {
|
style: {
|
||||||
style: {
|
alignSelf: 'center',
|
||||||
fontFamily: 'Nunito Regular',
|
},
|
||||||
fontSize: '14px',
|
onClick (event) {
|
||||||
lineHeight: '18px',
|
event.preventDefault()
|
||||||
},
|
state.dispatch(actions.confirmChangePassword())
|
||||||
}, [
|
},
|
||||||
'Resetting is for developer use only. ',
|
}, 'Change password'),
|
||||||
]),
|
|
||||||
h('br'),
|
|
||||||
|
|
||||||
h('button', {
|
|
||||||
style: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
},
|
|
||||||
onClick (event) {
|
|
||||||
event.preventDefault()
|
|
||||||
state.dispatch(actions.resetAccount())
|
|
||||||
},
|
|
||||||
}, 'Reset Account'),
|
|
||||||
|
|
||||||
h('hr.horizontal-line', {
|
|
||||||
style: {
|
|
||||||
marginTop: '20px',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
|
|
||||||
h('button', {
|
|
||||||
style: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
},
|
|
||||||
onClick (event) {
|
|
||||||
event.preventDefault()
|
|
||||||
state.dispatch(actions.confirmChangePassword())
|
|
||||||
},
|
|
||||||
}, 'Change password'),
|
|
||||||
]),
|
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
])
|
]),
|
||||||
)
|
])
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
<<<<<<< ef400f8d291b983ac5a95bb2d4a3287dae588f76
|
|
||||||
componentWillUnmount () {
|
|
||||||
this.props.dispatch(actions.displayWarning(''))
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
ConfigScreen.prototype.toggleProvider = function (){
|
ConfigScreen.prototype.toggleProvider = function (){
|
||||||
// console.log(this)
|
console.log(this)
|
||||||
|
console.log(this.props.metamask.provider.type)
|
||||||
if (this.state.provider == "Centralized"){
|
if (this.state.provider == "Centralized"){
|
||||||
this.setState({
|
this.setState({
|
||||||
provider: "Decentralized"
|
provider: "Decentralized"
|
||||||
})
|
})
|
||||||
this.props.dispatch(actions.setDProvider(true))
|
this.props.dispatch(actions.setDProvider(true))
|
||||||
|
this.props.dispatch(actions.setProviderType(this.props.metamask.provider.type))
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
provider: "Centralized"
|
provider: "Centralized"
|
||||||
})
|
})
|
||||||
this.props.dispatch(actions.setDProvider(false))
|
this.props.dispatch(actions.setDProvider(false))
|
||||||
|
this.props.dispatch(actions.setProviderType(this.props.metamask.provider.type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigScreen.prototype.componentWillUnmount = function () {
|
ConfigScreen.prototype.componentWillUnmount = function () {
|
||||||
this.props.dispatch(actions.displayWarning(''))
|
this.props.dispatch(actions.displayWarning(''))
|
||||||
}
|
}
|
||||||
>>>>>>> wip
|
|
||||||
|
|
||||||
rpcValidation (newRpc, state) {
|
ConfigScreen.prototype.rpcValidation = function (newRpc, state) {
|
||||||
if (validUrl.isWebUri(newRpc)) {
|
if (validUrl.isWebUri(newRpc)) {
|
||||||
this.setState({
|
this.setState({
|
||||||
loading: true,
|
loading: true,
|
||||||
})
|
})
|
||||||
const web3 = new Web3(new Web3.providers.HttpProvider(newRpc))
|
const web3 = new Web3(new Web3.providers.HttpProvider(newRpc))
|
||||||
web3.eth.getBlockNumber((err, res) => {
|
web3.eth.getBlockNumber((err, res) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
state.dispatch(actions.displayWarning('Invalid RPC endpoint'))
|
state.dispatch(actions.displayWarning('Invalid RPC endpoint'))
|
||||||
} else {
|
|
||||||
state.dispatch(actions.setRpcTarget(newRpc))
|
|
||||||
}
|
|
||||||
this.setState({
|
|
||||||
loading: false,
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
if (!newRpc.startsWith('http')) {
|
|
||||||
state.dispatch(actions.displayWarning('URIs require the appropriate HTTP/HTTPS prefix.'))
|
|
||||||
} else {
|
} else {
|
||||||
state.dispatch(actions.displayWarning('Invalid RPC URI'))
|
state.dispatch(actions.setRpcTarget(newRpc))
|
||||||
}
|
}
|
||||||
}
|
this.setState({
|
||||||
}
|
loading: false,
|
||||||
|
|
||||||
currentConversionInformation (metamaskState, state) {
|
|
||||||
const currentCurrency = metamaskState.currentCurrency
|
|
||||||
const conversionDate = metamaskState.conversionDate
|
|
||||||
return h('div', [
|
|
||||||
h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, 'Current Conversion'),
|
|
||||||
h('span', {style: { fontWeight: 'bold', paddingRight: '10px', fontSize: '13px'}}, `Updated ${Date(conversionDate)}`),
|
|
||||||
h('select#currentCurrency', {
|
|
||||||
onChange (event) {
|
|
||||||
event.preventDefault()
|
|
||||||
const element = document.getElementById('currentCurrency')
|
|
||||||
const newCurrency = element.value
|
|
||||||
state.dispatch(actions.setCurrentCurrency(newCurrency))
|
|
||||||
},
|
|
||||||
defaultValue: currentCurrency,
|
|
||||||
}, infuraCurrencies.map((currency) => {
|
|
||||||
return h('option', {key: currency.quote.code, value: currency.quote.code}, `${currency.quote.code.toUpperCase()} - ${currency.quote.name}`)
|
|
||||||
})
|
})
|
||||||
),
|
})
|
||||||
])
|
} else {
|
||||||
}
|
if (!newRpc.startsWith('http')) {
|
||||||
|
state.dispatch(actions.displayWarning('URIs require the appropriate HTTP/HTTPS prefix.'))
|
||||||
currentProviderDisplay (metamaskState, state) {
|
|
||||||
const provider = metamaskState.provider
|
|
||||||
let title, value
|
|
||||||
|
|
||||||
if (networks[provider.type]) {
|
|
||||||
title = 'Current Network'
|
|
||||||
value = ethNetProps.props.getNetworkDisplayName(networks[provider.type].networkID)
|
|
||||||
} else {
|
} else {
|
||||||
title = 'Current RPC'
|
state.dispatch(actions.displayWarning('Invalid RPC URI'))
|
||||||
value = metamaskState.provider.rpcTarget
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return h('div', [
|
|
||||||
h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, title),
|
|
||||||
h('span', value),
|
|
||||||
provider.type === 'rpc' && h('button', {
|
|
||||||
onClick (event) {
|
|
||||||
event.preventDefault()
|
|
||||||
state.dispatch(actions.showDeleteRPC())
|
|
||||||
},
|
|
||||||
}, 'Delete'),
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapStateToProps (state) {
|
|
||||||
return {
|
|
||||||
metamask: state.metamask,
|
|
||||||
warning: state.appState.warning,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = connect(mapStateToProps)(ConfigScreen)
|
function currentConversionInformation (metamaskState, state) {
|
||||||
|
const currentCurrency = metamaskState.currentCurrency
|
||||||
|
const conversionDate = metamaskState.conversionDate
|
||||||
|
return h('div', [
|
||||||
|
h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, 'Current Conversion'),
|
||||||
|
h('span', {style: { fontWeight: 'bold', paddingRight: '10px', fontSize: '13px'}}, `Updated ${Date(conversionDate)}`),
|
||||||
|
h('select#currentCurrency', {
|
||||||
|
onChange (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
const element = document.getElementById('currentCurrency')
|
||||||
|
const newCurrency = element.value
|
||||||
|
state.dispatch(actions.setCurrentCurrency(newCurrency))
|
||||||
|
},
|
||||||
|
defaultValue: currentCurrency,
|
||||||
|
}, infuraCurrencies.map((currency) => {
|
||||||
|
return h('option', {key: currency.quote.code, value: currency.quote.code}, `${currency.quote.code.toUpperCase()} - ${currency.quote.name}`)
|
||||||
|
})
|
||||||
|
),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
function currentProviderDisplay (metamaskState, state) {
|
||||||
|
const provider = metamaskState.provider
|
||||||
|
let title, value
|
||||||
|
|
||||||
|
if (networks[provider.type]) {
|
||||||
|
title = 'Current Network'
|
||||||
|
value = ethNetProps.props.getNetworkDisplayName(networks[provider.type].networkID)
|
||||||
|
} else {
|
||||||
|
title = 'Current RPC'
|
||||||
|
value = metamaskState.provider.rpcTarget
|
||||||
|
}
|
||||||
|
|
||||||
|
return h('div', [
|
||||||
|
h('span', {style: { fontWeight: 'bold', paddingRight: '10px'}}, title),
|
||||||
|
h('span', value),
|
||||||
|
provider.type === 'rpc' && h('button', {
|
||||||
|
onClick (event) {
|
||||||
|
event.preventDefault()
|
||||||
|
state.dispatch(actions.showDeleteRPC())
|
||||||
|
},
|
||||||
|
}, 'Delete'),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
|
@ -2652,10 +2652,20 @@ function updateCurrentLocale (key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDProvider(key){
|
function setDProvider (val) {
|
||||||
return {
|
return (dispatch) => {
|
||||||
type: actions.SET_DPROVIDER,
|
dispatch(actions.showLoadingIndication())
|
||||||
value: key,
|
log.debug(`background.setDProvider`)
|
||||||
|
background.setDProvider(val, (err) => {
|
||||||
|
dispatch(actions.hideLoadingIndication())
|
||||||
|
if (err) {
|
||||||
|
return dispatch(actions.displayWarning(err.message))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
dispatch({
|
||||||
|
type: actions.SET_DPROVIDER,
|
||||||
|
value: val,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -356,7 +356,9 @@ function reduceMetamask (state, action) {
|
||||||
|
|
||||||
case actions.SET_DPROVIDER:
|
case actions.SET_DPROVIDER:
|
||||||
return extend(metamaskState, {
|
return extend(metamaskState, {
|
||||||
dProvider: action.value
|
dProviderStore: {
|
||||||
|
dProvider : action.value,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
case actions.SET_CURRENT_LOCALE:
|
case actions.SET_CURRENT_LOCALE:
|
||||||
|
|
Loading…
Reference in New Issue