Skip to content

Commit

Permalink
feat: Runtime upgrade 1,002,000 fixes (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat authored Apr 22, 2024
1 parent ecb5538 commit 3b0bfb3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
11 changes: 8 additions & 3 deletions src/config/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ import BigNumber from 'bignumber.js';

// DEPRECATION: Paged Rewards
//
// Temporary until paged rewards migration has completed on all networks.
export const NetworksWithPagedRewards: NetworkName[] = ['westend', 'kusama'];
// Temporary until paged rewards migration has completed on all networks. Wait 84 eras from Polkadot
// start: 1420 + 84 = 1504, when full history depth will be moved over to new paged rewards storage.
export const NetworksWithPagedRewards: NetworkName[] = [
'polkadot',
'kusama',
'westend',
];
export const PagedRewardsStartEra: Record<NetworkName, BigNumber | null> = {
polkadot: null,
polkadot: new BigNumber(1420),
kusama: new BigNumber(6514),
westend: new BigNumber(7167),
};
Expand Down
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { stringToU8a } from '@polkadot/util';
/*
* Global Constants
*/
export const AppVersion = '1.3.1';
export const AppVersion = '1.4.2';
export const DappName = 'Polkadot Staking Dashboard';
export const PolkadotUrl = 'https://polkadot.network/features/staking/';
export const ManualSigners = ['ledger', 'vault'];
Expand Down
20 changes: 17 additions & 3 deletions src/controllers/IdentitiesController/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 @paritytech/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

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

export class IdentitiesController {
Expand All @@ -11,8 +11,16 @@ export class IdentitiesController {
const result = (await api.query.identity.identityOf.multi(addresses)).map(
(identity) => identity.toHuman()
);

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

return Object.fromEntries(
result.map((k, i) => [addresses[i], k]).filter(([, v]) => v !== null)
data
.map((key: string, index: number) => [addresses[index], key])
.filter(([, value]: AnyJson) => value !== null)
);
};

Expand All @@ -21,6 +29,7 @@ export class IdentitiesController {
const supersRaw = (await api.query.identity.superOf.multi(addresses)).map(
(superOf) => superOf.toHuman()
);

const supers = Object.fromEntries(
supersRaw
.map((k, i) => [
Expand All @@ -38,12 +47,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 supersWithIdentity = Object.fromEntries(
Object.entries(supers).map(([k, v]: AnyApi, i) => [
k,
{
...v,
identity: superIdentities[i],
identity: data[i],
},
])
);
Expand Down

0 comments on commit 3b0bfb3

Please sign in to comment.