diff --git a/app/components/simple-voting/AddPoll.js b/app/components/simple-voting/AddPoll.js index 5200111..2f49e80 100644 --- a/app/components/simple-voting/AddPoll.js +++ b/app/components/simple-voting/AddPoll.js @@ -5,11 +5,27 @@ import CardContent from '@material-ui/core/CardContent'; import PollManager from 'Embark/contracts/PollManager'; import TextField from '@material-ui/core/TextField'; import Button from '@material-ui/core/Button'; +import { map } from 'lodash'; +import rlp from 'rlp'; import { withStyles } from '@material-ui/core/styles'; import { withFormik } from 'formik'; const oneDayinBlocks = 5760; +const singleChoiceDef = (question, options) => { + const d = [ + new Buffer(question), + map(options, function(o) { + return new Buffer(o); + }) + ]; + + const b = rlp.encode(d); + const rlpDefinition = '0x' + b.toString('hex'); + + return rlpDefinition; +} + const styles = theme => ({ button: { margin: theme.spacing.unit, @@ -74,7 +90,7 @@ const AddPoll = withFormik({ const endTime = currentBlock + (oneDayinBlocks * 90); addPoll( endTime, - asciiToHex(description) + singleChoiceDef(description, ['YES', 'NO']) ) .send() .then(res => {