Cleanup jsonrpc, refer to api-codec (#174)
* Cleanup jsonrpc, refer to api-codec * Move storagekey legacy into type-params (legacy) * Remove misplaced debug log * Remove header encoding, use api-codec/Header * Remove legacy types * Add metadat array (hack around json import) * Move json metadata to ts
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
import { ApiInterface, ApiInterface$Section } from '@polkadot/api/types';
|
||||
import { ProviderInterface } from '@polkadot/api-provider/types';
|
||||
import { Interface$Sections } from '@polkadot/jsonrpc/types';
|
||||
import { RxApiInterface, RxApiInterface$Section } from './types';
|
||||
|
||||
import { BehaviorSubject, Observable, Subscriber, from } from 'rxjs';
|
||||
@@ -51,19 +50,17 @@ export default class RxApi implements RxApiInterface {
|
||||
provider.on('connected', () => this._isConnected.next(true));
|
||||
provider.on('disconnected', () => this._isConnected.next(false));
|
||||
|
||||
this.author = this.createInterface('author');
|
||||
this.chain = this.createInterface('chain');
|
||||
this.state = this.createInterface('state');
|
||||
this.system = this.createInterface('system');
|
||||
this.author = this.createInterface('author', this._api.author);
|
||||
this.chain = this.createInterface('chain', this._api.chain);
|
||||
this.state = this.createInterface('state', this._api.state);
|
||||
this.system = this.createInterface('system', this._api.system);
|
||||
}
|
||||
|
||||
isConnected (): BehaviorSubject<boolean> {
|
||||
return this._isConnected;
|
||||
}
|
||||
|
||||
private createInterface (sectionName: Interface$Sections): RxApiInterface$Section {
|
||||
const section: ApiInterface$Section = this._api[sectionName];
|
||||
|
||||
private createInterface (sectionName: string, section: ApiInterface$Section): RxApiInterface$Section {
|
||||
return Object
|
||||
.keys(section)
|
||||
.filter((name) => !['subscribe', 'unsubscribe'].includes(name))
|
||||
|
||||
Vendored
+3
-3
@@ -2,9 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { Interfaces } from '@polkadot/jsonrpc/types';
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { Interface$Sections } from '@polkadot/jsonrpc/types';
|
||||
|
||||
import interfaces from '@polkadot/jsonrpc/types';
|
||||
|
||||
export type RxApiInterface$Method = (...params: Array<any>) => Observable<any> | BehaviorSubject<any>;
|
||||
|
||||
@@ -13,7 +13,7 @@ export type RxApiInterface$Section = {
|
||||
};
|
||||
|
||||
type RxApiInterface$Keys = {
|
||||
readonly [key in keyof Interfaces]: RxApiInterface$Section;
|
||||
readonly [key in keyof typeof interfaces]: RxApiInterface$Section;
|
||||
};
|
||||
|
||||
export type RxApiInterface = RxApiInterface$Keys & {
|
||||
|
||||
Reference in New Issue
Block a user