Use ID instead of address for contribution owner

This commit is contained in:
2019-04-04 14:43:38 +02:00
parent 732dfe7b29
commit 20acfc70e3
4 changed files with 86 additions and 30 deletions

File diff suppressed because one or more lines are too long

View File

@@ -29,15 +29,33 @@ class Contribution extends Base {
}
getByContributor(contributor) {
return this.functions.balanceOf(contributor)
getByContributorId(contributorId) {
return this.functions.balanceOf(address)
then((balance) => {
count = balance.toNumber();
let contributions = [];
for (let index = 0; index <= count; index++) {
this.functions.tokenOfOwnerByIndex(contributor, index)
this.functions.tokenOfOwnerByIndex(address, index)
.then((id) => {
contributions.push(this.getById(id));
});
}
return RSVP.all(contributions);
});
}
getByContributorAddress(address) {
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));
});
@@ -56,7 +74,7 @@ class Contribution extends Base {
.then((ipfsHashAttr) => {
let contribution = [
contributionAttr.amount,
contributionAttr.contributorAccount,
contributionAttr.contributorId,
ipfsHashAttr.hashDigest,
ipfsHashAttr.hashFunction,
ipfsHashAttr.hashSize,