diff --git a/packages/apps-routing/src/staking.ts b/packages/apps-routing/src/staking.ts index 184a574c14..b4a08e47ab 100644 --- a/packages/apps-routing/src/staking.ts +++ b/packages/apps-routing/src/staking.ts @@ -2,7 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import type { ApiPromise } from '@polkadot/api'; -import type { PalletStakingExposure } from '@polkadot/types/lookup'; +import type { u32, Vec } from '@polkadot/types'; +import type { PalletStakingExposure, PalletStakingStakingLedger } from '@polkadot/types/lookup'; import type { Route, TFunction } from './types.js'; import Component from '@polkadot/app-staking'; @@ -44,6 +45,19 @@ function needsApiCheck (api: ApiPromise): boolean { return false; } + try { + const v = api.registry.createType( + unwrapStorageType(api.registry, api.query.staking.ledger.creator.meta.type), + { claimedRewards: [1, 2, 3] } + ); + + assert((v as unknown as { claimedRewards: Vec }).claimedRewards.eq([1, 2, 3]), 'Needs a claimedRewards array'); + } catch { + console.warn('No known claimedRewards inside staking ledger, disabling staking route'); + + return false; + } + return true; }