Merge pull request #145 from varasev/fix-123

(Fix) Checking transaction status when voting or finalizing
This commit is contained in:
Victor Baranov 2018-07-04 14:04:21 +03:00 committed by GitHub
commit 66a86aac19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 10 deletions

View File

@ -181,11 +181,16 @@ export class BallotCard extends React.Component {
return;
}
this.getContract(contractsStore, votingType).vote(id, choice, contractsStore.votingKey)
.on("receipt", () => {
.on("receipt", (tx) => {
commonStore.hideLoading();
swal("Congratulations!", messages.VOTED_SUCCESS_MSG, "success").then((result) => {
push(`${commonStore.rootPath}`);
});
if (tx.status === true || tx.status === '0x1') {
swal("Congratulations!", messages.VOTED_SUCCESS_MSG, "success").then((result) => {
push(`${commonStore.rootPath}`);
});
} else {
swal("Warning!", messages.VOTE_FAILED_TX, "warning").then((result) => {
});
}
})
.on("error", (e) => {
commonStore.hideLoading();
@ -225,11 +230,16 @@ export class BallotCard extends React.Component {
return;
}
this.getContract(contractsStore, votingType).finalize(id, contractsStore.votingKey)
.on("receipt", () => {
.on("receipt", (tx) => {
commonStore.hideLoading();
swal("Congratulations!", messages.FINALIZED_SUCCESS_MSG, "success").then((result) => {
push(`${commonStore.rootPath}`);
});
if (tx.status === true || tx.status === '0x1') {
swal("Congratulations!", messages.FINALIZED_SUCCESS_MSG, "success").then((result) => {
push(`${commonStore.rootPath}`);
});
} else {
swal("Warning!", messages.FINALIZE_FAILED_TX, "warning").then((result) => {
});
}
})
.on("error", (e) => {
commonStore.hideLoading();

View File

@ -231,7 +231,7 @@ export class NewBallot extends React.Component {
push(`${commonStore.rootPath}`);
});
} else {
swal("Warning!", messages.FAILED_TX, "warning").then((result) => {
swal("Warning!", messages.BALLOT_CREATE_FAILED_TX, "warning").then((result) => {
});
}
})

View File

@ -30,8 +30,12 @@ messages.SHOULD_BE_MORE_THAN_MIN_DURATION = (minDuration, duration, neededHours,
messages.SHOULD_BE_LESS_OR_EQUAL_14_DAYS = (duration) => {
return `Ballot end time should not be more than 14 days from now in UTC time. Current duration is ${duration} hours.`;
}
messages.FAILED_TX = `Your transaction was failed. Please make sure you set correct parameters for ballot creation.
messages.BALLOT_CREATE_FAILED_TX = `Your transaction was failed. Please make sure you set correct parameters for ballot creation.
Make sure you don't have Transaction Error. Exception thrown in contract code message in metamask before you sign it.`
messages.VOTE_FAILED_TX = `Your transaction was failed. Please make sure you haven't already voted for this ballot.
Make sure you don't have Transaction Error. Exception thrown in contract code message in metamask before you sign it.`
messages.FINALIZE_FAILED_TX = `Your transaction was failed. Make sure you don't have Transaction Error.
Exception thrown in contract code message in metamask before you sign it.`
messages.DESCRIPTION_IS_EMPTY = "Description cannot be empty";
messages.wrongRepo = (repo) => {
return `There is no contracts.json in configured repo ${repo}`;