Adjust wrapper and scripts for contract changes
This commit is contained in:
parent
6088f30cd8
commit
5b49f82544
@ -7,8 +7,7 @@ const Base = require('./base');
|
|||||||
class Contribution extends Base {
|
class Contribution extends Base {
|
||||||
all() {
|
all() {
|
||||||
return this.functions.contributionsCount()
|
return this.functions.contributionsCount()
|
||||||
.then((count) => {
|
.then(count => {
|
||||||
count = count.toNumber();
|
|
||||||
let contributions = [];
|
let contributions = [];
|
||||||
|
|
||||||
for (let id = 1; id <= count; id++) {
|
for (let id = 1; id <= count; id++) {
|
||||||
@ -20,31 +19,29 @@ class Contribution extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getById(id) {
|
getById(id) {
|
||||||
id = ethers.utils.bigNumberify(id);
|
|
||||||
|
|
||||||
return this.functions.getContribution(id)
|
return this.functions.getContribution(id)
|
||||||
.then((data) => {
|
.then(data => {
|
||||||
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
|
return this.ipfs.catAndMerge(data, ContributionSerializer.deserialize);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getByContributorId(contributorId) {
|
getByContributorId(contributorId) {
|
||||||
return this.functions.balanceOf(address)
|
// return this.functions.balanceOf(address)
|
||||||
then((balance) => {
|
// then(balance => {
|
||||||
count = balance.toNumber();
|
// count = balance.toNumber();
|
||||||
|
//
|
||||||
let contributions = [];
|
// let contributions = [];
|
||||||
|
//
|
||||||
for (let index = 0; index <= count; index++) {
|
// for (let index = 0; index <= count; index++) {
|
||||||
this.functions.tokenOfOwnerByIndex(address, index)
|
// this.functions.tokenOfOwnerByIndex(address, index)
|
||||||
.then((id) => {
|
// .then((id) => {
|
||||||
contributions.push(this.getById(id));
|
// contributions.push(this.getById(id));
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return RSVP.all(contributions);
|
// return RSVP.all(contributions);
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
getByContributorAddress(address) {
|
getByContributorAddress(address) {
|
||||||
|
@ -7,8 +7,7 @@ const Base = require('./base');
|
|||||||
class Contributor extends Base {
|
class Contributor extends Base {
|
||||||
all() {
|
all() {
|
||||||
return this.functions.contributorsCount()
|
return this.functions.contributorsCount()
|
||||||
.then((count) => {
|
.then(count => {
|
||||||
count = count.toNumber();
|
|
||||||
let contributors = [];
|
let contributors = [];
|
||||||
|
|
||||||
for (let id = 1; id <= count; id++) {
|
for (let id = 1; id <= count; id++) {
|
||||||
@ -20,8 +19,6 @@ class Contributor extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getById(id) {
|
getById(id) {
|
||||||
id = ethers.utils.bigNumberify(id);
|
|
||||||
|
|
||||||
return this.functions.getContributorById(id)
|
return this.functions.getContributorById(id)
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
// TODO: remove when naming updated on the contract
|
// TODO: remove when naming updated on the contract
|
||||||
|
@ -27,7 +27,7 @@ module.exports = async function(callback) {
|
|||||||
console.log(`Creating a contribution for contributor account ${contributorAccount} ID: ${contributorId}`);
|
console.log(`Creating a contribution for contributor account ${contributorAccount} ID: ${contributorId}`);
|
||||||
|
|
||||||
let contributionAttributes = {
|
let contributionAttributes = {
|
||||||
contributorAccount,
|
contributorId,
|
||||||
amount: await promptly.prompt('Amount: '),
|
amount: await promptly.prompt('Amount: '),
|
||||||
description: await promptly.prompt('Description: '),
|
description: await promptly.prompt('Description: '),
|
||||||
kind: await promptly.prompt('Kind: ', { default: 'dev' }),
|
kind: await promptly.prompt('Kind: ', { default: 'dev' }),
|
||||||
|
@ -14,7 +14,6 @@ module.exports = async function(callback) {
|
|||||||
|
|
||||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||||
|
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
head: ['ID', 'Contributor account', 'Amount', 'Claimed?', 'Vetoed?', 'Description']
|
head: ['ID', 'Contributor account', 'Amount', 'Claimed?', 'Vetoed?', 'Description']
|
||||||
})
|
})
|
||||||
@ -24,7 +23,7 @@ module.exports = async function(callback) {
|
|||||||
contributions.forEach((c) => {
|
contributions.forEach((c) => {
|
||||||
table.push([
|
table.push([
|
||||||
c.id.toString(),
|
c.id.toString(),
|
||||||
c.contributor,
|
c.contributorId,
|
||||||
c.amount.toString(),
|
c.amount.toString(),
|
||||||
c.claimed,
|
c.claimed,
|
||||||
c.vetoed,
|
c.vetoed,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user