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

feat(refactor): disable identities on networks where People Chain is being used #2183

Merged
merged 1 commit into from
Jul 6, 2024
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
5 changes: 5 additions & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ export const MaxPayoutDays = 60;
export const MaxEraRewardPointsEras = 10;
export const ZondaxMetadataHashApiUrl =
'https://api.zondax.ch/polkadot/node/metadata/hash';

/*
* People Chain migration - disallow identities on networks where People Chain is live.
*/
export const PeopleChainNetworks = ['westend', 'kusama'];
19 changes: 11 additions & 8 deletions src/contexts/Validators/ValidatorEntries/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { AnyApi, Fn } from 'types';
import { useEffectIgnoreInitial } from '@w3ux/hooks';
import { useNetwork } from 'contexts/Network';
import { useApi } from 'contexts/Api';
import { MaxEraRewardPointsEras } from 'consts';
import { MaxEraRewardPointsEras, PeopleChainNetworks } from 'consts';
import { useStaking } from 'contexts/Staking';
import type {
EraPointsBoundaries,
Expand Down Expand Up @@ -316,14 +316,17 @@ export const ValidatorsProvider = ({ children }: { children: ReactNode }) => {
// NOTE: validators are shuffled before committed to state.
setValidators(shuffle(validatorEntries));

const addresses = validatorEntries.map(({ address }) => address);
const { identities, supers } = await IdentitiesController.fetch(
api,
addresses
);
// PEOPLE CHAIN MIGRATION: Currently ignoring identities while People Chain is not supported.
if (!PeopleChainNetworks.includes(network)) {
const addresses = validatorEntries.map(({ address }) => address);
const { identities, supers } = await IdentitiesController.fetch(
api,
addresses
);
setValidatorIdentities(identities);
setValidatorSupers(supers);
}

setValidatorIdentities(identities);
setValidatorSupers(supers);
setValidatorsFetched('synced');
};

Expand Down
16 changes: 11 additions & 5 deletions src/controllers/ActivePoolsController/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
import { SyncController } from 'controllers/SyncController';
import type { Nominations } from 'contexts/Balances/types';
import type { ApiPromise } from '@polkadot/api';
import { PeopleChainNetworks } from 'consts';

export class ActivePoolsController {
// ------------------------------------------------------
Expand Down Expand Up @@ -126,11 +127,16 @@ export class ActivePoolsController {
const balance = accountDataResult.data;
const rewardAccountBalance = balance?.free.toString();

// Fetch identities for roles and expand `bondedPool` state to store them.
bondedPool.roleIdentities = await IdentitiesController.fetch(
api,
this.getUniqueRoleAddresses(bondedPool.roles)
);
// PEOPLE CHAIN MIGRATION: Currently ignoring identities while People Chain is not supported.
if (
!PeopleChainNetworks.includes(api.runtimeChain.toString().toLowerCase())
) {
// Fetch identities for roles and expand `bondedPool` state to store them.
bondedPool.roleIdentities = await IdentitiesController.fetch(
api,
this.getUniqueRoleAddresses(bondedPool.roles)
);
}

// Only persist the active pool to class state (and therefore dispatch an event) if both the
// bonded pool and reward pool are returned.
Expand Down
Loading