Mark api.query.<section>.<method>.at as deprecated (#4023)

* Use api.at internally for sizeAt/entriesAt/keysAt

* Remove debug logs

* Mark api.query.<section>.<method>.at as deprecated

* formatting

* @deprecated formatting

* commenting
This commit is contained in:
Jaco
2021-10-06 08:53:50 +03:00
committed by GitHub
parent 407aca37c1
commit affa6ab1bd
8 changed files with 70 additions and 59 deletions
+10 -12
View File
@@ -5,7 +5,7 @@ import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EventRecord, Hash, SignedBlock } from '@polkadot/types/interfaces';
import { map, switchMap } from 'rxjs';
import { combineLatest, map, switchMap } from 'rxjs';
import { memo } from '../util';
@@ -15,17 +15,15 @@ interface Result {
}
export function events (instanceId: string, api: ApiInterfaceRx): (at: Hash) => Observable<Result> {
return memo(instanceId, (at: Hash) =>
// we get the block first, setting up the registry
api.rpc.chain.getBlock(at).pipe(
switchMap((block) =>
api.query.system.events.at(at).pipe(
map((events): Result => ({
block,
events
}))
)
)
return memo(instanceId, (blockHash: Hash) =>
api.queryAt(blockHash).pipe(
switchMap((queryAt) =>
combineLatest([
api.rpc.chain.getBlock(blockHash),
queryAt.system.events()
])
),
map(([block, events]): Result => ({ block, events }))
)
);
}