Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/page-coretime/src/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function Row ({ chainRecord, highlight = false, id, lastCommittedTimeslice, leas
>
<span>
{estimatedTime}
{!!isWithinWeek && !isReservation && (
{!!isWithinWeek && !isReservation && chainRecord?.renewalStatus !== ChainRenewalStatus.Renewed && (
<StyledMarkWarning
content='Expires Soon'
/>
Expand All @@ -108,7 +108,7 @@ function Row ({ chainRecord, highlight = false, id, lastCommittedTimeslice, leas
<StyledCell
$p={highlight}
className='media--1200'
>{chainRecord?.renewalStatus}</StyledCell>
>{chainRecord?.renewalStatus === ChainRenewalStatus.Renewed ? chainRecord.renewalStatusMessage : chainRecord.renewalStatus}</StyledCell>
<StyledCell
$p={highlight}
className='media--1200'
Expand Down
1 change: 1 addition & 0 deletions packages/react-hooks/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export interface ChainWorkTaskInformation {
lastBlock: number
renewal: PotentialRenewal | undefined
renewalStatus: string
renewalStatusMessage: string
type: CoreTimeTypes
workload: CoreWorkload | undefined
workplan: CoreWorkplan[] | undefined
Expand Down
21 changes: 14 additions & 7 deletions packages/react-hooks/src/useCoretimeInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,30 @@ function useCoretimeInformationImpl (api: ApiPromise, ready: boolean): CoretimeI

const potentialRenewal = potentialRenewalsCurrentRegion?.find((renewal) => renewal.task.toString() === taskId);

let renewalStatus = potentialRenewal ? ChainRenewalStatus.Eligible : ChainRenewalStatus.None;
const chainRegionEnd = (renewalStatus === ChainRenewalStatus.Renewed ? salesInfo?.regionEnd : salesInfo?.regionBegin);
const targetTimeslice = lease?.until || chainRegionEnd;
const chainRenewedCore = type === CoreTimeTypes['Bulk Coretime'] && !!workplan?.length;

const lastBlock = targetTimeslice ? targetTimeslice * coretimeConstants?.relay.blocksPerTimeslice : 0;
let renewalStatus = ChainRenewalStatus.None;
let renewalStatusMessage = '';

const chainRenewedCore = type === CoreTimeTypes['Bulk Coretime'] && !!workplan?.length;
if (potentialRenewal) {
renewalStatus = ChainRenewalStatus.Eligible;
}

if (chainRenewedCore) {
renewalStatus = `Next cycle on core ${workplan[0].core}`;
renewalStatus = ChainRenewalStatus.Renewed;
renewalStatusMessage = `Next cycle on core ${workplan[0].core}`;
}

const chainRegionEnd = (renewalStatus === ChainRenewalStatus.Renewed ? salesInfo?.regionEnd : salesInfo?.regionBegin);
const targetTimeslice = lease?.until || chainRegionEnd;

const lastBlock = targetTimeslice ? targetTimeslice * coretimeConstants?.relay.blocksPerTimeslice : 0;

return {
chainRenewedCore,
lastBlock,
renewal: potentialRenewal,
renewalStatus,
renewalStatusMessage,
type,
workload,
workplan
Expand Down