Rename Kredits to Organization #52

Closed
fsmanuel wants to merge 3 commits from refactor/rename-kredits-to-organization into master
5 changed files with 22 additions and 24 deletions
Showing only changes of commit 3682e70a72 - Show all commits
+3 -4
View File
@@ -1,7 +1,7 @@
import ethers from 'npm:ethers';
import RSVP from 'rsvp';
import Kredits from '../kredits';
import Organization from '../kredits';
import ContributorSerializer from '../serializers/contributor';
import Base from './base';
@@ -35,7 +35,7 @@ export default class Contributor extends Base {
})
// Fetch IPFS data if available
.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);
// TODO: validate against schema
return Kredits.ipfs
return Organization.ipfs
.add(json)
.then((ipfsHashAttr) => {
let contributor = [
@@ -54,7 +54,6 @@ export default class Contributor extends Base {
contributorAttr.isCore,
];
console.log('[kredits] addContributor', ...contributor);
return this.functions.addContributor(...contributor);
});
}
+3 -4
View File
@@ -1,7 +1,7 @@
import ethers from 'npm:ethers';
import RSVP from 'rsvp';
import Kredits from '../kredits';
import Organization from '../kredits';
import ContributionSerializer from '../serializers/contribution';
import Base from './base';
@@ -35,7 +35,7 @@ export default class Operator extends Base {
})
// Fetch IPFS data if available
.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);
// TODO: validate against schema
return Kredits.ipfs
return Organization.ipfs
.add(json)
.then((ipfsHashAttr) => {
let proposal = [
@@ -54,7 +54,6 @@ export default class Operator extends Base {
ipfsHashAttr.hashSize,
];
console.log('[kredits] 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('')}`;
}
export default class Kredits {
export default class Organization {
constructor(provider, signer, addresses) {
this.provider = provider;
this.signer = signer;
@@ -45,7 +45,7 @@ export default class Kredits {
return RSVP.hash(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) => {
let signer = ethProvider.getSigner();
return Kredits.setup(ethProvider, signer, config.ipfs).then((kredits) => {
this.set('kredits', kredits);
this.set('organization', organization);
// TODO: Cleanup
if (this.get('currentUserAccounts').length > 0) {
@@ -69,13 +69,13 @@ export default Service.extend({
this.set('currentUser', contributorData);
});
}
return kredits;
return organization;
});
});
},
totalSupply: computed(function() {
return this.get('kredits').Token.functions.totalSupply();
return this.get('organization').Token.functions.totalSupply();
}),
contributors: [],
@@ -103,7 +103,7 @@ export default Service.extend({
addContributor(attributes) {
debug('[kredits] add contributor', attributes);
return this.get('kredits').Contributor.add(attributes)
return this.get('organization').Contributor.add(attributes)
.then((data) => {
debug('[kredits] add contributor response', data);
return this.buildModel('contributor', attributes);
@@ -111,7 +111,7 @@ export default Service.extend({
},
getContributors() {
return this.get('kredits').Contributor.all()
return this.get('organization').Contributor.all()
.then((contributors) => {
return contributors.map((contributor) => {
return this.buildModel('contributor', contributor);
@@ -122,7 +122,7 @@ export default Service.extend({
addProposal(attributes) {
debug('[kredits] add proposal', attributes);
return this.get('kredits').Operator.addProposal(attributes)
return this.get('organization').Operator.addProposal(attributes)
.then((data) => {
debug('[kredits] add proposal response', data);
return this.buildModel('proposal', attributes);
@@ -130,7 +130,7 @@ export default Service.extend({
},
getProposals() {
return this.get('kredits').Operator.all()
return this.get('organization').Operator.all()
.then((proposals) => {
return proposals.map((proposal) => {
return this.buildModel('proposal', proposal);
@@ -141,7 +141,7 @@ export default Service.extend({
vote(proposalId) {
debug('[kredits] vote for', proposalId);
return this.get('kredits').Operator.functions.vote(proposalId)
return this.get('organization').Operator.functions.vote(proposalId)
.then((data) => {
debug('[kredits] vote response', data);
return data;
@@ -153,7 +153,7 @@ export default Service.extend({
if (isEmpty(this.get('currentUserAccounts'))) {
return RSVP.resolve();
}
return this.get('kredits').Contributor
return this.get('organization').Contributor
.functions.getContributorIdByAddress(this.get('currentUserAccounts.firstObject'))
.then((id) => {
id = id.toNumber();
@@ -161,7 +161,7 @@ export default Service.extend({
if (id === 0) {
return RSVP.resolve();
} 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
addContractEventHandlers() {
// Operator events
this.get('kredits').Operator
this.get('organization').Operator
.on('ProposalCreated', this.handleProposalCreated.bind(this))
.on('ProposalVoted', this.handleProposalVoted.bind(this))
.on('ProposalExecuted', this.handleProposalExecuted.bind(this));
// Token events
this.get('kredits').Token
this.get('organization').Token
.on('Transfer', this.handleTransfer.bind(this));
},
@@ -191,7 +191,7 @@ export default Service.extend({
return;
}
this.get('kredits').Operator.getById(proposalId)
this.get('organization').Operator.getById(proposalId)
.then((proposal) => {
proposal = this.buildModel('proposal', proposal);
this.get('proposals').pushObject(proposal);