mirror of
https://github.com/status-im/autobounty.git
synced 2025-01-12 06:44:55 +00:00
Prefer const and let instead of var
This commit is contained in:
parent
1429a1af7b
commit
83df18e9d8
10
bot/index.js
10
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
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
@ -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)
|
||||
|
12
index.js
12
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())
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user