Fix name of "getBlock" in package "api-derive" and export it in "index.ts" (#2857)
Signed-off-by: lovesh <lovesh.bond@gmail.com>
This commit is contained in:
@@ -17,12 +17,12 @@ import { memo } from '../util';
|
|||||||
* <BR>
|
* <BR>
|
||||||
*
|
*
|
||||||
* ```javascript
|
* ```javascript
|
||||||
* const { author, number } = await api.derive.chain.getHeader('0x123...456');
|
* const { author, block } = await api.derive.chain.getBlock('0x123...456');
|
||||||
*
|
*
|
||||||
* console.log(`block #${number} was authored by ${author}`);
|
* console.log(`block #${block.header.number} was authored by ${author}`);
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<SignedBlockExtended | undefined> {
|
export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8Array | string) => Observable<SignedBlockExtended | undefined> {
|
||||||
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
|
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
api.rpc.chain.getBlock(hash),
|
api.rpc.chain.getBlock(hash),
|
||||||
@@ -35,7 +35,7 @@ export function getHeader (instanceId: string, api: ApiInterfaceRx): (hash: Uint
|
|||||||
),
|
),
|
||||||
catchError((): Observable<undefined> =>
|
catchError((): Observable<undefined> =>
|
||||||
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
// where rpc.chain.getHeader throws, we will land here - it can happen that
|
||||||
// we supplied an invalid hash. (Due to defaults, storeage will have an
|
// we supplied an invalid hash. (Due to defaults, storage will have an
|
||||||
// empty value, so only the RPC is affected). So return undefined
|
// empty value, so only the RPC is affected). So return undefined
|
||||||
of()
|
of()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ export * from './bestNumber';
|
|||||||
export * from './bestNumberFinalized';
|
export * from './bestNumberFinalized';
|
||||||
export * from './bestNumberLag';
|
export * from './bestNumberLag';
|
||||||
export * from './getHeader';
|
export * from './getHeader';
|
||||||
|
export * from './getBlock';
|
||||||
export * from './subscribeNewBlocks';
|
export * from './subscribeNewBlocks';
|
||||||
export * from './subscribeNewHeads';
|
export * from './subscribeNewHeads';
|
||||||
|
|||||||
Reference in New Issue
Block a user