Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wallet-mobile): Use explorer data when pool info is missing #3856

Merged
merged 6 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
>
<Stack.Screen
name="staking-dashboard-main"
component={Dashboard}
getComponent={() => Dashboard}

Check warning on line 36 in apps/wallet-mobile/src/legacy/Dashboard/DashboardNavigator.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/DashboardNavigator.tsx#L36

Added line #L36 was not covered by tests
options={{
title: meta.name,
}}
Expand Down
25 changes: 23 additions & 2 deletions apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {PoolInfoApi} from '@emurgo/yoroi-lib'
import {useTheme} from '@yoroi/theme'
import React from 'react'
import {defineMessages, useIntl} from 'react-intl'
Expand All @@ -8,6 +9,7 @@
import {CopyButton} from '../../components/CopyButton'
import {Text} from '../../components/Text'
import {TitledCard} from '../../components/TitledCard'
import {useSelectedNetwork} from '../../features/WalletManager/common/hooks/useSelectedNetwork'
import {useSelectedWallet} from '../../features/WalletManager/common/hooks/useSelectedWallet'
import {isEmptyString} from '../../kernel/utils'
import {YoroiWallet} from '../../yoroi-wallets/cardano/types'
Expand All @@ -16,11 +18,12 @@
export const StakePoolInfo = ({stakePoolId}: {stakePoolId: string}) => {
const strings = useStrings()
const styles = useStyles()
const {isDark} = useTheme()

Check warning on line 21 in apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx#L21

Added line #L21 was not covered by tests
const {wallet} = useSelectedWallet()
const {stakePoolInfoAndHistory, isLoading} = useStakePoolInfoAndHistory({wallet, stakePoolId})
const homepage = stakePoolInfoAndHistory?.info?.homepage

if (isLoading) return <ActivityIndicator size="large" color="black" />
if (isLoading) return <ActivityIndicator size="large" color={isDark ? 'white' : 'black'} />
if (!stakePoolInfoAndHistory?.info) return null

return (
Expand Down Expand Up @@ -63,13 +66,31 @@
[string, string, string]
>,
) => {
const {networkManager} = useSelectedNetwork()
const poolInfoApi = React.useMemo(
() => new PoolInfoApi(networkManager.legacyApiBaseUrl),

Check warning on line 71 in apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx#L69-L71

Added lines #L69 - L71 were not covered by tests
[networkManager.legacyApiBaseUrl],
)
const query = useQuery({
...options,
queryKey: [wallet.id, 'stakePoolInfo', stakePoolId],
queryFn: async () => {
const stakePoolInfosAndHistories = await wallet.fetchPoolInfo({poolIds: [stakePoolId]})

return stakePoolInfosAndHistories[stakePoolId]
if (stakePoolInfosAndHistories[stakePoolId]?.info?.name != null) return stakePoolInfosAndHistories[stakePoolId]

const history = stakePoolInfosAndHistories[stakePoolId]?.history

Check warning on line 82 in apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx#L82

Added line #L82 was not covered by tests
if (history == null) return null

const explorerPoolInfo = await poolInfoApi.getSingleExplorerPoolInfo(stakePoolId)

Check warning on line 85 in apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx#L85

Added line #L85 was not covered by tests

return {

Check warning on line 87 in apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfo.tsx#L87

Added line #L87 was not covered by tests
history,
info: {
name: explorerPoolInfo?.name ?? '',
ticker: explorerPoolInfo?.ticker ?? '',
},
}
},
})

Expand Down
4 changes: 3 additions & 1 deletion apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useTheme} from '@yoroi/theme'
import {Balance, Wallet} from '@yoroi/types'
import BigNumber from 'bignumber.js'
import React from 'react'
Expand All @@ -14,6 +15,7 @@
export const StakePoolInfos = () => {
const {wallet} = useSelectedWallet()
const {stakePoolIds, isLoading} = useStakePoolIds(wallet)
const {isDark} = useTheme()

Check warning on line 18 in apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx

View check run for this annotation

Codecov / codecov/patch

apps/wallet-mobile/src/legacy/Dashboard/StakePoolInfos.tsx#L18

Added line #L18 was not covered by tests

return stakePoolIds != null ? (
<View>
Expand All @@ -23,7 +25,7 @@
</View>
) : isLoading ? (
<View style={styles.activityIndicator}>
<ActivityIndicator size="large" color="black" />
<ActivityIndicator size="large" color={isDark ? 'white' : 'black'} />
</View>
) : null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"start": {
"line": 76,
"column": 9,
"index": 2279
"index": 2288
},
"end": {
"line": 79,
"column": 3,
"index": 2367
"index": 2376
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,74 +4,74 @@
"defaultMessage": "!!!Stake pool delegated",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 105,
"line": 126,
"column": 9,
"index": 3212
"index": 4022
},
"end": {
"line": 108,
"line": 129,
"column": 3,
"index": 3333
"index": 4143
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.warning",
"defaultMessage": "!!!If you just delegated to a new stake pool it may take a couple of minutes for the network to process your request.",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 109,
"line": 130,
"column": 11,
"index": 3346
"index": 4156
},
"end": {
"line": 114,
"line": 135,
"column": 3,
"index": 3581
"index": 4391
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.fullDescriptionButtonLabel",
"defaultMessage": "!!!Go to website",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 115,
"line": 136,
"column": 26,
"index": 3609
"index": 4419
},
"end": {
"line": 118,
"line": 139,
"column": 3,
"index": 3744
"index": 4554
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.copied",
"defaultMessage": "!!!Copied!",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 119,
"line": 140,
"column": 10,
"index": 3756
"index": 4566
},
"end": {
"line": 122,
"line": 143,
"column": 3,
"index": 3865
"index": 4675
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.unknownPool",
"defaultMessage": "!!!Unknown pool",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 123,
"line": 144,
"column": 15,
"index": 3882
"index": 4692
},
"end": {
"line": 126,
"line": 147,
"column": 3,
"index": 4001
"index": 4811
}
}
]
Loading