diff --git a/src/App.js b/src/App.js
index 2459212..cf7e2e1 100644
--- a/src/App.js
+++ b/src/App.js
@@ -9,6 +9,7 @@ import { error } from 'util';
import addressGenerator from './addressGenerator'
import JSzip from 'jszip';
import FileSaver from 'file-saver';
+import { constants } from './constants';
function generateElement(msg){
let errorNode = document.createElement("div");
@@ -46,7 +47,8 @@ class App extends Component {
this.keysManager = null;
getWeb3().then((web3Config) => {
this.setState({web3Config})
- this.keysManager = new KeysManager({
+ this.keysManager = new KeysManager()
+ this.keysManager.init({
web3: web3Config.web3Instance,
netId: web3Config.netId
});
@@ -75,7 +77,6 @@ class App extends Component {
const mining = await addressGenerator();
const voting = await addressGenerator();
const payout = await addressGenerator();
- const netIdName = this.state.web3Config.netIdName;
this.setState({
mining,
voting,
@@ -114,7 +115,6 @@ class App extends Component {
icon: 'error',
title: 'Error',
content: generateElement(invalidKeyMsg)
-
})
return;
}
@@ -130,15 +130,20 @@ class App extends Component {
console.log(receipt);
this.setState({loading: false})
swal("Congratulations!", "Your keys are generated!", "success");
- await this.generateZip({mining, voting, payout});
+ await this.generateZip({mining, voting, payout, netIdName: this.state.web3Config.netIdName});
}).catch((error) => {
console.error(error.message);
this.setState({loading: false, keysGenerated: false})
var content = document.createElement("div");
+ let msg;
+ if (error.message.includes(constants.userDeniedTransactionPattern))
+ msg = `Error: User ${constants.userDeniedTransactionPattern}`
+ else
+ msg = error.message
content.innerHTML = `
Something went wrong!
Please contact Master Of Ceremony
- ${error.message}
+ ${msg}
`;
swal({
icon: 'error',
diff --git a/src/DownloadBtn.js b/src/DownloadBtn.js
deleted file mode 100644
index e69de29..0000000
diff --git a/src/addresses.js b/src/addresses.js
index feb10b0..8f228a1 100644
--- a/src/addresses.js
+++ b/src/addresses.js
@@ -1,29 +1,19 @@
import { messages } from "./messages";
import swal from 'sweetalert';
+import helpers from "./helpers";
// const local = {
-// VOTING_TO_CHANGE_KEYS_ADDRESS: '0xecdbe3937cf6ff27f70480855cfe03254f915b48',
-// VOTING_TO_CHANGE_MIN_THRESHOLD_ADDRESS: '0x5ae30d4c8892292e0d8164f87a2e12dff9dc99e1',
-// VOTING_TO_CHANGE_PROXY_ADDRESS: '0x6c221df3695ac13a7f9366568ec069c353d273b8',
-// BALLOTS_STORAGE_ADDRESS: '0x5d6573e62e3688e40c1fc36e01b155fb0006f432',
-// METADATA_ADDRESS: '0x93eba9d9de66133fcde35775e9da593edd59a4e3',
-// POA_ADDRESS: '0xf472e0e43570b9afaab67089615080cf7c20018d',
-// }
+// "KEYS_MANAGER_ADDRESS": "0x3ef32bb244016ad9af8c8f45398511e7e551b581"
+//}
let SOKOL_ADDRESSES = {};
let CORE_ADDRESSES = {};
-function addressesURL(network) {
- const organization = 'poanetwork';
- const repoName = 'poa-chain-spec';
- const sourceFile = 'contracts.json';
- return `https://raw.githubusercontent.com/${organization}/${repoName}/${network}/${sourceFile}`;
-}
-
-function getContractsAddresses(network) {
- fetch(addressesURL(network)).then(function(response) {
+function getContractsAddresses(branch) {
+ let addr = helpers.addressesURL(branch);
+ fetch(helpers.addressesURL(branch)).then(function(response) {
return response.json();
}).then(function(contracts) {
- switch (network) {
+ switch (branch) {
case 'core':
CORE_ADDRESSES = contracts;
break;
@@ -35,16 +25,7 @@ function getContractsAddresses(network) {
break;
}
}).catch(function(err) {
- var content = document.createElement("div");
- content.innerHTML = `
- Something went wrong!
- ${messages.wrongRepo(addressesURL(network))}
-
`;
- swal({
- icon: 'error',
- title: 'Error',
- content: content
- });
+ helpers.wrongRepoAlert(addr);
});
}
diff --git a/src/keysManager.js b/src/keysManager.js
index 5ee467c..8cbf37f 100644
--- a/src/keysManager.js
+++ b/src/keysManager.js
@@ -1,16 +1,22 @@
-import KeysManagerAbi from './keysManagerAbi.json';
import Web3 from 'web3';
import addressGenerator from './addressGenerator';
import networkAddresses from './addresses';
+import helpers from "./helpers";
export default class KeysManager {
- constructor({web3, netId}){
- let web3_10 = new Web3(web3.currentProvider);
+ async init({web3, netId}){
+ this.web3_10 = new Web3(web3.currentProvider);
const {KEYS_MANAGER_ADDRESS} = networkAddresses(netId);
console.log('Keys Manager ', KEYS_MANAGER_ADDRESS);
- this.web3_10 = web3_10;
- this.keysInstance = new web3_10.eth.Contract(KeysManagerAbi, KEYS_MANAGER_ADDRESS);
+ const branch = helpers.getBranch(netId);
+
+ let that = this;
+
+ let KeysManagerAbi = await helpers.getABI(branch, 'KeysManager')
+
+ that.keysInstance = new this.web3_10.eth.Contract(KeysManagerAbi, KEYS_MANAGER_ADDRESS);
}
+
async isInitialKeyValid(initialKey) {
return await this.keysInstance.methods.initialKeys(initialKey).call();
}
diff --git a/src/keysManagerAbi.json b/src/keysManagerAbi.json
deleted file mode 100644
index 18cb54f..0000000
--- a/src/keysManagerAbi.json
+++ /dev/null
@@ -1,760 +0,0 @@
-[
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "successfulValidatorClone",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "removePayoutKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "removeVotingKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "getVotingByMining",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_votingKey",
- "type": "address"
- }
- ],
- "name": "getMiningKeyByVoting",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- }
- ],
- "name": "addMiningKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "poaNetworkConsensus",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "miningKeyHistory",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "getVotingToChangeKeys",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "getTime",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "validatorKeys",
- "outputs": [
- {
- "name": "votingKey",
- "type": "address"
- },
- {
- "name": "payoutKey",
- "type": "address"
- },
- {
- "name": "isMiningActive",
- "type": "bool"
- },
- {
- "name": "isVotingActive",
- "type": "bool"
- },
- {
- "name": "isPayoutActive",
- "type": "bool"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "previousKeysManager",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_votingKey",
- "type": "address"
- }
- ],
- "name": "isVotingActive",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- },
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "addPayoutKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "initialKeys",
- "outputs": [
- {
- "name": "",
- "type": "uint8"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- },
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "swapPayoutKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "getPayoutByMining",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- }
- ],
- "name": "removeMiningKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "maxLimitValidators",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "migrateMiningKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_initialKey",
- "type": "address"
- }
- ],
- "name": "initiateKeys",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- },
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "addVotingKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_initialKey",
- "type": "address"
- }
- ],
- "name": "migrateInitialKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- }
- ],
- "name": "isMiningActive",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "contractVersion",
- "outputs": [
- {
- "name": "",
- "type": "uint8"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "getMiningKeyHistory",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "proxyStorage",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_initialKey",
- "type": "address"
- }
- ],
- "name": "getInitialKey",
- "outputs": [
- {
- "name": "",
- "type": "uint8"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- },
- {
- "name": "_votingKey",
- "type": "address"
- },
- {
- "name": "_payoutKey",
- "type": "address"
- }
- ],
- "name": "createKeys",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "initialKeysCount",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- },
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "swapVotingKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": false,
- "inputs": [
- {
- "name": "_key",
- "type": "address"
- },
- {
- "name": "_oldMiningKey",
- "type": "address"
- }
- ],
- "name": "swapMiningKey",
- "outputs": [],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "maxNumberOfInitialKeys",
- "outputs": [
- {
- "name": "",
- "type": "uint256"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "name": "miningKeyByVoting",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [],
- "name": "masterOfCeremony",
- "outputs": [
- {
- "name": "",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "constant": true,
- "inputs": [
- {
- "name": "_miningKey",
- "type": "address"
- }
- ],
- "name": "isPayoutActive",
- "outputs": [
- {
- "name": "",
- "type": "bool"
- }
- ],
- "payable": false,
- "stateMutability": "view",
- "type": "function"
- },
- {
- "inputs": [
- {
- "name": "_proxyStorage",
- "type": "address"
- },
- {
- "name": "_poaConsensus",
- "type": "address"
- },
- {
- "name": "_masterOfCeremony",
- "type": "address"
- },
- {
- "name": "_previousKeysManager",
- "type": "address"
- }
- ],
- "payable": false,
- "stateMutability": "nonpayable",
- "type": "constructor"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": false,
- "name": "key",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "miningKey",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "action",
- "type": "string"
- }
- ],
- "name": "PayoutKeyChanged",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": false,
- "name": "key",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "miningKey",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "action",
- "type": "string"
- }
- ],
- "name": "VotingKeyChanged",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": false,
- "name": "key",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "action",
- "type": "string"
- }
- ],
- "name": "MiningKeyChanged",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "miningKey",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "votingKey",
- "type": "address"
- },
- {
- "indexed": true,
- "name": "payoutKey",
- "type": "address"
- }
- ],
- "name": "ValidatorInitialized",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": true,
- "name": "initialKey",
- "type": "address"
- },
- {
- "indexed": false,
- "name": "time",
- "type": "uint256"
- },
- {
- "indexed": false,
- "name": "initialKeysCount",
- "type": "uint256"
- }
- ],
- "name": "InitialKeyCreated",
- "type": "event"
- },
- {
- "anonymous": false,
- "inputs": [
- {
- "indexed": false,
- "name": "name",
- "type": "string"
- },
- {
- "indexed": false,
- "name": "key",
- "type": "address"
- }
- ],
- "name": "Migrated",
- "type": "event"
- }
-]
\ No newline at end of file