mirror of
https://github.com/status-im/liquid-funding-console.git
synced 2025-02-19 22:48:14 +00:00
cleanup
This commit is contained in:
parent
4d33583ba0
commit
e5232ec889
@ -1,60 +1,60 @@
|
||||
module.exports = {
|
||||
"RecoveryVault": require('./RecoveryVault').default,
|
||||
"LiquidPledgingACLHelpers": require('./LiquidPledgingACLHelpers').default,
|
||||
"ACLHelpers": require('./ACLHelpers').default,
|
||||
"ACLSyntaxSugar": require('./ACLSyntaxSugar').default,
|
||||
"IsContract": require('./IsContract').default,
|
||||
"TestSimpleDelegatePluginFactory": require('./TestSimpleDelegatePluginFactory').default,
|
||||
"StandardToken": require('./StandardToken').default,
|
||||
"ERC20Basic": require('./ERC20Basic').default,
|
||||
"ERC20": require('./ERC20').default,
|
||||
"ILiquidPledgingPlugin": require('./ILiquidPledgingPlugin').default,
|
||||
"ILiquidPledging": require('./ILiquidPledging').default,
|
||||
"LiquidPledgingStorage": require('./LiquidPledgingStorage').default,
|
||||
"LiquidPledgingACLHelpers": require('./LiquidPledgingACLHelpers').default,
|
||||
"ILPVault": require('./ILPVault').default,
|
||||
"LiquidPledgingStorage": require('./LiquidPledgingStorage').default,
|
||||
"ACLHelpers": require('./ACLHelpers').default,
|
||||
"ACLSyntaxSugar": require('./ACLSyntaxSugar').default,
|
||||
"ACLOracle": require('./ACLOracle').default,
|
||||
"AppProxyBase": require('./AppProxyBase').default,
|
||||
"IACL": require('./IACL').default,
|
||||
"DepositableDelegateProxy": require('./DepositableDelegateProxy').default,
|
||||
"DelegateProxy": require('./DelegateProxy').default,
|
||||
"IVaultRecoverable": require('./IVaultRecoverable').default,
|
||||
"AppStorage": require('./AppStorage').default,
|
||||
"ERCProxy": require('./ERCProxy').default,
|
||||
"EVMScriptRegistryConstants": require('./EVMScriptRegistryConstants').default,
|
||||
"Initializable": require('./Initializable').default,
|
||||
"DelegateProxy": require('./DelegateProxy').default,
|
||||
"DepositableDelegateProxy": require('./DepositableDelegateProxy').default,
|
||||
"EtherTokenConstant": require('./EtherTokenConstant').default,
|
||||
"IVaultRecoverable": require('./IVaultRecoverable').default,
|
||||
"IsContract": require('./IsContract').default,
|
||||
"VaultRecoverable": require('./VaultRecoverable').default,
|
||||
"Initializable": require('./Initializable').default,
|
||||
"IEVMScriptExecutor": require('./IEVMScriptExecutor').default,
|
||||
"LPConstants": require('./LPConstants').default,
|
||||
"DelegateScriptTarget": require('./DelegateScriptTarget').default,
|
||||
"EVMScriptRegistryConstants": require('./EVMScriptRegistryConstants').default,
|
||||
"IEVMScriptRegistry": require('./IEVMScriptRegistry').default,
|
||||
"DelegateScriptTarget": require('./DelegateScriptTarget').default,
|
||||
"IKernel": require('./IKernel').default,
|
||||
"CallsScript": require('./CallsScript').default,
|
||||
"TestSimpleDelegatePluginFactory": require('./TestSimpleDelegatePluginFactory').default,
|
||||
"AppProxyBase": require('./AppProxyBase').default,
|
||||
"EVMScriptRunner": require('./EVMScriptRunner').default,
|
||||
"ScriptHelpers": require('./ScriptHelpers').default,
|
||||
"DeployDelegateScript": require('./DeployDelegateScript').default,
|
||||
"CallsScript": require('./CallsScript').default,
|
||||
"DelegateScript": require('./DelegateScript').default,
|
||||
"KernelConstants": require('./KernelConstants').default,
|
||||
"KernelStorage": require('./KernelStorage').default,
|
||||
"LPConstants": require('./LPConstants').default,
|
||||
"TestSimpleDelegatePlugin": require('./TestSimpleDelegatePlugin').default,
|
||||
"TestSimpleProjectPlugin": require('./TestSimpleProjectPlugin').default,
|
||||
"AppProxyUpgradeable": require('./AppProxyUpgradeable').default,
|
||||
"StandardToken": require('./StandardToken').default,
|
||||
"KernelStorage": require('./KernelStorage').default,
|
||||
"SNT": require('./SNT').default,
|
||||
"TestSimpleProjectPluginFactory": require('./TestSimpleProjectPluginFactory').default,
|
||||
"AppProxyPinned": require('./AppProxyPinned').default,
|
||||
"AragonApp": require('./AragonApp').default,
|
||||
"KernelProxy": require('./KernelProxy').default,
|
||||
"Pledges": require('./Pledges').default,
|
||||
"LPVault": require('./LPVault').default,
|
||||
"LiquidPledgingPlugins": require('./LiquidPledgingPlugins').default,
|
||||
"DAOFactory": require('./DAOFactory').default,
|
||||
"EVMScriptRegistry": require('./EVMScriptRegistry').default,
|
||||
"ACL": require('./ACL').default,
|
||||
"DAOFactory": require('./DAOFactory').default,
|
||||
"AppProxyFactory": require('./AppProxyFactory').default,
|
||||
"Kernel": require('./Kernel').default,
|
||||
"LPFactory": require('./LPFactory').default,
|
||||
"LPVault": require('./LPVault').default,
|
||||
"ACL": require('./ACL').default,
|
||||
"EVMScriptRegistryFactory": require('./EVMScriptRegistryFactory').default,
|
||||
"Kernel": require('./Kernel').default,
|
||||
"PledgeAdmins": require('./PledgeAdmins').default,
|
||||
"LPFactory": require('./LPFactory').default,
|
||||
"LiquidPledgingBase": require('./LiquidPledgingBase').default,
|
||||
"LiquidPledgingMock": require('./LiquidPledgingMock').default,
|
||||
"LiquidPledging": require('./LiquidPledging').default,
|
||||
|
@ -47,8 +47,7 @@
|
||||
"colors": "^1.3.3",
|
||||
"embark": "^4.1.0-beta.0",
|
||||
"embarkjs-connector-web3": "^4.0.0",
|
||||
"inquirer": "^6.3.1",
|
||||
"neo-blessed": "^0.2.0"
|
||||
"inquirer": "^6.3.1"
|
||||
},
|
||||
"browserslist": [
|
||||
">0.2%",
|
||||
|
61
src/actions.js
Normal file
61
src/actions.js
Normal file
@ -0,0 +1,61 @@
|
||||
var inquirer = require('inquirer');
|
||||
const Web3 = require("web3");
|
||||
|
||||
const web3 = new Web3();
|
||||
|
||||
const LiquidPledgingJSONConfig = require("../dist/contracts/LiquidPledging.json");
|
||||
const LiquidPledging = new web3.eth.Contract(LiquidPledgingJSONConfig.abiDefinition, LiquidPledgingJSONConfig.address);
|
||||
|
||||
function doAction(actionText, action) {
|
||||
console.dir(actionText)
|
||||
const confirmation = inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'action',
|
||||
message: 'Execute?',
|
||||
}
|
||||
]).then(() => {
|
||||
console.dir("executing...");
|
||||
action()
|
||||
})
|
||||
}
|
||||
|
||||
class Actions {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
connect() {
|
||||
web3.setProvider("ws://localhost:8556");
|
||||
}
|
||||
|
||||
addProject(params) {
|
||||
let text = `await LiquidPledging.methods.addProject(\"${params.name}\", \"${params.url}\", \"${params.account}\", ${params.parentProject}, ${params.commitTime}, \"${params.plugin}\").send({from: web3.eth.defaultAccount, gas: 2000000})`
|
||||
doAction(text, async () => {
|
||||
let projectReceipt = await LiquidPledging.methods.addProject(params.name, params.url, params.account, params.parentProject, params.commitTime, params.plugin).send({from: web3.eth.defaultAccount, gas: 2000000});
|
||||
var projectId = projectReceipt.events.ProjectAdded.returnValues.idProject;
|
||||
|
||||
console.log(projectId);
|
||||
});
|
||||
}
|
||||
|
||||
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 () => {
|
||||
let funderReceipt = await LiquidPledging.methods.addGiver(params.name, params.url, params.commitTime, params.plugin).send({from: web3.eth.defaultAccount, gas: 2000000})
|
||||
var funderId = funderReceipt.events.GiverAdded.returnValues.idGiver;
|
||||
console.log(funderId);
|
||||
});
|
||||
}
|
||||
|
||||
mintToken(params) {
|
||||
let text = `await StandardToken.methods.mint(\"${params.account}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000})`
|
||||
doAction(text, async () => {
|
||||
await StandardToken.methods.mint(params.account, web3.utils.toWei(params.amount, "ether")).send({gas: 2000000})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Actions;
|
288
src/cmd.js
288
src/cmd.js
@ -1,297 +1,49 @@
|
||||
var inquirer = require('inquirer');
|
||||
const menus = require('./menus.js');
|
||||
const Actions = require('./actions.js');
|
||||
|
||||
async function main() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'What do you want to do?',
|
||||
choices: [
|
||||
'Projects',
|
||||
'Funders',
|
||||
new inquirer.Separator(),
|
||||
'Tokens',
|
||||
new inquirer.Separator(),
|
||||
'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
// .then(answers => {
|
||||
// console.log(JSON.stringify(answers, null, ' '));
|
||||
// test()
|
||||
// });
|
||||
}
|
||||
|
||||
async function projects() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Projects> ',
|
||||
choices: [
|
||||
'List Projects',
|
||||
'Create Project',
|
||||
'View Project',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
async function funders() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Funders> ',
|
||||
choices: [
|
||||
'List Funders',
|
||||
'Create Funder',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
async function tokens() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Tokens> ',
|
||||
choices: [
|
||||
'Mint',
|
||||
'Aprove',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
async function project(id) {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Project> ' + id,
|
||||
choices: [
|
||||
'Donate/Pledge',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
async function createProject(defaultAccount) {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'What is the project name?',
|
||||
filter: String,
|
||||
validate: function(value) {
|
||||
return value.length > 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'url',
|
||||
message: 'What is the project url?',
|
||||
default: "status.im",
|
||||
filter: String
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'account',
|
||||
message: 'Address of the project admin?',
|
||||
default: defaultAccount,
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'parentProject',
|
||||
message: 'What is the parent project?',
|
||||
default: 0,
|
||||
filter: Number
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'commitTime',
|
||||
message: 'Time in seconds after which the project owner can access funds',
|
||||
default: 86400,
|
||||
filter: Number
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'plugin',
|
||||
message: 'Plugin address',
|
||||
default: "0x0000000000000000000000000000000000000000",
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
async function createFunder() {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'What is the funders name?',
|
||||
filter: String,
|
||||
validate: function(value) {
|
||||
return value.length > 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'url',
|
||||
message: 'What is the funders url?',
|
||||
default: "status.im",
|
||||
filter: String
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'commitTime',
|
||||
message: 'commit time',
|
||||
default: 86400,
|
||||
filter: Number
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'plugin',
|
||||
message: 'Plugin address',
|
||||
default: "0x0000000000000000000000000000000000000000",
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
async function mintToken() {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'tokenAddress',
|
||||
message: 'What is the token address?',
|
||||
filter: String,
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'account',
|
||||
message: 'What account to mint?',
|
||||
filter: String
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'amount',
|
||||
message: 'amount (in ether units)',
|
||||
default: 2,
|
||||
filter: Number
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
function doAction(actionText, action) {
|
||||
console.dir(actionText)
|
||||
const confirmation = inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'confirm',
|
||||
name: 'action',
|
||||
message: 'Execute?',
|
||||
}
|
||||
]).then(() => {
|
||||
console.dir("executing...");
|
||||
action()
|
||||
})
|
||||
}
|
||||
|
||||
async function app() {
|
||||
async function app(actions) {
|
||||
console.dir("### Liquid Funding Console")
|
||||
let action = (await main()).action
|
||||
let action = (await menus.main()).action
|
||||
let subAction
|
||||
|
||||
if (action === 'Projects') {
|
||||
subAction = (await projects()).action
|
||||
subAction = (await menus.projects()).action
|
||||
|
||||
if (subAction === 'List Projects') {
|
||||
} if (subAction === 'Create Project') {
|
||||
let params = (await createProject("0x0000000000000000000000000000000000000001"))
|
||||
let text = `await LiquidPledging.methods.addProject(\"${params.name}\", \"${params.url}\", \"${params.account}\", ${params.parentProject}, ${params.commitTime}, \"${params.plugin}\").send({from: web3.eth.defaultAccount, gas: 2000000})`
|
||||
doAction(text, () => {
|
||||
let projectReceipt = await LiquidPledging.methods.addProject(params.name, params.url, params.account, params.parentProject, params.commitTime, params.plugin).send({from: web3.eth.defaultAccount, gas: 2000000});
|
||||
var projectId = projectReceipt.events.ProjectAdded.returnValues.idProject;
|
||||
|
||||
console.log(projectId);
|
||||
});
|
||||
let params = (await menus.createProject("0x0000000000000000000000000000000000000001"))
|
||||
actions.addProject(params);
|
||||
} if (subAction === 'view Project') {
|
||||
}
|
||||
} else if (action === 'Funders') {
|
||||
subAction = (await funders()).action
|
||||
subAction = (await menus.funders()).action
|
||||
|
||||
if (subAction === 'List Funders') {
|
||||
} if (subAction === 'Create Funder') {
|
||||
let params = (await createProject())
|
||||
let text = `await LiquidPledging.methods.addGiver(\"${params.name}\", \"${params.url}\", ${params.commitTime}, \"${params.plugin}\").send({from: web3.eth.defaultAccount, gas: 2000000})`
|
||||
doAction(text, () => {
|
||||
let funderReceipt = await LiquidPledging.methods.addGiver(params.name, params.url, params.commitTime, params.plugin).send({from: web3.eth.defaultAccount, gas: 2000000})
|
||||
var funderId = funderReceipt.events.GiverAdded.returnValues.idGiver;
|
||||
console.log(funderId);
|
||||
});
|
||||
let params = (await menus.createProject())
|
||||
actions.addProject(params);
|
||||
}
|
||||
} else if (action === 'Tokens') {
|
||||
subAction = (await tokens()).action
|
||||
subAction = (await menus.tokens()).action
|
||||
|
||||
if (subAction === 'Mint') {
|
||||
let params = (await mintToken())
|
||||
let text = `await StandardToken.methods.mint(\"${params.account}\", web3.utils.toWei(\"${params.amount}\", \"ether\")).send({gas: 2000000})`
|
||||
doAction(text, () => {
|
||||
await StandardToken.methods.mint(params.account, web3.utils.toWei(params.amount, "ether")).send({gas: 2000000})
|
||||
});
|
||||
let params = (await menus.mintToken())
|
||||
action.mintToken(params);
|
||||
} if (subAction === 'Aprove') {
|
||||
}
|
||||
} else if (action === 'Exit') {
|
||||
// const confirmation = await inquirer
|
||||
// .prompt([
|
||||
// {
|
||||
// type: 'confirm',
|
||||
// name: 'action',
|
||||
// message: 'Are you sure you want to exit?',
|
||||
// }
|
||||
// ])
|
||||
|
||||
process.exit()
|
||||
} else {
|
||||
console.dir("unknown action: " + action)
|
||||
}
|
||||
}
|
||||
|
||||
//(() => {
|
||||
app()
|
||||
//})()
|
||||
const actions = new Actions();
|
||||
|
||||
actions.connect();
|
||||
|
||||
setTimeout(async () => {
|
||||
app(actions)
|
||||
}, 1000);
|
||||
|
||||
|
219
src/menus.js
Normal file
219
src/menus.js
Normal file
@ -0,0 +1,219 @@
|
||||
var inquirer = require('inquirer');
|
||||
|
||||
const menus = {
|
||||
|
||||
main: async function() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'What do you want to do?',
|
||||
choices: [
|
||||
'Projects',
|
||||
'Funders',
|
||||
new inquirer.Separator(),
|
||||
'Tokens',
|
||||
new inquirer.Separator(),
|
||||
'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
projects: async function() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Projects> ',
|
||||
choices: [
|
||||
'List Projects',
|
||||
'Create Project',
|
||||
'View Project',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
funders: async function() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Funders> ',
|
||||
choices: [
|
||||
'List Funders',
|
||||
'Create Funder',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
tokens: async function() {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Tokens> ',
|
||||
choices: [
|
||||
'Mint',
|
||||
'Aprove',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
project: async function(id) {
|
||||
return inquirer
|
||||
.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'action',
|
||||
message: 'Project> ' + id,
|
||||
choices: [
|
||||
'Donate/Pledge',
|
||||
// new inquirer.Separator(),
|
||||
// 'Back',
|
||||
// new inquirer.Separator(),
|
||||
// 'Exit'
|
||||
]
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
createProject: async function(defaultAccount) {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'What is the project name?',
|
||||
filter: String,
|
||||
validate: function(value) {
|
||||
return value.length > 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'url',
|
||||
message: 'What is the project url?',
|
||||
default: "status.im",
|
||||
filter: String
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'account',
|
||||
message: 'Address of the project admin?',
|
||||
default: defaultAccount,
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'parentProject',
|
||||
message: 'What is the parent project?',
|
||||
default: 0,
|
||||
filter: Number
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'commitTime',
|
||||
message: 'Time in seconds after which the project owner can access funds',
|
||||
default: 86400,
|
||||
filter: Number
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'plugin',
|
||||
message: 'Plugin address',
|
||||
default: "0x0000000000000000000000000000000000000000",
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
createFunder: async function() {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message: 'What is the funders name?',
|
||||
filter: String,
|
||||
validate: function(value) {
|
||||
return value.length > 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'url',
|
||||
message: 'What is the funders url?',
|
||||
default: "status.im",
|
||||
filter: String
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'commitTime',
|
||||
message: 'commit time',
|
||||
default: 86400,
|
||||
filter: Number
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'plugin',
|
||||
message: 'Plugin address',
|
||||
default: "0x0000000000000000000000000000000000000000",
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
}
|
||||
])
|
||||
},
|
||||
|
||||
mintToken: async function() {
|
||||
return inquirer.prompt([
|
||||
{
|
||||
type: 'input',
|
||||
name: 'tokenAddress',
|
||||
message: 'What is the token address?',
|
||||
filter: String,
|
||||
validate: function(value) {
|
||||
return value.indexOf("0x") === 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'account',
|
||||
message: 'What account to mint?',
|
||||
filter: String
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'amount',
|
||||
message: 'amount (in ether units)',
|
||||
default: 2,
|
||||
filter: Number
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = menus;
|
293
src/ui.js
293
src/ui.js
@ -1,293 +0,0 @@
|
||||
require("colors");
|
||||
const blessed = require("neo-blessed");
|
||||
const Events = require("events");
|
||||
|
||||
class UI {
|
||||
|
||||
constructor(options) {
|
||||
this.events = new Events();
|
||||
|
||||
this.color = options.color || "green";
|
||||
this.minimal = options.minimal || false;
|
||||
|
||||
this.screen = blessed.screen({
|
||||
autoPadding: true,
|
||||
dockBorders: false,
|
||||
fullUnicode: true,
|
||||
smartCSR: true,
|
||||
title: options.title || ("StatusX"),
|
||||
});
|
||||
|
||||
this.layoutLog();
|
||||
this.layoutUsers();
|
||||
this.layoutChannels();
|
||||
this.layoutCmd();
|
||||
this.layoutState();
|
||||
|
||||
this.screen.key(["C-c"], () => {
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
this.logEntry = this.logEntry.bind(this);
|
||||
this.availableUsers = this.availableUsers.bind(this);
|
||||
this.availableChannels = this.availableChannels.bind(this);
|
||||
|
||||
this.screen.render();
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
availableUsers(users) {
|
||||
const stateColors = {
|
||||
off: "grey",
|
||||
on: "green",
|
||||
};
|
||||
|
||||
const userList = Object.keys(users).map((user) => {
|
||||
const userObj = users[user];
|
||||
if (userObj.status in stateColors) {
|
||||
const color = stateColors[userObj.status];
|
||||
return userObj.name[color];
|
||||
}
|
||||
return userObj.name;
|
||||
});
|
||||
|
||||
this.users.setContent(userList.join("\n"));
|
||||
this.screen.render();
|
||||
}
|
||||
|
||||
availableChannels(channels) {
|
||||
this.channels.setContent(channels.map((c, i) => `(${i}) ${c}`).join("\n"));
|
||||
this.screen.render();
|
||||
}
|
||||
|
||||
setStatus(status) {
|
||||
this.operations.setContent(status);
|
||||
this.screen.render();
|
||||
}
|
||||
|
||||
logEntry() {
|
||||
this.logText.log(arguments);
|
||||
this.screen.render();
|
||||
}
|
||||
|
||||
layoutLog() {
|
||||
this.log = blessed.box({
|
||||
border: {
|
||||
type: "line",
|
||||
},
|
||||
height: "92%",
|
||||
label: "Logs",
|
||||
left: "12%",
|
||||
padding: 1,
|
||||
style: {
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
fg: -1,
|
||||
},
|
||||
top: "0%",
|
||||
width: "68%",
|
||||
});
|
||||
|
||||
this.logText = blessed.log({
|
||||
alwaysScroll: true,
|
||||
// height: "90%",
|
||||
input: false,
|
||||
keys: false,
|
||||
mouse: true,
|
||||
parent: this.log,
|
||||
scrollable: true,
|
||||
scrollbar: {
|
||||
ch: " ",
|
||||
inverse: true,
|
||||
},
|
||||
tags: true,
|
||||
vi: false,
|
||||
width: "100%-5",
|
||||
});
|
||||
|
||||
this.screen.append(this.log);
|
||||
}
|
||||
|
||||
layoutUsers() {
|
||||
this.wrapper = blessed.layout({
|
||||
height: "100%",
|
||||
layout: "grid",
|
||||
left: "80%",
|
||||
top: "0%",
|
||||
width: "20%",
|
||||
});
|
||||
|
||||
this.users = blessed.box({
|
||||
alwaysScroll: true,
|
||||
border: {
|
||||
type: "line",
|
||||
},
|
||||
height: "95%",
|
||||
label: "Users",
|
||||
padding: this.minimal ? {
|
||||
left: 1,
|
||||
} : 1,
|
||||
parent: this.wrapper,
|
||||
scrollable: true,
|
||||
scrollbar: {
|
||||
ch: " ",
|
||||
inverse: true,
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
fg: -1,
|
||||
},
|
||||
tags: true,
|
||||
valign: "top",
|
||||
width: "100%",
|
||||
});
|
||||
|
||||
this.screen.append(this.wrapper);
|
||||
}
|
||||
|
||||
layoutChannels() {
|
||||
|
||||
this.wrapper = blessed.layout({
|
||||
height: "100%",
|
||||
layout: "grid",
|
||||
left: "0%",
|
||||
top: "0%",
|
||||
width: "12%",
|
||||
});
|
||||
|
||||
this.channels = blessed.box({
|
||||
alwaysScroll: true,
|
||||
border: {
|
||||
type: "line",
|
||||
},
|
||||
height: "95%",
|
||||
label: "Channels",
|
||||
padding: this.minimal ? {
|
||||
left: 1,
|
||||
} : 1,
|
||||
parent: this.wrapper,
|
||||
scrollable: true,
|
||||
scrollbar: {
|
||||
ch: " ",
|
||||
inverse: true,
|
||||
},
|
||||
style: {
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
fg: -1,
|
||||
},
|
||||
tags: true,
|
||||
valign: "top",
|
||||
width: "100%",
|
||||
});
|
||||
|
||||
this.screen.append(this.wrapper);
|
||||
}
|
||||
|
||||
layoutCmd() {
|
||||
this.consoleBox = blessed.box({
|
||||
border: {
|
||||
type: "line",
|
||||
},
|
||||
height: "6%",
|
||||
label: "Messages",
|
||||
left: "0%",
|
||||
padding: 0,
|
||||
style: {
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
fg: "black",
|
||||
},
|
||||
tags: true,
|
||||
top: "95%",
|
||||
width: "100%",
|
||||
});
|
||||
|
||||
this.input = blessed.textbox({
|
||||
height: "50%",
|
||||
input: true,
|
||||
inputOnFocus: true,
|
||||
keys: false,
|
||||
left: 1,
|
||||
name: "input",
|
||||
parent: this.consoleBox,
|
||||
style: {
|
||||
bg: "black",
|
||||
fg: "green",
|
||||
focus: {
|
||||
bg: "black",
|
||||
fg: "green",
|
||||
},
|
||||
},
|
||||
top: 0,
|
||||
width: "100%-2",
|
||||
});
|
||||
|
||||
this.input.key(["C-c"], () => {
|
||||
this.events.emit("exit");
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
this.input.key(["C-w"], () => {
|
||||
this.input.clearValue();
|
||||
this.input.focus();
|
||||
});
|
||||
|
||||
this.input.key("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""), () => {
|
||||
this.events.emit("typing", this.input.value);
|
||||
});
|
||||
|
||||
this.input.on("submit", this.submitCmd.bind(this));
|
||||
|
||||
this.screen.append(this.consoleBox);
|
||||
}
|
||||
|
||||
layoutState() {
|
||||
this.consoleStateContainer = blessed.layout({
|
||||
height: "5%",
|
||||
layout: "grid",
|
||||
left: "12%",
|
||||
top: "92%",
|
||||
width: "68%",
|
||||
});
|
||||
|
||||
this.consoleState = blessed.box({
|
||||
border: {
|
||||
type: "line",
|
||||
},
|
||||
height: "100%",
|
||||
label: "",
|
||||
padding: {
|
||||
left: 1,
|
||||
},
|
||||
parent: this.consoleStateContainer,
|
||||
style: {
|
||||
border: {
|
||||
fg: this.color,
|
||||
},
|
||||
fg: -1,
|
||||
},
|
||||
tags: true,
|
||||
valign: "middle",
|
||||
width: "100%",
|
||||
});
|
||||
|
||||
this.screen.append(this.consoleStateContainer);
|
||||
}
|
||||
|
||||
submitCmd(cmd) {
|
||||
if (cmd !== "") {
|
||||
this.events.emit("cmd", cmd);
|
||||
}
|
||||
this.input.clearValue();
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = UI;
|
Loading…
x
Reference in New Issue
Block a user