MCPcopy Create free account
hub / github.com/PolymathNetwork/polymath-core / executeApp

Function executeApp

CLI/commands/sto_manager.js:28–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26let securityToken;
27
28async function executeApp() {
29 let exit = false;
30 while (!exit) {
31 console.log('\n', chalk.blue('STO Manager - Main Menu'), '\n');
32
33 // Show non-archived attached STO modules
34 let stoModules = await getAllModulesByType(gbl.constants.MODULES_TYPES.STO);
35 let nonArchivedModules = stoModules.filter(m => !m.archived);
36 if (nonArchivedModules.length > 0) {
37 console.log(`STO modules attached:`);
38 nonArchivedModules.map(m => console.log(`- ${m.name} at ${m.address}`))
39 } else {
40 console.log(`There are no STO modules attached`);
41 }
42
43 let options = [];
44 if (nonArchivedModules.length > 0) {
45 options.push('Show existing STO information', 'Modify existing STO');
46 }
47 options.push('Add new STO module');
48
49 let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'EXIT' });
50 let optionSelected = index != -1 ? options[index] : 'EXIT';
51 console.log('Selected:', optionSelected, '\n');
52 switch (optionSelected) {
53 case 'Show existing STO information':
54 let stoToShow = selectExistingSTO(nonArchivedModules, true);
55 await showSTO(stoToShow.name, stoToShow.module);
56 break;
57 case 'Modify existing STO':
58 let stoToModify = selectExistingSTO(nonArchivedModules);
59 await modifySTO(stoToModify.name, stoToModify.module);
60 break;
61 case 'Add new STO module':
62 await addSTOModule();
63 break;
64 case 'EXIT':
65 exit = true;
66 break;
67 }
68 }
69};
70
71function selectExistingSTO(stoModules, showPaused) {
72 let filteredModules = stoModules;

Callers 1

sto_manager.jsFile · 0.70

Calls 5

selectExistingSTOFunction · 0.85
showSTOFunction · 0.85
modifySTOFunction · 0.85
addSTOModuleFunction · 0.85
getAllModulesByTypeFunction · 0.70

Tested by

no test coverage detected