fix: unexpected displayScale usage in txs operations

This commit is contained in:
José Oliveira 2021-06-26 02:05:03 +01:00
parent 9ec7f6f296
commit 168257bcc4

View file

@ -3,11 +3,11 @@ const configManager = require('./new-config-manager')
const { utils: coinUtils } = require('lamassu-coins') const { utils: coinUtils } = require('lamassu-coins')
function truncateCrypto (cryptoAtoms, cryptoCode) { function truncateCrypto (cryptoAtoms, cryptoCode) {
const DECIMAL_PLACES = 3 const DECIMAL_PLACES = 6
if (cryptoAtoms.eq(0)) return cryptoAtoms if (cryptoAtoms.eq(0)) return cryptoAtoms
const scale = coinUtils.getCryptoCurrency(cryptoCode).displayScale const scale = coinUtils.getCryptoCurrency(cryptoCode).unitScale
const scaleFactor = new BN(10).pow(scale) const scaleFactor = BN(10).pow(scale)
return new BN(cryptoAtoms).integerValue(BN.ROUND_DOWN).div(scaleFactor) return new BN(cryptoAtoms).integerValue(BN.ROUND_DOWN).div(scaleFactor)
.decimalPlaces(DECIMAL_PLACES).times(scaleFactor) .decimalPlaces(DECIMAL_PLACES).times(scaleFactor)