From c47908a454161a8b2dcc3108f115f6fa9280a770 Mon Sep 17 00:00:00 2001 From: Barry Gitarts Date: Tue, 17 Jul 2018 12:02:17 -0400 Subject: [PATCH] fix premature 50 block no confirm error add full refresh due to new off by one error --- app/components/simple-voting/PollsList.js | 3 ++- app/dapp.js | 7 +++++-- embark.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/components/simple-voting/PollsList.js b/app/components/simple-voting/PollsList.js index fe2b2c0..a26c4cc 100644 --- a/app/components/simple-voting/PollsList.js +++ b/app/components/simple-voting/PollsList.js @@ -1,4 +1,5 @@ import React, { Fragment, PureComponent } from 'react'; +import { toString } from 'lodash'; import AppBar from '@material-ui/core/AppBar'; import Toolbar from '@material-ui/core/Toolbar'; import Card from '@material-ui/core/Card'; @@ -79,7 +80,7 @@ class Poll extends PureComponent { const { value } = this.state; const { toWei } = web3.utils; - const balance4Voting = toWei(value * value); + const balance4Voting = toWei(toString(value * value)); const toSend = balance4Voting == 0 ? unvote(idPoll) : customVote(idPoll, balance4Voting); toSend.estimateGas() diff --git a/app/dapp.js b/app/dapp.js index 66914e2..fa9d499 100644 --- a/app/dapp.js +++ b/app/dapp.js @@ -57,11 +57,14 @@ class App extends React.Component { } updatePoll = async (idPoll) => { - const { poll } = PollManager.methods; + const { poll, nPolls } = PollManager.methods; const { rawPolls } = this.state; + const npolls = await nPolls().call(); + // This check needs to be done because of a bug in web3 + if (npolls !== rawPolls.length) return this._getPolls(); const newPolls = [...rawPolls]; const updatedPoll = await poll(idPoll).call(); - newPolls[idPoll] = updatedPoll; + newPolls[idPoll] = { ...updatedPoll }; this.setState({ rawPolls: newPolls }); } diff --git a/embark.json b/embark.json index 1c8404f..dbe7f91 100644 --- a/embark.json +++ b/embark.json @@ -10,7 +10,7 @@ "buildDir": "dist/", "config": "config/", "versions": { - "web3": "1.0.0-beta", + "web3": "1.0.0-beta.34", "solc": "0.4.24", "ipfs-api": "17.2.4" },