Skip to content
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

A0-2616: suspension page does not show new suspensions #69

Merged
Merged
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-staking/src/Suspensions/CurrentList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function CurrentList ({ suspensions }: Props): React.ReactElement<Props> {
address={address}
era={era}
filterName={nameFilter}
key={address}
key={`address-${address}-era-${era}`}
suspensionLiftsInEra={suspensionLiftsInEra}
suspensionReason={suspensionReason}
/>
Expand Down
6 changes: 3 additions & 3 deletions packages/page-staking/src/Suspensions/Suspensions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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[][];

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions packages/react-api/src/getCommitteeManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/react-signer/src/Address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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':
Expand Down