diff --git a/app/models/contributor.js b/app/models/contributor.js index 2303a1a..cd793d3 100644 --- a/app/models/contributor.js +++ b/app/models/contributor.js @@ -11,7 +11,7 @@ export default EmberObject.extend({ github_uid: null, wiki_username: null, profileHash: null, - balance: null, + balance: 0, isCore: false, isCurrentUser: false, diff --git a/app/services/kredits.js b/app/services/kredits.js index 530b0d6..868e5d2 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -191,7 +191,7 @@ export default Service.extend({ .then(ContributorSerializer.deserialize) .then((attributes) => { debug('[kredits] loaded contributor profile', attributes); - return Object.assign(data, attributes); + return Object.assign({}, data, attributes); }) .catch((err) => { error( @@ -293,28 +293,28 @@ export default Service.extend({ return this.get('ipfs') .storeFile(json) + // Set profileHash .then((profileHash) => { - // Set new attributes attributes.profileHash = profileHash; - attributes.balance = 0; - attributes.isCurrentUser = this.get('currentUserAccounts') - .includes(attributes.address); - + return attributes; + }) + .then((attributes) => { return this.get('kreditsContract') .then((contract) => { - let { address, isCore } = attributes; + let { address, isCore, profileHash } = attributes; let { digest, hashFunction, size } = this.getBytes32FromMultihash(profileHash); - debug('[kredits] addContributor', address, digest, hashFunction, size, isCore); - return contract.addContributor( + let contributor = [ address, digest, hashFunction, size, - isCore - ); + isCore, + ]; + debug('[kredits] addContributor', ...contributor); + return contract.addContributor(...contributor); }); }) .then((data) => {