2017-12-19 07:17:49 -08:00
|
|
|
import React, { Component } from 'react';
|
2017-12-11 14:23:01 -08:00
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
import { BrowserRouter } from 'react-router-dom';
|
|
|
|
import App from './App';
|
|
|
|
import registerServiceWorker from './registerServiceWorker';
|
2017-12-19 06:27:27 -08:00
|
|
|
import { Provider } from 'mobx-react';
|
2017-12-20 05:13:28 -08:00
|
|
|
import commonStore from './stores/CommonStore';
|
2017-12-19 08:53:51 -08:00
|
|
|
import validatorStore from './stores/ValidatorStore';
|
|
|
|
import ballotStore from './stores/BallotStore';
|
2017-12-19 07:17:49 -08:00
|
|
|
import contractsStore from './stores/ContractsStore';
|
2017-12-11 14:23:01 -08:00
|
|
|
import swal from 'sweetalert2';
|
2017-12-20 05:13:28 -08:00
|
|
|
import getWeb3 from './getWeb3';
|
2017-12-19 07:17:49 -08:00
|
|
|
import "babel-polyfill";
|
|
|
|
|
2017-12-20 05:13:28 -08:00
|
|
|
const stores = { commonStore, contractsStore, ballotStore, validatorStore };
|
2017-12-19 07:17:49 -08:00
|
|
|
|
|
|
|
function generateElement(msg){
|
|
|
|
let errorNode = document.createElement("div");
|
|
|
|
errorNode.innerHTML = `<div>
|
|
|
|
${msg}
|
|
|
|
</div>`;
|
|
|
|
return errorNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
class AppMainRouter extends Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
getWeb3().then(async (web3Config) => {
|
2017-12-20 05:13:28 -08:00
|
|
|
contractsStore.setWeb3Instance(web3Config);
|
2017-12-19 07:17:49 -08:00
|
|
|
contractsStore.setVotingToChangeKeys(web3Config);
|
|
|
|
contractsStore.setVotingToChangeMinThreshold(web3Config);
|
|
|
|
contractsStore.setVotingToChangeProxy(web3Config);
|
2017-12-19 08:53:51 -08:00
|
|
|
contractsStore.setVotingKey(web3Config);
|
|
|
|
await contractsStore.setMiningKey(web3Config);
|
|
|
|
console.log("votingKey", contractsStore.votingKey)
|
|
|
|
console.log("miningKey", contractsStore.miningKey)
|
2017-12-19 07:17:49 -08:00
|
|
|
}).catch((error) => {
|
|
|
|
console.error(error.message);
|
|
|
|
swal({
|
|
|
|
icon: 'error',
|
|
|
|
title: 'Error',
|
|
|
|
content: generateElement(error.message)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
render(){
|
|
|
|
return (
|
|
|
|
<Provider { ...stores }>
|
|
|
|
<BrowserRouter>
|
|
|
|
<App/>
|
|
|
|
</BrowserRouter>
|
|
|
|
</Provider>
|
|
|
|
)
|
|
|
|
}
|
2017-12-11 14:23:01 -08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-19 07:17:49 -08:00
|
|
|
ReactDOM.render(<AppMainRouter />, document.getElementById('root'));
|
2017-12-11 14:23:01 -08:00
|
|
|
registerServiceWorker();
|