Show unconfirmed balances in toplist #112
+5
-1
@@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
extends: 'recommended'
|
||||
extends: 'recommended',
|
||||
|
||||
rules: {
|
||||
'simple-unless': false
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ import Component from '@ember/component';
|
||||
import { and, notEmpty } from '@ember/object/computed';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
|
||||
export default Component.extend({
|
||||
kredits: service(),
|
||||
|
||||
@@ -14,6 +13,7 @@ export default Component.extend({
|
||||
isValidURL: notEmpty('url'),
|
||||
isValidGithubUID: notEmpty('github_uid'),
|
||||
isValidGithubUsername: notEmpty('github_username'),
|
||||
isValidGiteaUsername: notEmpty('gitea_username'),
|
||||
isValidWikiUsername: notEmpty('wiki_username'),
|
||||
isValid: and(
|
||||
'isValidAccount',
|
||||
@@ -21,10 +21,11 @@ export default Component.extend({
|
||||
'isValidGithubUID'
|
||||
),
|
||||
|
||||
inProgress: false,
|
||||
|
||||
init () {
|
||||
this._super(...arguments);
|
||||
|
||||
// Default attributes used by reset
|
||||
this.set('attributes', {
|
||||
account: null,
|
||||
name: null,
|
||||
@@ -32,8 +33,8 @@ export default Component.extend({
|
||||
url: null,
|
||||
github_username: null,
|
||||
github_uid: null,
|
||||
wiki_username: null,
|
||||
isCore: false
|
||||
gitea_username: null,
|
||||
wiki_username: null
|
||||
});
|
||||
},
|
||||
|
||||
@@ -53,17 +54,19 @@ export default Component.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
let attributes = Object.keys(this.attributes);
|
||||
let contributor = this.getProperties(attributes);
|
||||
let saved = this.save(contributor);
|
||||
const attributes = Object.keys(this.attributes);
|
||||
const contributor = this.getProperties(attributes);
|
||||
|
||||
// The promise handles inProgress
|
||||
this.set('inProgress', saved);
|
||||
this.set('inProgress', true);
|
||||
|
||||
saved.then(() => {
|
||||
this.save(contributor).then(() => {
|
||||
this.reset();
|
||||
window.scroll(0,0);
|
||||
window.alert('Contributor added.');
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
window.alert('Something went wrong. Please check the browser console.');
|
||||
}).finally(() => {
|
||||
this.set('inProgress', false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,4 @@
|
||||
<form {{action "submit" on="submit"}}>
|
||||
<p>
|
||||
{{input name="is-core"
|
||||
type="checkbox"
|
||||
id="is-core"
|
||||
checked=isCore}}
|
||||
<label for="is-core" class="checkbox">
|
||||
Core team member (can add contributors)
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
{{input name="account"
|
||||
type="text"
|
||||
@@ -49,6 +40,13 @@
|
||||
value=github_username
|
||||
class=(if isValidGithubUsername "valid" "")}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="gitea_username"
|
||||
type="text"
|
||||
placeholder="Gitea username"
|
||||
value=gitea_username
|
||||
class=(if isValidGiteaUsername "valid" "")}}
|
||||
</p>
|
||||
<p>
|
||||
{{input name="wiki_username"
|
||||
type="text"
|
||||
@@ -58,7 +56,7 @@
|
||||
</p>
|
||||
<p class="actions">
|
||||
{{input type="submit"
|
||||
disabled=(is-pending inProgress)
|
||||
value=(if (is-pending inProgress) "Processing" "Save")}}
|
||||
disabled=inProgress
|
||||
value=(if inProgress "Processing" "Save")}}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -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}} {{if contribution.vetoed "vetoed"}}">
|
||||
<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}}
|
||||
@@ -19,7 +19,7 @@
|
||||
<td colspan="2">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://testnet.etherscan.io/address/{{c.contributor.account}}" target="_blank" rel="noopener">Inspect Ethereum transactions</a>
|
||||
<a href="https://rinkeby.etherscan.io/address/{{c.contributor.account}}" target="_blank" rel="noopener">Inspect Ethereum transactions</a>
|
||||
</li>
|
||||
{{#if c.contributor.ipfsHash}}
|
||||
<li>
|
||||
|
||||
@@ -27,21 +27,21 @@ 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 => {
|
||||
console.debug('[controllers:index] Veto submitted to Ethereum blockhain: '+transaction.hash);
|
||||
});
|
||||
},
|
||||
|
||||
confirmProposal (proposalId) {
|
||||
this.kredits.vote(proposalId).then(transaction => {
|
||||
window.confirm('Vote submitted to Ethereum blockhain: '+transaction.hash);
|
||||
console.debug('[controllers:index] Vote submitted to Ethereum blockhain: '+transaction.hash);
|
||||
});
|
||||
},
|
||||
|
||||
save (contributor) {
|
||||
return this.kredits.addContributor(contributor)
|
||||
.then((contributor) => {
|
||||
.then(contributor => {
|
||||
this.contributors.pushObject(contributor);
|
||||
return contributor;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { alias } from '@ember/object/computed';
|
||||
|
||||
export default Helper.extend({
|
||||
|
||||
kredits: service(),
|
||||
currentBlock: alias('kredits.currentBlock'),
|
||||
|
||||
compute([contribution]) {
|
||||
if (contribution.vetoed) {
|
||||
return 'vetoed';
|
||||
} else if (contribution.confirmedAt > this.currentBlock) {
|
||||
return 'unconfirmed';
|
||||
} else {
|
||||
return 'confirmed'
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { alias } from '@ember/object/computed';
|
||||
|
||||
export default Helper.extend({
|
||||
|
||||
kredits: service(),
|
||||
currentBlock: alias('kredits.currentBlock'),
|
||||
|
||||
compute([contribution]) {
|
||||
return !contribution.vetoed &&
|
||||
(contribution.confirmedAt <= this.currentBlock);
|
||||
}
|
||||
|
||||
});
|
||||
+33
-10
@@ -84,9 +84,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();
|
||||
@@ -162,10 +163,15 @@ export default Service.extend({
|
||||
},
|
||||
|
||||
addContributor(attributes) {
|
||||
if (attributes.github_uid) {
|
||||
const uidInt = parseInt(attributes.github_uid);
|
||||
attributes.github_uid = uidInt;
|
||||
}
|
||||
|
||||
console.debug('[kredits] add contributor', attributes);
|
||||
|
||||
return this.kredits.Contributor.add(attributes)
|
||||
.then((data) => {
|
||||
return this.kredits.Contributor.add(attributes, { gasLimit: 350000 })
|
||||
.then(data => {
|
||||
console.debug('[kredits] add contributor response', data);
|
||||
return Contributor.create(attributes);
|
||||
});
|
||||
@@ -215,12 +221,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, { gasLimit: 300000 })
|
||||
.then(data => {
|
||||
console.debug('[kredits] veto response', data);
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
getCurrentUser: computed('kredits.provider', function() {
|
||||
if (isEmpty(this.currentUserAccounts)) {
|
||||
return RSVP.resolve();
|
||||
@@ -241,23 +257,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);
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
button, input[type=submit] {
|
||||
display: inline-block;
|
||||
padding: 0.6rem 2rem;
|
||||
background-color: rgba(22, 21, 40, 0.6);
|
||||
border: 1px solid rgba(22, 21, 40, 1);
|
||||
border-radius: 3px;
|
||||
color: $primary-color;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
letter-spacing: 0.1em;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(22, 21, 40, 0.8);
|
||||
}
|
||||
|
||||
&.small {
|
||||
font-size: 0.8rem;
|
||||
padding: 0.2rem 0.8rem;
|
||||
}
|
||||
|
||||
&.danger {
|
||||
color: $red;
|
||||
background-color: rgba(40, 21, 21, 0.6);
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(40, 21, 21, 0.8);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-16
@@ -87,22 +87,6 @@ section {
|
||||
}
|
||||
}
|
||||
|
||||
button, input[type=submit] {
|
||||
display: inline-block;
|
||||
border: 1px solid rgba(22, 21, 40, 1);
|
||||
background-color: rgba(22, 21, 40, 0.6);
|
||||
color: $primary-color;
|
||||
border-radius: 3px;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
letter-spacing: 0.1em;
|
||||
|
||||
&:hover {
|
||||
background-color: rgba(22, 21, 40, 0.8);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 550px) {
|
||||
section {
|
||||
h2 {
|
||||
@@ -111,6 +95,7 @@ button, input[type=submit] {
|
||||
}
|
||||
}
|
||||
|
||||
@import "buttons";
|
||||
@import "components/topbar";
|
||||
@import "components/loading-spinner";
|
||||
@import "components/contributor-list";
|
||||
|
||||
@@ -13,7 +13,7 @@ ul.contribution-list {
|
||||
|
||||
li {
|
||||
display: grid;
|
||||
grid-template-columns: auto 5rem;
|
||||
grid-template-columns: auto 5rem 5rem;
|
||||
grid-row-gap: 0.5rem;
|
||||
padding: 1rem 1.2rem;
|
||||
background-color: rgba(255,255,255,0.1);
|
||||
@@ -24,6 +24,16 @@ ul.contribution-list {
|
||||
border-top: 1px solid rgba(255,255,255,0.2);
|
||||
}
|
||||
|
||||
&.confirmed {
|
||||
grid-template-columns: auto 5rem;
|
||||
}
|
||||
|
||||
&.vetoed {
|
||||
grid-template-columns: auto 5rem;
|
||||
text-decoration: line-through;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
p {
|
||||
align-self: center;
|
||||
margin: 0;
|
||||
@@ -33,14 +43,6 @@ ul.contribution-list {
|
||||
&.kredits-amount, &.voting {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
&.description {
|
||||
grid-column-start: span 2;
|
||||
}
|
||||
|
||||
&.voting {
|
||||
grid-column-start: span 2;
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
@@ -92,12 +94,6 @@ ul.contribution-list {
|
||||
color: $primary-color;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 2rem;
|
||||
line-height: 2rem;
|
||||
padding: 0 0.6rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,12 +73,6 @@ ul.proposal-list {
|
||||
color: $primary-color;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
button {
|
||||
height: 2rem;
|
||||
line-height: 2rem;
|
||||
padding: 0 0.6rem;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Generated
+6
-6
@@ -10911,9 +10911,9 @@
|
||||
}
|
||||
},
|
||||
"kredits-contracts": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/kredits-contracts/-/kredits-contracts-5.2.0.tgz",
|
||||
"integrity": "sha512-XS8PN01SEiSNDKUhH28KVmGJ7hS3HlhT+CsaAMgqvU9ACcE1Wizqd0AxoRutUmJkILic6W6bQQ5gRqSHcBpPBA==",
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/kredits-contracts/-/kredits-contracts-5.3.0.tgz",
|
||||
"integrity": "sha512-Wz4zuA6yo0Q4WbVEO61fvFin+6VTNjkBqHPhHCqq6dIoGdFSjUZ3BCKan1ei0axIAda7ZDP+eebe2vCr+eqcHg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ethers": "^4.0.27",
|
||||
@@ -17139,9 +17139,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"pull-to-stream": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pull-to-stream/-/pull-to-stream-0.1.0.tgz",
|
||||
"integrity": "sha512-LMvdE0JwT7XQZMFjc7JDl/G9gmoZ8Zo8e86SG4ZZUcjuwvod803KxpAK8WrmdxzHsMRK9DETlIzuA0tbEVv6jg==",
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pull-to-stream/-/pull-to-stream-0.1.1.tgz",
|
||||
"integrity": "sha512-thZkMv6F9PILt9zdvpI2gxs19mkDrlixYKX6cOBxAW16i1NZH+yLAmF4r8QfJ69zuQh27e01JZP9y27tsH021w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"readable-stream": "^3.1.1"
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@
|
||||
"eslint-plugin-ember": "^5.2.0",
|
||||
"ethers": "^4.0.27",
|
||||
"kosmos-schemas": "^2.0.0",
|
||||
"kredits-contracts": "^5.2.0",
|
||||
"kredits-contracts": "^5.3.0",
|
||||
"loader.js": "^4.7.0",
|
||||
"qunit-dom": "^0.8.0",
|
||||
"tv4": "^1.3.0"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Helper | contribution-status', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('returns the appropriate status', function (assert) {
|
||||
const contributionStatus = this.owner.factoryFor('helper:contribution-status').create();
|
||||
const kredits = this.owner.lookup('service:kredits');
|
||||
|
||||
kredits.set('currentBlock', 23000);
|
||||
|
||||
const contributionUnconfirmed = { confirmedAt: 23001, vetoed: false };
|
||||
const contributionConfirmed = { confirmedAt: 21000, vetoed: false };
|
||||
const contributionVetoed = { confirmedAt: 23001, vetoed: true };
|
||||
|
||||
assert.eq(contributionStatus.compute([contributionUnconfirmed]), 'unconfirmed');
|
||||
assert.eq(contributionStatus.compute([contributionConfirmed]), 'confirmed');
|
||||
assert.eq(contributionStatus.compute([contributionVetoed]), 'vetoed');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Helper | contribution-status', function (hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('returns the appropriate status', function (assert) {
|
||||
const contributionStatus = this.owner.factoryFor('helper:contribution-status').create();
|
||||
const kredits = this.owner.lookup('service:kredits');
|
||||
|
||||
kredits.set('currentBlock', 23000);
|
||||
|
||||
const contributionUnconfirmed = { confirmedAt: 23001, vetoed: false };
|
||||
const contributionConfirmed = { confirmedAt: 21000, vetoed: false };
|
||||
const contributionVetoed = { confirmedAt: 23001, vetoed: true };
|
||||
|
||||
assert.notOk(contributionStatus.compute([contributionUnconfirmed]), 'unconfirmed');
|
||||
assert.notOk(contributionStatus.compute([contributionVetoed]), 'vetoed');
|
||||
assert.ok(contributionStatus.compute([contributionConfirmed]), 'confirmed');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user