Mark contributions as vetoed on incoming event

This commit is contained in:
2019-04-28 15:26:26 +01:00
parent 00b7b380b9
commit e1737392a7
4 changed files with 31 additions and 23 deletions
+13 -6
View File
@@ -220,23 +220,30 @@ export default Service.extend({
return this.proposals.findBy('id', proposalId.toString());
},
findContributionById(contributionId) {
return this.contributions.findBy('id', contributionId.toString());
},
// Contract events
addContractEventHandlers() {
// Proposal events
this.kredits.Contribution
.on('ContributionVetoed', this.handleContributionVetoed.bind(this))
this.kredits.Proposal
.on('ProposalCreated', this.handleProposalCreated.bind(this))
.on('ProposalVoted', this.handleProposalVoted.bind(this))
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
// Token events
this.kredits.Token
.on('Transfer', this.handleTransfer.bind(this));
},
handleContributionVetoed(contributionId) {
console.debug('[kredits] ContributionVetoed event received for ', contributionId);
const contribution = this.contributions.findBy('id', contributionId);
console.debug('[kredits] contribution', contribution);
if (contribution) {
contribution.set('vetoed', true);
}
},
handleProposalCreated(proposalId) {
let proposal = this.findProposalById(proposalId);