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

Function addTransferManagerModule

CLI/commands/transfer_manager.js:267–302  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

265}
266
267async function addTransferManagerModule() {
268 let availableModules = await moduleRegistry.methods.getModulesByTypeAndToken(gbl.constants.MODULES_TYPES.TRANSFER, securityToken.options.address).call();
269 let options = await Promise.all(availableModules.map(async function (m) {
270 let moduleFactoryABI = abis.moduleFactory();
271 let moduleFactory = new web3.eth.Contract(moduleFactoryABI, m);
272 return web3.utils.hexToUtf8(await moduleFactory.methods.name().call());
273 }));
274
275 let index = readlineSync.keyInSelect(options, 'Which Transfer Manager module do you want to add? ', { cancel: 'RETURN' });
276 if (index != -1 && readlineSync.keyInYNStrict(`Are you sure you want to add ${options[index]} module?`)) {
277 let bytes = web3.utils.fromAscii('', 16);
278 switch (options[index]) {
279 case 'CountTransferManager':
280 let maxHolderCount = readlineSync.question('Enter the maximum no. of holders the SecurityToken is allowed to have: ');
281 let configureCountTM = abis.countTransferManager().find(o => o.name === 'configure' && o.type === 'function');
282 bytes = web3.eth.abi.encodeFunctionCall(configureCountTM, [maxHolderCount]);
283 break;
284 case 'PercentageTransferManager':
285 let maxHolderPercentage = toWeiPercentage(readlineSync.question('Enter the maximum amount of tokens in percentage that an investor can hold: ', {
286 limit: function (input) {
287 return (parseInt(input) > 0 && parseInt(input) <= 100);
288 },
289 limitMessage: "Must be greater than 0 and less than 100"
290 }));
291 let allowPercentagePrimaryIssuance = readlineSync.keyInYNStrict(`Do you want to ignore transactions which are part of the primary issuance? `);
292 let configurePercentageTM = abis.percentageTransferManager().find(o => o.name === 'configure' && o.type === 'function');
293 bytes = web3.eth.abi.encodeFunctionCall(configurePercentageTM, [maxHolderPercentage, allowPercentagePrimaryIssuance]);
294 break;
295 }
296 let selectedTMFactoryAddress = await contracts.getModuleFactoryAddressByName(securityToken.options.address, gbl.constants.MODULES_TYPES.TRANSFER, options[index]);
297 let addModuleAction = securityToken.methods.addModule(selectedTMFactoryAddress, bytes, 0, 0);
298 let receipt = await common.sendTransaction(addModuleAction);
299 let event = common.getEventFromLogs(securityToken._jsonInterface, receipt.logs, 'ModuleAdded');
300 console.log(chalk.green(`Module deployed at address: ${event._module}`));
301 }
302}
303
304async function generalTransferManager() {
305 console.log('\n', chalk.blue(`General Transfer Manager at ${currentTransferManager.options.address}`), '\n');

Callers 2

executeAppFunction · 0.85

Calls 1

toWeiPercentageFunction · 0.85

Tested by

no test coverage detected