diff --git a/app/controllers/index.js b/app/controllers/index.js index 3864867..3a08d9e 100644 --- a/app/controllers/index.js +++ b/app/controllers/index.js @@ -29,9 +29,8 @@ export default Controller.extend({ .map((proposal) => { let contributor = this.get('contributors') .findBy('id', proposal.get('recipientId')); - if (contributor) { - proposal.set('contributor', contributor); - } + + proposal.set('contributor', contributor); return proposal; }); @@ -51,15 +50,7 @@ export default Controller.extend({ return; } - // TODO: we should remove votesNeeded - proposal = this.get('kredits').buildModel('proposal', { - id: proposalId, - creatorAddress: creatorAddress, - recipientId: recipientId.toString(), - votesNeeded: 2, - amount: amount.toNumber(), - }); - + proposal = this.get('kredits').getProposalById(proposalId); this.get('proposals').pushObject(proposal); }, @@ -88,13 +79,14 @@ export default Controller.extend({ .setProperties({ 'votesCount': totalVotes }); }, - _handleTransfer(data) { + _handleTransfer(from, to, value) { + value = value.toNumber(); this.get('contributors') - .findBy('address', data.args.from) - .incrementProperty('balance', - data.args.value.toNumber()); + .findBy('address', from) + .decrementProperty('balance', value); this.get('contributors') - .findBy('address', data.args.to) - .incrementProperty('balance', data.args.value.toNumber()); + .findBy('address', to) + .incrementProperty('balance', value); }, diff --git a/app/services/kredits.js b/app/services/kredits.js index 19f6495..f78f6e0 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -123,6 +123,8 @@ export default Service.extend({ }, getContributorById(id) { + id = ethers.utils.bigNumberify(id); + return this.get('contributorsContract') .then((contract) => contract.getContributorById(id)) .then(this.reassembleIpfsHash) @@ -199,6 +201,8 @@ export default Service.extend({ }, getProposalById(id) { + id = ethers.utils.bigNumberify(id); + return this.get('kreditsContract') .then((contract) => contract.proposals(id)) .then(this.reassembleIpfsHash)