()
| 2202 | } |
| 2203 | |
| 2204 | async function lockUpTransferManager() { |
| 2205 | console.log('\n', chalk.blue(`Lockup Transfer Manager at ${currentTransferManager.options.address}`), '\n'); |
| 2206 | |
| 2207 | let currentLockups = await currentTransferManager.methods.getAllLockups().call(); |
| 2208 | console.log(`- Lockups: ${currentLockups.length}`); |
| 2209 | |
| 2210 | let options = ['Add new lockup']; |
| 2211 | if (currentLockups.length > 0) { |
| 2212 | options.push('Manage existing lockups', 'Explore investor'); |
| 2213 | } |
| 2214 | options.push('Operate with multiple lockups'); |
| 2215 | |
| 2216 | let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'RETURN' }); |
| 2217 | let optionSelected = index !== -1 ? options[index] : 'RETURN'; |
| 2218 | console.log('Selected:', optionSelected, '\n'); |
| 2219 | switch (optionSelected) { |
| 2220 | case 'Add new lockup': |
| 2221 | let name = readlineSync.question(`Enter the name of the lockup type: `, { |
| 2222 | limit: function (input) { |
| 2223 | return input !== ""; |
| 2224 | }, |
| 2225 | limitMessage: `Invalid lockup name` |
| 2226 | }); |
| 2227 | let lockupAmount = readlineSync.questionInt(`Enter the amount of tokens that will be locked: `); |
| 2228 | let minuteFromNow = Math.floor(Date.now() / 1000) + 60; |
| 2229 | let startTime = readlineSync.questionInt(`Enter the start time (Unix Epoch time) of the lockup type (a minute from now = ${minuteFromNow}): `, { defaultInput: minuteFromNow }); |
| 2230 | let lockUpPeriodSeconds = readlineSync.questionInt(`Enter the total period (seconds) of the lockup type (ten minutes = 600): `, { defaultInput: 600 }); |
| 2231 | let releaseFrequencySeconds = readlineSync.questionInt(`Enter how often to release a tranche of tokens in seconds (one minute = 60): `, { defaultInput: 60 }); |
| 2232 | if (readlineSync.keyInYNStrict(`Do you want to add an investor to this lockup type? `)) { |
| 2233 | let investor = readlineSync.question(`Enter the address of the investor: `, { |
| 2234 | limit: function (input) { |
| 2235 | return web3.utils.isAddress(input); |
| 2236 | }, |
| 2237 | limitMessage: `Must be a valid address` |
| 2238 | }); |
| 2239 | let addNewLockUpToUserAction = currentTransferManager.methods.addNewLockUpToUser( |
| 2240 | investor, |
| 2241 | web3.utils.toWei(lockupAmount.toString()), |
| 2242 | startTime, |
| 2243 | lockUpPeriodSeconds, |
| 2244 | releaseFrequencySeconds, |
| 2245 | web3.utils.toHex(name) |
| 2246 | ); |
| 2247 | let addNewLockUpToUserReceipt = await common.sendTransaction(addNewLockUpToUserAction); |
| 2248 | let addNewLockUpToUserEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, addNewLockUpToUserReceipt.logs, 'AddNewLockUpType'); |
| 2249 | console.log(chalk.green(`${web3.utils.hexToUtf8(addNewLockUpToUserEvent._lockupName)} lockup type has been added successfully!`)); |
| 2250 | let addLockUpToUserEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, addNewLockUpToUserReceipt.logs, 'AddLockUpToUser'); |
| 2251 | console.log(chalk.green(`${addLockUpToUserEvent._userAddress} has been added to ${web3.utils.hexToUtf8(addLockUpToUserEvent._lockupName)} successfully!`)); |
| 2252 | } else { |
| 2253 | let addLockupTypeAction = currentTransferManager.methods.addNewLockUpType(web3.utils.toWei(lockupAmount.toString()), startTime, lockUpPeriodSeconds, releaseFrequencySeconds, web3.utils.toHex(name)); |
| 2254 | let addLockupTypeReceipt = await common.sendTransaction(addLockupTypeAction); |
| 2255 | let addLockupTypeEvent = common.getEventFromLogs(currentTransferManager._jsonInterface, addLockupTypeReceipt.logs, 'AddNewLockUpType'); |
| 2256 | console.log(chalk.green(`${web3.utils.hexToUtf8(addLockupTypeEvent._lockupName)} lockup type has been added successfully!`)); |
| 2257 | } |
| 2258 | break; |
| 2259 | case 'Manage existing lockups': |
| 2260 | let options = currentLockups.map(b => web3.utils.hexToUtf8(b)); |
| 2261 | let index = readlineSync.keyInSelect(options, 'Which lockup type do you want to manage? ', { cancel: 'RETURN' }); |
no test coverage detected