mirror of
https://github.com/status-im/snt-voting.git
synced 2025-02-23 15:48:10 +00:00
Transaction info by poll
This commit is contained in:
parent
2302945203
commit
be5f68da30
@ -26,8 +26,8 @@ class Voting extends PureComponent {
|
||||
addPoll: false,
|
||||
pollTokenBalances: [],
|
||||
votes: [],
|
||||
transaction: null,
|
||||
transactionHash: ''
|
||||
transaction: {},
|
||||
transactionHash: {}
|
||||
};
|
||||
|
||||
updatePollBalance = (pollId, tokenBalance, ethBalance, votes) => {
|
||||
@ -40,12 +40,17 @@ class Voting extends PureComponent {
|
||||
this.setState({votes});
|
||||
}
|
||||
|
||||
setTransactionHash = (transactionHash) => {
|
||||
this.setState({transactionHash});
|
||||
setTransactionHash = (idPoll, transactionHash) => {
|
||||
const stHash = this.state.transactionHash;
|
||||
stHash[idPoll] = transactionHash;
|
||||
|
||||
this.setState({transactionHash: stHash[idPoll]});
|
||||
}
|
||||
|
||||
setTransactionPromise = (transaction) => {
|
||||
this.setState({transaction});
|
||||
setTransactionPromise = (idPoll, transaction) => {
|
||||
const sTrx = this.state.transaction;
|
||||
sTrx[idPoll] = transaction;
|
||||
this.setState({transaction: sTrx});
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,13 +129,13 @@ class LandingPage extends Component {
|
||||
<h2 className="pollTypeTitle">Closed Polls</h2>
|
||||
<Card className="card poll">
|
||||
<CardContent>
|
||||
<Typography gutterBottom component="h2">{openPoll.content.title}</Typography>
|
||||
<Typography gutterBottom component="h2">{closedPoll.content.title}</Typography>
|
||||
<p className="stats">
|
||||
Voters: {openPoll._voters}<br />
|
||||
Total votes: {openPoll._votesSum}<br />
|
||||
Total SNT: {openPoll._tokenSum}<br />
|
||||
Voters: {closedPoll._voters}<br />
|
||||
Total votes: {closedPoll._votesSum}<br />
|
||||
Total SNT: {closedPoll._tokenSum}<br />
|
||||
</p>
|
||||
<Link to={"/results/" + openPoll.idPoll} className="arrowRightLink">See results</Link>
|
||||
<Link to={"/results/" + closedPoll.idPoll} className="arrowRightLink">See results</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<div style={{textAlign: "center", marginTop: "35px"}}>
|
||||
|
@ -53,8 +53,8 @@ class Results extends Component {
|
||||
this.setState({netId});
|
||||
});
|
||||
|
||||
if(transaction){
|
||||
transaction.catch(x => {
|
||||
if(transaction[idPoll]){
|
||||
transaction[idPoll].catch(x => {
|
||||
this.setState({isError: true});
|
||||
}).then(() => {
|
||||
this.updatePoll();
|
||||
@ -62,10 +62,10 @@ class Results extends Component {
|
||||
|
||||
let req = false;
|
||||
let interval = setInterval(async () => {
|
||||
if(req || !transactionHash) return;
|
||||
if(req || !transactionHash[idPoll]) return;
|
||||
|
||||
req = true;
|
||||
const receipt = await web3.eth.getTransactionReceipt(transactionHash);
|
||||
const receipt = await web3.eth.getTransactionReceipt(transactionHash[idPoll]);
|
||||
if(receipt){
|
||||
clearInterval(interval);
|
||||
|
||||
@ -110,7 +110,7 @@ class Results extends Component {
|
||||
</Link>
|
||||
</div> }
|
||||
|
||||
{ !isError && transaction && <div className="transactionArea">
|
||||
{ !isError && transaction[idPoll] && <div className="transactionArea">
|
||||
{ isPending && <div className="pending">
|
||||
<div className="spinner">
|
||||
<div className="bounce1"></div>
|
||||
@ -121,12 +121,12 @@ class Results extends Component {
|
||||
<Typography variant="body1">Your vote is in the process of being confirmed in the blockchain</Typography>
|
||||
</div>
|
||||
}
|
||||
{ !isPending && transaction && <div className="confirmed">
|
||||
{ !isPending && transaction[idPoll] && <div className="confirmed">
|
||||
<img src="images/confirmed.svg" width="40" />
|
||||
<Typography variant="headline">Transaction confirmed!<br />
|
||||
Your vote was posted.</Typography>
|
||||
</div>}
|
||||
{ transactionHash && etherscanURL && <Typography variant="body1"><a target="_blank" href={ etherscanURL + transactionHash}>View details on Etherscan</a></Typography> }
|
||||
{ transactionHash[idPoll] && etherscanURL && <Typography variant="body1"><a target="_blank" href={ etherscanURL + transactionHash[idPoll]}>View details on Etherscan</a></Typography> }
|
||||
</div>
|
||||
}
|
||||
<div className="section">
|
||||
|
@ -45,8 +45,8 @@ class ReviewVotes extends Component {
|
||||
const transaction = toSend.send({gas: gasEstimated + 100000});
|
||||
|
||||
transaction.on('transactionHash', hash => {
|
||||
this.props.setTransactionHash(hash);
|
||||
this.props.setTransactionPromise(transaction);
|
||||
this.props.setTransactionHash(idPoll, hash);
|
||||
this.props.setTransactionPromise(idPoll, transaction);
|
||||
history.push('/results/' + idPoll);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user