Add .args to decoded StorageKeys (#2004)

* Add .args to decoded StorageKeys

* Small opts

* Formatting
This commit is contained in:
Jaco Greeff
2020-03-06 13:47:40 +01:00
committed by GitHub
parent 63c22414ce
commit adee447cd0
7 changed files with 121 additions and 27 deletions
@@ -18,6 +18,8 @@ function queryClipped (api: ApiInterfaceRx): Observable<[EraIndex, [AccountId, E
combineLatest([
of(allPoints),
combineLatest(
// we could just do entries over the full set, however the resultset can be quite large - split it into
// batches - may need to re-visit this, or alternatively use pages keys for exceptionally large sets
allPoints.map(({ era }): Observable<[StorageKey, Exposure][]> =>
api.query.staking.erasStakersClipped.entries(era)
)
@@ -28,7 +30,7 @@ function queryClipped (api: ApiInterfaceRx): Observable<[EraIndex, [AccountId, E
allPoints.map(({ era }, index): [EraIndex, [AccountId, Exposure][]] => [
era,
erasStakers[index].map(([key, exposure]): [AccountId, Exposure] => [
api.registry.createType('AccountId', key.toU8a().slice(-32)),
key.args[1] as AccountId,
exposure
])
])
@@ -20,10 +20,7 @@ function queryNextStakers (api: ApiInterfaceRx): Observable<AccountId[]> {
api.query.staking.erasStakers.entries(activeEra.addn(1))
),
map((entries): AccountId[] =>
// key is from concat with AccountId bytes right at the end
entries.map(([key]): AccountId =>
api.registry.createType('AccountId', key.toU8a().slice(-32))
)
entries.map(([key]): AccountId => key.args[1] as AccountId)
)
);
}