Skip to content

Commit

Permalink
fix for showing expires even though chain renewed (#11353)
Browse files Browse the repository at this point in the history
  • Loading branch information
piggydoughnut authored Mar 4, 2025
1 parent 506b38c commit 2b9e019
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
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

0 comments on commit 2b9e019

Please sign in to comment.