Skip to content

Commit

Permalink
Merge branch 'develop' into refactor/swap-module
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo authored Mar 5, 2025
2 parents ed7966c + 575857b commit faac7b8
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const DashboardNavigator = () => {
>
<Stack.Screen
name="staking-dashboard-main"
component={Dashboard}
getComponent={() => Dashboard}
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 {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 All @@ -16,11 +18,12 @@ import {StakePoolInfoAndHistory} from '../../yoroi-wallets/types/staking'
export const StakePoolInfo = ({stakePoolId}: {stakePoolId: string}) => {
const strings = useStrings()
const styles = useStyles()
const {isDark} = useTheme()
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 @@ 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]

const history = stakePoolInfosAndHistories[stakePoolId]?.history
if (history == null) return null

const explorerPoolInfo = await poolInfoApi.getSingleExplorerPoolInfo(stakePoolId)

return {
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 @@ import {StakePoolInfo} from './StakePoolInfo'
export const StakePoolInfos = () => {
const {wallet} = useSelectedWallet()
const {stakePoolIds, isLoading} = useStakePoolIds(wallet)
const {isDark} = useTheme()

return stakePoolIds != null ? (
<View>
Expand All @@ -23,7 +25,7 @@ export const StakePoolInfos = () => {
</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
}
}
]

0 comments on commit faac7b8

Please sign in to comment.