Skip to content

Commit 6a531cf

Browse files
committed
feat: perform a stake pool query by id on stake pool details to fetch all the details
1 parent 244f71a commit 6a531cf

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

packages/staking/src/features/Drawer/StakePoolDetail.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { WalletType } from '@cardano-sdk/web-extension';
44
import { Button, Flex } from '@input-output-hk/lace-ui-toolkit';
55
import { StakePoolMetricsBrowser, StakePoolNameBrowser, Wallet } from '@lace/cardano';
6-
import { Ellipsis, PostHogAction } from '@lace/common';
6+
import { Ellipsis, PostHogAction, logger } from '@lace/common';
77
import cn from 'classnames';
88
import { StakePoolCardProgressBar } from 'features/BrowsePools';
99
import { isOversaturated } from 'features/BrowsePools/utils';
@@ -16,6 +16,7 @@ import {
1616
DelegationPortfolioStore,
1717
MAX_POOLS_COUNT,
1818
StakePoolDetails,
19+
mapStakePoolToDisplayData,
1920
stakePoolDetailsSelector,
2021
useDelegationPortfolioStore,
2122
} from '../store';
@@ -24,30 +25,14 @@ import styles from './StakePoolDetail.module.scss';
2425

2526
export const StakePoolDetail = ({ popupView }: { popupView?: boolean }): React.ReactElement => {
2627
const { t } = useTranslation();
27-
const { openExternalLink } = useOutsideHandles();
28+
const {
29+
openExternalLink,
30+
walletStoreBlockchainProvider: { stakePoolProvider },
31+
} = useOutsideHandles();
2832

2933
const {
3034
delegatingToThisPool,
31-
details: {
32-
delegators,
33-
description,
34-
id,
35-
hexId,
36-
owners = [],
37-
ros,
38-
saturation,
39-
activeStake,
40-
liveStake,
41-
logo,
42-
name,
43-
ticker,
44-
status,
45-
contact,
46-
blocks,
47-
cost,
48-
pledge,
49-
margin,
50-
},
35+
details: { activeStake, blocks, cost, contact, description, hexId, id, logo, name, pledge, ticker, saturation },
5136
} = useDelegationPortfolioStore((store) => ({
5237
delegatingToThisPool:
5338
store.viewedStakePool?.hexId &&
@@ -57,6 +42,15 @@ export const StakePoolDetail = ({ popupView }: { popupView?: boolean }): React.R
5742
details: stakePoolDetailsSelector(store) || ({} as StakePoolDetails),
5843
}));
5944

45+
const [{ delegators, liveStake, margin, owners = [], ros, status }, setDetails] = useState({} as StakePoolDetails);
46+
47+
useEffect(() => {
48+
stakePoolProvider
49+
.queryStakePools({ filters: { identifier: { values: [{ id }] } }, pagination: { limit: 1, startAt: 0 } })
50+
.then(({ pageResults: [stakePool] }) => stakePool && setDetails(mapStakePoolToDisplayData({ stakePool })))
51+
.catch(logger.error);
52+
}, [id, stakePoolProvider]);
53+
6054
const socialNetworks = [
6155
{ href: contact?.feed, type: SocialNetwork.RSS_FEED },
6256
{ href: contact?.primary, type: SocialNetwork.WEBSITE },

0 commit comments

Comments
 (0)