Adjust wrapper and scripts for contract changes

This commit is contained in:
2019-04-04 16:24:23 +02:00
parent 6088f30cd8
commit 5b49f82544
4 changed files with 20 additions and 27 deletions

View File

@@ -7,8 +7,7 @@ const Base = require('./base');
class Contribution extends Base {
all() {
return this.functions.contributionsCount()
.then((count) => {
count = count.toNumber();
.then(count => {
let contributions = [];
for (let id = 1; id <= count; id++) {
@@ -20,31 +19,29 @@ class Contribution extends Base {
}
getById(id) {
id = ethers.utils.bigNumberify(id);
return this.functions.getContribution(id)
.then((data) => {
.then(data => {
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
});
}
getByContributorId(contributorId) {
return this.functions.balanceOf(address)
then((balance) => {
count = balance.toNumber();
let contributions = [];
for (let index = 0; index <= count; index++) {
this.functions.tokenOfOwnerByIndex(address, index)
.then((id) => {
contributions.push(this.getById(id));
});
}
return RSVP.all(contributions);
});
// return this.functions.balanceOf(address)
// then(balance => {
// count = balance.toNumber();
//
// let contributions = [];
//
// for (let index = 0; index <= count; index++) {
// this.functions.tokenOfOwnerByIndex(address, index)
// .then((id) => {
// contributions.push(this.getById(id));
// });
// }
//
// return RSVP.all(contributions);
// });
}
getByContributorAddress(address) {

View File

@@ -7,8 +7,7 @@ const Base = require('./base');
class Contributor extends Base {
all() {
return this.functions.contributorsCount()
.then((count) => {
count = count.toNumber();
.then(count => {
let contributors = [];
for (let id = 1; id <= count; id++) {
@@ -20,8 +19,6 @@ class Contributor extends Base {
}
getById(id) {
id = ethers.utils.bigNumberify(id);
return this.functions.getContributorById(id)
.then((data) => {
// TODO: remove when naming updated on the contract