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

Function executeApp

CLI/commands/dividends_manager.js:24–68  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22let dividendsType;
23
24async function executeApp() {
25 console.log('\n', chalk.blue('Dividends Manager - Main Menu', '\n'));
26
27 let tmModules = await getAllModulesByType(gbl.constants.MODULES_TYPES.DIVIDENDS);
28 let nonArchivedModules = tmModules.filter(m => !m.archived);
29 if (nonArchivedModules.length > 0) {
30 console.log(`Dividends modules attached:`);
31 nonArchivedModules.map(m => console.log(`- ${m.name} at ${m.address}`))
32 } else {
33 console.log(`There are no dividends modules attached`);
34 }
35
36 let currentCheckpoint = await securityToken.methods.currentCheckpointId().call();
37 if (currentCheckpoint > 0) {
38 console.log(`\nCurrent checkpoint: ${currentCheckpoint}`);
39 }
40
41 let options = ['Create checkpoint', 'Explore address balances'];
42 if (nonArchivedModules.length > 0) {
43 options.push('Config existing modules');
44 }
45 options.push('Add new dividends module');
46
47 let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'EXIT' });
48 let optionSelected = index != -1 ? options[index] : 'EXIT';
49 console.log('Selected:', optionSelected, '\n');
50 switch (optionSelected) {
51 case 'Create checkpoint':
52 await createCheckpointFromST();
53 break;
54 case 'Explore address balances':
55 await exploreAddress(currentCheckpoint);
56 break;
57 case 'Config existing modules':
58 await configExistingModules(nonArchivedModules);
59 break;
60 case 'Add new dividends module':
61 await addDividendsModule();
62 break;
63 case 'EXIT':
64 return;
65 }
66
67 await executeApp();
68}
69
70async function createCheckpointFromST() {
71 let createCheckpointAction = securityToken.methods.createCheckpoint();

Callers 1

Calls 5

createCheckpointFromSTFunction · 0.85
exploreAddressFunction · 0.85
addDividendsModuleFunction · 0.85
getAllModulesByTypeFunction · 0.70
configExistingModulesFunction · 0.70

Tested by

no test coverage detected