From ce3bb182ad0385fb335b909ac4d640910d65927b Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 8 Nov 2019 11:20:19 +0100 Subject: [PATCH] Strengten identicon checks (#1856) --- packages/react-components/src/IdentityIcon.tsx | 8 ++++---- packages/react-query/src/BlockAuthors.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-components/src/IdentityIcon.tsx b/packages/react-components/src/IdentityIcon.tsx index 8e1dfaa91b..289d1ed0f6 100644 --- a/packages/react-components/src/IdentityIcon.tsx +++ b/packages/react-components/src/IdentityIcon.tsx @@ -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( ['derive.staking.validators', { propName: 'validators', - transform: ({ validators }): DeriveStakingValidators => validators + transform: ({ validators }): AccountId[] => validators }] ) ); diff --git a/packages/react-query/src/BlockAuthors.tsx b/packages/react-query/src/BlockAuthors.tsx index a7e2a6e643..e0c5babfb4 100644 --- a/packages/react-query/src/BlockAuthors.tsx +++ b/packages/react-query/src/BlockAuthors.tsx @@ -37,9 +37,9 @@ function BlockAuthors ({ children }: Props): React.ReactElement { 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) {