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

Function selectToken

CLI/commands/token_manager.js:665–693  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

663}
664
665async function selectToken() {
666 let result = null;
667
668 let userTokens = await securityTokenRegistry.methods.getTokensByOwner(Issuer.address).call();
669 let tokenDataArray = await Promise.all(userTokens.map(async function (t) {
670 let tokenData = await securityTokenRegistry.methods.getSecurityTokenData(t).call();
671 return { symbol: tokenData[0], address: t };
672 }));
673 let options = tokenDataArray.map(function (t) {
674 return `${t.symbol} - Deployed at ${t.address}`;
675 });
676 options.push('Enter token symbol manually');
677
678 let index = readlineSync.keyInSelect(options, 'Select a token:', { cancel: 'Exit' });
679 let selected = index != -1 ? options[index] : 'Exit';
680 switch (selected) {
681 case 'Enter token symbol manually':
682 result = readlineSync.question('Enter the token symbol: ');
683 break;
684 case 'Exit':
685 process.exit();
686 break;
687 default:
688 result = tokenDataArray[index].symbol;
689 break;
690 }
691
692 return result;
693}
694
695module.exports = {
696 executeApp: async function (_tokenSymbol) {

Callers 1

initializeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected