Skip to content

Commit a2f5018

Browse files
committed
fix: [lw-11802]: fix e2e
1 parent c3e5ddc commit a2f5018

File tree

7 files changed

+20
-27
lines changed

7 files changed

+20
-27
lines changed

apps/browser-extension-wallet/src/utils/format-number.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const formatLocaleNumber = (value: string, decimalPlaces: number = DEFAUL
5454
* @param maxDecimals The maximum number of decimal places to include. Default is 0.
5555
* @returns The formatted number string.
5656
*/
57-
export const formatNumberForDisplay = (value: string, maxDecimals = 0): string => {
57+
export const formatNumberForDisplay = (value?: string, maxDecimals = 0): string => {
5858
if (!value) return '0';
5959
// Remove any character that is not a dot or a number
6060
const parsedStringValue = value.replace(/[^\d.]/g, '');
@@ -137,7 +137,7 @@ export const handleFormattedValueChange = (
137137
* @param decimals The desired decimal places (default = 2)
138138
* @returns The formatted value with the desired decimals and the unit as a string
139139
*/
140-
export const compactNumberWithUnit = (value: number | string, decimals = DEFAULT_DECIMALS): string => {
140+
export const compactNumberWithUnit = (value?: number | string, decimals = DEFAULT_DECIMALS): string => {
141141
const bigNumberValue = value ? new BigNumber(value) : new BigNumber(0);
142142

143143
if (bigNumberValue.isNaN()) return formatLocaleNumber('0', decimals);

apps/browser-extension-wallet/src/views/browser-view/features/send-transaction/components/Form/CoinInput/useSelectedCoins.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { MAX_NFT_TICKER_LENGTH, MAX_TOKEN_TICKER_LENGTH } from '../../../constan
2727

2828
interface InputFieldActionParams {
2929
id: string;
30-
value: string;
30+
value?: string;
3131
maxDecimals?: number;
3232
}
3333

@@ -176,10 +176,10 @@ export const useSelectedCoins = ({
176176
coinBalance,
177177
spendableCoin?.toString(),
178178
tokensUsed[cardanoCoin.id] || '0',
179-
assetInputItem?.value || '0'
179+
assetInputItem?.value ?? '0'
180180
);
181181
const fiatValue = Wallet.util.convertAdaToFiat({
182-
ada: assetInputItem?.value || '0',
182+
ada: assetInputItem?.value ?? '0',
183183
fiat: prices?.cardano?.price
184184
});
185185
return {

packages/core/src/ui/components/AssetInput/AssetInput.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next';
1212
import cn from 'classnames';
1313
import { CoreTranslationKey } from '@lace/translation';
1414

15-
const isSameNumberFormat = (num1: string, num2: string) => {
15+
const isSameNumberFormat = (num1?: string, num2?: string) => {
1616
if (!num1 || !num2) return false;
1717
const strippedNum = Number(num2?.replace(/,/g, ''));
1818
return Number(num1) === strippedNum;
@@ -24,8 +24,8 @@ export interface AssetInputProps {
2424
inputId: string;
2525
coin: { id: string; balance: string; src?: string; ticker?: string; shortTicker?: string };
2626
onChange: (args: { value: string; prevValue?: string; id: string; element?: any; maxDecimals?: number }) => void;
27-
onBlur?: (args: { value: string; id: string; maxDecimals?: number }) => void;
28-
onFocus?: (args: { value: string; id: string; maxDecimals?: number }) => void;
27+
onBlur?: (args: { value?: string; id: string; maxDecimals?: number }) => void;
28+
onFocus?: (args: { value?: string; id: string; maxDecimals?: number }) => void;
2929
fiatValue: string;
3030
formattedFiatValue?: string;
3131
value?: string;
@@ -81,7 +81,7 @@ export const AssetInput = ({
8181
const [isInvalid, setIsInvalid] = useState(invalid);
8282
const [isTouched, setIsTouched] = useState(false);
8383

84-
const adjustInputWidth = useCallback((text: string) => {
84+
const adjustInputWidth = useCallback((text?: string) => {
8585
if (!inputRef?.current?.input) return;
8686
const textWidth = !text || text === '0' ? defaultInputWidth : getTextWidth(text, inputRef.current.input);
8787
const numberOneQuantity = text?.match(/1/g)?.length ?? 0;
@@ -115,14 +115,14 @@ export const AssetInput = ({
115115
}, [invalid]);
116116

117117
useLayoutEffect(() => {
118-
adjustInputWidth(focused ? displayValue ?? '' : compactValue ?? '');
118+
adjustInputWidth(focused ? displayValue : compactValue);
119119
// eslint-disable-next-line react-hooks/exhaustive-deps
120120
}, [adjustInputWidth]);
121121

122122
// eslint-disable-next-line complexity
123123
const setValue = (newValue: string, element?: any) => {
124124
const sanitizedValue = sanitizeNumber(newValue);
125-
const tokenMaxDecimalsOverflow = maxDecimals ?? 0;
125+
const tokenMaxDecimalsOverflow = maxDecimals;
126126
const isValidNumericValue = validateNumericValue(sanitizedValue, {
127127
isFloat: allowFloat,
128128
maxDecimals: tokenMaxDecimalsOverflow?.toString()
@@ -154,7 +154,7 @@ export const AssetInput = ({
154154

155155
const handleOnBlur = () => {
156156
setIsTouched(true);
157-
const currentValue = value && !Number.parseFloat(value) ? placeholderValue : value ?? '0';
157+
const currentValue = value && !Number.parseFloat(value) ? placeholderValue : value;
158158
onBlur?.({
159159
value: currentValue,
160160
id: coin.id,
@@ -167,7 +167,7 @@ export const AssetInput = ({
167167
const handleOnFocus = () => {
168168
setFocusInput?.(inputId);
169169
onFocus?.({
170-
value: value ?? placeholderValue,
170+
value,
171171
id: coin.id,
172172
maxDecimals
173173
});
@@ -207,13 +207,7 @@ export const AssetInput = ({
207207
</div>
208208
)}
209209

210-
<Tooltip
211-
title={
212-
!isSameNumberFormat(value ?? placeholderValue, compactValue ?? placeholderValue) &&
213-
!focused &&
214-
displayValue
215-
}
216-
>
210+
<Tooltip title={!isSameNumberFormat(value, compactValue) && !focused && displayValue}>
217211
<Input
218212
onMouseDown={onClick}
219213
ref={inputRef}

packages/core/src/ui/components/AssetInput/AssetInputRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const AssetInputRow = ({
3232
if (!isInFocusableArea)
3333
// do not apply compact notation in case we are still in the focusable area
3434
onBlur?.({
35-
value: value ?? '0',
35+
value,
3636
id: coin.id,
3737
maxDecimals
3838
});
@@ -54,7 +54,7 @@ export const AssetInputRow = ({
5454
() => {
5555
setIsFocused(false);
5656
onBlur?.({
57-
value: value ?? '0',
57+
value,
5858
id: coin.id,
5959
maxDecimals
6060
});

packages/core/src/ui/components/Transaction/CopiableHash.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import CopyToClipboard from 'react-copy-to-clipboard';
44

55
const TOAST_DEFAULT_DURATION = 3;
66

7-
export const CopiableHash = ({ hash, copiedText }: { hash: string; copiedText: string }): React.ReactElement => (
7+
export const CopiableHash = ({ hash = '', copiedText }: { hash?: string; copiedText: string }): React.ReactElement => (
88
<CopyToClipboard text={hash}>
99
<div
1010
onClick={() =>

packages/core/src/ui/components/Transaction/TxHash.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ type TxHashProps = {
1414
export const TxHash = ({ hash, success, sending, openLink }: TxHashProps): React.ReactElement => {
1515
const { t } = useTranslation();
1616
const hashComponent = useMemo(
17-
() =>
18-
sending && hash ? <CopiableHash hash={hash} copiedText={t('core.activityDetails.copiedToClipboard')} /> : hash,
17+
() => (sending ? <CopiableHash hash={hash} copiedText={t('core.activityDetails.copiedToClipboard')} /> : hash),
1918
[hash, sending, t]
2019
);
2120

@@ -34,7 +33,7 @@ export const TxHash = ({ hash, success, sending, openLink }: TxHashProps): React
3433
})}
3534
onClick={openLink}
3635
>
37-
{hashComponent && <div>{hashComponent}</div>}
36+
<div>{hashComponent}</div>
3837
</div>
3938
</div>
4039
);

packages/staking/src/features/overview/StakingInfoCard/StakingInfoCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export const StakingInfoCard = ({
7777
id,
7878
logo,
7979
margin,
80-
name = '',
80+
name,
8181
totalRewards,
8282
lastReward,
8383
ros,

0 commit comments

Comments
 (0)