Veto contributions

This commit is contained in:
2019-04-28 14:41:16 +01:00
parent c6a37f7e94
commit 9821c8b2ea
6 changed files with 54 additions and 35 deletions
+11 -11
View File
@@ -5,16 +5,16 @@ export default Component.extend({
tagName: 'ul',
classNames: ['contribution-list'],
// actions: {
//
// veto (contributionId) {
// if (this.contractInteractionEnabled) {
// this.vetoContribution(contributionId);
// } else {
// window.alert('Only members can veto contributions. Please ask someone to set you up.');
// }
// }
//
// }
actions: {
veto (contributionId) {
if (this.contractInteractionEnabled) {
this.vetoContribution(contributionId);
} else {
window.alert('Only members can veto contributions. Please ask someone to set you up.');
}
}
}
});
@@ -1,5 +1,5 @@
{{#each contributions as |contribution|}}
<li data-contribution-id={{contribution.id}} class={{if contribution.confirmed "confirmed" "unconfirmed"}}>
<li data-contribution-id={{contribution.id}} class={{contribution-status contribution}}>
<p class="meta">
<span class="recipient">{{user-avatar contributor=contribution.contributor}}</span>
<span class="category {{contribution.kind}}">({{contribution.kind}})</span>
@@ -14,5 +14,12 @@
<p class="kredits-amount">
<span class="amount">{{contribution.amount}}</span><span class="symbol">₭S</span>
</p>
{{#unless contribution.vetoed}}
{{#unless (is-confirmed-contribution contribution)}}
<p class="voting">
<button {{action "veto" contribution.id}} class="small danger">veto</button>
</p>
{{/unless}}
{{/unless}}
</li>
{{/each}}
+4 -4
View File
@@ -33,10 +33,10 @@ export default Controller.extend({
actions: {
vetoContribution (/* contributionId */) {
// this.kredits.vote(proposalId).then(transaction => {
// window.confirm('Vote submitted to Ethereum blockhain: '+transaction.hash);
// });
vetoContribution (contributionId) {
this.kredits.veto(contributionId).then(transaction => {
window.confirm('Veto submitted to Ethereum blockhain: '+transaction.hash);
});
},
confirmProposal (proposalId) {
+13 -2
View File
@@ -52,9 +52,10 @@ export default Service.extend({
});
}
function instantiateWithAccount (web3Provider, context) {
async function instantiateWithAccount (web3Provider, context) {
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
ethProvider = new ethers.providers.Web3Provider(web3Provider);
// const network = await ethProvider.getNetwork();
ethProvider.listAccounts().then(accounts => {
context.set('currentUserAccounts', accounts);
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
@@ -183,12 +184,22 @@ export default Service.extend({
console.debug('[kredits] vote for', proposalId);
return this.kredits.Proposal.functions.vote(proposalId)
.then((data) => {
.then(data => {
console.debug('[kredits] vote response', data);
return data;
});
},
veto(contributionId) {
console.debug('[kredits] veto against', contributionId);
return this.kredits.Contribution.functions.veto(contributionId)
.then(data => {
console.debug('[kredits] veto response', data);
return data;
});
},
getCurrentUser: computed('kredits.provider', function() {
if (isEmpty(this.currentUserAccounts)) {
return RSVP.resolve();
+13 -16
View File
@@ -20,14 +20,6 @@ ul.contribution-list {
font-size: 1.2rem;
border-bottom: 1px solid rgba(255,255,255,0.2);
&.unconfirmed {
grid-template-columns: auto 5rem 5rem;
}
&:first-of-type {
border-top: 1px solid rgba(255,255,255,0.2);
}
p {
align-self: center;
margin: 0;
@@ -37,14 +29,6 @@ ul.contribution-list {
&.kredits-amount, &.voting {
text-align: right;
}
// &.description {
// grid-column-start: span 2;
// }
// &.voting {
// grid-column-start: span 2;
// }
}
span {
@@ -96,6 +80,19 @@ ul.contribution-list {
color: $primary-color;
margin-right: 0.5rem;
}
&:first-of-type {
border-top: 1px solid rgba(255,255,255,0.2);
}
&.unconfirmed {
grid-template-columns: auto 5rem 5rem;
}
&.vetoed {
text-decoration: line-through;
opacity: 0.6;
}
}
}