mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* 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
46 lines
1.3 KiB
TypeScript
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('_', '-');
|
|
}
|