3
3
import { WalletType } from '@cardano-sdk/web-extension' ;
4
4
import { Button , Flex } from '@input-output-hk/lace-ui-toolkit' ;
5
5
import { StakePoolMetricsBrowser , StakePoolNameBrowser , Wallet } from '@lace/cardano' ;
6
- import { Ellipsis , PostHogAction } from '@lace/common' ;
6
+ import { Ellipsis , PostHogAction , logger } from '@lace/common' ;
7
7
import cn from 'classnames' ;
8
8
import { StakePoolCardProgressBar } from 'features/BrowsePools' ;
9
9
import { isOversaturated } from 'features/BrowsePools/utils' ;
@@ -16,6 +16,7 @@ import {
16
16
DelegationPortfolioStore ,
17
17
MAX_POOLS_COUNT ,
18
18
StakePoolDetails ,
19
+ mapStakePoolToDisplayData ,
19
20
stakePoolDetailsSelector ,
20
21
useDelegationPortfolioStore ,
21
22
} from '../store' ;
@@ -24,30 +25,14 @@ import styles from './StakePoolDetail.module.scss';
24
25
25
26
export const StakePoolDetail = ( { popupView } : { popupView ?: boolean } ) : React . ReactElement => {
26
27
const { t } = useTranslation ( ) ;
27
- const { openExternalLink } = useOutsideHandles ( ) ;
28
+ const {
29
+ openExternalLink,
30
+ walletStoreBlockchainProvider : { stakePoolProvider } ,
31
+ } = useOutsideHandles ( ) ;
28
32
29
33
const {
30
34
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 } ,
51
36
} = useDelegationPortfolioStore ( ( store ) => ( {
52
37
delegatingToThisPool :
53
38
store . viewedStakePool ?. hexId &&
@@ -57,6 +42,15 @@ export const StakePoolDetail = ({ popupView }: { popupView?: boolean }): React.R
57
42
details : stakePoolDetailsSelector ( store ) || ( { } as StakePoolDetails ) ,
58
43
} ) ) ;
59
44
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
+
60
54
const socialNetworks = [
61
55
{ href : contact ?. feed , type : SocialNetwork . RSS_FEED } ,
62
56
{ href : contact ?. primary , type : SocialNetwork . WEBSITE } ,
0 commit comments