From 7959c0514243c3a6aad9292ae9ae4abf17519b5f Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Tue, 9 Jan 2018 15:51:05 -0800 Subject: [PATCH 1/4] (Update) KeysManager address for sokol testnet --- src/addresses.js | 2 +- src/keysManagerAbi.json | 98 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/src/addresses.js b/src/addresses.js index 7b99b33..f8dd3d8 100644 --- a/src/addresses.js +++ b/src/addresses.js @@ -3,7 +3,7 @@ const CORE_ADDRESSES = { } const SOKOL_ADDRESSES = { - KEYS_MANAGER_ADDRESS: '0x88a34124bfffa27ef3e052c8dd2908e212643771', + KEYS_MANAGER_ADDRESS: '0xD480319659AFe5044FB09e2B92d10c987044DE4B', } module.exports = (netId) => { diff --git a/src/keysManagerAbi.json b/src/keysManagerAbi.json index 9986ded..18cb54f 100644 --- a/src/keysManagerAbi.json +++ b/src/keysManagerAbi.json @@ -1,4 +1,23 @@ [ + { + "constant": true, + "inputs": [ + { + "name": "", + "type": "address" + } + ], + "name": "successfulValidatorClone", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, { "constant": false, "inputs": [ @@ -50,7 +69,7 @@ "constant": true, "inputs": [ { - "name": "_miningKey", + "name": "_votingKey", "type": "address" } ], @@ -175,6 +194,20 @@ "stateMutability": "view", "type": "function" }, + { + "constant": true, + "inputs": [], + "name": "previousKeysManager", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, { "constant": true, "inputs": [ @@ -296,6 +329,20 @@ "stateMutability": "view", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "name": "_miningKey", + "type": "address" + } + ], + "name": "migrateMiningKey", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": false, "inputs": [ @@ -328,6 +375,20 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "name": "_initialKey", + "type": "address" + } + ], + "name": "migrateInitialKey", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": true, "inputs": [ @@ -347,6 +408,20 @@ "stateMutability": "view", "type": "function" }, + { + "constant": true, + "inputs": [], + "name": "contractVersion", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, { "constant": true, "inputs": [ @@ -550,6 +625,10 @@ { "name": "_masterOfCeremony", "type": "address" + }, + { + "name": "_previousKeysManager", + "type": "address" } ], "payable": false, @@ -660,5 +739,22 @@ ], "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 From 4cc9b925ec1d22c52fa48cda7ba17930bd4ded41 Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Tue, 9 Jan 2018 16:44:55 -0800 Subject: [PATCH 2/4] (Feature) Create a page where you can just generate keys --- src/App.js | 30 +++++++++++++++++++++--------- src/addresses.js | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/App.js b/src/App.js index eb87834..2a4f951 100644 --- a/src/App.js +++ b/src/App.js @@ -6,6 +6,7 @@ import swal from 'sweetalert'; import './index/index.css'; import ReactDOM from 'react-dom'; import { error } from 'util'; +import addressGenerator from './addressGenerator' function generateElement(msg){ let errorNode = document.createElement("div"); @@ -55,6 +56,25 @@ class App extends Component { } }) } + componentDidMount(){ + if(window.location.pathname.indexOf('just-generate-keys') !== -1) { + this.generateKeys(); + } + } + async generateKeys() { + const mining = await addressGenerator(); + const voting = await addressGenerator(); + const payout = await addressGenerator(); + this.setState({ + mining, + voting, + payout, + keysGenerated: true + }) + return { + mining, voting, payout + } + } async onClick() { this.setState({loading:true}); const initialKey = window.web3.eth.defaultAccount; @@ -74,15 +94,7 @@ class App extends Component { return; } if(Number(isValid) === 1){ - const mining = await this.keysManager.generateKeys(); - const voting = await this.keysManager.generateKeys(); - const payout = await this.keysManager.generateKeys(); - this.setState({ - mining, - voting, - payout, - keysGenerated: true - }) + const {mining, voting, payout} = await this.generateKeys() // add loading screen await this.keysManager.createKeys({ mining: mining.jsonStore.address, diff --git a/src/addresses.js b/src/addresses.js index f8dd3d8..031f213 100644 --- a/src/addresses.js +++ b/src/addresses.js @@ -10,7 +10,7 @@ module.exports = (netId) => { switch (netId){ case '77': return SOKOL_ADDRESSES - case '99': + case '99': return CORE_ADDRESSES default: return CORE_ADDRESSES From 9efbdf845a5b8833084401cd6a9945d5eedfc877 Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Tue, 9 Jan 2018 16:44:55 -0800 Subject: [PATCH 3/4] (Feature) Create a page where you can just generate keys --- src/App.js | 30 +++++++++++++++++++++--------- src/addresses.js | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/App.js b/src/App.js index eb87834..3d27764 100644 --- a/src/App.js +++ b/src/App.js @@ -6,6 +6,7 @@ import swal from 'sweetalert'; import './index/index.css'; import ReactDOM from 'react-dom'; import { error } from 'util'; +import addressGenerator from './addressGenerator' function generateElement(msg){ let errorNode = document.createElement("div"); @@ -55,6 +56,25 @@ class App extends Component { } }) } + componentDidMount(){ + if(window.location.hash.indexOf('just-generate-keys') !== -1) { + this.generateKeys(); + } + } + async generateKeys() { + const mining = await addressGenerator(); + const voting = await addressGenerator(); + const payout = await addressGenerator(); + this.setState({ + mining, + voting, + payout, + keysGenerated: true + }) + return { + mining, voting, payout + } + } async onClick() { this.setState({loading:true}); const initialKey = window.web3.eth.defaultAccount; @@ -74,15 +94,7 @@ class App extends Component { return; } if(Number(isValid) === 1){ - const mining = await this.keysManager.generateKeys(); - const voting = await this.keysManager.generateKeys(); - const payout = await this.keysManager.generateKeys(); - this.setState({ - mining, - voting, - payout, - keysGenerated: true - }) + const {mining, voting, payout} = await this.generateKeys() // add loading screen await this.keysManager.createKeys({ mining: mining.jsonStore.address, diff --git a/src/addresses.js b/src/addresses.js index f8dd3d8..031f213 100644 --- a/src/addresses.js +++ b/src/addresses.js @@ -10,7 +10,7 @@ module.exports = (netId) => { switch (netId){ case '77': return SOKOL_ADDRESSES - case '99': + case '99': return CORE_ADDRESSES default: return CORE_ADDRESSES From e251f273db656aabf41de60955004fbc547fa21b Mon Sep 17 00:00:00 2001 From: Roman Storm Date: Tue, 9 Jan 2018 16:59:26 -0800 Subject: [PATCH 4/4] (Fix) make codacy happy --- src/addresses.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/addresses.js b/src/addresses.js index 031f213..222fefd 100644 --- a/src/addresses.js +++ b/src/addresses.js @@ -1,9 +1,9 @@ const CORE_ADDRESSES = { - KEYS_MANAGER_ADDRESS: '0xfc90125492e58dbfe80c0bfb6a2a759c4f703ca8', + KEYS_MANAGER_ADDRESS: "0xfc90125492e58dbfe80c0bfb6a2a759c4f703ca8", } const SOKOL_ADDRESSES = { - KEYS_MANAGER_ADDRESS: '0xD480319659AFe5044FB09e2B92d10c987044DE4B', + KEYS_MANAGER_ADDRESS: "0xD480319659AFe5044FB09e2B92d10c987044DE4B", } module.exports = (netId) => {