Merge pull request #83 from varasev/dai-netid
(Feature) Add poa-chain-spec branch name and netId for DAI shard
This commit is contained in:
commit
b1b6e485f1
|
@ -203,7 +203,7 @@ class App extends Component {
|
|||
}
|
||||
render() {
|
||||
const { netId } = this.props.web3Config
|
||||
const classNameHiddenIfNotCoreNetwork = netId !== '99' ? 'display-none' : ''
|
||||
const classNameHiddenIfNotCoreNetwork = netId !== constants.NETID_CORE ? 'display-none' : ''
|
||||
|
||||
if (!this.isValidVotingKey) {
|
||||
return null
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import React from 'react'
|
||||
import moment from 'moment'
|
||||
import Socials from './Socials'
|
||||
import { isTestnet } from './helpers'
|
||||
|
||||
const Footer = ({ netId }) => {
|
||||
const footerClassName = netId === '77' ? 'sokol' : ''
|
||||
const footerClassName = isTestnet(netId) ? 'sokol' : ''
|
||||
|
||||
return (
|
||||
<footer className={`footer ${footerClassName}`}>
|
||||
|
|
|
@ -8,12 +8,15 @@ import menuOpenIconBase from './images/icons/icon-close.svg'
|
|||
import menuOpenIconSokol from './images/icons/icon-close-sokol.svg'
|
||||
import NavigationLinks from './NavigationLinks'
|
||||
import MobileMenuLinks from './MobileMenuLinks'
|
||||
import { constants } from './constants'
|
||||
import { isTestnet } from './helpers'
|
||||
|
||||
const Header = ({ netId, onChange, injectedWeb3, showMobileMenu, onMenuToggle, baseRootPath, navigationData }) => {
|
||||
const headerClassName = netId === '77' ? 'sokol' : ''
|
||||
const logoImageName = netId === '77' ? logoSokol : logoBase
|
||||
const menuIcon = netId === '77' ? menuIconSokol : menuIconBase
|
||||
const menuOpenIcon = netId === '77' ? menuOpenIconSokol : menuOpenIconBase
|
||||
const thisIsTestnet = isTestnet(netId)
|
||||
const headerClassName = thisIsTestnet ? 'sokol' : ''
|
||||
const logoImageName = thisIsTestnet ? logoSokol : logoBase
|
||||
const menuIcon = thisIsTestnet ? menuIconSokol : menuIconBase
|
||||
const menuOpenIcon = thisIsTestnet ? menuOpenIconSokol : menuOpenIconBase
|
||||
|
||||
let select
|
||||
|
||||
|
@ -30,7 +33,10 @@ const Header = ({ netId, onChange, injectedWeb3, showMobileMenu, onMenuToggle, b
|
|||
width: '150px'
|
||||
}}
|
||||
clearable={false}
|
||||
options={[{ value: '77', label: 'Network: Sokol' }, { value: '99', label: 'Network: Core' }]}
|
||||
options={[
|
||||
{ value: constants.NETID_SOKOL, label: 'Network: Sokol' },
|
||||
{ value: constants.NETID_CORE, label: 'Network: Core' }
|
||||
]}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import React from 'react'
|
||||
import { constants } from './constants'
|
||||
|
||||
const styles = netId => {
|
||||
const core = {
|
||||
|
@ -9,9 +10,11 @@ const styles = netId => {
|
|||
}
|
||||
|
||||
switch (netId) {
|
||||
case '77':
|
||||
case constants.NETID_SOKOL:
|
||||
case constants.NETID_DAI_TEST:
|
||||
return sokol
|
||||
case '99':
|
||||
case constants.NETID_CORE:
|
||||
case constants.NETID_DAI:
|
||||
return core
|
||||
default:
|
||||
return {}
|
||||
|
|
|
@ -10,6 +10,11 @@ constants.ABIsSources = {
|
|||
}
|
||||
constants.userDeniedTransactionPattern = 'User denied transaction'
|
||||
|
||||
constants.NETID_SOKOL = '77'
|
||||
constants.NETID_CORE = '99'
|
||||
constants.NETID_DAI_TEST = '79'
|
||||
constants.NETID_DAI = '100'
|
||||
|
||||
module.exports = {
|
||||
constants
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { constants } from '../constants'
|
||||
import helpers from './helpers'
|
||||
import helpersGlobal from '../helpers'
|
||||
import messages from '../messages'
|
||||
|
@ -12,12 +13,18 @@ export default web3Config => {
|
|||
let branch
|
||||
|
||||
switch (web3Config.netId) {
|
||||
case '77':
|
||||
case constants.NETID_SOKOL:
|
||||
branch = 'sokol'
|
||||
break
|
||||
case '99':
|
||||
case constants.NETID_DAI_TEST:
|
||||
branch = 'dai-test'
|
||||
break
|
||||
case constants.NETID_CORE:
|
||||
branch = 'core'
|
||||
break
|
||||
case constants.NETID_DAI:
|
||||
branch = 'dai'
|
||||
break
|
||||
default:
|
||||
branch = 'core'
|
||||
break
|
||||
|
|
|
@ -25,10 +25,14 @@ function getABI(branch, contract) {
|
|||
|
||||
function getBranch(netId) {
|
||||
switch (netId) {
|
||||
case '77':
|
||||
case constants.NETID_SOKOL:
|
||||
return 'sokol'
|
||||
case '99':
|
||||
case constants.NETID_DAI_TEST:
|
||||
return 'dai-test'
|
||||
case constants.NETID_CORE:
|
||||
return 'core'
|
||||
case constants.NETID_DAI:
|
||||
return 'dai'
|
||||
default:
|
||||
return 'core'
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import Web3 from 'web3'
|
||||
const POA_CORE = { RPC_URL: 'https://core.poa.network', netIdName: 'CORE', netId: '99' }
|
||||
const POA_SOKOL = { RPC_URL: 'https://sokol.poa.network', netIdName: 'SOKOL', netId: '77' }
|
||||
import { constants } from './constants'
|
||||
|
||||
const POA_CORE = { RPC_URL: 'https://core.poa.network', netIdName: 'CORE', netId: constants.NETID_CORE }
|
||||
const POA_SOKOL = { RPC_URL: 'https://sokol.poa.network', netIdName: 'SOKOL', netId: constants.NETID_SOKOL }
|
||||
const POA_DAI = { RPC_URL: 'https://dai.poa.network', netIdName: 'DAI', netId: constants.NETID_DAI }
|
||||
const POA_DAI_TEST = { RPC_URL: 'https://dai-test.poa.network', netIdName: 'DAI-TEST', netId: constants.NETID_DAI_TEST }
|
||||
|
||||
let getWeb3 = () => {
|
||||
return new Promise(function(resolve, reject) {
|
||||
// Wait for loading completion to avoid race conditions with web3 injection timing.
|
||||
|
@ -17,11 +22,19 @@ let getWeb3 = () => {
|
|||
let netIdName
|
||||
console.log('netId', netId)
|
||||
switch (netId) {
|
||||
case '99':
|
||||
case constants.NETID_DAI:
|
||||
netIdName = 'Dai'
|
||||
console.log('This is Dai', netId)
|
||||
break
|
||||
case constants.NETID_CORE:
|
||||
netIdName = 'Core'
|
||||
console.log('This is Core', netId)
|
||||
break
|
||||
case '77':
|
||||
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
|
||||
|
@ -51,7 +64,16 @@ let getWeb3 = () => {
|
|||
} else {
|
||||
// Fallback to localhost if no web3 injection.
|
||||
|
||||
const network = window.location.host.indexOf('sokol') !== -1 ? POA_SOKOL : POA_CORE
|
||||
let network
|
||||
if (window.location.host.indexOf('sokol') !== -1) {
|
||||
network = POA_SOKOL
|
||||
} else if (window.location.host.indexOf('dai-test') !== -1) {
|
||||
network = POA_DAI_TEST
|
||||
} else if (window.location.host.indexOf('dai') !== -1) {
|
||||
network = POA_DAI
|
||||
} else {
|
||||
network = POA_CORE
|
||||
}
|
||||
|
||||
document.title = `${network.netIdName} - POA validators dApp`
|
||||
const provider = new Web3.providers.HttpProvider(network.RPC_URL)
|
||||
|
@ -75,12 +97,18 @@ let getWeb3 = () => {
|
|||
const setWeb3 = netId => {
|
||||
let network
|
||||
switch (netId) {
|
||||
case '77':
|
||||
case constants.NETID_SOKOL:
|
||||
network = POA_SOKOL
|
||||
break
|
||||
case '99':
|
||||
case constants.NETID_DAI_TEST:
|
||||
network = POA_DAI_TEST
|
||||
break
|
||||
case constants.NETID_CORE:
|
||||
network = POA_CORE
|
||||
break
|
||||
case constants.NETID_DAI:
|
||||
network = POA_DAI
|
||||
break
|
||||
default:
|
||||
network = POA_CORE
|
||||
break
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import swal from 'sweetalert'
|
||||
import { constants } from './constants'
|
||||
|
||||
function generateAlert(icon, title, msg) {
|
||||
var content = document.createElement('div')
|
||||
|
@ -10,8 +11,11 @@ function generateAlert(icon, title, msg) {
|
|||
})
|
||||
}
|
||||
|
||||
let helpers = {
|
||||
generateAlert
|
||||
function isTestnet(netId) {
|
||||
return netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST
|
||||
}
|
||||
|
||||
export default helpers
|
||||
module.exports = {
|
||||
generateAlert,
|
||||
isTestnet
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import networkAddresses from './contracts/addresses'
|
|||
import registerServiceWorker from './registerServiceWorker'
|
||||
import { Router, Route } from 'react-router-dom'
|
||||
import { messages } from './messages'
|
||||
import { constants } from './constants'
|
||||
|
||||
const history = createBrowserHistory()
|
||||
const baseRootPath = '/poa-dapps-validators'
|
||||
|
@ -214,7 +215,8 @@ class AppMainRouter extends Component {
|
|||
)
|
||||
}
|
||||
getNetIdClass() {
|
||||
return this.state.netId === '77' ? 'sokol' : ''
|
||||
const netId = this.state.netId
|
||||
return netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST ? 'sokol' : ''
|
||||
}
|
||||
onSearch(term) {
|
||||
this.setState({ searchTerm: term.target.value.toLowerCase() })
|
||||
|
|
Loading…
Reference in New Issue