Extend ApiRx from abstract Base (prepare for promise) (#243)

* Extend ApiRx from abstract Base (prepare for promise)

* Update Metadata parsing

* Update Base.ts

* Update types.d.ts

* Cleanup base

* Cleanup linting (renamed imports)

* PR comments

* Update decoded Metadata.json
This commit is contained in:
Jaco Greeff
2018-10-11 10:20:54 +02:00
committed by GitHub
parent 05da1ee8c8
commit 27b2885722
13 changed files with 719 additions and 608 deletions
+9
View File
@@ -0,0 +1,9 @@
// Copyright 2017-2018 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const WS_URL = 'ws://127.0.0.1:9944';
export default {
WS_URL
};
+5 -2
View File
@@ -7,12 +7,15 @@ import { RpcSection, RpcMethod } from '@polkadot/jsonrpc/types';
import { RpcInterface, RpcInterface$Section, RpcInterface$Section$Method } from './types';
import interfaces from '@polkadot/jsonrpc/index';
import WsProvider from '@polkadot/rpc-provider/ws';
import { Base, Vector, createType } from '@polkadot/types/codec';
import { StorageChangeSet, StorageKey } from '@polkadot/types/index';
import assert from '@polkadot/util/assert';
import ExtError from '@polkadot/util/ext/error';
import isFunction from '@polkadot/util/is/function';
import defaults from './defaults';
/**
* @name Rpc
* @summary The API may use a HTTP or WebSockets provider.
@@ -37,7 +40,7 @@ import isFunction from '@polkadot/util/is/function';
* ```
*/
export default class Rpc implements RpcInterface {
private _provider: ProviderInterface;
readonly _provider: ProviderInterface;
readonly author: RpcInterface$Section;
readonly chain: RpcInterface$Section;
readonly state: RpcInterface$Section;
@@ -48,7 +51,7 @@ export default class Rpc implements RpcInterface {
* Default constructor for the Api Object
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket
*/
constructor (provider: ProviderInterface) {
constructor (provider: ProviderInterface = new WsProvider(defaults.WS_URL)) {
assert(provider && isFunction(provider.send), 'Expected Provider to API create');
this._provider = provider;