diff --git a/bot/index.js b/bot/index.js index f482844..6128ff2 100644 --- a/bot/index.js +++ b/bot/index.js @@ -79,9 +79,9 @@ const getAmount = function (req) { Promise.all([labelPromise, tokenPricePromise]) .then(function (values) { - let label = values[0] - let tokenPrice = values[1] - let amountToPayDollar = config.priceHour * config.bountyLabels[label.name] + const label = values[0] + const tokenPrice = values[1] + const amountToPayDollar = config.priceHour * config.bountyLabels[label.name] resolve(amountToPayDollar / tokenPrice) }) .catch((err) => { @@ -112,8 +112,8 @@ const error = function (errorMessage) { const sendTransaction = async function (to, amount, gasPrice) { - var chainId = providers.Provider.chainId.ropsten - var chainName = providers.networks.ropsten + let chainId = providers.Provider.chainId.ropsten + let chainName = providers.networks.ropsten if (config.realTransaction) { chainId = providers.Provider.chainId.homestead diff --git a/bot/prices.js b/bot/prices.js index 63cc7f6..c938336 100644 --- a/bot/prices.js +++ b/bot/prices.js @@ -22,8 +22,8 @@ const getGasPrice = function () { // we are done, resolve promise with those joined chunks response.on('end', () => { // safeLowWait returns GWei (10^10 Wei). - let jsonBody = JSON.parse(body.join('')) - let gasPriceWei = parseInt(jsonBody['safeLowWait']) * Math.pow(10, 10) + const jsonBody = JSON.parse(body.join('')) + const gasPriceWei = parseInt(jsonBody['safeLowWait']) * Math.pow(10, 10) resolve(gasPriceWei) }) }) @@ -57,8 +57,8 @@ const getTokenPrice = function (token) { response.on('data', (chunk) => body.push(chunk)) // we are done, resolve promise with those joined chunks response.on('end', () => { - let jsonBody = JSON.parse(body.join('')) - let tokenPrice = parseFloat(jsonBody[currency]) + const jsonBody = JSON.parse(body.join('')) + const tokenPrice = parseFloat(jsonBody[currency]) resolve(tokenPrice) }) }) diff --git a/config/index.js b/config/index.js index 03ad5f2..94567eb 100644 --- a/config/index.js +++ b/config/index.js @@ -1,4 +1,4 @@ -var _ = require("lodash") -var defaults = require("./default.js") -var config = require("./" + (process.env.NODE_ENV || "default") + ".js") +const _ = require("lodash") +const defaults = require("./default.js") +const config = require("./" + (process.env.NODE_ENV || "default") + ".js") module.exports = _.merge({}, defaults, config) diff --git a/index.js b/index.js index 255d4f2..2215922 100644 --- a/index.js +++ b/index.js @@ -12,12 +12,12 @@ const bot = require('./bot') const crypto = require('crypto') -var express = require('express'), - cors = require('cors'), - helmet = require('helmet'), - app = express(), - bodyParser = require('body-parser'), - jsonParser = bodyParser.json() +const express = require('express'), + cors = require('cors'), + helmet = require('helmet'), + app = express(), + bodyParser = require('body-parser'), + jsonParser = bodyParser.json() app.use(cors()) app.use(helmet()) diff --git a/test/test_bot.js b/test/test_bot.js index a9d0583..c16b1f2 100644 --- a/test/test_bot.js +++ b/test/test_bot.js @@ -7,10 +7,10 @@ const bot = require('../bot') // status-open-bounty comment from https://github.com/status-im/autobounty/issues/1 -let sob_comment = 'Current balance: 0.000000 ETH\nTokens: SNT: 2500.00 ANT: 25.00\nContract address: 0x3645fe42b1a744ad98cc032c22472388806f86f9\nNetwork: Mainnet\n To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.\nTo fund it, send ETH or ERC20/ERC223 tokens to the contract address.' +const sob_comment = 'Current balance: 0.000000 ETH\nTokens: SNT: 2500.00 ANT: 25.00\nContract address: 0x3645fe42b1a744ad98cc032c22472388806f86f9\nNetwork: Mainnet\n To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.\nTo fund it, send ETH or ERC20/ERC223 tokens to the contract address.' // Fake requests -let requests = [ +const requests = [ { body: { action: 'created', comment: { body: 'Creating my first comment', user: { login: 'randomUser' } } } }, { body: { action: 'edited', comment: { body: 'Editing my comment', user: { login: 'RandomUser' } } } }, { body: { action: 'edited', comment: { body: sob_comment, user: { login: 'status-open-bounty' } } } }, @@ -43,9 +43,9 @@ describe('Bot behavior', function () { it('should return the amount for the issue given the price per hour and the bounty label for this issue', (done) => { bot.getAmount(requests[3]) .then(function (amount) { - let label = 'bounty-s' - let tokenPrice = 0.35 - let priceInDollars = config.priceHour * config.bountyLabels[label] + const label = 'bounty-s' + const tokenPrice = 0.35 + const priceInDollars = config.priceHour * config.bountyLabels[label] expected_amount = priceInDollars / tokenPrice assert.equal(amount, expected_amount) done()