diff --git a/packages/page-broker/src/Overview/Summary.tsx b/packages/page-broker/src/Overview/Summary.tsx index ba9d05c2fefa..82310871d2be 100644 --- a/packages/page-broker/src/Overview/Summary.tsx +++ b/packages/page-broker/src/Overview/Summary.tsx @@ -109,7 +109,7 @@ function Summary ({ coreCount, workloadInfos }: Props): React.ReactElement { <>
{estimateTime(currentRegionStart, status?.lastTimeslice * 80, coretimeConstants?.relay)}
@@ -118,7 +118,7 @@ function Summary ({ coreCount, workloadInfos }: Props): React.ReactElement {
{currentRegionStart}
diff --git a/packages/page-coretime/src/CoretimeContext.tsx b/packages/page-coretime/src/CoretimeContext.tsx index 353ae0587549..5ca71de1f0bb 100644 --- a/packages/page-coretime/src/CoretimeContext.tsx +++ b/packages/page-coretime/src/CoretimeContext.tsx @@ -24,10 +24,10 @@ const CoretimeContext = createContext({ export const CoretimeProvider = ({ api, children, isApiReady }: { - children: ReactNode; - api: ApiPromise; - isApiReady: boolean; - }) => { + children: ReactNode; + api: ApiPromise; + isApiReady: boolean; +}) => { const coretimeInfo = useCoretimeInformation(api, isApiReady); const get = useMemo(() => { if (coretimeInfo?.constants) { diff --git a/packages/page-coretime/src/Overview/Summary.tsx b/packages/page-coretime/src/Overview/Summary.tsx index 8eaf407b4d31..cd733b6fa7ea 100644 --- a/packages/page-coretime/src/Overview/Summary.tsx +++ b/packages/page-coretime/src/Overview/Summary.tsx @@ -24,7 +24,7 @@ interface Props { constants: ChainConstants } -function Summary({ chainName, config, constants, parachainCount, saleInfo, status }: Props): React.ReactElement { +function Summary ({ chainName, config, constants, parachainCount, saleInfo, status }: Props): React.ReactElement { const { t } = useTranslation(); const currentRegionEnd = saleInfo.regionEnd - config.regionLength; const currentRegionStart = saleInfo.regionEnd - config.regionLength * 2; diff --git a/packages/page-coretime/src/Sale/SaleDetailsView.tsx b/packages/page-coretime/src/Sale/SaleDetailsView.tsx index 968d77bdee31..d027206b74bc 100644 --- a/packages/page-coretime/src/Sale/SaleDetailsView.tsx +++ b/packages/page-coretime/src/Sale/SaleDetailsView.tsx @@ -1,8 +1,15 @@ -import { styled } from "@polkadot/react-components"; -import { PhaseName } from "../constants.js"; -import PhaseTable from "./PhaseTable.js"; -import { ChainName, SaleParameters } from "../types.js"; -import { SubScanButton } from "./SubScanButton.js"; +// Copyright 2017-2025 @polkadot/app-coretime authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { ChainName, SaleParameters } from '../types.js'; + +import React from 'react'; + +import { styled } from '@polkadot/react-components'; + +import { PhaseName } from '../constants.js'; +import PhaseTable from './PhaseTable.js'; +import { SubScanButton } from './SubScanButton.js'; const ResponsiveContainer = styled.div` display: flex; @@ -19,88 +26,101 @@ const Title = styled.h3` margin-bottom: 1rem; `; -const LinkWithLogo = ({ href, logo, alt }: { href: string, logo: string, alt: string }) => { - return ( - {alt} - ) -} +const LinkWithLogo = ({ alt, href, logo }: { href: string, logo: string, alt: string }) => { + return ( + + {alt} + + ); +}; const providers = { - regionx: { - href: 'https://app.regionx.tech/?network=${chainName}', - logo: 'https://app.regionx.tech/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Flogo.8f0fd171.png&w=3840&q=75', - alt: 'RegionX' - }, - subscan: { - href: 'https://coretime-${chainName}.subscan.io/coretime_dashboard', - logo: 'https://www.subscan.io/_next/image?url=%2Fwebsite%2Flogo-light.png&w=256&q=75', - alt: 'Subscan' - }, - lastic: { - href: 'https://www.lastic.xyz/${chainName}/bulkcore1', - logo: 'https://www.lastic.xyz/_next/image?url=%2Fassets%2FImages%2FLogos%2Flastic-logo.png&w=384&q=100', - alt: 'Lastic' - } -} + lastic: { + alt: 'Lastic', + href: (chainName: string) => `https://www.lastic.xyz/${chainName}/bulkcore1`, + logo: 'https://www.lastic.xyz/_next/image?url=%2Fassets%2FImages%2FLogos%2Flastic-logo.png&w=384&q=100' + }, + regionx: { + alt: 'RegionX', + href: (chainName: string) => `https://app.regionx.tech/?network=${chainName}`, + logo: 'https://app.regionx.tech/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Flogo.8f0fd171.png&w=3840&q=75' + }, + subscan: { + alt: 'Subscan', + href: (chainName: string) => `https://coretime-${chainName}.subscan.io/coretime_dashboard`, + logo: 'https://www.subscan.io/_next/image?url=%2Fwebsite%2Flogo-light.png&w=256&q=75' + } +}; const phases = { - [PhaseName.Renewals]: { - name: 'Interlude/Renewals phase', - description: 'In this phase, core owners can renew existing cores at a fixed price to ensure continued operation in the next region. No new core purchases are permitted.' - }, - [PhaseName.PriceDiscovery]: { - name: 'Price Discovery phase', - description: 'The period during which cores are available for both purchase and renewal. The price is linearly declining price.' - }, - [PhaseName.FixedPrice]: { - name: 'Fixed price phase', - description: 'The period during which cores are available for both purchase and renewal. The price is fixed price towards the end of the sales period.' - } -} - -const SaleDetailsView = ({ saleParams, chosenSaleNumber, chainName }: { saleParams: SaleParameters, chosenSaleNumber: number, chainName: ChainName }) => { + [PhaseName.Renewals]: { + description: 'In this phase, core owners can renew existing cores at a fixed price to ensure continued operation in the next region. No new core purchases are permitted.', + name: 'Interlude/Renewals phase' + }, + [PhaseName.PriceDiscovery]: { + description: 'The period during which cores are available for both purchase and renewal. The price is linearly declining price.', + name: 'Price Discovery phase' + }, + [PhaseName.FixedPrice]: { + description: 'The period during which cores are available for both purchase and renewal. The price is fixed price towards the end of the sales period.', + name: 'Fixed price phase' + } +}; - if (chosenSaleNumber === -1 || !saleParams) { - return null; - } +const SaleDetailsView = ({ chainName, chosenSaleNumber, saleParams }: { saleParams: SaleParameters, chosenSaleNumber: number, chainName: ChainName }) => { + if (chosenSaleNumber === -1 || !saleParams) { + return null; + } - return ( - -
- Sale #{chosenSaleNumber + 1} phases -
- {Object.entries(phases).map(([phase, { name, description }]) => ( -
-

{name}

-

{description}

- {saleParams?.phaseConfig && + return ( + +
+ Sale #{chosenSaleNumber + 1} phases +
+ {Object.entries(phases).map(([phase, { description, name }]) => ( +
+

{name}

+

{description}

+ {saleParams?.phaseConfig && } -
- ))} -
-
- -
- Sale #{chosenSaleNumber + 1} Transactions - - - Region for sale #${chosenSaleNumber + 1} -

Region is an asset of Coretime. It signifies the upcoming sales period within which a core can be secured by purchasing coretime. Acquiring coretime grants access to a core for the duration of that specific region.

- {saleParams?.regionForSale && } - - Coretime providers -
- {Object.entries(providers).map(([provider, { href, logo, alt }]) => ( - - ))} -
-
- ) + ))} +
+
+
+ Sale #{chosenSaleNumber + 1} Transactions + + Region for sale #${chosenSaleNumber + 1} +

Region is an asset of Coretime. It signifies the upcoming sales period within which a core can be secured by purchasing coretime. Acquiring coretime grants access to a core for the duration of that specific region.

+ {saleParams?.regionForSale && } + Coretime providers +
+ {Object.entries(providers).map(([provider, { alt, href, logo }]) => ( + + ))} +
+
+ + ); }; - - -export default SaleDetailsView; \ No newline at end of file +export default SaleDetailsView; diff --git a/packages/page-coretime/src/Sale/SubScanButton.tsx b/packages/page-coretime/src/Sale/SubScanButton.tsx index f65a38d862ca..552701c0606d 100644 --- a/packages/page-coretime/src/Sale/SubScanButton.tsx +++ b/packages/page-coretime/src/Sale/SubScanButton.tsx @@ -1,27 +1,32 @@ -import { Button } from "@polkadot/react-components" -import { useCallback } from "react"; -import { constructSubscanQuery } from "../utils/index.js"; -import { SaleParameters } from "../types.js"; -import { useTranslation } from '../translate.js'; +// Copyright 2017-2025 @polkadot/app-coretime authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { SaleParameters } from '../types.js'; + +import React, { useCallback } from 'react'; -export const SubScanButton = ({ chosenSaleNumber, currentRegion, chainName }: { chosenSaleNumber: number, currentRegion: SaleParameters['currentRegion'], chainName: string }) => { - const { t } = useTranslation(); - const onQuerySaleClick = useCallback(() => { - if (currentRegion) { - window.open(constructSubscanQuery(currentRegion.start.blocks.coretime, currentRegion.end.blocks.coretime, chainName)); - } - }, [currentRegion, chainName]); +import { Button } from '@polkadot/react-components'; + +import { useTranslation } from '../translate.js'; +import { constructSubscanQuery } from '../utils/index.js'; - if (chosenSaleNumber === -1 || !currentRegion) { - return null; +export const SubScanButton = ({ chainName, chosenSaleNumber, currentRegion }: { chosenSaleNumber: number, currentRegion: SaleParameters['currentRegion'], chainName: string }) => { + const { t } = useTranslation(); + const onQuerySaleClick = useCallback(() => { + if (currentRegion) { + window.open(constructSubscanQuery(currentRegion.start.blocks.coretime, currentRegion.end.blocks.coretime, chainName)); } + }, [currentRegion, chainName]); - return ( -
} */} - - ) + + ); }; diff --git a/packages/page-coretime/src/Sale/boxes/Region.tsx b/packages/page-coretime/src/Sale/boxes/Region.tsx index 1bd3f6fe6b34..69dd2520653c 100644 --- a/packages/page-coretime/src/Sale/boxes/Region.tsx +++ b/packages/page-coretime/src/Sale/boxes/Region.tsx @@ -1,22 +1,30 @@ -import { WhiteBox } from "../../WhiteBox.js"; +// Copyright 2017-2025 @polkadot/app-coretime authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import type { SaleParameters } from 'page-coretime/src/types.js'; + +import React from 'react'; + import { formatNumber } from '@polkadot/util'; -export const Region = ({ regionForSale }: { regionForSale: any }) => { - return ( - -

Region for sale

- {regionForSale && +import { WhiteBox } from '../../WhiteBox.js'; + +export const Region = ({ regionForSale }: { regionForSale: SaleParameters['regionForSale'] }) => { + return ( + +

Region for sale

+ {regionForSale &&
-
-

date period

-

{regionForSale.start.date} - {regionForSale.end.date}

-
-
-

relay chain blocks

-

{formatNumber(regionForSale.start.blocks)} - {formatNumber(regionForSale.end.blocks)}

-
+
+

date period

+

{regionForSale.start.date} - {regionForSale.end.date}

+
+
+

relay chain blocks

+

{formatNumber(regionForSale.start.blocks)} - {formatNumber(regionForSale.end.blocks)}

+
} -
- ) -} \ No newline at end of file +
+ ); +}; diff --git a/packages/page-coretime/src/Sale/boxes/Timeline.tsx b/packages/page-coretime/src/Sale/boxes/Timeline.tsx index 6b44070ae589..bd4b1028d565 100644 --- a/packages/page-coretime/src/Sale/boxes/Timeline.tsx +++ b/packages/page-coretime/src/Sale/boxes/Timeline.tsx @@ -1,42 +1,45 @@ -import { SummaryBox } from "@polkadot/react-components" +// Copyright 2017-2025 @polkadot/app-coretime authors & contributors +// SPDX-License-Identifier: Apache-2.0 -import { CardSummary } from "@polkadot/react-components" +import type { SaleParameters } from 'page-coretime/src/types.js'; +import type { ProgressBarSection } from '@polkadot/react-components/types'; +import type { CoretimeInformation } from '@polkadot/react-hooks/types'; -import { ProgressBar } from "@polkadot/react-components" -import { ProgressBarSection } from "@polkadot/react-components/types"; -import { CoretimeInformation } from "@polkadot/react-hooks/types"; +import React, { useMemo } from 'react'; + +import { CardSummary, ProgressBar, SummaryBox } from '@polkadot/react-components'; import { formatBalance, formatNumber } from '@polkadot/util'; -import { getSaleProgress } from "../../utils/sale.js"; -import { WhiteBox } from "../../WhiteBox.js"; -import { useMemo } from "react"; -export const Timeline = ({ phaseName, saleParams, coretimeInfo: { salesInfo, status } }: { phaseName: string, saleParams: any, coretimeInfo: { salesInfo: CoretimeInformation['salesInfo'], status: CoretimeInformation['status'] } }) => { - const progressValues = useMemo(() => saleParams && salesInfo.regionBegin && +import { getSaleProgress } from '../../utils/sale.js'; +import { WhiteBox } from '../../WhiteBox.js'; + +export const Timeline = ({ coretimeInfo: { salesInfo, status }, phaseName, saleParams }: { phaseName: string, saleParams: SaleParameters, coretimeInfo: { salesInfo: CoretimeInformation['salesInfo'], status: CoretimeInformation['status'] } }) => { + const progressValues = useMemo(() => saleParams && salesInfo.regionBegin && getSaleProgress( - status.lastTimeslice, - saleParams.currentRegion.start.ts, - saleParams.interlude.ts, - saleParams.leadin.ts, - salesInfo.regionBegin), - [saleParams, status.lastTimeslice, salesInfo.regionBegin]); + status.lastTimeslice, + saleParams.currentRegion.start.ts, + saleParams.interlude.ts, + saleParams.leadin.ts, + salesInfo.regionBegin), + [saleParams, status.lastTimeslice, salesInfo.regionBegin]); - return ( - -

Sale timeline

- -
- {phaseName && <> - {phaseName} - {saleParams?.phaseConfig?.config[phaseName].end.date} - {formatNumber(saleParams?.phaseConfig?.config[phaseName].end.blocks.relay)} - } - {formatBalance(salesInfo.endPrice)} -
-
+ return ( + +

Sale timeline

+ +
+ {phaseName && <> + {phaseName} + {saleParams?.phaseConfig?.config[phaseName as keyof typeof saleParams.phaseConfig.config].end.date} + {formatNumber(saleParams?.phaseConfig?.config[phaseName as keyof typeof saleParams.phaseConfig.config].end.blocks.relay)} + } + {formatBalance(salesInfo.endPrice)} +
+
-
-
- -
- ) -} \ No newline at end of file +
+
+ +
+ ); +}; diff --git a/packages/page-coretime/src/Sale/index.tsx b/packages/page-coretime/src/Sale/index.tsx index aad4b740be36..22fe057e3085 100644 --- a/packages/page-coretime/src/Sale/index.tsx +++ b/packages/page-coretime/src/Sale/index.tsx @@ -1,7 +1,7 @@ // Copyright 2017-2025 @polkadot/app-coretime authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { ChainName, SaleDetails, SaleParameters } from '../types.js'; +import type { ChainName, SaleParameters } from '../types.js'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; @@ -11,17 +11,18 @@ import { useApi } from '@polkadot/react-hooks'; import { useCoretimeContext } from '../CoretimeContext.js'; import { useTranslation } from '../translate.js'; import { getSaleParameters } from '../utils/sale.js'; -import Summary from './Summary.js'; -import SaleDetailsView from './SaleDetailsView.js'; import { Cores } from './boxes/Cores.js'; import { Region } from './boxes/Region.js'; import { Timeline } from './boxes/Timeline.js'; +import SaleDetailsView from './SaleDetailsView.js'; +import Summary from './Summary.js'; interface Props { chainName: ChainName } -function Sale({ chainName }: Props): React.ReactElement { - const { coretimeInfo, get } = useCoretimeContext(); + +function Sale ({ chainName }: Props): React.ReactElement { + const { coretimeInfo } = useCoretimeContext(); const { api, isApiReady } = useApi(); const { t } = useTranslation(); const lastCommittedTimeslice = coretimeInfo?.status?.lastTimeslice; @@ -29,7 +30,7 @@ function Sale({ chainName }: Props): React.ReactElement { const saleParams = coretimeInfo && getSaleParameters( coretimeInfo, chainName, - lastCommittedTimeslice ?? 0, + lastCommittedTimeslice ?? 0 ); const phaseName = useMemo(() => saleParams?.phaseConfig?.currentPhaseName, [saleParams]); @@ -47,7 +48,7 @@ function Sale({ chainName }: Props): React.ReactElement { })).reverse() ] - , [saleParams, t]); + , [saleParams, t]); useEffect(() => { if (saleNumberOptions.length > 1 && chosenSaleNumber === -1) { @@ -60,11 +61,13 @@ function Sale({ chainName }: Props): React.ReactElement { const onDropDownChange = useCallback((value: number) => { setChosenSaleNumber(value); + if (value !== -1) { if (!coretimeInfo) { return; } - setSelectedSaleParams(getSaleParameters(coretimeInfo, chainName, lastCommittedTimeslice ?? 0, value)) + + setSelectedSaleParams(getSaleParameters(coretimeInfo, chainName, lastCommittedTimeslice ?? 0, value)); } }, [coretimeInfo, chainName, lastCommittedTimeslice]); @@ -82,12 +85,18 @@ function Sale({ chainName }: Props): React.ReactElement { />}
- {phaseName && } - + {phaseName && + } {saleParams?.regionForSale && } - - {phaseName && coretimeInfo && } - + {phaseName && coretimeInfo && + }

Sale information

@@ -100,7 +109,12 @@ function Sale({ chainName }: Props): React.ReactElement { value={chosenSaleNumber} />
- {saleParams && } + {saleParams && + }
diff --git a/packages/page-coretime/src/WhiteBox.tsx b/packages/page-coretime/src/WhiteBox.tsx index c71f15874a54..221462c86205 100644 --- a/packages/page-coretime/src/WhiteBox.tsx +++ b/packages/page-coretime/src/WhiteBox.tsx @@ -1,5 +1,10 @@ -export const WhiteBox = ({ children }: { children: React.ReactNode }) => { - return
- {children} -
-}; \ No newline at end of file +// Copyright 2017-2025 @polkadot/app-coretime authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +import React, { type ReactNode } from 'react'; + +export const WhiteBox = ({ children }: { children: ReactNode }) => { + return
+ {children} +
; +}; diff --git a/packages/page-coretime/src/types.ts b/packages/page-coretime/src/types.ts index e917606697db..10a24184d0ee 100644 --- a/packages/page-coretime/src/types.ts +++ b/packages/page-coretime/src/types.ts @@ -38,8 +38,8 @@ export interface PhaseProgress { export interface SaleParameters { currentRegion: { - start: { date: string, ts: number; blocks: number }; - end: { date: string, ts: number; blocks: number }; + start: { date: string, ts: number; blocks: { coretime: number, relay: number } }; + end: { date: string, ts: number; blocks: { coretime: number, relay: number } }; }; regionForSale: { start: { date: string, ts: number; blocks: number }; @@ -83,3 +83,14 @@ export interface RegionInfo { } export type ChainName = 'kusama' | 'polkadot' | 'paseo testnet' | 'westend' + +export interface GetResponse { + blocks: { + coretime: (ts: number) => number; + relay: (ts: number) => number; + }; + timeslices: { + coretime: (blocks: number) => number; + relay: (blocks: number) => number; + }; +} diff --git a/packages/page-coretime/src/utils/index.ts b/packages/page-coretime/src/utils/index.ts index 634e5d56dc47..f730a36b1998 100644 --- a/packages/page-coretime/src/utils/index.ts +++ b/packages/page-coretime/src/utils/index.ts @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import type { ChainBlockConstants, ChainConstants, CoretimeInformation } from '@polkadot/react-hooks/types'; -import type { ChainName, RegionInfo } from '../types.js'; +import type { ChainName, GetResponse, RegionInfo } from '../types.js'; import { BN } from '@polkadot/util'; @@ -94,7 +94,7 @@ export const estimateTime = ( * * @returns An object containing blocks and timeslices conversion functions. */ -export const createGet = (constants: ChainConstants) => ({ +export const createGet = (constants: ChainConstants): GetResponse => ({ blocks: { /** * Convert timeslices to Coretime blocks. diff --git a/packages/page-coretime/src/utils/sale.ts b/packages/page-coretime/src/utils/sale.ts index a63efabf9941..47201efc0e2b 100644 --- a/packages/page-coretime/src/utils/sale.ts +++ b/packages/page-coretime/src/utils/sale.ts @@ -3,6 +3,7 @@ import type { ChainConstants, PalletBrokerConfigRecord, PalletBrokerSaleInfoRecord } from '@polkadot/react-hooks/types'; import type { ChainName, PhaseConfig, RegionInfo, SaleParameters } from '../types.js'; +import type { GetResponse } from './index.js'; import { type ProgressBarSection } from '@polkadot/react-components/types'; import { BN } from '@polkadot/util'; @@ -10,7 +11,6 @@ import { BN } from '@polkadot/util'; import { PhaseName } from '../constants.js'; import { createGet, estimateTime, FirstCycleStart, getCurrentRegionStartEndTs } from './index.js'; - // We are scaling everything to avoid floating point precision issues. const SCALE = new BN(10000); @@ -129,17 +129,8 @@ export const getSaleProgress = ( ]; }; -const makeConfig = (startTs: number, endTs: number, get: any, getDate: (ts: number) => string | null, phaseName?: typeof PhaseName[keyof typeof PhaseName]) => { +const makeConfig = (startTs: number, endTs: number, get: GetResponse, getDate: (ts: number) => string | null, phaseName?: typeof PhaseName[keyof typeof PhaseName]) => { return { - name: phaseName ?? "", - start: { - blocks: { - coretime: get.blocks.coretime(startTs), - relay: get.blocks.relay(startTs) - }, - date: getDate(startTs), - ts: startTs - }, end: { blocks: { coretime: get.blocks.coretime(endTs), @@ -147,7 +138,17 @@ const makeConfig = (startTs: number, endTs: number, get: any, getDate: (ts: numb }, date: getDate(endTs), ts: endTs + }, + name: phaseName ?? '', + start: { + blocks: { + coretime: get.blocks.coretime(startTs), + relay: get.blocks.relay(startTs) + }, + date: getDate(startTs), + ts: startTs } + }; }; @@ -157,14 +158,15 @@ const getPhaseConfiguration = ( interludeLengthTs: number, leadInLengthTs: number, lastCommittedTimeslice: number, - constants: ChainConstants, + constants: ChainConstants ): PhaseConfig => { const renewalsEndTs = currentRegionStart + interludeLengthTs; const priceDiscoveryEndTs = renewalsEndTs + leadInLengthTs; const fixedPriceLengthTs = regionLength - interludeLengthTs - leadInLengthTs; const fixedPriceEndTs = priceDiscoveryEndTs + fixedPriceLengthTs; const get = createGet(constants); - const getDate = (ts: number) => estimateTime(ts, get.blocks.relay(lastCommittedTimeslice) ?? 0, constants.relay); + const getDate = (ts: number) => estimateTime(ts, get.blocks.relay(lastCommittedTimeslice) ?? 0, constants.relay); + return { config: { [PhaseName.FixedPrice]: makeConfig(fixedPriceEndTs, fixedPriceEndTs, get, getDate, PhaseName.FixedPrice), @@ -176,7 +178,7 @@ const getPhaseConfiguration = ( }; export const getSaleParameters = ( - { salesInfo, config, constants} : {salesInfo: RegionInfo, config: Pick, constants: ChainConstants}, + { config, constants, salesInfo }: {salesInfo: RegionInfo, config: Pick, constants: ChainConstants}, chainName: ChainName, lastCommittedTimeslice: number, chosenSaleNumber?: number @@ -186,13 +188,13 @@ export const getSaleParameters = ( const interludeLengthTs = get.timeslices.coretime(config.interludeLength); const leadInLengthTs = get.timeslices.coretime(config.leadinLength); const { currentRegionEndTs, currentRegionStartTs } = getCurrentRegionStartEndTs(salesInfo, config.regionLength); - const getDate = (ts: number) => estimateTime(ts, get.blocks.relay(lastCommittedTimeslice), constants.relay); + const getDate = (ts: number) => estimateTime(ts, get.blocks.relay(lastCommittedTimeslice), constants.relay) || ''; let regionStartTs = currentRegionStartTs; let regionEndTs = currentRegionEndTs; const saleNumber = getCurrentSaleNumber(currentRegionEndTs, chainName, config); - let currentRegionInfo; + let currentRegionInfo: SaleParameters['currentRegion']; if (chosenSaleNumber) { const blocksPerSaleRelay = get.blocks.relay(config.regionLength); @@ -204,41 +206,39 @@ export const getSaleParameters = ( const saleStartBlockCoretime = FirstCycleStart.block.coretime[chainName] + get.blocks.coretime((chosenSaleNumber) * config.regionLength); const saleEndBlockCoretime = saleStartBlockCoretime + get.blocks.coretime(config.regionLength); - + regionStartTs = currentRegionStartTs + get.blocks.coretime(config.regionLength * (chosenSaleNumber - 1)); regionEndTs = regionStartTs + get.blocks.coretime(config.regionLength); currentRegionInfo = { end: { blocks: { - relay: get.blocks.relay(regionEndTs), - coretime: saleEndBlockCoretime + coretime: saleEndBlockCoretime, + relay: get.blocks.relay(regionEndTs) }, date: getDate(regionEndTs), ts: saleEndTs }, start: { blocks: { - relay: get.blocks.relay(regionStartTs), - coretime: saleStartBlockCoretime + coretime: saleStartBlockCoretime, + relay: get.blocks.relay(regionStartTs) }, date: getDate(regionStartTs), ts: saleStartTs } }; - } else { - currentRegionInfo = makeConfig(regionStartTs, regionEndTs, get, getDate); + currentRegionInfo = makeConfig(regionStartTs, regionEndTs, get, getDate) as SaleParameters['currentRegion']; } - const phaseConfig = getPhaseConfiguration( regionStartTs, config.regionLength, interludeLengthTs, leadInLengthTs, lastCommittedTimeslice, - constants, + constants ); return { @@ -266,4 +266,4 @@ export const getSaleParameters = ( }, saleNumber }; -}; \ No newline at end of file +};