add rlp encoding for new proposal

This commit is contained in:
Barry Gitarts 2018-06-26 17:40:27 -04:00
parent 0f0c7261c4
commit 0d75175db3
1 changed files with 17 additions and 1 deletions

View File

@ -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 => {