+23
-1
@@ -18,11 +18,12 @@ export default Ember.Service.extend({
|
||||
web3Instance = window.web3;
|
||||
} else {
|
||||
Ember.Logger.debug('[web3] Creating new instance from npm module class');
|
||||
let provider = new Web3.providers.HttpProvider("http://localhost:8545");
|
||||
let provider = new Web3.providers.HttpProvider("http://139.59.248.169:8545");
|
||||
web3Instance = new Web3(provider);
|
||||
}
|
||||
|
||||
this.set('web3Instance', web3Instance);
|
||||
window.web3 = web3Instance;
|
||||
|
||||
return web3Instance;
|
||||
}.property('web3Instance'),
|
||||
@@ -32,6 +33,7 @@ export default Ember.Service.extend({
|
||||
let contract = this.get('web3')
|
||||
.eth.contract(config.kreditsContract.ABI)
|
||||
.at(config.kreditsContract.address);
|
||||
window.Kredits = contract;
|
||||
return contract;
|
||||
}.property('web3'),
|
||||
|
||||
@@ -39,6 +41,26 @@ export default Ember.Service.extend({
|
||||
return this.get('kreditsContract').totalSupply();
|
||||
}.property('kreditsContract'),
|
||||
|
||||
contributorsCount: function() {
|
||||
return this.get('kreditsContract').contributorsCount();
|
||||
}.property('kreditsContract'),
|
||||
|
||||
contributors: function() {
|
||||
var c = [];
|
||||
for(var i = 0; i < this.get('contributorsCount').toNumber(); i++) {
|
||||
var address = this.get('kreditsContract').contributorAddresses(i);
|
||||
var person = this.get('kreditsContract').contributors(address);
|
||||
var balance = this.get('kreditsContract').balanceOf(address);
|
||||
console.log(person);
|
||||
c.push({address: address, github_username: person[1], github_uid: person[0], ipfsHash: person[3], kredits: balance.toNumber()});
|
||||
};
|
||||
return c;
|
||||
}.property('kreditsContract', 'contributorCount'),
|
||||
|
||||
balanceOf: function(address) {
|
||||
return this.get('kreditsContract').balanceOf(address).toNumber();
|
||||
}.property('kreditsContract'),
|
||||
|
||||
logKreditsContract: function() {
|
||||
Ember.Logger.debug('kreditsContract', this.get('kreditsContract'));
|
||||
}.on('init')
|
||||
|
||||
Reference in New Issue
Block a user