@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@polkadot/api-base/types';
|
||||
import type { DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@polkadot/api-base/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Metadata } from '@polkadot/types';
|
||||
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
@@ -10,6 +10,7 @@ import type { Registry, Signer } from '@polkadot/types/types';
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
export interface ApiInterfaceRx {
|
||||
call: QueryableCalls<'rxjs'>,
|
||||
consts: QueryableConsts<'rxjs'>;
|
||||
extrinsicType: number;
|
||||
genesisHash?: Hash;
|
||||
|
||||
@@ -108,6 +108,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
protected _runtimeVersion?: RuntimeVersion;
|
||||
|
||||
protected _rx: ApiInterfaceRx = {
|
||||
call: {} as QueryableCalls<'rxjs'>,
|
||||
consts: {} as QueryableConsts<'rxjs'>,
|
||||
query: {} as QueryableStorage<'rxjs'>,
|
||||
tx: {} as SubmittableExtrinsics<'rxjs'>
|
||||
@@ -220,6 +221,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
query: {},
|
||||
registry,
|
||||
rx: {
|
||||
call: {},
|
||||
query: {}
|
||||
},
|
||||
tx: createSubmittable(this._type, this._rx, this._decorateMethod, registry, blockHash)
|
||||
@@ -236,8 +238,9 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
const runtime = this._decorateCalls(registry, this._decorateMethod, blockHash);
|
||||
const runtimeRx = this._decorateCalls<'rxjs'>(registry, this._rxDecorateMethod, blockHash);
|
||||
const storage = this._decorateStorage(registry.decoratedMeta, this._decorateMethod, blockHash);
|
||||
const storageRx = this._decorateStorage(registry.decoratedMeta, this._rxDecorateMethod, blockHash);
|
||||
const storageRx = this._decorateStorage<'rxjs'>(registry.decoratedMeta, this._rxDecorateMethod, blockHash);
|
||||
|
||||
augmentObject('consts', registry.decoratedMeta.consts, decoratedApi.consts, fromEmpty);
|
||||
augmentObject('errors', registry.decoratedMeta.errors, decoratedApi.errors, fromEmpty);
|
||||
@@ -245,6 +248,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
augmentObject('query', storage, decoratedApi.query, fromEmpty);
|
||||
augmentObject('query', storageRx, decoratedApi.rx.query, fromEmpty);
|
||||
augmentObject('call', runtime, decoratedApi.call, fromEmpty);
|
||||
augmentObject('call', runtimeRx, decoratedApi.rx.call, fromEmpty);
|
||||
|
||||
decoratedApi.findCall = (callIndex: Uint8Array | string): CallFunction =>
|
||||
findCall(registry.registry, callIndex);
|
||||
@@ -488,7 +492,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
// pre-metadata decoration
|
||||
protected _decorateCalls<ApiType extends ApiTypes> ({ registry, runtimeVersion: { apis, specName } }: VersionedRegistry<ApiType>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType> {
|
||||
protected _decorateCalls<ApiType extends ApiTypes> ({ registry, runtimeVersion: { apis, specName } }: VersionedRegistry<any>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType> {
|
||||
const result = {} as QueryableCalls<ApiType>;
|
||||
const named: Record<string, Record<string, DefinitionCallNamed>> = {};
|
||||
const hashes: Record<HexString, boolean> = {};
|
||||
|
||||
@@ -194,8 +194,8 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> im
|
||||
/**
|
||||
* @description The underlying Rx API interface
|
||||
*/
|
||||
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'> {
|
||||
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'>);
|
||||
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query' | 'call'> {
|
||||
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query' | 'call'>);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,6 +104,7 @@ export interface ApiDecoration<ApiType extends ApiTypes> {
|
||||
registry: Registry;
|
||||
runtimeVersion: RuntimeVersionPartial;
|
||||
rx: {
|
||||
call: QueryableCalls<'rxjs'>;
|
||||
query: QueryableStorage<'rxjs'>;
|
||||
};
|
||||
tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
|
||||
|
||||
Reference in New Issue
Block a user