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 2 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
20 changes: 19 additions & 1 deletion 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 {Button, ButtonType} from '../../components/Button/Button'
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 Down Expand Up @@ -63,13 +65,29 @@ export const useStakePoolInfoAndHistory = (
[string, string, string]
>,
) => {
const {networkManager} = useSelectedNetwork()
const poolInfoApi = React.useMemo(
() => new PoolInfoApi(networkManager.legacyApiBaseUrl),
[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]
if (stakePoolInfosAndHistories[stakePoolId]?.history == null) return null

const explorerPoolInfo = await poolInfoApi.getSingleExplorerPoolInfo(stakePoolId)

return {
history: stakePoolInfosAndHistories[stakePoolId].history,
info: {
name: explorerPoolInfo?.name ?? '',
ticker: explorerPoolInfo?.ticker ?? '',
},
}
},
})

Expand Down
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": 123,
"column": 9,
"index": 3212
"index": 3989
},
"end": {
"line": 108,
"line": 126,
"column": 3,
"index": 3333
"index": 4110
}
},
{
"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": 127,
"column": 11,
"index": 3346
"index": 4123
},
"end": {
"line": 114,
"line": 132,
"column": 3,
"index": 3581
"index": 4358
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.fullDescriptionButtonLabel",
"defaultMessage": "!!!Go to website",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 115,
"line": 133,
"column": 26,
"index": 3609
"index": 4386
},
"end": {
"line": 118,
"line": 136,
"column": 3,
"index": 3744
"index": 4521
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.copied",
"defaultMessage": "!!!Copied!",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 119,
"line": 137,
"column": 10,
"index": 3756
"index": 4533
},
"end": {
"line": 122,
"line": 140,
"column": 3,
"index": 3865
"index": 4642
}
},
{
"id": "components.delegationsummary.delegatedStakepoolInfo.unknownPool",
"defaultMessage": "!!!Unknown pool",
"file": "src/legacy/Dashboard/StakePoolInfo.tsx",
"start": {
"line": 123,
"line": 141,
"column": 15,
"index": 3882
"index": 4659
},
"end": {
"line": 126,
"line": 144,
"column": 3,
"index": 4001
"index": 4778
}
}
]
Loading