If the blocknumber is higher or equal the contribution.confirmedAt block number then the contribution is confirmed and can be claimed.
46 lines
1.0 KiB
JavaScript
46 lines
1.0 KiB
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.confirmedAtBlock <= 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();
|
|
}
|