connect add contributor form to ethereum

This commit is contained in:
2017-02-08 13:44:27 +08:00
parent 1de2e002bb
commit d05356cfe4
5 changed files with 68 additions and 19 deletions
+19
View File
@@ -38,6 +38,7 @@ export default Ember.Service.extend({
return this.get('kreditsContractInstance');
}
console.log(config.ethereumChain);
let contract = kreditsContracts(this.get('web3'), config.ethereumChain)['Kredits'];
this.set('kreditsContractInstance', contract);
@@ -130,6 +131,24 @@ export default Ember.Service.extend({
});
},
addContributor(address, name, ipfsHash, isCore, id) {
Ember.Logger.debug('[kredits] add contributor', name, address);
return new Ember.RSVP.Promise((resolve, reject) => {
this.get('kreditsContract').addContributor(address, name, ipfsHash, isCore, id, (err, data) => {
if (err) { reject(err); }
Ember.Logger.debug('[kredits] add contributor response', data);
let contributor = Contributor.create({
address: address,
github_username: name,
github_uid: id,
ipfsHash: ipfsHash,
kredits: 0
});
resolve(contributor);
});
});
},
logKreditsContract: function() {
Ember.Logger.debug('[kredits] kreditsContract', this.get('kreditsContract'));
}.on('init')