2018-11-29 20:52:24 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { Formik } from 'formik';
|
|
|
|
import EmbarkJS from 'Embark/EmbarkJS';
|
|
|
|
import LPVault from 'Embark/contracts/LPVault';
|
|
|
|
import LiquidPledgingMock from 'Embark/contracts/LiquidPledgingMock';
|
|
|
|
import Button from '@material-ui/core/Button';
|
|
|
|
import TextField from '@material-ui/core/TextField';
|
|
|
|
import web3 from "Embark/web3";
|
|
|
|
|
|
|
|
const { addGiver, numberOfPledgeAdmins, getPledgeAdmin } = LiquidPledgingMock.methods;
|
|
|
|
const hoursToSeconds = hours => hours * 60 * 60;
|
|
|
|
|
2018-11-30 11:02:57 +00:00
|
|
|
const AddFunder = () => (
|
2018-11-29 20:52:24 +00:00
|
|
|
<Formik
|
2018-11-30 11:02:57 +00:00
|
|
|
initialValues={{ funderName: '', funderProfile: '', commitTime : '' }}
|
2018-11-29 20:52:24 +00:00
|
|
|
onSubmit={async (values, { setSubmitting, resetForm }) => {
|
2018-11-30 11:02:57 +00:00
|
|
|
const { funderName, funderProfile, commitTime } = values;
|
2018-11-29 20:52:24 +00:00
|
|
|
const account = await web3.eth.getCoinbase();
|
2018-11-30 11:02:57 +00:00
|
|
|
const args = [funderName, funderProfile, commitTime, 0];
|
2018-11-29 20:52:24 +00:00
|
|
|
addGiver(...args)
|
|
|
|
.estimateGas({ from: account })
|
|
|
|
.then(async gas => {
|
|
|
|
addGiver(...args)
|
|
|
|
.send({ from: account, gas: gas + 100 })
|
|
|
|
.then(res => { console.log({res}) })
|
|
|
|
.catch(e => { console.log({e}) })
|
|
|
|
})
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{({
|
|
|
|
values,
|
|
|
|
errors,
|
|
|
|
touched,
|
|
|
|
handleChange,
|
|
|
|
handleBlur,
|
|
|
|
handleSubmit,
|
|
|
|
setFieldValue
|
|
|
|
}) => (
|
|
|
|
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
|
<TextField
|
2018-11-30 11:02:57 +00:00
|
|
|
id="funderName"
|
|
|
|
name="funderName"
|
|
|
|
label="Funder Name"
|
|
|
|
placeholder="Funder Name"
|
2018-11-29 20:52:24 +00:00
|
|
|
margin="normal"
|
|
|
|
variant="outlined"
|
|
|
|
onChange={handleChange}
|
|
|
|
onBlur={handleBlur}
|
2018-11-30 11:02:57 +00:00
|
|
|
value={values.funderName || ''}
|
2018-11-29 20:52:24 +00:00
|
|
|
/>
|
|
|
|
<TextField
|
2018-11-30 11:02:57 +00:00
|
|
|
id="funderProfile"
|
|
|
|
name="funderProfile"
|
|
|
|
label="Funder Profile URL or IPFS Hash"
|
|
|
|
placeholder="Funder Profile URL or IPFS Hash"
|
2018-11-29 20:52:24 +00:00
|
|
|
margin="normal"
|
|
|
|
variant="outlined"
|
|
|
|
onChange={handleChange}
|
|
|
|
onBlur={handleBlur}
|
2018-11-30 11:02:57 +00:00
|
|
|
value={values.funderProfile || ''}
|
2018-11-29 20:52:24 +00:00
|
|
|
/>
|
|
|
|
<TextField
|
|
|
|
id="commitTime"
|
|
|
|
name="commitTime"
|
|
|
|
label="Commit time in hours"
|
|
|
|
placeholder="Commit time in hours"
|
|
|
|
margin="normal"
|
|
|
|
variant="outlined"
|
2018-11-30 11:02:57 +00:00
|
|
|
helperText="The length of time in hours the Funder has to veto when the delegates pledge funds to a project"
|
2018-11-29 20:52:24 +00:00
|
|
|
onChange={handleChange}
|
|
|
|
onBlur={handleBlur}
|
|
|
|
value={values.commitTime || ''}
|
|
|
|
/>
|
|
|
|
<Button variant="contained" color="primary" type="submit">
|
2018-11-30 11:02:57 +00:00
|
|
|
ADD FUNDER
|
2018-11-29 20:52:24 +00:00
|
|
|
</Button>
|
|
|
|
</form>
|
|
|
|
)}
|
|
|
|
</Formik>
|
|
|
|
)
|
|
|
|
|
2018-11-30 11:02:57 +00:00
|
|
|
export default AddFunder;
|