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