Add query.<sec>.<met>.{size, hash}(arg? any) (#630)
This commit is contained in:
@@ -427,12 +427,20 @@ export default abstract class ApiBase<OnCall> implements ApiBaseInterface<OnCall
|
||||
|
||||
decorated.at = (hash: Hash, arg?: any): T =>
|
||||
onCall(
|
||||
arg => this._rpcRx.state
|
||||
.getStorage([method, arg], hash)
|
||||
.pipe(
|
||||
// same as above (for single result), in the case of errors on creation, return `undefined`
|
||||
catchError(() => of())
|
||||
),
|
||||
// same as above (for single result), in the case of errors on creation, return `undefined`
|
||||
arg => this._rpcRx.state.getStorage([method, arg], hash).pipe(catchError(() => of())),
|
||||
[arg]
|
||||
);
|
||||
|
||||
decorated.hash = (arg?: any): T =>
|
||||
onCall(
|
||||
arg => this._rpcRx.state.getStorageSize([method, arg]).pipe(catchError(() => of())),
|
||||
[arg]
|
||||
);
|
||||
|
||||
decorated.size = (arg?: any): T =>
|
||||
onCall(
|
||||
arg => this._rpcRx.state.getStorageSize([method, arg]).pipe(catchError(() => of())),
|
||||
[arg]
|
||||
);
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import { QueryableStorageFunction as QueryableStorageFunctionBase, SubmittableEx
|
||||
import ApiBase from '../Base';
|
||||
import SubmittableExtrinsicBase from '../SubmittableExtrinsic';
|
||||
|
||||
export type OnCall = Promise<Codec | null | undefined> | PromiseSubscription;
|
||||
|
||||
export type PromiseSubscription = Promise<() => any>;
|
||||
|
||||
export type OnCall = Promise<Codec | null | undefined> | PromiseSubscription;
|
||||
|
||||
export interface ApiPromiseInterface extends ApiBase<OnCall> {
|
||||
readonly isReady: Promise<ApiPromiseInterface>;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@ export interface DecoratedRpc<OnCall> {
|
||||
interface QueryableStorageFunctionBase<OnCall> extends StorageFunction {
|
||||
(arg?: any): OnCall;
|
||||
at: (hash: Uint8Array | string, arg?: any) => OnCall;
|
||||
hash: (arg?: any) => OnCall; // Observable<Hash>
|
||||
key: (arg?: any) => string;
|
||||
size: (arg?: any) => OnCall; // Observable<U64>
|
||||
}
|
||||
|
||||
interface QueryableStorageFunctionPromise<OnCall> extends QueryableStorageFunctionBase<OnCall> {
|
||||
|
||||
Reference in New Issue
Block a user