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

Function getAllModules

CLI/commands/token_manager.js:597–636  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

595}
596
597async function getAllModules() {
598 function ModuleInfo(_moduleType, _name, _address, _factoryAddress, _archived, _paused) {
599 this.name = _name;
600 this.type = _moduleType;
601 this.address = _address;
602 this.factoryAddress = _factoryAddress;
603 this.archived = _archived;
604 this.paused = _paused;
605 }
606
607 let modules = [];
608
609 // Iterate over all module types
610 for (let type = 1; type <= 5; type++) {
611 let allModules = await securityToken.methods.getModulesByType(type).call();
612
613 // Iterate over all modules of each type
614 for (let i = 0; i < allModules.length; i++) {
615 try {
616 let details = await securityToken.methods.getModule(allModules[i]).call();
617 let nameTemp = web3.utils.hexToUtf8(details[0]);
618 let pausedTemp = null;
619 if (type == gbl.constants.MODULES_TYPES.STO || type == gbl.constants.MODULES_TYPES.TRANSFER) {
620 let abiTemp = JSON.parse(require('fs').readFileSync(`./build/contracts/${nameTemp}.json`).toString()).abi;
621 let contractTemp = new web3.eth.Contract(abiTemp, details[1]);
622 pausedTemp = await contractTemp.methods.paused().call();
623 }
624 modules.push(new ModuleInfo(type, nameTemp, details[1], details[2], details[3], pausedTemp));
625 } catch (error) {
626 console.log(error);
627 console.log(chalk.red(`
628 *************************
629 Unable to iterate over module type - unexpected error
630 *************************`));
631 }
632 }
633 }
634
635 return modules;
636}
637
638async function initialize(_tokenSymbol) {
639 welcome();

Callers 1

executeAppFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected