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

Function selectToken

CLI/commands/dividends_manager.js:854–882  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

852}
853
854async function selectToken() {
855 let result = null;
856
857 let userTokens = await securityTokenRegistry.methods.getTokensByOwner(Issuer.address).call();
858 let tokenDataArray = await Promise.all(userTokens.map(async function (t) {
859 let tokenData = await securityTokenRegistry.methods.getSecurityTokenData(t).call();
860 return { symbol: tokenData[0], address: t };
861 }));
862 let options = tokenDataArray.map(function (t) {
863 return `${t.symbol} - Deployed at ${t.address} `;
864 });
865 options.push('Enter token symbol manually');
866
867 let index = readlineSync.keyInSelect(options, 'Select a token:', { cancel: 'Exit' });
868 let selected = index != -1 ? options[index] : 'Exit';
869 switch (selected) {
870 case 'Enter token symbol manually':
871 result = readlineSync.question('Enter the token symbol: ');
872 break;
873 case 'Exit':
874 process.exit();
875 break;
876 default:
877 result = tokenDataArray[index].symbol;
878 break;
879 }
880
881 return result;
882}
883
884module.exports = {
885 executeApp: async function (_tokenSymbol) {

Callers 1

initializeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected