From d200f0860b1bd21a65a964ccaafebe6d7cf9cd33 Mon Sep 17 00:00:00 2001 From: "Pol.Alvarez@BSC" Date: Tue, 27 Feb 2018 16:10:18 +0100 Subject: [PATCH] Cleanup for testing --- bot/index.js | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bot/index.js b/bot/index.js index 4285353..44fc3a5 100644 --- a/bot/index.js +++ b/bot/index.js @@ -3,6 +3,7 @@ const winston = require('winston'); const ethers = require('ethers'); const Wallet = ethers.Wallet; const providers = ethers.providers; +const utils = ethers.utils; const prices = require('./prices'); const config = require('../config'); @@ -112,8 +113,8 @@ const getAmount = function (req) { const logTransaction = function (tx) { logger.info("[OK] Succesfully funded bounty with transaction " + tx.hash); logger.info(" * From: " + tx.from); - logger.info(" * To: " + to); - logger.info(" * Amount: " + amount); + logger.info(" * To: " + tx.to); + logger.info(" * Amount: " + tx.value); logger.info(" * Gas Price: " + tx.gasPrice); logger.info("===================================================="); } @@ -129,30 +130,34 @@ const error = function (errorMessage) { -const sendTransaction = function (to, amount, gasPrice) { +const sendTransaction = function (to, amount, gvar chainId = providers.Provider.chainId.ropsten; - const wallet = new Wallet(config.privateKey); - if (config.debug){ - wallet.provider = ethers.providers.getDefaultProvider('ropsten'); - } else { - wallet.provider = ethers.providers.getDefaultProvider('metropolis'); + var chaind = providers.Provider.chainId.ropsten; + var chainName = providers.networks.ropsten; + if (!config.debug) { + chainId = providers.Provider.chainId.homestead; + chainName = providers.networks.homestead; } + var wallet = new Wallet(config.privateKey); + const provider = ethers.providers.getDefaultProvider(chainName); - const transaction = { + + var transaction = { nonce: 0, gasLimit: config.gasLimit, gasPrice: gasPrice, to: to, value: amount, + chainId: chainId }; - const signedTransaction = wallet.sign(transaction); + var signedTransaction = wallet.sign(transaction); return new Promise((resolve, reject) => { wallet.provider.sendTransaction(signedTransaction) .then(function(hash) { - logTransaction(hash, config.sourceAddress, to, amount, gasPrice); + logTransaction(hash); resolve(hash); }).catch(function(err) { reject(err);