Add support for new splitted Token contract
This commit is contained in:
+2
-2
@@ -9,8 +9,8 @@ export default Ember.Route.extend({
|
||||
|
||||
return Ember.RSVP.hash({
|
||||
contributors: kredits.getContributors(),
|
||||
totalSupply: kredits.getValueFromContract('totalSupply'),
|
||||
contributorsCount: kredits.getValueFromContract('contributorsCount'),
|
||||
totalSupply: kredits.getValueFromContract('tokenContract', 'totalSupply'),
|
||||
contributorsCount: kredits.getValueFromContract('kreditsContract', 'contributorsCount'),
|
||||
proposals: kredits.getProposals()
|
||||
});
|
||||
}
|
||||
|
||||
+22
-10
@@ -44,16 +44,28 @@ export default Ember.Service.extend({
|
||||
return this.get('kreditsContractInstance');
|
||||
}
|
||||
|
||||
console.log(config.ethereumChain);
|
||||
let contract = kreditsContracts(this.get('web3'), config.ethereumChain)['Kredits'];
|
||||
let contract = kreditsContracts(this.get('web3'))['Kredits'];
|
||||
|
||||
this.set('kreditsContractInstance', contract);
|
||||
window.Kredits = contract;
|
||||
return contract;
|
||||
}.property('web3'),
|
||||
|
||||
getValueFromContract(contractMethod, ...args) {
|
||||
tokenContract: function() {
|
||||
if (this.get('tokenContractInstance')) {
|
||||
return this.get('tokenContractInstance');
|
||||
}
|
||||
|
||||
let contract = kreditsContracts(this.get('web3'), config.ethereumChain)['Token'];
|
||||
this.set('tokenContractInstance', contract);
|
||||
window.Token = contract;
|
||||
return contract;
|
||||
}.property('web3', 'kreditsContract', 'tokenContract'),
|
||||
|
||||
getValueFromContract(contract, contractMethod, ...args) {
|
||||
Ember.Logger.debug('[kredits] read from contract', contract);
|
||||
return new Ember.RSVP.Promise((resolve, reject) => {
|
||||
this.get('kreditsContract')[contractMethod](...args, (err, data) => {
|
||||
this.get(contract)[contractMethod](...args, (err, data) => {
|
||||
if (err) { reject(err); }
|
||||
resolve(data);
|
||||
});
|
||||
@@ -62,9 +74,9 @@ export default Ember.Service.extend({
|
||||
|
||||
getContributorData(i) {
|
||||
let promise = new Ember.RSVP.Promise((resolve, reject) => {
|
||||
this.getValueFromContract('contributorAddresses', i).then(address => {
|
||||
this.getValueFromContract('contributors', address).then(person => {
|
||||
this.getValueFromContract('balanceOf', address).then(balance => {
|
||||
this.getValueFromContract('kreditsContract', 'contributorAddresses', i).then(address => {
|
||||
this.getValueFromContract('kreditsContract', 'contributors', address).then(person => {
|
||||
this.getValueFromContract('tokenContract', 'balanceOf', address).then(balance => {
|
||||
console.debug('person', person);
|
||||
let contributor = Contributor.create({
|
||||
address: address,
|
||||
@@ -84,7 +96,7 @@ export default Ember.Service.extend({
|
||||
},
|
||||
|
||||
getContributors() {
|
||||
return this.getValueFromContract('contributorsCount').then(contributorsCount => {
|
||||
return this.getValueFromContract('kreditsContract', 'contributorsCount').then(contributorsCount => {
|
||||
let contributors = [];
|
||||
|
||||
for(var i = 0; i < contributorsCount.toNumber(); i++) {
|
||||
@@ -97,7 +109,7 @@ export default Ember.Service.extend({
|
||||
|
||||
getProposalData(i) {
|
||||
let promise = new Ember.RSVP.Promise((resolve, reject) => {
|
||||
this.getValueFromContract('proposals', i).then(p => {
|
||||
this.getValueFromContract('kreditsContract', 'proposals', i).then(p => {
|
||||
let proposal = Proposal.create({
|
||||
id : i,
|
||||
creatorAddress : p[0],
|
||||
@@ -117,7 +129,7 @@ export default Ember.Service.extend({
|
||||
},
|
||||
|
||||
getProposals() {
|
||||
return this.getValueFromContract('proposalsCount').then(proposalsCount => {
|
||||
return this.getValueFromContract('kreditsContract', 'proposalsCount').then(proposalsCount => {
|
||||
let proposals = [];
|
||||
|
||||
for(var i = 0; i < proposalsCount.toNumber(); i++) {
|
||||
|
||||
+6
-2
@@ -21,7 +21,11 @@
|
||||
"build": "ember build",
|
||||
"build-prod": "ember build --environment production",
|
||||
"update-version-file": "bash scripts/update-version-file.sh",
|
||||
"deploy": "npm run build-prod && npm run update-version-file && bash scripts/deploy.sh"
|
||||
"deploy": "npm run build-prod && npm run update-version-file && bash scripts/deploy.sh",
|
||||
"kredits-console": "kredits-console",
|
||||
"kredits-parity": "kredits-parity",
|
||||
"kredits-deploy": "kredits-deploy",
|
||||
"kredits-inspect": "kredits-inspect"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-preset-es2015": "^6.22.0",
|
||||
@@ -47,7 +51,7 @@
|
||||
"ember-load-initializers": "^0.5.1",
|
||||
"ember-resolver": "^2.0.3",
|
||||
"ipfs-api": "^12.1.7",
|
||||
"kredits-contracts": "67P/kredits-contracts",
|
||||
"kredits-contracts": "67p/kredits-contracts",
|
||||
"loader.js": "^4.0.10",
|
||||
"web3": "^0.18.2"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user