Skip to content

Commit

Permalink
Merge pull request #1243 from novasamatech/rc/1.3.6-hotfix
Browse files Browse the repository at this point in the history
Rc/1.3.6-hotfix
  • Loading branch information
stepanLav authored Nov 13, 2023
2 parents 825e7c0 + 6f6bb7e commit e60527a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nova-spektr",
"description": "Polkadot Enterprise application",
"version": "1.3.5",
"version": "1.3.6",
"main": "./release/build/main.js",
"repository": "https://github.com/novasamatech/nova-spektr",
"license": "MIT",
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/entities/network/lib/common/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ExtendedChain } from './types';
import { ConnectionType } from '@renderer/shared/core';
import type { ChainOptions } from '@renderer/shared/core';
import type { ChainId, ChainOptions } from '@renderer/shared/core';

export const isPolkadot = (chainName: string): boolean => {
return chainName === 'Polkadot';
Expand All @@ -10,6 +10,10 @@ export const isKusama = (chainName: string): boolean => {
return chainName === 'Kusama';
};

export const isKusamaChainId = (chainId: ChainId): boolean => {
return chainId === '0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe';
};

export const isTestnet = (chainOptions?: ChainOptions[]): boolean => {
return Boolean(chainOptions?.includes('testnet'));
};
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/entities/staking/lib/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const INTEREST_IDEAL = INFLATION_IDEAL / STAKED_PORTION_IDEAL;

export const DECAY_RATE = 0.05;
export const DAYS_IN_YEAR = 365;

export const KUSAMA_MAX_NOMINATORS = 24;
export const DEFAULT_MAX_NOMINATORS = 16;
14 changes: 13 additions & 1 deletion src/renderer/entities/staking/lib/validatorsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { AccountId32 } from '@polkadot/types/interfaces';
import { getValidatorsApy } from './apyCalculator';
import { IValidatorsService, ValidatorMap } from './common/types';
import type { Address, ChainId, EraIndex, Identity, SubIdentity, Validator } from '@renderer/shared/core';
import { isKusamaChainId } from '@renderer/entities/network';
import { DEFAULT_MAX_NOMINATORS, KUSAMA_MAX_NOMINATORS } from './common/constants';

export const useValidators = (): IValidatorsService => {
/**
Expand Down Expand Up @@ -71,8 +73,18 @@ export const useValidators = (): IValidatorsService => {
}, {});
};

const getDefaultValidatorsAmount = (api: ApiPromise): number => {
if (isKusamaChainId(api.genesisHash.toHex())) return KUSAMA_MAX_NOMINATORS;

return DEFAULT_MAX_NOMINATORS;
};

const getMaxValidators = (api: ApiPromise): number => {
return api.consts.staking.maxNominations.toNumber();
if (api.consts.staking.maxNominations) {
return api.consts.staking.maxNominations.toNumber();
} else {
return getDefaultValidatorsAmount(api);
}
};

const getIdentities = async (
Expand Down

0 comments on commit e60527a

Please sign in to comment.