From 8d9edf62eb66a4397d90d8bb7de71a6c99a27966 Mon Sep 17 00:00:00 2001 From: "Valentin D. Pinkman" Date: Mon, 25 Sep 2023 15:07:20 +0200 Subject: [PATCH] chore: fix ts error on LLM --- apps/ledger-live-desktop/package.json | 2 +- apps/ledger-live-mobile/package.json | 2 +- .../src/__test__/test-renderer.tsx | 2 +- .../src/bridge/BridgeSyncContext.tsx | 6 +- .../src/components/AccountGraphCard.tsx | 9 +- .../src/components/AccountSelector.tsx | 2 +- .../src/components/AnalyticsConsole/index.tsx | 4 +- .../AnalyticsConsole/useAnalyticsEventsLog.ts | 3 +- .../src/components/AnimatedHeader.tsx | 5 +- .../src/components/AssetCentricGraphCard.tsx | 4 +- .../BleDevicesScanning.tsx | 2 +- .../src/components/BulletList.tsx | 4 +- .../src/components/Carousel/index.tsx | 6 +- .../src/components/CollapsibleList.tsx | 2 +- .../src/components/CounterValue.tsx | 2 +- .../CustomImage/CustomImageBottomModal.tsx | 2 +- .../components/CustomImage/ImageCropper.tsx | 2 +- .../CustomImage/StaxFramedLottie.tsx | 1 + .../components/CustomImageDeviceAction.tsx | 3 +- .../src/components/DoubleCountervalue.tsx | 2 +- .../src/components/ExternalLink.tsx | 3 +- .../src/components/GraphCard.tsx | 4 +- .../Nft/NftGallery/NftFilterChip.tsx | 5 +- .../NftFilterDrawer/NftFilterItem.tsx | 11 +- .../NftFilterDrawer/NftFilterSection.tsx | 7 +- .../Nft/NftGallery/NftFilterDrawer/index.tsx | 8 +- .../components/PerformanceConsole/index.tsx | 4 +- .../RootNavigator/MainNavigator.tsx | 2 +- .../src/components/SafeMarkdown.tsx | 1 + .../src/components/SelectFeesStrategy.tsx | 2 +- .../src/components/SelectableAccountsList.tsx | 3 +- .../StorylyStories/StoriesConfig.tsx | 10 +- .../src/components/StorylyStories/index.tsx | 5 +- .../src/components/ToggleButton.tsx | 4 +- .../Web3AppWebview/PlatformAPIWebview.tsx | 4 +- .../src/components/Web3AppWebview/helpers.ts | 4 +- .../WebPlatformPlayer/InfoPanel.tsx | 2 +- .../src/components/wrappedUi/Button.tsx | 3 +- .../src/components/wrappedUi/Link.tsx | 3 +- .../src/context/DiscreetModeContext.tsx | 2 +- .../algorand/OptInFlow/01-SelectToken.tsx | 1 + .../src/families/bitcoin/SendRowsFee.tsx | 4 +- .../celo/ActivateFlow/SelectValidator.tsx | 33 +++-- .../src/families/celo/LockFlow/01-Amount.tsx | 2 +- .../celo/RevokeFlow/SelectValidator.tsx | 27 ++-- .../families/celo/UnlockFlow/01-Amount.tsx | 2 +- .../celo/VoteFlow/SelectValidator.tsx | 4 +- .../celo/WithdrawFlow/WithdrawAmount.tsx | 5 +- .../src/families/celo/operationDetails.tsx | 3 +- .../ClaimRewardsFlow/01-SelectValidator.tsx | 16 ++- .../ClaimRewardsFlow/02-SelectMethod.tsx | 2 +- .../src/families/cosmos/operationDetails.tsx | 2 +- .../src/families/evm/EditFeeUnitEvm.tsx | 6 +- .../src/families/evm/EvmFeesStrategy.tsx | 4 +- .../src/families/evm/SelectFeesStrategy.tsx | 2 +- .../families/hedera/NoAssociatedAccounts.tsx | 4 +- .../families/near/shared/02-SelectAmount.tsx | 2 +- .../families/polkadot/BondFlow/02-Amount.tsx | 2 +- .../polkadot/NominateFlow/01-Validators.tsx | 15 ++- .../polkadot/NominateFlow/drawerInfo.tsx | 36 ++--- .../polkadot/Nominations/drawerInfo.tsx | 11 +- .../families/polkadot/Nominations/index.tsx | 9 +- .../polkadot/RebondFlow/01-Amount.tsx | 2 +- .../polkadot/TransactionConfirmFields.tsx | 2 +- .../polkadot/UnbondFlow/01-Amount.tsx | 2 +- .../families/polkadot/operationDetails.tsx | 4 +- .../stacks/TransactionConfirmFields.tsx | 2 +- .../stellar/AddAssetFlow/01-SelectAsset.tsx | 4 +- .../families/stellar/ScreenEditMemoType.tsx | 2 +- .../tezos/DelegationFlow/SelectValidator.tsx | 5 +- .../src/families/tron/operationDetails.tsx | 2 +- .../src/helpers/formatAccountSearchResults.ts | 2 +- apps/ledger-live-mobile/src/index.tsx | 4 +- .../src/logic/notifications.tsx | 6 +- .../src/logic/npsRatings.tsx | 10 +- apps/ledger-live-mobile/src/logic/ratings.tsx | 19 +-- .../src/logic/screenTransactionHooks.ts | 16 ++- .../src/navigation/utils.ts | 1 + .../screens/Account/NftCollectionsList.tsx | 6 +- .../src/screens/Account/SubAccountsList.tsx | 4 +- .../screens/AddAccounts/02-SelectDevice.tsx | 3 +- .../src/screens/Analytics/Operations.tsx | 10 +- .../src/screens/ClaimNft/ClaimNftQrScan.tsx | 4 +- .../src/screens/ConnectDevice.tsx | 4 +- .../src/screens/CustomImage/Step1Crop.tsx | 3 +- .../CustomImage/Step2ChooseContrast.tsx | 2 +- .../FeatureFlagsSettings/FeatureFlagEdit.tsx | 6 +- .../FeatureFlagsSettings/GroupedFeatures.tsx | 2 +- .../screens/FeatureFlagsSettings/index.tsx | 4 +- .../FirmwareUpdate/RestoreStepDenied.tsx | 14 +- .../src/screens/FreezeFunds/02-Amount.tsx | 6 +- .../Manager/AppsList/AppUpdateStepper.tsx | 1 + .../screens/Manager/Device/DeviceLanguage.tsx | 4 +- .../screens/Manager/Modals/FilterModal.tsx | 12 +- .../screens/Market/MarketCurrencySelect.tsx | 4 +- .../Market/MarketDetail/MarketGraph.tsx | 4 +- .../src/screens/Market/index.tsx | 6 +- .../src/screens/Modals/index.tsx | 3 +- .../src/screens/Nft/NftCollection/index.tsx | 2 +- .../NotificationsProvider.tsx | 12 +- .../src/screens/NpsRatingsModal/Form.tsx | 10 +- .../src/screens/NpsRatingsModal/index.tsx | 3 +- .../src/screens/Onboarding/OnboardingQuiz.tsx | 6 +- .../steps/setupDevice/scenes/ConnectNano.tsx | 2 +- .../src/screens/Onboarding/steps/welcome.tsx | 2 +- .../Platform/exchange/CompleteExchange.tsx | 42 +++--- .../screens/RatingsModal/DisappointedForm.tsx | 4 +- .../src/screens/RatingsModal/Init.tsx | 9 +- .../src/screens/RatingsModal/index.tsx | 3 +- .../screens/ReceiveFunds/02-AddAccount.tsx | 2 +- .../02-AddAccountSelectDevice.tsx | 3 +- .../screens/ReceiveFunds/02-SelectAccount.tsx | 2 +- .../ReceiveFunds/03a-ConnectDevice.tsx | 1 + .../ReceiveSecurityModal/index.tsx | 3 +- .../RequestAccount/01-SelectCrypto.tsx | 6 +- .../RequestAccount/02-SelectAccount.tsx | 8 +- .../src/screens/SelectAccount.tsx | 3 +- .../src/screens/SelectDevice.tsx | 2 +- .../screens/SendFunds/02-SelectRecipient.tsx | 4 +- .../src/screens/SendFunds/03a-AmountCoin.tsx | 2 +- .../src/screens/SendFunds/03b-AmountNft.tsx | 2 +- .../Accounts/HiddenNftCollections.tsx | 2 +- .../src/screens/Settings/Accounts/index.tsx | 2 +- .../Currencies/CurrenciesList.tsx | 2 +- .../Settings/Debug/Configuration/DebugEnv.tsx | 2 +- .../Debug/Connectivity/CommandSender.tsx | 2 +- .../Settings/Debug/Debugging/Store.tsx | 4 +- .../screens/Settings/Debug/Features/Swap.tsx | 2 +- .../Generators/GenerateMockAccountsSelect.tsx | 6 +- .../Settings/Developer/CustomManifest.tsx | 2 +- .../Settings/Experimental/FeatureFloat.tsx | 5 +- .../Settings/Experimental/FeatureInteger.tsx | 5 +- .../Settings/General/BiometricsRow.tsx | 2 +- .../screens/Settings/General/CarouselRow.tsx | 2 +- .../SignTransaction/02-ConnectDevice.tsx | 1 + .../screens/Swap/Form/Modal/Confirmation.tsx | 4 +- .../src/screens/Swap/Form/Modal/index.tsx | 4 +- .../src/screens/Swap/Form/index.tsx | 10 +- .../screens/Swap/SubScreens/SelectAccount.tsx | 2 +- .../Swap/SubScreens/SelectCurrency.tsx | 3 +- .../screens/Swap/SubScreens/SelectFees.tsx | 2 +- .../src/screens/VerifyAccount/index.tsx | 2 +- .../WalletCentricAsset/AccountsSection.tsx | 4 +- .../OperationsHistory.tsx | 3 +- libs/domain-service/package.json | 2 +- libs/ledger-live-common/package.json | 2 +- pnpm-lock.yaml | 123 ++++++++---------- 147 files changed, 485 insertions(+), 377 deletions(-) diff --git a/apps/ledger-live-desktop/package.json b/apps/ledger-live-desktop/package.json index 973b597fcab6..7479660dbee2 100644 --- a/apps/ledger-live-desktop/package.json +++ b/apps/ledger-live-desktop/package.json @@ -198,7 +198,7 @@ "native-modules-tools": "workspace:*", "prebuild-install": "^7.1.1", "react-refresh": "^0.14.0", - "react-test-renderer": "^17.0.2", + "react-test-renderer": "^18.2.0", "serve-handler": "^6.1.3", "ts-jest": "^28.0.8", "vite": "^4.1.1", diff --git a/apps/ledger-live-mobile/package.json b/apps/ledger-live-mobile/package.json index 5b493705fd13..b20a5c4a12f8 100644 --- a/apps/ledger-live-mobile/package.json +++ b/apps/ledger-live-mobile/package.json @@ -262,7 +262,7 @@ "react-native-launch-arguments": "^4.0.1", "react-native-performance": "^3.1.2", "react-native-performance-flipper-reporter": "^3.0.0", - "react-test-renderer": "^18", + "react-test-renderer": "^18.2.0", "strip-ansi": "6.0.1", "ts-jest": "^28.0.8", "ts-node": "^10.4.0", diff --git a/apps/ledger-live-mobile/src/__test__/test-renderer.tsx b/apps/ledger-live-mobile/src/__test__/test-renderer.tsx index 315dca03be3f..e0247b28551a 100644 --- a/apps/ledger-live-mobile/src/__test__/test-renderer.tsx +++ b/apps/ledger-live-mobile/src/__test__/test-renderer.tsx @@ -9,7 +9,7 @@ import { i18n } from "../context/Locale"; import StyleProvider from "../StyleProvider"; -const ProvidersWrapper: React.FC = ({ children }) => { +const ProvidersWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => { return ( diff --git a/apps/ledger-live-mobile/src/bridge/BridgeSyncContext.tsx b/apps/ledger-live-mobile/src/bridge/BridgeSyncContext.tsx index b9b852ae23d5..72b9492fb685 100644 --- a/apps/ledger-live-mobile/src/bridge/BridgeSyncContext.tsx +++ b/apps/ledger-live-mobile/src/bridge/BridgeSyncContext.tsx @@ -7,16 +7,18 @@ import { accountsSelector } from "../reducers/accounts"; import { blacklistedTokenIdsSelector } from "../reducers/settings"; import { track } from "../analytics/segment"; import { prepareCurrency, hydrateCurrency } from "./cache"; +import { Account } from "@ledgerhq/types-live"; export const BridgeSyncProvider = ({ children }: { children: React.ReactNode }) => { const accounts = useSelector(accountsSelector); const blacklistedTokenIds = useSelector(blacklistedTokenIdsSelector); const dispatch = useDispatch(); const updateAccount = useCallback( - (accountId, updater) => dispatch(updateAccountWithUpdater({ accountId, updater })), + (accountId: string, updater: (arg0: Account) => Account) => + dispatch(updateAccountWithUpdater({ accountId, updater })), [dispatch], ); - const recoverError = useCallback(error => { + const recoverError = useCallback((error: Error) => { logger.critical(error); }, []); return ( diff --git a/apps/ledger-live-mobile/src/components/AccountGraphCard.tsx b/apps/ledger-live-mobile/src/components/AccountGraphCard.tsx index 8752f0409409..6d38894bddd3 100644 --- a/apps/ledger-live-mobile/src/components/AccountGraphCard.tsx +++ b/apps/ledger-live-mobile/src/components/AccountGraphCard.tsx @@ -102,7 +102,7 @@ function AccountGraphCard({ const activeRangeIndex = ranges.findIndex(r => r.value === timeRange); const updateRange = useCallback( - index => { + (index: number) => { if (ranges[index]) { const range = ranges[index].value as PortfolioRange; track("timeframe_clicked", { timeframe: range }); @@ -128,8 +128,11 @@ function AccountGraphCard({ const [hoveredItem, setHoverItem] = useState(); - const mapCryptoValue = useCallback(d => d.value || 0, []); - const mapCounterValue = useCallback(d => (d.countervalue ? d.countervalue : 0), []); + const mapCryptoValue = useCallback((d: Item) => d.value || 0, []); + const mapCounterValue = useCallback( + (d: Item) => (d && "countervalue" in d ? d.countervalue : 0), + [], + ); const graphColor = ensureContrast(getCurrencyColor(currency), colors.background.main); diff --git a/apps/ledger-live-mobile/src/components/AccountSelector.tsx b/apps/ledger-live-mobile/src/components/AccountSelector.tsx index 46287a4ffaca..2a6a340a63f5 100644 --- a/apps/ledger-live-mobile/src/components/AccountSelector.tsx +++ b/apps/ledger-live-mobile/src/components/AccountSelector.tsx @@ -47,7 +47,7 @@ const AccountSelector = ({ ); const renderList = useCallback( - items => { + (items: AccountLike[]) => { const formatedList = formatSearchResults(items, accounts); return ( diff --git a/apps/ledger-live-mobile/src/components/AnalyticsConsole/index.tsx b/apps/ledger-live-mobile/src/components/AnalyticsConsole/index.tsx index 061f486972e0..920e87d2b6f7 100644 --- a/apps/ledger-live-mobile/src/components/AnalyticsConsole/index.tsx +++ b/apps/ledger-live-mobile/src/components/AnalyticsConsole/index.tsx @@ -49,8 +49,8 @@ const AnalyticsConsole = () => { const handleSlidingComplete = useCallback(() => { setPreviewTransparent(false); }, []); - const handleSliderValueChange = useCallback(val => { - setTransparentHeightPercentage(Math.min(100, Math.max(0, Math.round(val)))); + const handleSliderValueChange = useCallback((val: string | number) => { + setTransparentHeightPercentage(Math.min(100, Math.max(0, Math.round(val as number)))); }, []); const { bottom } = useSafeAreaInsets(); diff --git a/apps/ledger-live-mobile/src/components/AnalyticsConsole/useAnalyticsEventsLog.ts b/apps/ledger-live-mobile/src/components/AnalyticsConsole/useAnalyticsEventsLog.ts index a57ba1588999..7a2c49c5fe91 100644 --- a/apps/ledger-live-mobile/src/components/AnalyticsConsole/useAnalyticsEventsLog.ts +++ b/apps/ledger-live-mobile/src/components/AnalyticsConsole/useAnalyticsEventsLog.ts @@ -7,7 +7,7 @@ export default function useAnalyticsEventsLog(limit = 40) { const id = useRef(0); const [items, setItems] = useState([]); const addItem = useCallback( - item => { + (item: LoggableEventRenderable) => { setItems(currentItems => [...currentItems.slice(-(limit - 1)), item]); }, [limit], @@ -15,6 +15,7 @@ export default function useAnalyticsEventsLog(limit = 40) { useEffect(() => { const subscription = trackSubject .pipe(map(item => ({ ...item, id: ++id.current }))) + // @ts-expect-error RXJS being stubborn .subscribe(addItem); return () => subscription.unsubscribe(); }, [addItem]); diff --git a/apps/ledger-live-mobile/src/components/AnimatedHeader.tsx b/apps/ledger-live-mobile/src/components/AnimatedHeader.tsx index 41dda8e1a2e0..33a200c8fb81 100644 --- a/apps/ledger-live-mobile/src/components/AnimatedHeader.tsx +++ b/apps/ledger-live-mobile/src/components/AnimatedHeader.tsx @@ -7,6 +7,7 @@ import { StyleProp, ViewStyle, TextStyle, + LayoutChangeEvent, } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { useIsFocused } from "@react-navigation/native"; @@ -56,7 +57,7 @@ export default function AnimatedHeaderView({ const { colors, space } = useTheme(); const [textHeight, setTextHeight] = useState(250); const [isReady, setReady] = useState(false); - const onLayoutText = useCallback(event => { + const onLayoutText = useCallback((event: LayoutChangeEvent) => { setTextHeight(event.nativeEvent.layout.height); setReady(true); }, []); @@ -126,7 +127,7 @@ export default function AnimatedHeaderView({ contentContainerStyle={[styles.scrollArea]} testID={isFocused ? "ScrollView" : undefined} data={[children]} - renderItem={({ item, index }) => {item}} + renderItem={({ item, index }) => {item as React.ReactNode}} /> )} diff --git a/apps/ledger-live-mobile/src/components/AssetCentricGraphCard.tsx b/apps/ledger-live-mobile/src/components/AssetCentricGraphCard.tsx index 271e430c85a2..960933cc84e6 100644 --- a/apps/ledger-live-mobile/src/components/AssetCentricGraphCard.tsx +++ b/apps/ledger-live-mobile/src/components/AssetCentricGraphCard.tsx @@ -87,7 +87,7 @@ function AssetCentricGraphCard({ ]; const updateTimeRange = useCallback( - index => { + (index: number) => { track("timeframe_clicked", { timeframe: timeRangeItems[index], }); @@ -96,7 +96,7 @@ function AssetCentricGraphCard({ [setTimeRange, timeRangeItems], ); - const mapCounterValue = useCallback(d => d.value || 0, []); + const mapCounterValue = useCallback((d: Item) => d.value || 0, []); const range = assetPortfolio.range; const isAvailable = assetPortfolio.balanceAvailable; diff --git a/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx b/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx index 96f744c6c5cb..8fd81fff49d0 100644 --- a/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx +++ b/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx @@ -73,7 +73,7 @@ const BleDevicesScanning = ({ }, []); const onWrappedDeviceSelect = useCallback( - device => { + (device: Device) => { setStopBleScanning(true); onDeviceSelect(device); }, diff --git a/apps/ledger-live-mobile/src/components/BulletList.tsx b/apps/ledger-live-mobile/src/components/BulletList.tsx index 25a3502bdfdd..494f80e35703 100644 --- a/apps/ledger-live-mobile/src/components/BulletList.tsx +++ b/apps/ledger-live-mobile/src/components/BulletList.tsx @@ -39,7 +39,7 @@ export class BulletItem extends PureComponent<{ itemContainerStyle?: StyleProp; itemStyle?: StyleProp; itemTextStyle?: StyleProp; - Bullet: React.ComponentType; + Bullet: React.ComponentType<{ children: React.ReactNode }>; }> { static defaultProps = { Bullet, @@ -106,7 +106,7 @@ export function BulletSmallDot() { class BulletList extends PureComponent<{ list: React.ComponentProps["value"][]; animated?: boolean; - Bullet: React.ComponentType; + Bullet: React.ComponentType<{ children: React.ReactNode }>; itemContainerStyle?: React.ComponentProps["itemContainerStyle"]; itemStyle?: React.ComponentProps["itemStyle"]; style?: StyleProp; diff --git a/apps/ledger-live-mobile/src/components/Carousel/index.tsx b/apps/ledger-live-mobile/src/components/Carousel/index.tsx index ab37bf91b786..7799762a6584 100644 --- a/apps/ledger-live-mobile/src/components/Carousel/index.tsx +++ b/apps/ledger-live-mobile/src/components/Carousel/index.tsx @@ -1,5 +1,5 @@ import React, { memo, useMemo, useCallback, useRef, useState } from "react"; -import { ScrollView } from "react-native"; +import { NativeScrollEvent, NativeSyntheticEvent, ScrollView } from "react-native"; import useDynamicContent from "../../dynamicContent/dynamicContent"; import { width } from "../../helpers/normalizeSize"; import CarouselCard from "./CarouselCard"; @@ -12,14 +12,14 @@ const Carousel = () => { const { walletCardsDisplayed } = useDynamicContent(); - const onScrollEnd = useCallback(event => { + const onScrollEnd = useCallback((event: NativeSyntheticEvent) => { setCurrentPositionX( event.nativeEvent.contentOffset.x + event.nativeEvent.layoutMeasurement.width, ); }, []); const onScrollViewContentChange = useCallback( - contentWidth => { + (contentWidth: number) => { if (currentPositionX > contentWidth) { scrollViewRef.current?.scrollToEnd({ animated: true }); } diff --git a/apps/ledger-live-mobile/src/components/CollapsibleList.tsx b/apps/ledger-live-mobile/src/components/CollapsibleList.tsx index 4a41b415110c..7b8b21c90e6f 100644 --- a/apps/ledger-live-mobile/src/components/CollapsibleList.tsx +++ b/apps/ledger-live-mobile/src/components/CollapsibleList.tsx @@ -19,7 +19,7 @@ import { useTheme } from "@react-navigation/native"; import LText from "./LText"; import Chevron from "../icons/Chevron"; -const renderListItem = ({ item, index }: { item: T; index: number }) => ( +const renderListItem = ({ item, index }: { item: T; index: number }) => ( {item} ); diff --git a/apps/ledger-live-mobile/src/components/CounterValue.tsx b/apps/ledger-live-mobile/src/components/CounterValue.tsx index 203d0e1f3b29..7295cfba6695 100644 --- a/apps/ledger-live-mobile/src/components/CounterValue.tsx +++ b/apps/ledger-live-mobile/src/components/CounterValue.tsx @@ -27,7 +27,7 @@ type Props = { placeholderProps?: unknown; // as we can't render View inside Text, provide ability to pass // wrapper component from outside - Wrapper?: React.ComponentType; + Wrapper?: React.ComponentType<{ children: React.ReactNode }>; subMagnitude?: number; joinFragmentsSeparator?: string; alwaysShowValue?: boolean; diff --git a/apps/ledger-live-mobile/src/components/CustomImage/CustomImageBottomModal.tsx b/apps/ledger-live-mobile/src/components/CustomImage/CustomImageBottomModal.tsx index fbf26e5a455b..a0ca3e275db6 100644 --- a/apps/ledger-live-mobile/src/components/CustomImage/CustomImageBottomModal.tsx +++ b/apps/ledger-live-mobile/src/components/CustomImage/CustomImageBottomModal.tsx @@ -105,7 +105,7 @@ const CustomImageBottomModal: React.FC = props => { }, [setDeviceHasImage, wrappedOnClose, pushToast, t]); const onError = useCallback( - error => { + (error: Error) => { if (error instanceof ImageDoesNotExistOnDevice) { if (setDeviceHasImage) { setDeviceHasImage(false); diff --git a/apps/ledger-live-mobile/src/components/CustomImage/ImageCropper.tsx b/apps/ledger-live-mobile/src/components/CustomImage/ImageCropper.tsx index 6aedc568fcfd..24a1ffef959b 100644 --- a/apps/ledger-live-mobile/src/components/CustomImage/ImageCropper.tsx +++ b/apps/ledger-live-mobile/src/components/CustomImage/ImageCropper.tsx @@ -43,7 +43,7 @@ const ImageCropper = React.forwardRef((props, ref) => { const { t } = useTranslation(); const handleImageCrop = useCallback( - async res => { + async (res: { uri: string; width: number; height: number }) => { const { height, width, uri: fileUri } = res; if (!fileUri) { onError(new ImageCropError()); diff --git a/apps/ledger-live-mobile/src/components/CustomImage/StaxFramedLottie.tsx b/apps/ledger-live-mobile/src/components/CustomImage/StaxFramedLottie.tsx index 3f538564bf61..5d59d191b86a 100644 --- a/apps/ledger-live-mobile/src/components/CustomImage/StaxFramedLottie.tsx +++ b/apps/ledger-live-mobile/src/components/CustomImage/StaxFramedLottie.tsx @@ -15,6 +15,7 @@ export type Props = { lottieSource: React.ComponentProps["source"]; source?: FramedImageProps["source"]; loadingProgress?: FramedImageProps["loadingProgress"]; + children?: React.ReactNode; }; const StaxFramedLottie: React.FC = ({ source, lottieSource, loadingProgress }) => { diff --git a/apps/ledger-live-mobile/src/components/CustomImageDeviceAction.tsx b/apps/ledger-live-mobile/src/components/CustomImageDeviceAction.tsx index 3a58065142d7..2a917a6d218b 100644 --- a/apps/ledger-live-mobile/src/components/CustomImageDeviceAction.tsx +++ b/apps/ledger-live-mobile/src/components/CustomImageDeviceAction.tsx @@ -15,6 +15,7 @@ import Button from "./wrappedUi/Button"; import Link from "./wrappedUi/Link"; import { screen, TrackScreen } from "../analytics"; import { useStaxLoadImageDeviceAction } from "../hooks/deviceActions"; +import { SettingsSetLastSeenCustomImagePayload } from "../actions/types"; type Props = { device: Device; @@ -71,7 +72,7 @@ const CustomImageDeviceAction: React.FC void }> = ({ }, [setIsModalOpened]); const handleResult = useCallback( - lastSeenCustomImage => { + (lastSeenCustomImage: SettingsSetLastSeenCustomImagePayload) => { screen("The lock screen has successfully loaded"); dispatch(setLastSeenCustomImage(lastSeenCustomImage)); onResult && onResult(lastSeenCustomImage); diff --git a/apps/ledger-live-mobile/src/components/DoubleCountervalue.tsx b/apps/ledger-live-mobile/src/components/DoubleCountervalue.tsx index 0a918c080ab5..eac24713f38e 100644 --- a/apps/ledger-live-mobile/src/components/DoubleCountervalue.tsx +++ b/apps/ledger-live-mobile/src/components/DoubleCountervalue.tsx @@ -25,7 +25,7 @@ type Props = { placeholderProps?: unknown; // as we can't render View inside Text, provide ability to pass // wrapper component from outside - Wrapper?: React.ComponentType; + Wrapper?: React.ComponentType<{ children?: React.ReactNode }>; subMagnitude?: number; tooltipDateLabel?: React.ReactNode; tooltipCompareDateLabel?: React.ReactNode; diff --git a/apps/ledger-live-mobile/src/components/ExternalLink.tsx b/apps/ledger-live-mobile/src/components/ExternalLink.tsx index 4b95ef0417b5..d28d583cb7a6 100644 --- a/apps/ledger-live-mobile/src/components/ExternalLink.tsx +++ b/apps/ledger-live-mobile/src/components/ExternalLink.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from "react"; import { IconsLegacy, Link as BaseLink } from "@ledgerhq/native-ui"; import { LinkProps } from "@ledgerhq/native-ui/components/cta/Link/index"; import { track } from "../analytics"; +import { GestureResponderEvent } from "react-native-modal"; type Props = { disabled?: boolean; @@ -28,7 +29,7 @@ export default function ExternalLink({ type, }: Props) { const handlePress = useCallback( - nativeEvent => { + (nativeEvent: GestureResponderEvent) => { if (event) { track(event, ...(eventProperties ? [eventProperties] : [])); } diff --git a/apps/ledger-live-mobile/src/components/GraphCard.tsx b/apps/ledger-live-mobile/src/components/GraphCard.tsx index 9296ff9de3ce..8ecb268a310c 100644 --- a/apps/ledger-live-mobile/src/components/GraphCard.tsx +++ b/apps/ledger-live-mobile/src/components/GraphCard.tsx @@ -63,7 +63,7 @@ function GraphCard({ const { colors } = useTheme(); const updateTimeRange = useCallback( - index => { + (index: number) => { track("timeframe_clicked", { timeframe: timeRangeItems[index].value, }); @@ -72,7 +72,7 @@ function GraphCard({ [setTimeRange, timeRangeItems], ); - const mapGraphValue = useCallback(d => d.value || 0, []); + const mapGraphValue = useCallback((d: Item) => d.value || 0, []); const range = portfolio.range; const isAvailable = portfolio.balanceAvailable; diff --git a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterChip.tsx b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterChip.tsx index 69feb9f0454f..592d395d935d 100644 --- a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterChip.tsx +++ b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterChip.tsx @@ -3,8 +3,9 @@ import { Text } from "@ledgerhq/native-ui"; import styled from "@ledgerhq/native-ui/components/styled"; interface Props { - readonly onPress: () => void; - readonly testID?: string; + onPress: () => void; + testID?: string; + children?: React.ReactNode; } const NftFilterChip: FC = ({ onPress, children, ...rest }) => { diff --git a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterItem.tsx b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterItem.tsx index 48f15a865ad9..cb7c42702c68 100644 --- a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterItem.tsx +++ b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterItem.tsx @@ -12,11 +12,12 @@ import { CryptoCurrencyId } from "@ledgerhq/types-cryptoassets"; import Switch from "../../../Switch"; export type NftFilterItemProps = { - readonly first?: boolean; - readonly last?: boolean; - readonly leftComponent: ReactElement; - readonly rightComponent: ReactElement; - readonly onPress: () => void; + first?: boolean; + last?: boolean; + leftComponent: ReactElement; + rightComponent: ReactElement; + onPress: () => void; + children?: React.ReactNode; }; const NftFilterItem: FC = ({ diff --git a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterSection.tsx b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterSection.tsx index 6b748cfcc302..b528306d125b 100644 --- a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterSection.tsx +++ b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/NftFilterSection.tsx @@ -9,9 +9,10 @@ import { View } from "react-native"; import { NftFilterItemProps } from "./NftFilterItem"; type Props = { - readonly title: string; - readonly footer?: string; - readonly onSeeAllPress?: () => void; + title: string; + footer?: string; + onSeeAllPress?: () => void; + children?: React.ReactNode; }; const NftFilterSection: FC = ({ title, onSeeAllPress, footer, children }) => { diff --git a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/index.tsx b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/index.tsx index 1652a6d1852b..224c52c40870 100644 --- a/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/index.tsx +++ b/apps/ledger-live-mobile/src/components/Nft/NftGallery/NftFilterDrawer/index.tsx @@ -12,10 +12,10 @@ import { View } from "react-native"; import QueuedDrawer from "../../../QueuedDrawer"; type Props = { - readonly isOpen: boolean; - readonly onClose: () => void; - readonly toggleFilter: (filter: keyof NftGalleryChainFiltersState) => void; - readonly filters: NftGalleryChainFiltersState; + isOpen: boolean; + onClose: () => void; + toggleFilter: (filter: keyof NftGalleryChainFiltersState) => void; + filters: NftGalleryChainFiltersState; }; const NftFilterDraw: FC = ({ onClose, isOpen, filters, toggleFilter }) => { const { t } = useTranslation(); diff --git a/apps/ledger-live-mobile/src/components/PerformanceConsole/index.tsx b/apps/ledger-live-mobile/src/components/PerformanceConsole/index.tsx index 7e028bbc3b96..302f3f5e4261 100644 --- a/apps/ledger-live-mobile/src/components/PerformanceConsole/index.tsx +++ b/apps/ledger-live-mobile/src/components/PerformanceConsole/index.tsx @@ -48,8 +48,8 @@ const PerformanceConsole = () => { const handleSlidingComplete = useCallback(() => { setPreviewTransparent(false); }, []); - const handleSliderValueChange = useCallback(val => { - setTransparentHeightPercentage(Math.min(100, Math.max(0, Math.round(val)))); + const handleSliderValueChange = useCallback((val: string | number) => { + setTransparentHeightPercentage(Math.min(100, Math.max(0, Math.round(val as number)))); }, []); const { bottom } = useSafeAreaInsets(); diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/MainNavigator.tsx b/apps/ledger-live-mobile/src/components/RootNavigator/MainNavigator.tsx index ef78c2e8000e..d54f4556f041 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/MainNavigator.tsx +++ b/apps/ledger-live-mobile/src/components/RootNavigator/MainNavigator.tsx @@ -49,7 +49,7 @@ export default function MainNavigator() { ); const managerLockAwareCallback = useCallback( - callback => { + (callback: () => void) => { // NB This is conditionally going to show the confirmation modal from the manager // in the event of having ongoing installs/uninstalls. managerNavLockCallback ? managerNavLockCallback(() => callback) : callback(); diff --git a/apps/ledger-live-mobile/src/components/SafeMarkdown.tsx b/apps/ledger-live-mobile/src/components/SafeMarkdown.tsx index f2c6a65fb353..01bf01f4a660 100644 --- a/apps/ledger-live-mobile/src/components/SafeMarkdown.tsx +++ b/apps/ledger-live-mobile/src/components/SafeMarkdown.tsx @@ -32,6 +32,7 @@ class SafeMarkdown extends PureComponent< } return ( + // @ts-expect-error children is not on Markdown props { + (event: LayoutChangeEvent) => { const buttonWidth = event?.nativeEvent?.layout?.width; if (buttonWidth) { setEditNameButtonWidth(buttonWidth); diff --git a/apps/ledger-live-mobile/src/components/StorylyStories/StoriesConfig.tsx b/apps/ledger-live-mobile/src/components/StorylyStories/StoriesConfig.tsx index af524f287118..abb32414aef9 100644 --- a/apps/ledger-live-mobile/src/components/StorylyStories/StoriesConfig.tsx +++ b/apps/ledger-live-mobile/src/components/StorylyStories/StoriesConfig.tsx @@ -6,7 +6,7 @@ import { Camera } from "expo-camera"; import { Flex, Switch, BaseInput, Text, IconsLegacy } from "@ledgerhq/native-ui"; import { TouchableOpacity } from "react-native"; import { InputRenderRightContainer } from "@ledgerhq/native-ui/components/Form/Input/BaseInput/index"; -import { CameraType } from "expo-camera/build/Camera.types"; +import { BarCodeScanningResult, CameraType } from "expo-camera/build/Camera.types"; import QueuedDrawer from "../QueuedDrawer"; type Props = { @@ -29,7 +29,7 @@ const StoriesConfig: React.FC = ({ instanceID }) => { const { testingEnabled, token } = storyConfig; const overrideStoryConfig = useCallback( - val => { + (val: { testingEnabled: boolean; token: string }) => { overrideFeature("storyly", { ...featureValue, enabled: true, @@ -46,21 +46,21 @@ const StoriesConfig: React.FC = ({ instanceID }) => { ); const handleSwitchChange = useCallback( - val => { + (val: boolean) => { overrideStoryConfig({ ...storyConfig, testingEnabled: val }); }, [overrideStoryConfig, storyConfig], ); const handleTokenChange = useCallback( - input => { + (input: string) => { overrideStoryConfig({ ...storyConfig, token: input }); }, [overrideStoryConfig, storyConfig], ); const handleBarCodeScanned = useCallback( - ({ data }) => { + ({ data }: BarCodeScanningResult) => { try { const parsedData = JSON.parse(data); const { token } = parsedData; diff --git a/apps/ledger-live-mobile/src/components/StorylyStories/index.tsx b/apps/ledger-live-mobile/src/components/StorylyStories/index.tsx index 41f8c3585bb4..3aae81a1d22d 100644 --- a/apps/ledger-live-mobile/src/components/StorylyStories/index.tsx +++ b/apps/ledger-live-mobile/src/components/StorylyStories/index.tsx @@ -56,7 +56,10 @@ type StoryGroupItemWrapperProps = { }; const AnimatedStoryGroupWrapper = Animated.createAnimatedComponent< - FlexBoxProps & StoryGroupItemWrapperProps + FlexBoxProps & + StoryGroupItemWrapperProps & { + children?: React.ReactNode; + } >( styled(Flex).attrs(p => ({ mr: p.isLast || p.vertical ? 0 : 5, diff --git a/apps/ledger-live-mobile/src/components/ToggleButton.tsx b/apps/ledger-live-mobile/src/components/ToggleButton.tsx index 28f2cdf62a79..65d138638580 100644 --- a/apps/ledger-live-mobile/src/components/ToggleButton.tsx +++ b/apps/ledger-live-mobile/src/components/ToggleButton.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useEffect, useState } from "react"; -import { View, TouchableOpacity, StyleSheet } from "react-native"; +import { View, TouchableOpacity, StyleSheet, LayoutChangeEvent } from "react-native"; import Animated, { interpolate, useAnimatedStyle, @@ -29,7 +29,7 @@ const ToggleButton = ({ value, options, onChange }: Props) => { // Animated value that will be updated to be equal to `activeIndex` const animatedIndex = useSharedValue(0); - const onLayout = useCallback(evt => { + const onLayout = useCallback((evt: LayoutChangeEvent) => { setWidth(evt.nativeEvent.layout.width); }, []); diff --git a/apps/ledger-live-mobile/src/components/Web3AppWebview/PlatformAPIWebview.tsx b/apps/ledger-live-mobile/src/components/Web3AppWebview/PlatformAPIWebview.tsx index 330f7bc21f46..1b6ad817a24a 100644 --- a/apps/ledger-live-mobile/src/components/Web3AppWebview/PlatformAPIWebview.tsx +++ b/apps/ledger-live-mobile/src/components/Web3AppWebview/PlatformAPIWebview.tsx @@ -1,7 +1,7 @@ import React, { useState, useCallback, useEffect, useMemo, forwardRef } from "react"; import { useSelector } from "react-redux"; import { ActivityIndicator, StyleSheet, View } from "react-native"; -import { WebView as RNWebView } from "react-native-webview"; +import { WebView as RNWebView, WebViewMessageEvent } from "react-native-webview"; import { useNavigation } from "@react-navigation/native"; import { JSONRPCRequest } from "json-rpc-2.0"; import { UserRefusedOnDevice } from "@ledgerhq/errors"; @@ -475,7 +475,7 @@ export const PlatformAPIWebview = forwardRef( ); const [receive] = useJSONRPCServer(handlers, handleSend); const handleMessage = useCallback( - e => { + (e: WebViewMessageEvent) => { // FIXME: event isn't the same on desktop & mobile // if (e.isTrusted && e.origin === manifest.url.origin && e.data) { if (e.nativeEvent?.data) { diff --git a/apps/ledger-live-mobile/src/components/Web3AppWebview/helpers.ts b/apps/ledger-live-mobile/src/components/Web3AppWebview/helpers.ts index 4f191343bb5e..01741cf05420 100644 --- a/apps/ledger-live-mobile/src/components/Web3AppWebview/helpers.ts +++ b/apps/ledger-live-mobile/src/components/Web3AppWebview/helpers.ts @@ -14,7 +14,7 @@ import type { Device } from "@ledgerhq/live-common/hw/actions/types"; import BigNumber from "bignumber.js"; import { useSelector } from "react-redux"; import { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react"; -import { WebViewProps, WebView } from "react-native-webview"; +import { WebViewProps, WebView, WebViewMessageEvent } from "react-native-webview"; import VersionNumber from "react-native-version-number"; import { useTheme } from "styled-components/native"; import { useNavigation } from "@react-navigation/native"; @@ -89,7 +89,7 @@ export function useWebView( }); const onMessage = useCallback( - e => { + (e: WebViewMessageEvent) => { if (e.nativeEvent?.data) { try { const msg = JSON.parse(e.nativeEvent.data); diff --git a/apps/ledger-live-mobile/src/components/WebPlatformPlayer/InfoPanel.tsx b/apps/ledger-live-mobile/src/components/WebPlatformPlayer/InfoPanel.tsx index 498787098b4b..4a60ea8d7f18 100644 --- a/apps/ledger-live-mobile/src/components/WebPlatformPlayer/InfoPanel.tsx +++ b/apps/ledger-live-mobile/src/components/WebPlatformPlayer/InfoPanel.tsx @@ -27,7 +27,7 @@ export function InfoPanel({ name, icon, description, url, uri, isOpened, setIsOp const onClose = useCallback(() => { setIsOpened(false); }, [setIsOpened]); - const onLinkPress = useCallback(url => { + const onLinkPress = useCallback((url: string) => { Linking.openURL(url); }, []); return ( diff --git a/apps/ledger-live-mobile/src/components/wrappedUi/Button.tsx b/apps/ledger-live-mobile/src/components/wrappedUi/Button.tsx index 678192ec5c8b..497ba6710e05 100644 --- a/apps/ledger-live-mobile/src/components/wrappedUi/Button.tsx +++ b/apps/ledger-live-mobile/src/components/wrappedUi/Button.tsx @@ -3,6 +3,7 @@ import { ButtonProps } from "@ledgerhq/native-ui/components/cta/Button/index"; import { Button as UiButton } from "@ledgerhq/native-ui"; import { track } from "../../analytics"; import { TouchableOpacityProps } from "react-native"; +import { GestureResponderEvent } from "react-native-modal"; export type WrappedButtonProps = ButtonProps & { event?: string; @@ -19,7 +20,7 @@ function Button({ ...othersProps }: WrappedButtonProps) { const onPressHandler = useCallback( - async pressEvent => { + async (pressEvent: GestureResponderEvent) => { if (!onPress) return; if (event) { track(event, eventProperties as Record); diff --git a/apps/ledger-live-mobile/src/components/wrappedUi/Link.tsx b/apps/ledger-live-mobile/src/components/wrappedUi/Link.tsx index e46d6dba1242..ae58134eef7d 100644 --- a/apps/ledger-live-mobile/src/components/wrappedUi/Link.tsx +++ b/apps/ledger-live-mobile/src/components/wrappedUi/Link.tsx @@ -2,6 +2,7 @@ import React, { useCallback } from "react"; import { Link as UiLink } from "@ledgerhq/native-ui"; import { LinkProps } from "@ledgerhq/native-ui/components/cta/Link/index"; import { track } from "../../analytics"; +import { GestureResponderEvent } from "react-native-modal"; export type WrappedLinkProps = LinkProps & { event?: string; @@ -15,7 +16,7 @@ export default function Link({ ...othersProps }: WrappedLinkProps) { const onPressHandler = useCallback( - async pressEvent => { + async (pressEvent: GestureResponderEvent) => { if (!onPress) return; if (event) { track(event, eventProperties); diff --git a/apps/ledger-live-mobile/src/context/DiscreetModeContext.tsx b/apps/ledger-live-mobile/src/context/DiscreetModeContext.tsx index 707ff6513482..dd2752c795bd 100644 --- a/apps/ledger-live-mobile/src/context/DiscreetModeContext.tsx +++ b/apps/ledger-live-mobile/src/context/DiscreetModeContext.tsx @@ -40,7 +40,7 @@ export function DiscreetModeProvider({ export function withDiscreetMode( Component: React.ComponentType, shouldApplyDiscreetMode = true, -): React.ComponentType { +) { return (props: React.PropsWithChildren) => ( diff --git a/apps/ledger-live-mobile/src/families/algorand/OptInFlow/01-SelectToken.tsx b/apps/ledger-live-mobile/src/families/algorand/OptInFlow/01-SelectToken.tsx index 6dd5e4398b44..90d480776cef 100644 --- a/apps/ledger-live-mobile/src/families/algorand/OptInFlow/01-SelectToken.tsx +++ b/apps/ledger-live-mobile/src/families/algorand/OptInFlow/01-SelectToken.tsx @@ -114,6 +114,7 @@ export default function DelegationStarted({ navigation, route }: Props) { const subAccounts = mainAccount.subAccounts; const options = listTokensForCryptoCurrency(mainAccount.currency); const [infoModalOpen, setInfoModalOpen] = useState(false); + // @ts-expect-error token is a string and setInfoModalOpen expect a boolean, whut ? const openModal = useCallback(token => setInfoModalOpen(token), [setInfoModalOpen]); const closeModal = useCallback(() => setInfoModalOpen(false), [setInfoModalOpen]); const renderList = useCallback( diff --git a/apps/ledger-live-mobile/src/families/bitcoin/SendRowsFee.tsx b/apps/ledger-live-mobile/src/families/bitcoin/SendRowsFee.tsx index 65c95831d48b..24863227815b 100644 --- a/apps/ledger-live-mobile/src/families/bitcoin/SendRowsFee.tsx +++ b/apps/ledger-live-mobile/src/families/bitcoin/SendRowsFee.tsx @@ -9,7 +9,7 @@ import { useFeesStrategy } from "@ledgerhq/live-common/families/bitcoin/react"; import { CompositeScreenProps } from "@react-navigation/native"; import BigNumber from "bignumber.js"; import { ScreenName } from "../../const"; -import SelectFeesStrategy from "../../components/SelectFeesStrategy"; +import SelectFeesStrategy, { SelectFeeStrategy } from "../../components/SelectFeesStrategy"; import type { StackNavigatorProps } from "../../components/RootNavigator/types/helpers"; import type { SendFundsNavigatorStackParamList } from "../../components/RootNavigator/types/SendFundsNavigator"; import type { BaseNavigatorStackParamList } from "../../components/RootNavigator/types/BaseNavigator"; @@ -56,7 +56,7 @@ export default function BitcoinSendRowsFee({ [defaultStrategies, transaction], ); const onFeesSelected = useCallback( - ({ amount, label }) => { + ({ amount, label }: SelectFeeStrategy) => { const bridge = getAccountBridge(account, parentAccount); setTransaction( bridge.updateTransaction(transaction, { diff --git a/apps/ledger-live-mobile/src/families/celo/ActivateFlow/SelectValidator.tsx b/apps/ledger-live-mobile/src/families/celo/ActivateFlow/SelectValidator.tsx index cdb14516c7de..a872bcd60dc5 100644 --- a/apps/ledger-live-mobile/src/families/celo/ActivateFlow/SelectValidator.tsx +++ b/apps/ledger-live-mobile/src/families/celo/ActivateFlow/SelectValidator.tsx @@ -1,9 +1,13 @@ import { useTheme } from "@react-navigation/native"; import invariant from "invariant"; import React, { useCallback, useMemo } from "react"; -import { FlatList, StyleSheet, View, SafeAreaView } from "react-native"; +import { FlatList, StyleSheet, View, SafeAreaView, ListRenderItem } from "react-native"; import { useSelector } from "react-redux"; -import { CeloAccount, CeloValidatorGroup } from "@ledgerhq/live-common/families/celo/types"; +import { + CeloAccount, + CeloValidatorGroup, + CeloVote, +} from "@ledgerhq/live-common/families/celo/types"; import { useCeloPreloadData } from "@ledgerhq/live-common/families/celo/react"; import { activatableVotes, @@ -51,18 +55,19 @@ export default function SelectValidator({ navigation, route }: Props) { [navigation, route.params], ); - const renderItem = useCallback( - ({ item }) => ( - - ), - [onItemPress, account], - ); + const renderItem: ListRenderItem<{ vote: CeloVote; validatorGroup: CeloValidatorGroup }> = + useCallback( + ({ item }) => ( + + ), + [onItemPress, account], + ); return ( diff --git a/apps/ledger-live-mobile/src/families/celo/LockFlow/01-Amount.tsx b/apps/ledger-live-mobile/src/families/celo/LockFlow/01-Amount.tsx index 393a6e873fd5..b53842a34d41 100644 --- a/apps/ledger-live-mobile/src/families/celo/LockFlow/01-Amount.tsx +++ b/apps/ledger-live-mobile/src/families/celo/LockFlow/01-Amount.tsx @@ -82,7 +82,7 @@ export default function LockAmount({ navigation, route }: Props) { }, [account, parentAccount, debouncedTransaction]); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { setTransaction(bridge.updateTransaction(transaction, { amount })); } diff --git a/apps/ledger-live-mobile/src/families/celo/RevokeFlow/SelectValidator.tsx b/apps/ledger-live-mobile/src/families/celo/RevokeFlow/SelectValidator.tsx index b32d40273876..aadc3835100b 100644 --- a/apps/ledger-live-mobile/src/families/celo/RevokeFlow/SelectValidator.tsx +++ b/apps/ledger-live-mobile/src/families/celo/RevokeFlow/SelectValidator.tsx @@ -1,7 +1,7 @@ import { useTheme } from "@react-navigation/native"; import invariant from "invariant"; import React, { useCallback, useMemo } from "react"; -import { FlatList, StyleSheet, View, SafeAreaView } from "react-native"; +import { FlatList, StyleSheet, View, SafeAreaView, ListRenderItem } from "react-native"; import { useSelector } from "react-redux"; import { CeloAccount, @@ -53,18 +53,19 @@ export default function SelectValidator({ navigation, route }: Props) { [navigation, route.params], ); - const renderItem = useCallback( - ({ item }) => ( - - ), - [onItemPress, account], - ); + const renderItem: ListRenderItem<{ vote: CeloVote; validatorGroup: CeloValidatorGroup }> = + useCallback( + ({ item }) => ( + + ), + [onItemPress, account], + ); return ( diff --git a/apps/ledger-live-mobile/src/families/celo/UnlockFlow/01-Amount.tsx b/apps/ledger-live-mobile/src/families/celo/UnlockFlow/01-Amount.tsx index 944df0676b5b..d150f9a2846a 100644 --- a/apps/ledger-live-mobile/src/families/celo/UnlockFlow/01-Amount.tsx +++ b/apps/ledger-live-mobile/src/families/celo/UnlockFlow/01-Amount.tsx @@ -83,7 +83,7 @@ export default function UnlockAmount({ navigation, route }: Props) { }, [account, parentAccount, debouncedTransaction, bridge]); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { setTransaction(bridge.updateTransaction(transaction, { amount })); } diff --git a/apps/ledger-live-mobile/src/families/celo/VoteFlow/SelectValidator.tsx b/apps/ledger-live-mobile/src/families/celo/VoteFlow/SelectValidator.tsx index a65e0b7ddf8e..5a858006182f 100644 --- a/apps/ledger-live-mobile/src/families/celo/VoteFlow/SelectValidator.tsx +++ b/apps/ledger-live-mobile/src/families/celo/VoteFlow/SelectValidator.tsx @@ -1,7 +1,7 @@ import { useTheme } from "@react-navigation/native"; import invariant from "invariant"; import React, { useCallback, useState } from "react"; -import { FlatList, StyleSheet, View, SafeAreaView } from "react-native"; +import { FlatList, StyleSheet, View, SafeAreaView, ListRenderItem } from "react-native"; import { useSelector } from "react-redux"; import { CeloValidatorGroup } from "@ledgerhq/live-common/families/celo/types"; import { useValidatorGroups } from "@ledgerhq/live-common/families/celo/react"; @@ -37,7 +37,7 @@ export default function SelectValidator({ navigation, route }: Props) { [navigation, route.params], ); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item }) => ( ), diff --git a/apps/ledger-live-mobile/src/families/celo/WithdrawFlow/WithdrawAmount.tsx b/apps/ledger-live-mobile/src/families/celo/WithdrawFlow/WithdrawAmount.tsx index 69b7c39a3828..eff8bcf10855 100644 --- a/apps/ledger-live-mobile/src/families/celo/WithdrawFlow/WithdrawAmount.tsx +++ b/apps/ledger-live-mobile/src/families/celo/WithdrawFlow/WithdrawAmount.tsx @@ -39,7 +39,7 @@ type Props = BaseComposite< export default function WithdrawAmount({ navigation, route }: Props) { const [infoModalOpen, setInfoModalOpen] = useState(false); - const openModal = useCallback(time => setInfoModalOpen(time), [setInfoModalOpen]); + const openModal = useCallback((time: boolean) => setInfoModalOpen(time), [setInfoModalOpen]); const closeModal = useCallback(() => setInfoModalOpen(false), [setInfoModalOpen]); const { colors } = useTheme(); const { account, parentAccount } = useSelector(accountScreenSelector(route)); @@ -69,7 +69,7 @@ export default function WithdrawAmount({ navigation, route }: Props) { }, [account, parentAccount, transaction, bridge, debouncedTransaction]); const onChange = useCallback( - index => { + (index: number) => { if (index != null) { setTransaction(bridge.updateTransaction(transaction, { index })); } @@ -136,6 +136,7 @@ export default function WithdrawAmount({ navigation, route }: Props) { return transaction.index === index ? ( ) : ( + // @ts-expect-error we are giving a bignumber to be used as a boolean, whut ? openModal(time) : () => onChange(index)}> { const optimisticOperation = useRoute().params?.operation ?? null; const redirectAddressCreator = useCallback( - address => () => { + (address?: string) => () => { + if (!address) return; const url = getAddressExplorer(getDefaultExplorerView(account.currency), address); if (url) Linking.openURL(url); }, diff --git a/apps/ledger-live-mobile/src/families/cosmos/ClaimRewardsFlow/01-SelectValidator.tsx b/apps/ledger-live-mobile/src/families/cosmos/ClaimRewardsFlow/01-SelectValidator.tsx index 045fc06a7bfb..49733ba187ab 100644 --- a/apps/ledger-live-mobile/src/families/cosmos/ClaimRewardsFlow/01-SelectValidator.tsx +++ b/apps/ledger-live-mobile/src/families/cosmos/ClaimRewardsFlow/01-SelectValidator.tsx @@ -1,8 +1,13 @@ import invariant from "invariant"; import React, { useCallback } from "react"; -import { View, StyleSheet, FlatList } from "react-native"; +import { View, StyleSheet, FlatList, ListRenderItem } from "react-native"; import { useSelector } from "react-redux"; -import type { CosmosAccount, Transaction } from "@ledgerhq/live-common/families/cosmos/types"; +import type { + CosmosAccount, + CosmosMappedDelegation, + CosmosValidatorItem, + Transaction, +} from "@ledgerhq/live-common/families/cosmos/types"; import { getAccountBridge } from "@ledgerhq/live-common/bridge/index"; import { getMainAccount, getAccountUnit } from "@ledgerhq/live-common/account/index"; import useBridgeTransaction from "@ledgerhq/live-common/bridge/useBridgeTransaction"; @@ -13,6 +18,7 @@ import { ScreenName } from "../../../const"; import Item from "../shared/Item"; import type { StackNavigatorProps } from "../../../components/RootNavigator/types/helpers"; import type { CosmosClaimRewardsFlowParamList } from "./types"; +import BigNumber from "bignumber.js"; type Props = StackNavigatorProps< CosmosClaimRewardsFlowParamList, @@ -41,7 +47,7 @@ function ClaimRewardsSelectValidator({ navigation, route }: Props) { const unit = getAccountUnit(account); const delegations = useCosmosFamilyMappedDelegations(mainAccount, "claimReward"); const onSelect = useCallback( - (validator, value) => { + (validator: CosmosValidatorItem, value?: BigNumber | null) => { const tx = bridge.updateTransaction(transaction, { validators: [ { @@ -54,12 +60,12 @@ function ClaimRewardsSelectValidator({ navigation, route }: Props) { ...route.params, transaction: tx, validator, - value, + value: value as BigNumber, }); }, [navigation, route.params, transaction, bridge], ); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item }) => ( { + (mode: string) => { updateTransaction(() => bridge.updateTransaction(transaction, { mode, diff --git a/apps/ledger-live-mobile/src/families/cosmos/operationDetails.tsx b/apps/ledger-live-mobile/src/families/cosmos/operationDetails.tsx index c325e80e8d54..3c9334f79883 100644 --- a/apps/ledger-live-mobile/src/families/cosmos/operationDetails.tsx +++ b/apps/ledger-live-mobile/src/families/cosmos/operationDetails.tsx @@ -38,7 +38,7 @@ function OperationDetailsExtra({ operation, type, account }: Props) { const { extra } = operation; const { validators: cosmosValidators } = useCosmosFamilyPreloadData(currencyId); const redirectAddressCreator = useCallback( - address => () => { + (address: string) => () => { const url = getAddressExplorer(getDefaultExplorerView(account.currency), address); if (url) Linking.openURL(url); }, diff --git a/apps/ledger-live-mobile/src/families/evm/EditFeeUnitEvm.tsx b/apps/ledger-live-mobile/src/families/evm/EditFeeUnitEvm.tsx index 33a40ca76e1b..a41595cd8c74 100644 --- a/apps/ledger-live-mobile/src/families/evm/EditFeeUnitEvm.tsx +++ b/apps/ledger-live-mobile/src/families/evm/EditFeeUnitEvm.tsx @@ -17,13 +17,13 @@ const FeeSlider = React.memo( range, }: { value: BigNumber; - onChange: (arg: unknown) => void; + onChange: (arg: BigNumber) => void; range: Range; }) => { const { colors } = useTheme(); const index = reverseRangeIndex(range, value); const setValueIndex = useCallback( - i => onChange(projectRangeIndex(range, i)), + (i: number | string) => onChange(projectRangeIndex(range, i as number)), [range, onChange], ); return ( @@ -53,7 +53,7 @@ export default function EditFeeUnitEvm({ account, feeAmount, onChange, range, ti const unit = getDefaultFeeUnit(account.currency); const onChangeF = useCallback( - value => { + (value: BigNumber) => { onChange(value); }, [onChange], diff --git a/apps/ledger-live-mobile/src/families/evm/EvmFeesStrategy.tsx b/apps/ledger-live-mobile/src/families/evm/EvmFeesStrategy.tsx index f69517b73653..3463a27195e3 100644 --- a/apps/ledger-live-mobile/src/families/evm/EvmFeesStrategy.tsx +++ b/apps/ledger-live-mobile/src/families/evm/EvmFeesStrategy.tsx @@ -10,7 +10,7 @@ import BigNumber from "bignumber.js"; import React, { useCallback, useEffect, useState } from "react"; import { ScreenName } from "../../const"; import { EvmNetworkFeeInfo } from "./EvmNetworkFeesInfo"; -import SelectFeesStrategy from "./SelectFeesStrategy"; +import SelectFeesStrategy, { StrategyWithCustom } from "./SelectFeesStrategy"; import { SendRowsFeeProps as Props } from "./types"; const getCustomStrategy = (transaction: Transaction): BigNumber | null => { @@ -65,7 +65,7 @@ export default function EvmFeesStrategy({ }, [transaction, setCustomStrategy]); const onFeesSelected = useCallback( - ({ feesStrategy }) => { + ({ feesStrategy }: { feesStrategy: StrategyWithCustom }) => { setTransaction( bridge.updateTransaction(transaction, { feesStrategy, diff --git a/apps/ledger-live-mobile/src/families/evm/SelectFeesStrategy.tsx b/apps/ledger-live-mobile/src/families/evm/SelectFeesStrategy.tsx index da114aeeaa13..845349b81901 100644 --- a/apps/ledger-live-mobile/src/families/evm/SelectFeesStrategy.tsx +++ b/apps/ledger-live-mobile/src/families/evm/SelectFeesStrategy.tsx @@ -31,7 +31,7 @@ import TachometerSlow from "../../icons/TachometerSlow"; import SummaryRow from "../../screens/SendFunds/SummaryRow"; import { sharedSwapTracking } from "../../screens/Swap/utils"; -type StrategyWithCustom = Strategy | "custom"; +export type StrategyWithCustom = Strategy | "custom"; type Props = { gasOptions: GasOptions; diff --git a/apps/ledger-live-mobile/src/families/hedera/NoAssociatedAccounts.tsx b/apps/ledger-live-mobile/src/families/hedera/NoAssociatedAccounts.tsx index 331154bb33b3..f5c6604220ac 100644 --- a/apps/ledger-live-mobile/src/families/hedera/NoAssociatedAccounts.tsx +++ b/apps/ledger-live-mobile/src/families/hedera/NoAssociatedAccounts.tsx @@ -21,7 +21,7 @@ function NoAssociatedAccounts({ style }: Props) { const onPress = useCallback(() => Linking.openURL(urls.hedera.supportArticleLink), []); return ( - {i18next.t("hedera.createHederaAccountHelp.text")} + {i18next.t("hedera.createHederaAccountHelp.text") as React.ReactNode} - {i18next.t("hedera.createHederaAccountHelp.link")} + {i18next.t("hedera.createHederaAccountHelp.link") as React.ReactNode} diff --git a/apps/ledger-live-mobile/src/families/near/shared/02-SelectAmount.tsx b/apps/ledger-live-mobile/src/families/near/shared/02-SelectAmount.tsx index e5c83e0b757c..b96ca36c91a5 100644 --- a/apps/ledger-live-mobile/src/families/near/shared/02-SelectAmount.tsx +++ b/apps/ledger-live-mobile/src/families/near/shared/02-SelectAmount.tsx @@ -67,7 +67,7 @@ function StakingAmount({ navigation, route }: Props) { }); }, [navigation, route.params, bridge, value, max]); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { setValue(amount); updateTransaction && updateTransaction(oldTx => ({ ...oldTx, amount })); diff --git a/apps/ledger-live-mobile/src/families/polkadot/BondFlow/02-Amount.tsx b/apps/ledger-live-mobile/src/families/polkadot/BondFlow/02-Amount.tsx index 0b92b5446b59..7b003e5ce29d 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/BondFlow/02-Amount.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/BondFlow/02-Amount.tsx @@ -121,7 +121,7 @@ export default function PolkadotBondAmount({ navigation, route }: Props) { }; }, [account, parentAccount, debouncedTransaction]); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { setTransaction( bridge.updateTransaction(transaction, { diff --git a/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/01-Validators.tsx b/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/01-Validators.tsx index 732db3ceba0a..85ad700a11fe 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/01-Validators.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/01-Validators.tsx @@ -1,7 +1,14 @@ import { BigNumber } from "bignumber.js"; import invariant from "invariant"; import React, { useCallback, useState, useMemo } from "react"; -import { View, StyleSheet, TouchableOpacity, SectionList, Linking } from "react-native"; +import { + View, + StyleSheet, + TouchableOpacity, + SectionList, + Linking, + SectionListRenderItem, +} from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { Trans, useTranslation } from "react-i18next"; import { useSelector } from "react-redux"; @@ -161,7 +168,7 @@ function NominateSelectValidator({ navigation, route }: Props) { }); }, [navigation, route.params, transaction, status]); const onSelect = useCallback( - (validator, selected) => { + (validator: PolkadotValidator, selected: boolean) => { setDrawerValidator(undefined); const newValidators = selected ? validators.filter(v => v !== validator.address) @@ -181,7 +188,7 @@ function NominateSelectValidator({ navigation, route }: Props) { [mainAccount.currency], ); const onOpenDrawer = useCallback( - address => { + (address: string) => { const validator = polkadotValidators.find(v => v.address === address); setDrawerValidator(validator); }, @@ -214,7 +221,7 @@ function NominateSelectValidator({ navigation, route }: Props) { : [], [drawerValidator, t, account, maxNominatorRewardedPerValidator, onOpenExplorer], ); - const renderItem = useCallback( + const renderItem: SectionListRenderItem = useCallback( ({ item }) => { const selected = validators.indexOf(item.address) > -1; const disabled = validators.length >= MAX_NOMINATIONS; diff --git a/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/drawerInfo.tsx b/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/drawerInfo.tsx index 23100ce5187f..f9fd5683759a 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/drawerInfo.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/NominateFlow/drawerInfo.tsx @@ -41,8 +41,8 @@ export function getDrawerInfo({ const drawerData: NominationDrawerData = [ { - label: t("delegation.validatorAddress"), - Component: () => { + label: t("delegation.validatorAddress") as string, + Component: (() => { const { colors } = useTheme(); return ( ); - }, + })(), }, { - label: t("polkadot.nomination.status"), - info: t(`polkadot.nomination.${validatorStatus}Info`), + label: t("polkadot.nomination.status") as string, + info: t(`polkadot.nomination.${validatorStatus}Info`) as string, Component: ( - {t(`polkadot.nomination.${validatorStatus}`)} + {t(`polkadot.nomination.${validatorStatus}`) as string} ), }, ]; const delegationValidator: NominationDrawerDatum = { - label: t("delegation.validator"), + label: t("delegation.validator") as string, Component: ( {validator.identity} @@ -92,7 +92,7 @@ export function getDrawerInfo({ }; const nominationComission: NominationDrawerDatum = { - label: t("polkadot.nomination.commission"), + label: t("polkadot.nomination.commission") as string, Component: ( {formattedCommission} @@ -101,14 +101,14 @@ export function getDrawerInfo({ }; const nominationNominators: NominationDrawerDatum = { - label: t("polkadot.nomination.nominators"), + label: t("polkadot.nomination.nominators") as string, info: validator.isOversubscribed - ? t("polkadot.nomination.oversubscribedInfo", { + ? (t("polkadot.nomination.oversubscribedInfo", { maxNominatorRewardedPerValidator, - }) - : t("polkadot.nomination.nominatorsInfo", { + }) as string) + : (t("polkadot.nomination.nominatorsInfo", { count: validator.nominatorsCount, - }), + }) as string), infoType: validator.isOversubscribed ? "warning" : "info", Component: ( {validator.isOversubscribed - ? t("polkadot.nomination.oversubscribed", { + ? (t("polkadot.nomination.oversubscribed", { nominatorsCount: validator.nominatorsCount, - }) - : t("polkadot.nomination.nominatorsCount", { + }) as string) + : (t("polkadot.nomination.nominatorsCount", { nominatorsCount: validator.nominatorsCount, - })} + }) as string)} ), }; const nominationTotalStake: NominationDrawerDatum = { - label: t("polkadot.nomination.totalStake"), + label: t("polkadot.nomination.totalStake") as string, Component: ( diff --git a/apps/ledger-live-mobile/src/families/polkadot/Nominations/drawerInfo.tsx b/apps/ledger-live-mobile/src/families/polkadot/Nominations/drawerInfo.tsx index d67c6feef5b8..f930dfd783fa 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/Nominations/drawerInfo.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/Nominations/drawerInfo.tsx @@ -39,6 +39,7 @@ export function getDrawerInfo({ const formattedCommission = validator?.commission ? `${validator?.commission.multipliedBy(100).toFixed(2)} %` : "-"; + // @ts-expect-error return type is not matching what we return return [ ...(validator?.identity ? [ @@ -91,7 +92,7 @@ export function getDrawerInfo({ !nomination.status ? "orange" : nomination.status === "active" ? "success" : "darkBlue" } > - {t(`polkadot.nomination.${nomination.status || "notValidator"}`)} + {t(`polkadot.nomination.${nomination.status || "notValidator"}`) as string} ), }, @@ -120,12 +121,12 @@ export function getDrawerInfo({ color={validator?.isOversubscribed ? "orange" : "darkBlue"} > {validator?.isOversubscribed - ? t(`polkadot.nomination.oversubscribed`, { + ? (t(`polkadot.nomination.oversubscribed`, { nominatorsCount: validator?.nominatorsCount, - }) - : t(`polkadot.nomination.nominatorsCount`, { + }) as string) + : (t(`polkadot.nomination.nominatorsCount`, { nominatorsCount: validator?.nominatorsCount, - })} + }) as string)} ), }, diff --git a/apps/ledger-live-mobile/src/families/polkadot/Nominations/index.tsx b/apps/ledger-live-mobile/src/families/polkadot/Nominations/index.tsx index efb1dfd20a6b..15cc3c49ef22 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/Nominations/index.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/Nominations/index.tsx @@ -18,6 +18,7 @@ import { usePolkadotPreloadData } from "@ledgerhq/live-common/families/polkadot/ import type { PolkadotAccount, PolkadotNomination, + PolkadotUnlocking, PolkadotValidator, } from "@ledgerhq/live-common/families/polkadot/types"; @@ -227,7 +228,7 @@ export default function Nominations(props: Props) { const earnRewardsEnabled = !electionOpen && !hasBondedBalance && !hasPendingBondOperation; const renderNomination = useCallback( - ({ nomination, validator }, i, isLast) => ( + ({ nomination, validator }: Section, i: number, isLast: boolean) => ( + (collapsed: boolean) => collapsed ? t("polkadot.nomination.showInactiveNominations", { count: mappedNominations.collapsed.length, @@ -252,7 +253,7 @@ export default function Nominations(props: Props) { ); const renderUnlocking = useCallback( - (unlocking, i, isLast) => ( + (unlocking: PolkadotUnlocking, i: number, isLast: boolean) => ( + (collapsed: boolean) => collapsed ? t("polkadot.nomination.showAllUnlockings", { count: mappedUnlockings.collapsed.length, diff --git a/apps/ledger-live-mobile/src/families/polkadot/RebondFlow/01-Amount.tsx b/apps/ledger-live-mobile/src/families/polkadot/RebondFlow/01-Amount.tsx index 5735e7a0fe83..f9ad4cf576ec 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/RebondFlow/01-Amount.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/RebondFlow/01-Amount.tsx @@ -76,7 +76,7 @@ export default function PolkadotRebondAmount({ navigation, route }: NavigationPr }; }, [account, parentAccount, debouncedTransaction]); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { setTransaction( bridge.updateTransaction(transaction, { diff --git a/apps/ledger-live-mobile/src/families/polkadot/TransactionConfirmFields.tsx b/apps/ledger-live-mobile/src/families/polkadot/TransactionConfirmFields.tsx index a52d449bb6ab..6622e3e0302b 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/TransactionConfirmFields.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/TransactionConfirmFields.tsx @@ -37,7 +37,7 @@ function PolkadotValidatorsField({ account, transaction, field }: FieldProps) { [validators, polkadotValidators], ); const redirectAddressCreator = useCallback( - address => () => { + (address: string) => () => { const url = getAddressExplorer(getDefaultExplorerView(account.currency), address); if (url) Linking.openURL(url); }, diff --git a/apps/ledger-live-mobile/src/families/polkadot/UnbondFlow/01-Amount.tsx b/apps/ledger-live-mobile/src/families/polkadot/UnbondFlow/01-Amount.tsx index cf06308c65d2..3c87a3959137 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/UnbondFlow/01-Amount.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/UnbondFlow/01-Amount.tsx @@ -73,7 +73,7 @@ export default function PolkadotUnbondAmount({ navigation, route }: Props) { }; }, [account, parentAccount, debouncedTransaction]); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { setTransaction( bridge.updateTransaction(transaction, { diff --git a/apps/ledger-live-mobile/src/families/polkadot/operationDetails.tsx b/apps/ledger-live-mobile/src/families/polkadot/operationDetails.tsx index 953cfc0566eb..ada206c9d4ed 100644 --- a/apps/ledger-live-mobile/src/families/polkadot/operationDetails.tsx +++ b/apps/ledger-live-mobile/src/families/polkadot/operationDetails.tsx @@ -166,7 +166,7 @@ export const OperationDetailsRewardFrom = ({ ); const redirectAddressCreator = useCallback( - address => () => { + (address: string) => () => { const url = getAddressExplorer(getDefaultExplorerView(account.currency), address); if (url) Linking.openURL(url); }, @@ -222,7 +222,7 @@ export function OperationDetailsValidators({ ); const redirectAddressCreator = useCallback( - address => () => { + (address: string) => () => { const url = getAddressExplorer(getDefaultExplorerView(account.currency), address); if (url) Linking.openURL(url); }, diff --git a/apps/ledger-live-mobile/src/families/stacks/TransactionConfirmFields.tsx b/apps/ledger-live-mobile/src/families/stacks/TransactionConfirmFields.tsx index 44bdff3e5382..14c5acc13b3a 100644 --- a/apps/ledger-live-mobile/src/families/stacks/TransactionConfirmFields.tsx +++ b/apps/ledger-live-mobile/src/families/stacks/TransactionConfirmFields.tsx @@ -26,7 +26,7 @@ const StacksField = ({ return ( - {(field as ExtraDeviceTransactionField).value} + {(field as ExtraDeviceTransactionField).value as React.ReactNode} ); diff --git a/apps/ledger-live-mobile/src/families/stellar/AddAssetFlow/01-SelectAsset.tsx b/apps/ledger-live-mobile/src/families/stellar/AddAssetFlow/01-SelectAsset.tsx index 19b4da922704..432b039cf850 100644 --- a/apps/ledger-live-mobile/src/families/stellar/AddAssetFlow/01-SelectAsset.tsx +++ b/apps/ledger-live-mobile/src/families/stellar/AddAssetFlow/01-SelectAsset.tsx @@ -123,10 +123,11 @@ export default function DelegationStarted({ navigation, route }: Props) { ); const options = listTokensForCryptoCurrency(mainAccount.currency); const [infoModalOpen, setInfoModalOpen] = useState(false); + // @ts-expect-error this does not make any type of sense... we get a string yet we pass it to a function expecting a boolean const openModal = useCallback(token => setInfoModalOpen(token), [setInfoModalOpen]); const closeModal = useCallback(() => setInfoModalOpen(false), [setInfoModalOpen]); const renderList = useCallback( - list => ( + (list: TokenCurrency[]) => ( ( @@ -137,6 +138,7 @@ export default function DelegationStarted({ navigation, route }: Props) { sub.type === "TokenAccount" && sub.token && sub.token.id === item.id, )} onPress={() => onNext(item.id)} + // FIXME: why to we pass a string to a function that accepts boolean ? onDisabledPress={() => openModal(item.name)} /> )} diff --git a/apps/ledger-live-mobile/src/families/stellar/ScreenEditMemoType.tsx b/apps/ledger-live-mobile/src/families/stellar/ScreenEditMemoType.tsx index eec718165ef9..a5f8750e9117 100644 --- a/apps/ledger-live-mobile/src/families/stellar/ScreenEditMemoType.tsx +++ b/apps/ledger-live-mobile/src/families/stellar/ScreenEditMemoType.tsx @@ -63,7 +63,7 @@ const Screen = connect(mapStateToProps)( memoType: item.value, }), keyExtractor: item => item.value, - formatItem: item => i18next.t(`stellar.memoType.${item.label}`), + formatItem: item => i18next.t(`stellar.memoType.${item.label}`) as React.ReactNode, ListHeaderComponent: () => ( diff --git a/apps/ledger-live-mobile/src/families/tezos/DelegationFlow/SelectValidator.tsx b/apps/ledger-live-mobile/src/families/tezos/DelegationFlow/SelectValidator.tsx index d24d299a5932..82432a1a86f8 100644 --- a/apps/ledger-live-mobile/src/families/tezos/DelegationFlow/SelectValidator.tsx +++ b/apps/ledger-live-mobile/src/families/tezos/DelegationFlow/SelectValidator.tsx @@ -8,6 +8,7 @@ import { Platform, Linking, KeyboardEventListener, + ListRenderItem, } from "react-native"; import { useSelector } from "react-redux"; import { SafeAreaView } from "react-native-safe-area-context"; @@ -176,7 +177,7 @@ export default function SelectValidator({ navigation, route }: Props) { } const onChangeText = useCallback( - recipient => { + (recipient: string) => { const bridge = getAccountBridge(account, parentAccount); setTransaction( bridge.updateTransaction(transaction, { @@ -220,7 +221,7 @@ export default function SelectValidator({ navigation, route }: Props) { }, [account, parentAccount, route.params, navigation, status], ); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item }) => , [onItemPress], ); diff --git a/apps/ledger-live-mobile/src/families/tron/operationDetails.tsx b/apps/ledger-live-mobile/src/families/tron/operationDetails.tsx index 1dd6759f2077..fc5844ba0ce5 100644 --- a/apps/ledger-live-mobile/src/families/tron/operationDetails.tsx +++ b/apps/ledger-live-mobile/src/families/tron/operationDetails.tsx @@ -87,7 +87,7 @@ function OperationDetailsVotes({ votes, account }: OperationsDetailsVotesProps) const locale = useSelector(localeSelector); const formattedVotes = formatVotes(votes, sp); const redirectAddressCreator = useCallback( - address => () => { + (address: string) => () => { const url = getAddressExplorer(getDefaultExplorerView(account.currency), address); if (url) Linking.openURL(url); }, diff --git a/apps/ledger-live-mobile/src/helpers/formatAccountSearchResults.ts b/apps/ledger-live-mobile/src/helpers/formatAccountSearchResults.ts index 47c98fa222bf..3efead68efa0 100644 --- a/apps/ledger-live-mobile/src/helpers/formatAccountSearchResults.ts +++ b/apps/ledger-live-mobile/src/helpers/formatAccountSearchResults.ts @@ -68,7 +68,7 @@ export const formatSearchResults = (searchResults: AccountLike[], accounts: Acco export const formatSearchResultsTuples = ( searchResults: { account: AccountLike; - subAccount: SubAccount; + subAccount?: SubAccount | null; }[], ): SearchResult[] => { const formated = reduce( diff --git a/apps/ledger-live-mobile/src/index.tsx b/apps/ledger-live-mobile/src/index.tsx index 9afabbbe0f82..2f68fe18d62d 100644 --- a/apps/ledger-live-mobile/src/index.tsx +++ b/apps/ledger-live-mobile/src/index.tsx @@ -108,7 +108,7 @@ function App() { useFetchCurrencyFrom(); useListenToHidDevices(); - const getSettingsChanged = useCallback((a, b) => a.settings !== b.settings, []); + const getSettingsChanged = useCallback((a: State, b: State) => a.settings !== b.settings, []); const getAccountsChanged = useCallback( ( oldState: State, @@ -135,7 +135,7 @@ function App() { ); const getPostOnboardingStateChanged = useCallback( - (a, b) => !isEqual(a.postOnboarding, b.postOnboarding), + (a: State, b: State) => !isEqual(a.postOnboarding, b.postOnboarding), [], ); diff --git a/apps/ledger-live-mobile/src/logic/notifications.tsx b/apps/ledger-live-mobile/src/logic/notifications.tsx index 7e66ddaa18ca..f4bb2303bbc2 100644 --- a/apps/ledger-live-mobile/src/logic/notifications.tsx +++ b/apps/ledger-live-mobile/src/logic/notifications.tsx @@ -117,7 +117,7 @@ const useNotifications = () => { }, []); const setPushNotificationsModalOpenCallback = useCallback( - isModalOpen => { + (isModalOpen: boolean) => { if (!isModalOpen) { dispatch(setNotificationsModalType("generic")); dispatch(setNotificationsModalOpen(isModalOpen)); @@ -202,7 +202,7 @@ const useNotifications = () => { ); const onPushNotificationsRouteChange = useCallback( - (newRoute, isOtherModalOpened = false) => { + (newRoute: string, isOtherModalOpened = false) => { if (pushNotificationsEventTriggered?.timeout) { clearTimeout(pushNotificationsEventTriggered?.timeout); dispatch(setRatingsModalLocked(false)); @@ -321,7 +321,7 @@ const useNotifications = () => { ]); const handleSetDateOfNextAllowedRequest = useCallback( - (delay, additionalParams?: Partial) => { + (delay?: Duration, additionalParams?: Partial) => { if (delay !== null && delay !== undefined) { const dateOfNextAllowedRequest: Date = add(Date.now(), delay); updatePushNotificationsDataOfUserInStateAndStore({ diff --git a/apps/ledger-live-mobile/src/logic/npsRatings.tsx b/apps/ledger-live-mobile/src/logic/npsRatings.tsx index 7fece20756c6..197ff7f33037 100644 --- a/apps/ledger-live-mobile/src/logic/npsRatings.tsx +++ b/apps/ledger-live-mobile/src/logic/npsRatings.tsx @@ -79,7 +79,7 @@ const useNpsRatings = () => { const dispatch = useDispatch(); const setRatingsModalOpenCallback = useCallback( - isRatingsModalOpen => { + (isRatingsModalOpen: boolean) => { if (!isRatingsModalOpen) { dispatch(setRatingsModalOpen(isRatingsModalOpen)); dispatch(setNotificationsModalLocked(false)); @@ -172,7 +172,7 @@ const useNpsRatings = () => { ); const onRatingsRouteChange = useCallback( - (ratingsNewRoute, isOtherModalOpened = false) => { + (ratingsNewRoute: string, isOtherModalOpened = false) => { if (ratingsHappyMoment?.timeout) { dispatch(setNotificationsModalLocked(false)); clearTimeout(ratingsHappyMoment?.timeout); @@ -213,7 +213,7 @@ const useNpsRatings = () => { ); const updateRatingsDataOfUserInStateAndStore = useCallback( - ratingsDataOfUserUpdated => { + (ratingsDataOfUserUpdated: RatingsDataOfUser) => { dispatch(setRatingsDataOfUser(ratingsDataOfUserUpdated)); setRatingsDataOfUserInStorage(ratingsDataOfUserUpdated); }, @@ -251,7 +251,7 @@ const useNpsRatings = () => { }, [isRatingsModalLocked, dispatch, setRatingsModalOpenCallback]); const handleRatingsSetDateOfNextAllowedRequest = useCallback( - (delay, additionalParams = {}) => { + (delay?: Duration, additionalParams = {}) => { if (delay !== null && delay !== undefined) { const dateOfNextAllowedRequest: Date = add(Date.now(), delay); updateRatingsDataOfUserInStateAndStore({ @@ -326,7 +326,7 @@ const useNpsRatings = () => { }, [ratingsDataOfUser, updateRatingsDataOfUserInStateAndStore]); const updateNpsRating = useCallback( - nps => { + (nps: number) => { dispatch(setUserNps(nps)); }, [dispatch], diff --git a/apps/ledger-live-mobile/src/logic/ratings.tsx b/apps/ledger-live-mobile/src/logic/ratings.tsx index 93ba57b14ee4..bd5ab3a93775 100644 --- a/apps/ledger-live-mobile/src/logic/ratings.tsx +++ b/apps/ledger-live-mobile/src/logic/ratings.tsx @@ -78,7 +78,7 @@ const useRatings = () => { const dispatch = useDispatch(); const setRatingsModalOpenCallback = useCallback( - isRatingsModalOpen => { + (isRatingsModalOpen: boolean) => { if (!isRatingsModalOpen) { dispatch(setRatingsModalOpen(isRatingsModalOpen)); dispatch(setNotificationsModalLocked(false)); @@ -171,7 +171,7 @@ const useRatings = () => { ); const onRatingsRouteChange = useCallback( - (ratingsNewRoute, isOtherModalOpened = false) => { + (ratingsNewRoute: string, isOtherModalOpened = false) => { if (ratingsHappyMoment?.timeout) { dispatch(setNotificationsModalLocked(false)); clearTimeout(ratingsHappyMoment?.timeout); @@ -212,7 +212,7 @@ const useRatings = () => { ); const updateRatingsDataOfUserInStateAndStore = useCallback( - ratingsDataOfUserUpdated => { + (ratingsDataOfUserUpdated: RatingsDataOfUser) => { dispatch(setRatingsDataOfUser(ratingsDataOfUserUpdated)); setRatingsDataOfUserInStorage(ratingsDataOfUserUpdated); }, @@ -254,7 +254,7 @@ const useRatings = () => { }, [isRatingsModalLocked, dispatch, ratingsFeature?.params, setRatingsModalOpenCallback]); const handleRatingsSetDateOfNextAllowedRequest = useCallback( - (delay, additionalParams = {}) => { + (delay: Duration, additionalParams = {}) => { if (delay !== null && delay !== undefined) { const dateOfNextAllowedRequest: Date = add(Date.now(), delay); updateRatingsDataOfUserInStateAndStore({ @@ -279,7 +279,7 @@ const useRatings = () => { }); } else { handleRatingsSetDateOfNextAllowedRequest( - ratingsFeature?.params?.conditions?.satisfied_then_not_now_delay, + ratingsFeature?.params?.conditions?.satisfied_then_not_now_delay as Duration, { alreadyClosedFromEnjoyStep: true, }, @@ -302,9 +302,12 @@ const useRatings = () => { doNotAskAgain: true, }); } else { - handleRatingsSetDateOfNextAllowedRequest(ratingsFeature?.params?.conditions?.not_now_delay, { - alreadyClosedFromInitStep: true, - }); + handleRatingsSetDateOfNextAllowedRequest( + ratingsFeature?.params?.conditions?.not_now_delay as Duration, + { + alreadyClosedFromInitStep: true, + }, + ); } }, [ handleRatingsSetDateOfNextAllowedRequest, diff --git a/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts b/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts index 74521f199eed..4a961e6af0cc 100644 --- a/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts +++ b/apps/ledger-live-mobile/src/logic/screenTransactionHooks.ts @@ -248,7 +248,13 @@ export function useSignedTxHandler({ return useCallback( // TODO: fix type error - async ({ signedOperation, transactionSignError }) => { + async ({ + signedOperation, + transactionSignError, + }: { + signedOperation: SignedOperation; + transactionSignError?: Error; + }) => { try { if (transactionSignError) { throw transactionSignError; @@ -293,7 +299,13 @@ export function useSignedTxHandlerWithoutBroadcast({ const navigation = useNavigation(); const route = useRoute(); return useCallback( - async ({ signedOperation, transactionSignError }) => { + async ({ + signedOperation, + transactionSignError, + }: { + signedOperation: SignedOperation; + transactionSignError?: Error; + }) => { try { if (transactionSignError) { throw transactionSignError; diff --git a/apps/ledger-live-mobile/src/navigation/utils.ts b/apps/ledger-live-mobile/src/navigation/utils.ts index b6940986ca2e..983b0c847e28 100644 --- a/apps/ledger-live-mobile/src/navigation/utils.ts +++ b/apps/ledger-live-mobile/src/navigation/utils.ts @@ -14,6 +14,7 @@ export function useScrollToTop( >, ) { const isFocused = useIsFocused(); + // @ts-expect-error expecting a weir type useNativeScrollToTop(ref); useEffect(() => { const subscription = scrollSubject.subscribe(() => { diff --git a/apps/ledger-live-mobile/src/screens/Account/NftCollectionsList.tsx b/apps/ledger-live-mobile/src/screens/Account/NftCollectionsList.tsx index 4df108e3e856..3e451093699d 100644 --- a/apps/ledger-live-mobile/src/screens/Account/NftCollectionsList.tsx +++ b/apps/ledger-live-mobile/src/screens/Account/NftCollectionsList.tsx @@ -41,10 +41,10 @@ export default function NftCollectionsList({ account }: Props) { ) as [string, ProtoNFT[]][]; const [isCollectionMenuOpen, setIsCollectionMenuOpen] = useState(false); - const [selectedCollection, setSelectedCollection] = useState(); + const [selectedCollection, setSelectedCollection] = useState(); const onSelectCollection = useCallback( - collection => { + (collection: ProtoNFT[]) => { setSelectedCollection(collection); setIsCollectionMenuOpen(true); }, @@ -68,7 +68,7 @@ export default function NftCollectionsList({ account }: Props) { ); const navigateToCollection = useCallback( - collection => + (collection: ProtoNFT[]) => navigation.navigate(NavigatorName.Accounts, { screen: ScreenName.NftCollection, params: { diff --git a/apps/ledger-live-mobile/src/screens/Account/SubAccountsList.tsx b/apps/ledger-live-mobile/src/screens/Account/SubAccountsList.tsx index d0af0d453608..95f3efb5bea5 100644 --- a/apps/ledger-live-mobile/src/screens/Account/SubAccountsList.tsx +++ b/apps/ledger-live-mobile/src/screens/Account/SubAccountsList.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useState, useMemo } from "react"; import { Trans } from "react-i18next"; import { useSelector } from "react-redux"; import take from "lodash/take"; -import { StyleSheet, View, FlatList } from "react-native"; +import { StyleSheet, View, FlatList, ListRenderItem } from "react-native"; import { useNavigation, useTheme } from "@react-navigation/native"; import { Account, SubAccount, TokenAccount } from "@ledgerhq/types-live"; import useEnv from "@ledgerhq/live-common/hooks/useEnv"; @@ -195,7 +195,7 @@ export default function SubAccountsList({ accountId, ]); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item }) => ( { + (device: Device) => { dispatch(setLastConnectedDevice(device)); setDevice(device); dispatch(setReadOnlyMode(false)); @@ -57,6 +57,7 @@ export default function AddAccountsSelectDevice({ navigation, route }: Props) { }, []); const onResult = useCallback( + // @ts-expect-error should be AppResult but navigation.navigate does not agree meta => { setDevice(null); const { inline } = route.params; diff --git a/apps/ledger-live-mobile/src/screens/Analytics/Operations.tsx b/apps/ledger-live-mobile/src/screens/Analytics/Operations.tsx index 044d787c4bc3..646ffc1ba5f0 100644 --- a/apps/ledger-live-mobile/src/screens/Analytics/Operations.tsx +++ b/apps/ledger-live-mobile/src/screens/Analytics/Operations.tsx @@ -3,7 +3,13 @@ import { SectionList, SectionListData, SectionListRenderItem } from "react-nativ import { Flex } from "@ledgerhq/native-ui"; import { useSelector } from "react-redux"; import { useFocusEffect } from "@react-navigation/native"; -import { Account, AccountLikeArray, DailyOperationsSection, Operation } from "@ledgerhq/types-live"; +import { + Account, + AccountLike, + AccountLikeArray, + DailyOperationsSection, + Operation, +} from "@ledgerhq/types-live"; import { groupAccountsOperationsByDay } from "@ledgerhq/live-common/account/index"; import { isAccountEmpty } from "@ledgerhq/live-common/account/helpers"; @@ -55,7 +61,7 @@ export function Operations({ navigation, route }: Props) { filterTokenOperationsZeroAmountEnabledSelector, ); const filterOperation = useCallback( - (operation, account) => { + (operation: Operation, account: AccountLike) => { // Remove operations linked to address poisoning const removeZeroAmountTokenOp = shouldFilterTokenOpsZeroAmount && isAddressPoisoningOperation(operation, account); diff --git a/apps/ledger-live-mobile/src/screens/ClaimNft/ClaimNftQrScan.tsx b/apps/ledger-live-mobile/src/screens/ClaimNft/ClaimNftQrScan.tsx index ffc07a7ff736..67aaa79e9a1d 100644 --- a/apps/ledger-live-mobile/src/screens/ClaimNft/ClaimNftQrScan.tsx +++ b/apps/ledger-live-mobile/src/screens/ClaimNft/ClaimNftQrScan.tsx @@ -3,7 +3,7 @@ import { Dimensions, Linking, Platform, StyleSheet } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { Flex, InfiniteLoader, Text } from "@ledgerhq/native-ui"; import { useTranslation } from "react-i18next"; -import { CameraType } from "expo-camera/build/Camera.types"; +import { BarCodeScanningResult, CameraType } from "expo-camera/build/Camera.types"; import { Camera } from "expo-camera"; import { BarCodeScanner } from "expo-barcode-scanner"; import { Svg, Defs, Rect, Mask } from "react-native-svg"; @@ -96,7 +96,7 @@ const ClaimNftQrScan = () => { }; }, [navigateToHub, isInFocus]); - const handleBarCodeScanned = useCallback(({ data }) => { + const handleBarCodeScanned = useCallback(({ data }: BarCodeScanningResult) => { try { const url = new URL(data); const { hostname } = url; diff --git a/apps/ledger-live-mobile/src/screens/ConnectDevice.tsx b/apps/ledger-live-mobile/src/screens/ConnectDevice.tsx index 15f2939eed7d..dcc223417bd4 100644 --- a/apps/ledger-live-mobile/src/screens/ConnectDevice.tsx +++ b/apps/ledger-live-mobile/src/screens/ConnectDevice.tsx @@ -53,6 +53,7 @@ import { TronVoteFlowParamList } from "../families/tron/VoteFlow/types"; import { SignTransactionNavigatorParamList } from "../components/RootNavigator/types/SignTransactionNavigator"; import { SignMessageNavigatorStackParamList } from "../components/RootNavigator/types/SignMessageNavigator"; import { useTransactionDeviceAction } from "../hooks/deviceActions"; +import { SignedOperation } from "@ledgerhq/types-live"; type Props = | StackNavigatorProps @@ -130,7 +131,7 @@ export default function ConnectDevice({ route, navigation }: Props) { parentAccount, }); const onResult = useCallback( - payload => { + (payload: { signedOperation: SignedOperation; transactionSignError?: Error }) => { handleTx(payload); return renderLoading({ t, @@ -160,6 +161,7 @@ export default function ConnectDevice({ route, navigation }: Props) { > @@ -76,7 +77,7 @@ const Step1Cropping = ({ navigation, route }: NavigationProps) => { }, [cropperRef, rotated, setRotated]); const [containerDimensions, setContainerDimensions] = useState(null); - const onContainerLayout = useCallback(({ nativeEvent: { layout } }) => { + const onContainerLayout = useCallback(({ nativeEvent: { layout } }: LayoutChangeEvent) => { setContainerDimensions({ height: layout.height, width: layout.width }); }, []); diff --git a/apps/ledger-live-mobile/src/screens/CustomImage/Step2ChooseContrast.tsx b/apps/ledger-live-mobile/src/screens/CustomImage/Step2ChooseContrast.tsx index 4d5f9bd7dcbd..aa2f778c1ba8 100644 --- a/apps/ledger-live-mobile/src/screens/CustomImage/Step2ChooseContrast.tsx +++ b/apps/ledger-live-mobile/src/screens/CustomImage/Step2ChooseContrast.tsx @@ -157,7 +157,7 @@ const Step2ChooseContrast = ({ navigation, route }: NavigationProps) => { }, [imageProcessorRef, setRawResultLoading]); const setSelectedIndexWrapped = useCallback( - newIndex => { + (newIndex: number) => { setSelectedIndex(newIndex); animSelectedIndex.value = withTiming(newIndex, { duration: 300 }); }, diff --git a/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/FeatureFlagEdit.tsx b/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/FeatureFlagEdit.tsx index 7c727aaa2984..a3805de3a534 100644 --- a/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/FeatureFlagEdit.tsx +++ b/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/FeatureFlagEdit.tsx @@ -39,7 +39,7 @@ const FeatureFlagEdit: React.FC<{ const { t } = useTranslation(); - const handleInputChange = useCallback(value => { + const handleInputChange = useCallback((value: string) => { setError(undefined); setInputValue(value); }, []); @@ -71,7 +71,7 @@ const FeatureFlagEdit: React.FC<{ }, [inputValueDefaulted]); const handleSwitchChange = useCallback( - enabled => { + (enabled: boolean) => { featureFlagsProvider.overrideFeature(flagName, { ...flagValue, enabled }); }, [featureFlagsProvider, flagName, flagValue], @@ -85,7 +85,7 @@ const FeatureFlagEdit: React.FC<{ ) : null} ( diff --git a/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/GroupedFeatures.tsx b/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/GroupedFeatures.tsx index 80bdf447f33d..089a410b1bb7 100644 --- a/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/GroupedFeatures.tsx +++ b/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/GroupedFeatures.tsx @@ -47,7 +47,7 @@ const GroupedFeatures: React.FC = ({ groupName, focused, setFocusedGroupN }); const handleSwitchChange = useCallback( - enabled => { + (enabled: boolean) => { featureIds.forEach(featureId => overrideFeature(featureId, { ...getFeature(featureId), enabled }), ); diff --git a/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/index.tsx b/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/index.tsx index 79686ecc51bc..c3ef6f0f626e 100644 --- a/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/index.tsx +++ b/apps/ledger-live-mobile/src/screens/FeatureFlagsSettings/index.tsx @@ -59,7 +59,7 @@ export default function DebugFeatureFlags() { return featureKeys; }, [isFeature, searchInputTrimmed]); - const handleSearch = useCallback(value => { + const handleSearch = useCallback((value: string) => { setSearchInput(value); }, []); @@ -135,7 +135,7 @@ export default function DebugFeatureFlags() { const featureFlagsBannerVisible = useSelector(featureFlagsBannerVisibleSelector); const dispatch = useDispatch(); const setFeatureFlagBannerVisible = useCallback( - newVal => { + (newVal: boolean) => { dispatch(setFeatureFlagsBannerVisible(newVal)); }, [dispatch], diff --git a/apps/ledger-live-mobile/src/screens/FirmwareUpdate/RestoreStepDenied.tsx b/apps/ledger-live-mobile/src/screens/FirmwareUpdate/RestoreStepDenied.tsx index d9dd6d8c729a..29b302232482 100644 --- a/apps/ledger-live-mobile/src/screens/FirmwareUpdate/RestoreStepDenied.tsx +++ b/apps/ledger-live-mobile/src/screens/FirmwareUpdate/RestoreStepDenied.tsx @@ -41,12 +41,14 @@ export const RestoreStepDenied = ({ - {t(`FirmwareUpdate.steps.restoreSettings.errors.${stepDeniedError.name}`, { - deviceName: getDeviceModel(device.modelId).productName, - })} + { + t(`FirmwareUpdate.steps.restoreSettings.errors.${stepDeniedError.name}`, { + deviceName: getDeviceModel(device.modelId).productName, + }) as string + } - {t("FirmwareUpdate.steps.restoreSettings.errors.description")} + {t("FirmwareUpdate.steps.restoreSettings.errors.description") as string} - {t("common.skip")} + {t("common.skip") as string} diff --git a/apps/ledger-live-mobile/src/screens/FreezeFunds/02-Amount.tsx b/apps/ledger-live-mobile/src/screens/FreezeFunds/02-Amount.tsx index 5d5a954fe8db..7e750a5b7fea 100644 --- a/apps/ledger-live-mobile/src/screens/FreezeFunds/02-Amount.tsx +++ b/apps/ledger-live-mobile/src/screens/FreezeFunds/02-Amount.tsx @@ -69,7 +69,7 @@ export default function FreezeAmount({ navigation, route }: NavigatorProps) { const defaultUnit = getAccountUnit(account); const { spendableBalance } = account; - const [selectedRatio, selectRatio] = useState(); + const [selectedRatio, selectRatio] = useState(); const [infoModalOpen, setInfoModalOpen] = useState(); @@ -157,7 +157,7 @@ export default function FreezeAmount({ navigation, route }: NavigatorProps) { }, [setInfoModalOpen]); const onRatioPress = useCallback( - value => { + (value: BigNumber) => { blur(); selectRatio(value); onChange(value, true); @@ -166,7 +166,7 @@ export default function FreezeAmount({ navigation, route }: NavigatorProps) { ); const onChangeResource = useCallback( - optionIndex => { + (optionIndex: number) => { setTransaction( bridge.updateTransaction(transaction, { resource: options[optionIndex].value, diff --git a/apps/ledger-live-mobile/src/screens/Manager/AppsList/AppUpdateStepper.tsx b/apps/ledger-live-mobile/src/screens/Manager/AppsList/AppUpdateStepper.tsx index abb017e2a231..f166c7b4e2b6 100644 --- a/apps/ledger-live-mobile/src/screens/Manager/AppsList/AppUpdateStepper.tsx +++ b/apps/ledger-live-mobile/src/screens/Manager/AppsList/AppUpdateStepper.tsx @@ -21,6 +21,7 @@ const AppUpdateStepper = ({ state }: Props) => { const count = updateAllQueue.length; return ( + // @ts-expect-error don't understand what is going on = ({ onLanguageChange(); }, [onLanguageChange]); - const errorTracked = useRef(null); + const errorTracked = useRef(null); const handleError = useCallback( - error => { + (error: Error) => { if (errorTracked.current !== error) { track("Page Manager LanguageInstallError", { error, type: "drawer" }); errorTracked.current = error; diff --git a/apps/ledger-live-mobile/src/screens/Manager/Modals/FilterModal.tsx b/apps/ledger-live-mobile/src/screens/Manager/Modals/FilterModal.tsx index f0e59aeadea4..c54b835f51aa 100644 --- a/apps/ledger-live-mobile/src/screens/Manager/Modals/FilterModal.tsx +++ b/apps/ledger-live-mobile/src/screens/Manager/Modals/FilterModal.tsx @@ -1,7 +1,7 @@ import { Flex, IconsLegacy, Text } from "@ledgerhq/native-ui"; import React, { memo, useCallback, useEffect, useReducer } from "react"; import { Trans } from "react-i18next"; -import { SectionList, SectionListData } from "react-native"; +import { ListRenderItem, SectionList, SectionListData } from "react-native"; import styled from "styled-components/native"; import Touchable from "../../../components/Touchable"; import { Unpacked } from "../../../types/helpers"; @@ -60,7 +60,7 @@ const filterSections = [ }, ]; type FilterSection = Unpacked; -type FilterSectionData = FilterSection["data"][0]; +type FilterSectionData = FilterSection["data"][number]; const FilterLine = styled(Touchable)` flex-direction: row; @@ -174,8 +174,10 @@ const FilterModalComponent = ({ onClose(); }, [state, setFilter, setSort, setOrder, onClose]); - const FilterItem = useCallback( - ({ item: { label, value, isFilter } }) => { + const FilterItem: ListRenderItem = useCallback( + ({ item }) => { + const { label, value } = item; + const isFilter = "isFilter" in item ? item.isFilter : undefined; const isSelected = isFilter ? state.filter === value : state.sort === value; let orderValue: string; @@ -186,7 +188,7 @@ const FilterModalComponent = ({ } const onPress = () => { - if (isFilter) dispatch({ type: "setFilter", payload: value }); + if ("isFilter" in item && item.isFilter) dispatch({ type: "setFilter", payload: value }); else dispatch({ type: "setState", diff --git a/apps/ledger-live-mobile/src/screens/Market/MarketCurrencySelect.tsx b/apps/ledger-live-mobile/src/screens/Market/MarketCurrencySelect.tsx index edf1232977bb..1ded1f78feb8 100644 --- a/apps/ledger-live-mobile/src/screens/Market/MarketCurrencySelect.tsx +++ b/apps/ledger-live-mobile/src/screens/Market/MarketCurrencySelect.tsx @@ -79,7 +79,7 @@ function MarketCurrencySelect({ navigation }: Props) { ); const renderItem = useCallback( - ({ item, index }) => { + ({ item, index }: { item: (typeof items)[number]; index: number }) => { const isChecked = counterCurrency === item.value; const color = isChecked ? "primary.c80" : "neutral.c100"; const labelColor = isChecked ? "primary.c80" : "neutral.c80"; @@ -114,7 +114,7 @@ function MarketCurrencySelect({ navigation }: Props) { ); const renderList = useCallback( - list => ( + (list: typeof items) => ( { + (index: number) => { if (isLoading) return; const newRange = ranges[index]?.value; if (range !== newRange) refreshChart({ range: newRange }); @@ -59,7 +59,7 @@ function MarketGraph({ [isLoading, range, ranges, refreshChart], ); - const mapGraphValue = useCallback(d => d?.value || 0, []); + const mapGraphValue = useCallback((d: Item) => d?.value || 0, []); return ( diff --git a/apps/ledger-live-mobile/src/screens/Market/index.tsx b/apps/ledger-live-mobile/src/screens/Market/index.tsx index 8224049bdcf8..971abe166092 100644 --- a/apps/ledger-live-mobile/src/screens/Market/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Market/index.tsx @@ -14,8 +14,8 @@ import { useDispatch, useSelector } from "react-redux"; import { Trans, useTranslation } from "react-i18next"; import { useMarketData } from "@ledgerhq/live-common/market/MarketDataProvider"; import { rangeDataTable } from "@ledgerhq/live-common/market/utils/rangeDataTable"; -import { FlatList, RefreshControl, TouchableOpacity } from "react-native"; -import { MarketListRequestParams } from "@ledgerhq/live-common/market/types"; +import { FlatList, ListRenderItem, RefreshControl, TouchableOpacity } from "react-native"; +import { CurrencyData, MarketListRequestParams } from "@ledgerhq/live-common/market/types"; import { useRoute, useFocusEffect } from "@react-navigation/native"; import { useNetInfo } from "@react-native-community/netinfo"; import { useSafeAreaInsets } from "react-native-safe-area-context"; @@ -316,7 +316,7 @@ export default function Market({ navigation }: NavigationProps) { } }, [initialTop100, refresh]); - const renderItems = useCallback( + const renderItems: ListRenderItem = useCallback( ({ item, index }) => ( { diff --git a/apps/ledger-live-mobile/src/screens/Modals/index.tsx b/apps/ledger-live-mobile/src/screens/Modals/index.tsx index d6526b7ba536..48aecf75ee11 100644 --- a/apps/ledger-live-mobile/src/screens/Modals/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Modals/index.tsx @@ -40,10 +40,11 @@ const Modals = () => { : "none"; const onRouteChange = useCallback( + // @ts-expect-error cannot find the correct event there e => { const navState = e?.data?.state; if (navState && navState.routeNames) { - const currentRouteName = getCurrentRouteName(navState); + const currentRouteName = getCurrentRouteName(navState) as string; let isModalOpened = false; if (pushNotificationsFeature?.enabled) { isModalOpened = onPushNotificationsRouteChange(currentRouteName, isModalOpened); diff --git a/apps/ledger-live-mobile/src/screens/Nft/NftCollection/index.tsx b/apps/ledger-live-mobile/src/screens/Nft/NftCollection/index.tsx index 4865bafc8f00..5da42537120c 100644 --- a/apps/ledger-live-mobile/src/screens/Nft/NftCollection/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Nft/NftCollection/index.tsx @@ -73,7 +73,7 @@ const NftCollection = ({ route }: NavigationProps) => { }; const renderNftItem = useCallback( - ({ item, index }) => ( + ({ item, index }: { item: ProtoNFT; index: number }) => ( + ({ + announcements, + seenIds, + lastUpdateTime, + }: { + announcements: Announcement[]; + seenIds: string[]; + lastUpdateTime: number; + }) => saveNotifications({ announcements, seenIds, @@ -108,7 +116,7 @@ export default function NotificationsProvider({ children }: Props) { }, [pushToast, initDateRef], ); - const onAnnouncementRead = useCallback(({ uuid, utm_campaign: utmCampaign }) => { + const onAnnouncementRead = useCallback(({ uuid, utm_campaign: utmCampaign }: Announcement) => { track("Announcement Viewed", { uuid, utm_campaign: utmCampaign, diff --git a/apps/ledger-live-mobile/src/screens/NpsRatingsModal/Form.tsx b/apps/ledger-live-mobile/src/screens/NpsRatingsModal/Form.tsx index 893260309190..409411b1aefb 100644 --- a/apps/ledger-live-mobile/src/screens/NpsRatingsModal/Form.tsx +++ b/apps/ledger-live-mobile/src/screens/NpsRatingsModal/Form.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useState } from "react"; import { Flex } from "@ledgerhq/native-ui"; -import { WebView } from "react-native-webview"; +import { WebView, WebViewMessageEvent } from "react-native-webview"; import VersionNumber from "react-native-version-number"; import { Platform } from "react-native"; import styled from "styled-components/native"; @@ -77,7 +77,7 @@ const Form = ({ setStep }: Props) => { const language = useSelector(languageSelector); const devices = useSelector(knownDevicesSelector); const lastDevice = useSelector(lastSeenDeviceSelector) || devices[devices.length - 1]; - const [selectedRate, setSelectedRate] = useState(); + const [selectedRate, setSelectedRate] = useState(); const notifications = useSelector(notificationsSelector); const notificationsAllowed = notifications.areNotificationsAllowed; @@ -87,10 +87,10 @@ const Form = ({ setStep }: Props) => { .join(","); const onMessage = useCallback( - event => { + (event: WebViewMessageEvent) => { const { data } = event.nativeEvent; if (data.startsWith("nps-submit")) { - const rate = data.split("-")[2]; + const rate = parseInt(data.split("-")[2], 10); setSelectedRate(rate); if (rate <= 8) { screen( @@ -109,7 +109,7 @@ const Form = ({ setStep }: Props) => { } } if (data === "form-submit") { - updateNpsRating(selectedRate); + updateNpsRating(selectedRate as number); if (!selectedRate || selectedRate <= 7) { setStep("disappointedDone"); } else { diff --git a/apps/ledger-live-mobile/src/screens/NpsRatingsModal/index.tsx b/apps/ledger-live-mobile/src/screens/NpsRatingsModal/index.tsx index fe52f08d9e0e..62328508582b 100644 --- a/apps/ledger-live-mobile/src/screens/NpsRatingsModal/index.tsx +++ b/apps/ledger-live-mobile/src/screens/NpsRatingsModal/index.tsx @@ -8,6 +8,7 @@ import Form from "./Form"; import Enjoy from "./Enjoy"; import DisappointedDone from "./DisappointedDone"; +import { LayoutChangeEvent } from "react-native"; const eventNameByPage: Record = { form: "NPS Step 1 Rating", @@ -40,7 +41,7 @@ const RatingsModal = () => { */ const sharedHeight = useSharedValue(null); const onLayout = useCallback( - ({ nativeEvent: { layout } }) => { + ({ nativeEvent: { layout } }: LayoutChangeEvent) => { sharedHeight.value = withTiming(layout.height, { duration: 200 }); }, [sharedHeight], diff --git a/apps/ledger-live-mobile/src/screens/Onboarding/OnboardingQuiz.tsx b/apps/ledger-live-mobile/src/screens/Onboarding/OnboardingQuiz.tsx index 2c7e592787b7..8fb8841d3181 100644 --- a/apps/ledger-live-mobile/src/screens/Onboarding/OnboardingQuiz.tsx +++ b/apps/ledger-live-mobile/src/screens/Onboarding/OnboardingQuiz.tsx @@ -153,8 +153,10 @@ function OnboardingQuiz({ navigation, route }: Props) { ); const onNext = useCallback( - correct => { - setAnswers(userAnswers + correct); + (correct: boolean) => { + if (correct) { + setAnswers(userAnswers + 1); + } setBg("constant.purple"); if (index < quizData.length - 1) { setIndex(index + 1); diff --git a/apps/ledger-live-mobile/src/screens/Onboarding/steps/setupDevice/scenes/ConnectNano.tsx b/apps/ledger-live-mobile/src/screens/Onboarding/steps/setupDevice/scenes/ConnectNano.tsx index d49bf45d5608..5e01ddaf24ca 100644 --- a/apps/ledger-live-mobile/src/screens/Onboarding/steps/setupDevice/scenes/ConnectNano.tsx +++ b/apps/ledger-live-mobile/src/screens/Onboarding/steps/setupDevice/scenes/ConnectNano.tsx @@ -46,7 +46,7 @@ const ConnectNanoScene = ({ ); const directNext = useCallback( - async device => { + async (device: Device) => { dispatch(setLastConnectedDevice(device)); dispatch(setReadOnlyMode(false)); dispatch(setHasOrderedNano(false)); diff --git a/apps/ledger-live-mobile/src/screens/Onboarding/steps/welcome.tsx b/apps/ledger-live-mobile/src/screens/Onboarding/steps/welcome.tsx index d692d3a5a7f6..bd43ae59ee7f 100644 --- a/apps/ledger-live-mobile/src/screens/Onboarding/steps/welcome.tsx +++ b/apps/ledger-live-mobile/src/screens/Onboarding/steps/welcome.tsx @@ -82,7 +82,7 @@ function OnboardingStepWelcome({ navigation }: NavigationProps) { const timeout = useRef>(); const handleNavigateToFeatureFlagsSettings = useCallback( - nb => { + (nb: string) => { if (nb === "1") countTitle.current++; else if (nb === "2") countSubtitle.current++; if (countTitle.current > 3 && countSubtitle.current > 5) { diff --git a/apps/ledger-live-mobile/src/screens/Platform/exchange/CompleteExchange.tsx b/apps/ledger-live-mobile/src/screens/Platform/exchange/CompleteExchange.tsx index 45e19306b51b..307db51d8c22 100644 --- a/apps/ledger-live-mobile/src/screens/Platform/exchange/CompleteExchange.tsx +++ b/apps/ledger-live-mobile/src/screens/Platform/exchange/CompleteExchange.tsx @@ -11,6 +11,8 @@ import { useTransactionDeviceAction, useCompleteExchangeDeviceAction, } from "../../../hooks/deviceActions"; +import { SignedOperation } from "@ledgerhq/types-live"; +import { Transaction } from "@ledgerhq/live-common/generated/types"; type Props = StackNavigatorProps< PlatformExchangeNavigatorParamList, @@ -29,9 +31,9 @@ const PlatformCompleteExchange: React.FC = ({ if (account.type === "TokenAccount") tokenCurrency = account.token; const broadcast = useBroadcast({ account, parentAccount }); - const [transaction, setTransaction] = useState(); - const [signedOperation, setSignedOperation] = useState(); - const [error, setError] = useState(); + const [transaction, setTransaction] = useState(); + const [signedOperation, setSignedOperation] = useState(); + const [error, setError] = useState(); useEffect(() => { if (signedOperation) { @@ -51,21 +53,27 @@ const PlatformCompleteExchange: React.FC = ({ navigation.pop(); }, [navigation]); - const onCompleteExchange = useCallback(({ completeExchangeResult, completeExchangeError }) => { - if (completeExchangeError) { - setError(completeExchangeError); - } else { - setTransaction(completeExchangeResult); - } - }, []); + const onCompleteExchange = useCallback( + (res: { completeExchangeResult: Transaction } | { completeExchangeError: Error }) => { + if ("completeExchangeError" in res) { + setError(res.completeExchangeError); + } else if ("completeExchangeResult" in res) { + setTransaction(res.completeExchangeResult); + } + }, + [], + ); - const onSign = useCallback(({ signedOperation, transactionSignError }) => { - if (transactionSignError) { - setError(transactionSignError); - } else { - setSignedOperation(signedOperation); - } - }, []); + const onSign = useCallback( + (res: { signedOperation: SignedOperation } | { transactionSignError?: Error }) => { + if ("transactionSignError" in res) { + setError(res.transactionSignError); + } else if ("signedOperation" in res) { + setSignedOperation(res.signedOperation); + } + }, + [], + ); const signRequest = useMemo(() => { if (transaction) { diff --git a/apps/ledger-live-mobile/src/screens/RatingsModal/DisappointedForm.tsx b/apps/ledger-live-mobile/src/screens/RatingsModal/DisappointedForm.tsx index 5588d85df3ae..82f4e2de9477 100644 --- a/apps/ledger-live-mobile/src/screens/RatingsModal/DisappointedForm.tsx +++ b/apps/ledger-live-mobile/src/screens/RatingsModal/DisappointedForm.tsx @@ -1,6 +1,6 @@ import React, { useCallback } from "react"; import { Flex } from "@ledgerhq/native-ui"; -import { WebView } from "react-native-webview"; +import { WebView, WebViewMessageEvent } from "react-native-webview"; import VersionNumber from "react-native-version-number"; import { Platform } from "react-native"; import styled from "styled-components/native"; @@ -81,7 +81,7 @@ const DisappointedForm = ({ setStep }: Props) => { }); }, [ratingsFeatureParams, ratingsHappyMoment?.route_name]); const onMessage = useCallback( - event => { + (event: WebViewMessageEvent) => { const { data } = event.nativeEvent; if (data === "form-submit") { diff --git a/apps/ledger-live-mobile/src/screens/RatingsModal/Init.tsx b/apps/ledger-live-mobile/src/screens/RatingsModal/Init.tsx index 757b289319b4..b3a1623a572f 100644 --- a/apps/ledger-live-mobile/src/screens/RatingsModal/Init.tsx +++ b/apps/ledger-live-mobile/src/screens/RatingsModal/Init.tsx @@ -47,9 +47,12 @@ const Init = ({ closeModal, setStep }: Props) => { source: ratingsHappyMoment?.route_name, params: ratingsFeatureParams, }); - handleRatingsSetDateOfNextAllowedRequest(ratingsFeatureParams?.conditions?.disappointed_delay, { - satisfaction: "disappointed", - }); + handleRatingsSetDateOfNextAllowedRequest( + ratingsFeatureParams?.conditions?.disappointed_delay as Duration, + { + satisfaction: "disappointed", + }, + ); updateIdentify(); }, [ setStep, diff --git a/apps/ledger-live-mobile/src/screens/RatingsModal/index.tsx b/apps/ledger-live-mobile/src/screens/RatingsModal/index.tsx index 03b433c7d4aa..e30c047e19f7 100644 --- a/apps/ledger-live-mobile/src/screens/RatingsModal/index.tsx +++ b/apps/ledger-live-mobile/src/screens/RatingsModal/index.tsx @@ -7,6 +7,7 @@ import Enjoy from "./Enjoy"; import Disappointed from "./Disappointed"; import DisappointedForm from "./DisappointedForm"; import DisappointedDone from "./DisappointedDone"; +import { LayoutChangeEvent } from "react-native"; const RatingsModal = () => { const { @@ -33,7 +34,7 @@ const RatingsModal = () => { */ const sharedHeight = useSharedValue(null); const onLayout = useCallback( - ({ nativeEvent: { layout } }) => { + ({ nativeEvent: { layout } }: LayoutChangeEvent) => { sharedHeight.value = withTiming(layout.height, { duration: 200 }); }, [sharedHeight], diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx index e3a492f1db96..d067ede9ea1b 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccount.tsx @@ -217,7 +217,7 @@ function AddAccountsAccounts({ navigation, route }: Props) { [currency.ticker, t], ); - const keyExtractor = useCallback(item => item?.id, []); + const keyExtractor = useCallback((item: Account) => item?.id, []); return ( <> diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccountSelectDevice.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccountSelectDevice.tsx index 8c7c9ace62a2..bbcfbd871727 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccountSelectDevice.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-AddAccountSelectDevice.tsx @@ -46,7 +46,7 @@ export default function AddAccountsSelectDevice({ const newDeviceSelectionFeatureFlag = useFeature("llmNewDeviceSelection"); const onSetDevice = useCallback( - device => { + (device: Device) => { dispatch(setLastConnectedDevice(device)); setDevice(device); }, @@ -58,6 +58,7 @@ export default function AddAccountsSelectDevice({ }, []); const onResult = useCallback( + // @ts-expect-error should be AppResult but navigation.navigate does not agree meta => { setDevice(null); const { inline } = route.params; diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx index c5bd98755836..5dfa5354cbe1 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/02-SelectAccount.tsx @@ -140,7 +140,7 @@ function ReceiveSelectAccount({ } }, [currency, navigationAccount]); - const keyExtractor = useCallback(item => item?.id, []); + const keyExtractor = useCallback((item: AccountLike) => item?.id, []); return currency && aggregatedAccounts && aggregatedAccounts.length > 0 ? ( <> diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/03a-ConnectDevice.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/03a-ConnectDevice.tsx index 65d73924a6ec..6cfbed6f0e6a 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/03a-ConnectDevice.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/03a-ConnectDevice.tsx @@ -65,6 +65,7 @@ export default function ConnectDevice({ ); const onResult = useCallback( + // @ts-expect-error should be AppResult but navigation.navigate does not agree payload => { if (!account) { return null; diff --git a/apps/ledger-live-mobile/src/screens/ReceiveFunds/ReceiveSecurityModal/index.tsx b/apps/ledger-live-mobile/src/screens/ReceiveFunds/ReceiveSecurityModal/index.tsx index 849e81ad19d3..0be78fee27fb 100644 --- a/apps/ledger-live-mobile/src/screens/ReceiveFunds/ReceiveSecurityModal/index.tsx +++ b/apps/ledger-live-mobile/src/screens/ReceiveFunds/ReceiveSecurityModal/index.tsx @@ -4,6 +4,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage"; import QueuedDrawer from "../../../components/QueuedDrawer"; import InitMessage from "./InitMessage"; import ConfirmUnverified from "./ConfirmUnverified"; +import { LayoutChangeEvent } from "react-native"; const shouldNotRemindUserAgainToVerifyAddressOnReceive = "shouldNotRemindUserAgainToVerifyAddressOnReceive"; @@ -45,7 +46,7 @@ const ReceiveSecurityModal = ({ const [step, setStep] = useState("initMessage"); const sharedHeight = useSharedValue(0); - const onLayout = useCallback(({ nativeEvent: { layout } }) => { + const onLayout = useCallback(({ nativeEvent: { layout } }: LayoutChangeEvent) => { sharedHeight.value = withTiming(layout.height, { duration: 200 }); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); diff --git a/apps/ledger-live-mobile/src/screens/RequestAccount/01-SelectCrypto.tsx b/apps/ledger-live-mobile/src/screens/RequestAccount/01-SelectCrypto.tsx index aa4aa545cfce..281f4b7135a5 100644 --- a/apps/ledger-live-mobile/src/screens/RequestAccount/01-SelectCrypto.tsx +++ b/apps/ledger-live-mobile/src/screens/RequestAccount/01-SelectCrypto.tsx @@ -1,6 +1,6 @@ import React, { useCallback } from "react"; import { Trans } from "react-i18next"; -import { StyleSheet, View, FlatList, SafeAreaView } from "react-native"; +import { StyleSheet, View, FlatList, SafeAreaView, ListRenderItem } from "react-native"; import type { CryptoOrTokenCurrency } from "@ledgerhq/types-cryptoassets"; import { useCurrenciesByMarketcap } from "@ledgerhq/live-common/currencies/index"; import { useTheme } from "@react-navigation/native"; @@ -46,12 +46,12 @@ export default function RequestAccountsSelectCrypto({ navigation, route }: Props }, [navigation, route.params], ); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item }) => , [onPressCurrency], ); const renderList = useCallback( - items => ( + (items: CryptoOrTokenCurrency[]) => ( ; renderFooter: React.ComponentType | React.ReactElement | null | undefined; }) => { @@ -112,7 +112,7 @@ function SelectAccount({ navigation, route }: Props) { [navigation, onSuccess], ); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item }) => , [onSelect], ); @@ -151,7 +151,9 @@ function SelectAccount({ navigation, route }: Props) { ); const renderList = useCallback( - items => , + (items: { account: AccountLike; subAccount?: SubAccount | null }[]) => ( + + ), [renderFooter, renderItem], ); diff --git a/apps/ledger-live-mobile/src/screens/SelectAccount.tsx b/apps/ledger-live-mobile/src/screens/SelectAccount.tsx index 320299ec67ef..0f9e6eebac54 100644 --- a/apps/ledger-live-mobile/src/screens/SelectAccount.tsx +++ b/apps/ledger-live-mobile/src/screens/SelectAccount.tsx @@ -11,6 +11,7 @@ import AccountSelector from "../components/AccountSelector"; import GenericErrorBottomModal from "../components/GenericErrorBottomModal"; import { SendFundsNavigatorStackParamList } from "../components/RootNavigator/types/SendFundsNavigator"; import { StackNavigatorProps } from "../components/RootNavigator/types/helpers"; +import { AccountLike } from "@ledgerhq/types-live"; type Props = StackNavigatorProps; @@ -55,7 +56,7 @@ export default function ReceiveFunds({ navigation, route }: Props) { : enhancedAccounts; const handleSelectAccount = useCallback( - account => { + (account: AccountLike) => { const balance = getAccountSpendableBalance(account); if (typeof minBalance !== "undefined" && !isNaN(minBalance) && balance.lte(minBalance)) { diff --git a/apps/ledger-live-mobile/src/screens/SelectDevice.tsx b/apps/ledger-live-mobile/src/screens/SelectDevice.tsx index 7b5cc4213204..2cf138a3a759 100644 --- a/apps/ledger-live-mobile/src/screens/SelectDevice.tsx +++ b/apps/ledger-live-mobile/src/screens/SelectDevice.tsx @@ -33,7 +33,7 @@ export default function SelectDevice({ const { colors } = useTheme(); const dispatchRedux = useReduxDispatch(); const onNavigate = useCallback( - device => { + (device: Device) => { // Assumes that it will always navigate to a "ConnectDevice" // type of component accepting mostly the same params as this one. navigation.navigate(route.name.replace("SelectDevice", "ConnectDevice"), { diff --git a/apps/ledger-live-mobile/src/screens/SendFunds/02-SelectRecipient.tsx b/apps/ledger-live-mobile/src/screens/SendFunds/02-SelectRecipient.tsx index 681dae848697..087827d2c5b1 100644 --- a/apps/ledger-live-mobile/src/screens/SendFunds/02-SelectRecipient.tsx +++ b/apps/ledger-live-mobile/src/screens/SendFunds/02-SelectRecipient.tsx @@ -103,7 +103,7 @@ export default function SendSelectRecipient({ navigation, route }: Props) { }); }, [navigation, transaction, route.params]); const onChangeText = useCallback( - recipient => { + (recipient: string) => { if (!account) return; const bridge = getAccountBridge(account, parentAccount); setTransaction( @@ -116,8 +116,6 @@ export default function SendSelectRecipient({ navigation, route }: Props) { [account, parentAccount, setTransaction, transaction, setValue], ); - // FIXME: PROP IS NOT USED. REMOVE ? - // const clear = useCallback(() => onChangeText(""), [onChangeText]); const [bridgeErr, setBridgeErr] = useState(bridgeError); useEffect(() => setBridgeErr(bridgeError), [bridgeError]); invariant(account, "account is needed "); diff --git a/apps/ledger-live-mobile/src/screens/SendFunds/03a-AmountCoin.tsx b/apps/ledger-live-mobile/src/screens/SendFunds/03a-AmountCoin.tsx index edbc5761955b..a5604fbb7fc8 100644 --- a/apps/ledger-live-mobile/src/screens/SendFunds/03a-AmountCoin.tsx +++ b/apps/ledger-live-mobile/src/screens/SendFunds/03a-AmountCoin.tsx @@ -74,7 +74,7 @@ export default function SendAmountCoin({ navigation, route }: Props) { }, [account, parentAccount, debouncedTransaction]); invariant(account, "account is needed"); const onChange = useCallback( - amount => { + (amount: BigNumber) => { if (!amount.isNaN()) { if (!account) return; const bridge = getAccountBridge(account, parentAccount); diff --git a/apps/ledger-live-mobile/src/screens/SendFunds/03b-AmountNft.tsx b/apps/ledger-live-mobile/src/screens/SendFunds/03b-AmountNft.tsx index c3f77856d71c..f87fc7d2726b 100644 --- a/apps/ledger-live-mobile/src/screens/SendFunds/03b-AmountNft.tsx +++ b/apps/ledger-live-mobile/src/screens/SendFunds/03b-AmountNft.tsx @@ -42,7 +42,7 @@ const SendAmountNFT = ({ route }: Props) => { invariant(transaction, "transaction required"); const onQuantityChange = useCallback( - text => { + (text: string) => { const newQuantity = new BigNumber(text.replace(/\D/g, "")); if (!bridge) return; diff --git a/apps/ledger-live-mobile/src/screens/Settings/Accounts/HiddenNftCollections.tsx b/apps/ledger-live-mobile/src/screens/Settings/Accounts/HiddenNftCollections.tsx index 8f40a795e188..63404a794663 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Accounts/HiddenNftCollections.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Accounts/HiddenNftCollections.tsx @@ -108,7 +108,7 @@ const HiddenNftCollections = () => { [dispatch], ); - const keyExtractor = useCallback(item => item, []); + const keyExtractor = useCallback((item: string) => item, []); return ( diff --git a/apps/ledger-live-mobile/src/screens/Settings/Accounts/index.tsx b/apps/ledger-live-mobile/src/screens/Settings/Accounts/index.tsx index 7847be12df3d..e5865c0fe29f 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Accounts/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Accounts/index.tsx @@ -65,7 +65,7 @@ export default function AccountsSettings({ [colors, dispatch], ); - const keyExtractor = useCallback(token => token.id, []); + const keyExtractor = useCallback((token: TokenCurrency) => token.id, []); const renderHeader = useCallback( () => ( diff --git a/apps/ledger-live-mobile/src/screens/Settings/CryptoAssets/Currencies/CurrenciesList.tsx b/apps/ledger-live-mobile/src/screens/Settings/CryptoAssets/Currencies/CurrenciesList.tsx index 6d174ceb3ed1..229a8b9a7dd6 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/CryptoAssets/Currencies/CurrenciesList.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/CryptoAssets/Currencies/CurrenciesList.tsx @@ -57,7 +57,7 @@ function CurrenciesList({ [navigation], ); - const keyExtractor = useCallback(item => item.id, []); + const keyExtractor = useCallback((item: CryptoCurrency) => item.id, []); return ( diff --git a/apps/ledger-live-mobile/src/screens/Settings/Debug/Configuration/DebugEnv.tsx b/apps/ledger-live-mobile/src/screens/Settings/Debug/Configuration/DebugEnv.tsx index 47592b9242dd..85259713a118 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Debug/Configuration/DebugEnv.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Debug/Configuration/DebugEnv.tsx @@ -53,7 +53,7 @@ export default function DebugEnv() { setResetIndex(resetIndex + 1); }, [value, resetIndex]); - const onPress = useCallback(env => { + const onPress = useCallback((env: string) => { Clipboard.setString(env); }, []); diff --git a/apps/ledger-live-mobile/src/screens/Settings/Debug/Connectivity/CommandSender.tsx b/apps/ledger-live-mobile/src/screens/Settings/Debug/Connectivity/CommandSender.tsx index 62f7bafb18d7..f7a80327629d 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Debug/Connectivity/CommandSender.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Debug/Connectivity/CommandSender.tsx @@ -40,7 +40,7 @@ const CommandSender = ({ route }: Props) => { const [running, setRunning] = useState(false); const onCommandSend = useCallback( - id => { + (id: keyof typeof commandsById) => { const { deviceId } = params; if (!deviceId) return; diff --git a/apps/ledger-live-mobile/src/screens/Settings/Debug/Debugging/Store.tsx b/apps/ledger-live-mobile/src/screens/Settings/Debug/Debugging/Store.tsx index f22d8158e7fd..414c8919930d 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Debug/Debugging/Store.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Debug/Debugging/Store.tsx @@ -38,7 +38,7 @@ export default function Store() { const dispatch = useDispatch(); const onEdit = useCallback( - (path, type) => { + (path: string, type: string) => { const currentValue = get(modifiedState, path); setTargetType(type); @@ -54,6 +54,7 @@ export default function Store() { ); const onChangeText = useCallback( + // @ts-expect-error string | number but it means casting in the function value => { const currentValue = get(state, targetPath); @@ -168,6 +169,7 @@ export default function Store() { + {/* @ts-expect-error onEdit gives (a: string, type?: string) => but our function needs type (and it seems always defined anyway) */} diff --git a/apps/ledger-live-mobile/src/screens/Settings/Debug/Features/Swap.tsx b/apps/ledger-live-mobile/src/screens/Settings/Debug/Features/Swap.tsx index 503496d47f10..3924b467b0e1 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Debug/Features/Swap.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Debug/Features/Swap.tsx @@ -11,7 +11,7 @@ export default function DebugSwap() { const currentDisabledProviders = useMemo(() => configWrapper.split(","), [configWrapper]); const onToggleProvider = useCallback( - provider => { + (provider: string) => { if (currentDisabledProviders.includes(provider)) { setConfigWrapper(currentDisabledProviders.filter(p => p !== provider).join(",")); } else { diff --git a/apps/ledger-live-mobile/src/screens/Settings/Debug/Generators/GenerateMockAccountsSelect.tsx b/apps/ledger-live-mobile/src/screens/Settings/Debug/Generators/GenerateMockAccountsSelect.tsx index 4c90e9bfff7f..b1e42c4992fa 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Debug/Generators/GenerateMockAccountsSelect.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Debug/Generators/GenerateMockAccountsSelect.tsx @@ -5,7 +5,7 @@ import { useNavigation } from "@react-navigation/native"; import { Alert as Confirm, ScrollView } from "react-native"; import { Button, Checkbox, Flex, Text, IconsLegacy, Alert } from "@ledgerhq/native-ui"; import { useSafeAreaInsets } from "react-native-safe-area-context"; -import { CryptoCurrency } from "@ledgerhq/types-cryptoassets"; +import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets"; import SettingsRow from "../../../../components/SettingsRow"; import accountModel from "../../../../logic/accountModel"; import { saveAccounts } from "../../../../db"; @@ -30,6 +30,8 @@ async function injectMockAccountsInDB(currencies: CryptoCurrency[], tokens: stri }); } +type ID = CryptoCurrencyId | "LBRY" | "groestcoin" | "osmo"; + const currencies = listSupportedCurrencies().sort((a, b) => a.name.localeCompare(b.name)); export const GenerateMockAccountSelectScreen = () => { @@ -39,7 +41,7 @@ export const GenerateMockAccountSelectScreen = () => { const [checkedCurrencies, setCheckedCurrencies] = useState({} as Record); const handleItemPressed = useCallback( - ({ id }) => { + ({ id }: { id: ID }) => { setCheckedCurrencies({ ...checkedCurrencies, [id]: !checkedCurrencies[id], diff --git a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx index 58edc3daf200..a91b067a99d9 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Developer/CustomManifest.tsx @@ -133,7 +133,7 @@ export default function CustomManifest({ navigation }: Props) { function useCustomManifest() { const [manifest, setManifest] = useState(""); const { addLocalManifest } = useLocalLiveAppContext(); - const onChange = useCallback(val => { + const onChange = useCallback((val: string) => { try { const json = JSON.parse(val); setManifest(JSON.stringify(json, null, 2)); diff --git a/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureFloat.tsx b/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureFloat.tsx index 90a29fe96274..ee06673a03ee 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureFloat.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureFloat.tsx @@ -29,6 +29,7 @@ const FeatureInteger = ({ const navigation = useNavigation(); const inputRef = useRef(null); const constraintValue = useCallback( + // @ts-expect-error supposed to be number | string but this means casting everywhere v => { let value = v; if (typeof maxValue === "number" && parseInt(value, 10) > maxValue) { @@ -81,7 +82,7 @@ const FeatureInteger = ({ }, [enabled, value, setInputValue, constraintValue]); const onInputChange = useCallback( - str => { + (str: string) => { if (!enabled) return; const sanitized = str.replace(/[^0-9.]/g, ""); if (sanitized.length > 0) { @@ -94,7 +95,7 @@ const FeatureInteger = ({ ); const onEnableChange = useCallback( - e => { + (e: boolean) => { setEnabled(!!e); if (e) { setTimeout(() => { diff --git a/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureInteger.tsx b/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureInteger.tsx index f67a141d1b7c..cb864237fb53 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureInteger.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Experimental/FeatureInteger.tsx @@ -29,6 +29,7 @@ const FeatureInteger = ({ const navigation = useNavigation(); const inputRef = useRef(null); const constraintValue = useCallback( + // @ts-expect-error supposed to be number | string but this means casting everywhere v => { let value = v; if (typeof maxValue === "number" && parseInt(value, 10) > maxValue) { @@ -81,7 +82,7 @@ const FeatureInteger = ({ }, [enabled, value, setInputValue, constraintValue]); const onInputChange = useCallback( - str => { + (str: string) => { if (!enabled) return; const sanitized = str.replace(/[^0-9]/g, ""); if (sanitized.length > 0) { @@ -94,7 +95,7 @@ const FeatureInteger = ({ ); const onEnableChange = useCallback( - e => { + (e: boolean) => { setEnabled(!!e); if (e) { setTimeout(() => { diff --git a/apps/ledger-live-mobile/src/screens/Settings/General/BiometricsRow.tsx b/apps/ledger-live-mobile/src/screens/Settings/General/BiometricsRow.tsx index 0dc7ffe8bb67..86923fe24194 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/General/BiometricsRow.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/General/BiometricsRow.tsx @@ -41,7 +41,7 @@ export default function BiometricsRow({ iconLeft }: Props) { }, [dispatch, biometricsEnabled]); const onError = useCallback( - error => { + (error?: Error) => { setValidationPending(false); setBiometricsEnabled((val: boolean) => !val); Alert.alert(t("auth.failed.title"), `${t("auth.failed.denied")}\n${String(error || "")}`); diff --git a/apps/ledger-live-mobile/src/screens/Settings/General/CarouselRow.tsx b/apps/ledger-live-mobile/src/screens/Settings/General/CarouselRow.tsx index 7643356c25bc..04dc17a17712 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/General/CarouselRow.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/General/CarouselRow.tsx @@ -14,7 +14,7 @@ const CarouselRow = () => { const dispatch = useDispatch(); const onSetDynamicCardsVisibility = useCallback( - checked => { + (checked: boolean) => { dispatch( setDismissedDynamicCards( checked ? [] : [...walletCards, ...assetsCards].map(card => card.id), diff --git a/apps/ledger-live-mobile/src/screens/SignTransaction/02-ConnectDevice.tsx b/apps/ledger-live-mobile/src/screens/SignTransaction/02-ConnectDevice.tsx index 54d0af30af7a..a8416f8aba7d 100644 --- a/apps/ledger-live-mobile/src/screens/SignTransaction/02-ConnectDevice.tsx +++ b/apps/ledger-live-mobile/src/screens/SignTransaction/02-ConnectDevice.tsx @@ -66,6 +66,7 @@ function ConnectDevice({ // @ts-expect-error Wrong types? request={request} device={route.params.device} + // @ts-expect-error onResult dissonance onResult={handleTx} onSelectDeviceLink={() => navigateToSelectDevice(navigation, route)} /> diff --git a/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/Confirmation.tsx b/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/Confirmation.tsx index 83a935f32adb..c13e7c0422a4 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/Confirmation.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/Confirmation.tsx @@ -14,7 +14,7 @@ import { import { SyncSkipUnderPriority } from "@ledgerhq/live-common/bridge/react/index"; import addToSwapHistory from "@ledgerhq/live-common/exchange/swap/addToSwapHistory"; import { addPendingOperation, getMainAccount } from "@ledgerhq/live-common/account/index"; -import { AccountLike, DeviceInfo, SignedOperation } from "@ledgerhq/types-live"; +import { AccountLike, DeviceInfo, Operation, SignedOperation } from "@ledgerhq/types-live"; import { Device } from "@ledgerhq/live-common/hw/actions/types"; import { postSwapAccepted, postSwapCancelled } from "@ledgerhq/live-common/exchange/swap/index"; import { getEnv } from "@ledgerhq/live-env"; @@ -91,7 +91,7 @@ export function Confirmation({ const navigation = useNavigation(); const onComplete = useCallback( - result => { + (result: { operation: Operation; swapId: string }) => { const { operation, swapId } = result; /** * If transaction broadcast are disabled, consider the swap as cancelled diff --git a/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/index.tsx b/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/index.tsx index ecc2a858b474..7b04505634a9 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/Form/Modal/index.tsx @@ -52,14 +52,14 @@ export function Modal({ }, [dispatch, provider]); const onError = useCallback( - ({ error, swapId }) => { + ({ error, swapId }: { error?: Error; swapId?: string }) => { track("error_message", { ...sharedSwapTracking, message: "drawer_error", page: "Page Swap Drawer", error: error?.name ?? "unknown", }); - if (!exchangeRate) { + if (!exchangeRate || !swapId) { return; } // Consider the swap as cancelled (on provider perspective) in case of error diff --git a/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx b/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx index 1baad9af3347..2c8a36544290 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/Form/index.tsx @@ -2,8 +2,12 @@ import React, { useState, useEffect, useCallback, useMemo } from "react"; import { useNavigation } from "@react-navigation/native"; import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view"; import { Button, Flex } from "@ledgerhq/native-ui"; -import { OnNoRatesCallback } from "@ledgerhq/live-common/exchange/swap/types"; -import { useSwapTransaction, usePageState } from "@ledgerhq/live-common/exchange/swap/hooks/index"; +import { ExchangeRate, OnNoRatesCallback } from "@ledgerhq/live-common/exchange/swap/types"; +import { + useSwapTransaction, + useSwapProviders, + usePageState, +} from "@ledgerhq/live-common/exchange/swap/hooks/index"; import { getCustomDappUrl } from "@ledgerhq/live-common/exchange/swap/utils/index"; import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; import { useDispatch, useSelector } from "react-redux"; @@ -58,7 +62,7 @@ export function SwapForm({ const [confirmed, setConfirmed] = useState(false); const setExchangeRate = useCallback( - rate => { + (rate?: ExchangeRate) => { dispatch(updateRateAction(rate)); }, [dispatch], diff --git a/apps/ledger-live-mobile/src/screens/Swap/SubScreens/SelectAccount.tsx b/apps/ledger-live-mobile/src/screens/Swap/SubScreens/SelectAccount.tsx index 62b2e14b7e35..f8f5cb7f7dc3 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/SubScreens/SelectAccount.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/SubScreens/SelectAccount.tsx @@ -134,7 +134,7 @@ export function SelectAccount({ navigation, route: { params } }: SelectAccountPa }, [navigation, params, selectableCurrencyIds, track]); const renderList = useCallback( - items => { + (items: typeof allAccounts) => { const formatedList = formatSearchResults(items, accounts); return ( ( + (items: (TokenCurrency | CryptoCurrency)[]) => ( { + (updatedTransaction: NonNullable) => { // @ts-expect-error navigation type is only partially declared navigation.navigate(ScreenName.SwapForm, { transaction: updatedTransaction, diff --git a/apps/ledger-live-mobile/src/screens/VerifyAccount/index.tsx b/apps/ledger-live-mobile/src/screens/VerifyAccount/index.tsx index 9c378de20cd1..b3cce32aa125 100644 --- a/apps/ledger-live-mobile/src/screens/VerifyAccount/index.tsx +++ b/apps/ledger-live-mobile/src/screens/VerifyAccount/index.tsx @@ -45,7 +45,7 @@ export default function VerifyAccount({ navigation, route }: NavigationProps) { navigation.pop(); }, [navigation]); const onConfirm = useCallback( - (confirmed, error) => { + (confirmed: boolean, error?: Error) => { if (confirmed) { onSuccess(account); } else if (error) { diff --git a/apps/ledger-live-mobile/src/screens/WalletCentricAsset/AccountsSection.tsx b/apps/ledger-live-mobile/src/screens/WalletCentricAsset/AccountsSection.tsx index ca0fa3b6f65d..c334370a8580 100644 --- a/apps/ledger-live-mobile/src/screens/WalletCentricAsset/AccountsSection.tsx +++ b/apps/ledger-live-mobile/src/screens/WalletCentricAsset/AccountsSection.tsx @@ -1,5 +1,5 @@ import React, { useCallback, useMemo } from "react"; -import { FlatList } from "react-native"; +import { FlatList, ListRenderItem } from "react-native"; import { useNavigation } from "@react-navigation/native"; import { Button } from "@ledgerhq/native-ui"; import { useTranslation } from "react-i18next"; @@ -30,7 +30,7 @@ const AccountsSection = ({ accounts, currencyId, currencyTicker }: ListProps) => [accounts], ); - const renderItem = useCallback( + const renderItem: ListRenderItem = useCallback( ({ item, index }) => ( { filterTokenOperationsZeroAmountEnabledSelector, ); const filterOperation = useCallback( - (operation, account) => { + (operation: Operation, account: AccountLike) => { // Remove operations linked to address poisoning const removeZeroAmountTokenOp = shouldFilterTokenOpsZeroAmount && isAddressPoisoningOperation(operation, account); diff --git a/libs/domain-service/package.json b/libs/domain-service/package.json index 74d213119761..7db5f619c38a 100644 --- a/libs/domain-service/package.json +++ b/libs/domain-service/package.json @@ -84,7 +84,7 @@ "eslint-plugin-jest": "^27.2.1", "jest": "^28.1.3", "jest-environment-jsdom": "^28.1.3", - "react-test-renderer": "^17.0.2", + "react-test-renderer": "^18.2.0", "ts-jest": "^28.0.8" } } diff --git a/libs/ledger-live-common/package.json b/libs/ledger-live-common/package.json index 6a6daab40bc9..810d8941f74b 100644 --- a/libs/ledger-live-common/package.json +++ b/libs/ledger-live-common/package.json @@ -294,7 +294,7 @@ "react-native": "0.71.6", "react-native-svg": "13.4.0", "react-redux": "^7.2.9", - "react-test-renderer": "^17.0.2", + "react-test-renderer": "^18.2.0", "redux-actions": "2.6.5", "timemachine": "^0.3.2", "ts-jest": "^28.0.5", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe38c529126b..57c09c820879 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -528,7 +528,7 @@ importers: version: 12.1.5(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0) '@testing-library/react-hooks': specifier: ^8.0.0 - version: 8.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react-test-renderer@17.0.2)(react@18.2.0) + version: 8.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react-test-renderer@18.2.0)(react@18.2.0) '@testing-library/user-event': specifier: ^14.4.3 version: 14.4.3(@testing-library/dom@9.3.1) @@ -680,8 +680,8 @@ importers: specifier: ^0.14.0 version: 0.14.0 react-test-renderer: - specifier: ^17.0.2 - version: 17.0.2(react@18.2.0) + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) serve-handler: specifier: ^6.1.3 version: 6.1.3 @@ -1144,10 +1144,10 @@ importers: version: 2.5.2 '@testing-library/jest-native': specifier: ^5.4.2 - version: 5.4.2(react-native@0.71.6)(react-test-renderer@18.0.0)(react@18.2.0) + version: 5.4.2(react-native@0.71.6)(react-test-renderer@18.2.0)(react@18.2.0) '@testing-library/react-native': specifier: ^12.1.0 - version: 12.1.0(jest@28.1.3)(react-native@0.71.6)(react-test-renderer@18.0.0)(react@18.2.0) + version: 12.1.0(jest@28.1.3)(react-native@0.71.6)(react-test-renderer@18.2.0)(react@18.2.0) '@types/color': specifier: ^3.0.3 version: 3.0.3 @@ -1308,8 +1308,8 @@ importers: specifier: ^3.0.0 version: 3.0.0(react-native-flipper@0.164.0)(react-native-performance@3.1.2) react-test-renderer: - specifier: ^18 - version: 18.0.0(react@18.2.0) + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) strip-ansi: specifier: 6.0.1 version: 6.0.1 @@ -1847,7 +1847,7 @@ importers: version: 12.1.5(react-dom@18.2.0)(react@18.2.0) '@testing-library/react-hooks': specifier: ^8.0.0 - version: 8.0.1(react-dom@18.2.0)(react-test-renderer@17.0.2)(react@18.2.0) + version: 8.0.1(react-dom@18.2.0)(react-test-renderer@18.2.0)(react@18.2.0) '@types/jest': specifier: ^28.1.3 version: 28.1.8 @@ -1870,8 +1870,8 @@ importers: specifier: ^28.1.3 version: 28.1.3 react-test-renderer: - specifier: ^17.0.2 - version: 17.0.2(react@18.2.0) + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) ts-jest: specifier: ^28.0.8 version: 28.0.8(jest@28.1.3)(typescript@5.1.3) @@ -2393,7 +2393,7 @@ importers: version: 12.1.5(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0) '@testing-library/react-hooks': specifier: ^8.0.0 - version: 8.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react-test-renderer@17.0.2)(react@18.2.0) + version: 8.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react-test-renderer@18.2.0)(react@18.2.0) '@types/bn.js': specifier: ^5.1.1 version: 5.1.1 @@ -2482,8 +2482,8 @@ importers: specifier: ^7.2.9 version: 7.2.9(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0) react-test-renderer: - specifier: ^17.0.2 - version: 17.0.2(react@18.2.0) + specifier: ^18.2.0 + version: 18.2.0(react@18.2.0) redux-actions: specifier: 2.6.5 version: 2.6.5 @@ -11353,7 +11353,7 @@ packages: '@celo/connect': 3.0.1 '@celo/utils': 3.0.1 '@celo/wallet-base': 3.0.1 - '@types/debug': 4.1.9 + '@types/debug': 4.1.7 '@types/ethereumjs-util': 5.2.0 eth-lib: 0.2.8 ethereumjs-util: 5.2.1 @@ -18347,9 +18347,24 @@ packages: resolution: {integrity: sha512-C16M+IYz0rgRhWZdCmK+h58JMv8vijAA61gmz2rspCSwKwzBebpdcsiUmwrtJRdphuY30i6BSLEOP8ppbNLyLg==} dev: false - /@polkadot/keyring@10.4.2: + /@polkadot/keyring@10.4.2(@polkadot/util-crypto@10.3.1)(@polkadot/util@10.3.1): + resolution: {integrity: sha512-7iHhJuXaHrRTG6cJDbZE9G+c1ts1dujp0qbO4RfAPmT7YUvphHvAtCKueN9UKPz5+TYDL+rP/jDEaSKU8jl/qQ==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@polkadot/util': 10.4.2 + '@polkadot/util-crypto': 10.4.2 + dependencies: + '@babel/runtime': 7.22.10 + '@polkadot/util': 10.3.1 + '@polkadot/util-crypto': 10.3.1(@polkadot/util@10.3.1) + dev: false + + /@polkadot/keyring@10.4.2(@polkadot/util-crypto@10.4.2)(@polkadot/util@10.4.2): resolution: {integrity: sha512-7iHhJuXaHrRTG6cJDbZE9G+c1ts1dujp0qbO4RfAPmT7YUvphHvAtCKueN9UKPz5+TYDL+rP/jDEaSKU8jl/qQ==} engines: {node: '>=14.0.0'} + peerDependencies: + '@polkadot/util': 10.4.2 + '@polkadot/util-crypto': 10.4.2 dependencies: '@babel/runtime': 7.22.10 '@polkadot/util': 10.4.2 @@ -18383,7 +18398,7 @@ packages: styled-components: '*' dependencies: '@babel/runtime': 7.20.13 - '@polkadot/keyring': 10.4.2 + '@polkadot/keyring': 10.4.2(@polkadot/util-crypto@10.4.2)(@polkadot/util@10.4.2) '@polkadot/ui-settings': 2.11.3 '@polkadot/ui-shared': 2.11.3(@polkadot/util-crypto@10.4.2)(@polkadot/util@10.4.2) '@polkadot/util': 10.4.2 @@ -18458,7 +18473,7 @@ packages: engines: {node: '>=14.0.0'} dependencies: '@babel/runtime': 7.20.13 - '@polkadot/keyring': 10.4.2 + '@polkadot/keyring': 10.4.2(@polkadot/util-crypto@10.3.1)(@polkadot/util@10.3.1) '@polkadot/types-augment': 9.8.2 '@polkadot/types-codec': 9.8.2 '@polkadot/types-create': 9.8.2 @@ -24531,7 +24546,7 @@ packages: redent: 3.0.0 dev: true - /@testing-library/jest-native@5.4.2(react-native@0.71.6)(react-test-renderer@18.0.0)(react@18.2.0): + /@testing-library/jest-native@5.4.2(react-native@0.71.6)(react-test-renderer@18.2.0)(react@18.2.0): resolution: {integrity: sha512-Vo/CE1uvCVH1H8YPoOEXLXVsm+BjzSQTq35+wkri1fr0O5D+A2WZ+m3ni5g6f1OCzNKNGIAHmisBEWkDs1P1mw==} peerDependencies: react: '>=16.0.0' @@ -24544,11 +24559,11 @@ packages: pretty-format: 29.5.0 react: 18.2.0 react-native: 0.71.6(@babel/core@7.22.8)(metro-resolver@0.76.0)(metro-transform-worker@0.76.0)(react@18.2.0) - react-test-renderer: 18.0.0(react@18.2.0) + react-test-renderer: 18.2.0(react@18.2.0) redent: 3.0.0 dev: true - /@testing-library/react-hooks@8.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react-test-renderer@17.0.2)(react@18.2.0): + /@testing-library/react-hooks@8.0.1(@types/react@18.2.23)(react-dom@18.2.0)(react-test-renderer@18.2.0)(react@18.2.0): resolution: {integrity: sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==} engines: {node: '>=12'} peerDependencies: @@ -24569,10 +24584,10 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-error-boundary: 3.1.4(react@18.2.0) - react-test-renderer: 17.0.2(react@18.2.0) + react-test-renderer: 18.2.0(react@18.2.0) dev: true - /@testing-library/react-hooks@8.0.1(react-dom@18.2.0)(react-test-renderer@17.0.2)(react@18.2.0): + /@testing-library/react-hooks@8.0.1(react-dom@18.2.0)(react-test-renderer@18.2.0)(react@18.2.0): resolution: {integrity: sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==} engines: {node: '>=12'} peerDependencies: @@ -24592,10 +24607,10 @@ packages: react: 18.2.0 react-dom: 18.2.0(react@18.2.0) react-error-boundary: 3.1.4(react@18.2.0) - react-test-renderer: 17.0.2(react@18.2.0) + react-test-renderer: 18.2.0(react@18.2.0) dev: true - /@testing-library/react-native@12.1.0(jest@28.1.3)(react-native@0.71.6)(react-test-renderer@18.0.0)(react@18.2.0): + /@testing-library/react-native@12.1.0(jest@28.1.3)(react-native@0.71.6)(react-test-renderer@18.2.0)(react@18.2.0): resolution: {integrity: sha512-jfx5OPOSRdqpJROvnxMZFFMXfmN8xDp8cEDN7DWQcpwjEWuGMRK1uEe+0JX+DqousrG2v1ViaNWJLWFm9761Tw==} peerDependencies: jest: '>=28.0.0' @@ -24613,7 +24628,7 @@ packages: react-native: 0.71.6(@babel/core@7.22.8)(metro-resolver@0.76.0)(metro-transform-worker@0.76.0)(react@18.2.0) react-native-safe-area-context: 4.6.3(react-native@0.71.6)(react@18.2.0) react-native-screens: 3.20.0(react-native@0.71.6)(react@18.2.0) - react-test-renderer: 18.0.0(react@18.2.0) + react-test-renderer: 18.2.0(react@18.2.0) dev: true /@testing-library/react@12.1.5(@types/react@18.2.23)(react-dom@18.2.0)(react@18.2.0): @@ -29066,7 +29081,7 @@ packages: babel-plugin-syntax-jsx: 6.18.0 lodash: 4.17.21 picomatch: 2.3.1 - styled-components: 5.3.5(react-dom@18.2.0)(react-is@17.0.2)(react@18.2.0) + styled-components: 5.3.5(react-is@18.1.0)(react@18.2.0) /babel-plugin-syntax-jsx@6.18.0: resolution: {integrity: sha512-qrPaCSo9c8RHNRHIotaufGbuOBN8rtdC4QrrFFc43vyWCCz7Kl7GL1PGaXtMGQZUXrkCjNEgxDfmAuAabr/rlw==} @@ -41153,7 +41168,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41182,7 +41197,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41211,7 +41226,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41240,7 +41255,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41269,7 +41284,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41298,7 +41313,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41327,7 +41342,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -41356,7 +41371,7 @@ packages: jest-util: 28.1.3 jest-validate: 28.1.3 prompts: 2.4.2 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - '@types/node' - metro @@ -46622,7 +46637,7 @@ packages: debug: 2.6.9 node-fetch: 2.6.9 ws: 7.5.7 - yargs: 17.7.2 + yargs: 17.5.1 transitivePeerDependencies: - bufferutil - encoding @@ -54073,27 +54088,15 @@ packages: - '@types/react' dev: false - /react-test-renderer@17.0.2(react@18.2.0): - resolution: {integrity: sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==} - peerDependencies: - react: 17.0.2 - dependencies: - object-assign: 4.1.1 - react: 18.2.0 - react-is: 17.0.2 - react-shallow-renderer: 16.15.0(react@18.2.0) - scheduler: 0.20.2 - dev: true - - /react-test-renderer@18.0.0(react@18.2.0): - resolution: {integrity: sha512-SyZTP/FSkwfiKOZuTZiISzsrC8A80KNlQ8PyyoGoOq+VzMAab6Em1POK/CiX3+XyXG6oiJa1C53zYDbdrJu9fw==} + /react-test-renderer@18.2.0(react@18.2.0): + resolution: {integrity: sha512-JWD+aQ0lh2gvh4NM3bBM42Kx+XybOxCpgYK7F8ugAlpaTSnWsX+39Z4XkOykGZAHrjwwTZT3x3KxswVWxHPUqA==} peerDependencies: - react: ^18.0.0 + react: ^18.2.0 dependencies: react: 18.2.0 - react-is: 18.1.0 + react-is: 18.2.0 react-shallow-renderer: 16.15.0(react@18.2.0) - scheduler: 0.21.0 + scheduler: 0.23.0 dev: true /react-textarea-autosize@8.3.3(@types/react@18.2.23)(react@18.2.0): @@ -55470,19 +55473,6 @@ packages: xmlchars: 2.2.0 dev: true - /scheduler@0.20.2: - resolution: {integrity: sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==} - dependencies: - loose-envify: 1.4.0 - object-assign: 4.1.1 - dev: true - - /scheduler@0.21.0: - resolution: {integrity: sha512-1r87x5fz9MXqswA2ERLo0EbOAU74DpIUO090gIasYTqlVoJeMcl+Z1Rg7WHz+qtPujhS/hGIt9kxZOYBV3faRQ==} - dependencies: - loose-envify: 1.4.0 - dev: true - /scheduler@0.23.0: resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} dependencies: @@ -55952,7 +55942,7 @@ packages: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.2.1 + get-intrinsic: 1.2.0 object-inspect: 1.12.3 /signal-exit@3.0.7: @@ -57142,7 +57132,6 @@ packages: react-is: 18.1.0 shallowequal: 1.1.0 supports-color: 5.5.0 - dev: false /styled-components@6.0.7(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-xIwWuiRMYR43mskVsW9MGTRjSo7ol4bcVjT595fGUp3OLBJOlOgaiKaxsHdC4a2HqWKqKnh0CmcRbk5ogyDjTg==}