From 26c27101499041d1ac94044c9238be8da880172a Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sat, 6 Apr 2019 17:56:48 +0200 Subject: [PATCH] Improve list-contributions script * Improve sort order of table columns * Print if the contribution is confirmed * Log error if something goes wrong --- scripts/list-contributions.js | 38 ++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/scripts/list-contributions.js b/scripts/list-contributions.js index cc2652a..73d7e58 100644 --- a/scripts/list-contributions.js +++ b/scripts/list-contributions.js @@ -15,21 +15,31 @@ module.exports = async function(callback) { console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`); 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) => { - table.push([ - c.id.toString(), - c.contributorId, - c.amount.toString(), - c.claimed, - c.vetoed, - `${c.description}` - ]) - }) - console.log(table.toString()) - callback() + 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(); }