diff --git a/src/services/blocks/BlocksService.ts b/src/services/blocks/BlocksService.ts index bd60d477c..237315909 100644 --- a/src/services/blocks/BlocksService.ts +++ b/src/services/blocks/BlocksService.ts @@ -4,6 +4,7 @@ import { extractAuthor } from '@polkadot/api-derive/type/util'; import { Compact, GenericCall, Struct, Vec } from '@polkadot/types'; import { AbstractInt } from '@polkadot/types/codec/AbstractInt'; import { + AccountId32, Block, BlockHash, BlockNumber, @@ -102,7 +103,7 @@ export class BlocksService extends AbstractService { const [{ block }, validators, events, finalizedHead] = await Promise.all([ api.rpc.chain.getBlock(hash), - historicApi.query.session.validators(), + this.fetchValidators(historicApi), this.fetchEvents(historicApi), queryFinalizedHead ? api.rpc.chain.getFinalizedHead() @@ -631,8 +632,7 @@ export class BlocksService extends AbstractService { /** * Fetch events for the specified block. * - * @param api ApiPromise to use for query - * @param hash `BlockHash` to make query at + * @param historicApi ApiDecoration to use for the query */ private async fetchEvents( historicApi: ApiDecoration<'promise'> @@ -644,6 +644,20 @@ export class BlocksService extends AbstractService { } } + /** + * Checks to see if the current chain has the session module, then retrieve all + * validators. + * + * @param historicApi ApiDecoration to use for the query + */ + private async fetchValidators( + historicApi: ApiDecoration<'promise'> + ): Promise> { + return historicApi.query.session + ? await historicApi.query.session.validators() + : ([] as unknown as Vec); + } + /** * Helper function for `parseGenericCall`. *