Files
api/packages/api-provider/src/http/index.ts
T
Jaco Greeff f5a9c207d0 Add TSLint (#106)
* Add TSLint

* Update dependencies

* Update dependencies
2018-06-27 12:22:52 +02:00

31 lines
1.1 KiB
TypeScript

// Copyright 2017-2018 @polkadot/api-provider authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
import './polyfill';
import on from './on';
import send from './send';
import subscribe from './subscribe';
import state from './state';
import unsubscribe from './unsubscribe';
export default function httpProvider (endpoint: string): ProviderInterface {
const self = state(endpoint);
return {
isConnected: (): boolean =>
true,
on: (type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void =>
on(self, type, sub),
send: (method: string, params: Array<any>): Promise<any> =>
send(self, method, params),
subscribe: (method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number> =>
subscribe(self, method, params, cb),
unsubscribe: (method: string, id: number): Promise<boolean> =>
unsubscribe(self, method, id)
};
}