Merge pull request #4 from status-im/feat/list-projects

feat: list projects
This commit is contained in:
Iuri Matias 2019-05-23 08:16:37 -04:00 committed by GitHub
commit c6e459008b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 14 deletions

View File

@ -103,22 +103,12 @@ module.exports = {
LiquidPledging: {
instanceOf: 'LiquidPledgingMock'
},
RecoveryVault: {},
LPFactory: {
args: ['$LPVault', '$LiquidPledging'],
},
// contracts for testing
StandardToken: {},
Kernel: {
file: "@aragon/os/contracts/kernel/Kernel.sol"
},
ACL: {
file: "@aragon/os/contracts/acl/ACL.sol"
}
StandardToken: {}
},
afterDeploy: async (deps) => {
await deps.contracts.LiquidPledging.methods.initialize(deps.contracts.LPVault.options.address).send({gas: 1000000});
await deps.contracts.LPVault.methods.initialize(deps.contracts.LiquidPledging.options.address).send({gas: 1000000});
await deps.contracts.LiquidPledging.methods.initialize(deps.contracts.LPVault.options.address).send({gas: 1000000, from: deps.web3.eth.defaultAccount});
await deps.contracts.LPVault.methods.initialize(deps.contracts.LiquidPledging.options.address).send({gas: 1000000, from: deps.web3.eth.defaultAccount});
}
// afterDeploy: [

View File

@ -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",

View File

@ -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,29 @@ class Actions {
});
}
async listProjects() {
try {
let numProjects = await this.contracts.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 this.contracts.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());
} catch(error){
console.log("Couldn't obtain the list of projects: ", error.message);
}
}
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 () => {

View File

@ -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);

View File

@ -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"