feat: list projects
This commit is contained in:
parent
d28c41f84e
commit
9ac98f6909
|
@ -44,6 +44,7 @@
|
|||
"homepage": ".",
|
||||
"dependencies": {
|
||||
"@aragon/os": "3.1.9",
|
||||
"cli-table": "^0.3.1",
|
||||
"colors": "^1.3.3",
|
||||
"commander": "^2.20.0",
|
||||
"embark": "^4.1.0-beta.0",
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
var inquirer = require('inquirer');
|
||||
const Web3 = require("web3");
|
||||
const Table = require('cli-table');
|
||||
|
||||
|
||||
const Contracts = require("./contracts.js");
|
||||
|
||||
|
@ -65,6 +67,25 @@ class Actions {
|
|||
});
|
||||
}
|
||||
|
||||
async listProjects() {
|
||||
let numProjects = await LiquidPledging.methods.numberOfPledgeAdmins().call();
|
||||
|
||||
const table = new Table({
|
||||
head: ['Id', 'Name', 'URL', 'ParentProject', 'Status', 'Commit Time', 'Owner', 'Plugin']
|
||||
});
|
||||
|
||||
for(let i = 1; i <= numProjects; i++){
|
||||
const pledge = await LiquidPledging.methods.getPledgeAdmin(i).call();
|
||||
if(pledge.adminType !== '2') continue;
|
||||
|
||||
table.push(
|
||||
[i, pledge.name, pledge.url, pledge.parentProject, pledge.canceled ? 'Canceled' : 'Active', pledge.commitTime, pledge.addr, pledge.plugin]
|
||||
);
|
||||
}
|
||||
|
||||
console.log(table.toString());
|
||||
}
|
||||
|
||||
addGiver(params) {
|
||||
let text = `await LiquidPledging.methods.addGiver(\"${params.name}\", \"${params.url}\", ${params.commitTime}, \"${params.plugin}\").send({from: \"${web3.eth.defaultAccount}\", gas: 2000000})`
|
||||
doAction(text, async () => {
|
||||
|
|
|
@ -10,10 +10,11 @@ async function app(actions) {
|
|||
subAction = (await menus.projects()).action
|
||||
|
||||
if (subAction === 'List Projects') {
|
||||
actions.listProjects();
|
||||
} if (subAction === 'Create Project') {
|
||||
let params = (await menus.createProject(actions.web3().eth.defaultAccount))
|
||||
actions.addProject(params);
|
||||
} if (subAction === 'view Project') {
|
||||
} if (subAction === 'View Project') {
|
||||
} if (subAction === 'Donate to Project') {
|
||||
let params = (await menus.donate())
|
||||
actions.donate(params);
|
||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -2656,6 +2656,13 @@ cli-spinners@^1.1.0:
|
|||
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.3.1.tgz#002c1990912d0d59580c93bd36c056de99e4259a"
|
||||
integrity sha512-1QL4544moEsDVH9T/l6Cemov/37iv1RtoKf7NJ04A60+4MREXNfx/QvavbH6QoGdsD4N4Mwy49cmaINR/o2mdg==
|
||||
|
||||
cli-table@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23"
|
||||
integrity sha1-9TsFJmqLGguTSz0IIebi3FkUriM=
|
||||
dependencies:
|
||||
colors "1.0.3"
|
||||
|
||||
cli-width@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
|
||||
|
@ -2784,6 +2791,11 @@ colornames@^1.1.1:
|
|||
resolved "https://registry.yarnpkg.com/colornames/-/colornames-1.1.1.tgz#f8889030685c7c4ff9e2a559f5077eb76a816f96"
|
||||
integrity sha1-+IiQMGhcfE/54qVZ9Qd+t2qBb5Y=
|
||||
|
||||
colors@1.0.3:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b"
|
||||
integrity sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=
|
||||
|
||||
colors@1.3.2:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/colors/-/colors-1.3.2.tgz#2df8ff573dfbf255af562f8ce7181d6b971a359b"
|
||||
|
|
Loading…
Reference in New Issue