diff --git a/.changelog/990.feature.md b/.changelog/990.feature.md new file mode 100644 index 0000000000..9c024abc94 --- /dev/null +++ b/.changelog/990.feature.md @@ -0,0 +1 @@ +Show block-level evens in block details diff --git a/src/app/pages/BlockDetailPage/EventsCard.tsx b/src/app/pages/BlockDetailPage/EventsCard.tsx new file mode 100644 index 0000000000..8bdb253efd --- /dev/null +++ b/src/app/pages/BlockDetailPage/EventsCard.tsx @@ -0,0 +1,54 @@ +import { FC } from 'react' +import { useTranslation } from 'react-i18next' +import { ScrollingCard } from '../../components/PageLayout/ScrollingCard' +import CardHeader from '@mui/material/CardHeader' +import CardContent from '@mui/material/CardContent' + +import { Layer, useGetRuntimeEvents } from '../../../oasis-nexus/api' +import { ErrorBoundary } from '../../components/ErrorBoundary' +import { AppErrors } from '../../../types/errors' +import { SearchScope } from '../../../types/searchScope' +import { RuntimeEventsDetailedList } from '../../components/RuntimeEvents/RuntimeEventsDetailedList' +import { AddressSwitchOption } from '../../components/AddressSwitch' + +export const eventsContainerId = 'events' + +const EventsList: FC<{ scope: SearchScope; blockHeight: number }> = ({ scope, blockHeight }) => { + if (scope.layer === Layer.consensus) { + // Loading events for consensus blocks is not yet supported. + // Should use useGetConsensusEvents() + throw AppErrors.UnsupportedLayer + } + const eventsQuery = useGetRuntimeEvents(scope.network, scope.layer, { + block: blockHeight, + // TODO: search for tx_hase = null + }) + + const { isLoading, isError, data } = eventsQuery + + const events = data?.data.events.filter(event => !event.tx_hash) // TODO: remove filtering here if it's implemented using the query parameters + + return ( + + ) +} + +export const EventsCard: FC<{ scope: SearchScope; blockHeight: number }> = ({ scope, blockHeight }) => { + const { t } = useTranslation() + return ( + + + + + + + + + ) +} diff --git a/src/app/pages/BlockDetailPage/index.tsx b/src/app/pages/BlockDetailPage/index.tsx index 19211a05fd..230ac226bd 100644 --- a/src/app/pages/BlockDetailPage/index.tsx +++ b/src/app/pages/BlockDetailPage/index.tsx @@ -18,6 +18,7 @@ import { BlockLink, BlockHashLink } from '../../components/Blocks/BlockLink' import { RouteUtils } from '../../utils/route-utils' import { useRequiredScopeParam } from '../../hooks/useScopeParam' import { DashboardLink } from '../ParatimeDashboardPage/DashboardLink' +import { EventsCard } from './EventsCard' export const BlockDetailPage: FC = () => { const { t } = useTranslation() @@ -43,6 +44,7 @@ export const BlockDetailPage: FC = () => { {!!block?.num_transactions && } + ) }