Merge pull request #80 from varasev/dai-netid

(Feature) Add poa-chain-spec branch name and netId for DAI shard
This commit is contained in:
Vadim Arasev 2018-10-03 11:32:25 +03:00 committed by GitHub
commit 646431be5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 62 deletions

68
package-lock.json generated
View File

@ -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",

View File

@ -1,7 +1,9 @@
import React from 'react';
import moment from 'moment';
import React from "react";
import moment from "moment";
import helpers from "./helpers";
const Footer = ({netId}) => {
const footerClassName = netId === '77' ? 'sokol' : '';
const footerClassName = helpers.isTestnet(netId) ? "sokol" : "";
return (
<footer className={`footer ${footerClassName}`}>
<div className="container">

View File

@ -1,7 +1,10 @@
import React from 'react';
import helpers from "./helpers";
let Header = ({netId}) => {
const headerClassName = netId === '77' ? 'sokol' : '';
const logoClassName = netId === '77' ? '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">

View File

@ -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,9 +9,11 @@ const styles = (netId) => {
backgroundColor: 'rgba(47, 109, 99, 0.8)'
}
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 {};

View File

@ -1,3 +1,4 @@
import { constants } from "./constants";
import helpers from "./helpers";
//const local = {
// "KEYS_MANAGER_ADDRESS": "0x3ef32bb244016ad9af8c8f45398511e7e551b581"
@ -7,14 +8,18 @@ export default (web3Config) => {
let branch;
switch (web3Config.netId) {
case '77':
branch = 'sokol'
case constants.NETID_DAI_TEST:
branch = "dai-test";
break;
case '99':
branch = 'core'
case constants.NETID_SOKOL:
branch = "sokol";
break;
case constants.NETID_DAI:
branch = "dai";
break;
case constants.NETID_CORE:
default:
branch = 'core'
branch = "core";
break;
}
return new Promise((resolve, reject) => {

View File

@ -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
}

View File

@ -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,22 +26,30 @@ let getWeb3 = () => {
web3.version.getNetwork((err, netId) => {
let netIdName;
switch (netId) {
case "77":
netIdName = 'Sokol'
console.log('This is sokol')
case constants.NETID_SOKOL:
netIdName = "Sokol";
console.log("This is sokol");
break
case "99":
netIdName = 'Core'
console.log('This is Core')
case constants.NETID_DAI_TEST:
netIdName = "Dai-Test";
console.log("This is Dai-Test");
break
case constants.NETID_CORE:
netIdName = "Core";
console.log("This is Core");
break
case constants.NETID_DAI:
netIdName = "Dai";
console.log("This is Dai");
break
default:
netIdName = 'Unknown'
netIdName = "Unknown";
errorMsg = `You aren't connected to POA Network.
Please switch on Metamask and refresh the page.
Check POA Network <a href='https://github.com/poanetwork/wiki' target='blank'>wiki</a> for more info.
<b>Current Network ID</b> is <i>${netId}</i>`
<b>Current Network ID</b> is <i>${netId}</i>`;
console.log('This is an unknown network.', netId)
console.log("This is an unknown network.", netId);
}
results = {
web3Instance: web3,
@ -69,4 +79,3 @@ let getWeb3 = () => {
}
export default getWeb3

View File

@ -49,23 +49,30 @@ function wrongRepoAlert(addr) {
function getBranch(netId) {
switch (netId) {
case '77':
return 'sokol'
case '99':
return 'core'
case constants.NETID_DAI_TEST:
return "dai-test";
case constants.NETID_SOKOL:
return "sokol";
case constants.NETID_DAI:
return "dai";
case constants.NETID_CORE:
default:
return 'core'
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