Merge branch '000-snt-voting-dapp' of https://github.com/status-im/contracts into 000-snt-voting-dapp

This commit is contained in:
Barry Gitarts 2018-06-27 15:09:20 -04:00
commit e17870ab17
1 changed files with 12 additions and 7 deletions

View File

@ -92,8 +92,10 @@ const InnerForm = ({
const StyledForm = withStyles(styles)(InnerForm);
const AddPoll = withFormik({
mapPropsToValues: props => ({ description: ''}),
validate(values){
validate(values, props){
const errors = {};
const { description } = values;
if(description.toString().trim() === "") errors.description = true;
return errors;
},
async handleSubmit(values, { setSubmitting }) {
@ -102,17 +104,20 @@ const AddPoll = withFormik({
const { addPoll } = PollManager.methods;
const currentBlock = await getBlockNumber();
const endTime = currentBlock + (oneDayinBlocks * 90);
addPoll(
endTime,
singleChoiceDef(description, ['YES', 'NO'])
)
.send()
const toSend = addPoll(endTime, singleChoiceDef(description, ['YES']));
toSend.estimateGas()
.then(gasEstimated => {
console.log("addPoll gas estimated: "+gasEstimated);
return toSend.send({gas: gasEstimated + 1000});
})
.then(res => {
console.log('sucess:', res);
})
.catch(res => {
console.log('fail:', res);
})
});
}
})(StyledForm)