Rename Kredits to Organization

This commit is contained in:
2018-04-15 22:00:16 +02:00
parent 33d6499dd4
commit 3682e70a72
5 changed files with 22 additions and 24 deletions
+3 -4
View File
@@ -1,7 +1,7 @@
import ethers from 'npm:ethers'; import ethers from 'npm:ethers';
import RSVP from 'rsvp'; import RSVP from 'rsvp';
import Kredits from '../kredits'; import Organization from '../kredits';
import ContributorSerializer from '../serializers/contributor'; import ContributorSerializer from '../serializers/contributor';
import Base from './base'; import Base from './base';
@@ -35,7 +35,7 @@ export default class Contributor extends Base {
}) })
// Fetch IPFS data if available // Fetch IPFS data if available
.then((data) => { .then((data) => {
return Kredits.ipfs.catAndMerge(data, ContributorSerializer.deserialize); return Organization.ipfs.catAndMerge(data, ContributorSerializer.deserialize);
}); });
} }
@@ -43,7 +43,7 @@ export default class Contributor extends Base {
let json = ContributorSerializer.serialize(contributorAttr); let json = ContributorSerializer.serialize(contributorAttr);
// TODO: validate against schema // TODO: validate against schema
return Kredits.ipfs return Organization.ipfs
.add(json) .add(json)
.then((ipfsHashAttr) => { .then((ipfsHashAttr) => {
let contributor = [ let contributor = [
@@ -54,7 +54,6 @@ export default class Contributor extends Base {
contributorAttr.isCore, contributorAttr.isCore,
]; ];
console.log('[kredits] addContributor', ...contributor);
return this.functions.addContributor(...contributor); return this.functions.addContributor(...contributor);
}); });
} }
+3 -4
View File
@@ -1,7 +1,7 @@
import ethers from 'npm:ethers'; import ethers from 'npm:ethers';
import RSVP from 'rsvp'; import RSVP from 'rsvp';
import Kredits from '../kredits'; import Organization from '../kredits';
import ContributionSerializer from '../serializers/contribution'; import ContributionSerializer from '../serializers/contribution';
import Base from './base'; import Base from './base';
@@ -35,7 +35,7 @@ export default class Operator extends Base {
}) })
// Fetch IPFS data if available // Fetch IPFS data if available
.then((data) => { .then((data) => {
return Kredits.ipfs.catAndMerge(data, ContributionSerializer.deserialize); return Organization.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
}); });
} }
@@ -43,7 +43,7 @@ export default class Operator extends Base {
let json = ContributionSerializer.serialize(proposalAttr); let json = ContributionSerializer.serialize(proposalAttr);
// TODO: validate against schema // TODO: validate against schema
return Kredits.ipfs return Organization.ipfs
.add(json) .add(json)
.then((ipfsHashAttr) => { .then((ipfsHashAttr) => {
let proposal = [ let proposal = [
@@ -54,7 +54,6 @@ export default class Operator extends Base {
ipfsHashAttr.hashSize, ipfsHashAttr.hashSize,
]; ];
console.log('[kredits] addProposal', ...proposal);
return this.functions.addProposal(...proposal); return this.functions.addProposal(...proposal);
}); });
} }
+1 -1
View File
@@ -1 +1 @@
export { default } from './kredits'; export { default } from './organization';
@@ -13,7 +13,7 @@ function capitalize(word) {
return `${first.toUpperCase()}${rest.join('')}`; return `${first.toUpperCase()}${rest.join('')}`;
} }
export default class Kredits { export default class Organization {
constructor(provider, signer, addresses) { constructor(provider, signer, addresses) {
this.provider = provider; this.provider = provider;
this.signer = signer; this.signer = signer;
@@ -45,7 +45,7 @@ export default class Kredits {
return RSVP.hash(addresses) return RSVP.hash(addresses)
.then((addresses) => { .then((addresses) => {
return new Kredits(provider, signer, addresses); return new Organization(provider, signer, addresses);
}); });
}); });
} }
+13 -13
View File
@@ -61,7 +61,7 @@ export default Service.extend({
return this.initEthProvider().then((ethProvider) => { return this.initEthProvider().then((ethProvider) => {
let signer = ethProvider.getSigner(); let signer = ethProvider.getSigner();
return Kredits.setup(ethProvider, signer, config.ipfs).then((kredits) => { return Kredits.setup(ethProvider, signer, config.ipfs).then((kredits) => {
this.set('kredits', kredits); this.set('organization', organization);
// TODO: Cleanup // TODO: Cleanup
if (this.get('currentUserAccounts').length > 0) { if (this.get('currentUserAccounts').length > 0) {
@@ -69,13 +69,13 @@ export default Service.extend({
this.set('currentUser', contributorData); this.set('currentUser', contributorData);
}); });
} }
return kredits; return organization;
}); });
}); });
}, },
totalSupply: computed(function() { totalSupply: computed(function() {
return this.get('kredits').Token.functions.totalSupply(); return this.get('organization').Token.functions.totalSupply();
}), }),
contributors: [], contributors: [],
@@ -103,7 +103,7 @@ export default Service.extend({
addContributor(attributes) { addContributor(attributes) {
debug('[kredits] add contributor', attributes); debug('[kredits] add contributor', attributes);
return this.get('kredits').Contributor.add(attributes) return this.get('organization').Contributor.add(attributes)
.then((data) => { .then((data) => {
debug('[kredits] add contributor response', data); debug('[kredits] add contributor response', data);
return this.buildModel('contributor', attributes); return this.buildModel('contributor', attributes);
@@ -111,7 +111,7 @@ export default Service.extend({
}, },
getContributors() { getContributors() {
return this.get('kredits').Contributor.all() return this.get('organization').Contributor.all()
.then((contributors) => { .then((contributors) => {
return contributors.map((contributor) => { return contributors.map((contributor) => {
return this.buildModel('contributor', contributor); return this.buildModel('contributor', contributor);
@@ -122,7 +122,7 @@ export default Service.extend({
addProposal(attributes) { addProposal(attributes) {
debug('[kredits] add proposal', attributes); debug('[kredits] add proposal', attributes);
return this.get('kredits').Operator.addProposal(attributes) return this.get('organization').Operator.addProposal(attributes)
.then((data) => { .then((data) => {
debug('[kredits] add proposal response', data); debug('[kredits] add proposal response', data);
return this.buildModel('proposal', attributes); return this.buildModel('proposal', attributes);
@@ -130,7 +130,7 @@ export default Service.extend({
}, },
getProposals() { getProposals() {
return this.get('kredits').Operator.all() return this.get('organization').Operator.all()
.then((proposals) => { .then((proposals) => {
return proposals.map((proposal) => { return proposals.map((proposal) => {
return this.buildModel('proposal', proposal); return this.buildModel('proposal', proposal);
@@ -141,7 +141,7 @@ export default Service.extend({
vote(proposalId) { vote(proposalId) {
debug('[kredits] vote for', proposalId); debug('[kredits] vote for', proposalId);
return this.get('kredits').Operator.functions.vote(proposalId) return this.get('organization').Operator.functions.vote(proposalId)
.then((data) => { .then((data) => {
debug('[kredits] vote response', data); debug('[kredits] vote response', data);
return data; return data;
@@ -153,7 +153,7 @@ export default Service.extend({
if (isEmpty(this.get('currentUserAccounts'))) { if (isEmpty(this.get('currentUserAccounts'))) {
return RSVP.resolve(); return RSVP.resolve();
} }
return this.get('kredits').Contributor return this.get('organization').Contributor
.functions.getContributorIdByAddress(this.get('currentUserAccounts.firstObject')) .functions.getContributorIdByAddress(this.get('currentUserAccounts.firstObject'))
.then((id) => { .then((id) => {
id = id.toNumber(); id = id.toNumber();
@@ -161,7 +161,7 @@ export default Service.extend({
if (id === 0) { if (id === 0) {
return RSVP.resolve(); return RSVP.resolve();
} else { } else {
return this.get('kredits').Contributor.getById(id); return this.get('organization').Contributor.getById(id);
} }
}); });
}), }),
@@ -173,13 +173,13 @@ export default Service.extend({
// Contract events // Contract events
addContractEventHandlers() { addContractEventHandlers() {
// Operator events // Operator events
this.get('kredits').Operator this.get('organization').Operator
.on('ProposalCreated', this.handleProposalCreated.bind(this)) .on('ProposalCreated', this.handleProposalCreated.bind(this))
.on('ProposalVoted', this.handleProposalVoted.bind(this)) .on('ProposalVoted', this.handleProposalVoted.bind(this))
.on('ProposalExecuted', this.handleProposalExecuted.bind(this)); .on('ProposalExecuted', this.handleProposalExecuted.bind(this));
// Token events // Token events
this.get('kredits').Token this.get('organization').Token
.on('Transfer', this.handleTransfer.bind(this)); .on('Transfer', this.handleTransfer.bind(this));
}, },
@@ -191,7 +191,7 @@ export default Service.extend({
return; return;
} }
this.get('kredits').Operator.getById(proposalId) this.get('organization').Operator.getById(proposalId)
.then((proposal) => { .then((proposal) => {
proposal = this.buildModel('proposal', proposal); proposal = this.buildModel('proposal', proposal);
this.get('proposals').pushObject(proposal); this.get('proposals').pushObject(proposal);