From 0d75175db32a6d26c2dede52cebdd3fc4f025f11 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Tue, 26 Jun 2018 17:40:27 -0400 Subject: [PATCH] add rlp encoding for new proposal --- app/components/simple-voting/AddPoll.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 => {