From 0ce658e2f6ed21c495c4fe102ef334275b1c2641 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 08:04:47 +0530 Subject: [PATCH 01/12] Added internal nonce management --- CLI/commands/common/common_functions.js | 60 +++++++++++++++++++++++++ CLI/commands/strMigrator.js | 5 ++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/CLI/commands/common/common_functions.js b/CLI/commands/common/common_functions.js index af3cdc8fa..684457dd7 100644 --- a/CLI/commands/common/common_functions.js +++ b/CLI/commands/common/common_functions.js @@ -71,6 +71,9 @@ module.exports = { @@@@@@@@@@#%####%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ `); }, + getNonce: async function(from) { + return (await web3.eth.getTransactionCount(from.address)); + }, sendTransaction: async function (from, action, gasPrice, value, factor) { let contractRegistry = await connect(action._parent.options.jsonInterface, action._parent._address); @@ -126,6 +129,63 @@ module.exports = { ); }); }, + sendTransactionWithNonce: async function (from, action, gasPrice, value, factor, minNonce) { + let contractRegistry = await connect(action._parent.options.jsonInterface, action._parent._address); + + //NOTE this is a condition to verify if the transaction comes from a module or not. + if (contractRegistry.methods.hasOwnProperty('factory')) { + let moduleAddress = await contractRegistry.methods.factory().call(); + let moduleRegistry = await connect(abis.moduleFactory(), moduleAddress) + let parentModule = await moduleRegistry.methods.getName().call(); + let result = await checkPermission(web3.utils.hexToUtf8(parentModule), action._method.name, contractRegistry); + if (!result) { + console.log("You haven't the right permissions to execute this method."); + process.exit(0); + } + } + + if (typeof factor === 'undefined') factor = 1.2; + + let block = await web3.eth.getBlock("latest"); + let networkGasLimit = block.gasLimit; + + let gas = Math.round(factor * (await action.estimateGas({ from: from.address, value: value}))); + if (gas > networkGasLimit) gas = networkGasLimit; + + console.log(chalk.black.bgYellowBright(`---- Transaction executed: ${action._method.name} - Gas limit provided: ${gas} ----`)); + + let nonce = await web3.eth.getTransactionCount(from.address); + if (nonce < minNonce) + nonce = minNonce; + let abi = action.encodeABI(); + let parameter = { + from: from.address, + to: action._parent._address, + data: abi, + gasLimit: gas, + gasPrice: gasPrice, + nonce: nonce, + value: web3.utils.toHex(value) + }; + + const transaction = new Tx(parameter); + transaction.sign(Buffer.from(from.privateKey.replace('0x', ''), 'hex')); + return await web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex')) + .on('transactionHash', function(hash){ + console.log(` + Your transaction is being processed. Please wait... + TxHash: ${hash}` + ); + }) + .on('receipt', function(receipt){ + console.log(` + Congratulations! The transaction was successfully completed. + Gas used: ${receipt.gasUsed} - Gas spent: ${web3.utils.fromWei((new web3.utils.BN(gasPrice)).mul(new web3.utils.BN(receipt.gasUsed)))} Ether + Review it on Etherscan. + TxHash: ${receipt.transactionHash}\n` + ); + }); + }, getEventFromLogs: function (jsonInterface, logs, eventName) { let eventJsonInterface = jsonInterface.find(o => o.name === eventName && o.type === 'event'); let log = logs.find(l => l.topics.includes(eventJsonInterface.signature)); diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index edabfb214..000f55d23 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -7,6 +7,7 @@ var common = require('./common/common_functions'); var global = require('./common/global'); let network; +let minNonce; async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, remoteNetwork) { network = remoteNetwork; @@ -27,6 +28,7 @@ async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTic let fromSecurityTokenRegistry = await step_instance_fromSTR(fromStrAddress); let tokens = await step_get_deployed_tokens(fromSecurityTokenRegistry, singleTicker); await step_launch_STs(tokens, toSecurityTokenRegistry); + minNonce = await common.getNonce(Issuer); } catch (err) { console.log(err); return; @@ -275,7 +277,8 @@ async function step_launch_STs(tokens, securityTokenRegistry) { try { // Deploying 2.0.0 Token let deployTokenAction = STFactory.methods.deployToken(t.name, t.ticker, 18, t.details, Issuer.address, t.divisble, polymathRegistryAddress) - let deployTokenReceipt = await common.sendTransaction(Issuer, deployTokenAction, defaultGasPrice); + let deployTokenReceipt = await common.sendTransactionWithNonce(Issuer, deployTokenAction, defaultGasPrice, minNonce); + minNonce = minNonce.add(1); // Instancing Security Token let newTokenAddress = deployTokenReceipt.logs[deployTokenReceipt.logs.length -1].address; //Last log is the ST creation let newTokenABI = abis.securityToken(); From a376e5e13897b10d9d751a9e92af083eaf1733ca Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 08:11:40 +0530 Subject: [PATCH 02/12] nonce tracking fixed --- CLI/commands/strMigrator.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 000f55d23..6b336e1d6 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -146,7 +146,8 @@ async function step_register_tickers(tickers, securityTokenRegistry) { console.log(``); try { let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); - let receipt = await common.sendTransaction(Issuer, modifyTickerAction, defaultGasPrice); + let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice); + minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); succeed.push(t); } catch (error) { @@ -299,25 +300,29 @@ async function step_launch_STs(tokens, securityTokenRegistry) { new web3.utils.BN(gmtEvent._expiryTime), gmtEvent._canBuyFromSTO ); - let modifyWhitelistReceipt = await common.sendTransaction(Issuer, modifyWhitelistAction, defaultGasPrice); + let modifyWhitelistReceipt = await common.sendTransactionWithNonce(Issuer, modifyWhitelistAction, defaultGasPrice); + minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(modifyWhitelistReceipt.gasUsed)); } // Minting tokens for (const mintedEvent of t.mintedEvents) { let mintAction = newToken.methods.mint(mintedEvent.to, new web3.utils.BN(mintedEvent.value)); - let mintReceipt = await common.sendTransaction(Issuer, mintAction, defaultGasPrice); + let mintReceipt = await common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice); + minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(mintReceipt.gasUsed)); } } // Transferring onweship to the original owner let transferOwnershipAction = newToken.methods.transferOwnership(t.owner); - let transferOwnershipReceipt = await common.sendTransaction(Issuer, transferOwnershipAction, defaultGasPrice); + let transferOwnershipReceipt = await common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice); + minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(transferOwnershipReceipt.gasUsed)); // Adding 2.0.0 Security Token to SecurityTokenRegistry let modifySecurityTokenAction = securityTokenRegistry.methods.modifySecurityToken(t.name, t.ticker, t.owner, newTokenAddress, t.details, t.deployedAt); - let modifySecurityTokenReceipt = await common.sendTransaction(Issuer, modifySecurityTokenAction, defaultGasPrice); + let modifySecurityTokenReceipt = await common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice); + minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(modifySecurityTokenReceipt.gasUsed)); succeed.push(t); From 19caff39d13ff6715518958fe24ef696ccd35761 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 08:13:24 +0530 Subject: [PATCH 03/12] minNonce fixed --- CLI/commands/strMigrator.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 6b336e1d6..4b6d5a622 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -146,7 +146,7 @@ async function step_register_tickers(tickers, securityTokenRegistry) { console.log(``); try { let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); - let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice); + let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); succeed.push(t); @@ -300,14 +300,14 @@ async function step_launch_STs(tokens, securityTokenRegistry) { new web3.utils.BN(gmtEvent._expiryTime), gmtEvent._canBuyFromSTO ); - let modifyWhitelistReceipt = await common.sendTransactionWithNonce(Issuer, modifyWhitelistAction, defaultGasPrice); + let modifyWhitelistReceipt = await common.sendTransactionWithNonce(Issuer, modifyWhitelistAction, defaultGasPrice, minNonce); minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(modifyWhitelistReceipt.gasUsed)); } // Minting tokens for (const mintedEvent of t.mintedEvents) { let mintAction = newToken.methods.mint(mintedEvent.to, new web3.utils.BN(mintedEvent.value)); - let mintReceipt = await common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice); + let mintReceipt = await common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice, minNonce); minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(mintReceipt.gasUsed)); } @@ -315,13 +315,13 @@ async function step_launch_STs(tokens, securityTokenRegistry) { // Transferring onweship to the original owner let transferOwnershipAction = newToken.methods.transferOwnership(t.owner); - let transferOwnershipReceipt = await common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice); + let transferOwnershipReceipt = await common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice, minNonce); minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(transferOwnershipReceipt.gasUsed)); // Adding 2.0.0 Security Token to SecurityTokenRegistry let modifySecurityTokenAction = securityTokenRegistry.methods.modifySecurityToken(t.name, t.ticker, t.owner, newTokenAddress, t.details, t.deployedAt); - let modifySecurityTokenReceipt = await common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice); + let modifySecurityTokenReceipt = await common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice, minNonce); minNonce = minNonce.add(1); totalGas = totalGas.add(new web3.utils.BN(modifySecurityTokenReceipt.gasUsed)); From 79e45f00f195faa2f256eef468fbad831a320a19 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 08:20:05 +0530 Subject: [PATCH 04/12] Nonce not BN --- CLI/commands/strMigrator.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 4b6d5a622..c47a073f2 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -147,7 +147,8 @@ async function step_register_tickers(tickers, securityTokenRegistry) { try { let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); - minNonce = minNonce.add(1); + console.log(minNonce); + minNonce = minNonce + 1; totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); succeed.push(t); } catch (error) { @@ -279,7 +280,7 @@ async function step_launch_STs(tokens, securityTokenRegistry) { // Deploying 2.0.0 Token let deployTokenAction = STFactory.methods.deployToken(t.name, t.ticker, 18, t.details, Issuer.address, t.divisble, polymathRegistryAddress) let deployTokenReceipt = await common.sendTransactionWithNonce(Issuer, deployTokenAction, defaultGasPrice, minNonce); - minNonce = minNonce.add(1); + minNonce = minNonce + 1; // Instancing Security Token let newTokenAddress = deployTokenReceipt.logs[deployTokenReceipt.logs.length -1].address; //Last log is the ST creation let newTokenABI = abis.securityToken(); @@ -301,14 +302,14 @@ async function step_launch_STs(tokens, securityTokenRegistry) { gmtEvent._canBuyFromSTO ); let modifyWhitelistReceipt = await common.sendTransactionWithNonce(Issuer, modifyWhitelistAction, defaultGasPrice, minNonce); - minNonce = minNonce.add(1); + minNonce = minNonce + 1; totalGas = totalGas.add(new web3.utils.BN(modifyWhitelistReceipt.gasUsed)); } // Minting tokens for (const mintedEvent of t.mintedEvents) { let mintAction = newToken.methods.mint(mintedEvent.to, new web3.utils.BN(mintedEvent.value)); let mintReceipt = await common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice, minNonce); - minNonce = minNonce.add(1); + minNonce = minNonce + 1; totalGas = totalGas.add(new web3.utils.BN(mintReceipt.gasUsed)); } } @@ -316,13 +317,13 @@ async function step_launch_STs(tokens, securityTokenRegistry) { // Transferring onweship to the original owner let transferOwnershipAction = newToken.methods.transferOwnership(t.owner); let transferOwnershipReceipt = await common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice, minNonce); - minNonce = minNonce.add(1); + minNonce = minNonce + 1; totalGas = totalGas.add(new web3.utils.BN(transferOwnershipReceipt.gasUsed)); // Adding 2.0.0 Security Token to SecurityTokenRegistry let modifySecurityTokenAction = securityTokenRegistry.methods.modifySecurityToken(t.name, t.ticker, t.owner, newTokenAddress, t.details, t.deployedAt); let modifySecurityTokenReceipt = await common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice, minNonce); - minNonce = minNonce.add(1); + minNonce = minNonce + 1; totalGas = totalGas.add(new web3.utils.BN(modifySecurityTokenReceipt.gasUsed)); succeed.push(t); From e9cc330f44f97f173c2c208d0993f573f1f4b819 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 08:37:39 +0530 Subject: [PATCH 05/12] None init fixed --- CLI/commands/strMigrator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index c47a073f2..3bd378c24 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -21,6 +21,8 @@ async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTic console.log("Issuer Account: " + Issuer.address + "\n"); try { + minNonce = await common.getNonce(Issuer); + console.log(minNonce); let toSecurityTokenRegistry = await step_instance_toSTR(toStrAddress); let fromTickerRegistry = await step_instance_fromTR(fromTrAddress); let tickers = await step_get_registered_tickers(fromTickerRegistry, singleTicker); @@ -28,7 +30,6 @@ async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTic let fromSecurityTokenRegistry = await step_instance_fromSTR(fromStrAddress); let tokens = await step_get_deployed_tokens(fromSecurityTokenRegistry, singleTicker); await step_launch_STs(tokens, toSecurityTokenRegistry); - minNonce = await common.getNonce(Issuer); } catch (err) { console.log(err); return; From 620ff1819d4c6b879e389b27508876d4bbaec76c Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 09:13:49 +0530 Subject: [PATCH 06/12] Send function fixed --- CLI/commands/common/common_functions.js | 6 ++++-- CLI/commands/strMigrator.js | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CLI/commands/common/common_functions.js b/CLI/commands/common/common_functions.js index 684457dd7..8f8f3242e 100644 --- a/CLI/commands/common/common_functions.js +++ b/CLI/commands/common/common_functions.js @@ -129,7 +129,7 @@ module.exports = { ); }); }, - sendTransactionWithNonce: async function (from, action, gasPrice, value, factor, minNonce) { + sendTransactionWithNonce: async function (from, action, gasPrice, minNonce, value, factor) { let contractRegistry = await connect(action._parent.options.jsonInterface, action._parent._address); //NOTE this is a condition to verify if the transaction comes from a module or not. @@ -155,8 +155,10 @@ module.exports = { console.log(chalk.black.bgYellowBright(`---- Transaction executed: ${action._method.name} - Gas limit provided: ${gas} ----`)); let nonce = await web3.eth.getTransactionCount(from.address); - if (nonce < minNonce) + + if (nonce < minNonce) { nonce = minNonce; + } let abi = action.encodeABI(); let parameter = { from: from.address, diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 3bd378c24..43a7a0de5 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -22,7 +22,6 @@ async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTic try { minNonce = await common.getNonce(Issuer); - console.log(minNonce); let toSecurityTokenRegistry = await step_instance_toSTR(toStrAddress); let fromTickerRegistry = await step_instance_fromTR(fromTrAddress); let tickers = await step_get_registered_tickers(fromTickerRegistry, singleTicker); From 65b3a78bbf947df25b9d9c0ebaec45df1dc350f5 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 11 Nov 2018 19:28:06 +0530 Subject: [PATCH 07/12] await Optimizations --- CLI/commands/common/common_functions.js | 10 +++++++--- CLI/commands/common/global.js | 2 +- CLI/commands/strMigrator.js | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CLI/commands/common/common_functions.js b/CLI/commands/common/common_functions.js index 8f8f3242e..2e6c01ffe 100644 --- a/CLI/commands/common/common_functions.js +++ b/CLI/commands/common/common_functions.js @@ -72,7 +72,7 @@ module.exports = { `); }, getNonce: async function(from) { - return (await web3.eth.getTransactionCount(from.address)); + return (await web3.eth.getTransactionCount(from.address, "pending")); }, sendTransaction: async function (from, action, gasPrice, value, factor) { let contractRegistry = await connect(action._parent.options.jsonInterface, action._parent._address); @@ -94,8 +94,12 @@ module.exports = { let block = await web3.eth.getBlock("latest"); let networkGasLimit = block.gasLimit; - let gas = Math.round(factor * (await action.estimateGas({ from: from.address, value: value}))); - if (gas > networkGasLimit) gas = networkGasLimit; + try { + let gas = Math.round(factor * (await action.estimateGas({ from: from.address, value: value}))); + if (gas > networkGasLimit) gas = networkGasLimit; + } catch(exception) { + gas = networkGasLimit; + } console.log(chalk.black.bgYellowBright(`---- Transaction executed: ${action._method.name} - Gas limit provided: ${gas} ----`)); diff --git a/CLI/commands/common/global.js b/CLI/commands/common/global.js index fb898a708..c9653f658 100644 --- a/CLI/commands/common/global.js +++ b/CLI/commands/common/global.js @@ -13,7 +13,7 @@ function getGasPrice (networkId) { gasPrice = 50000000000; break; case 42: //Kovan - gasPrice = 50000000000; + gasPrice = 5000000000; break; default: throw new Error('Network ID not identified'); diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 43a7a0de5..dac208d87 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -146,10 +146,10 @@ async function step_register_tickers(tickers, securityTokenRegistry) { console.log(``); try { let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); - let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); + let receipt = common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); console.log(minNonce); minNonce = minNonce + 1; - totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); + //totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); succeed.push(t); } catch (error) { failed.push(t); @@ -303,30 +303,31 @@ async function step_launch_STs(tokens, securityTokenRegistry) { ); let modifyWhitelistReceipt = await common.sendTransactionWithNonce(Issuer, modifyWhitelistAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; - totalGas = totalGas.add(new web3.utils.BN(modifyWhitelistReceipt.gasUsed)); + //totalGas = totalGas.add(new web3.utils.BN(modifyWhitelistReceipt.gasUsed)); } // Minting tokens for (const mintedEvent of t.mintedEvents) { let mintAction = newToken.methods.mint(mintedEvent.to, new web3.utils.BN(mintedEvent.value)); - let mintReceipt = await common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice, minNonce); + let mintReceipt = common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; - totalGas = totalGas.add(new web3.utils.BN(mintReceipt.gasUsed)); + //totalGas = totalGas.add(new web3.utils.BN(mintReceipt.gasUsed)); } } // Transferring onweship to the original owner let transferOwnershipAction = newToken.methods.transferOwnership(t.owner); - let transferOwnershipReceipt = await common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice, minNonce); + let transferOwnershipReceipt = common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; - totalGas = totalGas.add(new web3.utils.BN(transferOwnershipReceipt.gasUsed)); + //totalGas = totalGas.add(new web3.utils.BN(transferOwnershipReceipt.gasUsed)); // Adding 2.0.0 Security Token to SecurityTokenRegistry let modifySecurityTokenAction = securityTokenRegistry.methods.modifySecurityToken(t.name, t.ticker, t.owner, newTokenAddress, t.details, t.deployedAt); - let modifySecurityTokenReceipt = await common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice, minNonce); + let modifySecurityTokenReceipt = common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; - totalGas = totalGas.add(new web3.utils.BN(modifySecurityTokenReceipt.gasUsed)); + //totalGas = totalGas.add(new web3.utils.BN(modifySecurityTokenReceipt.gasUsed)); succeed.push(t); + console.log('done'); } catch (error) { failed.push(t); console.log(chalk.red(`Transaction failed!!! `)) From 7ba482f7c166a25dc9b5d6d058e3d0ac2b22e5c9 Mon Sep 17 00:00:00 2001 From: Victor Vicente Date: Sun, 11 Nov 2018 12:40:54 -0300 Subject: [PATCH 08/12] Skip token deployment if the ST address is known --- CLI/commands/strMigrator.js | 40 ++++++++++++++++++++++++------------- CLI/polymath-cli.js | 3 ++- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 54d8191c3..bb084bc35 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -9,7 +9,7 @@ var global = require('./common/global'); let network; let minNonce; -async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, remoteNetwork) { +async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, remoteNetwork) { network = remoteNetwork; await global.initialize(remoteNetwork); @@ -23,12 +23,14 @@ async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTic try { minNonce = await common.getNonce(Issuer); let toSecurityTokenRegistry = await step_instance_toSTR(toStrAddress); - let fromTickerRegistry = await step_instance_fromTR(fromTrAddress); - let tickers = await step_get_registered_tickers(fromTickerRegistry, singleTicker); - await step_register_tickers(tickers, toSecurityTokenRegistry); + if (typeof tokenAddress === 'undefined') { + let fromTickerRegistry = await step_instance_fromTR(fromTrAddress); + let tickers = await step_get_registered_tickers(fromTickerRegistry, singleTicker); + await step_register_tickers(tickers, toSecurityTokenRegistry); + } let fromSecurityTokenRegistry = await step_instance_fromSTR(fromStrAddress); let tokens = await step_get_deployed_tokens(fromSecurityTokenRegistry, singleTicker); - await step_launch_STs(tokens, toSecurityTokenRegistry); + await step_launch_STs(tokens, toSecurityTokenRegistry, tokenAddress); } catch (err) { console.log(err); return; @@ -259,7 +261,7 @@ async function step_get_deployed_tokens(securityTokenRegistry, singleTicker) { return tokens; } -async function step_launch_STs(tokens, securityTokenRegistry) { +async function step_launch_STs(tokens, securityTokenRegistry, tokenAddress) { if (tokens.length == 0) { console.log(chalk.yellow(`There are no security tokens to migrate!`)); } else if (readlineSync.keyInYNStrict(`Do you want to migrate ${tokens.length} Security Tokens?`)) { @@ -275,15 +277,25 @@ async function step_launch_STs(tokens, securityTokenRegistry) { console.log(`\n`); console.log(`-------- Migrating token No ${++i}--------`); console.log(`Token symbol: ${t.ticker}`); - console.log(`Token address: ${t.address}`); + console.log(`Token old address: ${t.address}`); console.log(``); try { // Deploying 2.0.0 Token - let deployTokenAction = STFactory.methods.deployToken(t.name, t.ticker, 18, t.details, Issuer.address, t.divisble, polymathRegistryAddress) - let deployTokenReceipt = await common.sendTransactionWithNonce(Issuer, deployTokenAction, defaultGasPrice, minNonce); - minNonce = minNonce + 1; - // Instancing Security Token - let newTokenAddress = deployTokenReceipt.logs[deployTokenReceipt.logs.length -1].address; //Last log is the ST creation + let newTokenAddress; + if (tokens.length == 1 && typeof tokenAddress !== 'undefined') { + if (web3.utils.isAddress(tokenAddress)) { + newTokenAddress = tokenAddress; + } else { + console.log(chalk.red('Given tokenAddress is not an address!!')); + process.exit(0); + } + } else { + let deployTokenAction = STFactory.methods.deployToken(t.name, t.ticker, 18, t.details, Issuer.address, t.divisble, polymathRegistryAddress) + let deployTokenReceipt = await common.sendTransactionWithNonce(Issuer, deployTokenAction, defaultGasPrice, minNonce); + minNonce = minNonce + 1; + // Instancing Security Token + newTokenAddress = deployTokenReceipt.logs[deployTokenReceipt.logs.length -1].address; //Last log is the ST creation + } console.log(chalk.green(`The migrated to 2.0.0 Security Token address is ${newTokenAddress}`)); let newTokenABI = abis.securityToken(); let newToken = new web3.eth.Contract(newTokenABI, newTokenAddress); @@ -424,7 +436,7 @@ async function getBlockfromEtherscan(_blockNumber) { } module.exports = { - executeApp: async function(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, remoteNetwork) { - return executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, remoteNetwork); + executeApp: async function(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, remoteNetwork) { + return executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, remoteNetwork); } }; \ No newline at end of file diff --git a/CLI/polymath-cli.js b/CLI/polymath-cli.js index d9e7b9fd4..ceb370ca0 100644 --- a/CLI/polymath-cli.js +++ b/CLI/polymath-cli.js @@ -138,10 +138,11 @@ program program .command('strMigrator [toStrAddress] [fromTrAddress] [fromStrAddress]') .option('-tick, --singleTicker ', 'It only reads and migrates the ticker and token for given token symbol') + .option('-tok, --tokenAddress ', 'Migrated security token address. It skips all steps until modifySecurityToken') .alias('str') .description('Runs STR Migrator') .action(async function(toStrAddress, fromTrAddress, fromStrAddress, cmd) { - await strMigrator.executeApp(toStrAddress, fromTrAddress, fromStrAddress, cmd.singleTicker, program.remoteNode); + await strMigrator.executeApp(toStrAddress, fromTrAddress, fromStrAddress, cmd.singleTicker, cmd.tokenAddress, program.remoteNode); }); program From 7ba6c5861d7bd6bc2c94bc7ef5ee63957fbbb0c3 Mon Sep 17 00:00:00 2001 From: Pablo Ruiz Date: Mon, 12 Nov 2018 00:19:58 -0300 Subject: [PATCH 09/12] migrator fixes --- CLI/commands/common/global.js | 2 +- CLI/commands/strMigrator.js | 55 ++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/CLI/commands/common/global.js b/CLI/commands/common/global.js index 8953d171d..1285766df 100644 --- a/CLI/commands/common/global.js +++ b/CLI/commands/common/global.js @@ -4,7 +4,7 @@ function getGasPrice (networkId) { let gasPrice; switch (networkId) { case 1: //Mainnet - gasPrice = 30000000000; + gasPrice = 20000000000; break; case 3: //Ropsten gasPrice = 50000000000; diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index bb084bc35..502c3ce60 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -47,12 +47,13 @@ async function step_instance_toSTR(toStrAddress){ return; } } else { - _toStrAddress = readlineSync.question('Enter the new SecurityTokenRegistry address to migrate TO: ', { - limit: function(input) { - return web3.utils.isAddress(input); - }, - limitMessage: "Must be a valid address" - }); + // _toStrAddress = readlineSync.question('Enter the new SecurityTokenRegistry address to migrate TO: ', { + // limit: function(input) { + // return web3.utils.isAddress(input); + // }, + // limitMessage: "Must be a valid address" + // }); + _toStrAddress = "0x240f9f86b1465bf1b8eb29bc88cbf65573dfdd97"; } console.log(`Creating SecurityTokenRegistry contract instance of address: ${_toStrAddress}...`); @@ -73,12 +74,13 @@ async function step_instance_fromTR(fromTrAddress){ return; } } else { - _fromTrAddress = readlineSync.question('Enter the old TikcerRegistry address to migrate FROM: ', { - limit: function(input) { - return web3.utils.isAddress(input); - }, - limitMessage: "Must be a valid address" - }); + // _fromTrAddress = readlineSync.question('Enter the old TikcerRegistry address to migrate FROM: ', { + // limit: function(input) { + // return web3.utils.isAddress(input); + // }, + // limitMessage: "Must be a valid address" + // }); + _fromTrAddress = "0xc31714e6759a1ee26db1d06af1ed276340cd4233"; } console.log(`Creating TickerRegistry contract instance of address: ${_fromTrAddress}...`); @@ -136,7 +138,7 @@ async function step_get_registered_tickers(tickerRegistry, singleTicker) { async function step_register_tickers(tickers, securityTokenRegistry) { if (tickers.length == 0) { console.log(chalk.yellow(`There are no tickers to migrate!`)); - } else if (readlineSync.keyInYNStrict(`Do you want to migrate ${tickers.length} Tickers?`)) { +} else /*if (readlineSync.keyInYNStrict(`Do you want to migrate ${tickers.length} Tickers?`)) */{ let i = 0; let succeed = []; let failed = []; @@ -148,7 +150,7 @@ async function step_register_tickers(tickers, securityTokenRegistry) { console.log(``); try { let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); - let receipt = common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); + let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); console.log(minNonce); minNonce = minNonce + 1; //totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); @@ -174,12 +176,13 @@ async function step_instance_fromSTR(fromStrAddress){ return; } } else { - _fromStrAddress = readlineSync.question('Enter the old SecurityTokenRegistry address to migrate FROM: ', { - limit: function(input) { - return web3.utils.isAddress(input); - }, - limitMessage: "Must be a valid address" - }); + // _fromStrAddress = readlineSync.question('Enter the old SecurityTokenRegistry address to migrate FROM: ', { + // limit: function(input) { + // return web3.utils.isAddress(input); + // }, + // limitMessage: "Must be a valid address" + // }); + _fromStrAddress = "0xef58491224958d978facf55d2120c55a24516b98"; } console.log(`Creating SecurityTokenRegistry contract instance of address: ${_fromStrAddress}...`); @@ -264,7 +267,7 @@ async function step_get_deployed_tokens(securityTokenRegistry, singleTicker) { async function step_launch_STs(tokens, securityTokenRegistry, tokenAddress) { if (tokens.length == 0) { console.log(chalk.yellow(`There are no security tokens to migrate!`)); - } else if (readlineSync.keyInYNStrict(`Do you want to migrate ${tokens.length} Security Tokens?`)) { +} else /*if (readlineSync.keyInYNStrict(`Do you want to migrate ${tokens.length} Security Tokens?`))*/ { let i = 0; let succeed = []; let failed = []; @@ -291,7 +294,7 @@ async function step_launch_STs(tokens, securityTokenRegistry, tokenAddress) { } } else { let deployTokenAction = STFactory.methods.deployToken(t.name, t.ticker, 18, t.details, Issuer.address, t.divisble, polymathRegistryAddress) - let deployTokenReceipt = await common.sendTransactionWithNonce(Issuer, deployTokenAction, defaultGasPrice, minNonce); + let deployTokenReceipt = await common.sendTransactionWithNonce(Issuer, deployTokenAction, 25000000000, minNonce); minNonce = minNonce + 1; // Instancing Security Token newTokenAddress = deployTokenReceipt.logs[deployTokenReceipt.logs.length -1].address; //Last log is the ST creation @@ -321,8 +324,8 @@ async function step_launch_STs(tokens, securityTokenRegistry, tokenAddress) { } // Minting tokens for (const mintedEvent of t.mintedEvents) { - let mintAction = newToken.methods.mint(mintedEvent.to, new web3.utils.BN(mintedEvent.value)); - let mintReceipt = common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice, minNonce); + let mintAction = newToken.methods.mint(mintedEvent.to, new web3.utils.BN(mintedEvent.amount)); + let mintReceipt = await common.sendTransactionWithNonce(Issuer, mintAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; //totalGas = totalGas.add(new web3.utils.BN(mintReceipt.gasUsed)); } @@ -330,13 +333,13 @@ async function step_launch_STs(tokens, securityTokenRegistry, tokenAddress) { // Transferring onweship to the original owner let transferOwnershipAction = newToken.methods.transferOwnership(t.owner); - let transferOwnershipReceipt = common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice, minNonce); + let transferOwnershipReceipt = await common.sendTransactionWithNonce(Issuer, transferOwnershipAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; //totalGas = totalGas.add(new web3.utils.BN(transferOwnershipReceipt.gasUsed)); // Adding 2.0.0 Security Token to SecurityTokenRegistry let modifySecurityTokenAction = securityTokenRegistry.methods.modifySecurityToken(t.name, t.ticker, t.owner, newTokenAddress, t.details, t.deployedAt); - let modifySecurityTokenReceipt = common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice, minNonce); + let modifySecurityTokenReceipt = await common.sendTransactionWithNonce(Issuer, modifySecurityTokenAction, defaultGasPrice, minNonce); minNonce = minNonce + 1; //totalGas = totalGas.add(new web3.utils.BN(modifySecurityTokenReceipt.gasUsed)); From 9a92f7e92e43c25989f7f3f36abaf589d4f3ff1e Mon Sep 17 00:00:00 2001 From: Victor Vicente Date: Mon, 12 Nov 2018 09:45:39 -0300 Subject: [PATCH 10/12] Only tickers option --- CLI/commands/strMigrator.js | 70 ++++++++++++++++++++----------------- CLI/polymath-cli.js | 3 +- 2 files changed, 40 insertions(+), 33 deletions(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 502c3ce60..1d11f883a 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -9,7 +9,7 @@ var global = require('./common/global'); let network; let minNonce; -async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, remoteNetwork) { +async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, onlyTickers, remoteNetwork) { network = remoteNetwork; await global.initialize(remoteNetwork); @@ -25,12 +25,14 @@ async function executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTic let toSecurityTokenRegistry = await step_instance_toSTR(toStrAddress); if (typeof tokenAddress === 'undefined') { let fromTickerRegistry = await step_instance_fromTR(fromTrAddress); - let tickers = await step_get_registered_tickers(fromTickerRegistry, singleTicker); + let tickers = await step_get_registered_tickers(fromTickerRegistry, singleTicker, onlyTickers); await step_register_tickers(tickers, toSecurityTokenRegistry); } - let fromSecurityTokenRegistry = await step_instance_fromSTR(fromStrAddress); - let tokens = await step_get_deployed_tokens(fromSecurityTokenRegistry, singleTicker); - await step_launch_STs(tokens, toSecurityTokenRegistry, tokenAddress); + if (typeof onlyTickers === 'undefined') { + let fromSecurityTokenRegistry = await step_instance_fromSTR(fromStrAddress); + let tokens = await step_get_deployed_tokens(fromSecurityTokenRegistry, singleTicker); + await step_launch_STs(tokens, toSecurityTokenRegistry, tokenAddress); + } } catch (err) { console.log(err); return; @@ -91,7 +93,7 @@ async function step_instance_fromTR(fromTrAddress){ return fromTR; } -async function step_get_registered_tickers(tickerRegistry, singleTicker) { +async function step_get_registered_tickers(tickerRegistry, singleTicker, onlyTickers) { let tickers = []; let expiryTime = await tickerRegistry.methods.expiryLimit().call(); @@ -103,30 +105,33 @@ async function step_get_registered_tickers(tickerRegistry, singleTicker) { let event = common.getEventFromLogs(tickerRegistry._jsonInterface, [log], 'LogRegisterTicker'); if (typeof singleTicker === 'undefined' || event._symbol == singleTicker) { let details = await tickerRegistry.methods.getDetails(event._symbol).call(); - let expiredTicker = details[0] == '0x0000000000000000000000000000000000000000'; - let _symbol = event._symbol; - let _owner = expiredTicker ? event._owner : details[0]; - let _name = expiredTicker ? event._name : details[2]; - let _registrationDate = expiredTicker ? event._timestamp : details[1]; let _status = details[4]; - - console.log(`------------ Ticker Registered ------------`); - console.log(`Ticker: ${_symbol}`); - console.log(`Owner: ${_owner}`); - console.log(`Token name: ${_name}`); - console.log(`Timestamp: ${_registrationDate}`); - console.log(`Transaction hash: ${log.transactionHash}`); - console.log(`-------------------------------------------`); - console.log(`\n`); - - tickers.push({ - ticker: _symbol, - owner: _owner, - name: _name, - registrationDate: new web3.utils.BN(_registrationDate), - expiryDate: new web3.utils.BN(_registrationDate).add(new web3.utils.BN(expiryTime)), - status: _status - }); + if (typeof onlyTickers === 'undefined' || (onlyTickers && !_status)) { + let expiredTicker = details[0] == '0x0000000000000000000000000000000000000000'; + let _symbol = event._symbol; + let _owner = expiredTicker ? event._owner : details[0]; + let _name = expiredTicker ? event._name : details[2]; + let _registrationDate = expiredTicker ? event._timestamp : details[1]; + + + console.log(`------------ Ticker Registered ------------`); + console.log(`Ticker: ${_symbol}`); + console.log(`Owner: ${_owner}`); + console.log(`Token name: ${_name}`); + console.log(`Timestamp: ${_registrationDate}`); + console.log(`Transaction hash: ${log.transactionHash}`); + console.log(`-------------------------------------------`); + console.log(`\n`); + + tickers.push({ + ticker: _symbol, + owner: _owner, + name: _name, + registrationDate: new web3.utils.BN(_registrationDate), + expiryDate: new web3.utils.BN(_registrationDate).add(new web3.utils.BN(expiryTime)), + status: _status + }); + } } } } @@ -134,7 +139,8 @@ async function step_get_registered_tickers(tickerRegistry, singleTicker) { console.log(chalk.yellow(`${tickers.length} tickers found!`)); return tickers; } - +//0x240f9f86b1465bf1b8eb29bc88cbf65573dfdd97 +//0xc31714e6759a1ee26db1d06af1ed276340cd4233 async function step_register_tickers(tickers, securityTokenRegistry) { if (tickers.length == 0) { console.log(chalk.yellow(`There are no tickers to migrate!`)); @@ -439,7 +445,7 @@ async function getBlockfromEtherscan(_blockNumber) { } module.exports = { - executeApp: async function(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, remoteNetwork) { - return executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, remoteNetwork); + executeApp: async function(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, onlyTickers, remoteNetwork) { + return executeApp(toStrAddress, fromTrAddress, fromStrAddress, singleTicker, tokenAddress, onlyTickers, remoteNetwork); } }; \ No newline at end of file diff --git a/CLI/polymath-cli.js b/CLI/polymath-cli.js index ceb370ca0..a4d912c82 100644 --- a/CLI/polymath-cli.js +++ b/CLI/polymath-cli.js @@ -139,10 +139,11 @@ program .command('strMigrator [toStrAddress] [fromTrAddress] [fromStrAddress]') .option('-tick, --singleTicker ', 'It only reads and migrates the ticker and token for given token symbol') .option('-tok, --tokenAddress ', 'Migrated security token address. It skips all steps until modifySecurityToken') + .option('-ot, --onlyTickers', 'Only migrate tickers without a launched token') .alias('str') .description('Runs STR Migrator') .action(async function(toStrAddress, fromTrAddress, fromStrAddress, cmd) { - await strMigrator.executeApp(toStrAddress, fromTrAddress, fromStrAddress, cmd.singleTicker, cmd.tokenAddress, program.remoteNode); + await strMigrator.executeApp(toStrAddress, fromTrAddress, fromStrAddress, cmd.singleTicker, cmd.tokenAddress, cmd.onlyTickers, program.remoteNode); }); program From 23995919a7b2fc5135a5fc15459b2595e76bd03e Mon Sep 17 00:00:00 2001 From: Victor Vicente Date: Mon, 12 Nov 2018 11:13:21 -0300 Subject: [PATCH 11/12] Possibility to skip tickers --- CLI/commands/strMigrator.js | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 1d11f883a..913d851c8 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -139,8 +139,7 @@ async function step_get_registered_tickers(tickerRegistry, singleTicker, onlyTic console.log(chalk.yellow(`${tickers.length} tickers found!`)); return tickers; } -//0x240f9f86b1465bf1b8eb29bc88cbf65573dfdd97 -//0xc31714e6759a1ee26db1d06af1ed276340cd4233 + async function step_register_tickers(tickers, securityTokenRegistry) { if (tickers.length == 0) { console.log(chalk.yellow(`There are no tickers to migrate!`)); @@ -149,22 +148,26 @@ async function step_register_tickers(tickers, securityTokenRegistry) { let succeed = []; let failed = []; let totalGas = new web3.utils.BN(0); + let migrateAll = false; for (const t of tickers) { - console.log(`\n`); - console.log(`-------- Migrating ticker No ${++i}--------`); - console.log(`Ticker: ${t.ticker}`); - console.log(``); - try { - let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); - let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); - console.log(minNonce); - minNonce = minNonce + 1; - //totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); - succeed.push(t); - } catch (error) { - failed.push(t); - console.log(chalk.red(`Transaction failed!!! `)) - console.log(error); + if (migrateAll || readlineSync.keyInYNStrict(`Do you want to migrate ${t.ticker}?`)) { + migrateAll = readlineSync.keyInYNStrict(`Do you want to migrate all tickers from here?`) + console.log(`\n`); + console.log(`-------- Migrating ticker No ${++i}--------`); + console.log(`Ticker: ${t.ticker}`); + console.log(``); + try { + let modifyTickerAction = securityTokenRegistry.methods.modifyTicker(t.owner, t.ticker, t.name, t.registrationDate, t.expiryDate, false); + let receipt = await common.sendTransactionWithNonce(Issuer, modifyTickerAction, defaultGasPrice, minNonce); + console.log(minNonce); + minNonce = minNonce + 1; + //totalGas = totalGas.add(new web3.utils.BN(receipt.gasUsed)); + succeed.push(t); + } catch (error) { + failed.push(t); + console.log(chalk.red(`Transaction failed!!! `)) + console.log(error); + } } } From 5650ed88d077a24318fc09f9c00ac2b543b889c2 Mon Sep 17 00:00:00 2001 From: Victor Vicente Date: Mon, 12 Nov 2018 11:37:56 -0300 Subject: [PATCH 12/12] Fix --- CLI/commands/strMigrator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CLI/commands/strMigrator.js b/CLI/commands/strMigrator.js index 913d851c8..4951f680d 100644 --- a/CLI/commands/strMigrator.js +++ b/CLI/commands/strMigrator.js @@ -151,7 +151,9 @@ async function step_register_tickers(tickers, securityTokenRegistry) { let migrateAll = false; for (const t of tickers) { if (migrateAll || readlineSync.keyInYNStrict(`Do you want to migrate ${t.ticker}?`)) { - migrateAll = readlineSync.keyInYNStrict(`Do you want to migrate all tickers from here?`) + if (!migrateAll) { + migrateAll = readlineSync.keyInYNStrict(`Do you want to migrate all tickers from here?`) + } console.log(`\n`); console.log(`-------- Migrating ticker No ${++i}--------`); console.log(`Ticker: ${t.ticker}`);