Fixes and refactoring
This commit is contained in:
parent
a412ab9114
commit
b72164f5a8
|
@ -4266,7 +4266,8 @@
|
|||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
|
@ -4284,11 +4285,13 @@
|
|||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -4301,15 +4304,18 @@
|
|||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -4412,7 +4418,8 @@
|
|||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -4422,6 +4429,7 @@
|
|||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -4434,17 +4442,20 @@
|
|||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
|
@ -4461,6 +4472,7 @@
|
|||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
@ -4533,7 +4545,8 @@
|
|||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -4543,6 +4556,7 @@
|
|||
"once": {
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -4618,7 +4632,8 @@
|
|||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
|
@ -4648,6 +4663,7 @@
|
|||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
@ -4665,6 +4681,7 @@
|
|||
"strip-ansi": {
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
|
@ -4703,11 +4720,13 @@
|
|||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
29
src/App.js
29
src/App.js
|
@ -5,7 +5,7 @@ import { Route, Redirect } from 'react-router-dom'
|
|||
import { constants } from './utils/constants'
|
||||
import { getNetworkBranch } from './utils/utils'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
import { messages } from './utils/messages'
|
||||
import messages from './utils/messages'
|
||||
|
||||
import './assets/stylesheets/index.css'
|
||||
|
||||
|
@ -41,16 +41,32 @@ class App extends Component {
|
|||
onNewBallotRender = () => {
|
||||
const { commonStore, contractsStore } = this.props
|
||||
|
||||
if (!contractsStore.web3Instance) {
|
||||
if (!commonStore.loading) {
|
||||
if (!commonStore.loading) {
|
||||
if (!contractsStore.injectedWeb3) {
|
||||
commonStore.hideLoading()
|
||||
swal({
|
||||
title: 'Error',
|
||||
html: messages.NO_METAMASK_MSG,
|
||||
icon: 'error',
|
||||
type: 'error'
|
||||
})
|
||||
} else if (!contractsStore.networkMatch) {
|
||||
commonStore.hideLoading()
|
||||
swal({
|
||||
title: 'Warning!',
|
||||
html: messages.networkMatchError(contractsStore.netId),
|
||||
icon: 'warning',
|
||||
type: 'warning'
|
||||
})
|
||||
} else if (contractsStore.votingKey && !contractsStore.isValidVotingKey) {
|
||||
commonStore.hideLoading()
|
||||
swal({
|
||||
title: 'Warning!',
|
||||
html: messages.invalidVotingKeyMsg(contractsStore.votingKey),
|
||||
icon: 'warning',
|
||||
type: 'warning'
|
||||
})
|
||||
}
|
||||
return null
|
||||
}
|
||||
return <NewBallot networkBranch={this.getVotingNetworkBranch()} />
|
||||
}
|
||||
|
@ -91,7 +107,9 @@ class App extends Component {
|
|||
|
||||
render() {
|
||||
const { commonStore, contractsStore } = this.props
|
||||
const networkBranch = this.getVotingNetworkBranch()
|
||||
const networkBranch = commonStore.loadingNetworkBranch
|
||||
? commonStore.loadingNetworkBranch
|
||||
: this.getVotingNetworkBranch()
|
||||
|
||||
return networkBranch ? (
|
||||
<div
|
||||
|
@ -102,7 +120,6 @@ class App extends Component {
|
|||
{commonStore.loading ? <Loading networkBranch={networkBranch} /> : null}
|
||||
<Header
|
||||
baseRootPath={commonStore.rootPath}
|
||||
injectedWeb3={contractsStore.injectedWeb3}
|
||||
netId={contractsStore.netId}
|
||||
networkBranch={networkBranch}
|
||||
onChange={this.props.onNetworkChange}
|
||||
|
|
|
@ -71,6 +71,11 @@
|
|||
padding-top: 8px;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
li.currentNetwork {
|
||||
@media (max-width: $breakpoint-md) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
a {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@ import { BallotInfoContainer } from '../BallotInfoContainer'
|
|||
import { Votes } from '../Votes'
|
||||
import { getNetworkBranch } from '../../utils/utils'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
import { messages } from '../../utils/messages'
|
||||
import messages from '../../utils/messages'
|
||||
import { observable, action, computed } from 'mobx'
|
||||
import { sendTransactionByVotingKey } from '../../utils/helpers'
|
||||
|
||||
|
@ -375,7 +375,7 @@ export class BallotCard extends React.Component {
|
|||
swal('Warning!', messages.NO_METAMASK_MSG, 'warning')
|
||||
return
|
||||
} else if (!contractsStore.networkMatch) {
|
||||
swal('Warning!', messages.NETWORK_MATCH_ERROR, 'warning')
|
||||
swal('Warning!', messages.networkMatchError(contractsStore.netId), 'warning')
|
||||
return
|
||||
} else if (!contractsStore.isValidVotingKey) {
|
||||
swal('Warning!', messages.invalidVotingKeyMsg(contractsStore.votingKey), 'warning')
|
||||
|
@ -515,7 +515,7 @@ export class BallotCard extends React.Component {
|
|||
swal('Warning!', messages.NO_METAMASK_MSG, 'warning')
|
||||
return
|
||||
} else if (!contractsStore.networkMatch) {
|
||||
swal('Warning!', messages.NETWORK_MATCH_ERROR, 'warning')
|
||||
swal('Warning!', messages.networkMatchError(contractsStore.netId), 'warning')
|
||||
return
|
||||
} else if (!contractsStore.isValidVotingKey) {
|
||||
swal('Warning!', messages.invalidVotingKeyMsg(contractsStore.votingKey), 'warning')
|
||||
|
|
|
@ -2,14 +2,12 @@ import React from 'react'
|
|||
import { FormInput } from '../FormInput'
|
||||
import { FormSelect } from '../FormSelect'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
import { constants } from '../../utils/constants'
|
||||
import { getNetworkName } from '../../utils/utils'
|
||||
|
||||
@inject('ballotStore', 'contractsStore')
|
||||
@inject('ballotStore')
|
||||
@observer
|
||||
export class BallotProxyMetadata extends React.Component {
|
||||
render() {
|
||||
const { ballotStore, contractsStore, networkBranch } = this.props
|
||||
const { ballotStore, networkBranch } = this.props
|
||||
let options = [
|
||||
/*0*/ { value: '', label: '' },
|
||||
/*1*/ { value: '1', label: ballotStore.ProxyBallotType[1] }, // KeysManager
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React, { Component } from 'react'
|
||||
import { constants } from '../../utils/constants'
|
||||
import helpers from '../../utils/helpers'
|
||||
|
||||
export default class NetworkSelect extends Component {
|
||||
changeNetworkRPC(e) {
|
||||
|
@ -9,7 +8,7 @@ export default class NetworkSelect extends Component {
|
|||
let getCurrentClickedLinkId = ''
|
||||
for (const _netId in constants.NETWORKS) {
|
||||
if (constants.NETWORKS[_netId].FULLNAME === getCurrentClickedLink) {
|
||||
getCurrentClickedLinkId = helpers.netIdByName(constants.NETWORKS[_netId].BRANCH)
|
||||
getCurrentClickedLinkId = _netId
|
||||
}
|
||||
}
|
||||
this.props.onChange({ value: getCurrentClickedLinkId })
|
||||
|
@ -17,21 +16,41 @@ export default class NetworkSelect extends Component {
|
|||
|
||||
render() {
|
||||
let networkFullNames = []
|
||||
let currentNetworkBranch = ''
|
||||
let currentNetworkFullName = ''
|
||||
|
||||
for (const _netId in constants.NETWORKS) {
|
||||
networkFullNames.push(constants.NETWORKS[_netId].FULLNAME)
|
||||
if (constants.NETWORKS[_netId].NAME.toLowerCase() === this.props.networkBranch) {
|
||||
currentNetworkBranch = constants.NETWORKS[_netId].FULLNAME
|
||||
const networks = constants.NETWORKS
|
||||
|
||||
let netIds = []
|
||||
Object.keys(networks)
|
||||
.sort((a, b) => (networks[a].SORTORDER > networks[b].SORTORDER ? 1 : -1))
|
||||
.forEach(function(_netId) {
|
||||
netIds.push(_netId)
|
||||
})
|
||||
|
||||
let selectedNetworkIndex = -1
|
||||
|
||||
netIds.forEach(_netId => {
|
||||
networkFullNames.push(networks[_netId].FULLNAME)
|
||||
if (networks[_netId].BRANCH === this.props.networkBranch) {
|
||||
currentNetworkFullName = networks[_netId].FULLNAME
|
||||
selectedNetworkIndex = networkFullNames.length - 1
|
||||
}
|
||||
}
|
||||
const listItems = networkFullNames.map(number => (
|
||||
<li key={number.toString()}>
|
||||
<a href="#" onClick={e => this.changeNetworkRPC(e)}>
|
||||
{number}
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
})
|
||||
|
||||
const listItems = networkFullNames.map((name, index) => {
|
||||
let className = ''
|
||||
if (index === selectedNetworkIndex) {
|
||||
className = 'currentNetwork'
|
||||
}
|
||||
return (
|
||||
<li key={name.toString()} className={className}>
|
||||
<a href="#" onClick={e => this.changeNetworkRPC(e)}>
|
||||
{name}
|
||||
</a>
|
||||
</li>
|
||||
)
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={`NetworkSelect nl-NavigationLinks_Link opacityFull`}>
|
||||
<div className={`NetworkSelect_Top`}>
|
||||
|
@ -42,7 +61,7 @@ export default class NetworkSelect extends Component {
|
|||
/>
|
||||
</svg>
|
||||
<span className={`nl-NavigationLinks_Text nl-NavigationLinks_Text-${this.props.networkBranch}`}>
|
||||
{currentNetworkBranch}
|
||||
{currentNetworkFullName}
|
||||
</span>
|
||||
<svg className={`nl-IconNetwork_Arrow`} xmlns="http://www.w3.org/2000/svg" width="8" height="4">
|
||||
<path d="M0 0h8L4 4 0 0z" />
|
||||
|
|
|
@ -15,7 +15,7 @@ import { Validator } from '../Validator'
|
|||
import { constants } from '../../utils/constants'
|
||||
import { getNetworkBranch } from '../../utils/utils'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
import { messages } from '../../utils/messages'
|
||||
import messages from '../../utils/messages'
|
||||
import { sendTransactionByVotingKey } from '../../utils/helpers'
|
||||
|
||||
@inject('commonStore', 'ballotStore', 'validatorStore', 'contractsStore', 'routing', 'ballotsStore')
|
||||
|
@ -40,9 +40,10 @@ export class NewBallot extends React.Component {
|
|||
}
|
||||
|
||||
checkValidation() {
|
||||
const { commonStore, contractsStore, ballotStore, validatorStore } = this.props
|
||||
const { commonStore, contractsStore, ballotStore } = this.props
|
||||
|
||||
// Temporarily commented (until we implement https://github.com/poanetwork/poa-dapps-voting/issues/120)
|
||||
// const { validatorStore } = this.props
|
||||
// if (ballotStore.isNewValidatorPersonalData) {
|
||||
// for (let validatorProp in validatorStore) {
|
||||
// if (validatorStore[validatorProp].length === 0) {
|
||||
|
@ -256,7 +257,7 @@ export class NewBallot extends React.Component {
|
|||
swal('Warning!', messages.NO_METAMASK_MSG, 'warning')
|
||||
return
|
||||
} else if (!contractsStore.networkMatch) {
|
||||
swal('Warning!', messages.NETWORK_MATCH_ERROR, 'warning')
|
||||
swal('Warning!', messages.networkMatchError(contractsStore.netId), 'warning')
|
||||
return
|
||||
} else if (!contractsStore.isValidVotingKey) {
|
||||
swal('Warning!', messages.invalidVotingKeyMsg(contractsStore.votingKey), 'warning')
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
import React from 'react'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
|
||||
export const SearchBar = ({ extraClassName = '', networkBranch = false, onSearch }) => {
|
||||
return (
|
||||
<div className={`sw-SearchBar sw-SearchBar-${networkBranch} ${extraClassName}`}>
|
||||
<div className="sw-SearchBar_Content">
|
||||
<input
|
||||
className={`sw-SearchBar_Input sw-SearchBar_Input-${networkBranch}`}
|
||||
onChange={onSearch}
|
||||
placeholder="Search..."
|
||||
type="search"
|
||||
/>
|
||||
@inject('commonStore')
|
||||
@observer
|
||||
export class SearchBar extends React.Component {
|
||||
render() {
|
||||
const { commonStore, networkBranch, onSearch } = this.props
|
||||
return (
|
||||
<div className={`sw-SearchBar sw-SearchBar-${networkBranch}`}>
|
||||
<div className="sw-SearchBar_Content">
|
||||
<input
|
||||
className={`sw-SearchBar_Input sw-SearchBar_Input-${networkBranch}`}
|
||||
onChange={onSearch}
|
||||
placeholder="Search..."
|
||||
type="search"
|
||||
value={commonStore.searchTerm}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react'
|
||||
import { FormAutocomplete } from '../FormAutocomplete'
|
||||
import { FormInput } from '../FormInput'
|
||||
import { FormSelect } from '../FormSelect'
|
||||
//import { FormAutocomplete } from '../FormAutocomplete'
|
||||
//import { FormInput } from '../FormInput'
|
||||
//import { FormSelect } from '../FormSelect'
|
||||
import { constants } from '../../utils/constants'
|
||||
import { geocodeByAddress } from 'react-places-autocomplete'
|
||||
import { inject, observer } from 'mobx-react'
|
||||
|
@ -64,6 +64,7 @@ export class Validator extends React.Component {
|
|||
|
||||
render() {
|
||||
return null // Temporarily empty (until we implement https://github.com/poanetwork/poa-dapps-voting/issues/120)
|
||||
/*
|
||||
const { validatorStore, networkBranch } = this.props
|
||||
const inputProps = {
|
||||
value: validatorStore.address,
|
||||
|
@ -190,5 +191,6 @@ export class Validator extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
)
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { constants } from '../utils/constants'
|
||||
import { messages } from '../utils/messages'
|
||||
import messages from '../utils/messages'
|
||||
import swal from 'sweetalert2'
|
||||
|
||||
function addressesURL(branch) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Router, Route } from 'react-router-dom'
|
|||
import { RouterStore, syncHistoryWithStore } from 'mobx-react-router'
|
||||
import { constants } from './utils/constants'
|
||||
import { getContractsAddresses } from './contracts/addresses'
|
||||
import { getNetworkBranch } from './utils/utils'
|
||||
|
||||
const browserHistory = createBrowserHistory()
|
||||
const routingStore = new RouterStore()
|
||||
|
@ -101,10 +102,11 @@ class AppMainRouter extends Component {
|
|||
}
|
||||
|
||||
onNetworkChange = e => {
|
||||
commonStore.showLoading()
|
||||
commonStore.showLoading(getNetworkBranch(e.value))
|
||||
window.localStorage.netId = e.value
|
||||
contractsStore.resetContracts()
|
||||
ballotsStore.reset()
|
||||
commonStore.setSearchTerm('')
|
||||
this.initChain()
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ class BallotsStore {
|
|||
@observable ballotCards
|
||||
|
||||
constructor() {
|
||||
this.ballotCards = []
|
||||
this.reset()
|
||||
}
|
||||
|
||||
reset() {
|
||||
|
|
|
@ -2,6 +2,7 @@ import { observable, action } from 'mobx'
|
|||
|
||||
class CommonStore {
|
||||
@observable loading
|
||||
@observable loadingNetworkBranch
|
||||
@observable rootPath
|
||||
@observable isActiveFilter
|
||||
@observable isToFinalizeFilter
|
||||
|
@ -10,6 +11,7 @@ class CommonStore {
|
|||
|
||||
constructor() {
|
||||
this.loading = false
|
||||
this.loadingNetworkBranch = null
|
||||
this.isActiveFilter = false
|
||||
this.isToFinalizeFilter = false
|
||||
this.rootPath = '/poa-dapps-voting'
|
||||
|
@ -17,13 +19,15 @@ class CommonStore {
|
|||
}
|
||||
|
||||
@action('show loading')
|
||||
showLoading() {
|
||||
showLoading(loadingNetworkBranch) {
|
||||
this.loading = true
|
||||
this.loadingNetworkBranch = loadingNetworkBranch
|
||||
}
|
||||
|
||||
@action('hide loading')
|
||||
hideLoading() {
|
||||
this.loading = false
|
||||
this.loadingNetworkBranch = null
|
||||
}
|
||||
|
||||
@action('set search term')
|
||||
|
|
|
@ -54,7 +54,7 @@ class ContractsStore {
|
|||
this.validatorsMetadata = {}
|
||||
this.validatorLimits = { keys: null, minThreshold: null, proxy: null }
|
||||
this.minBallotDuration = { keys: 0, minThreshold: 0, proxy: 0 }
|
||||
this.injectedWeb3 = true
|
||||
this.injectedWeb3 = false
|
||||
}
|
||||
|
||||
@computed
|
||||
|
|
|
@ -59,31 +59,35 @@ constants.KOVAN = 'kovan'
|
|||
constants.NETWORKS = {
|
||||
'42': {
|
||||
NAME: 'Kovan',
|
||||
FULLNAME: 'Kovan',
|
||||
FULLNAME: 'Kovan Testnet',
|
||||
RPC: 'https://kovan.infura.io/v3/1125fe73d87c4e5396678f4e3089b3dd',
|
||||
BRANCH: constants.KOVAN,
|
||||
TESTNET: true
|
||||
TESTNET: true,
|
||||
SORTORDER: 3
|
||||
},
|
||||
'77': {
|
||||
NAME: 'Sokol',
|
||||
FULLNAME: 'Sokol',
|
||||
FULLNAME: 'Sokol Testnet',
|
||||
RPC: 'https://sokol.poa.network',
|
||||
BRANCH: constants.SOKOL,
|
||||
TESTNET: true
|
||||
TESTNET: true,
|
||||
SORTORDER: 4
|
||||
},
|
||||
'99': {
|
||||
NAME: 'Core',
|
||||
FULLNAME: 'POA Core Chain',
|
||||
FULLNAME: 'POA Core',
|
||||
RPC: 'https://core.poa.network',
|
||||
BRANCH: constants.CORE,
|
||||
TESTNET: false
|
||||
TESTNET: false,
|
||||
SORTORDER: 1
|
||||
},
|
||||
'100': {
|
||||
NAME: 'Dai',
|
||||
NAME: 'xDai',
|
||||
FULLNAME: 'xDai Stable Chain',
|
||||
RPC: 'https://dai.poa.network',
|
||||
BRANCH: constants.DAI,
|
||||
TESTNET: false
|
||||
TESTNET: false,
|
||||
SORTORDER: 2
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import Web3 from 'web3'
|
|||
import helpers from './helpers'
|
||||
import { constants } from './constants'
|
||||
|
||||
const defaultNetId = helpers.netIdByName(constants.CORE)
|
||||
const defaultNetId = helpers.netIdByBranch(constants.CORE)
|
||||
|
||||
export default async function getWeb3(netId = defaultNetId, onAccountChange) {
|
||||
let web3 = null
|
||||
|
@ -23,8 +23,8 @@ export default async function getWeb3(netId = defaultNetId, onAccountChange) {
|
|||
}
|
||||
|
||||
const network = constants.NETWORKS[netId]
|
||||
const injectedWeb3 = web3 !== null
|
||||
let netIdName = network.NAME
|
||||
let injectedWeb3 = web3 !== null
|
||||
let defaultAccount = null
|
||||
let networkMatch = false
|
||||
|
||||
|
@ -57,7 +57,7 @@ export default async function getWeb3(netId = defaultNetId, onAccountChange) {
|
|||
web3 = new Web3(new Web3.providers.HttpProvider(network.RPC))
|
||||
}
|
||||
|
||||
document.title = `${netIdName} - POA Validators DApp`
|
||||
document.title = `${netIdName} - POA Governance DApp`
|
||||
|
||||
return {
|
||||
web3Instance: web3,
|
||||
|
|
|
@ -58,10 +58,10 @@ function sendTransactionByVotingKey(props, to, data, cb, warning) {
|
|||
)
|
||||
}
|
||||
|
||||
function netIdByName(netName) {
|
||||
const netNameLowerCase = netName.toLowerCase()
|
||||
function netIdByBranch(branch) {
|
||||
const branchLowerCase = branch.toLowerCase()
|
||||
for (let netId in constants.NETWORKS) {
|
||||
if (constants.NETWORKS[netId].NAME.toLowerCase() === netNameLowerCase) {
|
||||
if (constants.NETWORKS[netId].BRANCH.toLowerCase() === branchLowerCase) {
|
||||
return netId
|
||||
}
|
||||
}
|
||||
|
@ -71,5 +71,5 @@ function netIdByName(netName) {
|
|||
module.exports = {
|
||||
toAscii,
|
||||
sendTransactionByVotingKey,
|
||||
netIdByName
|
||||
netIdByBranch
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { getNetworkFullName } from './utils'
|
||||
|
||||
let messages = {}
|
||||
messages.invalidVotingKeyMsg = key => {
|
||||
return `The key ${key} is not valid voting Key! Please make sure you have loaded correct voting key in Metamask`
|
||||
return `The key ${key} is not valid Voting Key! Please make sure you have loaded correct Voting Key in MetaMask.`
|
||||
}
|
||||
messages.VOTED_SUCCESS_MSG = 'You successfully voted'
|
||||
messages.BALLOT_CREATED_SUCCESS_MSG = 'You successfully created a new ballot'
|
||||
|
@ -16,10 +18,7 @@ messages.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG = "Proposed address isn't address"
|
|||
messages.END_TIME_SHOULD_BE_GREATER_THAN_NOW_MSG = 'Ballot end time should be greater than now'
|
||||
messages.BALLOT_TYPE_IS_EMPTY_MSG = 'Ballot type is empty'
|
||||
messages.USER_DENIED_ACCOUNT_ACCESS = 'You have denied access to your accounts'
|
||||
messages.NO_METAMASK_MSG = 'Your MetaMask is locked.'
|
||||
messages.WRONG_NETWORK_MSG = `You aren't connected to POA Network.
|
||||
Please, switch on POA plugin and refresh the page.
|
||||
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`
|
||||
messages.NO_METAMASK_MSG = 'Your MetaMask is locked or not installed.'
|
||||
messages.ballotIsNotActiveMsg = timeToStart => {
|
||||
return `The ballot is not active yet. Time to start: ${timeToStart}`
|
||||
}
|
||||
|
@ -36,18 +35,20 @@ messages.EMISSION_RELEASE_TIME_IN_FUTURE = emissionReleaseTime => {
|
|||
}
|
||||
messages.PREVIOUS_BALLOT_NOT_FINALIZED = 'Previous ballot should be finalized first.'
|
||||
messages.BALLOT_CREATE_FAILED_TX = `Your transaction was failed. Please make sure you set correct parameters for ballot creation.
|
||||
Make sure you don't have Transaction Error. Exception thrown in contract code message in Metamask before you sign it.`
|
||||
Make sure you don't have Transaction Error. Exception thrown in contract code message in MetaMask before you sign it.`
|
||||
messages.VOTE_FAILED_TX = `Your transaction was failed. Please make sure you haven't already voted for this ballot.
|
||||
Make sure you don't have Transaction Error. Exception thrown in contract code message in Metamask before you sign it.`
|
||||
Make sure you don't have Transaction Error. Exception thrown in contract code message in MetaMask before you sign it.`
|
||||
messages.FINALIZE_FAILED_TX = `Your transaction was failed. Make sure you don't have Transaction Error.
|
||||
Exception thrown in contract code message in Metamask before you sign it.`
|
||||
Exception thrown in contract code message in MetaMask before you sign it.`
|
||||
messages.CANCEL_BALLOT_FAILED_TX = `Your transaction was failed. Make sure you don't have Transaction Error.
|
||||
Exception thrown in contract code message in Metamask before you sign it.`
|
||||
Exception thrown in contract code message in MetaMask before you sign it.`
|
||||
messages.DESCRIPTION_IS_EMPTY = 'Description cannot be empty'
|
||||
messages.wrongRepo = repo => {
|
||||
return `There is no contracts.json in configured repo ${repo}`
|
||||
}
|
||||
messages.NETWORK_MATCH_ERROR = 'Networks do not match. Change the network in Metamask.'
|
||||
module.exports = {
|
||||
messages
|
||||
messages.networkMatchError = function(netId) {
|
||||
const networkName = getNetworkFullName(Number(netId))
|
||||
return `Networks in DApp and MetaMask do not match. Switch MetaMask to ${networkName} or change the network in DApp.`
|
||||
}
|
||||
|
||||
export default messages
|
||||
|
|
|
@ -12,8 +12,8 @@ export const getNetworkBranch = netId => {
|
|||
return constants.NETWORKS[netId].BRANCH
|
||||
}
|
||||
|
||||
export const getNetworkName = netId => {
|
||||
return constants.NETWORKS[netId].NAME
|
||||
export const getNetworkFullName = netId => {
|
||||
return constants.NETWORKS[netId].FULLNAME
|
||||
}
|
||||
|
||||
export const scrollToTop = () => {
|
||||
|
|
Loading…
Reference in New Issue