diff --git a/app/lib/kredits/contracts/contributor.js b/app/lib/kredits/contracts/contributor.js index 3e8ab1e..da5de50 100644 --- a/app/lib/kredits/contracts/contributor.js +++ b/app/lib/kredits/contracts/contributor.js @@ -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); }); } diff --git a/app/lib/kredits/contracts/operator.js b/app/lib/kredits/contracts/operator.js index c3e3898..cd5f7fe 100644 --- a/app/lib/kredits/contracts/operator.js +++ b/app/lib/kredits/contracts/operator.js @@ -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); }); } diff --git a/app/lib/kredits/index.js b/app/lib/kredits/index.js index eeb0011..5e28369 100644 --- a/app/lib/kredits/index.js +++ b/app/lib/kredits/index.js @@ -1 +1 @@ -export { default } from './kredits'; +export { default } from './organization'; diff --git a/app/lib/kredits/kredits.js b/app/lib/kredits/organization.js similarity index 96% rename from app/lib/kredits/kredits.js rename to app/lib/kredits/organization.js index 46a893f..0e7b103 100644 --- a/app/lib/kredits/kredits.js +++ b/app/lib/kredits/organization.js @@ -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); }); }); } diff --git a/app/services/kredits.js b/app/services/kredits.js index 91cfa3f..1c0f859 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -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);