Merge pull request #766 from josepfo/feat/crypto-units-selector
feat: advanced wallet settings
This commit is contained in:
commit
0881d00594
9 changed files with 222 additions and 47 deletions
|
|
@ -3,11 +3,11 @@ const configManager = require('./new-config-manager')
|
|||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
|
||||
function truncateCrypto (cryptoAtoms, cryptoCode) {
|
||||
const DECIMAL_PLACES = 3
|
||||
const DECIMAL_PLACES = 6
|
||||
if (cryptoAtoms.eq(0)) return cryptoAtoms
|
||||
|
||||
const scale = coinUtils.getCryptoCurrency(cryptoCode).displayScale
|
||||
const scaleFactor = new BN(10).pow(scale)
|
||||
const scale = coinUtils.getCryptoCurrency(cryptoCode).unitScale
|
||||
const scaleFactor = BN(10).pow(scale)
|
||||
|
||||
return new BN(cryptoAtoms).integerValue(BN.ROUND_DOWN).div(scaleFactor)
|
||||
.decimalPlaces(DECIMAL_PLACES).times(scaleFactor)
|
||||
|
|
|
|||
|
|
@ -132,6 +132,10 @@ const getCryptosFromWalletNamespace = config => {
|
|||
|
||||
const getCashInSettings = config => fromNamespace(namespaces.CASH_IN)(config)
|
||||
|
||||
const getCryptoUnits = (crypto, config) => {
|
||||
return getWalletSettings(crypto, config).cryptoUnits
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getWalletSettings,
|
||||
getCashInSettings,
|
||||
|
|
@ -149,5 +153,6 @@ module.exports = {
|
|||
getTriggers,
|
||||
getTriggersAutomation,
|
||||
getCashOut,
|
||||
getCryptosFromWalletNamespace
|
||||
getCryptosFromWalletNamespace,
|
||||
getCryptoUnits
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ function plugins (settings, deviceId) {
|
|||
const cashInCommission = new BN(commissions.cashIn)
|
||||
const cashOutCommission = _.isNumber(commissions.cashOut) ? new BN(commissions.cashOut) : null
|
||||
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
|
||||
const cryptoUnits = configManager.getCryptoUnits(cryptoCode, settings.config)
|
||||
|
||||
return {
|
||||
cryptoCode,
|
||||
|
|
@ -214,13 +215,13 @@ function plugins (settings, deviceId) {
|
|||
cashInFee,
|
||||
cashInCommission,
|
||||
cashOutCommission,
|
||||
cryptoNetwork
|
||||
cryptoNetwork,
|
||||
cryptoUnits
|
||||
}
|
||||
}
|
||||
|
||||
function pollQueries (serialNumber, deviceTime, deviceRec, machineVersion, machineModel) {
|
||||
const localeConfig = configManager.getLocale(deviceId, settings.config)
|
||||
|
||||
const fiatCode = localeConfig.fiatCurrency
|
||||
const cryptoCodes = localeConfig.cryptoCurrencies
|
||||
const timezone = localeConfig.timezone.split(':')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue