()
| 54 | let currentTransferManager; |
| 55 | |
| 56 | async function executeApp() { |
| 57 | console.log('\n', chalk.blue('Transfer Manager - Main Menu', '\n')); |
| 58 | |
| 59 | let tmModules = await getAllModulesByType(gbl.constants.MODULES_TYPES.TRANSFER); |
| 60 | let nonArchivedModules = tmModules.filter(m => !m.archived); |
| 61 | if (nonArchivedModules.length > 0) { |
| 62 | console.log(`Transfer Manager modules attached:`); |
| 63 | nonArchivedModules.map(m => console.log(`- ${m.name} at ${m.address}`)) |
| 64 | } else { |
| 65 | console.log(`There are no Transfer Manager modules attached`); |
| 66 | } |
| 67 | |
| 68 | let options = ['Verify transfer', 'Transfer']; |
| 69 | let forcedTransferDisabled = await securityToken.methods.controllerDisabled().call(); |
| 70 | if (!forcedTransferDisabled) { |
| 71 | options.push('Forced transfers'); |
| 72 | } |
| 73 | if (nonArchivedModules.length > 0) { |
| 74 | options.push('Config existing modules'); |
| 75 | } |
| 76 | options.push('Add new Transfer Manager module'); |
| 77 | |
| 78 | let index = readlineSync.keyInSelect(options, 'What do you want to do?', { cancel: 'EXIT' }); |
| 79 | let optionSelected = index != -1 ? options[index] : 'EXIT'; |
| 80 | console.log('Selected:', optionSelected, '\n'); |
| 81 | switch (optionSelected) { |
| 82 | case 'Verify transfer': |
| 83 | let verifyTotalSupply = web3.utils.fromWei(await securityToken.methods.totalSupply().call()); |
| 84 | await logTotalInvestors(); |
| 85 | let verifyTransferFrom = readlineSync.question(`Enter the sender account (${Issuer.address}): `, { |
| 86 | limit: function (input) { |
| 87 | return web3.utils.isAddress(input); |
| 88 | }, |
| 89 | limitMessage: "Must be a valid address", |
| 90 | defaultInput: Issuer.address |
| 91 | }); |
| 92 | await logBalance(verifyTransferFrom, verifyTotalSupply); |
| 93 | let verifyTransferTo = readlineSync.question('Enter the receiver account: ', { |
| 94 | limit: function (input) { |
| 95 | return web3.utils.isAddress(input); |
| 96 | }, |
| 97 | limitMessage: "Must be a valid address", |
| 98 | }); |
| 99 | await logBalance(verifyTransferTo, verifyTotalSupply); |
| 100 | let verifyTransferAmount = readlineSync.question('Enter amount of tokens to verify: '); |
| 101 | let isVerified = await securityToken.methods.verifyTransfer(verifyTransferFrom, verifyTransferTo, web3.utils.toWei(verifyTransferAmount), web3.utils.fromAscii("")).call(); |
| 102 | if (isVerified) { |
| 103 | console.log(chalk.green(`\n${verifyTransferAmount} ${tokenSymbol} can be transferred from ${verifyTransferFrom} to ${verifyTransferTo}!`)); |
| 104 | } else { |
| 105 | console.log(chalk.red(`\n${verifyTransferAmount} ${tokenSymbol} can't be transferred from ${verifyTransferFrom} to ${verifyTransferTo}!`)); |
| 106 | } |
| 107 | break; |
| 108 | case 'Transfer': |
| 109 | let totalSupply = web3.utils.fromWei(await securityToken.methods.totalSupply().call()); |
| 110 | await logTotalInvestors(); |
| 111 | await logBalance(Issuer.address, totalSupply); |
| 112 | let transferTo = readlineSync.question('Enter beneficiary of tranfer: ', { |
| 113 | limit: function (input) { |
no test coverage detected