Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | import { HomeLayout } from './home-layout'; import { TransactionList, StackingPromoCard, StackingRewardCard, TransactionListItem, BalanceCard, } from '@components/home'; import { TransactionListItemMempool } from '@components/home/transaction-list/transaction-list-item-mempool'; import routes from '@constants/routes.json'; import { useAnalytics } from '@hooks/use-analytics'; import { useApi } from '@hooks/use-api'; import { useBalance } from '@hooks/use-balance'; import { usePromptUserToSetDiagnosticPermissions } from '@hooks/use-diagnostic-permission-prompt'; import { useLatestNonce } from '@hooks/use-latest-nonce'; import { useTransactionList } from '@hooks/use-transaction-list'; import { ReceiveStxModal } from '@modals/receive-stx/receive-stx-modal'; import { RequestDiagnosticsModal } from '@modals/request-diagnostics/request-diagnostic-modal'; import { RevokeDelegationModal } from '@modals/revoke-delegation/revoke-delegation-modal'; import { SendStxModal } from '@modals/send-stx/send-stx-modal'; import { Spinner } from '@stacks/ui'; import { homeActions, selectTxModalOpen, selectReceiveModalOpen, selectHomeCardState, } from '@store/home'; import { selectRevokeDelegationModalOpen } from '@store/home/home.reducer'; import { RootState } from '@store/index'; import { selectAddress } from '@store/keys'; import { selectLoadingStacking, selectNextCycleInfo, selectStackerInfo } from '@store/stacking'; import { selectActiveNodeApi } from '@store/stacks-node'; import { selectTransactionsLoading, selectTransactionListFetchError } from '@store/transaction'; import { openTxInExplorer } from '@utils/external-links'; import React from 'react'; import { FC } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { Route, Switch } from 'react-router-dom'; export const Home: FC = () => { const dispatch = useDispatch(); const api = useApi(); useLatestNonce(); usePromptUserToSetDiagnosticPermissions(); const { availableBalance } = useBalance(); const { address, loadingTxs, txModalOpen, txListFetchError, receiveModalOpen, revokeDelegationModalOpen, activeNode, } = useSelector((state: RootState) => ({ address: selectAddress(state), txModalOpen: selectTxModalOpen(state), revokeDelegationModalOpen: selectRevokeDelegationModalOpen(state), receiveModalOpen: selectReceiveModalOpen(state), loadingTxs: selectTransactionsLoading(state), txListFetchError: selectTransactionListFetchError(state), activeNode: selectActiveNodeApi(state), nextCycleInfo: selectNextCycleInfo(state), stackerInfo: selectStackerInfo(state), stackingLoading: selectLoadingStacking(state), stackingCardState: selectHomeCardState(state), })); const { txs, pendingTxs, txCount, focusedTxIdRef, txDomNodeRefMap } = useTransactionList(); const analytics = useAnalytics(); Iif (!address) return <Spinner />; const openTxInExplorerTracked = (txId: string) => { void analytics.track('view_transaction'); return openTxInExplorer(txId); }; const transactionList = ( <> <TransactionList txCount={txCount} loading={loadingTxs} node={activeNode} error={txListFetchError} > {pendingTxs.map(pendingTxs => ( <TransactionListItemMempool address={address} domNodeMapRef={txDomNodeRefMap} activeTxIdRef={focusedTxIdRef} key={pendingTxs.tx_id} tx={pendingTxs} onSelectTx={openTxInExplorerTracked} /> ))} {txs.map(tx => ( <TransactionListItem domNodeMapRef={txDomNodeRefMap} activeTxIdRef={focusedTxIdRef} key={tx.tx.tx_id} txWithEvents={tx} onSelectTx={openTxInExplorerTracked} /> ))} </TransactionList> </> ); const balanceCard = ( <BalanceCard address={address} onSelectSend={() => dispatch(homeActions.openTxModal())} onSelectReceive={() => dispatch(homeActions.openReceiveModal())} onRequestTestnetStx={async ({ stacking }) => api.getFaucetStx(address, stacking)} /> ); // const stackingCardMap: Record<HomeCardState, JSX.Element> = { // [HomeCardState.LoadingResources]: ( // <> // <StackingPromoCard /> // <StackingLoading /> // </> // ), // [HomeCardState.NotEnoughStx]: <StackingPromoCard />, // [HomeCardState.EligibleToParticipate]: <StackingPromoCard />, // [HomeCardState.StackingPendingContactCall]: <StackingLoading />, // [HomeCardState.StackingPreCycle]: ( // <StackingBeginsSoonCard blocksTillNextCycle={stackerInfo?.blocksUntilStackingCycleBegins} /> // ), // [HomeCardState.StackingActive]: <StackingCard />, // [HomeCardState.StackingError]: <StackingError />, // [HomeCardState.PostStacking]: <></>, // }; const stackingRewardCard = ( <StackingRewardCard lifetime="0.0281 Bitcoin (sample)" lastCycle="0.000383 Bitcoin (sample)" /> ); return ( <> <ReceiveStxModal isOpen={receiveModalOpen} /> <SendStxModal isOpen={txModalOpen} balance={availableBalance.toString()} address={address} /> {revokeDelegationModalOpen && <RevokeDelegationModal />} <HomeLayout transactionList={transactionList} balanceCard={balanceCard} stackingCard={<StackingPromoCard />} stackingRewardCard={stackingRewardCard} /> <Switch> <Route exact path={routes.HOME_REQUEST_DIAGNOSTICS} component={RequestDiagnosticsModal} /> </Switch> </> ); }; |