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

Function selectToken

CLI/commands/sto_manager.js:1070–1098  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1068}
1069
1070async function selectToken() {
1071 let result = null;
1072
1073 let userTokens = await securityTokenRegistry.methods.getTokensByOwner(Issuer.address).call();
1074 let tokenDataArray = await Promise.all(userTokens.map(async function (t) {
1075 let tokenData = await securityTokenRegistry.methods.getSecurityTokenData(t).call();
1076 return { symbol: tokenData[0], address: t };
1077 }));
1078 let options = tokenDataArray.map(function (t) {
1079 return `${t.symbol} - Deployed at ${t.address}`;
1080 });
1081 options.push('Enter token symbol manually');
1082
1083 let index = readlineSync.keyInSelect(options, 'Select a token:', { cancel: 'EXIT' });
1084 let selected = index != -1 ? options[index] : 'EXIT';
1085 switch (selected) {
1086 case 'Enter token symbol manually':
1087 result = readlineSync.question('Enter the token symbol: ');
1088 break;
1089 case 'Exit':
1090 process.exit();
1091 break;
1092 default:
1093 result = tokenDataArray[index].symbol;
1094 break;
1095 }
1096
1097 return result;
1098}
1099
1100module.exports = {
1101 executeApp: async function (_tokenSymbol) {

Callers 1

initializeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected