From b3715767efac36bff870d6507609213346e7e2eb Mon Sep 17 00:00:00 2001 From: "Pol.Alvarez@BSC" Date: Tue, 27 Feb 2018 16:41:01 +0100 Subject: [PATCH] Cleanup --- bot/index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bot/index.js b/bot/index.js index b9b9d56..21dcadc 100644 --- a/bot/index.js +++ b/bot/index.js @@ -132,19 +132,21 @@ const error = function (errorMessage) { const sendTransaction = function (to, amount, gasPrice) { - var chaind = providers.Provider.chainId.ropsten; + var chainId = providers.Provider.chainId.ropsten; var chainName = providers.networks.ropsten; - if (!config.debug) { + + if (config.realTransaction) { chainId = providers.Provider.chainId.homestead; chainName = providers.networks.homestead; } - var wallet = new Wallet(config.privateKey); + const wallet = new Wallet(config.privateKey); const provider = ethers.providers.getDefaultProvider(chainName); + wallet.provider = provider; + var transaction = { - nonce: 0, gasLimit: config.gasLimit, gasPrice: gasPrice, to: to, @@ -152,10 +154,8 @@ const sendTransaction = function (to, amount, gasPrice) { chainId: chainId }; - var signedTransaction = wallet.sign(transaction); - return new Promise((resolve, reject) => { - wallet.provider.sendTransaction(signedTransaction) + wallet.sendTransaction(transaction) .then(function(hash) { logTransaction(hash); resolve(hash);