Merge pull request #110 from 67P/feature/contribution-balances

Add contract calls for total contribution balances
This commit was merged in pull request #110.
This commit is contained in:
2019-04-23 13:47:50 +01:00
committed by GitHub
6 changed files with 44 additions and 5 deletions

View File

@@ -22,6 +22,7 @@ module.exports = async function(callback) {
let blockNumber = await kredits.provider.getBlockNumber();
let contributions = await kredits.Contribution.all();
console.log(`Current block number: ${blockNumber}`);
contributions.forEach((c) => {
const confirmed = c.confirmedAtBlock <= blockNumber;
@@ -30,7 +31,7 @@ module.exports = async function(callback) {
c.contributorId,
`${c.description}`,
c.amount.toString(),
confirmed,
`${confirmed} (${c.confirmedAtBlock})`,
c.vetoed,
c.claimed,
c.ipfsHash
@@ -38,6 +39,9 @@ module.exports = async function(callback) {
});
console.log(table.toString());
let totalContributionBalances = await kredits.Contribution.functions.totalCount(true);
console.log(`Total confirmed balance: ${totalContributionBalances}`);
} catch (err) {
console.log(err);
}

View File

@@ -16,7 +16,7 @@ module.exports = async function(callback) {
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
const table = new Table({
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'IPFS']
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
})
try {
@@ -33,6 +33,8 @@ module.exports = async function(callback) {
`${c.name}`,
c.isCore,
ethers.utils.formatEther(c.balance),
c.totalKreditsEarned.toString(),
c.contributionsCount.toString(),
c.ipfsHash
])
})