Improve list-contributions script

* Improve sort order of table columns
* Print if the contribution is confirmed
* Log error if something goes wrong
This commit is contained in:
Basti 2019-04-06 17:56:48 +02:00
parent cc24c27444
commit 26c2710149
No known key found for this signature in database
GPG Key ID: BE4634D632D39B67

View File

@ -15,21 +15,31 @@ 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 ID', 'Description', 'Amount', 'Confirmed?', 'Vetoed?', 'Claimed?']
}) })
let contributions = await kredits.Contribution.all() try {
let blockNumber = await kredits.provider.getBlockNumber();
let contributions = await kredits.Contribution.all()
contributions.forEach((c) => { contributions.forEach((c) => {
table.push([ const confirmed = !!(c.claimAtBlock < blockNumber)
c.id.toString(),
c.contributorId, table.push([
c.amount.toString(), c.id.toString(),
c.claimed, c.contributorId,
c.vetoed, `${c.description}`,
`${c.description}` c.amount.toString(),
]) confirmed,
}) c.vetoed,
console.log(table.toString()) c.claimed,
callback() ])
})
console.log(table.toString())
} catch (err) {
console.log(err);
}
callback();
} }