diff --git a/packages/page-calendar/src/DayItem.tsx b/packages/page-calendar/src/DayItem.tsx index c70fe6f704..189dd96cb8 100644 --- a/packages/page-calendar/src/DayItem.tsx +++ b/packages/page-calendar/src/DayItem.tsx @@ -40,7 +40,7 @@ function DayItem ({ className, item: { date, info, type } }: Props): React.React ?
{t('via Democracy')}
: ['societyChallenge', 'societyRotate'].includes(type) ?
{t('via Society')}
- : ['stakingEra', 'stakingSession'].includes(type) + : ['stakingEpoch', 'stakingEra'].includes(type) ?
{t('via Staking')}
: ['stakingSlash'].includes(type) ?
{t('via Staking/Slashed')}
@@ -74,12 +74,12 @@ function DayItem ({ className, item: { date, info, type } }: Props): React.React : t('Execute anonymous scheduled task') }{typeLink}; + case 'stakingEpoch': + return <>
{t('Start of a new staking session {{id}}', { replace: { id } })}
{typeLink}; + case 'stakingEra': return <>
{t('Start of a new staking era {{id}}', { replace: { id } })}
{typeLink}; - case 'stakingSession': - return <>
{t('Start of a new staking session {{id}}', { replace: { id } })}
{typeLink}; - case 'stakingSlash': return <>
{t('Application of slashes from era {{id}}', { replace: { id } })}
{typeLink}; diff --git a/packages/page-calendar/src/types.ts b/packages/page-calendar/src/types.ts index b6cee79da2..eb5319d158 100644 --- a/packages/page-calendar/src/types.ts +++ b/packages/page-calendar/src/types.ts @@ -4,7 +4,7 @@ import BN from 'bn.js'; -export type EntryType = 'councilElection' | 'councilMotion' | 'democracyDispatch' | 'democracyLaunch' | 'referendumDispatch' | 'referendumVote' | 'scheduler' | 'societyChallenge' | 'societyRotate'| 'stakingEra' | 'stakingSession' | 'stakingSlash' | 'treasurySpend'; +export type EntryType = 'councilElection' | 'councilMotion' | 'democracyDispatch' | 'democracyLaunch' | 'referendumDispatch' | 'referendumVote' | 'scheduler' | 'societyChallenge' | 'societyRotate'| 'stakingEpoch' | 'stakingEra' | 'stakingSlash' | 'treasurySpend'; export interface EntryInfo { blockNumber: BN; diff --git a/packages/page-calendar/src/useScheduled.ts b/packages/page-calendar/src/useScheduled.ts index 83ac3a4812..7aebdd53d0 100644 --- a/packages/page-calendar/src/useScheduled.ts +++ b/packages/page-calendar/src/useScheduled.ts @@ -21,8 +21,8 @@ type SlashEntry = [{ args: [EraIndex] }, UnappliedSlash[]]; type ScheduleEntry = [{ args: [BlockNumber] }, Option[]]; -function newDate (remaining: BN, blockTime: number): DateExt { - const date = new Date(Date.now() + remaining.muln(blockTime).toNumber()); +function newDate (blocks: BN, blockTime: number): DateExt { + const date = new Date(Date.now() + blocks.muln(blockTime).toNumber()); return { date, dateTime: date.getTime() }; } @@ -106,8 +106,8 @@ function createReferendums (bestNumber: BlockNumber, blockTime: number, referend } function createStakingInfo (bestNumber: BlockNumber, blockTime: number, sessionInfo: DeriveSessionProgress, unapplied: SlashEntry[], slashDeferDuration?: BlockNumber): [EntryType, EntryInfo[]][] { - const remainingEra = sessionInfo.eraLength.sub(sessionInfo.eraProgress); - const remainingSes = sessionInfo.sessionLength.sub(sessionInfo.sessionProgress); + const blocksEra = sessionInfo.eraLength.sub(sessionInfo.eraProgress); + const blocksSes = sessionInfo.sessionLength.sub(sessionInfo.sessionProgress); const slashDuration = slashDeferDuration?.mul(sessionInfo.eraLength); const slashEras = slashDuration ? unapplied @@ -128,20 +128,20 @@ function createStakingInfo (bestNumber: BlockNumber, blockTime: number, sessionI : []; return [ + ['stakingEpoch', [{ + ...newDate(blocksSes, blockTime), + blockNumber: bestNumber.add(blocksSes), + blocks: blocksSes, + info: sessionInfo.currentIndex.add(BN_ONE), + type: 'stakingEpoch' + }]], ['stakingEra', [{ - ...newDate(remainingEra, blockTime), - blockNumber: bestNumber.add(remainingEra), - blocks: remainingEra, + ...newDate(blocksEra, blockTime), + blockNumber: bestNumber.add(blocksEra), + blocks: blocksEra, info: sessionInfo.activeEra.add(BN_ONE), type: 'stakingEra' }]], - ['stakingSession', [{ - ...newDate(remainingSes, blockTime), - blockNumber: bestNumber.add(remainingSes), - blocks: remainingSes, - info: sessionInfo.currentIndex.add(BN_ONE), - type: 'stakingSession' - }]], ['stakingSlash', slashEras] ]; }