From 8708bd56b13e6d4c027f1b338c56a4126a7913e5 Mon Sep 17 00:00:00 2001 From: Vadim Arasev Date: Fri, 25 Jan 2019 20:39:32 +0300 Subject: [PATCH 1/3] Add `RewardByBlock` item to the page `Modify Proxy Contract Ballot` --- src/components/BallotProxyMetadata/index.js | 23 +++++++++------------ src/stores/BallotStore.js | 3 ++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/components/BallotProxyMetadata/index.js b/src/components/BallotProxyMetadata/index.js index 8a9e34e..e0d0c01 100644 --- a/src/components/BallotProxyMetadata/index.js +++ b/src/components/BallotProxyMetadata/index.js @@ -7,22 +7,19 @@ import { inject, observer } from 'mobx-react' @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 - /*2*/ { value: '2', label: ballotStore.ProxyBallotType[2] }, // VotingToChangeKeys - /*3*/ { value: '3', label: ballotStore.ProxyBallotType[3] }, // VotingToChangeMinThreshold - /*4*/ { value: '4', label: ballotStore.ProxyBallotType[4] }, // VotingToChangeProxy - /*5*/ { value: '5', label: ballotStore.ProxyBallotType[5] }, // BallotsStorage - /*6*/ { value: '7', label: ballotStore.ProxyBallotType[7] }, // ValidatorMetadata - /*7*/ { value: '8', label: ballotStore.ProxyBallotType[8] } // ProxyStorage + { value: '', label: '' }, + { value: '1', label: ballotStore.ProxyBallotType[1] }, // KeysManager + { value: '2', label: ballotStore.ProxyBallotType[2] }, // VotingToChangeKeys + { value: '3', label: ballotStore.ProxyBallotType[3] }, // VotingToChangeMinThreshold + { value: '4', label: ballotStore.ProxyBallotType[4] }, // VotingToChangeProxy + { value: '5', label: ballotStore.ProxyBallotType[5] }, // BallotsStorage + { value: '7', label: ballotStore.ProxyBallotType[7] }, // ValidatorMetadata + { value: '8', label: ballotStore.ProxyBallotType[8] }, // ProxyStorage + { value: '9', label: ballotStore.ProxyBallotType[9] } // RewardByBlock ] - if (!contractsStore.proxyStorage || !contractsStore.proxyStorage.doesMethodExist('getValidatorMetadata')) { - options.splice(6) // keep 0-5 and remove 6-... items if ProxyStorage is old - } - return (
diff --git a/src/stores/BallotStore.js b/src/stores/BallotStore.js index 690003a..5645dad 100644 --- a/src/stores/BallotStore.js +++ b/src/stores/BallotStore.js @@ -26,7 +26,8 @@ class BallotStore { 4: 'VotingToChangeProxy', 5: 'BallotsStorage', 7: 'ValidatorMetadata', - 8: 'ProxyStorage' + 8: 'ProxyStorage', + 9: 'RewardByBlock' } @observable ballotType @observable keysBallotType From 1b7ae3e94b08753bc9da4fea443690fe32cb2af1 Mon Sep 17 00:00:00 2001 From: Vadim Arasev Date: Fri, 25 Jan 2019 21:04:16 +0300 Subject: [PATCH 2/3] `RewardByBlock` item only for `Sokol` network --- src/components/BallotProxyMetadata/index.js | 25 ++++++++++++--------- src/utils/constants.js | 6 ----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/components/BallotProxyMetadata/index.js b/src/components/BallotProxyMetadata/index.js index e0d0c01..9c7e6e4 100644 --- a/src/components/BallotProxyMetadata/index.js +++ b/src/components/BallotProxyMetadata/index.js @@ -2,24 +2,29 @@ import React from 'react' import { FormInput } from '../FormInput' import { FormSelect } from '../FormSelect' import { inject, observer } from 'mobx-react' +import { getNetworkName } from '../../utils/utils' @inject('ballotStore', 'contractsStore') @observer export class BallotProxyMetadata extends React.Component { render() { - const { ballotStore, networkBranch } = this.props + const { ballotStore, contractsStore, networkBranch } = this.props let options = [ - { value: '', label: '' }, - { value: '1', label: ballotStore.ProxyBallotType[1] }, // KeysManager - { value: '2', label: ballotStore.ProxyBallotType[2] }, // VotingToChangeKeys - { value: '3', label: ballotStore.ProxyBallotType[3] }, // VotingToChangeMinThreshold - { value: '4', label: ballotStore.ProxyBallotType[4] }, // VotingToChangeProxy - { value: '5', label: ballotStore.ProxyBallotType[5] }, // BallotsStorage - { value: '7', label: ballotStore.ProxyBallotType[7] }, // ValidatorMetadata - { value: '8', label: ballotStore.ProxyBallotType[8] }, // ProxyStorage - { value: '9', label: ballotStore.ProxyBallotType[9] } // RewardByBlock + /*0*/ { value: '', label: '' }, + /*1*/ { value: '1', label: ballotStore.ProxyBallotType[1] }, // KeysManager + /*2*/ { value: '2', label: ballotStore.ProxyBallotType[2] }, // VotingToChangeKeys + /*3*/ { value: '3', label: ballotStore.ProxyBallotType[3] }, // VotingToChangeMinThreshold + /*4*/ { value: '4', label: ballotStore.ProxyBallotType[4] }, // VotingToChangeProxy + /*5*/ { value: '5', label: ballotStore.ProxyBallotType[5] }, // BallotsStorage + /*6*/ { value: '7', label: ballotStore.ProxyBallotType[7] }, // ValidatorMetadata + /*7*/ { value: '8', label: ballotStore.ProxyBallotType[8] }, // ProxyStorage + /*8*/ { value: '9', label: ballotStore.ProxyBallotType[9] } // RewardByBlock ] + if (getNetworkName(contractsStore.netId).toLowerCase() != 'sokol') { + options.splice(8) // keep 0-7 items and remove 8th if the network is not Sokol + } + return (
diff --git a/src/utils/constants.js b/src/utils/constants.js index 8778580..50fbfe5 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -64,12 +64,6 @@ constants.NETWORKS = { BRANCH: 'core', TESTNET: false }, - '79': { - NAME: 'Dai-Test', - RPC: 'https://dai-test.poa.network', - BRANCH: 'dai-test', - TESTNET: true - }, '100': { NAME: 'Dai', RPC: 'https://dai.poa.network', From 3ef692cfa00a42d5c33db8b2dc22a54ac402cd90 Mon Sep 17 00:00:00 2001 From: Vadim Arasev Date: Sat, 26 Jan 2019 16:32:36 +0300 Subject: [PATCH 3/3] Small refactoring --- src/App.js | 2 +- src/components/BallotEmissionFundsMetadata/index.js | 9 +++------ src/components/BallotProxyMetadata/index.js | 3 ++- src/components/Logo/index.js | 7 +++---- src/index.js | 2 +- src/utils/constants.js | 10 +++++++--- src/utils/getWeb3.js | 2 +- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/App.js b/src/App.js index 032a5ac..a8c3988 100644 --- a/src/App.js +++ b/src/App.js @@ -87,7 +87,7 @@ class App extends Component { getNetIdClass() { const { netId } = this.props.contractsStore - return netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET ? 'sokol' : '' + return netId in constants.NETWORKS && constants.NETWORKS[netId].TESTNET ? constants.SOKOL : '' } isNewBallotPage() { diff --git a/src/components/BallotEmissionFundsMetadata/index.js b/src/components/BallotEmissionFundsMetadata/index.js index e0ade22..4dc9f41 100644 --- a/src/components/BallotEmissionFundsMetadata/index.js +++ b/src/components/BallotEmissionFundsMetadata/index.js @@ -72,7 +72,7 @@ export class BallotEmissionFundsMetadata extends React.Component { render() { const { ballotStore, contractsStore, networkBranch } = this.props - let note, explorerLink + let note if (this.noActiveBallotExists === true) { note = ( @@ -85,11 +85,8 @@ export class BallotEmissionFundsMetadata extends React.Component { note =

To be able to create a new ballot, the previous ballot of this type must be finalized.

} - if (constants.NETWORKS[contractsStore.netId].NAME.toLowerCase() === 'sokol') { - explorerLink = `https://sokol.poaexplorer.com/address/search/${contractsStore.emissionFunds.address}` - } else { - explorerLink = `https://poaexplorer.com/address/${contractsStore.emissionFunds.address}` - } + const networkName = constants.NETWORKS[contractsStore.netId].NAME.toLowerCase() + const explorerLink = `https://blockscout.com/poa/${networkName}/address/${contractsStore.emissionFunds.address}` return (
diff --git a/src/components/BallotProxyMetadata/index.js b/src/components/BallotProxyMetadata/index.js index 9c7e6e4..8ee4c2a 100644 --- a/src/components/BallotProxyMetadata/index.js +++ b/src/components/BallotProxyMetadata/index.js @@ -2,6 +2,7 @@ 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') @@ -21,7 +22,7 @@ export class BallotProxyMetadata extends React.Component { /*8*/ { value: '9', label: ballotStore.ProxyBallotType[9] } // RewardByBlock ] - if (getNetworkName(contractsStore.netId).toLowerCase() != 'sokol') { + if (getNetworkName(contractsStore.netId).toLowerCase() !== constants.SOKOL) { options.splice(8) // keep 0-7 items and remove 8th if the network is not Sokol } diff --git a/src/components/Logo/index.js b/src/components/Logo/index.js index ffcaaba..0047e9f 100644 --- a/src/components/Logo/index.js +++ b/src/components/Logo/index.js @@ -2,15 +2,14 @@ import React from 'react' import { LogoPOA } from '../LogoPOA' import { LogoSokol } from '../LogoSokol' import { LogoDai } from '../LogoDai' +import { constants } from '../../utils/constants' export const Logo = ({ href = null, extraClass = '', networkBranch = '' }) => { switch (networkBranch) { - case 'sokol': + case constants.SOKOL: return - case 'dai': - case 'dai-test': + case constants.DAI: return - case 'poa': default: return } diff --git a/src/index.js b/src/index.js index 5ce9534..f9248c7 100644 --- a/src/index.js +++ b/src/index.js @@ -59,7 +59,7 @@ class AppMainRouter extends Component { ] const networkName = constants.NETWORKS[web3Config.netId].NAME.toLowerCase() - if (networkName === 'core' || networkName === 'sokol') { + if (networkName === constants.CORE || networkName === constants.SOKOL) { // if we're in Core or Sokol promises.push(contractsStore.setEmissionFunds(web3Config)) promises.push(contractsStore.setVotingToManageEmissionFunds(web3Config)) diff --git a/src/utils/constants.js b/src/utils/constants.js index 50fbfe5..35de4fa 100644 --- a/src/utils/constants.js +++ b/src/utils/constants.js @@ -51,23 +51,27 @@ constants.navigationData = [ } ] +constants.SOKOL = 'sokol' +constants.CORE = 'core' +constants.DAI = 'dai' + constants.NETWORKS = { '77': { NAME: 'Sokol', RPC: 'https://sokol.poa.network', - BRANCH: 'sokol', + BRANCH: constants.SOKOL, TESTNET: true }, '99': { NAME: 'Core', RPC: 'https://core.poa.network', - BRANCH: 'core', + BRANCH: constants.CORE, TESTNET: false }, '100': { NAME: 'Dai', RPC: 'https://dai.poa.network', - BRANCH: 'dai', + BRANCH: constants.DAI, TESTNET: false } } diff --git a/src/utils/getWeb3.js b/src/utils/getWeb3.js index f698357..b61da6b 100644 --- a/src/utils/getWeb3.js +++ b/src/utils/getWeb3.js @@ -52,7 +52,7 @@ let getWeb3 = () => { console.log('No web3 instance injected, using Local web3.') console.error('Metamask not found') - netId = netIdByName('core') + netId = netIdByName(constants.CORE) const network = constants.NETWORKS[netId]