From 405fb9ce309b5e762cd1254f597da3db13452606 Mon Sep 17 00:00:00 2001 From: Satoshi Qazi Muhammed Date: Mon, 12 Oct 2026 12:11:27 +0400 Subject: [PATCH] Read the active validator set from the relay session on Asset Hub staking Connected to Asset Hub, the staking page asked the relay for derive.staking.validators. The api only offers the staking derives on a chain with the staking pallet, and the Pezkuwi relay carries only stakingAhClient, so rcApi.derive.staking is undefined: the page rendered, then crashed with "reading 'validators'" once the relay api connected. Neither chain can answer that derive alone. Take the active set from the relay's session.validators (Asset Hub's session set is its collators) and the next elected set from Asset Hub, where staking lives, in the shape the derive returns. --- packages/page-staking-async/src/System/index.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/page-staking-async/src/System/index.tsx b/packages/page-staking-async/src/System/index.tsx index af5203d..9fbf90b 100644 --- a/packages/page-staking-async/src/System/index.tsx +++ b/packages/page-staking-async/src/System/index.tsx @@ -4,7 +4,7 @@ import type { ApiPromise } from '@pezkuwi/api'; import type { DeriveStakingOverview, DeriveStakingValidators } from '@pezkuwi/api-derive/types'; import type { AppProps } from '@pezkuwi/react-components/types'; -import type { ElectionStatus, ParaValidatorIndex, ValidatorId } from '@pezkuwi/types/interfaces'; +import type { AccountId, ElectionStatus, ParaValidatorIndex, ValidatorId } from '@pezkuwi/types/interfaces'; import type { BN } from '@pezkuwi/util'; import React, { useCallback, useMemo, useState } from 'react'; @@ -72,7 +72,18 @@ function StakingApp ({ ahApi, ahEndPoints, basePath, isRelayChain, rcApi, rcEndP const nominatedBy = useNominations(loadNominations); const ownPools = useOwnPools(); const ahStakingOverview = useCall(api?.derive.staking.overview); - const validatorsInfo = useCall(rcApi?.derive.staking.validators); + // derive.staking.validators pairs the session set with the next elected set, and the api + // only offers it on a chain that has the staking pallet. Here staking lives on Asset Hub and + // the relay carries only stakingAhClient, so neither chain can answer it alone: the active + // set is the relay's session set (Asset Hub's session set is its collators), the next set is + // elected on Asset Hub. + const rcValidators = useCall(rcApi?.query.session.validators); + const nextElected = useCall(api.derive.staking.nextElected); + const validatorsInfo = useMemo((): DeriveStakingValidators | undefined => ( + rcValidators && nextElected + ? { nextElected, validators: rcValidators } + : undefined + ), [nextElected, rcValidators]); const stakingOverview = useMemo(() => ( !!ahStakingOverview && !!validatorsInfo