liquid-funding/app/dapp.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-11-28 16:12:50 +00:00
import React from 'react';
import EmbarkJS from 'Embark/EmbarkJS';
2018-11-29 16:45:57 +00:00
import LPVault from 'Embark/contracts/LPVault';
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock';
2018-11-28 16:12:50 +00:00
import web3 from "Embark/web3";
2018-12-01 14:31:04 +00:00
import Divider from '@material-ui/core/Divider';
2018-11-30 11:02:57 +00:00
import AddFunder from './components/AddFunder';
2018-11-30 18:36:09 +00:00
import CreateFunding from './components/CreateFunding';
2018-12-01 20:32:00 +00:00
import { initVaultAndLP, vaultPledgingNeedsInit, standardTokenApproval } from './utils/initialize'
2018-11-28 16:12:50 +00:00
const { getNetworkType } = web3.eth.net;
class App extends React.Component {
constructor(props) {
super(props)
}
state = { admin: false };
componentDidMount(){
2018-11-29 16:45:57 +00:00
EmbarkJS.onReady(async (err) => {
2018-12-01 14:31:04 +00:00
getNetworkType().then(async network => {
2018-11-28 16:12:50 +00:00
const { environment } = EmbarkJS
2018-12-01 20:32:00 +00:00
const needsInit = await vaultPledgingNeedsInit();
2018-11-28 16:12:50 +00:00
this.setState({ network, environment })
2018-12-01 20:32:00 +00:00
//methods during testing to help setup
if (environment === 'development') standardTokenApproval()
2018-12-01 14:31:04 +00:00
if (!needsInit) initVaultAndLP(LiquidPledgingMock, LPVault)
2018-11-28 16:12:50 +00:00
});
});
}
render() {
return (
<div>
2018-11-30 11:02:57 +00:00
<AddFunder />
2018-12-01 14:31:04 +00:00
<Divider variant="middle" />
2018-11-30 18:36:09 +00:00
<CreateFunding />
</div>
2018-11-28 16:12:50 +00:00
)
}
}
export default App;