* Improve sort order of table columns * Print if the contribution is confirmed * Log error if something goes wrong
46 lines
1019 B
JavaScript
46 lines
1019 B
JavaScript
const promptly = require('promptly');
|
|
const Table = require('cli-table');
|
|
|
|
const initKredits = require('./helpers/init_kredits.js');
|
|
|
|
module.exports = async function(callback) {
|
|
let kredits;
|
|
try {
|
|
kredits = await initKredits(web3);
|
|
} catch(e) {
|
|
callback(e);
|
|
return;
|
|
}
|
|
|
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
|
|
|
const table = new Table({
|
|
head: ['ID', 'Contributor ID', 'Description', 'Amount', 'Confirmed?', 'Vetoed?', 'Claimed?']
|
|
})
|
|
|
|
try {
|
|
let blockNumber = await kredits.provider.getBlockNumber();
|
|
let contributions = await kredits.Contribution.all()
|
|
|
|
contributions.forEach((c) => {
|
|
const confirmed = !!(c.claimAtBlock < blockNumber)
|
|
|
|
table.push([
|
|
c.id.toString(),
|
|
c.contributorId,
|
|
`${c.description}`,
|
|
c.amount.toString(),
|
|
confirmed,
|
|
c.vetoed,
|
|
c.claimed,
|
|
])
|
|
})
|
|
|
|
console.log(table.toString())
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
|
|
callback();
|
|
}
|