()
| 71 | } |
| 72 | |
| 73 | async function registerTickers() { |
| 74 | // Poly approval for registration fees |
| 75 | let polyBalance = BigNumber(await polyToken.methods.balanceOf(Issuer.address).call()); |
| 76 | let fee = web3.utils.fromWei(await securityTokenRegistry.methods.getTickerRegistrationFee().call()); |
| 77 | let totalFee = BigNumber(ticker_data.length).mul(fee); |
| 78 | |
| 79 | if (totalFee.gt(polyBalance)) { |
| 80 | console.log(chalk.red(`\n*******************************************************************************`)); |
| 81 | console.log(chalk.red(`Not enough POLY to pay registration fee. Require ${totalFee.div(10 ** 18).toNumber()} POLY but have ${polyBalance.div(10 ** 18).toNumber()} POLY.`)); |
| 82 | console.log(chalk.red(`*******************************************************************************\n`)); |
| 83 | process.exit(0); |
| 84 | } else { |
| 85 | let approveAction = polyToken.methods.approve(securityTokenRegistryAddress, totalFee); |
| 86 | let receipt = await common.sendTransaction(approveAction); |
| 87 | totalGas = totalGas.add(receipt.gasUsed); |
| 88 | } |
| 89 | |
| 90 | for (var i = 0; i < ticker_data.length; i++) { |
| 91 | let valid = true; |
| 92 | let owner; |
| 93 | |
| 94 | // validate owner |
| 95 | if (web3.utils.isAddress(ticker_data[i].owner)) { |
| 96 | owner = web3.utils.toChecksumAddress(ticker_data[i].owner); |
| 97 | } else { |
| 98 | failed_tickers.push(` ${i} has invalid owner address`); |
| 99 | valid = false; |
| 100 | } |
| 101 | |
| 102 | // validate ticker |
| 103 | await securityTokenRegistry.methods.getTickerDetails(ticker_data[i].symbol).call({}, function (error, result) { |
| 104 | if (result[1] != 0) { |
| 105 | failed_tickers.push(` ${i} is already registered`); |
| 106 | valid = false; |
| 107 | } |
| 108 | }); |
| 109 | |
| 110 | if (valid) { |
| 111 | try { |
| 112 | let registerTickerAction = securityTokenRegistry.methods.registerTicker(owner, ticker_data[i].symbol, ticker_data[i].name); |
| 113 | let receipt = await common.sendTransaction(registerTickerAction); |
| 114 | registered_tickers.push(ticker_data[i]); |
| 115 | console.log(ticker_data[i]); |
| 116 | totalGas = totalGas.add(receipt.gasUsed); |
| 117 | } catch (error) { |
| 118 | failed_tickers.push(` ${i} is ${error}`); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | await logResults(); |
| 123 | } |
| 124 | |
| 125 | async function logResults() { |
| 126 | console.log(` |
no test coverage detected