Skip to content

Handle the case when pallet slots is not being used #11381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion packages/page-parachains/src/Overview/useParaInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function useParaInfoImpl (id: ParaId): Result {
[(api.query.parasHrmp || api.query.paraHrmp || api.query.hrmp)?.hrmpWatermarks, id],
[(api.query.parasInclusion || api.query.paraInclusion || api.query.inclusion)?.pendingAvailability, id],
[api.query.registrar.paras, id],
[api.query.slots.leases, id]
[api.query.slots?.leases, id]
], MULTI_OPTS);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/page-parachains/src/Parathreads/useParaMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function useParaMapImpl (ids?: ParaId[]): Result | undefined {
[hasLinksMap]
);

return useCall<Result>(ids && api.query.slots.leases.multi, [ids], {
return useCall<Result>(ids && api.query.slots?.leases.multi, [ids], {
transform,
withParamsTransform: true
});
Expand Down
2 changes: 1 addition & 1 deletion packages/page-parachains/src/useFunds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function useFundsImpl (): Campaigns {
const trigger = useEventTrigger([api.events.crowdloan?.Created]);
const paraIds = useMapKeys(api.query.crowdloan?.funds, [], OPT_FUNDS, trigger.blockHash);
const campaigns = useCall<Campaign[]>(api.query.crowdloan?.funds.multi, [paraIds], OPT_FUNDS_MULTI);
const leases = useCall<ParaId[]>(api.query.slots.leases.multi, [paraIds], OPT_LEASE);
const leases = useCall<ParaId[]>(api.query.slots?.leases.multi, [paraIds], OPT_LEASE);
const [result, setResult] = useState<Campaigns>(EMPTY);

// here we manually add the actual ending status and calculate the totals
Expand Down
6 changes: 3 additions & 3 deletions packages/page-parachains/src/useLeasePeriod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ function useLeasePeriodImpl (): LeasePeriod | undefined {
const bestNumber = useBestNumber();

return useMemo((): LeasePeriod | undefined => {
if (!api.consts.slots.leasePeriod || !bestNumber) {
if (!api.consts.slots?.leasePeriod || !bestNumber) {
return;
}

const length = api.consts.slots.leasePeriod as BlockNumber;
const startNumber = bestNumber.sub((api.consts.slots.leaseOffset as BlockNumber) || BN_ZERO);
const length = api.consts.slots?.leasePeriod as BlockNumber;
const startNumber = bestNumber.sub((api.consts.slots?.leaseOffset as BlockNumber) || BN_ZERO);
const progress = startNumber.mod(length);

return {
Expand Down