Merge pull request #968 from chaotixkilla/feat-implement-pazuz-ticker

Implement pazuz ticker
This commit is contained in:
Rafael Taranto 2022-05-11 16:07:16 +01:00 committed by GitHub
commit 1b44a40903

View file

@ -0,0 +1,28 @@
const https = require('https')
const axios = require('axios').create({
// TODO: get rejectUnauthorized true to work
baseURL: `${process.env.TICKER_URL}/api/rates/`,
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
})
const BN = require('../../../bn')
function ticker (account, fiatCode, cryptoCode) {
return axios.get(`${cryptoCode}/${fiatCode}`)
.then(({ data }) => {
if (data.error) throw new Error(JSON.stringify(data.error))
return {
rates: {
ask: BN(data.ask),
bid: BN(data.bid),
signature: data.signature
}
}
})
}
module.exports = {
ticker
}