diff --git a/packages/api-observable/src/Base.ts b/packages/api-observable/src/Base.ts index e9a5acdf3b..6d36d5f7c8 100644 --- a/packages/api-observable/src/Base.ts +++ b/packages/api-observable/src/Base.ts @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -import { RxRpcInterface, RxRpcInterface$Method, RxRpcInterface$Section } from '@polkadot/rpc-rx/types'; +import { RpcRxInterface, RpcRxInterface$Method, RpcRxInterface$Section } from '@polkadot/rpc-rx/types'; import { RpcMethod } from '@polkadot/jsonrpc/types'; import { EMPTY, Observable, combineLatest, from } from 'rxjs'; @@ -25,13 +25,13 @@ const defaultMapFn = (result: any): any => // Raw base implementation for the observable API. It simply provides access to raw calls, allowing // decendants to make direct queries to either API methods or actual storage export default class ApiBase { - protected _api: RxRpcInterface; + protected _api: RpcRxInterface; protected _genesisHash: Hash; // Observable that returns the first time we are connected and loaded whenReady: Observable; - constructor (api: RxRpcInterface) { + constructor (api: RpcRxInterface) { this._api = api; this._genesisHash = new Hash(); this.whenReady = from(this.init()); @@ -91,11 +91,11 @@ export default class ApiBase { } rawCall = ({ method, section }: RpcMethod, ...params: Array): Observable => { - const apiSection = this._api[section as keyof RxRpcInterface] as RxRpcInterface$Section; + const apiSection = this._api[section as keyof RpcRxInterface] as RpcRxInterface$Section; assert(apiSection, `Unable to find 'api.${section}'`); - const fn: RxRpcInterface$Method = apiSection[method]; + const fn: RpcRxInterface$Method = apiSection[method]; assert(fn, `Unable to find 'api.${section}.${method}'`); diff --git a/packages/api/src/rx/types.d.ts b/packages/api/src/rx/types.d.ts index 3859fa75a3..685d7d34f7 100644 --- a/packages/api/src/rx/types.d.ts +++ b/packages/api/src/rx/types.d.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { ExtrinsicFunction } from '@polkadot/extrinsics/types'; import RpcRx from '@polkadot/rpc-rx/index'; -import { RxRpcInterface$Events } from '@polkadot/rpc-rx/types'; +import { RpcRxInterface$Events } from '@polkadot/rpc-rx/types'; import { Base } from '@polkadot/types/codec'; import { Hash, RuntimeVersion } from '@polkadot/types/index'; import RuntimeMetadata, { FunctionMetadata } from '@polkadot/types/Metadata'; @@ -37,7 +37,7 @@ export interface SubmittableExtrinsics { [index: string]: SubmittableModuleExtrinsics; } -export type RxApiInterface$Events = RxRpcInterface$Events | 'ready'; +export type RxApiInterface$Events = RpcRxInterface$Events | 'ready'; export interface RxApiInterface { readonly genesisHash: Hash; diff --git a/packages/rpc-rx/src/index.ts b/packages/rpc-rx/src/index.ts index 39df1847fa..7df9d6adf0 100644 --- a/packages/rpc-rx/src/index.ts +++ b/packages/rpc-rx/src/index.ts @@ -4,7 +4,7 @@ import { RpcInterface, RpcInterface$Section } from '@polkadot/rpc-core/types'; import { ProviderInterface } from '@polkadot/rpc-provider/types'; -import { RxRpcInterface, RxRpcInterface$Section } from './types'; +import { RpcRxInterface, RpcRxInterface$Section } from './types'; import E3 from 'eventemitter3'; import { BehaviorSubject, ReplaySubject, Observable, Subscriber, from } from 'rxjs'; @@ -37,14 +37,14 @@ type CachedMap = { * const api = new RpcRx(provider); * ``` */ -export default class RpcRx extends E3.EventEmitter implements RxRpcInterface { +export default class RpcRx extends E3.EventEmitter implements RpcRxInterface { private _api: RpcInterface; private _cacheMap: CachedMap; private _isConnected: BehaviorSubject; - readonly author: RxRpcInterface$Section; - readonly chain: RxRpcInterface$Section; - readonly state: RxRpcInterface$Section; - readonly system: RxRpcInterface$Section; + readonly author: RpcRxInterface$Section; + readonly chain: RpcRxInterface$Section; + readonly state: RpcRxInterface$Section; + readonly system: RpcRxInterface$Section; /** * @param {ProviderInterface} provider An API provider using HTTP or WebSocket @@ -82,7 +82,7 @@ export default class RpcRx extends E3.EventEmitter implements RxRpcInterface { }); } - private createInterface (sectionName: string, section: RpcInterface$Section): RxRpcInterface$Section { + private createInterface (sectionName: string, section: RpcInterface$Section): RpcRxInterface$Section { return Object .keys(section) .filter((name) => !['subscribe', 'unsubscribe'].includes(name)) @@ -90,7 +90,7 @@ export default class RpcRx extends E3.EventEmitter implements RxRpcInterface { observables[name] = this.createObservable(`${sectionName}_${name}`, name, section); return observables; - }, ({} as RxRpcInterface$Section)); + }, ({} as RpcRxInterface$Section)); } private createObservable (subName: string, name: string, section: RpcInterface$Section): (...params: Array) => Observable | ReplaySubject { diff --git a/packages/rpc-rx/src/types.d.ts b/packages/rpc-rx/src/types.d.ts index ea056852b7..3bf8c5d76c 100644 --- a/packages/rpc-rx/src/types.d.ts +++ b/packages/rpc-rx/src/types.d.ts @@ -5,20 +5,20 @@ import { ReplaySubject, Observable } from 'rxjs'; import interfaces from '@polkadot/jsonrpc/types'; -export type RxRpcInterface$Method = (...params: Array) => Observable | ReplaySubject; +export type RpcRxInterface$Method = (...params: Array) => Observable | ReplaySubject; -export type RxRpcInterface$Section = { - [index: string]: RxRpcInterface$Method +export type RpcRxInterface$Section = { + [index: string]: RpcRxInterface$Method }; -export type RxRpcInterface$Events = 'connected' | 'disconnected'; +export type RpcRxInterface$Events = 'connected' | 'disconnected'; -export type RxRpcInterface = { - readonly author: RxRpcInterface$Section; - readonly chain: RxRpcInterface$Section; - readonly state: RxRpcInterface$Section; - readonly system: RxRpcInterface$Section; +export type RpcRxInterface = { + readonly author: RpcRxInterface$Section; + readonly chain: RpcRxInterface$Section; + readonly state: RpcRxInterface$Section; + readonly system: RpcRxInterface$Section; isConnected: () => Observable - on: (type: RxRpcInterface$Events, handler: (...args: Array) => any) => void; + on: (type: RpcRxInterface$Events, handler: (...args: Array) => any) => void; }