Skip to content
This repository was archived by the owner on Mar 18, 2025. It is now read-only.

Commit e7eb7c6

Browse files
authored
Merge pull request #2917 from Analog-Labs/patches/active_era
EraPointsJob: ensure reliable and correct retrieval of era points
2 parents ea413e4 + cecba8b commit e7eb7c6

File tree

1 file changed

+6
-3
lines changed
  • packages/common/src/chaindata/queries

1 file changed

+6
-3
lines changed

packages/common/src/chaindata/queries/Era.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ export const getTotalEraPoints = async (
4646
if (!chainType) {
4747
return {} as EraPointsInfo;
4848
}
49-
const [blockHash, err] = await chaindata.findEraBlockHash(era, chainType);
49+
const [blockHash, err] = await chaindata.findEraBlockHash(
50+
era + 1,
51+
chainType,
52+
);
5053

5154
if (blockHash) {
5255
const apiAt = await chaindata?.api?.at(blockHash);
@@ -204,12 +207,12 @@ export const findEraBlockHash = async (
204207
return ["", "API at block hash is null"];
205208
}
206209

207-
const testEra = await apiAt.query.staking.currentEra();
210+
const testEra = await apiAt.query.staking.activeEra();
208211
if (testEra && testEra.isEmpty) {
209212
logger.info(`Test era is empty: ${JSON.stringify(testEra)}`);
210213
return ["", "Test era is none"];
211214
}
212-
const testIndex = testEra.unwrap().toNumber();
215+
const testIndex = testEra.unwrap().index.toNumber();
213216
if (era == testIndex) {
214217
return [blockHash.toString(), null];
215218
}

0 commit comments

Comments
 (0)