Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/components/ChainDataSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
SuiChainData,
CosmosChainData,
EthereumChainData,
PolkadotChainData,
} from '@/types/api';

// --- Styles (matching ValidatorProfile patterns) ---
Expand Down Expand Up @@ -699,6 +700,38 @@ function EthereumChainSections({
);
}

function PolkadotChainSections({
data,
isMobile,
}: {
data: PolkadotChainData;
isMobile: boolean;
}) {
// Replaces the demoted dot_not_elected feed event. Badge renders
// only when the worker has populated chain_data.is_elected — during
// the deploy gap window where worker is_elected hasn't reached prod
// yet, undefined would render falsy and incorrectly show "No". Better
// to render nothing than to show wrong data.
if (typeof data.is_elected !== 'boolean') {
return null;
}
return (
<Section title="Active Set" isMobile={isMobile}>
<Field
label="Currently Elected"
value={
<span style={{ color: data.is_elected ? 'var(--color-accent)' : 'var(--color-danger)' }}>
{data.is_elected ? 'Yes' : 'No'}
</span>
}
/>
{data.observed_at_block != null && (
<Field label="Observed at Block" value={formatNumber(data.observed_at_block)} />
)}
</Section>
);
}

// --- Main export ---

interface ChainDataSectionsProps {
Expand All @@ -721,6 +754,8 @@ export function ChainDataSections({ chainData, isMobile }: ChainDataSectionsProp
return (
<EthereumChainSections data={cd as unknown as EthereumChainData} computed={computed} isMobile={isMobile} />
);
case 'polkadot':
return <PolkadotChainSections data={cd as unknown as PolkadotChainData} isMobile={isMobile} />;
default:
return null;
}
Expand Down
5 changes: 5 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ export interface EthereumChainData {
slashed: boolean;
}

export interface PolkadotChainData {
is_elected: boolean;
observed_at_block: number;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The observed_at_block field is checked for nullability in the PolkadotChainSections component (line 724), but it is defined as a non-nullable number here. To ensure type consistency with the implementation and handle cases where block data might be missing, it should be marked as nullable.

Suggested change
observed_at_block: number;
observed_at_block: number | null;

}

// --- Scan Analysis ---

export interface ScanAnalysisSummary {
Expand Down
Loading