Skip to content

Commit

Permalink
Merge branch 'staging-harmony' into production-harmony
Browse files Browse the repository at this point in the history
  • Loading branch information
DenSmolonski committed Sep 12, 2024
2 parents cb3b1da + 8a0ec04 commit df14942
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions mocks/blocks/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const base: Block = {
base_fee_per_gas: '10000000000',
burnt_fees: '5449200000000000',
burnt_fees_percentage: 20.292245650793845,
epoch: 1,
difficulty: '340282366920938463463374607431768211454',
extra_data: 'TODO',
gas_limit: '12500000',
Expand Down Expand Up @@ -57,6 +58,7 @@ export const genesis: Block = {
burnt_fees_percentage: null,
difficulty: '131072',
extra_data: 'TODO',
epoch: 0,
gas_limit: '6700000',
gas_target_percentage: -100,
gas_used: '0',
Expand Down
3 changes: 2 additions & 1 deletion stubs/RPC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const GET_BALANCE = BigInt(42_000_000_000_000);

export const GET_TRANSACTIONS_COUNT = 42;

export const GET_BLOCK: GetBlockReturnType<Chain, false, 'latest'> = {
export const GET_BLOCK: GetBlockReturnType<Chain, false, 'latest'> & { epoch: number } = {
baseFeePerGas: BigInt(11),
difficulty: BigInt(111),
extraData: '0xd8830',
Expand All @@ -76,6 +76,7 @@ export const GET_BLOCK: GetBlockReturnType<Chain, false, 'latest'> = {
receiptsRoot: BLOCK_HASH,
sha3Uncles: BLOCK_HASH,
size: BigInt(88),
epoch: 1,
stateRoot: BLOCK_HASH,
timestamp: BigInt(1628580000),
totalDifficulty: BigInt(10361367),
Expand Down
1 change: 1 addition & 0 deletions stubs/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const BLOCK: Block = {
base_fee_per_gas: '14',
burnt_fees: '92834504000000000',
burnt_fees_percentage: 42.2,
epoch: 1,
difficulty: '340282366920938463463374607431768211451',
extra_data: 'TODO',
gas_limit: '30000000',
Expand Down
1 change: 1 addition & 0 deletions types/api/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Block {
tx_count: number;
miner: AddressParam;
size: number;
epoch: number;
hash: string;
parent_hash: string;
difficulty: string;
Expand Down
9 changes: 9 additions & 0 deletions ui/block/BlockDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ const BlockDetails = ({ query }: Props) => {
{ data.size.toLocaleString() }
</Skeleton>
</DetailsInfoItem>
{ data.epoch && (
<DetailsInfoItem
title="Epoch"
hint="The epoch of the block"
isLoading={ isPlaceholderData }
>
{ data.epoch }
</DetailsInfoItem>
) }
<DetailsInfoItem
title="Timestamp"
hint="Date & time at which block was produced."
Expand Down
5 changes: 3 additions & 2 deletions ui/block/useBlockQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { BLOCK } from 'stubs/block';
import { GET_BLOCK } from 'stubs/RPC';
import { unknownAddress } from 'ui/shared/address/utils';

type RpcResponseType = GetBlockReturnType<Chain, false, 'latest'> | null;
type RpcResponseType = GetBlockReturnType<Chain, false, 'latest'> & { epoch: number } | null;

export type BlockQuery = UseQueryResult<Block, ResourceError<{ status: number }>> & {
isDegradedData: boolean;
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function useBlockQuery({ heightOrHash }: Params): BlockQuery {
}

const blockParams = heightOrHash.startsWith('0x') ? { blockHash: heightOrHash as `0x${ string }` } : { blockNumber: BigInt(heightOrHash) };
return publicClient.getBlock(blockParams).catch(() => null);
return publicClient.getBlock(blockParams).catch(() => null) as Promise<GetBlockReturnType<Chain, false, 'latest'> & { epoch: number } | null>;
},
select: (block) => {
if (!block) {
Expand All @@ -68,6 +68,7 @@ export default function useBlockQuery({ heightOrHash }: Params): BlockQuery {
tx_count: block.transactions.length,
miner: { ...unknownAddress, hash: block.miner },
size: Number(block.size),
epoch: Number(block.epoch),
hash: block.hash,
parent_hash: block.parentHash,
difficulty: block.difficulty.toString(),
Expand Down

0 comments on commit df14942

Please sign in to comment.