Skip to content

Commit 3d93105

Browse files
Merge pull request #5491 from LiskHQ/5487-fix-crash-on-edit-fee
Fix crash on edit fee
2 parents de6f9d7 + f21d218 commit 3d93105

File tree

8 files changed

+31
-26
lines changed

8 files changed

+31
-26
lines changed

e2e/features/requestToken/RequestToken.feature

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ Feature: Request Token
4343
Then button with text "Copy link" should be enabled
4444
And Element 'qrContainer' should not contain class 'disabled'
4545
Given I click on a button with text "Add message (Optional)"
46-
And I type "hello&(&*#(@))*!#@$^%#@&@)world!@&$^#message*@)#*)@$$@&^!(@#)~~@!@#" in "reference-field"
47-
Then I should possibly see "-3 bytes left"
46+
And I type "hello(*#(@))*!#@$^%#@@)world!@$^#message*@)#*)@$$@^!(@#)~~@!@#tester12334" in "reference-field"
47+
Then I should possibly see "-9 bytes left"
4848
And Element 'qrContainer' should contain class 'disabled'
4949

5050
Scenario: Request token should generate a copy link if message is within 64 characters
5151
Given I type "10" in "amount"
5252
Then button with text "Copy link" should be enabled
5353
And Element 'qrContainer' should not contain class 'disabled'
5454
Given I click on a button with text "Add message (Optional)"
55-
And I type "hello&(&*#(@))*!#@$^%#@&@)world!@&$^#message*@)#*)@$$@&^!(@#)~~@" in "reference-field"
55+
And I type "hello(*#(@))*!#@$^%#@@)world!@$^#message*@)#*)@$$@^!(@#)~~@test1" in "reference-field"
5656
Then I should possibly see "0 bytes left"
5757
And I click on a button with text "Copy link"
58-
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"
58+
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"

src/locales/en/common.json

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"\"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.",
66
"\"{{username}}\" is already taken.": "\"{{username}}\" is already taken.",
77
"(12-24 mnemonic phrases supported)": "(12-24 mnemonic phrases supported)",
8-
"64 bytes left": "64 bytes left",
98
"A bit more. Make sure to type at least 3 characters.": "A bit more. Make sure to type at least 3 characters.",
109
"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.",
1110
"A required signatory account": "A required signatory account",

src/modules/pos/validator/components/SentStakes/SentStakes.css

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050

5151
& button {
5252
padding: 0px 45px !important;
53-
54-
&:first-child:hover {
55-
color: var(--color-black);
56-
}
5753
}
5854
}
5955

src/modules/token/fungible/components/MessageField/MessageField.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function MessageField({
8282
}`}
8383
>
8484
{feedback}
85-
{!!feedback && (
85+
{!!feedback && !error && (
8686
<Tooltip position="right" title={t('Bytes counter')}>
8787
<p className={styles.tooltipText}>
8888
{t(`Lisk counts your message in bytes, so keep in mind

src/modules/token/fungible/hooks/useMessageField.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@ import { useTranslation } from 'react-i18next';
33
import { maxMessageLength } from '@transaction/configuration/transactions';
44
import { sizeOfString } from 'src/utils/helpers';
55

6+
const getBytesLeftMessage = (value, t) => {
7+
const byteCount = sizeOfString(value);
8+
return t('{{length}} bytes left', { length: maxMessageLength - byteCount });
9+
};
10+
611
const useMessageField = (initialValue) => {
712
const { t } = useTranslation();
813
const [messageField, setMessage] = useState({
914
error: false,
1015
value: initialValue,
11-
feedback: t('64 bytes left'),
16+
feedback: getBytesLeftMessage(initialValue, t),
1217
byteCount: sizeOfString(initialValue),
1318
});
1419

1520
const onMessageInputChange = ({ target: { value } }) => {
1621
const byteCount = sizeOfString(value);
1722
setMessage({
1823
byteCount,
19-
error: byteCount > maxMessageLength,
2024
value,
21-
feedback: t('{{length}} bytes left', { length: maxMessageLength - byteCount }),
25+
error: byteCount > maxMessageLength,
26+
feedback: getBytesLeftMessage(value, t),
2227
});
2328
};
2429

src/modules/transaction/components/TransactionPriority/FeeViewer.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ const FeesViewer = ({
118118
}));
119119

120120
setCustomFee((state) => ({
121-
value: {
122-
...state.value,
123-
[label]: customFeeInput,
124-
},
121+
...(!customFeeStatus && {
122+
value: { ...state.value, [label]: customFeeInput },
123+
}),
125124
feedback: { ...state.feedback, [label]: customFeeStatus },
126125
error: { ...state.error, [label]: !!customFeeStatus },
127126
}));

src/modules/wallet/components/request/request.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import RequestWrapper from './requestWrapper';
2323
import styles from './request.css';
2424
import WalletVisual from '../walletVisual';
2525

26+
const restrictedCharacters = ['&'];
2627
const requestInitState = {
2728
amount: {
2829
error: false,
@@ -90,7 +91,6 @@ const Request = () => {
9091
const networkSupportedTokens = useNetworkSupportedTokens(state.recipientChain.value);
9192
const { recipientChain, token, amount, reference } = state;
9293
const selectedToken = networkSupportedTokens.data?.find(({ tokenID }) => tokenID === token.value);
93-
9494
const shareLink = useMemo(
9595
() =>
9696
Object.keys(state).reduce((link, fieldName) => {
@@ -104,7 +104,6 @@ const Request = () => {
104104
}, `lisk://wallet?modal=send&recipient=${address}`),
105105
[address, state]
106106
);
107-
108107
const mainChainApplication = useMemo(
109108
() => applications.find(({ chainID }) => /0{4}$/.test(chainID)),
110109
[applications]
@@ -119,7 +118,7 @@ const Request = () => {
119118

120119
const handleFieldChange = ({ target }) => {
121120
const byteCount = sizeOfString(target.value);
122-
const error =
121+
let error =
123122
target.name === 'amount'
124123
? validateAmount({
125124
amount: target.value,
@@ -135,16 +134,27 @@ const Request = () => {
135134
target.value = leadingPoint.test(target.value) ? `0${target.value}` : target.value;
136135
feedback = error || feedback;
137136
} else if (target.name === 'reference' && byteCount > 0) {
138-
feedback = t('{{length}} bytes left', { length: maxMessageLength - byteCount });
137+
const hasRestirctedChar = restrictedCharacters.some((character) =>
138+
target.value?.includes(character)
139+
);
140+
141+
if (hasRestirctedChar) {
142+
error = true;
143+
feedback = `${restrictedCharacters.join(',')} ${
144+
restrictedCharacters.length > 1 ? 'are' : 'is a'
145+
} restricted characters`;
146+
} else {
147+
feedback = t('{{length}} bytes left', { length: maxMessageLength - byteCount });
148+
}
139149
}
140150

141151
dispatch({
142152
[target.name]: {
143153
...state[target.name],
144154
feedback,
145155
error: !!error,
146-
value: target.value,
147156
loading: false,
157+
value: target.value,
148158
},
149159
});
150160
};

src/theme/buttons/css/base.css

-4
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@
6666
&:disabled {
6767
opacity: 0.58;
6868
cursor: default;
69-
70-
&:hover {
71-
color: initial;
72-
}
7369
}
7470
}
7571

0 commit comments

Comments
 (0)