diff --git a/src/krist/api/types.ts b/src/krist/api/types.ts index 736004c..93e700f 100644 --- a/src/krist/api/types.ts +++ b/src/krist/api/types.ts @@ -28,8 +28,8 @@ export interface KristBlock { height: number; address: string; - hash: string; - short_hash: string; + hash?: string | null; + short_hash?: string | null; value: number; difficulty: number; time: string; diff --git a/src/pages/blocks/BlockHash.tsx b/src/pages/blocks/BlockHash.tsx index 0003cc5..da55526 100644 --- a/src/pages/blocks/BlockHash.tsx +++ b/src/pages/blocks/BlockHash.tsx @@ -14,15 +14,17 @@ const SHORT_HASH_LENGTH = 12; interface Props { - hash: string; + hash?: string | null; alwaysCopyable?: boolean; neverCopyable?: boolean; className?: string; } -export function BlockHash({ hash, alwaysCopyable, neverCopyable, className }: Props): JSX.Element { +export function BlockHash({ hash, alwaysCopyable, neverCopyable, className }: Props): JSX.Element | null { const blockHashCopyButtons = useBooleanSetting("blockHashCopyButtons"); + if (hash === undefined || hash === null) return null; + // If the hash is longer than 12 characters (i.e. it's not just a short hash // on its own), then split it into two parts, so the short hash can be // highlighted. Otherwise, just put the whole hash in restHash.