From cd8071a32cf756d2c285f408d7e48fc504e3a969 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Wed, 5 Dec 2018 19:10:40 -0400 Subject: [PATCH] Fixing voting --- app/components/Voting.js | 2 +- app/components/flow/Results.js | 21 ++++++++++++--------- app/dapp.js | 6 +++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/components/Voting.js b/app/components/Voting.js index 96507c6..e8aa8b8 100644 --- a/app/components/Voting.js +++ b/app/components/Voting.js @@ -57,7 +57,7 @@ class Voting extends PureComponent { const stHash = this.state.transactionHash; stHash[idPoll] = transactionHash; - this.setState({transactionHash: stHash[idPoll]}); + this.setState({transactionHash: stHash}); } setTransactionPromise = (idPoll, transaction) => { diff --git a/app/components/flow/Results.js b/app/components/flow/Results.js index a8199c4..da73775 100644 --- a/app/components/flow/Results.js +++ b/app/components/flow/Results.js @@ -65,16 +65,19 @@ class Results extends Component { if(req || !transactionHash[idPoll]) return; req = true; - const receipt = await web3.eth.getTransactionReceipt(transactionHash[idPoll]); - if(receipt){ - clearInterval(interval); - - if(receipt.status || receipt.status == "0x1"){ - this.setState({isPending: false}); - this.updatePoll(); - } else { - this.setState({isError: true}); + try { + const receipt = await web3.eth.getTransactionReceipt(transactionHash[idPoll]); + if(receipt){ + clearInterval(interval); + + if(receipt.status || receipt.status == "0x1"){ + this.setState({isPending: false}); + this.updatePoll(); + } else { + this.setState({isError: true}); + } } + } catch(e){ } req = false; }, 100); diff --git a/app/dapp.js b/app/dapp.js index c4b84ed..fa7b80f 100644 --- a/app/dapp.js +++ b/app/dapp.js @@ -44,15 +44,15 @@ class App extends React.Component { web3.eth.defaultAccount = "0x0000000000000000000000000000000000000000"; } - DappToken.methods.symbol().call().then(symbol => { + DappToken.methods.symbol().call({from: web3.eth.defaultAccount}).then(symbol => { this.setState({symbol}); }); - DappToken.methods.decimals().call().then(decimals => { + DappToken.methods.decimals().call({from: web3.eth.defaultAccount}).then(decimals => { this.setState({decimals}); }); - DappToken.methods.name().call().then(name => { + DappToken.methods.name().call({from: web3.eth.defaultAccount}).then(name => { this.setState({name}); })