-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Enricher fixes for archival mode"" (#45)
* Revert "Revert "Enricher fixes for archival mode"" * fixed minor indentation and logical errors * reverted batch size to 500 * created custom interface for returning era reward points * created interface for active exposures * removed session keys from new session event * updated mockApi to preserve default function calls * reverted back lint changes, created interface for individual exposure and casted keys to storage tuple of variable length. * minor fixes and code optimization * Stylistic cleanup. * Add more comments and cleanup. Co-authored-by: Yameen Malik <yameen@seecode.io> Co-authored-by: Yameen <yameen@seedcode.io> Co-authored-by: Jake Naviasky <jake@commonwealth.im>
- Loading branch information
1 parent
4bff63b
commit 5c14429
Showing
12 changed files
with
373 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { AccountId, EraPoints, EraRewardPoints, RewardPoint, EraIndex, BlockHash } from '@polkadot/types/interfaces'; | ||
import { ApiPromise } from '@polkadot/api'; | ||
import { AccountPoints } from '../types'; | ||
|
||
export function currentPoints(api: ApiPromise, era: EraIndex, hash: BlockHash, validators: AccountId[]): Promise<AccountPoints> { | ||
const points: AccountPoints = {}; | ||
// api call to retreive eraRewardPoints for version >= 38 | ||
if (api.query.staking.erasRewardPoints) | ||
return api.query.staking.erasRewardPoints.at<EraRewardPoints>(hash, era).then((rewardPoints) => { | ||
rewardPoints.individual.forEach((rewardPoint, accountKey) => { | ||
points[accountKey.toString()] = +rewardPoint; | ||
}); | ||
return points; | ||
}) | ||
else { | ||
// creating eraRewardPoints for for version = 31 | ||
return api.query.staking.currentEraPointsEarned.at<EraPoints>(hash, era).then((eraPoints) => { | ||
const individual = eraPoints.individual; | ||
individual.map((point, idx) => { | ||
points[validators[idx].toString()] = +point | ||
}); | ||
return points; | ||
}); | ||
|
||
} | ||
} |
Oops, something went wrong.