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

Function step_launch_STs

CLI/commands/strMigrator.js:278–368  ·  view source on GitHub ↗
(tokens, securityTokenRegistry, tokenAddress)

Source from the content-addressed store, hash-verified

276}
277
278async function step_launch_STs(tokens, securityTokenRegistry, tokenAddress) {
279 if (tokens.length == 0) {
280 console.log(chalk.yellow(`There are no security tokens to migrate!`));
281 } else /*if (readlineSync.keyInYNStrict(`Do you want to migrate ${tokens.length} Security Tokens?`))*/ {
282 let i = 0;
283 let succeed = [];
284 let failed = [];
285 let totalGas = new web3.utils.BN(0);
286 let polymathRegistryAddress = await contracts.polymathRegistry();
287 let STFactoryABI = JSON.parse(require('fs').readFileSync(`${__dirname}/../../build/contracts/STFactory.json`).toString()).abi;
288 let STFactoryAddress = await securityTokenRegistry.methods.getSTFactoryAddress().call();
289 let STFactory = new web3.eth.Contract(STFactoryABI, STFactoryAddress);
290 for (const t of tokens) {
291 console.log(`\n`);
292 console.log(`-------- Migrating token No ${++i}--------`);
293 console.log(`Token symbol: ${t.ticker}`);
294 console.log(`Token old address: ${t.address}`);
295 console.log(``);
296 try {
297 // Deploying 2.0.0 Token
298 let newTokenAddress;
299 if (tokens.length == 1 && typeof tokenAddress !== 'undefined') {
300 if (web3.utils.isAddress(tokenAddress)) {
301 newTokenAddress = tokenAddress;
302 } else {
303 console.log(chalk.red('Given tokenAddress is not an address!!'));
304 process.exit(0);
305 }
306 } else {
307 let deployTokenAction = STFactory.methods.deployToken(t.name, t.ticker, 18, t.details, Issuer.address, t.divisble, polymathRegistryAddress)
308 let deployTokenReceipt = await common.sendTransaction(deployTokenAction, { minNonce: minNonce });
309 minNonce = minNonce + 1;
310 // Instancing Security Token
311 newTokenAddress = deployTokenReceipt.logs[deployTokenReceipt.logs.length - 1].address; //Last log is the ST creation
312 }
313 console.log(chalk.green(`The migrated to 2.0.0 Security Token address is ${newTokenAddress}`));
314 let newTokenABI = abis.securityToken();
315 let newToken = new web3.eth.Contract(newTokenABI, newTokenAddress);
316
317 // Checking if the old Security Token has activity
318 if (t.gmtEvents.length > 0) {
319 // Instancing GeneralTransferManager
320 let gmtABI = abis.generalTransferManager();
321 let gmtAddress = (await newToken.methods.getModulesByName(web3.utils.toHex("GeneralTransferManager")).call())[0];
322 let gmt = new web3.eth.Contract(gmtABI, gmtAddress);
323 // Whitelisting investors
324 for (const gmtEvent of t.gmtEvents) {
325 let modifyWhitelistAction = gmt.methods.modifyWhitelist(
326 gmtEvent._investor,
327 new web3.utils.BN(gmtEvent._fromTime),
328 new web3.utils.BN(gmtEvent._toTime),
329 new web3.utils.BN(gmtEvent._expiryTime),
330 gmtEvent._canBuyFromSTO
331 );
332 let modifyWhitelistReceipt = await common.sendTransaction(modifyWhitelistAction, { minNonce: minNonce });
333 minNonce = minNonce + 1;
334 //totalGas = totalGas.add(new web3.utils.BN(modifyWhitelistReceipt.gasUsed));
335 }

Callers 1

executeAppFunction · 0.85

Calls 1

logTokenResultsFunction · 0.85

Tested by

no test coverage detected