diff --git a/.eslintrc.js b/.eslintrc.js index fc724dd4a95..edbe2143bb0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,6 +51,12 @@ module.exports = { rules: { // under discussion 'no-unused-vars': 'off', + 'react/no-unstable-nested-components': [ + 'warn', + { + allowAsProps: true, + }, + ], }, }, { diff --git a/.vscode/settings.json b/.vscode/settings.json index 5eb140d7b1f..c74344a3637 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,7 @@ "cucumberautocomplete.steps": ["wdio/step-definitions/**/*.js"], "cucumberautocomplete.syncfeatures": "wdio/to/features/*.feature", "cucumberautocomplete.strictGherkinCompletion": true, - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "javascript.preferences.importModuleSpecifier": "relative", + "typescript.preferences.importModuleSpecifier": "relative" } diff --git a/app/actions/onboarding/index.ts b/app/actions/onboarding/index.ts index 9866cf8d17b..e85dd902fe3 100644 --- a/app/actions/onboarding/index.ts +++ b/app/actions/onboarding/index.ts @@ -25,4 +25,4 @@ export function clearOnboardingEvents(): ClearEventsAction { return { type: CLEAR_EVENTS, }; -} \ No newline at end of file +} diff --git a/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx b/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx index d92a8bbb5d7..5ba78777e38 100644 --- a/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx +++ b/app/component-library/components-temp/Contracts/ContractBoxBase/ContractBoxBase.tsx @@ -39,7 +39,7 @@ const ContractBoxBase = ({ theme: { colors }, } = useStyles(styleSheet, {}); - const IconView = ({ onPress, name, size, testID }: IconViewProps) => ( + const renderIconView = ({ onPress, name, size, testID }: IconViewProps) => ( @@ -78,20 +78,19 @@ const ContractBoxBase = ({ )} - - {hasBlockExplorer && ( - - )} + {renderIconView({ + onPress: onCopyAddress, + name: IconName.Copy, + size: IconSize.Lg, + testID: COPY_ICON_TEST_ID, + })} + {hasBlockExplorer && + renderIconView({ + onPress: onExportAddress, + name: IconName.Export, + size: IconSize.Md, + testID: EXPORT_ICON_TEST_ID, + })} ); diff --git a/app/component-library/components-temp/Contracts/ContractBoxBase/__snapshots__/ContractBoxBase.test.tsx.snap b/app/component-library/components-temp/Contracts/ContractBoxBase/__snapshots__/ContractBoxBase.test.tsx.snap index 01c380bb58a..56c4c78ddc2 100644 --- a/app/component-library/components-temp/Contracts/ContractBoxBase/__snapshots__/ContractBoxBase.test.tsx.snap +++ b/app/component-library/components-temp/Contracts/ContractBoxBase/__snapshots__/ContractBoxBase.test.tsx.snap @@ -65,12 +65,21 @@ exports[`Component ContractBoxBase should render correctly 1`] = ` } } > - + > + + `; diff --git a/app/components/Nav/App/index.js b/app/components/Nav/App/index.js index a587ef6c3ae..5d395121700 100644 --- a/app/components/Nav/App/index.js +++ b/app/components/Nav/App/index.js @@ -326,6 +326,231 @@ const VaultRecoveryFlow = () => ( ); +const EditAccountNameFlow = () => ( + + + +); + +// eslint-disable-next-line react/prop-types +const AddNetworkFlow = ({ route }) => ( + + + +); +const DetectedTokensFlow = () => ( + + + + +); + +const RootModalFlow = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {isNetworkUiRedesignEnabled() ? ( + + ) : null} + + + + +); + +const ImportPrivateKeyView = () => ( + + + + + +); + +const ConnectQRHardwareFlow = () => ( + + + +); + +const LedgerConnectFlow = () => ( + + + +); + +const ConnectHardwareWalletFlow = () => ( + + + +); + const App = (props) => { const { userLoggedIn } = props; // FIXME: Remove this when the unit tests are resolved for rendering this component. This property is only used by unit tests at the moment. Tests break when this is removed. @@ -564,241 +789,6 @@ const App = (props) => { } }; - const DetectedTokensFlow = () => ( - - - - - ); - - const RootModalFlow = () => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {isNetworkUiRedesignEnabled() ? ( - - ) : null} - - - - - ); - - const ImportPrivateKeyView = () => ( - - - - - - ); - - const ConnectQRHardwareFlow = () => ( - - - - ); - - const LedgerConnectFlow = () => ( - - - - ); - - const ConnectHardwareWalletFlow = () => ( - - - - ); - - const EditAccountNameFlow = () => ( - - - - ); - - // eslint-disable-next-line react/prop-types - const AddNetworkFlow = ({ route }) => ( - - - - ); - return supressRender ? null : ( <> { diff --git a/app/components/Nav/Main/MainNavigator.js b/app/components/Nav/Main/MainNavigator.js index dd7342adc58..e884d1664a1 100644 --- a/app/components/Nav/Main/MainNavigator.js +++ b/app/components/Nav/Main/MainNavigator.js @@ -498,20 +498,25 @@ const HomeTabs = () => { } }, []); + const renderTabBar = ({ state, descriptors, navigation }) => { + if (isKeyboardHidden) { + return ( + + ); + } + return null; + }; + return ( - isKeyboardHidden ? ( - - ) : null - } + tabBar={renderTabBar} > - Edit priority + + + { + const getAnalyticsParams = () => { try { return { ...analyticsParams, @@ -215,9 +214,9 @@ const EditGasFee1559 = ({ } catch (error) { return {}; } - }, [analyticsParams, chainId, selectedOption, view]); + }; - const toggleAdvancedOptions = useCallback(() => { + const toggleAdvancedOptions = () => { if (!showAdvancedOptions) { trackEvent( MetaMetricsEvents.GAS_ADVANCED_OPTIONS_CLICKED, @@ -225,158 +224,138 @@ const EditGasFee1559 = ({ ); } setShowAdvancedOptions((showAdvancedOptions) => !showAdvancedOptions); - }, [getAnalyticsParams, showAdvancedOptions, trackEvent]); + }; - const toggleLearnMoreModal = useCallback(() => { + const toggleLearnMoreModal = () => { setShowLearnMoreModal((showLearnMoreModal) => !showLearnMoreModal); - }, []); + }; - const save = useCallback(() => { + const save = () => { trackEvent(MetaMetricsEvents.GAS_FEE_CHANGED, getAnalyticsParams()); onSave(selectedOption); - }, [getAnalyticsParams, onSave, selectedOption, trackEvent]); - - const changeGas = useCallback( - (gas, selectedOption) => { - setSelectedOption(selectedOption); - onChange(gas, selectedOption); - }, - [onChange], - ); - - const changedMaxPriorityFee = useCallback( - (value) => { - const lowerValue = new BigNumber( - gasOptions?.[ - warningMinimumEstimateOption - ]?.suggestedMaxPriorityFeePerGas, + }; + + const changeGas = (gas, selectedOption) => { + setSelectedOption(selectedOption); + onChange(gas, selectedOption); + }; + + const changedMaxPriorityFee = (value) => { + const lowerValue = new BigNumber( + gasOptions?.[warningMinimumEstimateOption]?.suggestedMaxPriorityFeePerGas, + ); + const higherValue = new BigNumber( + gasOptions?.high?.suggestedMaxPriorityFeePerGas, + ).multipliedBy(new BigNumber(1.5)); + const updateFloor = new BigNumber(updateOption?.maxPriortyFeeThreshold); + + const valueBN = new BigNumber(value); + + if (updateFloor && !updateFloor.isNaN() && valueBN.lt(updateFloor)) { + setMaxPriorityFeeError( + updateOption?.isCancel + ? strings('edit_gas_fee_eip1559.max_priority_fee_cancel_low', { + cancel_value: updateFloor, + }) + : strings('edit_gas_fee_eip1559.max_priority_fee_speed_up_low', { + speed_up_floor_value: updateFloor, + }), ); - const higherValue = new BigNumber( - gasOptions?.high?.suggestedMaxPriorityFeePerGas, - ).multipliedBy(new BigNumber(1.5)); - const updateFloor = new BigNumber(updateOption?.maxPriortyFeeThreshold); - - const valueBN = new BigNumber(value); - - if (updateFloor && !updateFloor.isNaN() && valueBN.lt(updateFloor)) { - setMaxPriorityFeeError( - updateOption?.isCancel - ? strings('edit_gas_fee_eip1559.max_priority_fee_cancel_low', { - cancel_value: updateFloor, - }) - : strings('edit_gas_fee_eip1559.max_priority_fee_speed_up_low', { - speed_up_floor_value: updateFloor, - }), - ); - } else if (!lowerValue.isNaN() && valueBN.lt(lowerValue)) { - setMaxPriorityFeeError( - strings('edit_gas_fee_eip1559.max_priority_fee_low'), - ); - } else if (!higherValue.isNaN() && valueBN.gt(higherValue)) { - setMaxPriorityFeeError( - strings('edit_gas_fee_eip1559.max_priority_fee_high'), - ); - } else { - setMaxPriorityFeeError(''); - } - - const newGas = { ...gasFee, suggestedMaxPriorityFeePerGas: value }; - - changeGas(newGas, null); - }, - [changeGas, gasFee, gasOptions, updateOption, warningMinimumEstimateOption], - ); - - const changedMaxFeePerGas = useCallback( - (value) => { - const lowerValue = new BigNumber( - gasOptions?.[warningMinimumEstimateOption]?.suggestedMaxFeePerGas, + } else if (!lowerValue.isNaN() && valueBN.lt(lowerValue)) { + setMaxPriorityFeeError( + strings('edit_gas_fee_eip1559.max_priority_fee_low'), ); - const higherValue = new BigNumber( - gasOptions?.high?.suggestedMaxFeePerGas, - ).multipliedBy(new BigNumber(1.5)); - const updateFloor = new BigNumber(updateOption?.maxFeeThreshold); - - const valueBN = new BigNumber(value); - - if (updateFloor && !updateFloor.isNaN() && valueBN.lt(updateFloor)) { - setMaxFeeError( - updateOption?.isCancel - ? strings('edit_gas_fee_eip1559.max_fee_cancel_low', { - cancel_value: updateFloor, - }) - : strings('edit_gas_fee_eip1559.max_fee_speed_up_low', { - speed_up_floor_value: updateFloor, - }), - ); - } else if (!lowerValue.isNaN() && valueBN.lt(lowerValue)) { - setMaxFeeError(strings('edit_gas_fee_eip1559.max_fee_low')); - } else if (!higherValue.isNaN() && valueBN.gt(higherValue)) { - setMaxFeeError(strings('edit_gas_fee_eip1559.max_fee_high')); - } else { - setMaxFeeError(''); - } - - const newGas = { ...gasFee, suggestedMaxFeePerGas: value }; - changeGas(newGas, null); - }, - [changeGas, gasFee, gasOptions, updateOption, warningMinimumEstimateOption], - ); - - const changedGasLimit = useCallback( - (value) => { - const newGas = { ...gasFee, suggestedGasLimit: value }; - changeGas(newGas, null); - }, - [changeGas, gasFee], - ); + } else if (!higherValue.isNaN() && valueBN.gt(higherValue)) { + setMaxPriorityFeeError( + strings('edit_gas_fee_eip1559.max_priority_fee_high'), + ); + } else { + setMaxPriorityFeeError(''); + } - const selectOption = useCallback( - (option) => { - setSelectedOption(option); + const newGas = { ...gasFee, suggestedMaxPriorityFeePerGas: value }; + + changeGas(newGas, null); + }; + + const changedMaxFeePerGas = (value) => { + const lowerValue = new BigNumber( + gasOptions?.[warningMinimumEstimateOption]?.suggestedMaxFeePerGas, + ); + const higherValue = new BigNumber( + gasOptions?.high?.suggestedMaxFeePerGas, + ).multipliedBy(new BigNumber(1.5)); + const updateFloor = new BigNumber(updateOption?.maxFeeThreshold); + + const valueBN = new BigNumber(value); + + if (updateFloor && !updateFloor.isNaN() && valueBN.lt(updateFloor)) { + setMaxFeeError( + updateOption?.isCancel + ? strings('edit_gas_fee_eip1559.max_fee_cancel_low', { + cancel_value: updateFloor, + }) + : strings('edit_gas_fee_eip1559.max_fee_speed_up_low', { + speed_up_floor_value: updateFloor, + }), + ); + } else if (!lowerValue.isNaN() && valueBN.lt(lowerValue)) { + setMaxFeeError(strings('edit_gas_fee_eip1559.max_fee_low')); + } else if (!higherValue.isNaN() && valueBN.gt(higherValue)) { + setMaxFeeError(strings('edit_gas_fee_eip1559.max_fee_high')); + } else { setMaxFeeError(''); - setMaxPriorityFeeError(''); - changeGas({ ...gasOptions[option] }, option); - }, - [changeGas, gasOptions], - ); + } - const shouldIgnore = useCallback( - (option) => ignoreOptions.find((item) => item === option), - [ignoreOptions], + const newGas = { ...gasFee, suggestedMaxFeePerGas: value }; + changeGas(newGas, null); + }; + + const changedGasLimit = (value) => { + const newGas = { ...gasFee, suggestedGasLimit: value }; + changeGas(newGas, null); + }; + + const selectOption = (option) => { + setSelectedOption(option); + setMaxFeeError(''); + setMaxPriorityFeeError(''); + changeGas({ ...gasOptions[option] }, option); + }; + + const shouldIgnore = (option) => + ignoreOptions.find((item) => item === option); + + const renderLabel = (selected, disabled, label) => ( + + {label} + ); - const renderOptions = useMemo( - () => - [ - { - name: AppConstants.GAS_OPTIONS.LOW, - label: strings('edit_gas_fee_eip1559.low'), - }, - { - name: AppConstants.GAS_OPTIONS.MEDIUM, - label: strings('edit_gas_fee_eip1559.market'), - }, - { - name: AppConstants.GAS_OPTIONS.HIGH, - label: strings('edit_gas_fee_eip1559.aggressive'), - }, - ] - .filter(({ name }) => !shouldIgnore(name)) - .map(({ name, label, ...option }) => ({ - name, - label: (selected, disabled) => ( - - {label} - - ), - topLabel: recommended?.name === name && recommended.render, - ...option, - ...extendOptions[name], - })), - [recommended, extendOptions, shouldIgnore], - ); + const renderOptions = () => + [ + { + name: AppConstants.GAS_OPTIONS.LOW, + label: strings('edit_gas_fee_eip1559.low'), + }, + { + name: AppConstants.GAS_OPTIONS.MEDIUM, + label: strings('edit_gas_fee_eip1559.market'), + }, + { + name: AppConstants.GAS_OPTIONS.HIGH, + label: strings('edit_gas_fee_eip1559.aggressive'), + }, + ] + .filter(({ name }) => !shouldIgnore(name)) + .map(({ name, label, ...option }) => ({ + name, + label: renderLabel(selectedOption === name, false, label), + topLabel: recommended?.name === name && recommended.render, + ...option, + ...extendOptions[name], + })); const isMainnet = isMainnetByChainId(chainId); const nativeCurrencySelected = primaryCurrency === 'ETH' || !isMainnet; @@ -579,7 +558,7 @@ const EditGasFee1559 = ({ ); - const renderWarning = useMemo(() => { + const renderWarning = () => { if (!warning) return null; if (typeof warning === 'string') return ( @@ -606,9 +585,9 @@ const EditGasFee1559 = ({ ); return warning; - }, [warning, styles, colors]); + }; - const renderError = useMemo(() => { + const renderError = () => { if (!error) return null; if (typeof error === 'string') return ( @@ -635,15 +614,15 @@ const EditGasFee1559 = ({ ); return error; - }, [error, styles, colors]); + }; - const renderDisplayTitle = useMemo(() => { + const renderDisplayTitle = () => { if (updateOption) return updateOption.isCancel ? strings('edit_gas_fee_eip1559.cancel_transaction') : strings('edit_gas_fee_eip1559.speed_up_transaction'); return strings('edit_gas_fee_eip1559.edit_priority'); - }, [updateOption]); + }; return ( diff --git a/app/components/UI/EditGasFeeLegacy/__snapshots__/index.test.tsx.snap b/app/components/UI/EditGasFeeLegacy/__snapshots__/index.test.tsx.snap index 2925ad35a5c..b64630444d7 100644 --- a/app/components/UI/EditGasFeeLegacy/__snapshots__/index.test.tsx.snap +++ b/app/components/UI/EditGasFeeLegacy/__snapshots__/index.test.tsx.snap @@ -57,6 +57,8 @@ exports[`EditGasFeeLegacy should render correctly 1`] = ` /> + + { + const getAnalyticsParams = () => { try { return { ...analyticsParams, @@ -163,9 +163,9 @@ const EditGasFeeLegacy = ({ } catch (error) { return {}; } - }, [analyticsParams, chainId, selectedOption, view]); + }; - const toggleAdvancedOptions = useCallback(() => { + const toggleAdvancedOptions = () => { if (!showAdvancedOptions) { trackEvent( MetaMetricsEvents.GAS_ADVANCED_OPTIONS_CLICKED, @@ -173,113 +173,92 @@ const EditGasFeeLegacy = ({ ); } setShowAdvancedOptions((showAdvancedOptions) => !showAdvancedOptions); - }, [getAnalyticsParams, showAdvancedOptions, trackEvent]); + }; - const save = useCallback(() => { + const save = () => { trackEvent(MetaMetricsEvents.GAS_FEE_CHANGED, getAnalyticsParams()); onSave(selectedOption); - }, [getAnalyticsParams, onSave, selectedOption, trackEvent]); + }; - const changeGas = useCallback( - (gas, selectedOption) => { - setSelectedOption(selectedOption); - onChange(gas, selectedOption); - }, - [onChange], - ); + const changeGas = (gas, selectedOption) => { + setSelectedOption(selectedOption); + onChange(gas, selectedOption); + }; - const changedGasPrice = useCallback( - (value) => { - const lowerValue = new BigNumber( - gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY - ? gasOptions?.[warningMinimumEstimateOption] - : gasOptions?.gasPrice, - ); - const higherValue = new BigNumber( - gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY - ? gasOptions?.high - : gasOptions?.gasPrice, - ).multipliedBy(new BigNumber(1.5)); + const changedGasPrice = (value) => { + const lowerValue = new BigNumber( + gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY + ? gasOptions?.[warningMinimumEstimateOption] + : gasOptions?.gasPrice, + ); + const higherValue = new BigNumber( + gasEstimateType === GAS_ESTIMATE_TYPES.LEGACY + ? gasOptions?.high + : gasOptions?.gasPrice, + ).multipliedBy(new BigNumber(1.5)); - const valueBN = new BigNumber(value); + const valueBN = new BigNumber(value); - if (!lowerValue.isNaN() && valueBN.lt(lowerValue)) { - setGasPriceError(strings('edit_gas_fee_eip1559.gas_price_low')); - } else if (!higherValue.isNaN() && valueBN.gt(higherValue)) { - setGasPriceError(strings('edit_gas_fee_eip1559.gas_price_high')); - } else { - setGasPriceError(''); - } + if (!lowerValue.isNaN() && valueBN.lt(lowerValue)) { + setGasPriceError(strings('edit_gas_fee_eip1559.gas_price_low')); + } else if (!higherValue.isNaN() && valueBN.gt(higherValue)) { + setGasPriceError(strings('edit_gas_fee_eip1559.gas_price_high')); + } else { + setGasPriceError(''); + } - const newGas = { ...gasFee, suggestedGasPrice: value }; + const newGas = { ...gasFee, suggestedGasPrice: value }; - changeGas(newGas, null); - }, - [ - changeGas, - gasEstimateType, - gasFee, - gasOptions, - warningMinimumEstimateOption, - ], - ); + changeGas(newGas, null); + }; - const changedGasLimit = useCallback( - (value) => { - const newGas = { ...gasFee, suggestedGasLimit: value }; + const changedGasLimit = (value) => { + const newGas = { ...gasFee, suggestedGasLimit: value }; - changeGas(newGas, null); - }, - [changeGas, gasFee], - ); + changeGas(newGas, null); + }; - const selectOption = useCallback( - (option) => { - setGasPriceError(''); - setSelectedOption(option); - changeGas({ ...gasFee, suggestedGasPrice: gasOptions[option] }, option); - }, - [changeGas, gasFee, gasOptions], - ); + const selectOption = (option) => { + setGasPriceError(''); + setSelectedOption(option); + changeGas({ ...gasFee, suggestedGasPrice: gasOptions[option] }, option); + }; - const shouldIgnore = useCallback( - (option) => ignoreOptions.find((item) => item === option), - [ignoreOptions], - ); + const shouldIgnore = (option) => + ignoreOptions.find((item) => item === option); - const renderOptions = useMemo( - () => - [ - { - name: AppConstants.GAS_OPTIONS.LOW, - label: strings('edit_gas_fee_eip1559.low'), - }, - { - name: AppConstants.GAS_OPTIONS.MEDIUM, - label: strings('edit_gas_fee_eip1559.medium'), - }, - { - name: AppConstants.GAS_OPTIONS.HIGH, - label: strings('edit_gas_fee_eip1559.high'), - }, - ] - .filter(({ name }) => !shouldIgnore(name)) - .map(({ name, label, ...option }) => ({ - name, - label: (selected, disabled) => ( - - {label} - - ), - topLabel: recommended?.name === name && recommended.render, - ...option, - ...extendOptions[name], - })), - [recommended, extendOptions, shouldIgnore], + const renderLabel = (selected, disabled, label) => ( + + {label} + ); - const renderWarning = useMemo(() => { + const renderOptions = () => + [ + { + name: AppConstants.GAS_OPTIONS.LOW, + label: strings('edit_gas_fee_eip1559.low'), + }, + { + name: AppConstants.GAS_OPTIONS.MEDIUM, + label: strings('edit_gas_fee_eip1559.medium'), + }, + { + name: AppConstants.GAS_OPTIONS.HIGH, + label: strings('edit_gas_fee_eip1559.high'), + }, + ] + .filter(({ name }) => !shouldIgnore(name)) + .map(({ name, label, ...option }) => ({ + name, + label: renderLabel(selectedOption === name, false, label), + topLabel: recommended?.name === name && recommended.render, + ...option, + ...extendOptions[name], + })); + + const renderWarning = () => { if (!warning) return null; if (typeof warning === 'string') return ( @@ -306,9 +285,9 @@ const EditGasFeeLegacy = ({ ); return warning; - }, [warning, styles, colors]); + }; - const renderError = useMemo(() => { + const renderError = () => { if (!error) return null; if (typeof error === 'string') return ( @@ -335,7 +314,7 @@ const EditGasFeeLegacy = ({ ); return error; - }, [error, styles, colors]); + }; const isMainnet = isMainnetByChainId(chainId); const nativeCurrencySelected = primaryCurrency === 'ETH' || !isMainnet; diff --git a/app/components/UI/NetworkModal/NetworkDetails/index.tsx b/app/components/UI/NetworkModal/NetworkDetails/index.tsx index 9cbd21cb053..cc9ab3c5e66 100644 --- a/app/components/UI/NetworkModal/NetworkDetails/index.tsx +++ b/app/components/UI/NetworkModal/NetworkDetails/index.tsx @@ -60,7 +60,7 @@ const NetworkDetails = (props: NetworkDetailsProps) => { }, ]; - const DetailsView = () => ( + const renderDetailsView = () => ( <> {DisplayData.map((item, index) => ( @@ -79,9 +79,7 @@ const NetworkDetails = (props: NetworkDetailsProps) => { action={goBack} title={strings('networks.network_details')} /> - - - + {renderDetailsView()} ); }; diff --git a/app/components/UI/SimulationDetails/AssetPill/AssetPill.tsx b/app/components/UI/SimulationDetails/AssetPill/AssetPill.tsx index 534c0d58c50..8830e10e79b 100644 --- a/app/components/UI/SimulationDetails/AssetPill/AssetPill.tsx +++ b/app/components/UI/SimulationDetails/AssetPill/AssetPill.tsx @@ -66,7 +66,7 @@ const AssetPill: React.FC = ({ asset }) => { preferContractSymbol testID="simulation-details-asset-pill-name" type={NameType.EthereumAddress} - value={asset.address as Hex} + value={asset.address as Hex} /> )} diff --git a/app/components/Views/NavigationUnitTest/__snapshots__/TestScreen2.test.js.snap b/app/components/Views/NavigationUnitTest/__snapshots__/TestScreen2.test.js.snap index ae5908847fd..bae18b32fea 100644 --- a/app/components/Views/NavigationUnitTest/__snapshots__/TestScreen2.test.js.snap +++ b/app/components/Views/NavigationUnitTest/__snapshots__/TestScreen2.test.js.snap @@ -414,7 +414,7 @@ exports[`NavigationUnitTest should render correctly 1`] = ` } } > - TestScreen2 + TestSubStack @@ -592,10 +592,309 @@ exports[`NavigationUnitTest should render correctly 1`] = ` } } > - - TestScreen2 - THIS SHOULD NOT HAVE CHANGED, take a deeper look - + + + + + + + + + + + + TestScreen3 + + + + + + + + + + + + + + + + + + TestScreen3 + THIS SHOULD NOT HAVE CHANGED, take a deeper look + + + + + + + + + + diff --git a/app/components/Views/NavigationUnitTest/index.js b/app/components/Views/NavigationUnitTest/index.js index f142272337c..b81c3f8d469 100644 --- a/app/components/Views/NavigationUnitTest/index.js +++ b/app/components/Views/NavigationUnitTest/index.js @@ -15,54 +15,55 @@ import { Text } from 'react-native'; const Stack = createStackNavigator(); -const NavigationUnitTestFactory = ({ firstRoute, secondRoute }) => { - const TestScreen = ({ route }) => { - const routes = useNavigationState((state) => state.routes); +const TestScreen = ({ route }) => { + const routes = useNavigationState((state) => state.routes); - const name = findRouteNameFromNavigatorState(routes); + const name = findRouteNameFromNavigatorState(routes); - if (name !== route.params.screenName) - throw new Error( - 'Error, react navigation api changed: https://reactnavigation.org/docs/navigation-prop/#dangerouslygetstate', - ); + if (name !== route.params.screenName) + throw new Error( + 'Error, react navigation api changed: https://reactnavigation.org/docs/navigation-prop/#dangerouslygetstate', + ); - return {name} THIS SHOULD NOT HAVE CHANGED, take a deeper look; - }; + return {name} THIS SHOULD NOT HAVE CHANGED, take a deeper look; +}; - const TestSubStack = () => ( - - - - ); +const TestSubStack = () => ( + + + +); + +const TestStack = ({ secondRoute }) => ( + + + + +); - const TestStack = () => ( - - +const NavigationUnitTest = ({ firstRoute, secondRoute }) => ( + + + - ); + +); - const NavigationUnitTest = () => ( - - - - - - - ); +const NavigationUnitTestFactory = ({ firstRoute, secondRoute }) => ( + +); - return ; -}; export default NavigationUnitTestFactory; diff --git a/app/components/Views/Settings/ExperimentalSettings/index.tsx b/app/components/Views/Settings/ExperimentalSettings/index.tsx index 36b48a32ac0..98aa85ebb99 100644 --- a/app/components/Views/Settings/ExperimentalSettings/index.tsx +++ b/app/components/Views/Settings/ExperimentalSettings/index.tsx @@ -1,4 +1,4 @@ -import React, { FC, useCallback, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Linking, ScrollView, Switch, View } from 'react-native'; import { MMKV } from 'react-native-mmkv'; @@ -57,13 +57,13 @@ const ExperimentalSettings = ({ navigation, route }: Props) => { [colors], ); - const goToWalletConnectSessions = useCallback(() => { + const goToWalletConnectSessions = () => { navigation.navigate(Routes.WALLET.WALLET_CONNECT_SESSIONS_VIEW); - }, [navigation]); + }; const openSesLink = () => Linking.openURL(SES_URL); - const WalletConnectSettings: FC = () => ( + const renderWalletConnectSettings = () => ( <> {strings('experimental_settings.wallet_connect_dapps')} @@ -86,7 +86,7 @@ const ExperimentalSettings = ({ navigation, route }: Props) => { ); - const SesSettings: FC = () => ( + const renderSesSettings = () => ( <> { return ( - - {Device.isIos() && } + {renderWalletConnectSettings()} + {Device.isIos() && renderSesSettings()} ); }; diff --git a/app/components/Views/SmartTransactionStatus/SmartTransactionStatus.tsx b/app/components/Views/SmartTransactionStatus/SmartTransactionStatus.tsx index c99d82cf9b9..6762a6785d0 100644 --- a/app/components/Views/SmartTransactionStatus/SmartTransactionStatus.tsx +++ b/app/components/Views/SmartTransactionStatus/SmartTransactionStatus.tsx @@ -329,7 +329,7 @@ const SmartTransactionStatus = ({ const percentComplete = (1 - timeLeftForPendingStxInSec / stxDeadlineSec) * 100; - const PrimaryButton = () => + const renderPrimaryButton = () => handlePrimaryButtonPress ? ( ); - const SecondaryButton = () => ( + const renderSecondaryButton = () => (