Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load addresses based on netId #25

Merged
merged 2 commits into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions src/contracts/KeysManager.contract.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
13 changes: 6 additions & 7 deletions src/contracts/Metadata.contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/contracts/PoaConsensus.contract.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
23 changes: 21 additions & 2 deletions src/contracts/addresses.js
Original file line number Diff line number Diff line change
@@ -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
}
}
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down