Skip to content

Commit

Permalink
Revert 1,002,000 runtime validator identities fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov committed Sep 9, 2024
1 parent 9fa5f9c commit 8dd482e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/contexts/Pools/ActivePool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const ActivePoolProvider = ({ children }: { children: ReactNode }) => {
// Membership takes priority, followed by the first pool the account has a role in. Falls back
// to `null` if no active roles are found.
const initialActivePoolId = membership?.poolId || accountPoolIds[0] || null;

if (initialActivePoolId && !activePool) {
setActivePoolId(String(initialActivePoolId));
}
Expand Down Expand Up @@ -227,6 +228,7 @@ export const ActivePoolProvider = ({ children }: { children: ReactNode }) => {
assignActivePoolId();
}
}, [network, isReady, accountPoolIds]);
console.log('accountPoolIds: ', accountPoolIds);

// Reset on network change and component unmount. NOTE: ActivePoolsController also unsubscribes on
// network change; this is handled by the Api instance.
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/ActivePoolsController/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export class ActivePoolsController {
accountDataResult: AnyApi
): Promise<void> => {
const bondedPool = bondedPoolResult?.unwrapOr(undefined)?.toHuman();
console.log('bondedPool: ', bondedPool);
const rewardPool = rewardPoolResult?.unwrapOr(undefined)?.toHuman();
console.log('rewardPool: ', rewardPool);
const balance = accountDataResult.data;
const rewardAccountBalance = balance?.free.toString();

Expand Down
26 changes: 15 additions & 11 deletions src/controllers/IdentitiesController/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import type { AnyApi } from 'types';
import type { ApiPromise } from '@polkadot/api';
import type { AnyJson } from '@w3ux/types';

export class IdentitiesController {
static fetch = async (api: ApiPromise, addresses: string[]) => {
Expand All @@ -13,15 +12,19 @@ export class IdentitiesController {
(identity) => identity.toHuman()
);

// REVERTING #2090

// Take identity data (first index) of results.
const data = result.map(
(resultArray: AnyJson | null) => resultArray?.[0] || null
);
// const data = result.map(
// (resultArray: AnyJson | null) => resultArray?.[0] || null
// );

return Object.fromEntries(
data
.map((key: string, index: number) => [addresses[index], key])
.filter(([, value]) => value !== null)
// data
// .map((key: string, index: number) => [addresses[index], key])
// .filter(([, value]) => value !== null)

result.map((k, i) => [addresses[i], k]).filter(([, v]) => v !== null)
);
};

Expand Down Expand Up @@ -49,16 +52,17 @@ export class IdentitiesController {
).map((superIdentity) => superIdentity.toHuman());

// Take identity data (first index) of results.
const data = superIdentities.map(
(resultArray: AnyJson | null) => resultArray?.[0] || null
);
// const data = superIdentities.map(
// (resultArray: AnyJson | null) => resultArray?.[0] || null
// );

const supersWithIdentity = Object.fromEntries(
Object.entries(supers).map(([k, v]: AnyApi, i) => [
k,
{
...v,
identity: data[i],
// identity: data[i],
identity: superIdentities[i],
},
])
);
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/useActivePools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export const useActivePools = ({ onCallback, who }: ActivePoolsProps) => {
// Get an active pool.
const getActivePools = (poolId: string) => activePools?.[poolId] || null;

useEffect(() => {
console.log('activePools: ', activePools);
}, [activePools]);

// Get an active pool's nominations.
const getPoolNominations = (poolId: string) =>
poolNominations?.[poolId] || null;
Expand Down

0 comments on commit 8dd482e

Please sign in to comment.