Use rpc-rx internally to api-promise (#539)

* Use rpc-rx internally to api-promise

* Don't swallow errors

* Remove unused imports
This commit is contained in:
Jaco Greeff
2019-01-07 15:44:15 +01:00
committed by GitHub
parent f2748347c5
commit 70ff3c5dfc
5 changed files with 26 additions and 36 deletions
+5 -5
View File
@@ -4,7 +4,7 @@
import { ProviderInterface, ProviderInterface$Callback } from '@polkadot/rpc-provider/types';
import { RpcSection, RpcMethod } from '@polkadot/jsonrpc/types';
import { RpcInterface, RpcInterface$Section, RpcInterface$Section$Method } from './types';
import { RpcInterface, RpcInterface$Method, RpcInterface$Section } from './types';
import interfaces from '@polkadot/jsonrpc/index';
import WsProvider from '@polkadot/rpc-provider/ws';
@@ -99,7 +99,7 @@ export default class Rpc implements RpcInterface {
}, {} as RpcInterface$Section);
}
private createMethodSend (method: RpcMethod): RpcInterface$Section$Method {
private createMethodSend (method: RpcMethod): RpcInterface$Method {
const rpcName = `${method.section}_${method.method}`;
const call = async (...values: Array<any>): Promise<any> => {
@@ -119,10 +119,10 @@ export default class Rpc implements RpcInterface {
}
};
return call as RpcInterface$Section$Method;
return call as RpcInterface$Method;
}
private createMethodSubscribe (method: RpcMethod): RpcInterface$Section$Method {
private createMethodSubscribe (method: RpcMethod): RpcInterface$Method {
const [updateType, subMethod, unsubMethod] = method.pubsub;
const subName = `${method.section}_${subMethod}`;
const unsubName = `${method.section}_${unsubMethod}`;
@@ -157,7 +157,7 @@ export default class Rpc implements RpcInterface {
}
};
const call = _call as RpcInterface$Section$Method;
const call = _call as RpcInterface$Method;
call.unsubscribe = unsubscribe;
+2 -2
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export interface RpcInterface$Section$Method {
export interface RpcInterface$Method {
(...params: Array<any>): Promise<any>;
subscription: string;
@@ -10,7 +10,7 @@ export interface RpcInterface$Section$Method {
}
export type RpcInterface$Section = {
[index: string]: RpcInterface$Section$Method
[index: string]: RpcInterface$Method
};
export interface RpcInterface {