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

Function manageExistingLockups

CLI/commands/transfer_manager.js:2294–2405  ·  view source on GitHub ↗
(lockupName)

Source from the content-addressed store, hash-verified

2292}
2293
2294async function manageExistingLockups(lockupName) {
2295 console.log('\n', chalk.blue(`Lockup ${web3.utils.hexToUtf8(lockupName)}`), '\n');
2296
2297 // Show current data
2298 let currentLockup = await currentTransferManager.methods.getLockUp(lockupName).call();
2299 let investors = await currentTransferManager.methods.getListOfAddresses(lockupName).call();
2300
2301 console.log(`- Amount: ${web3.utils.fromWei(currentLockup.lockupAmount)} ${tokenSymbol}`);
2302 console.log(`- Currently unlocked: ${web3.utils.fromWei(currentLockup.unlockedAmount)} ${tokenSymbol}`);
2303 console.log(`- Start time: ${moment.unix(currentLockup.startTime).format('MMMM Do YYYY, HH:mm:ss')}`);
2304 console.log(`- Lockup period: ${currentLockup.lockUpPeriodSeconds} seconds`);
2305 console.log(`- End time: ${moment.unix(currentLockup.endTime).add(parseInt(currentLockup.lockUpPeriodSeconds)).format('MMMM Do YYYY, HH:mm:ss')}`);
2306 console.log(`- Release frequency: ${currentLockup.releaseFrequencySeconds} senconds`);
2307 console.log(`- Investors: ${investors.length}`);
2308 // ------------------
2309
2310 let options = [
2311 'Modify properties',
2312 'Show investors',
2313 'Add this lockup to investors',
2314 'Remove this lockup from investors',
2315 'Delete this lockup type'
2316 ];
2317
2318 let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'RETURN' });
2319 let optionSelected = index !== -1 ? options[index] : 'RETURN';
2320 console.log('Selected:', optionSelected, '\n');
2321 switch (optionSelected) {
2322 case 'Modify properties':
2323 let lockupAmount = readlineSync.questionInt(`Enter the amount of tokens that will be locked: `);
2324 let minuteFromNow = Math.floor(Date.now() / 1000) + 60;
2325 let startTime = readlineSync.questionInt(`Enter the start time (Unix Epoch time) of the lockup type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow });
2326 let lockUpPeriodSeconds = readlineSync.questionInt(`Enter the total period (seconds) of the lockup type (ten minutes = 600): `, { defaultInput: 600 });
2327 let releaseFrequencySeconds = readlineSync.questionInt(`Enter how often to release a tranche of tokens in seconds (one minute = 60): `, { defaultInput: 60 });
2328 let modifyLockUpTypeAction = currentTransferManager.methods.modifyLockUpType(lockupAmount, startTime, lockUpPeriodSeconds, releaseFrequencySeconds, lockupName);
2329 let modifyLockUpTypeReceipt = await common.sendTransaction(modifyLockUpTypeAction);
2330 let modifyLockUpTypeEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, modifyLockUpTypeReceipt.logs, 'ModifyLockUpType');
2331 console.log(chalk.green(`${web3.utils.hexToUtf8(modifyLockUpTypeEvent._lockupName)} lockup type has been modified successfully!`));
2332 break;
2333 case 'Show investors':
2334 if (investors.length > 0) {
2335 console.log("************ List of investors ************");
2336 investors.map(i => console.log(i));
2337 } else {
2338 console.log(chalk.yellow("There are no investors yet"));
2339 }
2340 break;
2341 case 'Add this lockup to investors':
2342 let investorsToAdd = readlineSync.question(`Enter the addresses of the investors separated by comma (i.e.addr1, addr2, addr3): `, {
2343 limit: function (input) {
2344 return (input !== '' && input.split(",").every(a => web3.utils.isAddress(a)));
2345 },
2346 limitMessage: `All addresses must be valid`
2347 }).split(",");
2348 let addInvestorToLockupAction;
2349 if (investorsToAdd.length === 1) {
2350 addInvestorToLockupAction = currentTransferManager.methods.addLockUpByName(investorsToAdd[0], lockupName);
2351 } else {

Callers 1

lockUpTransferManagerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected