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) {
|
||||
return github.getLabels(req)
|
||||
.then(labels => {
|
||||
return github.getLabels(req).then(labels => {
|
||||
if (labels.length === 1) {
|
||||
resolve(labels[0]);
|
||||
} else {
|
||||
@ -50,16 +49,19 @@ const getLabel = function(req) {
|
||||
}
|
||||
|
||||
const getAmount = function(req) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let labelPromise = getLabel(req);
|
||||
let tokenPricePromise = prices.getTokenPrice(config.token);
|
||||
|
||||
let label = getLabel(req);
|
||||
Promise.all([labelPromise, tokenPricePromise]).then(function(values) {
|
||||
let label = values[0];
|
||||
let tockenPrice = values[1];
|
||||
let amountToPayDollar = config.priceHour * config.workHours[label];
|
||||
|
||||
tokenPricePromise
|
||||
.then((tokenPrice) => {return tokenPrice * config.amountToPayInDollars} )
|
||||
.catch((err) => {console.log("TODO-ERROR: Failed token price request throw log error")});
|
||||
// Check how to handle errors when promises does not arrive
|
||||
|
||||
reslove(config.amountToPayDollar/tockenPrice);
|
||||
}).catch(error => {
|
||||
// TODO: Handle error
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const getGasPrice = function(req) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user