From b7c2cbccbaa846b01a3505003dc950e64d72d687 Mon Sep 17 00:00:00 2001 From: vovunku Date: Fri, 15 Mar 2024 11:07:32 +0100 Subject: [PATCH 1/2] added checks on empty era stakers received --- src/mappings/era/ValidatorEraInfoDataSource.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mappings/era/ValidatorEraInfoDataSource.ts b/src/mappings/era/ValidatorEraInfoDataSource.ts index a65bfa0..fc87b5a 100644 --- a/src/mappings/era/ValidatorEraInfoDataSource.ts +++ b/src/mappings/era/ValidatorEraInfoDataSource.ts @@ -22,11 +22,19 @@ export class ValidatorEraInfoDataSource extends CachingEraInfoDataSource { protected async fetchEraStakers(): Promise { const era = await this.era() + let stakers if (api.query.staking.erasStakersOverview) { - return await this.fetchEraStakersPaged(era); - } else { - return await this.fetchEraStakersClipped(era); + stakers = await this.fetchEraStakersPaged(era); + if (stakers.length > 0) { + return stakers + } + } + + stakers = await this.fetchEraStakersClipped(era); + if (stakers.length == 0) { + throw new Error("Empty era stakers fetched") } + return stakers } private async fetchEraStakersClipped(era: number): Promise { From e8c5d0f9a5e561710f6753831dcfc5b9ee3736a0 Mon Sep 17 00:00:00 2001 From: vovunku Date: Fri, 15 Mar 2024 11:10:39 +0100 Subject: [PATCH 2/2] fixed missing type --- src/mappings/era/ValidatorEraInfoDataSource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mappings/era/ValidatorEraInfoDataSource.ts b/src/mappings/era/ValidatorEraInfoDataSource.ts index fc87b5a..23ed889 100644 --- a/src/mappings/era/ValidatorEraInfoDataSource.ts +++ b/src/mappings/era/ValidatorEraInfoDataSource.ts @@ -22,7 +22,7 @@ export class ValidatorEraInfoDataSource extends CachingEraInfoDataSource { protected async fetchEraStakers(): Promise { const era = await this.era() - let stakers + let stakers: StakeTarget[] if (api.query.staking.erasStakersOverview) { stakers = await this.fetchEraStakersPaged(era); if (stakers.length > 0) {