Remove suspicious toHuman in author extraction (#7542)

This commit is contained in:
Jaco 2022-05-07 09:37:42 +02:00 committed by GitHub
parent cd96fe032c
commit 64889009b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@
import type { HeaderExtended } from '@polkadot/api-derive/types';
import type { EraRewardPoints } from '@polkadot/types/interfaces';
import type { Codec } from '@polkadot/types/types';
import React, { useEffect, useState } from 'react';
@ -68,10 +69,7 @@ function BlockAuthorsBase ({ children }: Props): React.ReactElement<Props> {
thisBlockAuthor = lastHeader.author.toString();
} else if (isAuthorMappingWithDeposit && (hasConsensusDigest || hasPreRuntimeDigest)) { // Check for a Digest
// Some blockchains such as Moonbeam need to fetch the author accountId from a mapping
thisBlockAuthor = ((await api.query.authorMapping.mappingWithDeposit(hasConsensusDigest ? lastHeader.digest.logs[0].asConsensus[1] : lastHeader.digest.logs[0].asPreRuntime[1])).toHuman() as {
account: string;
deposit: string;
}).account;
thisBlockAuthor = (await api.query.authorMapping.mappingWithDeposit<{ account: Codec } & Codec>(hasConsensusDigest ? lastHeader.digest.logs[0].asConsensus[1] : lastHeader.digest.logs[0].asPreRuntime[1])).account.toString();
lastHeader.authorFromMapping = thisBlockAuthor;
}