Strengten identicon checks (#1856)

This commit is contained in:
Jaco Greeff 2019-11-08 11:20:19 +01:00 committed by GitHub
parent 9600d3a563
commit ce3bb182ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -1,9 +1,7 @@
/* eslint-disable @typescript-eslint/camelcase */
// Copyright 2017-2019 @polkadot/react-components authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { DeriveStakingValidators } from '@polkadot/api-derive/types';
import { AccountId } from '@polkadot/types/interfaces';
import { IdentityProps } from '@polkadot/react-identicon/types';
import { I18nProps } from './types';
@ -41,9 +39,11 @@ function IdentityIcon ({ className, onCopy, prefix, size, style, t, theme, valid
const thisTheme = theme || getIdentityTheme(systemName);
useEffect((): void => {
const address = value?.toString();
setIsValidator(
validators
? validators.some((validator): boolean => validator.eq(value))
? validators.some((validator): boolean => validator.toString() === address)
: false
);
}, [validators, value]);
@ -78,7 +78,7 @@ export default withMulti(
withCalls<Props>(
['derive.staking.validators', {
propName: 'validators',
transform: ({ validators }): DeriveStakingValidators => validators
transform: ({ validators }): AccountId[] => validators
}]
)
);

View File

@ -37,9 +37,9 @@ function BlockAuthors ({ children }: Props): React.ReactElement<Props> {
let lastBlockNumber = '';
api.derive.chain.subscribeNewHeads((lastHeader): void => {
if (lastHeader && lastHeader.number) {
if (lastHeader?.number) {
const blockNumber = lastHeader.number.unwrap();
const thisBlockAuthor = lastHeader.author ? lastHeader.author.toString() : undefined;
const thisBlockAuthor = lastHeader.author?.toString();
const thisBlockNumber = formatNumber(blockNumber);
if (thisBlockAuthor) {