@@ -11,15 +11,4 @@ export default Ember.Controller.extend({
|
|||||||
|
|
||||||
kredits: service(),
|
kredits: service(),
|
||||||
|
|
||||||
contributorsCount: computed('model.contributors.[]', function() {
|
|
||||||
return this.get('model.contributors').length;
|
|
||||||
}),
|
|
||||||
|
|
||||||
kreditsSum: computed('model.contributors.[]', function() {
|
|
||||||
let kredits = this.get('model.contributors').mapBy('kredits');
|
|
||||||
return kredits.reduce(function(previousValue, currentValue) {
|
|
||||||
return currentValue + previousValue;
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
+3
-1
@@ -15,9 +15,11 @@ let fixtures = [
|
|||||||
|
|
||||||
export default Ember.Route.extend({
|
export default Ember.Route.extend({
|
||||||
|
|
||||||
|
kredits: Ember.inject.service(),
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
let contributors = [];
|
let contributors = [];
|
||||||
fixtures.forEach(obj => {
|
this.get('kredits.contributors').forEach(obj => {
|
||||||
contributors.pushObject(Contributor.create(obj));
|
contributors.pushObject(Contributor.create(obj));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+23
-1
@@ -18,11 +18,12 @@ export default Ember.Service.extend({
|
|||||||
web3Instance = window.web3;
|
web3Instance = window.web3;
|
||||||
} else {
|
} else {
|
||||||
Ember.Logger.debug('[web3] Creating new instance from npm module class');
|
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);
|
web3Instance = new Web3(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('web3Instance', web3Instance);
|
this.set('web3Instance', web3Instance);
|
||||||
|
window.web3 = web3Instance;
|
||||||
|
|
||||||
return web3Instance;
|
return web3Instance;
|
||||||
}.property('web3Instance'),
|
}.property('web3Instance'),
|
||||||
@@ -32,6 +33,7 @@ export default Ember.Service.extend({
|
|||||||
let contract = this.get('web3')
|
let contract = this.get('web3')
|
||||||
.eth.contract(config.kreditsContract.ABI)
|
.eth.contract(config.kreditsContract.ABI)
|
||||||
.at(config.kreditsContract.address);
|
.at(config.kreditsContract.address);
|
||||||
|
window.Kredits = contract;
|
||||||
return contract;
|
return contract;
|
||||||
}.property('web3'),
|
}.property('web3'),
|
||||||
|
|
||||||
@@ -39,6 +41,26 @@ export default Ember.Service.extend({
|
|||||||
return this.get('kreditsContract').totalSupply();
|
return this.get('kreditsContract').totalSupply();
|
||||||
}.property('kreditsContract'),
|
}.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() {
|
logKreditsContract: function() {
|
||||||
Ember.Logger.debug('kreditsContract', this.get('kreditsContract'));
|
Ember.Logger.debug('kreditsContract', this.get('kreditsContract'));
|
||||||
}.on('init')
|
}.on('init')
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<p class="stats">
|
<p class="stats">
|
||||||
<span class="number">{{kredits.totalSupply}}</span> kredits issued and distributed among
|
<span class="number">{{kredits.totalSupply}}</span> kredits issued and distributed among
|
||||||
<span class="number">{{contributorsCount}}</span> contributors.
|
<span class="number">{{kredits.contributorsCount}}</span> contributors.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ module.exports = function(environment) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
kreditsContract: {
|
kreditsContract: {
|
||||||
ABI: contracts['Kredits']
|
ABI: contracts['Kredits'].abi
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (environment === 'development') {
|
if (environment === 'development') {
|
||||||
ENV.kreditsContract.address = 'abcdef123456';
|
ENV.kreditsContract.address = '0x9C68Af50e97f5605402B4C01e7aB836ed7145e8B';
|
||||||
// ENV.APP.LOG_RESOLVER = true;
|
// ENV.APP.LOG_RESOLVER = true;
|
||||||
// ENV.APP.LOG_ACTIVE_GENERATION = true;
|
// ENV.APP.LOG_ACTIVE_GENERATION = true;
|
||||||
// ENV.APP.LOG_TRANSITIONS = true;
|
// ENV.APP.LOG_TRANSITIONS = true;
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user