diff --git a/.eslintrc b/.eslintrc index 091ca82db0..3e7737373a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -52,7 +52,8 @@ "@typescript-eslint/indent": "off", "react/prop-types": "off", "react/jsx-uses-react": "off", - "react/react-in-jsx-scope": "off" + "react/react-in-jsx-scope": "off", + "@typescript-eslint/no-floating-promises": "off" }, "excludedFiles": [ "*.test.ts", diff --git a/mobile-app/app/components/OceanInterface/OceanInterface.tsx b/mobile-app/app/components/OceanInterface/OceanInterface.tsx index 9d034a6dc7..eac0919a9a 100644 --- a/mobile-app/app/components/OceanInterface/OceanInterface.tsx +++ b/mobile-app/app/components/OceanInterface/OceanInterface.tsx @@ -12,11 +12,12 @@ import { tailwind } from '@tailwind' import { translate } from '@translations' import { useCallback, useEffect, useRef, useState } from 'react' import { Animated } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { NativeLoggingProps, useLogger } from '@shared-contexts/NativeLoggingProvider' import { TransactionDetail } from './TransactionDetail' import { TransactionError } from './TransactionError' import { getReleaseChannel } from '@api/releaseChannel' +import { useAppDispatch } from '@hooks/useAppDispatch' const MAX_AUTO_RETRY = 1 const MAX_TIMEOUT = 300000 @@ -72,7 +73,7 @@ async function waitForTxConfirmation (id: string, client: WhaleApiClient, logger * */ export function OceanInterface (): JSX.Element | null { const logger = useLogger() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const { wallet, address } = useWalletContext() const { getTransactionUrl } = useDeFiScanContext() diff --git a/mobile-app/app/contexts/FeatureFlagContext.tsx b/mobile-app/app/contexts/FeatureFlagContext.tsx index 36a6047975..a0f6933522 100644 --- a/mobile-app/app/contexts/FeatureFlagContext.tsx +++ b/mobile-app/app/contexts/FeatureFlagContext.tsx @@ -41,14 +41,16 @@ export function FeatureFlagProvider (props: React.PropsWithChildren): JSX.E const { network } = useNetworkContext() const [retries, setRetries] = useState(0) - if (isError && retries < MAX_RETRY) { - setTimeout(() => { + useEffect(() => { + if (isError && retries < MAX_RETRY) { + setTimeout(() => { + prefetchPage({}) + setRetries(retries + 1) + }, 10000) + } else if (!isError) { prefetchPage({}) - setRetries(retries + 1) - }, 10000) - } else if (!isError) { - prefetchPage({}) - } + } + }, [isError]) function isBetaFeature (featureId: FEATURE_FLAG_ID): boolean { return featureFlags.some((flag: FeatureFlag) => satisfies(appVersion, flag.version) && diff --git a/mobile-app/app/hooks/useAddressBook.ts b/mobile-app/app/hooks/useAddressBook.ts index eb6df209bf..b9fa83700b 100644 --- a/mobile-app/app/hooks/useAddressBook.ts +++ b/mobile-app/app/hooks/useAddressBook.ts @@ -1,7 +1,8 @@ import { useNetworkContext } from '@shared-contexts/NetworkContext' -import { RootState, useAppDispatch } from '@store' +import { RootState } from '@store' import { setAddressBook, setUserPreferences } from '@store/userPreferences' import { useSelector } from 'react-redux' +import { useAppDispatch } from '@hooks/useAppDispatch' export function useAddressBook (): { clearAddressBook: () => void diff --git a/mobile-app/app/hooks/useAppDispatch.tsx b/mobile-app/app/hooks/useAppDispatch.tsx new file mode 100644 index 0000000000..aa61c434c3 --- /dev/null +++ b/mobile-app/app/hooks/useAppDispatch.tsx @@ -0,0 +1,6 @@ +import { useDispatch } from 'react-redux' +import { RootStore } from '@store' + +export type AppDispatch = RootStore['dispatch'] +/* eslint-disable */ +export const useAppDispatch = () => useDispatch() diff --git a/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BidHistory.tsx b/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BidHistory.tsx index 4cf72b576b..ebd19acf53 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BidHistory.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BidHistory.tsx @@ -1,6 +1,7 @@ import { View } from '@components' import { ThemedFlatList, ThemedIcon, ThemedText, ThemedView } from '@components/themed' import { VaultAuctionBatchHistory } from '@defichain/whale-api-client/dist/api/loan' +import { useAppDispatch } from '@hooks/useAppDispatch' import { useIsFocused } from '@react-navigation/native' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { RootState } from '@store' @@ -11,7 +12,7 @@ import BigNumber from 'bignumber.js' import { useEffect } from 'react' import { Platform } from 'react-native' import NumberFormat from 'react-number-format' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { useTokenPrice } from '../../Balances/hooks/TokenPrice' import { ActiveUSDValue } from '../../Loans/VaultDetail/components/ActiveUSDValue' import { useBidTimeAgo } from '../hooks/BidTimeAgo' @@ -27,7 +28,7 @@ interface BidHistoryProps { export function BidHistory (props: BidHistoryProps): JSX.Element { const client = useWhaleApiClient() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const blockCount = useSelector((state: RootState) => state.block.count) ?? 0 const bidHistory = useSelector((state: RootState) => state.auctions.bidHistory) const { getTokenPrice } = useTokenPrice() diff --git a/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BrowseAuctions.tsx b/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BrowseAuctions.tsx index c5796aa751..fdf54fe8f4 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BrowseAuctions.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Auctions/components/BrowseAuctions.tsx @@ -4,7 +4,7 @@ import { tailwind } from '@tailwind' import { ThemedFlatList, ThemedScrollView } from '@components/themed' import { BatchCard } from '@screens/AppNavigator/screens/Auctions/components/BatchCard' import { Platform, View } from 'react-native' -import { useDispatch, useSelector, batch } from 'react-redux' +import { useSelector, batch } from 'react-redux' import { RootState } from '@store' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { SkeletonLoader, SkeletonLoaderScreen } from '@components/SkeletonLoader' @@ -18,6 +18,7 @@ import { QuickBid } from './QuickBid' import { useDebounce } from '@hooks/useDebounce' import { fetchVaults, LoanVault, vaultsSelector } from '@store/loans' import { useWalletContext } from '@shared-contexts/WalletContext' +import { useAppDispatch } from '@hooks/useAppDispatch' import { tokensSelector } from '@store/wallet' interface Props { @@ -33,7 +34,7 @@ export interface onQuickBidProps { } export function BrowseAuctions ({ searchString }: Props): JSX.Element { - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const { address } = useWalletContext() const tokens = useSelector((state: RootState) => tokensSelector(state.wallet)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Auctions/components/ManageBids.tsx b/mobile-app/app/screens/AppNavigator/screens/Auctions/components/ManageBids.tsx index 8e914979a1..16eb84be3e 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Auctions/components/ManageBids.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Auctions/components/ManageBids.tsx @@ -4,7 +4,7 @@ import { useFeatureFlagContext } from '@contexts/FeatureFlagContext' import { View } from 'react-native' import { InfoText } from '@components/InfoText' import { translate } from '@translations' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { useEffect } from 'react' import { fetchVaults } from '@store/loans' @@ -14,9 +14,10 @@ import { LoanVaultLiquidated, LoanVaultLiquidationBatch } from '@defichain/whale import { BidCard } from './BidCard' import { EmptyBidsScreen } from './EmptyBidsScreen' import { useIsFocused } from '@react-navigation/native' +import { useAppDispatch } from '@hooks/useAppDispatch' export function ManageBids (): JSX.Element { - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const { address } = useWalletContext() const blockCount = useSelector((state: RootState) => state.block.count) diff --git a/mobile-app/app/screens/AppNavigator/screens/Auctions/hooks/SignBidAndSend.tsx b/mobile-app/app/screens/AppNavigator/screens/Auctions/hooks/SignBidAndSend.tsx index 08d34ff622..03d4eed38a 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Auctions/hooks/SignBidAndSend.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Auctions/hooks/SignBidAndSend.tsx @@ -3,9 +3,10 @@ import { CTransactionSegWit, PlaceAuctionBid } from '@defichain/jellyfish-transa import { WhaleWalletAccount } from '@defichain/whale-api-wallet' import { useLogger } from '@shared-contexts/NativeLoggingProvider' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { firstTransactionSelector, hasTxQueued as hasBroadcastQueued, OceanTransaction } from '@store/ocean' +import { useAppDispatch } from '@hooks/useAppDispatch' interface ConstructSignedBidAndSendProps { vaultId: PlaceAuctionBid['vaultId'] @@ -21,7 +22,7 @@ export const useSignBidAndSend = (): { currentBroadcastJob: OceanTransaction constructSignedBidAndSend: (props: ConstructSignedBidAndSendProps) => Promise } => { - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/AuctionDetailScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/AuctionDetailScreen.tsx index 5010f6baff..9883cfb182 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/AuctionDetailScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/AuctionDetailScreen.tsx @@ -4,7 +4,7 @@ import { tailwind } from '@tailwind' import { Platform, TouchableOpacity, View } from 'react-native' import { translate } from '@translations' import { getNativeIcon } from '@components/icons/assets' -import { useSelector, useDispatch } from 'react-redux' +import { useSelector } from 'react-redux' import { NavigationProp, useNavigation, useIsFocused } from '@react-navigation/native' import { RootState } from '@store' import { useBottomSheet } from '@hooks/useBottomSheet' @@ -31,6 +31,7 @@ import { BidHistory } from '../components/BidHistory' import { MinNextBidTextRow } from '../components/MinNextBidTextRow' import { LoanVaultLiquidationBatch } from '@defichain/whale-api-client/dist/api/loan' import { fetchAuctions } from '@store/auctions' +import { useAppDispatch } from '@hooks/useAppDispatch' type BatchDetailScreenProps = StackScreenProps @@ -45,7 +46,7 @@ export function AuctionDetailScreen (props: BatchDetailScreenProps): JSX.Element const { batch: batchFromParam, vault } = props.route.params const [batch, setBatch] = useState(batchFromParam) const client = useWhaleApiClient() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const tokens = useSelector((state: RootState) => tokensSelector(state.wallet)) const { getAuctionsUrl } = useDeFiScanContext() const [activeTab, setActiveTab] = useState(TabKey.BidHistory) diff --git a/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/ConfirmPlaceBidScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/ConfirmPlaceBidScreen.tsx index 9b402db854..e163790c47 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/ConfirmPlaceBidScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Auctions/screens/ConfirmPlaceBidScreen.tsx @@ -1,5 +1,5 @@ import { Dispatch, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { NavigationProp, useNavigation } from '@react-navigation/native' import { StackScreenProps } from '@react-navigation/stack' import { tailwind } from '@tailwind' @@ -18,12 +18,13 @@ import { InfoRow, InfoType } from '@components/InfoRow' import { ThemedScrollView, ThemedSectionTitle } from '@components/themed' import { AuctionsParamList } from '../AuctionNavigator' import { WalletAddressRow } from '@components/WalletAddressRow' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps export function ConfirmPlaceBidScreen (props: Props): JSX.Element { const navigation = useNavigation>() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/BalancesScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/BalancesScreen.tsx index 3c609cbd9b..d027848ce3 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/BalancesScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/BalancesScreen.tsx @@ -11,7 +11,7 @@ import { dexPricesSelectorByDenomination, fetchDexPrice, fetchTokens, tokensSele import { tailwind } from '@tailwind' import BigNumber from 'bignumber.js' import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react' -import { batch, useDispatch, useSelector } from 'react-redux' +import { batch, useSelector } from 'react-redux' import { BalanceParamList } from './BalancesNavigator' import { Announcements } from '@screens/AppNavigator/screens/Balances/components/Announcements' import { DFIBalanceCard } from '@screens/AppNavigator/screens/Balances/components/DFIBalanceCard' @@ -35,6 +35,7 @@ import { SkeletonLoader, SkeletonLoaderScreen } from '@components/SkeletonLoader import { LoanVaultActive } from '@defichain/whale-api-client/dist/api/loan' import { fetchExecutionBlock, fetchFutureSwaps, hasFutureSwap } from '@store/futureSwap' import { useDenominationCurrency } from './hooks/PortfolioCurrency' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -67,7 +68,7 @@ export function BalancesScreen ({ navigation }: Props): JSX.Element { const blockCount = useSelector((state: RootState) => state.block.count) const vaults = useSelector((state: RootState) => activeVaultsSelector(state.loans)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const [refreshing, setRefreshing] = useState(false) const [isZeroBalance, setIsZeroBalance] = useState(true) const hasPendingFutureSwap = useSelector((state: RootState) => hasFutureSwap(state.futureSwaps)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/components/AddressControlScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/components/AddressControlScreen.tsx index fc8114ab55..8e68c2d91b 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/components/AddressControlScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/components/AddressControlScreen.tsx @@ -10,12 +10,13 @@ import { BalanceParamList } from '../BalancesNavigator' import { useLogger } from '@shared-contexts/NativeLoggingProvider' import { RandomAvatar } from '@screens/AppNavigator/screens/Balances/components/RandomAvatar' import { SkeletonLoader, SkeletonLoaderScreen } from '@components/SkeletonLoader' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' import { wallet as walletReducer } from '@store/wallet' import { loans } from '@store/loans' +import { useAppDispatch } from '@hooks/useAppDispatch' export function AddressControlScreen (): JSX.Element { const navigation = useNavigation>() @@ -84,7 +85,7 @@ export function AddressControlCard ({ onClose }: { onClose: () => void }): JSX.E const [availableAddresses, setAvailableAddresses] = useState([]) const [canCreateAddress, setCanCreateAddress] = useState(false) const blockCount = useSelector((state: RootState) => state.block.count) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const fetchAddresses = async (): Promise => { diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressBook.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressBook.tsx index fa845334fc..3a3f5f1ea3 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressBook.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressBook.tsx @@ -8,13 +8,14 @@ import { RandomAvatar } from './RandomAvatar' import { BottomSheetFlatList } from '@gorhom/bottom-sheet' import { useThemeContext } from '@shared-contexts/ThemeProvider' import { useSelector } from 'react-redux' -import { RootState, useAppDispatch } from '@store' +import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' import { NavigationProp, useNavigation } from '@react-navigation/native' import { BottomSheetWithNavRouteParam } from '@components/BottomSheetWithNav' import { LabeledAddress, setAddressBook, setUserPreferences } from '@store/userPreferences' import { useNetworkContext } from '@shared-contexts/NetworkContext' +import { useAppDispatch } from '@hooks/useAppDispatch' interface BottomSheetAddressBookProps { address: string diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressDetail.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressDetail.tsx index 028463365b..61c75e4e81 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressDetail.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/components/BottomSheetAddressDetail.tsx @@ -18,7 +18,7 @@ import { useThemeContext } from '@shared-contexts/ThemeProvider' import { wallet as walletReducer } from '@store/wallet' import { useSelector } from 'react-redux' import { loans } from '@store/loans' -import { RootState, useAppDispatch } from '@store' +import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' import { NavigationProp, useNavigation } from '@react-navigation/native' @@ -28,6 +28,7 @@ import { useNetworkContext } from '@shared-contexts/NetworkContext' import { useAddressLabel } from '@hooks/useAddressLabel' import { useFeatureFlagContext } from '@contexts/FeatureFlagContext' import { AddressListEditButton } from './AddressListEditButton' +import { useAppDispatch } from '@hooks/useAppDispatch' interface BottomSheetAddressDetailProps { address: string diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/components/CreateOrEditAddressLabelForm.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/components/CreateOrEditAddressLabelForm.tsx index 7e8bd2244c..651b3554b6 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/components/CreateOrEditAddressLabelForm.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/components/CreateOrEditAddressLabelForm.tsx @@ -13,12 +13,13 @@ import { SubmitButtonGroup } from '@components/SubmitButtonGroup' import { LabeledAddress, LocalAddress } from '@store/userPreferences' import { fromAddress } from '@defichain/jellyfish-address' import { useNetworkContext } from '@shared-contexts/NetworkContext' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { authentication, Authentication } from '@store/authentication' import { MnemonicStorage } from '@api/wallet/mnemonic_storage' import { useWalletNodeContext } from '@shared-contexts/WalletNodeProvider' import { useLogger } from '@shared-contexts/NativeLoggingProvider' +import { useAppDispatch } from '@hooks/useAppDispatch' export interface CreateOrEditAddressLabelFormProps { title: string @@ -102,7 +103,7 @@ export const CreateOrEditAddressLabelForm = memo(({ route, navigation }: Props): } // Passcode prompt on create - const dispatch = useDispatch() + const dispatch = useAppDispatch() const { data: { type: encryptionType } } = useWalletNodeContext() const isEncrypted = encryptionType === 'MNEMONIC_ENCRYPTED' const logger = useLogger() diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddOrEditAddressBookScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddOrEditAddressBookScreen.tsx index 51e449cdc6..d3b4f84626 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddOrEditAddressBookScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddOrEditAddressBookScreen.tsx @@ -5,6 +5,7 @@ import { SubmitButtonGroup } from '@components/SubmitButtonGroup' import { ThemedIcon, ThemedText, ThemedTouchableOpacity, ThemedView } from '@components/themed' import { WalletTextInput } from '@components/WalletTextInput' import { fromAddress } from '@defichain/jellyfish-address' +import { useAppDispatch } from '@hooks/useAppDispatch' import { StackScreenProps } from '@react-navigation/stack' import { useLogger } from '@shared-contexts/NativeLoggingProvider' import { useNetworkContext } from '@shared-contexts/NetworkContext' @@ -14,7 +15,7 @@ import { authentication, Authentication } from '@store/authentication' import { tailwind } from '@tailwind' import { translate } from '@translations' import { useEffect, useLayoutEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { BalanceParamList } from '../BalancesNavigator' type Props = StackScreenProps @@ -85,7 +86,7 @@ export function AddOrEditAddressBookScreen ({ route, navigation }: Props): JSX.E } // Passcode prompt - const dispatch = useDispatch() + const dispatch = useAppDispatch() const { data: { type: encryptionType } } = useWalletNodeContext() const isEncrypted = encryptionType === 'MNEMONIC_ENCRYPTED' const logger = useLogger() diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddressBookScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddressBookScreen.tsx index 56b2745e5e..d29a44480b 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddressBookScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/AddressBookScreen.tsx @@ -1,7 +1,7 @@ import { View } from '@components' import { ThemedFlatList, ThemedIcon, ThemedText, ThemedTouchableOpacity, ThemedView } from '@components/themed' import { StackScreenProps } from '@react-navigation/stack' -import { RootState, useAppDispatch } from '@store' +import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' import { LabeledAddress, setAddressBook, setUserPreferences } from '@store/userPreferences' @@ -26,6 +26,7 @@ import { HeaderSearchInput } from '@components/HeaderSearchInput' import { useDeFiScanContext } from '@shared-contexts/DeFiScanContext' import { debounce } from 'lodash' import { openURL } from '@api/linking' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConfirmWithdrawFutureSwapScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConfirmWithdrawFutureSwapScreen.tsx index a0b95d1814..9f92990237 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConfirmWithdrawFutureSwapScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConfirmWithdrawFutureSwapScreen.tsx @@ -8,7 +8,7 @@ import { translate } from '@translations' import BigNumber from 'bignumber.js' import { Dispatch, useEffect, useState } from 'react' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -20,6 +20,7 @@ import { WhaleWalletAccount } from '@defichain/whale-api-wallet' import { CTransactionSegWit } from '@defichain/jellyfish-transaction/dist' import { onTransactionBroadcast } from '@api/transaction/transaction_commands' import { useFutureSwapDate } from '../../Dex/hook/FutureSwap' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -37,7 +38,7 @@ export function ConfirmWithdrawFutureSwapScreen ({ const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) const blockCount = useSelector((state: RootState) => state.block.count ?? 0) const { isEnded } = useFutureSwapDate(executionBlock, blockCount) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const [isOnPage, setIsOnPage] = useState(true) diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConvertConfirmationScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConvertConfirmationScreen.tsx index 30abcfb1ba..f97fc8f0d3 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConvertConfirmationScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/ConvertConfirmationScreen.tsx @@ -3,7 +3,7 @@ import { NavigationProp, useNavigation } from '@react-navigation/native' import { StackScreenProps } from '@react-navigation/stack' import BigNumber from 'bignumber.js' import { Dispatch, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' import { SummaryTitle } from '@components/SummaryTitle' import { RootState } from '@store' @@ -21,6 +21,7 @@ import { NativeLoggingProps, useLogger } from '@shared-contexts/NativeLoggingPro import { onTransactionBroadcast } from '@api/transaction/transaction_commands' import { dfiConversionCrafter } from '@api/transaction/dfi_converter' import { WalletAddressRow } from '@components/WalletAddressRow' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -36,7 +37,7 @@ export function ConvertConfirmationScreen ({ route }: Props): JSX.Element { } = route.params const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const [isSubmitting, setIsSubmitting] = useState(false) const navigation = useNavigation>() const [isOnPage, setIsOnPage] = useState(true) diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/FutureSwapScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/FutureSwapScreen.tsx index 90654edce9..b7fff71882 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/FutureSwapScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/FutureSwapScreen.tsx @@ -7,7 +7,7 @@ import NumberFormat from 'react-number-format' import { tailwind } from '@tailwind' import { BalanceParamList } from '../BalancesNavigator' import { batch, useSelector } from 'react-redux' -import { RootState, useAppDispatch } from '@store' +import { RootState } from '@store' import { fetchExecutionBlock, fetchFutureSwaps, FutureSwapData, FutureSwapSelector } from '@store/futureSwap' import { useIsFocused } from '@react-navigation/native' import { useWalletContext } from '@shared-contexts/WalletContext' @@ -18,6 +18,7 @@ import { SymbolIcon } from '@components/SymbolIcon' import { TouchableOpacity } from 'react-native' import { useDeFiScanContext } from '@shared-contexts/DeFiScanContext' import { openURL } from '@api/linking' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendConfirmationScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendConfirmationScreen.tsx index f2152105f2..0e35fa4fbb 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendConfirmationScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendConfirmationScreen.tsx @@ -7,7 +7,7 @@ import { StackScreenProps } from '@react-navigation/stack' import { WalletToken } from '@store/wallet' import BigNumber from 'bignumber.js' import { Dispatch, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { NumberRow } from '@components/NumberRow' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' import { SummaryTitle } from '@components/SummaryTitle' @@ -28,6 +28,7 @@ import { onTransactionBroadcast } from '@api/transaction/transaction_commands' import { InfoText } from '@components/InfoText' import { Switch, View } from '@components' import { WalletAddressRow } from '@components/WalletAddressRow' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -44,7 +45,7 @@ export function SendConfirmationScreen ({ route }: Props): JSX.Element { const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) const currentBroadcastJob = useSelector((state: RootState) => firstTransactionSelector(state.ocean)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const [isSubmitting, setIsSubmitting] = useState(false) const navigation = useNavigation>() const [isOnPage, setIsOnPage] = useState(true) diff --git a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendScreen.tsx index 9333e15835..5ca953cdd0 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Balances/screens/SendScreen.tsx @@ -8,7 +8,7 @@ import BigNumber from 'bignumber.js' import { useCallback, useEffect, useRef, useState } from 'react' import { Control, Controller, useForm } from 'react-hook-form' import { Platform, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { AmountButtonTypes, SetAmountButton } from '@components/SetAmountButton' import { ThemedIcon, @@ -41,6 +41,7 @@ import { SubmitButtonGroup } from '@components/SubmitButtonGroup' import { useFeatureFlagContext } from '@contexts/FeatureFlagContext' import { LocalAddress } from '@store/userPreferences' import { debounce } from 'lodash' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -64,7 +65,7 @@ export function SendScreen ({ const { address } = watch() const addressBook = useSelector((state: RootState) => state.userPreferences.addressBook) const [matchedAddress, setMatchedAddress] = useState() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const [fee, setFee] = useState(new BigNumber(0.0001)) const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/CompositeSwapScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/CompositeSwapScreen.tsx index 229589a384..e2be9702fb 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/CompositeSwapScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/CompositeSwapScreen.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { Platform, TouchableOpacity, View } from 'react-native' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { Control, Controller, useForm } from 'react-hook-form' import BigNumber from 'bignumber.js' import { NavigationProp, useIsFocused, useNavigation } from '@react-navigation/native' @@ -48,6 +48,7 @@ import NumberFormat from 'react-number-format' import { TextRow } from '@components/TextRow' import { PriceRateProps } from '@components/PricesSection' import { fetchExecutionBlock } from '@store/futureSwap' +import { useAppDispatch } from '@hooks/useAppDispatch' export enum ButtonGroupTabKey { InstantSwap = 'INSTANT_SWAP', @@ -73,7 +74,7 @@ export function CompositeSwapScreen ({ route }: Props): JSX.Element { const whaleRpcClient = useWhaleRpcClient() const isFocused = useIsFocused() const navigation = useNavigation>() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const { address } = useWalletContext() const { getArbitraryPoolPair, diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/ConfirmCompositeSwapScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/ConfirmCompositeSwapScreen.tsx index b56735389c..aed4526876 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/ConfirmCompositeSwapScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/CompositeSwap/ConfirmCompositeSwapScreen.tsx @@ -1,5 +1,5 @@ import { Dispatch, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { tailwind } from '@tailwind' import { StackScreenProps } from '@react-navigation/stack' import { NavigationProp, useNavigation } from '@react-navigation/native' @@ -28,6 +28,7 @@ import { DexParamList } from '../DexNavigator' import { OwnedTokenState, TokenState } from './CompositeSwapScreen' import { WalletAddressRow } from '@components/WalletAddressRow' import { useTokenPrice } from '@screens/AppNavigator/screens/Balances/hooks/TokenPrice' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps export interface CompositeSwapForm { @@ -51,7 +52,7 @@ export function ConfirmCompositeSwapScreen ({ route }: Props): JSX.Element { estimatedAmount } = route.params const navigation = useNavigation>() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const { getTokenPrice } = useTokenPrice() const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/DexAddLiquidity.tsx b/mobile-app/app/screens/AppNavigator/screens/Dex/DexAddLiquidity.tsx index e4095003cc..ee272a6a7d 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/DexAddLiquidity.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/DexAddLiquidity.tsx @@ -16,7 +16,7 @@ import { InfoRow, InfoType } from '@components/InfoRow' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { DFITokenSelector, DFIUtxoSelector, tokensSelector, WalletToken } from '@store/wallet' import { ConversionInfoText } from '@components/ConversionInfoText' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -25,6 +25,7 @@ import { queueConvertTransaction, useConversion } from '@hooks/wallet/Conversion import { useLogger } from '@shared-contexts/NativeLoggingProvider' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' import { PricesSection } from '@components/PricesSection' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps type EditingAmount = 'primary' | 'secondary' @@ -40,7 +41,7 @@ export function AddLiquidityScreen (props: Props): JSX.Element { const logger = useLogger() const navigation = useNavigation>() const client = useWhaleApiClient() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const DFIToken = useSelector((state: RootState) => DFITokenSelector(state.wallet)) const DFIUtxo = useSelector((state: RootState) => DFIUtxoSelector(state.wallet)) const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmAddLiquidity.tsx b/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmAddLiquidity.tsx index 3723bb2aa0..4e23f053df 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmAddLiquidity.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmAddLiquidity.tsx @@ -4,7 +4,7 @@ import { NavigationProp, useNavigation } from '@react-navigation/native' import { StackScreenProps } from '@react-navigation/stack' import BigNumber from 'bignumber.js' import { useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { Dispatch } from 'redux' import { NumberRow } from '@components/NumberRow' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' @@ -27,6 +27,7 @@ import { View } from '@components' import { InfoText } from '@components/InfoText' import { WalletAddressRow } from '@components/WalletAddressRow' import { PricesSection } from '@components/PricesSection' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -44,7 +45,7 @@ export function ConfirmAddLiquidityScreen (props: Props): JSX.Element { } = props.route.params.summary const pair = props.route.params.pair const { conversion } = props.route.params - const dispatch = useDispatch() + const dispatch = useAppDispatch() const [isSubmitting, setIsSubmitting] = useState(false) const aToBRate = new BigNumber(pair.tokenB.reserve).div(pair.tokenA.reserve) const bToARate = new BigNumber(pair.tokenA.reserve).div(pair.tokenB.reserve) diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmRemoveLiquidity.tsx b/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmRemoveLiquidity.tsx index 58485f1be2..ca860459b4 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmRemoveLiquidity.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/DexConfirmRemoveLiquidity.tsx @@ -5,7 +5,7 @@ import { NavigationProp, useNavigation } from '@react-navigation/native' import { StackScreenProps } from '@react-navigation/stack' import BigNumber from 'bignumber.js' import { useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { Dispatch } from 'redux' import { NumberRow } from '@components/NumberRow' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' @@ -23,6 +23,7 @@ import { TransactionResultsRow } from '@components/TransactionResultsRow' import { onTransactionBroadcast } from '@api/transaction/transaction_commands' import { WalletAddressRow } from '@components/WalletAddressRow' import { PricesSection } from '@components/PricesSection' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -41,7 +42,7 @@ export function RemoveLiquidityConfirmScreen ({ route }: Props): JSX.Element { const symbol = (pair?.tokenA != null && pair?.tokenB != null) ? `${pair.tokenA.displaySymbol}-${pair.tokenB.displaySymbol}` : pair.symbol - const dispatch = useDispatch() + const dispatch = useAppDispatch() const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) const [isSubmitting, setIsSubmitting] = useState(false) diff --git a/mobile-app/app/screens/AppNavigator/screens/Dex/hook/SwappableTokens.ts b/mobile-app/app/screens/AppNavigator/screens/Dex/hook/SwappableTokens.ts index 78d19458b1..40d1d5f9e4 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Dex/hook/SwappableTokens.ts +++ b/mobile-app/app/screens/AppNavigator/screens/Dex/hook/SwappableTokens.ts @@ -1,5 +1,5 @@ import { useCallback, useMemo, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import BigNumber from 'bignumber.js' import { RootState } from '@store' import { DexItem, fetchSwappableTokens, tokensSelector } from '@store/wallet' @@ -10,6 +10,7 @@ import { CacheApi } from '@api/cache' import { useNetworkContext } from '@shared-contexts/NetworkContext' import { useFocusEffect } from '@react-navigation/core' import { AllSwappableTokensResult } from '@defichain/whale-api-client/dist/api/poolpairs' +import { useAppDispatch } from '@hooks/useAppDispatch' interface TokenPrice { toTokens: BottomSheetToken[] @@ -19,7 +20,7 @@ interface TokenPrice { export function useSwappableTokens (fromTokenId: string | undefined): TokenPrice { const client = useWhaleApiClient() const { network } = useNetworkContext() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const blockCount = useSelector((state: RootState) => state.block.count) const { swappableTokens, diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/LoansScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/LoansScreen.tsx index c2b24f3366..f05b960a99 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/LoansScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/LoansScreen.tsx @@ -6,7 +6,7 @@ import { Tabs } from '@components/Tabs' import { Vaults } from './components/Vaults' import { EmptyVault } from './components/EmptyVault' import { SkeletonLoader, SkeletonLoaderScreen } from '@components/SkeletonLoader' -import { batch, useDispatch, useSelector } from 'react-redux' +import { batch, useSelector } from 'react-redux' import { RootState } from '@store' import { fetchLoanSchemes, fetchLoanTokens, fetchVaults, loanTokensSelector } from '@store/loans' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' @@ -19,6 +19,7 @@ import { HeaderSearchInput } from '@components/HeaderSearchInput' import { debounce } from 'lodash' import { LoanToken } from '@defichain/whale-api-client/dist/api/loan' import { useIsFocused } from '@react-navigation/native' +import { useAppDispatch } from '@hooks/useAppDispatch' enum TabKey { BrowseLoans = 'BROWSE_LOANS', @@ -38,7 +39,7 @@ export function LoansScreen ({ navigation }: Props): JSX.Element { } = useSelector((state: RootState) => state.loans) const loans = useSelector((state: RootState) => loanTokensSelector(state.loans)) const [activeTab, setActiveTab] = useState(TabKey.YourVaults) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const onPress = (tabId: string): void => { if (tabId === TabKey.YourVaults) { diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/components/Vaults.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/components/Vaults.tsx index d5e64754f6..79bb3499e7 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/components/Vaults.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/components/Vaults.tsx @@ -1,16 +1,17 @@ import { tailwind } from '@tailwind' import { ThemedScrollView } from '@components/themed' import { VaultCard } from '@screens/AppNavigator/screens/Loans/components/VaultCard' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { useEffect, useRef } from 'react' import { fetchCollateralTokens, fetchVaults, vaultsSelector } from '@store/loans' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { useWalletContext } from '@shared-contexts/WalletContext' import { useIsFocused, useScrollToTop } from '@react-navigation/native' +import { useAppDispatch } from '@hooks/useAppDispatch' export function Vaults (): JSX.Element { - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const isFocused = useIsFocused() const { address } = useWalletContext() diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/BorrowLoanTokenScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/BorrowLoanTokenScreen.tsx index 43820b7607..aa5b319f80 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/BorrowLoanTokenScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/BorrowLoanTokenScreen.tsx @@ -27,7 +27,7 @@ import { InfoRow, InfoType } from '@components/InfoRow' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { useLogger } from '@shared-contexts/NativeLoggingProvider' import { Button } from '@components/Button' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -44,6 +44,7 @@ import { getPrecisedTokenValue } from '@screens/AppNavigator/screens/Auctions/he import { useIsFocused } from '@react-navigation/native' import { useFeatureFlagContext } from '@contexts/FeatureFlagContext' import { IconTooltip } from '@components/tooltip/IconTooltip' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -58,7 +59,7 @@ export function BorrowLoanTokenScreen ({ const isFocused = useIsFocused() const logger = useLogger() const { address } = useWalletContext() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const blockCount = useSelector((state: RootState) => state.block.count) const vaults = useSelector((state: RootState) => vaultsSelector(state.loans)) const [vault, setVault] = useState(route.params.vault) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ChooseLoanTokenScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ChooseLoanTokenScreen.tsx index 5f6f375b04..abe2dc64cb 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ChooseLoanTokenScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ChooseLoanTokenScreen.tsx @@ -5,7 +5,7 @@ import { StackScreenProps } from '@react-navigation/stack' import { LoanParamList } from '../LoansNavigator' import { debounce } from 'lodash' import { tailwind } from '@tailwind' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { LoanToken } from '@defichain/whale-api-client/dist/api/loan' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' @@ -13,6 +13,7 @@ import { fetchLoanTokens, loanTokensSelector } from '@store/loans' import { HeaderSearchIcon } from '@components/HeaderSearchIcon' import { HeaderSearchInput } from '@components/HeaderSearchInput' import { useIsFocused } from '@react-navigation/native' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -20,7 +21,7 @@ export function ChooseLoanTokenScreen ({ navigation, route }: Props): JSX.Elemen const { vaultId } = route.params const loans = useSelector((state: RootState) => loanTokensSelector(state.loans)) const blockCount = useSelector((state: RootState) => state.block.count) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const isFocused = useIsFocused() const [filteredLoans, setFilteredLoans] = useState(loans) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CloseVaultScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CloseVaultScreen.tsx index 69e3fd0b6e..9a3fb4879d 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CloseVaultScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CloseVaultScreen.tsx @@ -10,7 +10,7 @@ import { Dispatch, useEffect, useState } from 'react' import { LoanParamList } from '../LoansNavigator' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { NativeLoggingProps, useLogger } from '@shared-contexts/NativeLoggingProvider' import { onTransactionBroadcast } from '@api/transaction/transaction_commands' @@ -19,6 +19,7 @@ import { CTransactionSegWit } from '@defichain/jellyfish-transaction/dist' import { InfoText } from '@components/InfoText' import { View } from '@components' import { WalletAddressRow } from '@components/WalletAddressRow' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -26,7 +27,7 @@ export function CloseVaultScreen ({ route, navigation }: Props): JSX.Element { const { vaultId } = route.params const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const [isOnPage, setIsOnPage] = useState(true) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmBorrowLoanTokenScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmBorrowLoanTokenScreen.tsx index 54d47ca2fd..0be360cf65 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmBorrowLoanTokenScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmBorrowLoanTokenScreen.tsx @@ -8,7 +8,7 @@ import { translate } from '@translations' import BigNumber from 'bignumber.js' import { Dispatch, useEffect, useState } from 'react' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { firstTransactionSelector, hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -26,6 +26,7 @@ import { WalletAddressRow } from '@components/WalletAddressRow' import { CollateralizationRatioRow } from '../components/CollateralizationRatioRow' import { getPrecisedTokenValue } from '@screens/AppNavigator/screens/Auctions/helpers/precision-token-value' import { getActivePrice } from '../../Auctions/helpers/ActivePrice' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -45,7 +46,7 @@ export function ConfirmBorrowLoanTokenScreen ({ const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) const currentBroadcastJob = useSelector((state: RootState) => firstTransactionSelector(state.ocean)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const { address } = useWalletContext() const client = useWhaleApiClient() diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmCreateVaultScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmCreateVaultScreen.tsx index ceefe064be..dbee657286 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmCreateVaultScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmCreateVaultScreen.tsx @@ -4,7 +4,7 @@ import { RootState } from '@store' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { firstTransactionSelector, hasTxQueued as hasBroadcastQueued } from '@store/ocean' import { Dispatch, useEffect, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { LoanParamList } from '../LoansNavigator' import { LoanScheme } from '@defichain/whale-api-client/dist/api/loan' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' @@ -27,6 +27,7 @@ import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { useNetworkContext } from '@shared-contexts/NetworkContext' import { EnvironmentNetwork } from '@environment' import { WalletAddressRow } from '@components/WalletAddressRow' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -46,7 +47,7 @@ export function ConfirmCreateVaultScreen ({ const [isOnPage, setIsOnPage] = useState(true) const { address } = useWalletContext() const client = useWhaleApiClient() - const dispatch = useDispatch() + const dispatch = useAppDispatch() useEffect(() => { setIsOnPage(true) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditCollateralScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditCollateralScreen.tsx index 91e7adf4ad..0d8b23f668 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditCollateralScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditCollateralScreen.tsx @@ -12,7 +12,7 @@ import { LoanParamList } from '../LoansNavigator' import { SymbolIcon } from '@components/SymbolIcon' import NumberFormat from 'react-number-format' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { firstTransactionSelector, hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -31,6 +31,7 @@ import { ConversionParam } from '@screens/AppNavigator/screens/Balances/Balances import { LoanVaultActive } from '@defichain/whale-api-client/dist/api/loan' import { WalletAddressRow } from '@components/WalletAddressRow' import { getPrecisedTokenValue } from '@screens/AppNavigator/screens/Auctions/helpers/precision-token-value' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -53,7 +54,7 @@ export function ConfirmEditCollateralScreen ({ const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) const currentBroadcastJob = useSelector((state: RootState) => firstTransactionSelector(state.ocean)) const [isOnPage, setIsOnPage] = useState(true) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() useEffect(() => { diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditLoanSchemeScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditLoanSchemeScreen.tsx index ffe84541f2..f93a0a0642 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditLoanSchemeScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmEditLoanSchemeScreen.tsx @@ -9,7 +9,7 @@ import { LoanParamList } from '../LoansNavigator' import BigNumber from 'bignumber.js' import { InfoRow, InfoType } from '@components/InfoRow' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { firstTransactionSelector, hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -19,6 +19,7 @@ import { WhaleWalletAccount } from '@defichain/whale-api-wallet' import { CTransactionSegWit } from '@defichain/jellyfish-transaction/dist' import { onTransactionBroadcast } from '@api/transaction/transaction_commands' import { WalletAddressRow } from '@components/WalletAddressRow' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -33,7 +34,7 @@ export function ConfirmEditLoanSchemeScreen ({ route, navigation }: Props): JSX. const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) const currentBroadcastJob = useSelector((state: RootState) => firstTransactionSelector(state.ocean)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const [isOnPage, setIsOnPage] = useState(true) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmPaybackLoanScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmPaybackLoanScreen.tsx index 3477823f99..1ac86280a1 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmPaybackLoanScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/ConfirmPaybackLoanScreen.tsx @@ -11,7 +11,7 @@ import { translate } from '@translations' import BigNumber from 'bignumber.js' import { Dispatch, useEffect, useState } from 'react' import { SubmitButtonGroup } from '@components/SubmitButtonGroup' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued, transactionQueue } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -30,6 +30,7 @@ import { WalletAddressRow } from '@components/WalletAddressRow' import { CollateralizationRatioRow } from '../components/CollateralizationRatioRow' import { PaymentTokenProps } from '../hooks/LoanPaymentTokenRate' import { useFeatureFlagContext } from '@contexts/FeatureFlagContext' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -53,7 +54,7 @@ export function ConfirmPaybackLoanScreen ({ } = route.params const hasPendingJob = useSelector((state: RootState) => hasTxQueued(state.transactionQueue)) const hasPendingBroadcastJob = useSelector((state: RootState) => hasBroadcastQueued(state.ocean)) - const dispatch = useDispatch() + const dispatch = useAppDispatch() const logger = useLogger() const { address } = useWalletContext() const { isFeatureAvailable } = useFeatureFlagContext() diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx index 5a3de5377b..ad16ada1f3 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx @@ -14,7 +14,7 @@ import { LoanParamList } from '../LoansNavigator' import { LoanScheme } from '@defichain/whale-api-client/dist/api/loan' import BigNumber from 'bignumber.js' import { useLogger } from '@shared-contexts/NativeLoggingProvider' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { ascColRatioLoanScheme, fetchLoanSchemes } from '@store/loans' import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' @@ -24,6 +24,7 @@ import { ConversionInfoText } from '@components/ConversionInfoText' import { InfoTextLink } from '@components/InfoTextLink' import { queueConvertTransaction } from '@hooks/wallet/Conversion' import { LoanSchemeOptions } from '../components/LoanSchemeOptions' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -31,7 +32,7 @@ export function CreateVaultScreen ({ navigation, route }: Props): JSX.Element { - const dispatch = useDispatch() + const dispatch = useAppDispatch() const client = useWhaleApiClient() const loanSchemes = useSelector((state: RootState) => ascColRatioLoanScheme(state.loans)) const hasFetchedLoanSchemes = useSelector((state: RootState) => state.loans.hasFetchedLoanSchemes) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx index 278c39c698..314f38f551 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx @@ -15,7 +15,7 @@ import { BottomSheetTokenList, TokenType } from '@components/BottomSheetTokenLis import { useThemeContext } from '@shared-contexts/ThemeProvider' import { useWhaleApiClient } from '@shared-contexts/WhaleContext' import { useLogger } from '@shared-contexts/NativeLoggingProvider' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { fetchCollateralTokens } from '@store/loans' import { @@ -39,6 +39,7 @@ import { useLoanOperations } from '@screens/AppNavigator/screens/Loans/hooks/Loa import { getActivePrice } from '@screens/AppNavigator/screens/Auctions/helpers/ActivePrice' import { ActiveUSDValue } from '@screens/AppNavigator/screens/Loans/VaultDetail/components/ActiveUSDValue' import { getPrecisedTokenValue } from '@screens/AppNavigator/screens/Auctions/helpers/precision-token-value' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -65,7 +66,7 @@ export function EditCollateralScreen ({ const { isLight } = useThemeContext() const [bottomSheetScreen, setBottomSheetScreen] = useState([]) const [activeVault, setActiveVault] = useState() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const DFIUtxo = useSelector((state: RootState) => DFIUtxoSelector(state.wallet)) const DFIToken = useSelector((state: RootState) => DFITokenSelector(state.wallet)) const containerRef = useRef(null) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/PaybackLoanScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/PaybackLoanScreen.tsx index 63fb0e0ff8..01a9807c2f 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/PaybackLoanScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/PaybackLoanScreen.tsx @@ -14,7 +14,7 @@ import NumberFormat from 'react-number-format' import BigNumber from 'bignumber.js' import { LoanVaultActive } from '@defichain/whale-api-client/dist/api/loan' import { WalletTextInput } from '@components/WalletTextInput' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { RootState } from '@store' import { hasTxQueued } from '@store/transaction_queue' import { hasTxQueued as hasBroadcastQueued } from '@store/ocean' @@ -44,6 +44,7 @@ import { getTokenAmount, PaymentTokenProps, useLoanPaymentTokenRate } from '../h import { LoanPercentage } from '../components/LoanPercentage' import { getPrecisedTokenValue } from '../../Auctions/helpers/precision-token-value' import { ReservedDFIInfoText } from '@components/ReservedDFIInfoText' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps @@ -57,7 +58,7 @@ export function PaybackLoanScreen ({ vault } = route.params const { address } = useWalletContext() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const isFocused = useIsFocused() const blockCount = useSelector((state: RootState) => state.block.count) const tokens = useSelector((state: RootState) => tokensSelector(state.wallet)) diff --git a/mobile-app/app/screens/AppNavigator/screens/Settings/SettingsScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Settings/SettingsScreen.tsx index 53ad967db7..c4573bca1d 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Settings/SettingsScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Settings/SettingsScreen.tsx @@ -19,19 +19,19 @@ import { ocean } from '@store/ocean' import { tailwind } from '@tailwind' import { translate } from '@translations' import { useCallback } from 'react' -import { useDispatch } from 'react-redux' import { MnemonicStorage } from '@api/wallet/mnemonic_storage' import { RowThemeItem } from './components/RowThemeItem' import { SettingsParamList } from './SettingsNavigator' import { useLogger } from '@shared-contexts/NativeLoggingProvider' import { useAddressBook } from '@hooks/useAddressBook' +import { useAppDispatch } from '@hooks/useAppDispatch' type Props = StackScreenProps export function SettingsScreen ({ navigation }: Props): JSX.Element { const logger = useLogger() const { network } = useNetworkContext() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const walletContext = useWalletPersistenceContext() const localAuth = usePrivacyLockContext() const { data: { type } } = useWalletNodeContext() diff --git a/mobile-app/app/screens/PlaygroundNavigator/sections/PlaygroundOperations.tsx b/mobile-app/app/screens/PlaygroundNavigator/sections/PlaygroundOperations.tsx index 4c2b7ff7a5..ad1a07facd 100644 --- a/mobile-app/app/screens/PlaygroundNavigator/sections/PlaygroundOperations.tsx +++ b/mobile-app/app/screens/PlaygroundNavigator/sections/PlaygroundOperations.tsx @@ -1,4 +1,3 @@ -import { useDispatch } from 'react-redux' import { View } from '@components' import { PlaygroundTitle } from '@screens/PlaygroundNavigator/components/PlaygroundTitle' import { useWalletContext } from '@shared-contexts/WalletContext' @@ -9,11 +8,12 @@ import { WalletAddressIndexPersistence } from '@api/wallet/address_index' import { PlaygroundAction } from '@screens/PlaygroundNavigator/components/PlaygroundAction' import { fetchTokens } from '@store/wallet' import { PlaygroundConnectionStatus } from '@screens/PlaygroundNavigator/components/PlaygroundStatus' +import { useAppDispatch } from '@hooks/useAppDispatch' export function PlaygroundOperations (): JSX.Element { const { wallet } = useWalletContext() const client = useWhaleApiClient() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const { api, rpc diff --git a/mobile-app/app/screens/TransactionAuthorization/TransactionAuthorization.tsx b/mobile-app/app/screens/TransactionAuthorization/TransactionAuthorization.tsx index 5cff754d42..fa1e60787f 100644 --- a/mobile-app/app/screens/TransactionAuthorization/TransactionAuthorization.tsx +++ b/mobile-app/app/screens/TransactionAuthorization/TransactionAuthorization.tsx @@ -3,7 +3,7 @@ import { JellyfishWallet, WalletHdNodeProvider } from '@defichain/jellyfish-wall import { MnemonicHdNode } from '@defichain/jellyfish-wallet-mnemonic' import { WhaleWalletAccount } from '@defichain/whale-api-wallet' import { useEffect, useRef, useState } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { initJellyfishWallet, MnemonicEncrypted, @@ -41,6 +41,7 @@ import { import { BottomSheetModal, useBottomSheetModal } from '@gorhom/bottom-sheet' import { WalletAddressIndexPersistence } from '@api/wallet/address_index' import { useAddressBook } from '@hooks/useAddressBook' +import { useAppDispatch } from '@hooks/useAppDispatch' /** * @description - Passcode prompt promise that resolves the pin to the wallet @@ -58,7 +59,7 @@ export function TransactionAuthorization (): JSX.Element | null { const { network } = useNetworkContext() const whaleApiClient = useWhaleApiClient() const logger = useLogger() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const transaction = useSelector((state: RootState) => first(state.transactionQueue)) const authentication = useSelector((state: RootState) => state.authentication.authentication) diff --git a/mobile-app/cypress/integration/functional/wallet/balances/balances.spec.ts b/mobile-app/cypress/integration/functional/wallet/balances/balances.spec.ts index 184680bcec..ff72f8245a 100644 --- a/mobile-app/cypress/integration/functional/wallet/balances/balances.spec.ts +++ b/mobile-app/cypress/integration/functional/wallet/balances/balances.spec.ts @@ -1022,6 +1022,7 @@ context('Wallet - Balances - Token Breakdown', () => { }) it('should hide all locked amount of BTC and ETH', () => { + cy.getByTestID('details_dfi').click() cy.wait(1000) cy.getByTestID('dBTC_locked_amount_text').should('have.text', '*****') cy.getByTestID('dETH_locked_amount_text').should('have.text', '*****') diff --git a/package-lock.json b/package-lock.json index d28e13125e..b51f586158 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "@react-navigation/bottom-tabs": "^6.3.1", "@react-navigation/native": "^6.0.10", "@react-navigation/stack": "^6.2.1", - "@reduxjs/toolkit": "^1.8.1", + "@reduxjs/toolkit": "^1.8.2", "bignumber.js": "^9.0.2", "buffer": "^6.0.3", "classnames": "^2.3.1", @@ -84,7 +84,7 @@ "react-native-web": "0.17.7", "react-number-format": "^4.9.3", "react-overlays": "^5.1.2", - "react-redux": "^7.2.6", + "react-redux": "^8.0.2", "semver": "^7.3.7", "smart-buffer": "^4.2.0", "stream-browserify": "^3.0.0", @@ -107,7 +107,6 @@ "@types/react": "~17.0.21", "@types/react-native": "~0.67.6", "@types/react-native-loading-spinner-overlay": "^0.5.3", - "@types/react-redux": "^7.1.24", "@types/react-test-renderer": "^17.0.1", "@types/semver": "^7.3.9", "babel-plugin-istanbul": "^6.1.1", @@ -10578,7 +10577,7 @@ "version": "18.0.5", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.5.tgz", "integrity": "sha512-OWPWTUrY/NIrjsAPkAk1wW9LZeIjSvkXRhclsFO8CZcZGCOg2G0YZy4ft+rOyYxy8B7ui5iZzi9OkDebZ7/QSA==", - "dev": true, + "devOptional": true, "dependencies": { "@types/react": "*" } @@ -10602,17 +10601,6 @@ "@types/react-native": "*" } }, - "node_modules/@types/react-redux": { - "version": "7.1.24", - "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.24.tgz", - "integrity": "sha512-7FkurKcS1k0FHZEtdbbgN8Oc6b+stGSfZYjQGicofJ0j4U0qIn/jaSvnP2pLwZKiai3/17xqqxkkrxTgN8UNbQ==", - "dependencies": { - "@types/hoist-non-react-statics": "^3.3.0", - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0", - "redux": "^4.0.0" - } - }, "node_modules/@types/react-test-renderer": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/@types/react-test-renderer/-/react-test-renderer-17.0.2.tgz", @@ -10682,6 +10670,11 @@ "source-map": "^0.6.1" } }, + "node_modules/@types/use-sync-external-store": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", + "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" + }, "node_modules/@types/warning": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz", @@ -34283,33 +34276,55 @@ } }, "node_modules/react-redux": { - "version": "7.2.8", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.8.tgz", - "integrity": "sha512-6+uDjhs3PSIclqoCk0kd6iX74gzrGc3W5zcAjbrFgEdIjRSQObdIwfx80unTkVUYvbQ95Y8Av3OvFHq1w5EOUw==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.2.tgz", + "integrity": "sha512-nBwiscMw3NoP59NFCXFf02f8xdo+vSHT/uZ1ldDwF7XaTpzm+Phk97VT4urYBl5TYAPNVaFm12UHAEyzkpNzRA==", "dependencies": { - "@babel/runtime": "^7.15.4", - "@types/react-redux": "^7.1.20", + "@babel/runtime": "^7.12.1", + "@types/hoist-non-react-statics": "^3.3.1", + "@types/use-sync-external-store": "^0.0.3", "hoist-non-react-statics": "^3.3.2", - "loose-envify": "^1.4.0", - "prop-types": "^15.7.2", - "react-is": "^17.0.2" + "react-is": "^18.0.0", + "use-sync-external-store": "^1.0.0" }, "peerDependencies": { - "react": "^16.8.3 || ^17 || ^18" + "@types/react": "^16.8 || ^17.0 || ^18.0", + "@types/react-dom": "^16.8 || ^17.0 || ^18.0", + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0", + "react-native": ">=0.59", + "redux": "^4" }, "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + }, "react-dom": { "optional": true }, "react-native": { "optional": true + }, + "redux": { + "optional": true } } }, "node_modules/react-redux/node_modules/react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + "version": "18.1.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.1.0.tgz", + "integrity": "sha512-Fl7FuabXsJnV5Q1qIOQwx/sagGF18kogb4gpfcG4gjLBWO0WDiiz1ko/ExayuxE7InyQkBLkxRFG5oxY6Uu3Kg==" + }, + "node_modules/react-redux/node_modules/use-sync-external-store": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.1.0.tgz", + "integrity": "sha512-SEnieB2FPKEVne66NpXPd1Np4R1lTNKfjuy3XdIoPQKYBAFdzbzSZlSn1KJZUiihQLQC5Znot4SBz1EOTBwQAQ==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } }, "node_modules/react-refresh": { "version": "0.4.3", @@ -51377,7 +51392,7 @@ "version": "18.0.5", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.0.5.tgz", "integrity": "sha512-OWPWTUrY/NIrjsAPkAk1wW9LZeIjSvkXRhclsFO8CZcZGCOg2G0YZy4ft+rOyYxy8B7ui5iZzi9OkDebZ7/QSA==", - "dev": true, + "devOptional": true, "requires": { "@types/react": "*" } @@ -51401,17 +51416,6 @@ "@types/react-native": "*" } }, - "@types/react-redux": { - "version": "7.1.24", - "resolved": "https://registry.npmjs.org/@types/react-redux/-/react-redux-7.1.24.tgz", - "integrity": "sha512-7FkurKcS1k0FHZEtdbbgN8Oc6b+stGSfZYjQGicofJ0j4U0qIn/jaSvnP2pLwZKiai3/17xqqxkkrxTgN8UNbQ==", - "requires": { - "@types/hoist-non-react-statics": "^3.3.0", - "@types/react": "*", - "hoist-non-react-statics": "^3.3.0", - "redux": "^4.0.0" - } - }, "@types/react-test-renderer": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/@types/react-test-renderer/-/react-test-renderer-17.0.2.tgz", @@ -51481,6 +51485,11 @@ "source-map": "^0.6.1" } }, + "@types/use-sync-external-store": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/@types/use-sync-external-store/-/use-sync-external-store-0.0.3.tgz", + "integrity": "sha512-EwmlvuaxPNej9+T4v5AuBPJa2x2UOJVdjCtDHgcDqitUeOtjnJKJ+apYjVcAoBEMjKW1VVFGZLUb5+qqa09XFA==" + }, "@types/warning": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/warning/-/warning-3.0.0.tgz", @@ -69771,22 +69780,28 @@ } }, "react-redux": { - "version": "7.2.8", - "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-7.2.8.tgz", - "integrity": "sha512-6+uDjhs3PSIclqoCk0kd6iX74gzrGc3W5zcAjbrFgEdIjRSQObdIwfx80unTkVUYvbQ95Y8Av3OvFHq1w5EOUw==", + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/react-redux/-/react-redux-8.0.2.tgz", + "integrity": "sha512-nBwiscMw3NoP59NFCXFf02f8xdo+vSHT/uZ1ldDwF7XaTpzm+Phk97VT4urYBl5TYAPNVaFm12UHAEyzkpNzRA==", "requires": { - "@babel/runtime": "^7.15.4", - "@types/react-redux": "^7.1.20", + "@babel/runtime": "^7.12.1", + "@types/hoist-non-react-statics": "^3.3.1", + "@types/use-sync-external-store": "^0.0.3", "hoist-non-react-statics": "^3.3.2", - "loose-envify": "^1.4.0", - "prop-types": "^15.7.2", - "react-is": "^17.0.2" + "react-is": "^18.0.0", + "use-sync-external-store": "^1.0.0" }, "dependencies": { "react-is": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", - "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==" + "version": "18.1.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.1.0.tgz", + "integrity": "sha512-Fl7FuabXsJnV5Q1qIOQwx/sagGF18kogb4gpfcG4gjLBWO0WDiiz1ko/ExayuxE7InyQkBLkxRFG5oxY6Uu3Kg==" + }, + "use-sync-external-store": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.1.0.tgz", + "integrity": "sha512-SEnieB2FPKEVne66NpXPd1Np4R1lTNKfjuy3XdIoPQKYBAFdzbzSZlSn1KJZUiihQLQC5Znot4SBz1EOTBwQAQ==", + "requires": {} } } }, diff --git a/package.json b/package.json index dd51a31247..ce825b3ba4 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@react-navigation/bottom-tabs": "^6.3.1", "@react-navigation/native": "^6.0.10", "@react-navigation/stack": "^6.2.1", - "@reduxjs/toolkit": "^1.8.1", + "@reduxjs/toolkit": "^1.8.2", "bignumber.js": "^9.0.2", "buffer": "^6.0.3", "classnames": "^2.3.1", @@ -95,7 +95,7 @@ "react-native-web": "0.17.7", "react-number-format": "^4.9.3", "react-overlays": "^5.1.2", - "react-redux": "^7.2.6", + "react-redux": "^8.0.2", "semver": "^7.3.7", "smart-buffer": "^4.2.0", "stream-browserify": "^3.0.0", @@ -118,7 +118,6 @@ "@types/react": "~17.0.21", "@types/react-native": "~0.67.6", "@types/react-native-loading-spinner-overlay": "^0.5.3", - "@types/react-redux": "^7.1.24", "@types/react-test-renderer": "^17.0.1", "@types/semver": "^7.3.9", "babel-plugin-istanbul": "^6.1.1", diff --git a/shared/contexts/StatsProvider.tsx b/shared/contexts/StatsProvider.tsx index a3e2f53304..e2994a8529 100644 --- a/shared/contexts/StatsProvider.tsx +++ b/shared/contexts/StatsProvider.tsx @@ -1,11 +1,12 @@ import React, { useEffect, PropsWithChildren } from 'react' -import { useDispatch, useSelector } from 'react-redux' +import { useSelector } from 'react-redux' import { isPlayground } from '@environment' import { RootState } from '@store' import { block } from '@store/block' import { useNetworkContext } from '@shared-contexts/NetworkContext' import { useWhaleApiClient } from './WhaleContext' import { useLogger } from '@shared-contexts/NativeLoggingProvider' +import { useAppDispatch } from '@hooks/useAppDispatch' export function StatsProvider (props: PropsWithChildren): JSX.Element | null { const { network } = useNetworkContext() @@ -14,7 +15,7 @@ export function StatsProvider (props: PropsWithChildren): JSX.Element | nul const api = useWhaleApiClient() const interval: number = isPlayground(network) ? 3000 : 30000 - const dispatch = useDispatch() + const dispatch = useAppDispatch() useEffect(() => { // TODO: https://reactnative.dev/docs/appstate refactor to support app app refreshing diff --git a/shared/contexts/WalletDataProvider.tsx b/shared/contexts/WalletDataProvider.tsx index 23dd27b5be..b4a8c34ee7 100644 --- a/shared/contexts/WalletDataProvider.tsx +++ b/shared/contexts/WalletDataProvider.tsx @@ -1,5 +1,5 @@ import React, { useEffect, PropsWithChildren } from 'react' -import { batch, useDispatch, useSelector } from 'react-redux' +import { batch, useSelector } from 'react-redux' import { RootState } from '@store' import { useNetworkContext } from '@shared-contexts/NetworkContext' import { useWhaleApiClient } from './WhaleContext' @@ -9,12 +9,13 @@ import { useWalletPersistenceContext } from '@shared-contexts/WalletPersistenceC import { useFeatureFlagContext } from '@contexts/FeatureFlagContext' import { useWalletContext } from '@shared-contexts/WalletContext' import { fetchVaults } from '@store/loans' +import { useAppDispatch } from '@hooks/useAppDispatch' export function WalletDataProvider (props: PropsWithChildren): JSX.Element | null { const blockCount = useSelector((state: RootState) => state.block.count) const client = useWhaleApiClient() const { network } = useNetworkContext() - const dispatch = useDispatch() + const dispatch = useAppDispatch() const { address } = useWalletContext() const { wallets } = useWalletPersistenceContext() const { isFeatureAvailable } = useFeatureFlagContext() diff --git a/shared/store/index.ts b/shared/store/index.ts index bf064666a8..7ca38fd7cd 100644 --- a/shared/store/index.ts +++ b/shared/store/index.ts @@ -9,7 +9,6 @@ import { loans } from './loans' import { auctions } from './auctions' import { announcementWebsiteSlice, statusWebsiteSlice } from '@store/website' import { userPreferences } from '@store/userPreferences' -import { useDispatch } from 'react-redux' import { futureSwaps } from './futureSwap' /** @@ -45,4 +44,3 @@ export function initializeStore () { export type RootStore = ReturnType export type RootState = ReturnType -export const useAppDispatch = () => useDispatch()