From 7157a118952d2f4173e38442e502e109ff968fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Sun, 5 Sep 2021 00:19:08 +0100 Subject: [PATCH 1/5] feat: move paper wallet only to admin --- lib/routes/pollingRoutes.js | 2 + .../src/components/buttons/Button.styles.js | 1 + .../src/pages/Blacklist/Blacklist.js | 97 ++++++++++++++++++- .../src/pages/Blacklist/Blacklist.styles.js | 21 ++++ 4 files changed, 118 insertions(+), 3 deletions(-) diff --git a/lib/routes/pollingRoutes.js b/lib/routes/pollingRoutes.js index c4568233..14cb82d1 100644 --- a/lib/routes/pollingRoutes.js +++ b/lib/routes/pollingRoutes.js @@ -81,6 +81,7 @@ function poll (req, res, next) { const cashOutConfig = configManager.getCashOut(deviceId, settings.config) const receipt = configManager.getReceipt(settings.config) const terms = configManager.getTermsConditions(settings.config) + const enablePaperWalletOnly = configManager.getCompliance(settings.config).enablePaperWalletOnly state.pids[operatorId] = { [deviceId]: { pid, ts: Date.now() } } @@ -108,6 +109,7 @@ function poll (req, res, next) { version, receiptPrintingActive: receipt.active, smsReceiptActive: receipt.sms, + enablePaperWalletOnly, cassettes, twoWayMode: cashOutConfig.active, zeroConfLimits, diff --git a/new-lamassu-admin/src/components/buttons/Button.styles.js b/new-lamassu-admin/src/components/buttons/Button.styles.js index ad8e64a6..157c37a1 100644 --- a/new-lamassu-admin/src/components/buttons/Button.styles.js +++ b/new-lamassu-admin/src/components/buttons/Button.styles.js @@ -36,6 +36,7 @@ export default { const shadowSize = size === 'xl' ? 3 : height / 12 const padding = size === 'xl' ? 20 : height / 2 const isGrey = backgroundColor === 'grey' + return { extend: size === 'xl' ? h1 : h3, border: 'none', diff --git a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js index 96b9b34d..8c680f25 100644 --- a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js +++ b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js @@ -1,5 +1,5 @@ import { useQuery, useMutation } from '@apollo/react-hooks' -import { Box } from '@material-ui/core' +import { Box, Dialog, DialogContent, DialogActions } from '@material-ui/core' import Grid from '@material-ui/core/Grid' import { makeStyles } from '@material-ui/core/styles' import gql from 'graphql-tag' @@ -8,11 +8,12 @@ import * as R from 'ramda' import React, { useState } from 'react' import { HoverableTooltip } from 'src/components/Tooltip' -import { Link } from 'src/components/buttons' +import { Link, Button, IconButton } from 'src/components/buttons' import { Switch } from 'src/components/inputs' import Sidebar from 'src/components/layout/Sidebar' import TitleSection from 'src/components/layout/TitleSection' -import { H4, Label2, P } from 'src/components/typography' +import { H4, H2, Label2, P, Info3, Info2 } from 'src/components/typography' +import { ReactComponent as CloseIcon } from 'src/styling/icons/action/close/zodiac.svg' import { fromNamespace, toNamespace } from 'src/utils/config' import styles from './Blacklist.styles' @@ -66,6 +67,50 @@ const ADD_ROW = gql` } ` +const PaperWalletDialog = ({ onConfirmed, onDissmised, open, props }) => { + const classes = useStyles() + + return ( + <> + +
+ + + +
+

+ {'Are you sure you want to enable this?'} +

+ + {`This mode means that only paper wallets will be printed for users, and they won't be permitted to scan an address from their own wallet.`} + {`This mode is only useful for countries like Switzerland which mandates such a feature.\n`} + {`Don't enable this if you want users to be able to scan an address of their choosing.`} + + + + + +
+ + ) +} + const Blacklist = () => { const { data: blacklistResponse } = useQuery(GET_BLACKLIST) const { data: configData } = useQuery(GET_INFO) @@ -76,6 +121,7 @@ const Blacklist = () => { }) const [errorMsg, setErrorMsg] = useState(null) const [deleteDialog, setDeleteDialog] = useState(false) + const [confirmDialog, setConfirmDialog] = useState(false) const [deleteEntry] = useMutation(DELETE_ROW, { onError: ({ message }) => { @@ -108,6 +154,8 @@ const Blacklist = () => { const rejectAddressReuse = complianceConfig?.rejectAddressReuse ?? false + const enablePaperWalletOnly = complianceConfig?.enablePaperWalletOnly ?? false + const addressReuseSave = rawConfig => { const config = toNamespace('compliance')(rawConfig) return saveConfig({ variables: { config } }) @@ -121,6 +169,13 @@ const Blacklist = () => { deleteEntry({ variables: { cryptoCode, address } }) } + const handleConfirmDialog = confirm => { + addressReuseSave({ + enablePaperWalletOnly: confirm + }) + setConfirmDialog(false) + } + const validateAddress = (cryptoCode, address) => { try { return !R.isNil(coinUtils.parseUrl(cryptoCode, 'main', address)) @@ -151,6 +206,13 @@ const Blacklist = () => { return ( <> + { + setConfirmDialog(false) + }} + /> setShowModal(true)}> @@ -172,6 +234,35 @@ const Blacklist = () => { ? `${clickedItem.display} blacklisted addresses` : ''}{' '} + +

Enable paper wallet (only)

+ { + if (enablePaperWalletOnly) { + addressReuseSave({ + enablePaperWalletOnly: event.target.checked + }) + } else { + setConfirmDialog(true) + } + }} + value={enablePaperWalletOnly} + /> + {enablePaperWalletOnly ? 'On' : 'Off'} + +

+ The "Enable paper wallet (only)" option means that all only + paper wallets paper wallets will be printed for users, and + they won't be permitted to scan an address from their own + wallet. +

+
+
Date: Thu, 9 Sep 2021 23:10:34 +0100 Subject: [PATCH 2/5] refactor: conditions simplification --- .../src/pages/Blacklist/Blacklist.js | 90 +++++++++---------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js index 8c680f25..c23e5fef 100644 --- a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js +++ b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js @@ -71,43 +71,41 @@ const PaperWalletDialog = ({ onConfirmed, onDissmised, open, props }) => { const classes = useStyles() return ( - <> - -
- - - -
-

- {'Are you sure you want to enable this?'} -

- - {`This mode means that only paper wallets will be printed for users, and they won't be permitted to scan an address from their own wallet.`} - {`This mode is only useful for countries like Switzerland which mandates such a feature.\n`} - {`Don't enable this if you want users to be able to scan an address of their choosing.`} - - - - - -
- + +
+ + + +
+

+ {'Are you sure you want to enable this?'} +

+ + {`This mode means that only paper wallets will be printed for users, and they won't be permitted to scan an address from their own wallet.`} + {`This mode is only useful for countries like Switzerland which mandates such a feature.\n`} + {`Don't enable this if you want users to be able to scan an address of their choosing.`} + + + + + +
) } @@ -154,7 +152,7 @@ const Blacklist = () => { const rejectAddressReuse = complianceConfig?.rejectAddressReuse ?? false - const enablePaperWalletOnly = complianceConfig?.enablePaperWalletOnly ?? false + const enablePaperWalletOnly = !!complianceConfig.enablePaperWalletOnly const addressReuseSave = rawConfig => { const config = toNamespace('compliance')(rawConfig) @@ -242,15 +240,13 @@ const Blacklist = () => {

Enable paper wallet (only)

{ - if (enablePaperWalletOnly) { - addressReuseSave({ - enablePaperWalletOnly: event.target.checked - }) - } else { - setConfirmDialog(true) - } - }} + onChange={e => + enablePaperWalletOnly + ? addressReuseSave({ + enablePaperWalletOnly: e.target.checked + }) + : setConfirmDialog(true) + } value={enablePaperWalletOnly} /> {enablePaperWalletOnly ? 'On' : 'Off'} From 86af754c7eed64a2b08f7691c42846e741064dd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Mon, 20 Sep 2021 19:12:12 +0100 Subject: [PATCH 3/5] fix: undefined compliance config and cancel button color --- new-lamassu-admin/src/pages/Blacklist/Blacklist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js index c23e5fef..f08e00cf 100644 --- a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js +++ b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js @@ -152,7 +152,7 @@ const Blacklist = () => { const rejectAddressReuse = complianceConfig?.rejectAddressReuse ?? false - const enablePaperWalletOnly = !!complianceConfig.enablePaperWalletOnly + const enablePaperWalletOnly = !!complianceConfig?.enablePaperWalletOnly const addressReuseSave = rawConfig => { const config = toNamespace('compliance')(rawConfig) From c786f5fd6e179c325bb3d59bd87c063673a36654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Mon, 20 Sep 2021 21:00:17 +0100 Subject: [PATCH 4/5] fix: adjust content width --- new-lamassu-admin/src/pages/Blacklist/Blacklist.styles.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/new-lamassu-admin/src/pages/Blacklist/Blacklist.styles.js b/new-lamassu-admin/src/pages/Blacklist/Blacklist.styles.js index 707c3716..9c44bb1d 100644 --- a/new-lamassu-admin/src/pages/Blacklist/Blacklist.styles.js +++ b/new-lamassu-admin/src/pages/Blacklist/Blacklist.styles.js @@ -41,11 +41,11 @@ const styles = { justifyContent: 'end' }, dialogTitle: { - margin: [[0, spacer * 2, spacer, spacer * 2 + 4]] + margin: [[0, spacer * 2, spacer, spacer * 4 + spacer]] }, dialogContent: { - width: 610, - paddingLeft: 20 + width: 615, + marginLeft: 16 }, dialogActions: { padding: spacer * 4, From cace34d8fea1fb689cf002ded070120224a74786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Thu, 7 Oct 2021 14:48:16 +0100 Subject: [PATCH 5/5] fix: repeated words on tooltip and variable simplification --- new-lamassu-admin/src/pages/Blacklist/Blacklist.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js index f08e00cf..b4c53047 100644 --- a/new-lamassu-admin/src/pages/Blacklist/Blacklist.js +++ b/new-lamassu-admin/src/pages/Blacklist/Blacklist.js @@ -150,7 +150,7 @@ const Blacklist = () => { const complianceConfig = configData?.config && fromNamespace('compliance')(configData.config) - const rejectAddressReuse = complianceConfig?.rejectAddressReuse ?? false + const rejectAddressReuse = !!complianceConfig?.rejectAddressReuse const enablePaperWalletOnly = !!complianceConfig?.enablePaperWalletOnly @@ -252,10 +252,9 @@ const Blacklist = () => { {enablePaperWalletOnly ? 'On' : 'Off'}

- The "Enable paper wallet (only)" option means that all only - paper wallets paper wallets will be printed for users, and - they won't be permitted to scan an address from their own - wallet. + The "Enable paper wallet (only)" option means that only paper + wallets will be printed for users, and they won't be permitted + to scan an address from their own wallet.