Merge pull request #25 from rstormsf/core

load addresses based on netId
This commit is contained in:
Roman Storm 2017-12-30 12:41:50 -08:00 committed by GitHub
commit 2681a8709e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 47 additions and 17 deletions

8
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,8 @@
- (Mandatory) Description
a human-readable description of changes
a human-readable description of the purpose of the PR
- (Mandatory) What is it: (Fix), (Feature), or (Refactor) in Title, e.g., "(Fix) price of 1 token in Wei > 18 decimals"
- (Mandatory) Developers: Each completed PR should be updated in the Wiki Documentation.
(Recommended) Each PR should have one commit message and therefore should only contain one specific fix or feature. Otherwise, multiple PRs should be made
- Did you check that your PR is chain agnostic? It shouldn't depend on any hardcoded chainIds, URLs.
- (Optional) Any additional concerns or comments

View File

@ -1,13 +1,14 @@
import KeysManagerAbi from './keysManager.abi.json'
import Web3 from 'web3';
import {KEYS_MANAGER_ADDRESS} from './addresses';
import networkAddresses from './addresses';
console.log('Keys Manager', KEYS_MANAGER_ADDRESS);
export default class KeysManager {
constructor({web3}){
constructor({web3, netId}){
let web3_10 = new Web3(web3.currentProvider);
const {KEYS_MANAGER_ADDRESS} = networkAddresses(netId);
this.keysInstance = new web3_10.eth.Contract(KeysManagerAbi, KEYS_MANAGER_ADDRESS);
console.log('Keys Manager', KEYS_MANAGER_ADDRESS);
}
async isVotingActive(votingKey) {
return await this.keysInstance.methods.isVotingActive(votingKey).call();

View File

@ -2,7 +2,7 @@ import PoaConsensus from './PoaConsensus.contract'
import MetadataAbi from './metadata.abi.json'
import Web3 from 'web3';
import moment from 'moment';
import {METADATA_ADDRESS} from './addresses';
import networkAddresses from './addresses';
var toAscii = function(hex) {
var str = '',
i = 0,
@ -17,14 +17,13 @@ var toAscii = function(hex) {
}
return str;
};
console.log('Metadata contract:', METADATA_ADDRESS)
const SOKOL_MOC = '0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca';
const CORE_MOC = '0xCf260eA317555637C55F70e55dbA8D5ad8414Cb0';
export default class Metadata {
constructor({web3}){
constructor({web3, netId}){
this.web3_10 = new Web3(web3.currentProvider);
const {METADATA_ADDRESS, MOC} = networkAddresses(netId);
this.metadataInstance = new this.web3_10.eth.Contract(MetadataAbi, METADATA_ADDRESS);
this.MOC_ADDRESS = MOC;
console.log('Metadata contract:', METADATA_ADDRESS)
}
async createMetadata({
firstName,
@ -96,7 +95,7 @@ export default class Metadata {
const keys = await poaInstance.getValidators()
for (let key of keys) {
let data = await this.getValidatorData({miningKey: key})
if(key === SOKOL_MOC || key === CORE_MOC) {
if(key === this.MOC_ADDRESS) {
data = this.getMocData()
}
data.address = key

View File

@ -1,12 +1,13 @@
import poaConsensusAbi from './poaConsensus.abi.json'
import Web3 from 'web3';
import {POA_ADDRESS} from './addresses';
import networkAddresses from './addresses';
console.log('POA Address ' , POA_ADDRESS)
export default class POAConsensus {
constructor({web3}){
constructor({web3, netId}){
let web3_10 = new Web3(web3.currentProvider);
const {POA_ADDRESS} = networkAddresses(netId);
this.poaInstance = new web3_10.eth.Contract(poaConsensusAbi, POA_ADDRESS);
console.log('POA Address ' , POA_ADDRESS)
}
async getValidators(){
return await this.poaInstance.methods.getValidators().call();

View File

@ -1,5 +1,24 @@
module.exports = {
const CORE_ADDRESSES = {
METADATA_ADDRESS: '0xcBB2912666c7e8023B7ec78B6842702eB26336aC',
KEYS_MANAGER_ADDRESS: '0xfc90125492e58dbfe80c0bfb6a2a759c4f703ca8',
POA_ADDRESS: '0x8bf38d4764929064f2d4d3a56520a76ab3df415b'
POA_ADDRESS: '0x8bf38d4764929064f2d4d3a56520a76ab3df415b',
MOC: '0xCf260eA317555637C55F70e55dbA8D5ad8414Cb0'
}
const SOKOL_ADDRESSES = {
METADATA_ADDRESS: '0xce9ff1123223d13672cce06dd073d3749764daa6',
KEYS_MANAGER_ADDRESS: '0x88a34124bfffa27ef3e052c8dd2908e212643771',
POA_ADDRESS: '0x8bf38d4764929064f2d4d3a56520a76ab3df415b',
MOC: '0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca'
}
module.exports = (netId) => {
switch (netId){
case '77':
return SOKOL_ADDRESSES
case '99':
return CORE_ADDRESSES
default:
return CORE_ADDRESSES
}
}

View File

@ -51,10 +51,12 @@ class AppMainRouter extends Component {
}
getWeb3().then(async (web3Config) => {
const keysManager = new KeysManager({
web3: web3Config.web3Instance
web3: web3Config.web3Instance,
netId: web3Config.netId
});
const metadataContract = new Metadata({
web3: web3Config.web3Instance
web3: web3Config.web3Instance,
netId: web3Config.netId
})
this.setState({
votingKey: web3Config.defaultAccount,