()
| 158 | // HELPER FUNCTIONS // |
| 159 | ////////////////////// |
| 160 | async function selectTicker() { |
| 161 | let result; |
| 162 | let userTickers = (await securityTokenRegistry.methods.getTickersByOwner(Issuer.address).call()).map(t => web3.utils.hexToAscii(t)); |
| 163 | let options = await Promise.all(userTickers.map(async function (t) { |
| 164 | let tickerDetails = await securityTokenRegistry.methods.getTickerDetails(t).call(); |
| 165 | let tickerInfo; |
| 166 | if (tickerDetails[4]) { |
| 167 | tickerInfo = `Token launched at ${(await securityTokenRegistry.methods.getSecurityTokenAddress(t).call())}`; |
| 168 | } else { |
| 169 | tickerInfo = `Expires at ${moment.unix(tickerDetails[2]).format('MMMM Do YYYY, HH:mm:ss')}`; |
| 170 | } |
| 171 | return `${t} |
| 172 | ${tickerInfo}`; |
| 173 | })); |
| 174 | options.push('Register a new ticker'); |
| 175 | |
| 176 | let index = readlineSync.keyInSelect(options, 'Select a ticker:'); |
| 177 | if (index == -1) { |
| 178 | process.exit(0); |
| 179 | } else if (index == options.length - 1) { |
| 180 | result = readlineSync.question('Enter a symbol for your new ticker: '); |
| 181 | } else { |
| 182 | result = userTickers[index]; |
| 183 | } |
| 184 | |
| 185 | return result; |
| 186 | } |
| 187 | |
| 188 | async function approvePoly(spender, fee) { |
| 189 | polyBalance = await polyToken.methods.balanceOf(Issuer.address).call(); |
no outgoing calls
no test coverage detected