diff --git a/packages/page-calendar/src/DayItem.tsx b/packages/page-calendar/src/DayItem.tsx
index bf9b697ad4..938cb11d2d 100644
--- a/packages/page-calendar/src/DayItem.tsx
+++ b/packages/page-calendar/src/DayItem.tsx
@@ -25,9 +25,8 @@ const FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
year: 'numeric'
};
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-function assertUnreachable (x: never): never {
- throw new Error('We cannot get here');
+function assertUnreachable (type: string): never {
+ throw new Error(`We should not get here, unhandled ${type}`);
}
function exportCalendar (date: Date, description: string): void {
@@ -60,6 +59,10 @@ function exportCalendar (date: Date, description: string): void {
window.URL.revokeObjectURL(anchor.href);
}
+function createLink (to: string, desc: string): React.ReactNode {
+ return
;
+}
+
function DayItem ({ className, item: { date, info, type }, showAllEvents }: Props): React.ReactElement {
const { t } = useTranslation();
@@ -78,22 +81,26 @@ function DayItem ({ className, item: { date, info, type }, showAllEvents }: Prop
: formatNumber(info)
);
const typeLink = ['councilElection'].includes(type)
- ?
+ ? createLink('council', t('via Council'))
: ['councilMotion'].includes(type)
- ?
+ ? createLink('council/motions', t('via Council/Motions'))
: ['democracyDispatch', 'scheduler'].includes(type)
- ?
+ ? createLink('democracy/dispatch', t('via Democracy/Dispatch'))
: ['democracyLaunch', 'referendumDispatch', 'referendumVote'].includes(type)
- ?
+ ? createLink('/democracy', t('via Democracy'))
: ['societyChallenge', 'societyRotate'].includes(type)
- ?
+ ? createLink('society', t('via Society'))
: ['stakingEpoch', 'stakingEra'].includes(type)
- ?
+ ? createLink('staking', t('via Staking'))
: ['stakingSlash'].includes(type)
- ?
+ ? createLink('staking/slashes', t('via Staking/Slashed'))
: ['treasurySpend'].includes(type)
- ?
- : undefined;
+ ? createLink('treasury', t('via Treasury'))
+ : ['parachainLease'].includes(type)
+ ? createLink('parachains', t('via Parachains'))
+ : ['parachainAuction'].includes(type)
+ ? createLink('parachains/auction', t('via Parachains/Auction'))
+ : undefined;
let s = '';
switch (type) {
@@ -113,6 +120,14 @@ function DayItem ({ className, item: { date, info, type }, showAllEvents }: Prop
s = t('Start of the next referendum voting period');
break;
+ case 'parachainAuction':
+ s = t('End of the current parachain auction {{id}}', { replace: { id } });
+ break;
+
+ case 'parachainLease':
+ s = t('Start of the next parachain lease period {{id}}', { replace: { id } });
+ break;
+
case 'referendumDispatch':
s = t('Potential dispatch of referendum {{id}} (if passed)', { replace: { id } });
break;
diff --git a/packages/page-calendar/src/types.ts b/packages/page-calendar/src/types.ts
index 1c9ed81374..5481f01830 100644
--- a/packages/page-calendar/src/types.ts
+++ b/packages/page-calendar/src/types.ts
@@ -3,7 +3,7 @@
import type BN from 'bn.js';
-export type EntryType = 'councilElection' | 'councilMotion' | 'democracyDispatch' | 'democracyLaunch' | 'referendumDispatch' | 'referendumVote' | 'scheduler' | 'societyChallenge' | 'societyRotate'| 'stakingEpoch' | 'stakingEra' | 'stakingSlash' | 'treasurySpend';
+export type EntryType = 'councilElection' | 'councilMotion' | 'democracyDispatch' | 'democracyLaunch' | 'parachainAuction' | 'parachainLease' | '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 2bf8dbe931..ec1a0d4db0 100644
--- a/packages/page-calendar/src/useScheduled.ts
+++ b/packages/page-calendar/src/useScheduled.ts
@@ -1,16 +1,17 @@
// Copyright 2017-2021 @polkadot/app-calendar authors & contributors
// SPDX-License-Identifier: Apache-2.0
+import type BN from 'bn.js';
import type { DeriveCollectiveProposal, DeriveDispatch, DeriveReferendumExt, DeriveSessionProgress } from '@polkadot/api-derive/types';
import type { Option } from '@polkadot/types';
-import type { BlockNumber, EraIndex, Scheduled, UnappliedSlash } from '@polkadot/types/interfaces';
+import type { BlockNumber, EraIndex, LeasePeriodOf, Scheduled, UnappliedSlash } from '@polkadot/types/interfaces';
+import type { ITuple } from '@polkadot/types/types';
import type { EntryInfo, EntryInfoTyped, EntryType } from './types';
-import BN from 'bn.js';
import { useEffect, useState } from 'react';
import { useApi, useBestNumber, useBlockTime, useCall } from '@polkadot/react-hooks';
-import { BN_ONE } from '@polkadot/util';
+import { BN_ONE, BN_THREE } from '@polkadot/util';
interface DateExt {
date: Date;
@@ -39,7 +40,7 @@ function createConstDurations (bestNumber: BlockNumber, blockTime: number, items
...newDate(blocks, blockTime),
blockNumber: bestNumber.add(blocks),
blocks,
- info: null
+ info: bestNumber.div(duration)
}]];
});
}
@@ -168,6 +169,19 @@ function createScheduled (bestNumber: BlockNumber, blockTime: number, scheduled:
}, [])]];
}
+function createAuctionInfo (bestNumber: BlockNumber, blockTime: number, [leasePeriod, endBlock]: [LeasePeriodOf, BlockNumber]): [EntryType, EntryInfo[]][] {
+ const blocks = endBlock.sub(bestNumber);
+
+ return [
+ ['parachainAuction', [{
+ ...newDate(blocks, blockTime),
+ blockNumber: endBlock,
+ blocks,
+ info: `${leasePeriod.toString()} - ${leasePeriod.add(BN_THREE).toString()}`
+ }]]
+ ];
+}
+
function addFiltered (state: EntryInfoTyped[], types: [EntryType, EntryInfo[]][]): EntryInfoTyped[] {
return types.reduce((state: EntryInfoTyped[], [typeFilter, items]): EntryInfoTyped[] => {
return state
@@ -185,11 +199,12 @@ export default function useScheduled (): EntryInfo[] {
const { api } = useApi();
const [blockTime] = useBlockTime();
const bestNumber = useBestNumber();
+ const auctionInfo = useCall