Add helper funtion to list contract entries

This commit is contained in:
bumi 2019-03-28 11:16:20 +01:00
parent d6f99f57b7
commit 4f5ae01c5a
4 changed files with 116 additions and 13 deletions

View File

@ -100,24 +100,17 @@ instance.
$ truffle exec scripts/repl.js
### add-contributor.js
### add-{contributor, contribution, proposal}.js
Adds a new core contributor, creates a proposal for the new contributor and
votes for that one.
Script to add a new entries to the contracts using the JS wrapper
$ truffle exec scripts/add-contributor.js
$ truffle exec scripts/add-{contributor, contribution, proposal}.js
### add-proposal.js
### list-{contributor, contribution, proposal}.js
Adds a new proposal for an existing contributor
List contract entries
$ truffle exec scripts/add-proposal.js
### add-contribution.js
Adds a new contribution for an existing contributor
$ truffle exec scripts/add-contribution.js
$ truffle exec scripts/list-{contributor, contribution, proposal}.js
### send-funds.js

View File

@ -0,0 +1,37 @@
const promptly = require('promptly');
const Table = require('cli-table');
const ethers = require('ethers');
const Kredits = require('../lib/kredits');
const getNetworkId = require('./helpers/networkid.js')
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(
web3.currentProvider, { chainId: parseInt(networkId) }
);
const kredits = await new Kredits(provider, provider.getSigner()).init();
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
const table = new Table({
head: ['ID', 'Contributor account', 'Amount', 'Claimed?', 'Vetoed?', 'Description']
})
let contributions = await kredits.Contribution.all()
contributions.forEach((c) => {
table.push([
c.id.toString(),
c.contributor,
c.amount.toString(),
c.claimed,
c.vetoed,
`${c.description}`
])
})
console.log(table.toString())
callback()
}

View File

@ -0,0 +1,36 @@
const promptly = require('promptly');
const Table = require('cli-table');
const ethers = require('ethers');
const Kredits = require('../lib/kredits');
const getNetworkId = require('./helpers/networkid.js')
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(
web3.currentProvider, { chainId: parseInt(networkId) }
);
const kredits = await new Kredits(provider, provider.getSigner()).init();
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
const table = new Table({
head: ['ID', 'Account', 'Core?', 'Name']
})
let contributors = await kredits.Contributor.all()
contributors.forEach((c) => {
table.push([
c.id.toString(),
c.account,
c.isCore,
`${c.name}`
])
})
console.log(table.toString())
callback()
}

37
scripts/list-proposals.js Normal file
View File

@ -0,0 +1,37 @@
const promptly = require('promptly');
const Table = require('cli-table');
const ethers = require('ethers');
const Kredits = require('../lib/kredits');
const getNetworkId = require('./helpers/networkid.js')
module.exports = async function(callback) {
const networkId = await getNetworkId(web3)
const provider = new ethers.providers.Web3Provider(
web3.currentProvider, { chainId: parseInt(networkId) }
);
const kredits = await new Kredits(provider, provider.getSigner()).init();
console.log(`Using Proposal at: ${kredits.Proposal.contract.address}`);
const table = new Table({
head: ['ID', 'Contributor ID', 'Amount', 'Votes', 'Executed?', 'Description']
})
let proposals = await kredits.Proposal.all()
proposals.forEach((p) => {
table.push([
p.id.toString(),
p.contributorId.toString(),
p.amount.toString(),
`${p.votesCount.toString()}/${p.votesNeeded.toString()}`,
p.executed,
`${p.description}`
])
})
console.log(table.toString())
callback()
}