Merge pull request #181 from varasev/issue-179

(Fix, Refactor) Add support of a new version of MetaMask
This commit is contained in:
Victor Baranov 2018-10-16 15:41:30 +03:00 committed by GitHub
commit b72d0166e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 219 additions and 290 deletions

View File

@ -7,7 +7,7 @@ import { Route } from 'react-router-dom'
import { inject, observer } from 'mobx-react' import { inject, observer } from 'mobx-react'
import swal from 'sweetalert2' import swal from 'sweetalert2'
import { messages } from './messages' import { messages } from './messages'
import { isTestnet } from './helpers' import { constants } from './constants'
@inject('commonStore', 'contractsStore') @inject('commonStore', 'contractsStore')
@observer @observer
@ -124,8 +124,8 @@ class App extends Component {
} }
getNetIdClass() { getNetIdClass() {
const { contractsStore } = this.props const { netId } = this.props.contractsStore
return isTestnet(contractsStore.netId) ? 'sokol' : '' return netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET ? 'sokol' : ''
} }
render() { render() {
@ -142,6 +142,8 @@ class App extends Component {
'' ''
) )
const isTestnet = contractsStore.netId in constants.NETWORKS && constants.NETWORKS[contractsStore.netId].TESTNET
return ( return (
<section className={`content ${this.state.showMobileMenu ? 'content-menu-open' : ''}`}> <section className={`content ${this.state.showMobileMenu ? 'content-menu-open' : ''}`}>
{loading} {loading}
@ -155,7 +157,7 @@ class App extends Component {
{search} {search}
<div <div
className={`app-container ${this.state.showMobileMenu ? 'app-container-open-mobile-menu' : ''} ${ className={`app-container ${this.state.showMobileMenu ? 'app-container-open-mobile-menu' : ''} ${
isTestnet(contractsStore.netId) ? 'sokol' : '' isTestnet ? 'sokol' : ''
}`} }`}
> >
<div className="container"> <div className="container">

View File

@ -9,16 +9,11 @@ const styles = netId => {
backgroundColor: 'rgba(47, 109, 99, 0.8)' backgroundColor: 'rgba(47, 109, 99, 0.8)'
} }
switch (netId) { if (netId in constants.NETWORKS) {
case constants.NETID_SOKOL: return constants.NETWORKS[netId].TESTNET ? sokol : core
case constants.NETID_DAI_TEST:
return sokol
case constants.NETID_CORE:
case constants.NETID_DAI:
return core
default:
return {}
} }
return core
} }
const Loading = ({ netId }) => ( const Loading = ({ netId }) => (
<div className="loading-container" style={styles(netId)}> <div className="loading-container" style={styles(netId)}>

View File

@ -7,7 +7,7 @@ import { BallotCard } from './BallotCard.jsx'
export class BallotEmissionFundsCard extends React.Component { export class BallotEmissionFundsCard extends React.Component {
render() { render() {
const { id, votingState, pos, contractsStore } = this.props const { id, votingState, pos, contractsStore } = this.props
const amount = contractsStore.web3Instance.fromWei(votingState.amount, 'ether') const amount = contractsStore.web3Instance.utils.fromWei(votingState.amount, 'ether')
return ( return (
<BallotCard votingType="votingToManageEmissionFunds" votingState={votingState} id={id} pos={pos}> <BallotCard votingType="votingToManageEmissionFunds" votingState={votingState} id={id} pos={pos}>
<div className="ballots-about-i ballots-about-i_proposed_receiver"> <div className="ballots-about-i ballots-about-i_proposed_receiver">

View File

@ -16,7 +16,7 @@ export class BallotEmissionFundsMetadata extends React.Component {
getEmissionFundsBalance = async () => { getEmissionFundsBalance = async () => {
const { contractsStore } = this.props const { contractsStore } = this.props
this.emissionFundsBalance = this.emissionFundsBalance =
contractsStore.web3Instance.fromWei(await contractsStore.emissionFunds.balance(), 'ether') + ' POA' contractsStore.web3Instance.utils.fromWei(await contractsStore.emissionFunds.balance(), 'ether') + ' POA'
} }
@action('Get VotingToManageEmissionFunds.noActiveBallotExists') @action('Get VotingToManageEmissionFunds.noActiveBallotExists')
@ -82,7 +82,7 @@ export class BallotEmissionFundsMetadata extends React.Component {
} else if (this.noActiveBallotExists !== true) { } else if (this.noActiveBallotExists !== true) {
note = <p>To be able to create a new ballot, the previous ballot of this type must be finalized.</p> note = <p>To be able to create a new ballot, the previous ballot of this type must be finalized.</p>
} }
if (contractsStore.netId === constants.NETID_SOKOL) { if (constants.NETWORKS[contractsStore.netId].NAME.toLowerCase() === 'sokol') {
explorerLink = `https://sokol.poaexplorer.com/address/search/${contractsStore.emissionFunds.address}` explorerLink = `https://sokol.poaexplorer.com/address/search/${contractsStore.emissionFunds.address}`
} else { } else {
explorerLink = `https://poaexplorer.com/address/${contractsStore.emissionFunds.address}` explorerLink = `https://poaexplorer.com/address/${contractsStore.emissionFunds.address}`

View File

@ -2,10 +2,10 @@ import React from 'react'
import moment from 'moment' import moment from 'moment'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import Socials from './Socials.jsx' import Socials from './Socials.jsx'
import { isTestnet } from '../helpers' import { constants } from '../constants'
export const Footer = ({ netId }) => { export const Footer = ({ netId }) => {
const footerClassName = isTestnet(netId) ? 'sokol' : '' const footerClassName = netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET ? 'sokol' : ''
return ( return (
<footer className={`footer ${footerClassName}`}> <footer className={`footer ${footerClassName}`}>

View File

@ -7,10 +7,10 @@ import menuOpenIconBase from '../assets/images/icons/icon-close.svg'
import menuOpenIconSokol from '../assets/images/icons/icon-close-sokol.svg' import menuOpenIconSokol from '../assets/images/icons/icon-close-sokol.svg'
import NavigationLinks from './NavigationLinks.jsx' import NavigationLinks from './NavigationLinks.jsx'
import MobileMenuLinks from './MobileMenuLinks.jsx' import MobileMenuLinks from './MobileMenuLinks.jsx'
import { isTestnet } from '../helpers' import { constants } from '../constants'
export const Header = ({ netId, baseRootPath, navigationData, showMobileMenu, onMenuToggle }) => { export const Header = ({ netId, baseRootPath, navigationData, showMobileMenu, onMenuToggle }) => {
const thisIsTestnet = isTestnet(netId) const thisIsTestnet = netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET
const headerClassName = thisIsTestnet ? 'sokol' : '' const headerClassName = thisIsTestnet ? 'sokol' : ''
const logoImageName = thisIsTestnet ? logoSokol : logoBase const logoImageName = thisIsTestnet ? logoSokol : logoBase
const menuIcon = thisIsTestnet ? menuIconSokol : menuIconBase const menuIcon = thisIsTestnet ? menuIconSokol : menuIconBase

View File

@ -100,7 +100,7 @@ export class NewBallot extends React.Component {
} }
} }
let isAffectedKeyAddress = contractsStore.web3Instance.isAddress(ballotStore.ballotKeys.affectedKey) let isAffectedKeyAddress = contractsStore.web3Instance.utils.isAddress(ballotStore.ballotKeys.affectedKey)
if (!isAffectedKeyAddress) { if (!isAffectedKeyAddress) {
swal('Warning!', messages.AFFECTED_KEY_IS_NOT_ADDRESS_MSG, 'warning') swal('Warning!', messages.AFFECTED_KEY_IS_NOT_ADDRESS_MSG, 'warning')
@ -108,7 +108,7 @@ export class NewBallot extends React.Component {
return false return false
} }
let isMiningKeyAddress = contractsStore.web3Instance.isAddress(ballotStore.ballotKeys.miningKey.value) let isMiningKeyAddress = contractsStore.web3Instance.utils.isAddress(ballotStore.ballotKeys.miningKey.value)
if (!isMiningKeyAddress) { if (!isMiningKeyAddress) {
swal('Warning!', messages.MINING_KEY_IS_NOT_ADDRESS_MSG, 'warning') swal('Warning!', messages.MINING_KEY_IS_NOT_ADDRESS_MSG, 'warning')
commonStore.hideLoading() commonStore.hideLoading()
@ -135,7 +135,7 @@ export class NewBallot extends React.Component {
} }
} }
const isAddress = contractsStore.web3Instance.isAddress(ballotStore.ballotProxy.proposedAddress) const isAddress = contractsStore.web3Instance.utils.isAddress(ballotStore.ballotProxy.proposedAddress)
if (!isAddress) { if (!isAddress) {
swal('Warning!', messages.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG, 'warning') swal('Warning!', messages.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG, 'warning')
@ -151,7 +151,7 @@ export class NewBallot extends React.Component {
return false return false
} }
const isAddress = contractsStore.web3Instance.isAddress(ballotStore.ballotEmissionFunds.receiver) const isAddress = contractsStore.web3Instance.utils.isAddress(ballotStore.ballotEmissionFunds.receiver)
if (!isAddress) { if (!isAddress) {
swal('Warning!', messages.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG, 'warning') swal('Warning!', messages.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG, 'warning')
@ -320,17 +320,17 @@ export class NewBallot extends React.Component {
case ballotStore.BallotType.keys: case ballotStore.BallotType.keys:
methodToCreateBallot = this.createBallotForKeys methodToCreateBallot = this.createBallotForKeys
contractType = 'votingToChangeKeys' contractType = 'votingToChangeKeys'
contractInstance = contractsStore.votingToChangeKeys.votingToChangeKeysInstance contractInstance = contractsStore.votingToChangeKeys.instance
break break
case ballotStore.BallotType.minThreshold: case ballotStore.BallotType.minThreshold:
methodToCreateBallot = this.createBallotForMinThreshold methodToCreateBallot = this.createBallotForMinThreshold
contractType = 'votingToChangeMinThreshold' contractType = 'votingToChangeMinThreshold'
contractInstance = contractsStore.votingToChangeMinThreshold.votingToChangeMinThresholdInstance contractInstance = contractsStore.votingToChangeMinThreshold.instance
break break
case ballotStore.BallotType.proxy: case ballotStore.BallotType.proxy:
methodToCreateBallot = this.createBallotForProxy methodToCreateBallot = this.createBallotForProxy
contractType = 'votingToChangeProxy' contractType = 'votingToChangeProxy'
contractInstance = contractsStore.votingToChangeProxy.votingToChangeProxyInstance contractInstance = contractsStore.votingToChangeProxy.instance
break break
case ballotStore.BallotType.emissionFunds: case ballotStore.BallotType.emissionFunds:
methodToCreateBallot = this.createBallotForEmissionFunds methodToCreateBallot = this.createBallotForEmissionFunds

View File

@ -24,10 +24,30 @@ constants.minBallotDurationInDays = 2
constants.startTimeOffsetInMinutes = 5 constants.startTimeOffsetInMinutes = 5
constants.endTimeDefaultInMinutes = 2890 constants.endTimeDefaultInMinutes = 2890
constants.getTransactionReceiptInterval = 5000 constants.getTransactionReceiptInterval = 5000
constants.NETID_SOKOL = '77'
constants.NETID_CORE = '99' constants.NETWORKS = {
constants.NETID_DAI_TEST = '79' '77': {
constants.NETID_DAI = '100' NAME: 'Sokol',
BRANCH: 'sokol',
TESTNET: true
},
'99': {
NAME: 'Core',
BRANCH: 'core',
TESTNET: false
},
'79': {
NAME: 'Dai-Test',
BRANCH: 'dai-test',
TESTNET: true
},
'100': {
NAME: 'Dai',
BRANCH: 'dai',
TESTNET: false
}
}
module.exports = { module.exports = {
constants constants
} }

View File

@ -1,25 +1,21 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class BallotsStorage { export default class BallotsStorage {
async init({ web3, netId }) { async init({ web3, netId }) {
const { BALLOTS_STORAGE_ADDRESS } = networkAddresses(netId) const { BALLOTS_STORAGE_ADDRESS } = networkAddresses()
console.log('Ballots Storage address', BALLOTS_STORAGE_ADDRESS) console.log('Ballots Storage address', BALLOTS_STORAGE_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId)
const ballotsStorageAbi = await helpers.getABI(branch, 'BallotStorage') const ballotsStorageAbi = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'BallotStorage')
this.ballotsStorageInstance = new web3_10.eth.Contract(ballotsStorageAbi, BALLOTS_STORAGE_ADDRESS) this.instance = new web3.eth.Contract(ballotsStorageAbi, BALLOTS_STORAGE_ADDRESS)
} }
areKeysBallotParamsValid({ ballotType, affectedKeyType, affectedKey, miningKey }) { areKeysBallotParamsValid({ ballotType, affectedKeyType, affectedKey, miningKey }) {
if (!this.ballotsStorageInstance.methods.areKeysBallotParamsValid) { if (!this.instance.methods.areKeysBallotParamsValid) {
return null return null
} }
return this.ballotsStorageInstance.methods return this.instance.methods.areKeysBallotParamsValid(ballotType, affectedKeyType, affectedKey, miningKey).call()
.areKeysBallotParamsValid(ballotType, affectedKeyType, affectedKey, miningKey)
.call()
} }
} }

View File

@ -1,15 +1,14 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
export default class EmissionFunds { export default class EmissionFunds {
async init({ web3, netId }) { async init({ web3, netId }) {
const { EMISSION_FUNDS_ADDRESS } = networkAddresses(netId) const { EMISSION_FUNDS_ADDRESS } = networkAddresses()
console.log('EmissionFunds address', EMISSION_FUNDS_ADDRESS) console.log('EmissionFunds address', EMISSION_FUNDS_ADDRESS)
this.web3_10 = new Web3(web3.currentProvider) this.web3 = web3
this.address = EMISSION_FUNDS_ADDRESS this.address = EMISSION_FUNDS_ADDRESS
} }
balance() { balance() {
return this.web3_10.eth.getBalance(this.address) return this.web3.eth.getBalance(this.address)
} }
} }

View File

@ -1,18 +1,15 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class KeysManager { export default class KeysManager {
async init({ web3, netId }) { async init({ web3, netId }) {
const { KEYS_MANAGER_ADDRESS } = networkAddresses(netId) const { KEYS_MANAGER_ADDRESS } = networkAddresses()
console.log('KeysManager address', KEYS_MANAGER_ADDRESS) console.log('KeysManager address', KEYS_MANAGER_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const keysManagerABI = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'KeysManager')
const keysManagerABI = await helpers.getABI(branch, 'KeysManager') this.instance = new web3.eth.Contract(keysManagerABI, KEYS_MANAGER_ADDRESS)
this.instance = new web3_10.eth.Contract(keysManagerABI, KEYS_MANAGER_ADDRESS)
this.address = KEYS_MANAGER_ADDRESS this.address = KEYS_MANAGER_ADDRESS
} }
} }

View File

@ -1,21 +1,18 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class POAConsensus { export default class PoaConsensus {
async init({ web3, netId }) { async init({ web3, netId }) {
const { POA_ADDRESS } = networkAddresses(netId) const { POA_ADDRESS } = networkAddresses()
console.log('POA address', POA_ADDRESS) console.log('POA address', POA_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const poaConsensusAbi = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'PoaNetworkConsensus')
const poaConsensusAbi = await helpers.getABI(branch, 'PoaNetworkConsensus') this.instance = new web3.eth.Contract(poaConsensusAbi, POA_ADDRESS)
this.poaInstance = new web3_10.eth.Contract(poaConsensusAbi, POA_ADDRESS)
} }
async getValidators() { async getValidators() {
return await this.poaInstance.methods.getValidators().call() return await this.instance.methods.getValidators().call()
} }
} }

View File

@ -1,20 +1,18 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class ProxyStorage { export default class ProxyStorage {
async init({ web3, netId }) { async init({ web3, netId }) {
const { PROXY_ADDRESS } = networkAddresses(netId) const { PROXY_ADDRESS } = networkAddresses()
console.log('Proxy Storage address', PROXY_ADDRESS) console.log('Proxy Storage address', PROXY_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId)
const proxyStorageAbi = await helpers.getABI(branch, 'ProxyStorage') const proxyStorageAbi = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'ProxyStorage')
this.proxyStorageInstance = new web3_10.eth.Contract(proxyStorageAbi, PROXY_ADDRESS) this.instance = new web3.eth.Contract(proxyStorageAbi, PROXY_ADDRESS)
} }
doesMethodExist(methodName) { doesMethodExist(methodName) {
return this.proxyStorageInstance && this.proxyStorageInstance.methods[methodName] return this.instance && this.instance.methods[methodName]
} }
} }

View File

@ -1,27 +1,24 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { toAscii } from '../helpers' import { toAscii } from '../helpers'
import { constants } from '../constants'
export default class ValidatorMetadata { export default class ValidatorMetadata {
async init({ web3, netId }) { async init({ web3, netId }) {
const { METADATA_ADDRESS } = networkAddresses(netId) const { METADATA_ADDRESS } = networkAddresses()
console.log('Metadata address', METADATA_ADDRESS) console.log('Metadata address', METADATA_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const MetadataAbi = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'ValidatorMetadata')
const MetadataAbi = await helpers.getABI(branch, 'ValidatorMetadata') this.instance = new web3.eth.Contract(MetadataAbi, METADATA_ADDRESS)
this.metadataInstance = new web3_10.eth.Contract(MetadataAbi, METADATA_ADDRESS)
} }
async getValidatorFullName(miningKey) { async getValidatorFullName(miningKey) {
let validator let validator
if (this.metadataInstance.methods.getValidatorName) { if (this.instance.methods.getValidatorName) {
validator = await this.metadataInstance.methods.getValidatorName(miningKey).call() validator = await this.instance.methods.getValidatorName(miningKey).call()
} else { } else {
validator = await this.metadataInstance.methods.validators(miningKey).call() validator = await this.instance.methods.validators(miningKey).call()
} }
return { return {
firstName: toAscii(validator.firstName), firstName: toAscii(validator.firstName),

View File

@ -1,47 +1,42 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class VotingToChangeKeys { export default class VotingToChangeKeys {
async init({ web3, netId }) { async init({ web3, netId }) {
const { VOTING_TO_CHANGE_KEYS_ADDRESS } = networkAddresses(netId) const { VOTING_TO_CHANGE_KEYS_ADDRESS } = networkAddresses()
console.log('VotingToChangeKeys address', VOTING_TO_CHANGE_KEYS_ADDRESS) console.log('VotingToChangeKeys address', VOTING_TO_CHANGE_KEYS_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const votingToChangeKeysABI = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'VotingToChangeKeys')
const votingToChangeKeysABI = await helpers.getABI(branch, 'VotingToChangeKeys') this.instance = new web3.eth.Contract(votingToChangeKeysABI, VOTING_TO_CHANGE_KEYS_ADDRESS)
this.votingToChangeKeysInstance = new web3_10.eth.Contract(votingToChangeKeysABI, VOTING_TO_CHANGE_KEYS_ADDRESS)
this.gasPrice = web3_10.utils.toWei('1', 'gwei')
this.address = VOTING_TO_CHANGE_KEYS_ADDRESS this.address = VOTING_TO_CHANGE_KEYS_ADDRESS
this.instance = this.votingToChangeKeysInstance
} }
//setters //setters
createBallot({ startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo }) { createBallot({ startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo }) {
if (this.votingToChangeKeysInstance.methods.createBallot) { if (this.instance.methods.createBallot) {
return this.votingToChangeKeysInstance.methods return this.instance.methods
.createBallot(startTime, endTime, ballotType, affectedKeyType, memo, affectedKey, miningKey) .createBallot(startTime, endTime, ballotType, affectedKeyType, memo, affectedKey, miningKey)
.encodeABI() .encodeABI()
} }
return this.votingToChangeKeysInstance.methods return this.instance.methods
.createVotingForKeys(startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo) .createVotingForKeys(startTime, endTime, affectedKey, affectedKeyType, miningKey, ballotType, memo)
.encodeABI() .encodeABI()
} }
createBallotToAddNewValidator({ startTime, endTime, memo, affectedKey, newVotingKey, newPayoutKey }) { createBallotToAddNewValidator({ startTime, endTime, memo, affectedKey, newVotingKey, newPayoutKey }) {
return this.votingToChangeKeysInstance.methods return this.instance.methods
.createBallotToAddNewValidator(startTime, endTime, memo, affectedKey, newVotingKey, newPayoutKey) .createBallotToAddNewValidator(startTime, endTime, memo, affectedKey, newVotingKey, newPayoutKey)
.encodeABI() .encodeABI()
} }
vote(_id, choice) { vote(_id, choice) {
return this.votingToChangeKeysInstance.methods.vote(_id, choice).encodeABI() return this.instance.methods.vote(_id, choice).encodeABI()
} }
finalize(_id) { finalize(_id) {
return this.votingToChangeKeysInstance.methods.finalize(_id).encodeABI() return this.instance.methods.finalize(_id).encodeABI()
} }
//getters //getters
@ -49,47 +44,45 @@ export default class VotingToChangeKeys {
if (!this.doesMethodExist('areBallotParamsValid')) { if (!this.doesMethodExist('areBallotParamsValid')) {
return null return null
} }
return this.votingToChangeKeysInstance.methods return this.instance.methods.areBallotParamsValid(ballotType, affectedKey, affectedKeyType, miningKey).call()
.areBallotParamsValid(ballotType, affectedKey, affectedKeyType, miningKey)
.call()
} }
doesMethodExist(methodName) { doesMethodExist(methodName) {
return this.votingToChangeKeysInstance && this.votingToChangeKeysInstance.methods[methodName] return this.instance && this.instance.methods[methodName]
} }
nextBallotId() { nextBallotId() {
return this.votingToChangeKeysInstance.methods.nextBallotId().call() return this.instance.methods.nextBallotId().call()
} }
getBallotInfo(_id, _votingKey) { getBallotInfo(_id, _votingKey) {
if (this.doesMethodExist('getBallotInfo')) { if (this.doesMethodExist('getBallotInfo')) {
return this.votingToChangeKeysInstance.methods.getBallotInfo(_id).call() return this.instance.methods.getBallotInfo(_id).call()
} }
return this.votingToChangeKeysInstance.methods.votingState(_id).call() return this.instance.methods.votingState(_id).call()
} }
hasAlreadyVoted(_id, votingKey) { hasAlreadyVoted(_id, votingKey) {
return this.votingToChangeKeysInstance.methods.hasAlreadyVoted(_id, votingKey).call() return this.instance.methods.hasAlreadyVoted(_id, votingKey).call()
} }
isValidVote(_id, votingKey) { isValidVote(_id, votingKey) {
return this.votingToChangeKeysInstance.methods.isValidVote(_id, votingKey).call() return this.instance.methods.isValidVote(_id, votingKey).call()
} }
isActive(_id) { isActive(_id) {
return this.votingToChangeKeysInstance.methods.isActive(_id).call() return this.instance.methods.isActive(_id).call()
} }
canBeFinalizedNow(_id) { canBeFinalizedNow(_id) {
if (this.doesMethodExist('canBeFinalizedNow')) { if (this.doesMethodExist('canBeFinalizedNow')) {
return this.votingToChangeKeysInstance.methods.canBeFinalizedNow(_id).call() return this.instance.methods.canBeFinalizedNow(_id).call()
} }
return null return null
} }
async getBallotLimit(_miningKey, _limitPerValidator) { async getBallotLimit(_miningKey, _limitPerValidator) {
const _activeBallots = await this.votingToChangeKeysInstance.methods.validatorActiveBallots(_miningKey).call() const _activeBallots = await this.instance.methods.validatorActiveBallots(_miningKey).call()
return _limitPerValidator - _activeBallots return _limitPerValidator - _activeBallots
} }
} }

View File

@ -1,87 +1,80 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class VotingToChangeMinThreshold { export default class VotingToChangeMinThreshold {
async init({ web3, netId }) { async init({ web3, netId }) {
const { VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS } = networkAddresses(netId) const { VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS } = networkAddresses()
console.log('VotingToChangeMinThreshold address', VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS) console.log('VotingToChangeMinThreshold address', VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const votingToChangeMinThresholdABI = await helpers.getABI(
constants.NETWORKS[netId].BRANCH,
const votingToChangeMinThresholdABI = await helpers.getABI(branch, 'VotingToChangeMinThreshold') 'VotingToChangeMinThreshold'
this.votingToChangeMinThresholdInstance = new web3_10.eth.Contract(
votingToChangeMinThresholdABI,
VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS
) )
this.gasPrice = web3_10.utils.toWei('1', 'gwei')
this.instance = new web3.eth.Contract(votingToChangeMinThresholdABI, VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS)
this.address = VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS this.address = VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS
this.instance = this.votingToChangeMinThresholdInstance
} }
//setters //setters
createBallot({ startTime, endTime, proposedValue, memo }) { createBallot({ startTime, endTime, proposedValue, memo }) {
let method let method
if (this.votingToChangeMinThresholdInstance.methods.createBallot) { if (this.instance.methods.createBallot) {
method = this.votingToChangeMinThresholdInstance.methods.createBallot method = this.instance.methods.createBallot
} else { } else {
method = this.votingToChangeMinThresholdInstance.methods.createBallotToChangeThreshold method = this.instance.methods.createBallotToChangeThreshold
} }
return method(startTime, endTime, proposedValue, memo).encodeABI() return method(startTime, endTime, proposedValue, memo).encodeABI()
} }
vote(_id, choice) { vote(_id, choice) {
return this.votingToChangeMinThresholdInstance.methods.vote(_id, choice).encodeABI() return this.instance.methods.vote(_id, choice).encodeABI()
} }
finalize(_id) { finalize(_id) {
return this.votingToChangeMinThresholdInstance.methods.finalize(_id).encodeABI() return this.instance.methods.finalize(_id).encodeABI()
} }
//getters //getters
doesMethodExist(methodName) { doesMethodExist(methodName) {
if (this.votingToChangeMinThresholdInstance.methods[methodName]) { if (this.instance.methods[methodName]) {
return true return true
} }
return false return false
} }
nextBallotId() { nextBallotId() {
return this.votingToChangeMinThresholdInstance.methods.nextBallotId().call() return this.instance.methods.nextBallotId().call()
} }
getBallotInfo(_id, _votingKey) { getBallotInfo(_id, _votingKey) {
if (this.doesMethodExist('getBallotInfo')) { if (this.doesMethodExist('getBallotInfo')) {
return this.votingToChangeMinThresholdInstance.methods.getBallotInfo(_id, _votingKey).call() return this.instance.methods.getBallotInfo(_id, _votingKey).call()
} }
return this.votingToChangeMinThresholdInstance.methods.votingState(_id).call() return this.instance.methods.votingState(_id).call()
} }
hasAlreadyVoted(_id, votingKey) { hasAlreadyVoted(_id, votingKey) {
return this.votingToChangeMinThresholdInstance.methods.hasAlreadyVoted(_id, votingKey).call() return this.instance.methods.hasAlreadyVoted(_id, votingKey).call()
} }
isValidVote(_id, votingKey) { isValidVote(_id, votingKey) {
return this.votingToChangeMinThresholdInstance.methods.isValidVote(_id, votingKey).call() return this.instance.methods.isValidVote(_id, votingKey).call()
} }
isActive(_id) { isActive(_id) {
return this.votingToChangeMinThresholdInstance.methods.isActive(_id).call() return this.instance.methods.isActive(_id).call()
} }
canBeFinalizedNow(_id) { canBeFinalizedNow(_id) {
if (this.doesMethodExist('canBeFinalizedNow')) { if (this.doesMethodExist('canBeFinalizedNow')) {
return this.votingToChangeMinThresholdInstance.methods.canBeFinalizedNow(_id).call() return this.instance.methods.canBeFinalizedNow(_id).call()
} }
return null return null
} }
async getBallotLimit(_miningKey, _limitPerValidator) { async getBallotLimit(_miningKey, _limitPerValidator) {
const _activeBallots = await this.votingToChangeMinThresholdInstance.methods const _activeBallots = await this.instance.methods.validatorActiveBallots(_miningKey).call()
.validatorActiveBallots(_miningKey)
.call()
return _limitPerValidator - _activeBallots return _limitPerValidator - _activeBallots
} }
} }

View File

@ -1,83 +1,76 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class VotingToChangeProxy { export default class VotingToChangeProxy {
async init({ web3, netId }) { async init({ web3, netId }) {
const { VOTING_TO_CHANGE_PROXY_ADDRESS } = networkAddresses(netId) const { VOTING_TO_CHANGE_PROXY_ADDRESS } = networkAddresses()
console.log('VotingToChangeProxy address', VOTING_TO_CHANGE_PROXY_ADDRESS) console.log('VotingToChangeProxy address', VOTING_TO_CHANGE_PROXY_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const votingToChangeProxyABI = await helpers.getABI(constants.NETWORKS[netId].BRANCH, 'VotingToChangeProxyAddress')
const votingToChangeProxyABI = await helpers.getABI(branch, 'VotingToChangeProxyAddress') this.instance = new web3.eth.Contract(votingToChangeProxyABI, VOTING_TO_CHANGE_PROXY_ADDRESS)
this.votingToChangeProxyInstance = new web3_10.eth.Contract(votingToChangeProxyABI, VOTING_TO_CHANGE_PROXY_ADDRESS)
this.gasPrice = web3_10.utils.toWei('1', 'gwei')
this.address = VOTING_TO_CHANGE_PROXY_ADDRESS this.address = VOTING_TO_CHANGE_PROXY_ADDRESS
this.instance = this.votingToChangeProxyInstance
} }
//setters //setters
createBallot({ startTime, endTime, proposedValue, contractType, memo }) { createBallot({ startTime, endTime, proposedValue, contractType, memo }) {
if (!this.votingToChangeProxyInstance.methods.createBallot) { if (!this.instance.methods.createBallot) {
return this.votingToChangeProxyInstance.methods return this.instance.methods
.createBallotToChangeProxyAddress(startTime, endTime, proposedValue, contractType, memo) .createBallotToChangeProxyAddress(startTime, endTime, proposedValue, contractType, memo)
.encodeABI() .encodeABI()
} }
return this.votingToChangeProxyInstance.methods return this.instance.methods.createBallot(startTime, endTime, contractType, memo, proposedValue).encodeABI()
.createBallot(startTime, endTime, contractType, memo, proposedValue)
.encodeABI()
} }
vote(_id, choice) { vote(_id, choice) {
return this.votingToChangeProxyInstance.methods.vote(_id, choice).encodeABI() return this.instance.methods.vote(_id, choice).encodeABI()
} }
finalize(_id) { finalize(_id) {
return this.votingToChangeProxyInstance.methods.finalize(_id).encodeABI() return this.instance.methods.finalize(_id).encodeABI()
} }
//getters //getters
doesMethodExist(methodName) { doesMethodExist(methodName) {
if (this.votingToChangeProxyInstance.methods[methodName]) { if (this.instance.methods[methodName]) {
return true return true
} }
return false return false
} }
nextBallotId() { nextBallotId() {
return this.votingToChangeProxyInstance.methods.nextBallotId().call() return this.instance.methods.nextBallotId().call()
} }
getBallotInfo(_id, _votingKey) { getBallotInfo(_id, _votingKey) {
if (this.doesMethodExist('getBallotInfo')) { if (this.doesMethodExist('getBallotInfo')) {
return this.votingToChangeProxyInstance.methods.getBallotInfo(_id, _votingKey).call() return this.instance.methods.getBallotInfo(_id, _votingKey).call()
} }
return this.votingToChangeProxyInstance.methods.votingState(_id).call() return this.instance.methods.votingState(_id).call()
} }
hasAlreadyVoted(_id, votingKey) { hasAlreadyVoted(_id, votingKey) {
return this.votingToChangeProxyInstance.methods.hasAlreadyVoted(_id, votingKey).call() return this.instance.methods.hasAlreadyVoted(_id, votingKey).call()
} }
isValidVote(_id, votingKey) { isValidVote(_id, votingKey) {
return this.votingToChangeProxyInstance.methods.isValidVote(_id, votingKey).call() return this.instance.methods.isValidVote(_id, votingKey).call()
} }
isActive(_id) { isActive(_id) {
return this.votingToChangeProxyInstance.methods.isActive(_id).call() return this.instance.methods.isActive(_id).call()
} }
canBeFinalizedNow(_id) { canBeFinalizedNow(_id) {
if (this.doesMethodExist('canBeFinalizedNow')) { if (this.doesMethodExist('canBeFinalizedNow')) {
return this.votingToChangeProxyInstance.methods.canBeFinalizedNow(_id).call() return this.instance.methods.canBeFinalizedNow(_id).call()
} }
return null return null
} }
async getBallotLimit(_miningKey, _limitPerValidator) { async getBallotLimit(_miningKey, _limitPerValidator) {
const _activeBallots = await this.votingToChangeProxyInstance.methods.validatorActiveBallots(_miningKey).call() const _activeBallots = await this.instance.methods.validatorActiveBallots(_miningKey).call()
return _limitPerValidator - _activeBallots return _limitPerValidator - _activeBallots
} }
} }

View File

@ -1,18 +1,18 @@
import Web3 from 'web3'
import { networkAddresses } from './addresses' import { networkAddresses } from './addresses'
import helpers from './helpers' import helpers from './helpers'
import { constants } from '../constants'
export default class VotingToManageEmissionFunds { export default class VotingToManageEmissionFunds {
async init({ web3, netId }) { async init({ web3, netId }) {
const { VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS } = networkAddresses(netId) const { VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS } = networkAddresses()
console.log('VotingToManageEmissionFunds address', VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS) console.log('VotingToManageEmissionFunds address', VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS)
const web3_10 = new Web3(web3.currentProvider)
const branch = helpers.getBranch(netId) const votingToManageEmissionFundsABI = await helpers.getABI(
constants.NETWORKS[netId].BRANCH,
'VotingToManageEmissionFunds'
)
const votingToManageEmissionFundsABI = await helpers.getABI(branch, 'VotingToManageEmissionFunds') this.instance = new web3.eth.Contract(votingToManageEmissionFundsABI, VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS)
this.instance = new web3_10.eth.Contract(votingToManageEmissionFundsABI, VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS)
this.address = VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS this.address = VOTING_TO_MANAGE_EMISSION_FUNDS_ADDRESS
} }

View File

@ -1,4 +1,3 @@
import { constants } from '../constants'
import { addressesURL, wrongRepoAlert } from './helpers' import { addressesURL, wrongRepoAlert } from './helpers'
// const local = { // const local = {
// VOTING_TO_CHANGE_KEYS_ADDRESS: '0xecdbe3937cf6ff27f70480855cfe03254f915b48', // VOTING_TO_CHANGE_KEYS_ADDRESS: '0xecdbe3937cf6ff27f70480855cfe03254f915b48',
@ -9,13 +8,10 @@ import { addressesURL, wrongRepoAlert } from './helpers'
// POA_ADDRESS: '0xf472e0e43570b9afaab67089615080cf7c20018d', // POA_ADDRESS: '0xf472e0e43570b9afaab67089615080cf7c20018d',
// } // }
let SOKOL_ADDRESSES = {} let ADDRESSES = {}
let CORE_ADDRESSES = {}
let DAI_TEST_ADDRESSES = {}
let DAI_ADDRESSES = {}
async function getContractsAddresses(branch) { async function getContractsAddresses(branch) {
let addr = addressesURL(branch) const addr = addressesURL(branch)
let response let response
try { try {
response = await fetch(addr) response = await fetch(addr)
@ -23,43 +19,16 @@ async function getContractsAddresses(branch) {
return wrongRepoAlert(addr) return wrongRepoAlert(addr)
} }
let contracts = await response.json() const contracts = await response.json()
switch (branch) { ADDRESSES = contracts
case 'core':
CORE_ADDRESSES = contracts
break
case 'dai':
DAI_ADDRESSES = contracts
break
case 'sokol':
SOKOL_ADDRESSES = contracts
break
case 'dai-test':
DAI_TEST_ADDRESSES = contracts
break
default:
CORE_ADDRESSES = contracts
break
}
} }
function getAddresses(netId) { function networkAddresses() {
switch (netId) { return ADDRESSES
case constants.NETID_SOKOL:
return SOKOL_ADDRESSES
case constants.NETID_DAI_TEST:
return DAI_TEST_ADDRESSES
case constants.NETID_CORE:
return CORE_ADDRESSES
case constants.NETID_DAI:
return DAI_ADDRESSES
default:
return CORE_ADDRESSES
}
} }
module.exports = { module.exports = {
getContractsAddresses, getContractsAddresses,
networkAddresses: getAddresses networkAddresses
} }

View File

@ -27,25 +27,9 @@ function wrongRepoAlert(addr) {
swal('Error!', messages.wrongRepo(addr), 'error') swal('Error!', messages.wrongRepo(addr), 'error')
} }
function getBranch(netId) {
switch (netId) {
case constants.NETID_SOKOL:
return 'sokol'
case constants.NETID_DAI_TEST:
return 'dai-test'
case constants.NETID_CORE:
return 'core'
case constants.NETID_DAI:
return 'dai'
default:
return 'core'
}
}
module.exports = { module.exports = {
addressesURL, addressesURL,
ABIURL, ABIURL,
getABI, getABI,
wrongRepoAlert, wrongRepoAlert
getBranch
} }

View File

@ -1,66 +1,69 @@
import Web3 from 'web3'
import { messages } from './messages' import { messages } from './messages'
import { constants } from './constants' import { constants } from './constants'
let getWeb3 = () => { let getWeb3 = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Wait for loading completion to avoid race conditions with web3 injection timing. // Wait for loading completion to avoid race conditions with web3 injection timing.
window.addEventListener('load', () => { window.addEventListener('load', async () => {
var results let web3
var web3 = window.web3
// Checking if Web3 has been injected by the browser (Mist/MetaMask) // Checking if Web3 has been injected by the browser (Mist/MetaMask)
if (typeof web3 !== 'undefined') { if (window.ethereum) {
// Use Mist/MetaMask's provider. web3 = new Web3(window.ethereum)
var errorMsg = null console.log('Injected web3 detected.')
web3 = new window.Web3(web3.currentProvider) try {
web3.version.getNetwork((err, netId) => { await window.ethereum.enable()
let netIdName } catch (e) {
console.log('netId', netId) console.error('User denied account access')
switch (netId) { reject({ message: messages.USER_DENIED_ACCOUNT_ACCESS })
case constants.NETID_DAI: return
netIdName = 'Dai' }
console.log('This is Dai', netId) } else if (typeof window.web3 !== 'undefined') {
break web3 = new Web3(window.web3.currentProvider)
case constants.NETID_CORE:
netIdName = 'Core'
console.log('This is Core', netId)
break
case constants.NETID_DAI_TEST:
netIdName = 'Dai-Test'
console.log('This is Dai-Test', netId)
break
case constants.NETID_SOKOL:
netIdName = 'Sokol'
console.log('This is Sokol', netId)
break
default:
netIdName = 'ERROR'
errorMsg = messages.WRONG_NETWORK_MSG
console.log('This is an unknown network.', netId)
}
document.title = `${netIdName} - POA Network Governance DApp`
var defaultAccount = web3.eth.defaultAccount || null
if (defaultAccount === null) {
reject({ message: messages.NO_METAMASK_MSG })
}
if (errorMsg !== null) {
reject({ message: errorMsg })
}
results = {
web3Instance: web3,
netIdName,
netId,
injectedWeb3: true,
defaultAccount
}
resolve(results)
})
console.log('Injected web3 detected.') console.log('Injected web3 detected.')
} else { } else {
reject({ message: messages.NO_METAMASK_MSG })
console.error('Metamask not found') console.error('Metamask not found')
reject({ message: messages.NO_METAMASK_MSG })
return
} }
const netId = await web3.eth.net.getId()
console.log('netId', netId)
let netIdName
let errorMsg = null
if (netId in constants.NETWORKS) {
netIdName = constants.NETWORKS[netId].NAME
console.log(`This is ${netIdName}`)
} else {
netIdName = 'ERROR'
errorMsg = messages.WRONG_NETWORK_MSG
console.log('This is an unknown network.')
}
document.title = `${netIdName} - POA Network Governance DApp`
if (errorMsg !== null) {
reject({ message: errorMsg })
return
}
const accounts = await web3.eth.getAccounts()
var defaultAccount = accounts[0] || null
if (defaultAccount === null) {
reject({ message: messages.NO_METAMASK_MSG })
return
}
resolve({
web3Instance: web3,
netIdName,
netId,
defaultAccount
})
}) })
}) })
} }

View File

@ -1,4 +1,3 @@
import Web3 from 'web3'
import swal from 'sweetalert2' import swal from 'sweetalert2'
import { constants } from './constants' import { constants } from './constants'
@ -23,7 +22,7 @@ function sleep(ms) {
function sendTransactionByVotingKey(props, to, data, cb, warning) { function sendTransactionByVotingKey(props, to, data, cb, warning) {
const { commonStore, contractsStore } = props const { commonStore, contractsStore } = props
const web3 = new Web3(contractsStore.web3Instance.currentProvider) const web3 = contractsStore.web3Instance
web3.eth.sendTransaction( web3.eth.sendTransaction(
{ {
@ -59,12 +58,7 @@ function sendTransactionByVotingKey(props, to, data, cb, warning) {
) )
} }
function isTestnet(netId) {
return netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
}
module.exports = { module.exports = {
toAscii, toAscii,
sendTransactionByVotingKey, sendTransactionByVotingKey
isTestnet
} }

View File

@ -11,7 +11,6 @@ import ballotStore from './stores/BallotStore'
import ballotsStore from './stores/BallotsStore' import ballotsStore from './stores/BallotsStore'
import contractsStore from './stores/ContractsStore' import contractsStore from './stores/ContractsStore'
import { getContractsAddresses } from './contracts/addresses' import { getContractsAddresses } from './contracts/addresses'
import { getBranch } from './contracts/helpers'
import swal from 'sweetalert2' import swal from 'sweetalert2'
import getWeb3 from './getWeb3' import getWeb3 from './getWeb3'
import 'babel-polyfill' import 'babel-polyfill'
@ -35,7 +34,7 @@ class AppMainRouter extends Component {
getWeb3() getWeb3()
.then(async web3Config => { .then(async web3Config => {
await getContractsAddresses(getBranch(web3Config.netId)) await getContractsAddresses(constants.NETWORKS[web3Config.netId].BRANCH)
contractsStore.setWeb3Instance(web3Config) contractsStore.setWeb3Instance(web3Config)
@ -48,7 +47,7 @@ class AppMainRouter extends Component {
const setVotingToChangeProxy = contractsStore.setVotingToChangeProxy(web3Config) const setVotingToChangeProxy = contractsStore.setVotingToChangeProxy(web3Config)
const setValidatorMetadata = contractsStore.setValidatorMetadata(web3Config) const setValidatorMetadata = contractsStore.setValidatorMetadata(web3Config)
const promises = [ let promises = [
setPoaConsensus, setPoaConsensus,
setBallotsStorage, setBallotsStorage,
setKeysManager, setKeysManager,
@ -59,8 +58,9 @@ class AppMainRouter extends Component {
setValidatorMetadata setValidatorMetadata
] ]
if (web3Config.netId === constants.NETID_SOKOL) { const networkName = constants.NETWORKS[web3Config.netId].NAME.toLowerCase()
// if we're in Sokol if (networkName === 'core' || networkName === 'sokol') {
// if we're in Core or Sokol
promises.push(contractsStore.setEmissionFunds(web3Config)) promises.push(contractsStore.setEmissionFunds(web3Config))
promises.push(contractsStore.setVotingToManageEmissionFunds(web3Config)) promises.push(contractsStore.setVotingToManageEmissionFunds(web3Config))
} }

View File

@ -15,6 +15,7 @@ messages.MINING_KEY_IS_NOT_ADDRESS_MSG = "Ballot miningKey isn't address"
messages.PROPOSED_ADDRESS_IS_NOT_ADDRESS_MSG = "Proposed address isn't address" 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.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.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 = `You haven't chosen any account in MetaMask. messages.NO_METAMASK_MSG = `You haven't chosen any account in MetaMask.
Please, choose your voting key in MetaMask and reload the page. Please, choose your voting key in MetaMask and reload the page.
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.` Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`

View File

@ -61,13 +61,13 @@ class ContractsStore {
@action('Get keys ballot threshold') @action('Get keys ballot threshold')
getKeysBallotThreshold = async () => { getKeysBallotThreshold = async () => {
this.keysBallotThreshold = await this.ballotsStorage.ballotsStorageInstance.methods.getBallotThreshold(1).call() this.keysBallotThreshold = await this.ballotsStorage.instance.methods.getBallotThreshold(1).call()
this.minThresholdBallotThreshold = this.keysBallotThreshold this.minThresholdBallotThreshold = this.keysBallotThreshold
} }
@action('Get proxy ballot threshold') @action('Get proxy ballot threshold')
getProxyBallotThreshold = async () => { getProxyBallotThreshold = async () => {
this.proxyBallotThreshold = await this.ballotsStorage.ballotsStorageInstance.methods.getProxyThreshold().call() this.proxyBallotThreshold = await this.ballotsStorage.instance.methods.getProxyThreshold().call()
this.emissionFundsBallotThreshold = this.proxyBallotThreshold this.emissionFundsBallotThreshold = this.proxyBallotThreshold
} }
@ -176,7 +176,7 @@ class ContractsStore {
@action('Get validators length') @action('Get validators length')
getValidatorsLength = async () => { getValidatorsLength = async () => {
this.validatorsLength = await this.poaConsensus.poaInstance.methods.getCurrentValidatorsLength().call() this.validatorsLength = await this.poaConsensus.instance.methods.getCurrentValidatorsLength().call()
} }
@action('Set voting key') @action('Set voting key')
@ -389,9 +389,7 @@ class ContractsStore {
@action @action
async getBallotsLimits() { async getBallotsLimits() {
if (this.web3Instance && this.netId) { if (this.web3Instance && this.netId) {
const limitPerValidator = await this.ballotsStorage.ballotsStorageInstance.methods const limitPerValidator = await this.ballotsStorage.instance.methods.getBallotLimitPerValidator().call()
.getBallotLimitPerValidator()
.call()
let getKeysLimit = await this.votingToChangeKeys.getBallotLimit(this.miningKey, limitPerValidator) let getKeysLimit = await this.votingToChangeKeys.getBallotLimit(this.miningKey, limitPerValidator)
let getMinThresholdLimit = await this.votingToChangeMinThreshold.getBallotLimit(this.miningKey, limitPerValidator) let getMinThresholdLimit = await this.votingToChangeMinThreshold.getBallotLimit(this.miningKey, limitPerValidator)