Browse Source

Strengten identicon checks (#1856)

Jaco Greeff 5 years ago
parent
commit
ce3bb182ad

+ 4 - 4
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<Props>(
     ['derive.staking.validators', {
       propName: 'validators',
-      transform: ({ validators }): DeriveStakingValidators => validators
+      transform: ({ validators }): AccountId[] => validators
     }]
   )
 );

+ 2 - 2
packages/react-query/src/BlockAuthors.tsx

@@ -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) {