From 7cfa0370a01e4eaba6c85acbf7e4b015d2fc36b8 Mon Sep 17 00:00:00 2001 From: Eniola Olatunji Date: Fri, 24 Nov 2023 09:58:59 +0100 Subject: [PATCH 1/5] fix: added max_accuracy --- .../transaction/components/TransactionPriority/FeeViewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/transaction/components/TransactionPriority/FeeViewer.js b/src/modules/transaction/components/TransactionPriority/FeeViewer.js index 8742b403d1..d2c41f8819 100644 --- a/src/modules/transaction/components/TransactionPriority/FeeViewer.js +++ b/src/modules/transaction/components/TransactionPriority/FeeViewer.js @@ -18,7 +18,7 @@ const getCustomFeeStatus = ({ customFeeInput, minFee, minRequiredBalance, token token, accountBalance: BigInt(token.availableBalance) - BigInt(minRequiredBalance), minValue: minFee, - checklist: ['FORMAT', 'ZERO', 'MAX_ACCURACY', 'FEE_RANGE'], + checklist: ['FORMAT', 'ZERO', 'MAX_ACCURACY', 'FEE_RANGE', 'MAX_ACCURACY'], }); return message; From 95d9afebf33944d46cb246b137016891dd6d52df Mon Sep 17 00:00:00 2001 From: Eniola Olatunji Date: Fri, 24 Nov 2023 10:12:17 +0100 Subject: [PATCH 2/5] fix: resolved wrong bytes left message --- src/locales/en/common.json | 1 - src/modules/token/fungible/hooks/useMessageField.js | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/locales/en/common.json b/src/locales/en/common.json index a28b8dddc2..b8b7fede01 100644 --- a/src/locales/en/common.json +++ b/src/locales/en/common.json @@ -5,7 +5,6 @@ "\"Lisk\" will be the default mainchain application, please enter your custom network to be added to the wallet.": "\"Lisk\" will be the default mainchain application, please enter your custom network to be added to the wallet.", "\"{{username}}\" is already taken.": "\"{{username}}\" is already taken.", "(12-24 mnemonic phrases supported)": "(12-24 mnemonic phrases supported)", - "64 bytes left": "64 bytes left", "A bit more. Make sure to type at least 3 characters.": "A bit more. Make sure to type at least 3 characters.", "A new management feature allows you to seamlessly add and switch between applications. The dedicated application tab provides a comprehensive overview of registered, active, and terminated blockchain applications, and statistics.": "A new management feature allows you to seamlessly add and switch between applications. The dedicated application tab provides a comprehensive overview of registered, active, and terminated blockchain applications, and statistics.", "A required signatory account": "A required signatory account", diff --git a/src/modules/token/fungible/hooks/useMessageField.js b/src/modules/token/fungible/hooks/useMessageField.js index e846560b07..a17ed181f7 100644 --- a/src/modules/token/fungible/hooks/useMessageField.js +++ b/src/modules/token/fungible/hooks/useMessageField.js @@ -3,12 +3,17 @@ import { useTranslation } from 'react-i18next'; import { maxMessageLength } from '@transaction/configuration/transactions'; import { sizeOfString } from 'src/utils/helpers'; +const getBytesLeftMessage = (value, t) => { + const byteCount = sizeOfString(value); + return t('{{length}} bytes left', { length: maxMessageLength - byteCount }); +}; + const useMessageField = (initialValue) => { const { t } = useTranslation(); const [messageField, setMessage] = useState({ error: false, value: initialValue, - feedback: t('64 bytes left'), + feedback: getBytesLeftMessage(initialValue, t), byteCount: sizeOfString(initialValue), }); @@ -16,9 +21,9 @@ const useMessageField = (initialValue) => { const byteCount = sizeOfString(value); setMessage({ byteCount, - error: byteCount > maxMessageLength, value, - feedback: t('{{length}} bytes left', { length: maxMessageLength - byteCount }), + error: byteCount > maxMessageLength, + feedback: getBytesLeftMessage(value, t), }); }; From da0fb323d0d1719f5f5780c992098e7a28c4512a Mon Sep 17 00:00:00 2001 From: Eniola Olatunji Date: Fri, 24 Nov 2023 12:50:47 +0100 Subject: [PATCH 3/5] fix: restricted & from message field --- .../components/MessageField/MessageField.js | 2 +- .../TransactionPriority/FeeViewer.js | 9 ++++---- .../wallet/components/request/request.js | 21 ++++++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/modules/token/fungible/components/MessageField/MessageField.js b/src/modules/token/fungible/components/MessageField/MessageField.js index 7ffccdf8aa..ae24b2b243 100644 --- a/src/modules/token/fungible/components/MessageField/MessageField.js +++ b/src/modules/token/fungible/components/MessageField/MessageField.js @@ -82,7 +82,7 @@ function MessageField({ }`} > {feedback} - {!!feedback && ( + {!!feedback && !error && (

{t(`Lisk counts your message in bytes, so keep in mind diff --git a/src/modules/transaction/components/TransactionPriority/FeeViewer.js b/src/modules/transaction/components/TransactionPriority/FeeViewer.js index d2c41f8819..0804db23fa 100644 --- a/src/modules/transaction/components/TransactionPriority/FeeViewer.js +++ b/src/modules/transaction/components/TransactionPriority/FeeViewer.js @@ -18,7 +18,7 @@ const getCustomFeeStatus = ({ customFeeInput, minFee, minRequiredBalance, token token, accountBalance: BigInt(token.availableBalance) - BigInt(minRequiredBalance), minValue: minFee, - checklist: ['FORMAT', 'ZERO', 'MAX_ACCURACY', 'FEE_RANGE', 'MAX_ACCURACY'], + checklist: ['FORMAT', 'ZERO', 'MAX_ACCURACY', 'FEE_RANGE'], }); return message; @@ -118,10 +118,9 @@ const FeesViewer = ({ })); setCustomFee((state) => ({ - value: { - ...state.value, - [label]: customFeeInput, - }, + ...(!customFeeStatus && { + value: { ...state.value, [label]: customFeeInput }, + }), feedback: { ...state.feedback, [label]: customFeeStatus }, error: { ...state.error, [label]: !!customFeeStatus }, })); diff --git a/src/modules/wallet/components/request/request.js b/src/modules/wallet/components/request/request.js index 35ded768c5..250c069004 100644 --- a/src/modules/wallet/components/request/request.js +++ b/src/modules/wallet/components/request/request.js @@ -23,6 +23,7 @@ import RequestWrapper from './requestWrapper'; import styles from './request.css'; import WalletVisual from '../walletVisual'; +const restrictedCharacters = ['&']; const requestInitState = { amount: { error: false, @@ -90,7 +91,6 @@ const Request = () => { const networkSupportedTokens = useNetworkSupportedTokens(state.recipientChain.value); const { recipientChain, token, amount, reference } = state; const selectedToken = networkSupportedTokens.data?.find(({ tokenID }) => tokenID === token.value); - const shareLink = useMemo( () => Object.keys(state).reduce((link, fieldName) => { @@ -104,7 +104,6 @@ const Request = () => { }, `lisk://wallet?modal=send&recipient=${address}`), [address, state] ); - const mainChainApplication = useMemo( () => applications.find(({ chainID }) => /0{4}$/.test(chainID)), [applications] @@ -119,7 +118,7 @@ const Request = () => { const handleFieldChange = ({ target }) => { const byteCount = sizeOfString(target.value); - const error = + let error = target.name === 'amount' ? validateAmount({ amount: target.value, @@ -135,7 +134,19 @@ const Request = () => { target.value = leadingPoint.test(target.value) ? `0${target.value}` : target.value; feedback = error || feedback; } else if (target.name === 'reference' && byteCount > 0) { - feedback = t('{{length}} bytes left', { length: maxMessageLength - byteCount }); + const hasRestirctedChar = restrictedCharacters.some((character) => + target.value?.includes(character) + ); + + if (hasRestirctedChar) { + error = true; + feedback = `${restrictedCharacters.join(',')} ${ + restrictedCharacters.length ? 'are' : 'is' + } restricted characters`; + } else { + error = false; + feedback = t('{{length}} bytes left', { length: maxMessageLength - byteCount }); + } } dispatch({ @@ -143,8 +154,8 @@ const Request = () => { ...state[target.name], feedback, error: !!error, - value: target.value, loading: false, + value: target.value, }, }); }; From 85fc615d31df02e392cfbe24000b46ef61fb50a7 Mon Sep 17 00:00:00 2001 From: Eniola Olatunji Date: Fri, 24 Nov 2023 13:12:16 +0100 Subject: [PATCH 4/5] fix: changed count conditional logic --- src/modules/wallet/components/request/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/wallet/components/request/request.js b/src/modules/wallet/components/request/request.js index 250c069004..4836b19518 100644 --- a/src/modules/wallet/components/request/request.js +++ b/src/modules/wallet/components/request/request.js @@ -141,7 +141,7 @@ const Request = () => { if (hasRestirctedChar) { error = true; feedback = `${restrictedCharacters.join(',')} ${ - restrictedCharacters.length ? 'are' : 'is' + restrictedCharacters.length > 1 ? 'are' : 'is' } restricted characters`; } else { error = false; From 806792c1c45d7685f7b8e428c4542982223912a5 Mon Sep 17 00:00:00 2001 From: Eniola Olatunji Date: Fri, 24 Nov 2023 14:43:03 +0100 Subject: [PATCH 5/5] fix: resolved issue with e2e --- e2e/features/requestToken/RequestToken.feature | 8 ++++---- .../pos/validator/components/SentStakes/SentStakes.css | 4 ---- src/modules/wallet/components/request/request.js | 3 +-- src/theme/buttons/css/base.css | 4 ---- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/e2e/features/requestToken/RequestToken.feature b/e2e/features/requestToken/RequestToken.feature index 94e987aa2e..fc1f8fb21c 100644 --- a/e2e/features/requestToken/RequestToken.feature +++ b/e2e/features/requestToken/RequestToken.feature @@ -43,8 +43,8 @@ Feature: Request Token Then button with text "Copy link" should be enabled And Element 'qrContainer' should not contain class 'disabled' Given I click on a button with text "Add message (Optional)" - And I type "hello&(&*#(@))*!#@$^%#@&@)world!@&$^#message*@)#*)@$$@&^!(@#)~~@!@#" in "reference-field" - Then I should possibly see "-3 bytes left" + And I type "hello(*#(@))*!#@$^%#@@)world!@$^#message*@)#*)@$$@^!(@#)~~@!@#tester12334" in "reference-field" + Then I should possibly see "-9 bytes left" And Element 'qrContainer' should contain class 'disabled' Scenario: Request token should generate a copy link if message is within 64 characters @@ -52,7 +52,7 @@ Feature: Request Token Then button with text "Copy link" should be enabled And Element 'qrContainer' should not contain class 'disabled' Given I click on a button with text "Add message (Optional)" - And I type "hello&(&*#(@))*!#@$^%#@&@)world!@&$^#message*@)#*)@$$@&^!(@#)~~@" in "reference-field" + And I type "hello(*#(@))*!#@$^%#@@)world!@$^#message*@)#*)@$$@^!(@#)~~@test1" in "reference-field" Then I should possibly see "0 bytes left" And I click on a button with text "Copy link" - Then Clipboard should contain "lisk://wallet?modal=send&recipient=lskm9syv4wrjcjczpegz65zqxhk2cp9dkejs5wbjb&amount=10&reference=hello%26(%26*%23(%40))*!%23%40%24%5E%25%23%40%26%40)world!%40%26%24%5E%23message*%40)%23*)%40%24%24%40%26%5E!(%40%23)~~%40&token=0400000000000000&recipientChain=04000000" + Then Clipboard should contain "lisk://wallet?modal=send&recipient=lskm9syv4wrjcjczpegz65zqxhk2cp9dkejs5wbjb&amount=10&reference=hello(*%23(%40))*!%23%40%24%5E%25%23%40%40)world!%40%24%5E%23message*%40)%23*)%40%24%24%40%5E!(%40%23)~~%40test1&token=0400000000000000&recipientChain=04000000" diff --git a/src/modules/pos/validator/components/SentStakes/SentStakes.css b/src/modules/pos/validator/components/SentStakes/SentStakes.css index e7527b592d..a7ac3ddd63 100644 --- a/src/modules/pos/validator/components/SentStakes/SentStakes.css +++ b/src/modules/pos/validator/components/SentStakes/SentStakes.css @@ -50,10 +50,6 @@ & button { padding: 0px 45px !important; - - &:first-child:hover { - color: var(--color-black); - } } } diff --git a/src/modules/wallet/components/request/request.js b/src/modules/wallet/components/request/request.js index 4836b19518..f14a55f6ad 100644 --- a/src/modules/wallet/components/request/request.js +++ b/src/modules/wallet/components/request/request.js @@ -141,10 +141,9 @@ const Request = () => { if (hasRestirctedChar) { error = true; feedback = `${restrictedCharacters.join(',')} ${ - restrictedCharacters.length > 1 ? 'are' : 'is' + restrictedCharacters.length > 1 ? 'are' : 'is a' } restricted characters`; } else { - error = false; feedback = t('{{length}} bytes left', { length: maxMessageLength - byteCount }); } } diff --git a/src/theme/buttons/css/base.css b/src/theme/buttons/css/base.css index d589b230a9..8043be40c7 100644 --- a/src/theme/buttons/css/base.css +++ b/src/theme/buttons/css/base.css @@ -66,10 +66,6 @@ &:disabled { opacity: 0.58; cursor: default; - - &:hover { - color: initial; - } } }