From 705747e9e0e6749a00c5427d187c0cf0f3953e50 Mon Sep 17 00:00:00 2001
From: Cesar <26280794+csrapr@users.noreply.github.com>
Date: Tue, 15 Dec 2020 18:55:45 +0000
Subject: [PATCH] Feat: compliance blacklisted addresses notifications
---
lib/new-settings-loader.js | 12 ++++++++++++
lib/notifier/index.js | 14 ++++++++++++++
lib/notifier/queries.js | 5 +++++
.../src/pages/Customers/CustomerProfile.js | 7 ++++---
.../src/pages/Customers/CustomersList.js | 8 ++++++--
.../pages/Customers/components/CustomerDetails.js | 9 ++++-----
new-lamassu-admin/src/pages/Customers/helper.js | 7 +++----
7 files changed, 48 insertions(+), 14 deletions(-)
diff --git a/lib/new-settings-loader.js b/lib/new-settings-loader.js
index 916c6c5b..1f88ce8b 100644
--- a/lib/new-settings-loader.js
+++ b/lib/new-settings-loader.js
@@ -44,6 +44,18 @@ const configSql = 'insert into user_config (type, data, valid, schema_version) v
function saveConfig (config) {
return loadLatestConfigOrNone()
.then(currentConfig => {
+ if(config.notifications_cryptoHighBalance || config.notifications_cryptoLowBalance) {
+ clearCryptoBalanceNotifications(currentConfig, config, false)
+ }
+ if(config.notifications_cryptoBalanceOverrides) {
+ clearCryptoBalanceNotifications(currentConfig.notifications_cryptoBalanceOverrides, config.notifications_cryptoBalanceOverrides, true)
+ }
+ if(config.notifications_fiatBalanceCassette1 || config.notifications_fiatBalanceCassette2) {
+ clearCassetteNotifications(currentConfig, config, false)
+ }
+ if(config.notifications_fiatBalanceOverrides) {
+ clearCassetteNotifications(currentConfig.notifications_fiatBalanceOverrides, config.notifications_fiatBalanceOverrides, true)
+ }
const newConfig = _.assign(currentConfig, config)
return db.none(configSql, ['config', { config: newConfig }, true, NEW_SETTINGS_LOADER_SCHEMA_VERSION])
})
diff --git a/lib/notifier/index.js b/lib/notifier/index.js
index 792e4b6c..586ef189 100644
--- a/lib/notifier/index.js
+++ b/lib/notifier/index.js
@@ -512,6 +512,20 @@ const errorAlertsNotify = (alertRec) => {
}, alerts)
}
+const addBlacklistNotification = (tx, isAddressReuse) => {
+ let detail = ''
+ let message = ''
+ if(isAddressReuse) {
+ detail = `${tx.cryptoCode}_REUSED_${tx.toAddress}`
+ message = `Blocked address reuse: ${tx.cryptoCode} ${tx.toAddress.substr(0,10)}...`
+ } else {
+ detail = `${tx.cryptoCode}_BLOCKED_${tx.toAddress}`
+ message = `Blocked blacklisted address: ${tx.cryptoCode} ${tx.toAddress.substr(0,10)}...`
+ }
+
+ queries.addComplianceNotification(tx.deviceId, detail, message)
+}
+
module.exports = {
transactionNotify,
checkNotification,
diff --git a/lib/notifier/queries.js b/lib/notifier/queries.js
index 76a4eeeb..93040b5e 100644
--- a/lib/notifier/queries.js
+++ b/lib/notifier/queries.js
@@ -66,6 +66,11 @@ const hasUnreadNotifications = () => {
return db.oneOrNone(sql).then(res => res.exists)
}
+const addComplianceNotification = (deviceId, detail, message) => {
+ const sql = `INSERT INTO notifications (id, type, detail, device_id, message, created) values ($1, 'compliance', $2, $3, $4, CURRENT_TIMESTAMP)`
+ return db.oneOrNone(sql, [uuidv4(), detail, deviceId, message])
+}
+
module.exports = {
machineEvents: dbm.machineEvents,
addNotification,
diff --git a/new-lamassu-admin/src/pages/Customers/CustomerProfile.js b/new-lamassu-admin/src/pages/Customers/CustomerProfile.js
index 03049099..f8f96a13 100644
--- a/new-lamassu-admin/src/pages/Customers/CustomerProfile.js
+++ b/new-lamassu-admin/src/pages/Customers/CustomerProfile.js
@@ -24,7 +24,7 @@ import {
TransactionsList,
ComplianceDetails
} from './components'
-import { getFormattedPhone, getName } from './helper'
+import { /* getFormattedPhone, */ getName } from './helper'
const useStyles = makeStyles(styles)
@@ -147,12 +147,13 @@ const CustomerProfile = memo(() => {
Customers