chore: integrate new admin with l-s

This commit is contained in:
Taranto 2020-05-06 22:11:55 +01:00
parent 6b3db134e7
commit bf8f1d991c
72 changed files with 1493 additions and 1611 deletions

View file

@ -1,11 +1,10 @@
const _ = require('lodash/fp')
const BN = require('../bn')
const settingsLoader = require('../settings-loader')
const configManager = require('../config-manager')
const settingsLoader = require('../new-settings-loader')
const configManager = require('../new-config-manager')
const wallet = require('../wallet')
const ticker = require('../ticker')
const coinUtils = require('../coin-utils')
const machineLoader = require('../machine-loader')
function allScopes (cryptoScopes, machineScopes) {
const scopes = []
@ -25,18 +24,6 @@ function allMachineScopes (machineList, machineScope) {
return machineScopes
}
function getCryptos (config, machineList) {
const scopes = allScopes(['global'], allMachineScopes(machineList, 'both'))
const scoped = scope => configManager.scopedValue(scope[0], scope[1], 'cryptoCurrencies', config)
return _.uniq(_.flatten(_.map(scoped, scopes)))
}
function fetchMachines () {
return machineLoader.getMachines()
.then(machineList => machineList.map(r => r.deviceId))
}
function computeCrypto (cryptoCode, _balance) {
const cryptoRec = coinUtils.getCryptoCurrency(cryptoCode)
const unitScale = cryptoRec.unitScale
@ -82,11 +69,9 @@ function getSingleCoinFunding (settings, fiatCode, cryptoCode) {
}
function getFunding () {
return Promise.all([settingsLoader.loadLatest(), fetchMachines()])
.then(([settings, machineList]) => {
const config = configManager.unscoped(settings.config)
const cryptoCodes = getCryptos(settings.config, machineList)
const fiatCode = config.fiatCurrency
return settingsLoader.loadLatest().then(settings => {
const cryptoCodes = configManager.getAllCryptoCurrencies(settings.config)
const fiatCode = configManager.getGlobalLocale(settings.config).fiatCurrency
const pareCoins = c => _.includes(c.cryptoCode, cryptoCodes)
const cryptoCurrencies = coinUtils.cryptoCurrencies()
const cryptoDisplays = _.filter(pareCoins, cryptoCurrencies)