Skip to content

Commit

Permalink
add support for block hash and extrinsic hash dynamic route
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusDesk committed Nov 15, 2024
1 parent 462ce67 commit 8e9c195
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion explorer/src/components/Consensus/Block/Block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const Block: FC = () => {
const { loading, setIsVisible } = useSquidQuery<BlockByIdQuery, BlockByIdQueryVariables>(
QUERY_BLOCK_BY_ID,
{
variables: { blockId: blockId ?? '0' },
variables: { blockId: blockId ?? '0', blockHash: blockId?.toString() ?? '' },
skip: !inFocus,
},
Routes.consensus,
Expand Down
6 changes: 4 additions & 2 deletions explorer/src/components/Consensus/Block/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ export const QUERY_BLOCKS = gql`
`

export const QUERY_BLOCK_BY_ID = gql`
query BlockById($blockId: numeric!) {
consensus_blocks(where: { height: { _eq: $blockId } }) {
query BlockById($blockId: numeric!, $blockHash: String!) {
consensus_blocks(
where: { _or: [{ height: { _eq: $blockId } }, { hash: { _eq: $blockHash } }] }
) {
id
height
hash
Expand Down
4 changes: 3 additions & 1 deletion explorer/src/components/Consensus/Extrinsic/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export const QUERY_EXTRINSICS = gql`

export const QUERY_EXTRINSIC_BY_ID = gql`
query ExtrinsicsById($extrinsicId: String!) {
consensus_extrinsics(where: { id: { _eq: $extrinsicId } }) {
consensus_extrinsics(
where: { _or: [{ id: { _eq: $extrinsicId } }, { hash: { _eq: $extrinsicId } }] }
) {
id
index_in_block
hash
Expand Down

0 comments on commit 8e9c195

Please sign in to comment.