Add helper funtion to list contract entries
This commit is contained in:
parent
d6f99f57b7
commit
4f5ae01c5a
19
README.md
19
README.md
@ -100,24 +100,17 @@ instance.
|
|||||||
|
|
||||||
$ truffle exec scripts/repl.js
|
$ 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
|
Script to add a new entries to the contracts using the JS wrapper
|
||||||
votes for that one.
|
|
||||||
|
|
||||||
$ 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
|
$ truffle exec scripts/list-{contributor, contribution, proposal}.js
|
||||||
|
|
||||||
### add-contribution.js
|
|
||||||
|
|
||||||
Adds a new contribution for an existing contributor
|
|
||||||
|
|
||||||
$ truffle exec scripts/add-contribution.js
|
|
||||||
|
|
||||||
### send-funds.js
|
### send-funds.js
|
||||||
|
|
||||||
|
37
scripts/list-contributions.js
Normal file
37
scripts/list-contributions.js
Normal 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()
|
||||||
|
}
|
36
scripts/list-contributors.js
Normal file
36
scripts/list-contributors.js
Normal 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
37
scripts/list-proposals.js
Normal 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()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user