(Refactor) Move hardcoded netIds to constants.js
This commit is contained in:
parent
b669201cd9
commit
46c980d98e
|
@ -4248,11 +4248,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"
|
||||
|
@ -4269,7 +4271,8 @@
|
|||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
|
@ -4398,6 +4401,7 @@
|
|||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -12016,14 +12020,6 @@
|
|||
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
|
||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
|
||||
},
|
||||
"typedarray-to-buffer": {
|
||||
"version": "3.1.5",
|
||||
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
|
||||
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
|
||||
"requires": {
|
||||
"is-typedarray": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"ua-parser-js": {
|
||||
"version": "0.7.17",
|
||||
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz",
|
||||
|
@ -12742,11 +12738,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"
|
||||
|
@ -12759,15 +12757,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",
|
||||
|
@ -12870,7 +12871,8 @@
|
|||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -12880,6 +12882,7 @@
|
|||
"is-fullwidth-code-point": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -12892,6 +12895,7 @@
|
|||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -12991,7 +12995,8 @@
|
|||
},
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true
|
||||
"bundled": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -13106,6 +13111,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",
|
||||
|
@ -13570,8 +13576,19 @@
|
|||
"integrity": "sha1-fecPG4Py3jZHZ3IVa+z+9uNRbrM=",
|
||||
"requires": {
|
||||
"underscore": "1.8.3",
|
||||
"web3-core-helpers": "1.0.0-beta.34",
|
||||
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
|
||||
"web3-core-helpers": "1.0.0-beta.34"
|
||||
},
|
||||
"dependencies": {
|
||||
"websocket": {
|
||||
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||
"requires": {
|
||||
"debug": "^2.2.0",
|
||||
"nan": "^2.3.3",
|
||||
"typedarray-to-buffer": "^3.1.2",
|
||||
"yaeti": "^0.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"web3-shh": {
|
||||
|
@ -13969,16 +13986,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"websocket": {
|
||||
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
|
||||
"from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
|
||||
"requires": {
|
||||
"debug": "^2.2.0",
|
||||
"nan": "^2.3.3",
|
||||
"typedarray-to-buffer": "^3.1.2",
|
||||
"yaeti": "^0.0.6"
|
||||
}
|
||||
},
|
||||
"websocket-driver": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz",
|
||||
|
@ -14230,11 +14237,6 @@
|
|||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
|
||||
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE="
|
||||
},
|
||||
"yaeti": {
|
||||
"version": "0.0.6",
|
||||
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
|
||||
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
|
||||
},
|
||||
"yallist": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz",
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import React from 'react'
|
||||
import moment from 'moment'
|
||||
import helpers from "./helpers";
|
||||
|
||||
const Footer = ({netId}) => {
|
||||
const isTestnet = netId === '77' || netId === '79'
|
||||
const footerClassName = isTestnet ? 'sokol' : ''
|
||||
const footerClassName = helpers.isTestnet(netId) ? 'sokol' : ''
|
||||
return (
|
||||
<footer className={`footer ${footerClassName}`}>
|
||||
<div className="container">
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import React from 'react'
|
||||
import React from 'react';
|
||||
import helpers from "./helpers";
|
||||
|
||||
let Header = ({netId}) => {
|
||||
const isTestnet = netId === '77' || netId === '79'
|
||||
const headerClassName = isTestnet ? 'sokol' : ''
|
||||
const logoClassName = isTestnet ? 'header-logo-sokol' : 'header-logo'
|
||||
const thisIsTestnet = helpers.isTestnet(netId)
|
||||
const headerClassName = thisIsTestnet ? 'sokol' : ''
|
||||
const logoClassName = thisIsTestnet ? 'header-logo-sokol' : 'header-logo'
|
||||
return (
|
||||
<header className={`header ${headerClassName}`}>
|
||||
<div className="container">
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import React from 'react';
|
||||
import { constants } from "./constants";
|
||||
|
||||
const styles = (netId) => {
|
||||
const core = {
|
||||
backgroundColor: 'rgba(35, 29, 115, 0.8)'
|
||||
|
@ -7,11 +9,11 @@ const styles = (netId) => {
|
|||
backgroundColor: 'rgba(47, 109, 99, 0.8)'
|
||||
}
|
||||
switch(netId) {
|
||||
case '77':
|
||||
case '79':
|
||||
case constants.NETID_SOKOL:
|
||||
case constants.NETID_DAI_TEST:
|
||||
return sokol;
|
||||
case '99':
|
||||
case '100':
|
||||
case constants.NETID_CORE:
|
||||
case constants.NETID_DAI:
|
||||
return core;
|
||||
default:
|
||||
return {};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { constants } from "./constants";
|
||||
import helpers from "./helpers";
|
||||
//const local = {
|
||||
// "KEYS_MANAGER_ADDRESS": "0x3ef32bb244016ad9af8c8f45398511e7e551b581"
|
||||
|
@ -7,21 +8,21 @@ export default (web3Config) => {
|
|||
let branch;
|
||||
|
||||
switch (web3Config.netId) {
|
||||
case '77':
|
||||
branch = 'sokol'
|
||||
break
|
||||
case '79':
|
||||
branch = 'dai-test'
|
||||
break
|
||||
case '99':
|
||||
branch = 'core'
|
||||
break
|
||||
case '100':
|
||||
branch = 'dai'
|
||||
break
|
||||
case constants.NETID_SOKOL:
|
||||
branch = 'sokol';
|
||||
break;
|
||||
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
|
||||
branch = 'core';
|
||||
break;
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
fetch(helpers.addressesURL(branch)).then((response) => {
|
||||
|
|
|
@ -6,6 +6,12 @@ constants.ABIsSources = {
|
|||
'KeysManager': 'KeysManager.abi.json'
|
||||
};
|
||||
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,5 @@
|
|||
import { constants } from "./constants";
|
||||
|
||||
let errorMsgNoMetamaskAccount = `You haven't chosen any account in MetaMask.
|
||||
Please choose your initial key in MetaMask and reload the page.
|
||||
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.`;
|
||||
|
@ -24,19 +26,19 @@ let getWeb3 = () => {
|
|||
web3.version.getNetwork((err, netId) => {
|
||||
let netIdName;
|
||||
switch (netId) {
|
||||
case "77":
|
||||
case constants.NETID_SOKOL:
|
||||
netIdName = 'Sokol'
|
||||
console.log('This is sokol')
|
||||
break
|
||||
case "79":
|
||||
case constants.NETID_DAI_TEST:
|
||||
netIdName = 'Dai-Test'
|
||||
console.log('This is Dai-Test')
|
||||
break
|
||||
case "99":
|
||||
case constants.NETID_CORE:
|
||||
netIdName = 'Core'
|
||||
console.log('This is Core')
|
||||
break
|
||||
case "100":
|
||||
case constants.NETID_DAI:
|
||||
netIdName = 'Dai'
|
||||
console.log('This is Dai')
|
||||
break
|
||||
|
@ -77,4 +79,3 @@ let getWeb3 = () => {
|
|||
}
|
||||
|
||||
export default getWeb3
|
||||
|
||||
|
|
|
@ -49,27 +49,31 @@ function wrongRepoAlert(addr) {
|
|||
|
||||
function getBranch(netId) {
|
||||
switch (netId) {
|
||||
case '77':
|
||||
case constants.NETID_SOKOL:
|
||||
return 'sokol'
|
||||
case '79':
|
||||
case constants.NETID_DAI_TEST:
|
||||
return 'dai-test'
|
||||
case '99':
|
||||
case constants.NETID_CORE:
|
||||
return 'core'
|
||||
case '100':
|
||||
case constants.NETID_DAI:
|
||||
return 'dai'
|
||||
default:
|
||||
return 'core'
|
||||
}
|
||||
}
|
||||
|
||||
function isTestnet(netId) {
|
||||
return netId === constants.NETID_SOKOL || netId === constants.NETID_DAI_TEST;
|
||||
}
|
||||
|
||||
let helpers = {
|
||||
toAscii,
|
||||
addressesURL,
|
||||
ABIURL,
|
||||
getABI,
|
||||
wrongRepoAlert,
|
||||
getBranch
|
||||
getBranch,
|
||||
isTestnet
|
||||
}
|
||||
|
||||
export default helpers
|
||||
|
||||
|
|
Loading…
Reference in New Issue