From c42231e153741d530916bee06935420ce2916dfe Mon Sep 17 00:00:00 2001 From: Juliano Lazzarotto <30806844+stackchain@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:11:31 +0000 Subject: [PATCH] chore: fix react-query updates --- .../ReviewTx/common/hooks/useFormattedTx.tsx | 2 +- .../ReviewTx/common/hooks/useTxBody.tsx | 13 ++++++-- .../features/ReviewTx/common/operations.tsx | 32 +++++++++++++------ .../Staking/StakingCenter/StakingCenter.tsx | 23 +++++++++---- 4 files changed, 51 insertions(+), 19 deletions(-) diff --git a/apps/wallet/src/features/ReviewTx/common/hooks/useFormattedTx.tsx b/apps/wallet/src/features/ReviewTx/common/hooks/useFormattedTx.tsx index 133c96b4e6..86d926e626 100644 --- a/apps/wallet/src/features/ReviewTx/common/hooks/useFormattedTx.tsx +++ b/apps/wallet/src/features/ReviewTx/common/hooks/useFormattedTx.tsx @@ -3,7 +3,7 @@ import {isNonNullable} from '@yoroi/common' import {infoExtractName} from '@yoroi/portfolio' import {Portfolio} from '@yoroi/types' import _ from 'lodash' -import {useQuery} from 'react-query' +import {useQuery} from '@tanstack/react-query' import {YoroiWallet} from '../../../../yoroi-wallets/cardano/types' import {deriveRewardAddressFromAddress} from '../../../../yoroi-wallets/cardano/utils' diff --git a/apps/wallet/src/features/ReviewTx/common/hooks/useTxBody.tsx b/apps/wallet/src/features/ReviewTx/common/hooks/useTxBody.tsx index 75588bd47a..0d05940948 100644 --- a/apps/wallet/src/features/ReviewTx/common/hooks/useTxBody.tsx +++ b/apps/wallet/src/features/ReviewTx/common/hooks/useTxBody.tsx @@ -1,10 +1,16 @@ -import {useQuery} from 'react-query' +import {useQuery} from '@tanstack/react-query' import {wrappedCsl} from '../../../../yoroi-wallets/cardano/wrappedCsl' import {YoroiUnsignedTx} from '../../../../yoroi-wallets/types/yoroi' import {TransactionBody} from '../types' -export const useTxBody = ({cbor, unsignedTx}: {cbor?: string; unsignedTx?: YoroiUnsignedTx}): TransactionBody => { +export const useTxBody = ({ + cbor, + unsignedTx, +}: { + cbor?: string + unsignedTx?: YoroiUnsignedTx +}): TransactionBody => { const query = useQuery( ['useTxBody', cbor, unsignedTx], async () => { @@ -22,7 +28,8 @@ export const useTxBody = ({cbor, unsignedTx}: {cbor?: string; unsignedTx?: Yoroi }, ) - if (query.data === undefined) throw new Error('useTxBody: cannot extract txBody') + if (query.data === undefined) + throw new Error('useTxBody: cannot extract txBody') return query.data } const getCborTxBody = async (cbor: string) => { diff --git a/apps/wallet/src/features/ReviewTx/common/operations.tsx b/apps/wallet/src/features/ReviewTx/common/operations.tsx index 3c37ed4762..4c3097aa8e 100644 --- a/apps/wallet/src/features/ReviewTx/common/operations.tsx +++ b/apps/wallet/src/features/ReviewTx/common/operations.tsx @@ -2,7 +2,7 @@ import {useTheme} from '@yoroi/theme' import * as React from 'react' import {Linking, StyleSheet, Text, View} from 'react-native' import {TouchableOpacity} from 'react-native-gesture-handler' -import {useQuery} from 'react-query' +import {useQuery} from '@tanstack/react-query' import {Space} from '../../../components/Space/Space' import {wrappedCsl} from '../../../yoroi-wallets/cardano/wrappedCsl' @@ -26,7 +26,10 @@ export const StakeRegistrationOperation = () => { - {formatTokenWithText(asQuantity(wallet.protocolParams.keyDeposit), wallet.portfolioPrimaryTokenInfo)} + {formatTokenWithText( + asQuantity(wallet.protocolParams.keyDeposit), + wallet.portfolioPrimaryTokenInfo, + )} ) @@ -49,7 +52,9 @@ export const StakeRewardsWithdrawalOperation = () => { return ( - {strings.rewardsWithdrawalLabel} + + {strings.rewardsWithdrawalLabel} + {strings.rewardsWithdrawalText} @@ -62,7 +67,8 @@ export const StakeDelegateOperation = ({poolId}: {poolId: string}) => { const poolInfo = usePoolInfo({poolId}) const {networkManager} = useSelectedNetwork() - const poolInfoText = poolInfo != null ? `[${poolInfo.ticker}] ${poolInfo.name}` : poolId + const poolInfoText = + poolInfo != null ? `[${poolInfo.ticker}] ${poolInfo.name}` : poolId return ( @@ -72,7 +78,9 @@ export const StakeDelegateOperation = ({poolId}: {poolId: string}) => { Linking.openURL(networkManager.explorers.cardanoscan.pool(poolId))} + onPress={() => + Linking.openURL(networkManager.explorers.cardanoscan.pool(poolId)) + } > {poolInfoText} @@ -133,16 +141,22 @@ export const useOperations = (certificates: FormattedTx['certificates']) => { case CertificateType.StakeDelegation: { const poolKeyHash = certificate.value.pool_keyhash ?? null if (poolKeyHash == null) return acc - return [...acc, ] + return [ + ...acc, + , + ] } case CertificateType.VoteDelegation: { const drep = certificate.value.drep - if (drep === 'AlwaysAbstain') return [...acc, ] - if (drep === 'AlwaysNoConfidence') return [...acc, ] + if (drep === 'AlwaysAbstain') + return [...acc, ] + if (drep === 'AlwaysNoConfidence') + return [...acc, ] - const drepId = ('KeyHash' in drep ? drep.KeyHash : drep.ScriptHash) ?? '' + const drepId = + ('KeyHash' in drep ? drep.KeyHash : drep.ScriptHash) ?? '' return [...acc, ] } diff --git a/apps/wallet/src/legacy/Staking/StakingCenter/StakingCenter.tsx b/apps/wallet/src/legacy/Staking/StakingCenter/StakingCenter.tsx index b78fa44a45..881c7033d3 100644 --- a/apps/wallet/src/legacy/Staking/StakingCenter/StakingCenter.tsx +++ b/apps/wallet/src/legacy/Staking/StakingCenter/StakingCenter.tsx @@ -5,7 +5,7 @@ import {defineMessages, useIntl} from 'react-intl' import {StyleSheet, View} from 'react-native' import {SafeAreaView} from 'react-native-safe-area-context' import {WebView, WebViewMessageEvent} from 'react-native-webview' -import {useQueryClient} from 'react-query' +import {useQueryClient} from '@tanstack/react-query' import {PleaseWaitModal} from '../../../components/PleaseWaitModal' import {Spacer} from '../../../components/Spacer/Spacer' @@ -41,7 +41,9 @@ export const StakingCenter = () => { }, [track]), ) - const [selectedPoolId, setSelectedPoolId] = React.useState(null) + const [selectedPoolId, setSelectedPoolId] = React.useState( + null, + ) const [isContentLoaded, setIsContentLoaded] = React.useState(false) const {isLoading} = useStakingTx( @@ -53,7 +55,9 @@ export const StakingCenter = () => { if (selectedPoolId == null) return unsignedTxChanged(yoroiUnsignedTx) - navigateToTxReview({onSuccess: () => queryClient.resetQueries([wallet.id, 'stakingInfo'])}) + navigateToTxReview({ + onSuccess: () => queryClient.resetQueries([wallet.id, 'stakingInfo']), + }) }, }, ) @@ -72,7 +76,9 @@ export const StakingCenter = () => { return ( - {shouldDisplayPoolIDInput && } + {shouldDisplayPoolIDInput && ( + + )} {shouldDisplayPoolList && ( @@ -100,7 +106,11 @@ export const StakingCenter = () => { )} - + ) } @@ -127,7 +137,8 @@ const noPoolDataDialog = defineMessages({ }, message: { id: 'components.stakingcenter.noPoolDataDialog.message', - defaultMessage: '!!!The data from the stake pool(s) you selected is invalid. Please try again', + defaultMessage: + '!!!The data from the stake pool(s) you selected is invalid. Please try again', }, })