Classify Http & Ws providers (#120)
* Class-ify HttpProvider * Class-ify WsProvider (tests still WIP) * Rework tests * rx-api usage
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
jest.mock('@polkadot/api-provider/ws', () => () => ({
|
||||
isConnected: () => true,
|
||||
on: () => true,
|
||||
send: () => true
|
||||
}));
|
||||
jest.mock('@polkadot/api-provider/ws', () => class {
|
||||
isConnected = () => true;
|
||||
on = () => true;
|
||||
send = () => true;
|
||||
});
|
||||
jest.mock('./interface', () => (api, sectionName) => sectionName);
|
||||
|
||||
const createApi = require('./index').default;
|
||||
|
||||
@@ -8,13 +8,13 @@ import { RxApiInterface } from './types';
|
||||
|
||||
import createApi from '@polkadot/api/index';
|
||||
import interfaces from '@polkadot/jsonrpc';
|
||||
import createWs from '@polkadot/api-provider/ws';
|
||||
import Ws from '@polkadot/api-provider/ws';
|
||||
|
||||
import createExposed from './api';
|
||||
import defaults from './defaults';
|
||||
import createInterface from './interface';
|
||||
|
||||
export default function rxApi (provider: ProviderInterface = createWs(defaults.WS_URL)): RxApiInterface {
|
||||
export default function rxApi (provider: ProviderInterface = new Ws(defaults.WS_URL)): RxApiInterface {
|
||||
const api = createApi(provider);
|
||||
|
||||
return Object.keys(interfaces).reduce((result, type) => {
|
||||
|
||||
Reference in New Issue
Block a user