From dfa873687a0bf2406dcfbd59bd8846932e8cf1be Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Mon, 29 Aug 2016 01:20:33 +0300 Subject: [PATCH] WIP --- bin/migrate-config.js | 14 ++- lamassu-schema.json | 208 +++++++++++++++++++++++++++++++++++++----- todo.txt | 16 ++++ 3 files changed, 210 insertions(+), 28 deletions(-) diff --git a/bin/migrate-config.js b/bin/migrate-config.js index bdc18dce..91765546 100644 --- a/bin/migrate-config.js +++ b/bin/migrate-config.js @@ -7,9 +7,10 @@ const psqlUrl = require('../lib/options').postgresql const db = pgp(psqlUrl) -db.one('select data from user_config where type=$1', 'exchanges') -.then(data => { - const config = data.data +db.many('select data from user_config', 'exchanges') +.then(rows => { + const config = rows.filter(r => r.type === 'exchanges')[0].data + const brain = rows.filter(r => r.type === 'unit')[0].data const settings = config.exchanges.settings const compliance = settings.compliance const newConfig = { @@ -21,7 +22,12 @@ db.one('select data from user_config where type=$1', 'exchanges') idVerificationEnabled: compliance.idVerificationEnabled, idVerificationLimit: compliance.idVerificationLimit, lowBalanceMargin: settings.lowBalanceMargin, - zeroConfLimit: settings.zeroConfLimit + zeroConfLimit: settings.zeroConfLimit, + fiatCurrency: settings.currency, + topCashOutDenomination: settings.cartridges[0], + bottomCashOutDenomination: settings.cartridges[1], + virtualCashOutDenomination: settings.virtualCartridges[0], + machineLanguages: brain.locale.localeInfo.primaryLocales } } diff --git a/lamassu-schema.json b/lamassu-schema.json index b1ef978c..4b317c6a 100644 --- a/lamassu-schema.json +++ b/lamassu-schema.json @@ -1,42 +1,202 @@ [ { - "code": "cashInTransactionLimit", - "display": "Cash-in tx limit", - "type": "integer" + "group": { + "code": "commissions", + "display": "Commissions" + }, + "crypto": "both", + "machines": "both", + "entries": [ + { + "code": "cashInCommission", + "display": "Cash-in commission", + "type": "percentage" + }, + { + "code": "cashOutCommission", + "display": "Cash-out commission", + "type": "percentage" + }, + { + "code": "lowBalanceMargin", + "display": "Low balance margin", + "type": "percentage" + }, + { + "code": "zeroConfLimit", + "display": "Zero conf limit", + "type": "integer" + } + ] }, { - "code": "cashOutTransactionLimit", - "display": "Cash-out tx limit", - "type": "integer" + "group": { + "code": "crypto-services", + "display": "Crypto services" + }, + "crypto": "specific", + "machines": "both", + "entries": [ + { + "code": "ticker", + "display": "Ticker", + "type": "plugin", + "pluginCode": "ticker" + }, + { + "code": "wallet", + "display": "Wallet", + "type": "plugin", + "pluginCode": "wallet" + }, + { + "code": "exchange", + "display": "Exchange", + "type": "plugin", + "pluginCode": "exchange" + } + ] }, { - "code": "cashInCommission", - "display": "Cash-in commission", - "type": "percentage" + "group": { + "code": "fiat", + "display": "Fiat" + }, + "crypto": "global", + "machines": "both", + "entries": [ + { + "code": "fiatCurrency", + "display": "Fiat Currency", + "type": "currency" + }, + { + "code": "topCashOutDenomination", + "display": "Top cash-out denominations", + "type": "integer" + }, + { + "code": "bottomCashOutDenomination", + "display": "Bottom cash-out denominations", + "type": "integer" + } + ] }, { - "code": "cashOutCommission", - "display": "Cash-out commission", - "type": "percentage" + "group": { + "code": "limits", + "display": "Limits" + }, + "crypto": "global", + "machines": "both", + "entries": [ + { + "code": "cashInTransactionLimit", + "display": "Cash-in tx limit", + "type": "integer" + }, + { + "code": "cashOutTransactionLimit", + "display": "Cash-out tx limit", + "type": "integer" + } + ] }, { - "code": "idVerificationEnabled", - "display": "ID verification", - "type": "bool" + "group": { + "code": "compliance", + "display": "Compliance" + }, + "crypto": "global", + "machines": "both", + "entries": [ + { + "code": "idVerificationEnabled", + "display": "ID verification", + "type": "bool" + }, + { + "code": "idVerificationLimit", + "display": "ID Verification Limit", + "type": "integer" + } + ] }, { - "code": "idVerificationLimit", - "display": "ID Verification Limit", - "type": "int" + "group": { + "code": "languages", + "display": "Languages" + }, + "crypto": "global", + "machines": "both", + "entries": [ + { + "code": "machineLanguages", + "display": "Languages", + "type": "languages" + } + ] }, { - "code": "lowBalanceMargin", - "display": "Low balance margin", - "type": "percentage" + "group": { + "code": "machines", + "display": "Machines" + }, + "crypto": "global", + "machines": "specific", + "entries": [ + { + "code": "machineName", + "display": "Name", + "type": "string" + }, + { + "code": "machineLocation", + "display": "Location", + "type": "string" + }, + { + "code": "machineLocationCoordinates", + "display": "Location (GPS)", + "type": "coordinates" + } + ] }, { - "code": "zeroConfLimit", - "display": "Zero conf limit", - "type": "int" + "group": { + "code": "notifications", + "display": "Notifications" + }, + "crypto": "global", + "machines": "global", + "entries": [ + { + "code": "notificationsEnabled", + "display": "Notifications", + "type": "onOff" + }, + { + "code": "notificationsEmailEnabled", + "display": "Email notifications", + "type": "onOff" + }, + { + "code": "notificationsSMSEnabled", + "display": "SMS notifications", + "type": "onOff" + }, + { + "code": "email", + "display": "Email", + "type": "plugin", + "pluginCode": "email" + }, + { + "code": "sms", + "display": "SMS", + "type": "plugin", + "pluginCode": "sms" + } + ] } ] diff --git a/todo.txt b/todo.txt index b7866cc5..38dd2c36 100644 --- a/todo.txt +++ b/todo.txt @@ -9,3 +9,19 @@ - add default configuration - either remove lamassu-config or fix link in package.json + +------------------------ + +schemas: + +- global crypto / global machine +- global crypto / specific machine +- specific crypto / global machine +- specific crypto / specific machine + +- We'll have one group for config that applies to all 4 +- Machine config applies to only global crypto (machine config screen) +- Crypto config applies to only specific crypto + +v update migrate-config to match lamassu.json schema +- update machine name