Files
tom goriunovandGitHub 6112e475de Celo: support L2 epochs (#2784)
* epochs page

* epoch rewards distribution

* epoch election rewards

* address epoch rewards

* block epoch tag

* add some  tests

* adjust epoch details for L1 epochs

* support non-finalized epochs

* fixes after design review

* add truncation to block numbers on mobile

* update epochs table layout

* update timestamp hint

* fix bug with subheading of first epoch

* fixes of mobile view

* update screenshots
2025-06-30 17:44:10 +02:00

46 lines
1.3 KiB
TypeScript

import type { CeloEpochDetails } from 'types/api/epochs';
import type { ExcludeNull } from 'types/utils';
export function getRewardNumText(type: keyof CeloEpochDetails['aggregated_election_rewards'], num: number) {
const postfix1 = num !== 1 ? 's' : '';
const postfix2 = num !== 1 ? 'es' : '';
const text = (() => {
switch (type) {
case 'delegated_payment':
return 'payment' + postfix1;
case 'group':
return 'group reward' + postfix1;
case 'validator':
return 'validator' + postfix1;
case 'voter':
return 'voting address' + postfix2;
default:
return '';
}
})();
if (!text) {
return '';
}
return `${ num } ${ text }`;
}
export function getRewardDetailsTableTitles(type: keyof ExcludeNull<CeloEpochDetails['aggregated_election_rewards']>): [string, string] {
switch (type) {
case 'delegated_payment':
return [ 'Beneficiary', 'Validator' ];
case 'group':
return [ 'Validator group', 'Associated validator' ];
case 'validator':
return [ 'Validator', 'Validator group' ];
case 'voter':
return [ 'Voter', 'Validator group' ];
}
}
export function formatRewardType(type: keyof ExcludeNull<CeloEpochDetails['aggregated_election_rewards']>) {
return type.replaceAll('_', '-');
}