Merge pull request #1764 from RafaelTaranto/backport/machine-rates

LAM-481 backport: machine rates
This commit is contained in:
Rafael Taranto 2024-11-29 13:48:48 +00:00 committed by GitHub
commit f96eac8d15
9 changed files with 158 additions and 5 deletions

View file

@ -61,6 +61,18 @@ const addReceiptInfo = receiptInfo => ret => {
}
const addMachineScreenOpts = smth => _.update(
'screenOptions',
_.flow(
addSmthInfo(
'rates',
[
'active'
]
)(smth.rates)
)
)
/* TODO: Simplify this. */
const buildTriggers = allTriggers => {
const normalTriggers = []
@ -103,7 +115,8 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
_.pick([
'coins',
'configVersion',
'timezone'
'timezone',
'screenOptions'
]),
_.update('coins', massageCoins),
_.set('serverVersion', VERSION),
@ -117,6 +130,7 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
configManager.getLocale(deviceId, settings.config),
configManager.getOperatorInfo(settings.config),
configManager.getReceipt(settings.config),
configManager.getAllMachineScreenOpts(settings.config),
!!configManager.getCashOut(deviceId, settings.config).active,
getMachine(deviceId, currentConfigVersion),
configManager.getCustomerAuthenticationMethod(settings.config)
@ -129,6 +143,7 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
localeInfo,
operatorInfo,
receiptInfo,
machineScreenOpts,
twoWayMode,
{ numberOfCassettes, numberOfRecyclers },
customerAuthentication,
@ -153,7 +168,8 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
urlsToPing,
}),
addOperatorInfo(operatorInfo),
addReceiptInfo(receiptInfo)
addReceiptInfo(receiptInfo),
addMachineScreenOpts(machineScreenOpts)
)(staticConf))
}

View file

@ -49,6 +49,14 @@ type ReceiptInfo {
addressQRCode: Boolean!
}
type MachineScreenOptions {
rates: RateScreenOptions!
}
type RateScreenOptions {
active: Boolean!
}
type SpeedtestFile {
url: String!
size: Int!
@ -147,6 +155,7 @@ type StaticConfig {
operatorInfo: OperatorInfo
machineInfo: MachineInfo!
receiptInfo: ReceiptInfo
screenOptions: MachineScreenOptions
speedtestFiles: [SpeedtestFile!]!
urlsToPing: [String!]!

View file

@ -13,7 +13,12 @@ const namespaces = {
TERMS_CONDITIONS: 'termsConditions',
CASH_OUT: 'cashOut',
CASH_IN: 'cashIn',
COMPLIANCE: 'compliance'
COMPLIANCE: 'compliance',
MACHINE_SCREENS: 'machineScreens'
}
const machineScreens = {
RATES: 'rates'
}
const stripl = _.curry((q, str) => _.startsWith(q, str) ? str.slice(q.length) : str)
@ -72,6 +77,8 @@ const getCoinAtmRadar = fromNamespace(namespaces.COIN_ATM_RADAR)
const getTermsConditions = fromNamespace(namespaces.TERMS_CONDITIONS)
const getReceipt = fromNamespace(namespaces.RECEIPT)
const getCompliance = fromNamespace(namespaces.COMPLIANCE)
const getMachineScreenOpts = (screenName, config) => _.compose(fromNamespace(screenName), fromNamespace(namespaces.MACHINE_SCREENS))(config)
const getAllMachineScreenOpts = config => _.reduce((acc, value) => ({ ...acc, [value]: getMachineScreenOpts(value, config) }), {}, _.values(machineScreens))
const getAllCryptoCurrencies = (config) => {
const locale = fromNamespace(namespaces.LOCALE)(config)
@ -180,6 +187,8 @@ module.exports = {
getWalletSettings,
getCashInSettings,
getOperatorInfo,
getMachineScreenOpts,
getAllMachineScreenOpts,
getNotifications,
getGlobalNotifications,
getLocale,

View file

@ -278,6 +278,7 @@ function plugins (settings, deviceId) {
const localeConfig = configManager.getLocale(deviceId, settings.config)
const fiatCode = localeConfig.fiatCurrency
const cryptoCodes = localeConfig.cryptoCurrencies
const machineScreenOpts = configManager.getAllMachineScreenOpts(settings.config)
const tickerPromises = cryptoCodes.map(c => getTickerRates(fiatCode, c))
const balancePromises = cryptoCodes.map(c => fiatBalance(fiatCode, c))
@ -327,7 +328,8 @@ function plugins (settings, deviceId) {
coins,
configVersion,
areThereAvailablePromoCodes: numberOfAvailablePromoCodes > 0,
timezone
timezone,
screenOptions: machineScreenOpts
}
})
}