mirror of
https://github.com/status-im/autobounty.git
synced 2025-02-05 18:23:22 +00:00
Merge branch 'config' of https://github.com/jomsdev/autobounty into config
This commit is contained in:
commit
bcb7b939c8
20
bot/index.js
20
bot/index.js
@ -37,8 +37,7 @@ const getAddress = function(req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getLabel = function(req) {
|
const getLabel = function(req) {
|
||||||
return github.getLabels(req)
|
return github.getLabels(req).then(labels => {
|
||||||
.then(labels => {
|
|
||||||
if (labels.length === 1) {
|
if (labels.length === 1) {
|
||||||
resolve(labels[0]);
|
resolve(labels[0]);
|
||||||
} else {
|
} else {
|
||||||
@ -50,16 +49,19 @@ const getLabel = function(req) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getAmount = function(req) {
|
const getAmount = function(req) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let labelPromise = getLabel(req);
|
||||||
let tokenPricePromise = prices.getTokenPrice(config.token);
|
let tokenPricePromise = prices.getTokenPrice(config.token);
|
||||||
|
Promise.all([labelPromise, tokenPricePromise]).then(function(values) {
|
||||||
let label = getLabel(req);
|
let label = values[0];
|
||||||
|
let tockenPrice = values[1];
|
||||||
let amountToPayDollar = config.priceHour * config.workHours[label];
|
let amountToPayDollar = config.priceHour * config.workHours[label];
|
||||||
|
|
||||||
tokenPricePromise
|
reslove(config.amountToPayDollar/tockenPrice);
|
||||||
.then((tokenPrice) => {return tokenPrice * config.amountToPayInDollars} )
|
}).catch(error => {
|
||||||
.catch((err) => {console.log("TODO-ERROR: Failed token price request throw log error")});
|
// TODO: Handle error
|
||||||
// Check how to handle errors when promises does not arrive
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const getGasPrice = function(req) {
|
const getGasPrice = function(req) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user