feat: change to generic ERC-20 ABI json file

fix: coinUtils rename import
This commit is contained in:
Sérgio Salgado 2021-06-10 01:43:22 +01:00 committed by Josh Harvey
parent dff407e30e
commit 8e099e3283
36 changed files with 364 additions and 249 deletions

View file

@ -4,7 +4,7 @@ const settingsLoader = require('./settings-loader')
const configManager = require('./config-manager')
const wallet = require('../wallet')
const ticker = require('../ticker')
const { utils } = require('lamassu-coins')
const { utils: coinUtils } = require('lamassu-coins')
const machineLoader = require('../machine-loader')
module.exports = {getFunding}
@ -40,14 +40,14 @@ function fetchMachines () {
}
function computeCrypto (cryptoCode, _balance) {
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
const unitScale = cryptoRec.unitScale
return BN(_balance).shift(-unitScale).round(5)
}
function computeFiat (rate, cryptoCode, _balance) {
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
const unitScale = cryptoRec.unitScale
return BN(_balance).shift(-unitScale).mul(rate).round(5)
@ -61,9 +61,9 @@ function getFunding (_cryptoCode) {
const cryptoCode = _cryptoCode || cryptoCodes[0]
const fiatCode = config.fiatCurrency
const pareCoins = c => _.includes(c.cryptoCode, cryptoCodes)
const cryptoCurrencies = utils.cryptoCurrencies()
const cryptoCurrencies = coinUtils.cryptoCurrencies()
const cryptoDisplays = _.filter(pareCoins, cryptoCurrencies)
const cryptoRec = utils.getCryptoCurrency(cryptoCode)
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
if (!cryptoRec) throw new Error(`Unsupported coin: ${cryptoCode}`)
@ -81,7 +81,7 @@ function getFunding (_cryptoCode) {
const pending = fundingRec.fundingPendingBalance
const fiatPending = computeFiat(rate, cryptoCode, pending)
const fundingAddress = fundingRec.fundingAddress
const fundingAddressUrl = utils.buildUrl(cryptoCode, fundingAddress)
const fundingAddressUrl = coinUtils.buildUrl(cryptoCode, fundingAddress)
return {
cryptoCode,