diff --git a/packages/page-staking/src/Suspensions/CurrentList.tsx b/packages/page-staking/src/Suspensions/CurrentList.tsx index e568d7e7cde8..87b08079bd72 100644 --- a/packages/page-staking/src/Suspensions/CurrentList.tsx +++ b/packages/page-staking/src/Suspensions/CurrentList.tsx @@ -70,7 +70,7 @@ function CurrentList ({ suspensions }: Props): React.ReactElement { address={address} era={era} filterName={nameFilter} - key={address} + key={`address-${address}-era-${era}`} suspensionLiftsInEra={suspensionLiftsInEra} suspensionReason={suspensionReason} /> diff --git a/packages/page-staking/src/Suspensions/Suspensions.tsx b/packages/page-staking/src/Suspensions/Suspensions.tsx index 170896076d11..42e557536c92 100644 --- a/packages/page-staking/src/Suspensions/Suspensions.tsx +++ b/packages/page-staking/src/Suspensions/Suspensions.tsx @@ -3,7 +3,7 @@ import { useEffect, useMemo, useState } from 'react'; -import getCommitteeManagement from '@polkadot/react-api/getCommitteeManagement'; +import getCommitteeManagement, { COMMITTEE_MANAGEMENT_NAMES } from '@polkadot/react-api/getCommitteeManagement'; import { createNamedHook, useApi, useCall } from '@polkadot/react-hooks'; import { u64, Vec } from '@polkadot/types'; import { EventRecord, Hash } from '@polkadot/types/interfaces'; @@ -16,7 +16,7 @@ import { SuspensionEvent } from './index.js'; type SuspensionReasons = [string, string, number][]; function parseEvents (events: EventRecord[]): SuspensionReasons { - return events.filter(({ event }) => event.section === 'elections' && event.method === 'BanValidators') + return events.filter(({ event }) => COMMITTEE_MANAGEMENT_NAMES.includes(event.section) && event.method === 'BanValidators') .map(({ event }) => { const raw = event.data[0] as unknown as Codec[][]; @@ -73,7 +73,7 @@ function useSuspensions (): SuspensionEvent[] | undefined { ); useEffect(() => { - if (!(api && api.consts.elections) || erasStartSessionIndexLookup.length === 0) { + if (!(api && getCommitteeManagement(api).consts) || erasStartSessionIndexLookup.length === 0) { return; } diff --git a/packages/react-api/src/getCommitteeManagement.ts b/packages/react-api/src/getCommitteeManagement.ts index 1bbc05ec6015..8bceb9328226 100644 --- a/packages/react-api/src/getCommitteeManagement.ts +++ b/packages/react-api/src/getCommitteeManagement.ts @@ -4,6 +4,8 @@ import type { ApiPromise } from '@polkadot/api'; import type { ApiDecoration } from '@polkadot/api/types'; +export const COMMITTEE_MANAGEMENT_NAMES = ['committeeManagement', 'elections']; + export default function getCommitteeManagement (api: ApiPromise | ApiDecoration<'promise'>) { return { consts: api.consts.committeeManagement || api.consts.elections, diff --git a/packages/react-signer/src/Address.tsx b/packages/react-signer/src/Address.tsx index dc08bcd65313..24980b7a975f 100644 --- a/packages/react-signer/src/Address.tsx +++ b/packages/react-signer/src/Address.tsx @@ -13,6 +13,7 @@ import type { AddressFlags, AddressProxy } from './types.js'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { ApiPromise } from '@polkadot/api'; +import { COMMITTEE_MANAGEMENT_NAMES } from '@polkadot/react-api/getCommitteeManagement'; import { InputAddress, MarkError, Modal, Toggle } from '@polkadot/react-components'; import { useAccounts, useApi, useIsMountedRef } from '@polkadot/react-hooks'; import { BN_ZERO, isFunction } from '@polkadot/util'; @@ -100,7 +101,7 @@ function filterProxies (allAccounts: string[], tx: Call | SubmittableExtrinsic<' case 'Governance': return checkNested(address) || ( - ['convictionVoting', 'council', 'councilCollective', 'democracy', 'elections', 'electionsPhragmen', 'fellowshipCollective', 'fellowshipReferenda', 'phragmenElection', 'poll', 'referenda', 'society', 'technicalCommittee', 'tips', 'treasury', 'whitelist'].includes(section) + ['convictionVoting', 'council', 'councilCollective', 'democracy', 'elections', 'electionsPhragmen', 'fellowshipCollective', 'fellowshipReferenda', 'phragmenElection', 'poll', 'referenda', 'society', 'technicalCommittee', 'tips', 'treasury', 'whitelist', ...COMMITTEE_MANAGEMENT_NAMES].includes(section) ); case 'IdentityJudgement':