Skip to content

front: validator_prefs + era_exposure sections on Polkadot detail page#26

Merged
simonmorley merged 1 commit into
mainfrom
dot-enrichment
Apr 25, 2026
Merged

front: validator_prefs + era_exposure sections on Polkadot detail page#26
simonmorley merged 1 commit into
mainfrom
dot-enrichment

Conversation

@simonmorley
Copy link
Copy Markdown
Member

Summary

`PolkadotChainSections` now renders three Sections when chain_data is populated:

  1. Active Set (existing): currently_elected + observed_at_block
  2. Validator Preferences (new): commission % + accepting-nominations (red 'No (blocked)' when `validator_prefs.blocked === true`)
  3. Era Exposure (new): era_index, total/own stake (DOT), nominator count

Helpers:

  • `planckToDot` uses `BigInt` to avoid Number's 53-bit precision ceiling (top validators' stake exceeds 2^53 planck).
  • Each section gated on its chain_data field being non-null — graceful degradation during deploy gap and when storage row doesn't exist.

Pairs with worker PR slasher-worker#34.

Test plan

  • `npm run build`: zero TS errors
  • After both PRs deploy + worker cycle: known DOT validator detail page shows three sections with sensible values

PolkadotChainSections now renders three Sections when chain_data
is populated:

  1. Active Set (existing): currently_elected + observed_at_block
  2. Validator Preferences (new): commission % + accepting-nominations
     (red 'No (blocked)' when validator_prefs.blocked is true)
  3. Era Exposure (new): era_index, total_planck, own_planck,
     nominator_count with planckToDot conversion via BigInt to
     avoid Number's 53-bit precision ceiling

Each section gated on the corresponding chain_data field being
non-null — graceful degradation when the worker hasn't populated
yet (deploy gap) or when the storage row doesn't exist.
@simonmorley simonmorley merged commit 625b96d into main Apr 25, 2026
1 check passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request expands the Polkadot chain data display by adding sections for validator preferences (commission and status) and era exposure (stake and nominator counts). It also introduces a planckToDot utility to safely format large token values using BigInt. Feedback was provided regarding the planckToDot function, noting that hardcoding a decimal point while using localized thousands separators can lead to ambiguous formatting in certain locales.

const frac = planck % denom;
// Show 4 fractional digits — beyond that the value is noise for UI.
const fracStr = (frac / 1_000_000n).toString().padStart(4, '0');
return `${whole.toLocaleString()}.${fracStr}`;
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 planckToDot function currently mixes whole.toLocaleString() (which uses locale-specific thousands separators) with a hardcoded . decimal separator. In locales where the thousands separator is a dot (e.g., German), this produces ambiguous output like 1.234.5678.

To maintain consistency with the localized integer formatting used elsewhere in the file (via formatNumber), you should dynamically determine the decimal separator or use a fixed locale for both parts to ensure the output is clear and correctly formatted.

    const sep = new Intl.NumberFormat().formatToParts(1.1).find(p => p.type === 'decimal')?.value ?? '.';
    return `${whole.toLocaleString()}${sep}${fracStr}`;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant