diff --git a/docs/api-provider/README.md b/docs/api-provider/README.md deleted file mode 100644 index 3c876d1363..0000000000 --- a/docs/api-provider/README.md +++ /dev/null @@ -1,28 +0,0 @@ - -[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org) ![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square) [![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard) [![npm](https://img.shields.io/npm/v/@polkadot/api-provider.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api-provider) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api-provider)](https://david-dm.org/polkadot-js/api?path=packages/api-provider) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api-provider)](https://david-dm.org/polkadot-js/api?path=packages/api-provider#info=devDependencies) - -@polkadot/api-provider -====================== - -Generic transport providers to handle the transport of method calls to and from Polkadot clients from applications interacting with it. Generally, unless you are operating at a low-level and taking care of encoding and decoding of parameters/results, it won't be directly used. API interfaces building on top these providers can support various transports with the same underlying interfaces. - -Usage ------ - -Installation - - -``` -npm install --save @polkadot/api-provider -``` - -Initialisation - - -```js -import WsProvider from '@polkadot/api-provider/ws'; - -const provider = new WsProvider('http://127.0.0.1:9944'); -const version = await provider.send('client_version', []); - -console.log('clientVersion', version); -``` - diff --git a/docs/api-provider/SUMMARY.md b/docs/api-provider/SUMMARY.md deleted file mode 100644 index 2b24fb5fc5..0000000000 --- a/docs/api-provider/SUMMARY.md +++ /dev/null @@ -1,23 +0,0 @@ -* ["coder/json/decodeResponse"](modules/_coder_json_decoderesponse_.md) -* ["coder/json/encodeJson"](modules/_coder_json_encodejson_.md) -* ["coder/json/encodeObject"](modules/_coder_json_encodeobject_.md) -* ["coder/json/index"](modules/_coder_json_index_.md) -* ["coder/json/types.d"](modules/_coder_json_types_d_.md) -* ["http/index"](modules/_http_index_.md) - * [HttpProvider](classes/_http_index_.httpprovider.md) -* ["http/polyfill"](modules/_http_polyfill_.md) -* ["http/types.d"](modules/_http_types_d_.md) -* ["index"](modules/_index_.md) -* ["mock/index"](modules/_mock_index_.md) -* ["mock/mocks"](modules/_mock_mocks_.md) -* ["mock/on"](modules/_mock_on_.md) -* ["mock/send"](modules/_mock_send_.md) -* ["mock/state"](modules/_mock_state_.md) -* ["mock/subscribe"](modules/_mock_subscribe_.md) -* ["mock/types.d"](modules/_mock_types_d_.md) -* ["mock/unsubscribe"](modules/_mock_unsubscribe_.md) -* ["types.d"](modules/_types_d_.md) - * [ProviderInterface](interfaces/_types_d_.providerinterface.md) -* ["ws/index"](modules/_ws_index_.md) - * [WsProvider](classes/_ws_index_.wsprovider.md) -* ["ws/polyfill"](modules/_ws_polyfill_.md) diff --git a/docs/api-provider/classes/_http_index_.httpprovider.html b/docs/api-provider/classes/_http_index_.httpprovider.html deleted file mode 100644 index 54ce384eb0..0000000000 --- a/docs/api-provider/classes/_http_index_.httpprovider.html +++ /dev/null @@ -1,623 +0,0 @@ - - - - - - - HttpProvider · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - -
- -
- -
- - - - - - - - -
-
- -
-
- -
- -

name: HttpProvider

-

summary: The HTTP Provider allows sending requests using HTTP to a HTTP RPC server TCP port.

-

description: It does not support subscriptions so you won't be able to listen to events such as new blocks or balance changes. It is usually preferrable using the WsProvider.

-

example:

-
import Api from '@polkadot/api';
-import HttpProvider from '@polkadot/api-provider/http';
-
-const provider = new HttpProvider('http://127.0.0.1:9933');
-const api = new Api(provider);
-
-

see: WsProvider

-

Hierarchy

-

HttpProvider

-

Implements

- -

Constructors

-

-

constructor

-

⊕ new HttpProvider(endpoint: string): HttpProvider

-

Defined in http/index.ts:40

-

Parameters:

- - - - - - - - - - - - - - - -
ParamTypeDescription
endpointstringThe endpoint url starting with http://
-

Returns: HttpProvider

-
-

Methods

-

-

isConnected

-

▸ isConnected(): boolean

-

Implementation of ProviderInterface.isConnected

-

Defined in http/index.ts:57

-

summary: Whether the node is connected or not.

-

Returns: boolean -true if connected

-
-

-

on

-

▸ on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): void

-

Implementation of ProviderInterface.on

-

Defined in http/index.ts:65

-

summary: Events are not supported with the HttpProvider, see WsProvider.

-

description: HTTP Provider does not have 'on' emitters. WebSockets should be used instead.

-

Parameters:

- - - - - - - - - - - - - - - - - -
ParamType
typeProviderInterface$Emitted
subProviderInterface$EmitCb
-

Returns: void

-
-

-

send

-

▸ send(method: string, params: Array<any>): Promise<any>

-

Implementation of ProviderInterface.send

-

Defined in http/index.ts:72

-

summary: Send HTTP POST Request with Body to configured HTTP Endpoint.

-

Parameters:

- - - - - - - - - - - - - - - - - -
ParamType
methodstring
paramsArray<any>
-

Returns: Promise<any>

-
-

-

subscribe

-

▸ subscribe(types: string, method: string, params: Array<any>, cb: ProviderInterface$Callback): Promise<number>

-

Implementation of ProviderInterface.subscribe

-

Defined in http/index.ts:94

-

summary: Subscriptions are not supported with the HttpProvider, see WsProvider.

-

Parameters:

- - - - - - - - - - - - - - - - - - - - - - - - - -
ParamType
typesstring
methodstring
paramsArray<any>
cbProviderInterface$Callback
-

Returns: Promise<number>

-
-

-

unsubscribe

-

▸ unsubscribe(type: string, method: string, id: number): Promise<boolean>

-

Implementation of ProviderInterface.unsubscribe

-

Defined in http/index.ts:103

-

summary: Subscriptions are not supported with the HttpProvider, see WsProvider.

-

Parameters:

- - - - - - - - - - - - - - - - - - - - - -
ParamType
typestring
methodstring
idnumber
-

Returns: Promise<boolean>

-
- - -
- -
-
-
- -

results matching ""

-
    - -
    -
    - -

    No results matching ""

    - -
    -
    -
    - -
    -
    - -
    - - - - - - - - - - - - - - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api-provider/classes/_http_index_.httpprovider.md b/docs/api-provider/classes/_http_index_.httpprovider.md deleted file mode 100644 index a1f6f00ffd..0000000000 --- a/docs/api-provider/classes/_http_index_.httpprovider.md +++ /dev/null @@ -1,159 +0,0 @@ - - -*__name__*: HttpProvider - -*__summary__*: The HTTP Provider allows sending requests using HTTP to a HTTP RPC server TCP port. - -*__description__*: It does not support subscriptions so you won't be able to listen to events such as new blocks or balance changes. It is usually preferrable using the [WsProvider](_ws_index_.wsprovider.md). - -*__example__*: -```javascript -import Api from '@polkadot/api'; -import HttpProvider from '@polkadot/api-provider/http'; - -const provider = new HttpProvider('http://127.0.0.1:9933'); -const api = new Api(provider); -``` - -*__see__*: [WsProvider](_ws_index_.wsprovider.md) - -# Hierarchy - -**HttpProvider** - -# Implements - -* [ProviderInterface](../interfaces/_types_d_.providerinterface.md) - -# Constructors - - - -## constructor - -⊕ **new HttpProvider**(endpoint: *`string`*): [HttpProvider](_http_index_.httpprovider.md) - -*Defined in [http/index.ts:40](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L40)* - -**Parameters:** - -| Param | Type | Description | -| ------ | ------ | ------ | -| endpoint | `string` | The endpoint url starting with http:// | - -**Returns:** [HttpProvider](_http_index_.httpprovider.md) - -___ - -# Methods - - - -## isConnected - -▸ **isConnected**(): `boolean` - -*Implementation of [ProviderInterface](../interfaces/_types_d_.providerinterface.md).[isConnected](../interfaces/_types_d_.providerinterface.md#isconnected)* - -*Defined in [http/index.ts:57](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L57)* - -*__summary__*: Whether the node is connected or not. - -**Returns:** `boolean` -true if connected - -___ - - -## on - -▸ **on**(type: *[ProviderInterface$Emitted](../modules/_types_d_.md#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](../modules/_types_d_.md#providerinterface_emitcb)*): `void` - -*Implementation of [ProviderInterface](../interfaces/_types_d_.providerinterface.md).[on](../interfaces/_types_d_.providerinterface.md#on)* - -*Defined in [http/index.ts:65](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L65)* - -*__summary__*: Events are not supported with the HttpProvider, see [WsProvider](_ws_index_.wsprovider.md). - -*__description__*: HTTP Provider does not have 'on' emitters. WebSockets should be used instead. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| type | [ProviderInterface$Emitted](../modules/_types_d_.md#providerinterface_emitted) | -| sub | [ProviderInterface$EmitCb](../modules/_types_d_.md#providerinterface_emitcb) | - -**Returns:** `void` - -___ - - -## send - -▸ **send**(method: *`string`*, params: *`Array`<`any`>*): `Promise`<`any`> - -*Implementation of [ProviderInterface](../interfaces/_types_d_.providerinterface.md).[send](../interfaces/_types_d_.providerinterface.md#send)* - -*Defined in [http/index.ts:72](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L72)* - -*__summary__*: Send HTTP POST Request with Body to configured HTTP Endpoint. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| method | `string` | -| params | `Array`<`any`> | - -**Returns:** `Promise`<`any`> - -___ - - -## subscribe - -▸ **subscribe**(types: *`string`*, method: *`string`*, params: *`Array`<`any`>*, cb: *[ProviderInterface$Callback](../modules/_types_d_.md#providerinterface_callback)*): `Promise`<`number`> - -*Implementation of [ProviderInterface](../interfaces/_types_d_.providerinterface.md).[subscribe](../interfaces/_types_d_.providerinterface.md#subscribe)* - -*Defined in [http/index.ts:94](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L94)* - -*__summary__*: Subscriptions are not supported with the HttpProvider, see [WsProvider](_ws_index_.wsprovider.md). - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| types | `string` | -| method | `string` | -| params | `Array`<`any`> | -| cb | [ProviderInterface$Callback](../modules/_types_d_.md#providerinterface_callback) | - -**Returns:** `Promise`<`number`> - -___ - - -## unsubscribe - -▸ **unsubscribe**(type: *`string`*, method: *`string`*, id: *`number`*): `Promise`<`boolean`> - -*Implementation of [ProviderInterface](../interfaces/_types_d_.providerinterface.md).[unsubscribe](../interfaces/_types_d_.providerinterface.md#unsubscribe)* - -*Defined in [http/index.ts:103](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L103)* - -*__summary__*: Subscriptions are not supported with the HttpProvider, see [WsProvider](_ws_index_.wsprovider.md). - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| type | `string` | -| method | `string` | -| id | `number` | - -**Returns:** `Promise`<`boolean`> - -___ - diff --git a/docs/api-provider/classes/_ws_index_.wsprovider.html b/docs/api-provider/classes/_ws_index_.wsprovider.html deleted file mode 100644 index 157965988e..0000000000 --- a/docs/api-provider/classes/_ws_index_.wsprovider.html +++ /dev/null @@ -1,904 +0,0 @@ - - - - - - - WsProvider · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - -
    - -
    - - - - - - - - -
    -
    - -
    -
    - -
    - -

    name: WsProvider

    -

    summary: The WebSocket Provider allows sending requests using WebSocket to a WebSocket RPC server TCP port.

    -

    description: Unlike the HttpProvider, it does support subscriptions and allows listening to events such as new blocks or balance changes.

    -

    example:

    -
    import Api from '@polkadot/api';
    -import WsProvider from '@polkadot/api-provider/ws';
    -
    -const provider = new WsProvider('ws://127.0.0.1:9944');
    -const api = new Api(provider);
    -
    -

    see: HttpProvider

    -

    Type parameters

    -

    EventTypes : string | symbol

    -

    Hierarchy

    -

    EventEmitter

    -

    ↳ WsProvider

    -

    Implements

    -
      -
    • WSProviderInterface
    • -
    -

    Constructors

    -

    -

    constructor

    -

    ⊕ new WsProvider(endpoint: string, autoConnect?: boolean): WsProvider

    -

    Defined in ws/index.ts:73

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - - - -
    ParamTypeDefault valueDescription
    endpointstring-The endpoint url. Usually `ws://ip:9944` or `wss://ip:9944`
    Default value autoConnectbooleantrueWhether to connect automatically or not.
    -

    Returns: WsProvider

    -
    -

    Properties

    -

    -

    <Static> prefixed

    -

    ● prefixed: string | boolean -

    -

    Inherited from EventEmitter.prefixed

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:6

    -
    -

    Methods

    -

    -

    addListener

    -

    ▸ addListener(event: EventTypes, fn: ListenerFn, context?: any): this

    -

    Inherited from EventEmitter.addListener

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:33

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    fnListenerFn
    Optional contextany
    -

    Returns: this

    -
    -

    -

    connect

    -

    ▸ connect(): void

    -

    Defined in ws/index.ts:104

    -

    summary: Manually connect

    -

    description: The WsProvider connects automatically by default, however if you decided otherwise, you may connect manually using this method.

    -

    Returns: void

    -
    -

    -

    emit

    -

    ▸ emit(event: EventTypes, ...args: Array<any>): boolean

    -

    Inherited from EventEmitter.emit

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:27

    -

    Calls each of the listeners registered for a given event.

    -

    Parameters:

    - - - - - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    Rest argsArray<any>
    -

    Returns: boolean

    -
    -

    -

    eventNames

    -

    ▸ eventNames(): Array<EventTypes>

    -

    Inherited from EventEmitter.eventNames

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:12

    -

    Return an array listing the events for which the emitter has registered listeners.

    -

    Returns: Array<EventTypes>

    -
    -

    -

    isConnected

    -

    ▸ isConnected(): boolean

    -

    Defined in ws/index.ts:121

    -

    summary: Whether the node is connected or not.

    -

    Returns: boolean -true if connected

    -
    -

    -

    listenerCount

    -

    ▸ listenerCount(event: EventTypes): number

    -

    Inherited from EventEmitter.listenerCount

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:22

    -

    Return the number of listeners listening to a given event.

    -

    Parameters:

    - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    -

    Returns: number

    -
    -

    -

    listeners

    -

    ▸ listeners(event: EventTypes): Array<ListenerFn>

    -

    Inherited from EventEmitter.listeners

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:17

    -

    Return the listeners registered for a given event.

    -

    Parameters:

    - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    -

    Returns: Array<ListenerFn>

    -
    -

    -

    off

    -

    ▸ off(event: EventTypes, fn?: ListenerFn, context?: any, once?: undefined | false | true): this

    -

    Inherited from EventEmitter.off

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:44

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    Optional fnListenerFn
    Optional contextany
    Optional onceundefined | false | true
    -

    Returns: this

    -
    -

    -

    on

    -

    ▸ on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): this

    -

    Overrides EventEmitter.on

    -

    Defined in ws/index.ts:131

    -

    summary: Listens on events after having subscribed using the subscribe function.

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - -
    ParamTypeDescription
    typeProviderInterface$EmittedEvent
    subProviderInterface$EmitCbCallback
    -

    Returns: this -[description]

    -
    -

    -

    once

    -

    ▸ once(event: EventTypes, fn: ListenerFn, context?: any): this

    -

    Inherited from EventEmitter.once

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:38

    -

    Add a one-time listener for a given event.

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    fnListenerFn
    Optional contextany
    -

    Returns: this

    -
    -

    -

    removeAllListeners

    -

    ▸ removeAllListeners(event?: EventTypes): this

    -

    Inherited from EventEmitter.removeAllListeners

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:49

    -

    Remove all listeners, or those of the specified event.

    -

    Parameters:

    - - - - - - - - - - - - - -
    ParamType
    Optional eventEventTypes
    -

    Returns: this

    -
    -

    -

    removeListener

    -

    ▸ removeListener(event: EventTypes, fn?: ListenerFn, context?: any, once?: undefined | false | true): this

    -

    Inherited from EventEmitter.removeListener

    -

    Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:43

    -

    Remove the listeners of a given event.

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParamType
    eventEventTypes
    Optional fnListenerFn
    Optional contextany
    Optional onceundefined | false | true
    -

    Returns: this

    -
    -

    -

    send

    -

    ▸ send(method: string, params: Array<any>, subscription?: SubscriptionHandler): Promise<any>

    -

    Defined in ws/index.ts:138

    -

    summary: Send JSON data using WebSockets to configured HTTP Endpoint or queue.

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - -
    ParamType
    methodstring
    paramsArray<any>
    Optional subscriptionSubscriptionHandler
    -

    Returns: Promise<any>

    -
    -

    -

    subscribe

    -

    ▸ subscribe(type: string, method: string, params: Array<any>, callback: ProviderInterface$Callback): Promise<number>

    -

    Defined in ws/index.ts:194

    -

    name: subscribe

    -

    summary: Allows subscribing to a specific event.

    -

    example:

    -
    const provider = new WsProvider('ws://127.0.0.1:9944');
    -const api = new Api(provider);
    -
    -api.state.storage([[storage.balances.freeBalance, <Address>]], (_, values) => {
    -  console.log(values)
    -}).then((subscriptionId) => {
    -  console.log('balance changes subscription id: ', subscriptionId)
    -})
    -
    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ParamTypeDescription
    typestringSubscription type
    methodstringSubscription method
    paramsArray<any>Parameters
    callbackProviderInterface$CallbackCallback
    -

    Returns: Promise<number> -Promise resolving to the dd of the subscription you can use with [[unsubscribe]].

    -
    -

    -

    unsubscribe

    -

    ▸ unsubscribe(type: string, method: string, id: number): Promise<boolean>

    -

    Defined in ws/index.ts:203

    -

    summary: Allows unsubscribing to subscriptions made with subscribe.

    -

    Parameters:

    - - - - - - - - - - - - - - - - - - - - - -
    ParamType
    typestring
    methodstring
    idnumber
    -

    Returns: Promise<boolean>

    -
    - - -
    - -
    -
    -
    - -

    results matching ""

    -
      - -
      -
      - -

      No results matching ""

      - -
      -
      -
      - -
      -
      - -
      - - - - - - - - - - - - - - -
      - - -
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api-provider/classes/_ws_index_.wsprovider.md b/docs/api-provider/classes/_ws_index_.wsprovider.md deleted file mode 100644 index ddc210875b..0000000000 --- a/docs/api-provider/classes/_ws_index_.wsprovider.md +++ /dev/null @@ -1,392 +0,0 @@ - - -*__name__*: WsProvider - -*__summary__*: The WebSocket Provider allows sending requests using WebSocket to a WebSocket RPC server TCP port. - -*__description__*: Unlike the [HttpProvider](_http_index_.httpprovider.md), it does support subscriptions and allows listening to events such as new blocks or balance changes. - -*__example__*: -```javascript -import Api from '@polkadot/api'; -import WsProvider from '@polkadot/api-provider/ws'; - -const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); -``` - -*__see__*: [HttpProvider](_http_index_.httpprovider.md) - -# Type parameters -#### EventTypes : `string` | `symbol` - -# Hierarchy - - `EventEmitter` - -**↳ WsProvider** - -# Implements - -* `WSProviderInterface` - -# Constructors - - - -## constructor - -⊕ **new WsProvider**(endpoint: *`string`*, autoConnect?: *`boolean`*): [WsProvider](_ws_index_.wsprovider.md) - -*Defined in [ws/index.ts:73](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L73)* - -**Parameters:** - -| Param | Type | Default value | Description | -| ------ | ------ | ------ | ------ | -| endpoint | `string` | - | The endpoint url. Usually \`ws://ip:9944\` or \`wss://ip:9944\` | -| `Default value` autoConnect | `boolean` | true | Whether to connect automatically or not. | - -**Returns:** [WsProvider](_ws_index_.wsprovider.md) - -___ - -# Properties - - - -## `` prefixed - -**● prefixed**: * `string` | `boolean` -* - -*Inherited from EventEmitter.prefixed* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:6* - -___ - -# Methods - - - -## addListener - -▸ **addListener**(event: *`EventTypes`*, fn: *`ListenerFn`*, context?: *`any`*): `this` - -*Inherited from EventEmitter.addListener* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:33* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | -| fn | `ListenerFn` | -| `Optional` context | `any` | - -**Returns:** `this` - -___ - - -## connect - -▸ **connect**(): `void` - -*Defined in [ws/index.ts:104](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L104)* - -*__summary__*: Manually connect - -*__description__*: The [WsProvider](_ws_index_.wsprovider.md) connects automatically by default, however if you decided otherwise, you may connect manually using this method. - -**Returns:** `void` - -___ - - -## emit - -▸ **emit**(event: *`EventTypes`*, ...args: *`Array`<`any`>*): `boolean` - -*Inherited from EventEmitter.emit* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:27* - -Calls each of the listeners registered for a given event. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | -| `Rest` args | `Array`<`any`> | - -**Returns:** `boolean` - -___ - - -## eventNames - -▸ **eventNames**(): `Array`<`EventTypes`> - -*Inherited from EventEmitter.eventNames* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:12* - -Return an array listing the events for which the emitter has registered listeners. - -**Returns:** `Array`<`EventTypes`> - -___ - - -## isConnected - -▸ **isConnected**(): `boolean` - -*Defined in [ws/index.ts:121](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L121)* - -*__summary__*: Whether the node is connected or not. - -**Returns:** `boolean` -true if connected - -___ - - -## listenerCount - -▸ **listenerCount**(event: *`EventTypes`*): `number` - -*Inherited from EventEmitter.listenerCount* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:22* - -Return the number of listeners listening to a given event. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | - -**Returns:** `number` - -___ - - -## listeners - -▸ **listeners**(event: *`EventTypes`*): `Array`<`ListenerFn`> - -*Inherited from EventEmitter.listeners* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:17* - -Return the listeners registered for a given event. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | - -**Returns:** `Array`<`ListenerFn`> - -___ - - -## off - -▸ **off**(event: *`EventTypes`*, fn?: *[ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md)*, context?: *`any`*, once?: * `undefined` | `false` | `true`*): `this` - -*Inherited from EventEmitter.off* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:44* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | -| `Optional` fn | [ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md) | -| `Optional` context | `any` | -| `Optional` once | `undefined` | `false` | `true`| - -**Returns:** `this` - -___ - - -## on - -▸ **on**(type: *[ProviderInterface$Emitted](../modules/_types_d_.md#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](../modules/_types_d_.md#providerinterface_emitcb)*): `this` - -*Overrides EventEmitter.on* - -*Defined in [ws/index.ts:131](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L131)* - -*__summary__*: Listens on events after having subscribed using the [subscribe](_ws_index_.wsprovider.md#subscribe) function. - -**Parameters:** - -| Param | Type | Description | -| ------ | ------ | ------ | -| type | [ProviderInterface$Emitted](../modules/_types_d_.md#providerinterface_emitted) | Event | -| sub | [ProviderInterface$EmitCb](../modules/_types_d_.md#providerinterface_emitcb) | Callback | - -**Returns:** `this` -[description] - -___ - - -## once - -▸ **once**(event: *`EventTypes`*, fn: *`ListenerFn`*, context?: *`any`*): `this` - -*Inherited from EventEmitter.once* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:38* - -Add a one-time listener for a given event. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | -| fn | `ListenerFn` | -| `Optional` context | `any` | - -**Returns:** `this` - -___ - - -## removeAllListeners - -▸ **removeAllListeners**(event?: *[EventTypes]()*): `this` - -*Inherited from EventEmitter.removeAllListeners* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:49* - -Remove all listeners, or those of the specified event. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| `Optional` event | [EventTypes]() | - -**Returns:** `this` - -___ - - -## removeListener - -▸ **removeListener**(event: *`EventTypes`*, fn?: *[ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md)*, context?: *`any`*, once?: * `undefined` | `false` | `true`*): `this` - -*Inherited from EventEmitter.removeListener* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:43* - -Remove the listeners of a given event. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| event | `EventTypes` | -| `Optional` fn | [ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md) | -| `Optional` context | `any` | -| `Optional` once | `undefined` | `false` | `true`| - -**Returns:** `this` - -___ - - -## send - -▸ **send**(method: *`string`*, params: *`Array`<`any`>*, subscription?: *`SubscriptionHandler`*): `Promise`<`any`> - -*Defined in [ws/index.ts:138](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L138)* - -*__summary__*: Send JSON data using WebSockets to configured HTTP Endpoint or queue. - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| method | `string` | -| params | `Array`<`any`> | -| `Optional` subscription | `SubscriptionHandler` | - -**Returns:** `Promise`<`any`> - -___ - - -## subscribe - -▸ **subscribe**(type: *`string`*, method: *`string`*, params: *`Array`<`any`>*, callback: *[ProviderInterface$Callback](../modules/_types_d_.md#providerinterface_callback)*): `Promise`<`number`> - -*Defined in [ws/index.ts:194](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L194)* - -*__name__*: subscribe - -*__summary__*: Allows subscribing to a specific event. - -*__example__*: -```javascript -const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); - -api.state.storage([[storage.balances.freeBalance,
      ]], (_, values) => { - console.log(values) -}).then((subscriptionId) => { - console.log('balance changes subscription id: ', subscriptionId) -}) -``` - -**Parameters:** - -| Param | Type | Description | -| ------ | ------ | ------ | -| type | `string` | Subscription type | -| method | `string` | Subscription method | -| params | `Array`<`any`> | Parameters | -| callback | [ProviderInterface$Callback](../modules/_types_d_.md#providerinterface_callback) | Callback | - -**Returns:** `Promise`<`number`> -Promise resolving to the dd of the subscription you can use with [[unsubscribe]]. - -___ - - -## unsubscribe - -▸ **unsubscribe**(type: *`string`*, method: *`string`*, id: *`number`*): `Promise`<`boolean`> - -*Defined in [ws/index.ts:203](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L203)* - -*__summary__*: Allows unsubscribing to subscriptions made with [subscribe](_ws_index_.wsprovider.md#subscribe). - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| type | `string` | -| method | `string` | -| id | `number` | - -**Returns:** `Promise`<`boolean`> - -___ - diff --git a/docs/api-provider/index.html b/docs/api-provider/index.html deleted file mode 100644 index 3c04b66003..0000000000 --- a/docs/api-provider/index.html +++ /dev/null @@ -1,465 +0,0 @@ - - - - - - - api-provider · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      -
      - - - - - - - - -
      - -
      - -
      - - - - - - - - -
      -
      - -
      -
      - -
      - -

      polkadotjs isc style npm travis maintainability coverage dependency devDependency

      -

      @polkadot/api-provider

      -

      Generic transport providers to handle the transport of method calls to and from Polkadot clients from applications interacting with it. Generally, unless you are operating at a low-level and taking care of encoding and decoding of parameters/results, it won't be directly used. API interfaces building on top these providers can support various transports with the same underlying interfaces.

      -

      Usage

      -

      Installation -

      -
      npm install --save @polkadot/api-provider
      -

      Initialisation -

      -
      import WsProvider from '@polkadot/api-provider/ws';
      -
      -const provider = new WsProvider('http://127.0.0.1:9944');
      -const version = await provider.send('client_version', []);
      -
      -console.log('clientVersion', version);
      -
      - - -
      - -
      -
      -
      - -

      results matching ""

      -
        - -
        -
        - -

        No results matching ""

        - -
        -
        -
        - -
        -
        - -
        - - - - - - - - - - - - - - -
        - - -
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api-provider/interfaces/_types_d_.providerinterface.md b/docs/api-provider/interfaces/_types_d_.providerinterface.md deleted file mode 100644 index 2747fe448f..0000000000 --- a/docs/api-provider/interfaces/_types_d_.providerinterface.md +++ /dev/null @@ -1,99 +0,0 @@ - - -# Hierarchy - -**ProviderInterface** - -# Implemented by - -* [HttpProvider](../classes/_http_index_.httpprovider.md) - -# Methods - - - -## isConnected - -▸ **isConnected**(): `boolean` - -*Defined in [types.d.ts:45](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L45)* - -**Returns:** `boolean` - -___ - - -## on - -▸ **on**(type: *[ProviderInterface$Emitted](../modules/_types_d_.md#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](../modules/_types_d_.md#providerinterface_emitcb)*): `void` - -*Defined in [types.d.ts:46](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L46)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| type | [ProviderInterface$Emitted](../modules/_types_d_.md#providerinterface_emitted) | -| sub | [ProviderInterface$EmitCb](../modules/_types_d_.md#providerinterface_emitcb) | - -**Returns:** `void` - -___ - - -## send - -▸ **send**(method: *`string`*, params: *`Array`<`any`>*): `Promise`<`any`> - -*Defined in [types.d.ts:47](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L47)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| method | `string` | -| params | `Array`<`any`> | - -**Returns:** `Promise`<`any`> - -___ - - -## subscribe - -▸ **subscribe**(type: *`string`*, method: *`string`*, params: *`Array`<`any`>*, cb: *[ProviderInterface$Callback](../modules/_types_d_.md#providerinterface_callback)*): `Promise`<`number`> - -*Defined in [types.d.ts:48](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L48)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| type | `string` | -| method | `string` | -| params | `Array`<`any`> | -| cb | [ProviderInterface$Callback](../modules/_types_d_.md#providerinterface_callback) | - -**Returns:** `Promise`<`number`> - -___ - - -## unsubscribe - -▸ **unsubscribe**(type: *`string`*, method: *`string`*, id: *`number`*): `Promise`<`boolean`> - -*Defined in [types.d.ts:49](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L49)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| type | `string` | -| method | `string` | -| id | `number` | - -**Returns:** `Promise`<`boolean`> - -___ - diff --git a/docs/api-provider/interfaces/_ws_index_.wsprovider.eventemitter.eventemitterstatic.md b/docs/api-provider/interfaces/_ws_index_.wsprovider.eventemitter.eventemitterstatic.md deleted file mode 100644 index 0f98348674..0000000000 --- a/docs/api-provider/interfaces/_ws_index_.wsprovider.eventemitter.eventemitterstatic.md +++ /dev/null @@ -1,24 +0,0 @@ - - -# Hierarchy - -**EventEmitterStatic** - -# Constructors - - - -## constructor - -⊕ **new EventEmitterStatic**<`EventTypes`>(): `EventEmitter`<`EventTypes`> - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:57* - -**Type parameters:** - -#### EventTypes : `string` | `symbol` - -**Returns:** `EventEmitter`<`EventTypes`> - -___ - diff --git a/docs/api-provider/interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md b/docs/api-provider/interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md deleted file mode 100644 index a621570ab6..0000000000 --- a/docs/api-provider/interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md +++ /dev/null @@ -1,19 +0,0 @@ - - -# Hierarchy - -**ListenerFn** - -# Callable -▸ **__call**(...args: *`Array`<`any`>*): `void` - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:53* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| `Rest` args | `Array`<`any`> | - -**Returns:** `void` - diff --git a/docs/api-provider/modules/_coder_json_decoderesponse_.md b/docs/api-provider/modules/_coder_json_decoderesponse_.md deleted file mode 100644 index 61c71bfe8b..0000000000 --- a/docs/api-provider/modules/_coder_json_decoderesponse_.md +++ /dev/null @@ -1,23 +0,0 @@ - - -# Functions - - - -## decodeResponse - -▸ **decodeResponse**(self: *[RpcCoderState](_coder_json_types_d_.md#rpccoderstate)*, response: *[JsonRpcResponse](_types_d_.md#jsonrpcresponse)*): `any` - -*Defined in [coder/json/decodeResponse.ts:22](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/coder/json/decodeResponse.ts#L22)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| self | [RpcCoderState](_coder_json_types_d_.md#rpccoderstate) | -| response | [JsonRpcResponse](_types_d_.md#jsonrpcresponse) | - -**Returns:** `any` - -___ - diff --git a/docs/api-provider/modules/_coder_json_encodejson_.md b/docs/api-provider/modules/_coder_json_encodejson_.md deleted file mode 100644 index af2dd5ced1..0000000000 --- a/docs/api-provider/modules/_coder_json_encodejson_.md +++ /dev/null @@ -1,24 +0,0 @@ - - -# Functions - - - -## encodeJson - -▸ **encodeJson**(self: *[RpcCoderState](_coder_json_types_d_.md#rpccoderstate)*, method: *`string`*, params: *`Array`<`any`>*): `string` - -*Defined in [coder/json/encodeJson.ts:9](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/coder/json/encodeJson.ts#L9)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| self | [RpcCoderState](_coder_json_types_d_.md#rpccoderstate) | -| method | `string` | -| params | `Array`<`any`> | - -**Returns:** `string` - -___ - diff --git a/docs/api-provider/modules/_coder_json_encodeobject_.md b/docs/api-provider/modules/_coder_json_encodeobject_.md deleted file mode 100644 index aee19c8d04..0000000000 --- a/docs/api-provider/modules/_coder_json_encodeobject_.md +++ /dev/null @@ -1,24 +0,0 @@ - - -# Functions - - - -## encodeObject - -▸ **encodeObject**(self: *[RpcCoderState](_coder_json_types_d_.md#rpccoderstate)*, method: *`string`*, params: *`Array`<`any`>*): [JsonRpcRequest](_types_d_.md#jsonrpcrequest) - -*Defined in [coder/json/encodeObject.ts:8](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/coder/json/encodeObject.ts#L8)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| self | [RpcCoderState](_coder_json_types_d_.md#rpccoderstate) | -| method | `string` | -| params | `Array`<`any`> | - -**Returns:** [JsonRpcRequest](_types_d_.md#jsonrpcrequest) - -___ - diff --git a/docs/api-provider/modules/_coder_json_index_.md b/docs/api-provider/modules/_coder_json_index_.md deleted file mode 100644 index 8e88245505..0000000000 --- a/docs/api-provider/modules/_coder_json_index_.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Functions - - - -## rpcCoder - -▸ **rpcCoder**(): [RpcCoder](_coder_json_types_d_.md#rpccoder) - -*Defined in [coder/json/index.ts:12](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/coder/json/index.ts#L12)* - -**Returns:** [RpcCoder](_coder_json_types_d_.md#rpccoder) - -___ - diff --git a/docs/api-provider/modules/_coder_json_types_d_.md b/docs/api-provider/modules/_coder_json_types_d_.md deleted file mode 100644 index 36b3f41af8..0000000000 --- a/docs/api-provider/modules/_coder_json_types_d_.md +++ /dev/null @@ -1,27 +0,0 @@ - - -# Type aliases - - - -## RpcCoder - -**Ƭ RpcCoder**: *`object`* - -*Defined in [coder/json/types.d.ts:7](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/coder/json/types.d.ts#L7)* - -#### Type declaration - -___ - - -## RpcCoderState - -**Ƭ RpcCoderState**: *`object`* - -*Defined in [coder/json/types.d.ts:14](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/coder/json/types.d.ts#L14)* - -#### Type declaration - -___ - diff --git a/docs/api-provider/modules/_http_index_.md b/docs/api-provider/modules/_http_index_.md deleted file mode 100644 index b670dfa25b..0000000000 --- a/docs/api-provider/modules/_http_index_.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# Index - -### Classes - -* [HttpProvider](../classes/_http_index_.httpprovider.md) - ---- - diff --git a/docs/api-provider/modules/_http_polyfill_.md b/docs/api-provider/modules/_http_polyfill_.md deleted file mode 100644 index 139597f9cb..0000000000 --- a/docs/api-provider/modules/_http_polyfill_.md +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/docs/api-provider/modules/_http_types_d_.md b/docs/api-provider/modules/_http_types_d_.md deleted file mode 100644 index 2f651e0bf3..0000000000 --- a/docs/api-provider/modules/_http_types_d_.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Type aliases - - - -## HttpState - -**Ƭ HttpState**: *`object`* - -*Defined in [http/types.d.ts:8](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/types.d.ts#L8)* - -#### Type declaration - -___ - diff --git a/docs/api-provider/modules/_index_.md b/docs/api-provider/modules/_index_.md deleted file mode 100644 index 139597f9cb..0000000000 --- a/docs/api-provider/modules/_index_.md +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/docs/api-provider/modules/_mock_index_.md b/docs/api-provider/modules/_mock_index_.md deleted file mode 100644 index 5eb170c23e..0000000000 --- a/docs/api-provider/modules/_mock_index_.md +++ /dev/null @@ -1,19 +0,0 @@ - - -# Functions - - - -## mockProvider - -▸ **mockProvider**(): [ProviderInterface](../interfaces/_types_d_.providerinterface.md) - -*Defined in [mock/index.ts:18](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/index.ts#L18)* - -A moock provider mainly used for testing. - -**Returns:** [ProviderInterface](../interfaces/_types_d_.providerinterface.md) -The mock provider - -___ - diff --git a/docs/api-provider/modules/_mock_mocks_.md b/docs/api-provider/modules/_mock_mocks_.md deleted file mode 100644 index c1a7b855b4..0000000000 --- a/docs/api-provider/modules/_mock_mocks_.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# Functions - - - -## mocks - -▸ **mocks**(__namedParameters: *`object`*): `void` - -*Defined in [mock/mocks.ts:63](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/mocks.ts#L63)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| __namedParameters | `object` | - -**Returns:** `void` - -___ - diff --git a/docs/api-provider/modules/_mock_on_.md b/docs/api-provider/modules/_mock_on_.md deleted file mode 100644 index 9ef5265170..0000000000 --- a/docs/api-provider/modules/_mock_on_.md +++ /dev/null @@ -1,24 +0,0 @@ - - -# Functions - - - -## on - -▸ **on**(self: *[MockState](_mock_types_d_.md#mockstate)*, type: *[ProviderInterface$Emitted](_types_d_.md#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](_types_d_.md#providerinterface_emitcb)*): `void` - -*Defined in [mock/on.ts:8](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/on.ts#L8)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| self | [MockState](_mock_types_d_.md#mockstate) | -| type | [ProviderInterface$Emitted](_types_d_.md#providerinterface_emitted) | -| sub | [ProviderInterface$EmitCb](_types_d_.md#providerinterface_emitcb) | - -**Returns:** `void` - -___ - diff --git a/docs/api-provider/modules/_mock_send_.md b/docs/api-provider/modules/_mock_send_.md deleted file mode 100644 index 3a02b45d1a..0000000000 --- a/docs/api-provider/modules/_mock_send_.md +++ /dev/null @@ -1,24 +0,0 @@ - - -# Functions - - - -## send - -▸ **send**(__namedParameters: *`object`*, method: *`string`*, params: *`Array`<`any`>*): `Promise`<`any`> - -*Defined in [mock/send.ts:7](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/send.ts#L7)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| __namedParameters | `object` | -| method | `string` | -| params | `Array`<`any`> | - -**Returns:** `Promise`<`any`> - -___ - diff --git a/docs/api-provider/modules/_mock_state_.md b/docs/api-provider/modules/_mock_state_.md deleted file mode 100644 index 3de6b1e3ab..0000000000 --- a/docs/api-provider/modules/_mock_state_.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Functions - - - -## state - -▸ **state**(): [MockState](_mock_types_d_.md#mockstate) - -*Defined in [mock/state.ts:38](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/state.ts#L38)* - -**Returns:** [MockState](_mock_types_d_.md#mockstate) - -___ - diff --git a/docs/api-provider/modules/_mock_subscribe_.md b/docs/api-provider/modules/_mock_subscribe_.md deleted file mode 100644 index 41c4d8fb3d..0000000000 --- a/docs/api-provider/modules/_mock_subscribe_.md +++ /dev/null @@ -1,25 +0,0 @@ - - -# Functions - - - -## subscribe - -▸ **subscribe**(self: *[MockState](_mock_types_d_.md#mockstate)*, type: *`string`*, method: *`string`*, params: *`Array`<`any`>*): `Promise`<`number`> - -*Defined in [mock/subscribe.ts:7](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/subscribe.ts#L7)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| self | [MockState](_mock_types_d_.md#mockstate) | -| type | `string` | -| method | `string` | -| params | `Array`<`any`> | - -**Returns:** `Promise`<`number`> - -___ - diff --git a/docs/api-provider/modules/_mock_types_d_.md b/docs/api-provider/modules/_mock_types_d_.md deleted file mode 100644 index d3ab13698d..0000000000 --- a/docs/api-provider/modules/_mock_types_d_.md +++ /dev/null @@ -1,87 +0,0 @@ - - -# Type aliases - - - -## MockState - -**Ƭ MockState**: *`object`* - -*Defined in [mock/types.d.ts:27](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/types.d.ts#L27)* - -#### Type declaration - -___ - - -## MockState$Db - -**Ƭ MockState$Db**: *`object`* - -*Defined in [mock/types.d.ts:19](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/types.d.ts#L19)* - -#### Type declaration - -[index: `string`]: `Uint8Array` - -___ - - -## MockState$Requests - -**Ƭ MockState$Requests**: *`object`* - -*Defined in [mock/types.d.ts:23](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/types.d.ts#L23)* - -#### Type declaration - -[index: `string`]: `function` - -▸(db: *[MockState$Db](_mock_types_d_.md#mockstate_db)*, params: *`Array`<`any`>*): `string` - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| db | [MockState$Db](_mock_types_d_.md#mockstate_db) | -| params | `Array`<`any`> | - -**Returns:** `string` - -___ - - -## MockState$Subscription$Callback - -**Ƭ MockState$Subscription$Callback**: *`function`* - -*Defined in [mock/types.d.ts:8](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/types.d.ts#L8)* - -#### Type declaration -▸(error: * `Error` | `null`*, value: *`any`*): `void` - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| error | `Error` | `null`| -| value | `any` | - -**Returns:** `void` - -___ - - -## MockState$Subscriptions - -**Ƭ MockState$Subscriptions**: *`object`* - -*Defined in [mock/types.d.ts:10](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/types.d.ts#L10)* - -#### Type declaration - -[index: `string`]: `object` - -___ - diff --git a/docs/api-provider/modules/_mock_unsubscribe_.md b/docs/api-provider/modules/_mock_unsubscribe_.md deleted file mode 100644 index a9ed881818..0000000000 --- a/docs/api-provider/modules/_mock_unsubscribe_.md +++ /dev/null @@ -1,25 +0,0 @@ - - -# Functions - - - -## unsubscribe - -▸ **unsubscribe**(self: *[MockState](_mock_types_d_.md#mockstate)*, type: *`string`*, name: *`string`*, id: *`number`*): `Promise`<`boolean`> - -*Defined in [mock/unsubscribe.ts:7](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/mock/unsubscribe.ts#L7)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| self | [MockState](_mock_types_d_.md#mockstate) | -| type | `string` | -| name | `string` | -| id | `number` | - -**Returns:** `Promise`<`boolean`> - -___ - diff --git a/docs/api-provider/modules/_types_d_.md b/docs/api-provider/modules/_types_d_.md deleted file mode 100644 index 2c703ae788..0000000000 --- a/docs/api-provider/modules/_types_d_.md +++ /dev/null @@ -1,108 +0,0 @@ - - -# Type aliases - - - -## JsonRpcObject - -**Ƭ JsonRpcObject**: *`object`* - -*Defined in [types.d.ts:5](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L5)* - -#### Type declaration - -___ - - -## JsonRpcRequest - -**Ƭ JsonRpcRequest**: * [JsonRpcObject](_types_d_.md#jsonrpcobject) & `object` -* - -*Defined in [types.d.ts:10](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L10)* - -___ - - -## JsonRpcResponse - -**Ƭ JsonRpcResponse**: * [JsonRpcObject](_types_d_.md#jsonrpcobject) & [JsonRpcResponseBase](_types_d_.md#jsonrpcresponsebase) -* - -*Defined in [types.d.ts:36](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L36)* - -___ - - -## JsonRpcResponseBase - -**Ƭ JsonRpcResponseBase**: * `JsonRpcResponse$Single` & `JsonRpcResponse$Subscription` -* - -*Defined in [types.d.ts:34](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L34)* - -___ - - -## JsonRpcResponseBase$Error - -**Ƭ JsonRpcResponseBase$Error**: *`object`* - -*Defined in [types.d.ts:15](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L15)* - -#### Type declaration - -___ - - -## ProviderInterface$Callback - -**Ƭ ProviderInterface$Callback**: *`function`* - -*Defined in [types.d.ts:38](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L38)* - -#### Type declaration -▸(error: * `Error` | `null`*, result: *`any`*): `void` - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| error | `Error` | `null`| -| result | `any` | - -**Returns:** `void` - -___ - - -## ProviderInterface$EmitCb - -**Ƭ ProviderInterface$EmitCb**: *`function`* - -*Defined in [types.d.ts:42](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L42)* - -#### Type declaration -▸(value?: *`any`*): `any` - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| `Optional` value | `any` | - -**Returns:** `any` - -___ - - -## ProviderInterface$Emitted - -**Ƭ ProviderInterface$Emitted**: * "connected" | "disconnected" -* - -*Defined in [types.d.ts:40](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L40)* - -___ - diff --git a/docs/api-provider/modules/_ws_index_.md b/docs/api-provider/modules/_ws_index_.md deleted file mode 100644 index 5849e288b4..0000000000 --- a/docs/api-provider/modules/_ws_index_.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# Index - -### Classes - -* [WsProvider](../classes/_ws_index_.wsprovider.md) - ---- - diff --git a/docs/api-provider/modules/_ws_index_.wsprovider.eventemitter.md b/docs/api-provider/modules/_ws_index_.wsprovider.eventemitter.md deleted file mode 100644 index 18004cecc2..0000000000 --- a/docs/api-provider/modules/_ws_index_.wsprovider.eventemitter.md +++ /dev/null @@ -1,27 +0,0 @@ - - -# Index - -### Interfaces - -* [EventEmitterStatic](../interfaces/_ws_index_.wsprovider.eventemitter.eventemitterstatic.md) -* [ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md) - -### Variables - -* [EventEmitter](_ws_index_.wsprovider.eventemitter.md#eventemitter) - ---- - -# Variables - - - -## `` EventEmitter - -**● EventEmitter**: *`EventEmitterStatic`* - -*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:61* - -___ - diff --git a/docs/api-provider/modules/_ws_polyfill_.md b/docs/api-provider/modules/_ws_polyfill_.md deleted file mode 100644 index 139597f9cb..0000000000 --- a/docs/api-provider/modules/_ws_polyfill_.md +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/docs/api-rx/README.md b/docs/api-rx/README.md deleted file mode 100644 index 0a560dd8d1..0000000000 --- a/docs/api-rx/README.md +++ /dev/null @@ -1,8 +0,0 @@ - -[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org) ![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square) [![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard) [![npm](https://img.shields.io/npm/v/@polkadot/api-rx.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api-rx) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api-rx)](https://david-dm.org/polkadot-js/api?path=packages/api-rx) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api-rx)](https://david-dm.org/polkadot-js/api?path=packages/api-rx#info=devDependencies) - -@polkadot/api-rx -================ - -An RxJs wrapper around the [@polkadot/api](../api). - diff --git a/docs/api-rx/SUMMARY.md b/docs/api-rx/SUMMARY.md deleted file mode 100644 index 4194bf89d2..0000000000 --- a/docs/api-rx/SUMMARY.md +++ /dev/null @@ -1,4 +0,0 @@ -* ["defaults"](modules/_defaults_.md) -* ["index"](modules/_index_.md) - * [RxApi](classes/_index_.rxapi.md) -* ["types.d"](modules/_types_d_.md) diff --git a/docs/api-rx/classes/_index_.rxapi.html b/docs/api-rx/classes/_index_.rxapi.html deleted file mode 100644 index 45c2d70f1b..0000000000 --- a/docs/api-rx/classes/_index_.rxapi.html +++ /dev/null @@ -1,521 +0,0 @@ - - - - - - - ApiRx · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        -
        - - - - - - - - -
        - -
        - -
        - - - - - - - - -
        -
        - -
        -
        - -
        - -

        name: RxApi

        -

        summary: The RxJS API is a wrapper around the API.

        -

        description: It allows wrapping API components with observables using RxJS.

        -

        example:

        -
        import RxApi from '@polkadot/api';
        -import WsProvider from '@polkadot/api-provider/ws';
        -
        -const provider = new WsProvider('http://127.0.0.1:9944');
        -const rxapi = new RxApi(provider);
        -
        -

        Hierarchy

        -

        RxApi

        -

        Implements

        -
          -
        • object
        • -
        -

        Constructors

        -

        -

        constructor

        -

        ⊕ new RxApi(provider?: ProviderInterface): RxApi

        -

        Defined in index.ts:46

        -

        Parameters:

        - - - - - - - - - - - - - - - - - -
        ParamTypeDefault valueDescription
        Default value providerProviderInterfacenew Ws(defaults.WS_URL)An API provider using HTTP or WebSocket
        -

        Returns: RxApi

        -
        -

        Properties

        -

        -

        author

        -

        ● author: RxApiInterface$Section

        -

        Defined in index.ts:43

        -
        -

        -

        chain

        -

        ● chain: RxApiInterface$Section

        -

        Defined in index.ts:44

        -
        -

        -

        state

        -

        ● state: RxApiInterface$Section

        -

        Defined in index.ts:45

        -
        -

        -

        system

        -

        ● system: RxApiInterface$Section

        -

        Defined in index.ts:46

        -
        -

        Methods

        -

        -

        isConnected

        -

        ▸ isConnected(): BehaviorSubject<boolean>

        -

        Defined in index.ts:65

        -

        Returns: BehaviorSubject<boolean>

        -
        - - -
        - -
        -
        -
        - -

        results matching ""

        -
          - -
          -
          - -

          No results matching ""

          - -
          -
          -
          - -
          -
          - -
          - - - - - - - - - - - - - - -
          - - -
          - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api-rx/classes/_index_.rxapi.md b/docs/api-rx/classes/_index_.rxapi.md deleted file mode 100644 index 605da9b044..0000000000 --- a/docs/api-rx/classes/_index_.rxapi.md +++ /dev/null @@ -1,98 +0,0 @@ - - -*__name__*: RxApi - -*__summary__*: The RxJS API is a wrapper around the API. - -*__description__*: It allows wrapping API components with observables using RxJS. - -*__example__*: -```javascript -import RxApi from '@polkadot/api'; -import WsProvider from '@polkadot/api-provider/ws'; - -const provider = new WsProvider('http://127.0.0.1:9944'); -const rxapi = new RxApi(provider); -``` - -# Hierarchy - -**RxApi** - -# Implements - -* `object` - -# Constructors - - - -## constructor - -⊕ **new RxApi**(provider?: *`ProviderInterface`*): [RxApi](_index_.rxapi.md) - -*Defined in [index.ts:46](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L46)* - -**Parameters:** - -| Param | Type | Default value | Description | -| ------ | ------ | ------ | ------ | -| `Default value` provider | `ProviderInterface` | new Ws(defaults.WS_URL) | An API provider using HTTP or WebSocket | - -**Returns:** [RxApi](_index_.rxapi.md) - -___ - -# Properties - - - -## author - -**● author**: *[RxApiInterface$Section](../modules/_types_d_.md#rxapiinterface_section)* - -*Defined in [index.ts:43](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L43)* - -___ - - -## chain - -**● chain**: *[RxApiInterface$Section](../modules/_types_d_.md#rxapiinterface_section)* - -*Defined in [index.ts:44](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L44)* - -___ - - -## state - -**● state**: *[RxApiInterface$Section](../modules/_types_d_.md#rxapiinterface_section)* - -*Defined in [index.ts:45](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L45)* - -___ - - -## system - -**● system**: *[RxApiInterface$Section](../modules/_types_d_.md#rxapiinterface_section)* - -*Defined in [index.ts:46](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L46)* - -___ - -# Methods - - - -## isConnected - -▸ **isConnected**(): `BehaviorSubject`<`boolean`> - -*Defined in [index.ts:65](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L65)* - -**Returns:** `BehaviorSubject`<`boolean`> - -___ - diff --git a/docs/api-rx/index.html b/docs/api-rx/index.html deleted file mode 100644 index 6b8ea54cdc..0000000000 --- a/docs/api-rx/index.html +++ /dev/null @@ -1,454 +0,0 @@ - - - - - - - api-rx · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          -
          - - - - - - - - -
          - -
          - -
          - - - - - - - - -
          -
          - -
          -
          - -
          - -

          polkadotjs isc style npm travis maintainability coverage dependency devDependency

          -

          @polkadot/api-rx

          -

          An RxJs wrapper around the @polkadot/api.

          - - -
          - -
          -
          -
          - -

          results matching ""

          -
            - -
            -
            - -

            No results matching ""

            - -
            -
            -
            - -
            -
            - -
            - - - - - - - - - - - - - - -
            - - -
            - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api-rx/modules/_defaults_.md b/docs/api-rx/modules/_defaults_.md deleted file mode 100644 index 139597f9cb..0000000000 --- a/docs/api-rx/modules/_defaults_.md +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/docs/api-rx/modules/_index_.md b/docs/api-rx/modules/_index_.md deleted file mode 100644 index bec29894a8..0000000000 --- a/docs/api-rx/modules/_index_.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# Index - -### Classes - -* [RxApi](../classes/_index_.rxapi.md) - ---- - diff --git a/docs/api-rx/modules/_types_d_.md b/docs/api-rx/modules/_types_d_.md deleted file mode 100644 index 25cea7358f..0000000000 --- a/docs/api-rx/modules/_types_d_.md +++ /dev/null @@ -1,49 +0,0 @@ - - -# Type aliases - - - -## RxApiInterface - -**Ƭ RxApiInterface**: *`object`* - -*Defined in [types.d.ts:15](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/types.d.ts#L15)* - -#### Type declaration - -___ - - -## RxApiInterface$Method - -**Ƭ RxApiInterface$Method**: *`function`* - -*Defined in [types.d.ts:9](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/types.d.ts#L9)* - -#### Type declaration -▸(...params: *`Array`<`any`>*): `Observable`<`any`> | `BehaviorSubject`<`any`> - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| `Rest` params | `Array`<`any`> | - -**Returns:** `Observable`<`any`> | `BehaviorSubject`<`any`> - -___ - - -## RxApiInterface$Section - -**Ƭ RxApiInterface$Section**: *`object`* - -*Defined in [types.d.ts:11](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/types.d.ts#L11)* - -#### Type declaration - -[index: `string`]: [RxApiInterface$Method](_types_d_.md#rxapiinterface_method) - -___ - diff --git a/docs/api/README.md b/docs/api/README.md deleted file mode 100644 index 45ac535db4..0000000000 --- a/docs/api/README.md +++ /dev/null @@ -1,72 +0,0 @@ - -[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org) ![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square) [![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard) [![npm](https://img.shields.io/npm/v/@polkadot/api.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api)](https://david-dm.org/polkadot-js/api?path=packages/api) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api)](https://david-dm.org/polkadot-js/api?path=packages/api#info=devDependencies) - -@polkadot/api -============= - -This library provides a clean wrapper around all the methods exposed by a Polkadot network client. - -Usage ------ - -Installation - - -``` -npm install --save @polkadot/api -``` - -Initialisation - - -```js -import Api from '@polkadot/api'; -import WsProvider from '@polkadot/api-provider/ws'; - -const provider = new WsProvider('http://127.0.0.1:9944'); -const api = new Api(provider); -``` - -Making calls - - -```js -api.chain - .getHeader('0x1234567890') - .then((header) => console.log(header)) - .catch((error) => console.error(error)); -``` - -Retrieving the best block (once-off) - - -```js -api.chain - .getHead() - .then((headerHash) => { - return api.chain.getHeader(headerHash); - }) - .then((header) => { - console.log(`best #${header.number.toString()}`); - }) - .catch((error) => { - console.error('error:', error); - }); -``` - -Retrieving best header via subscription - - -```js -api.chain - .newHead((error, header) => { - if (error) { - console.error('error:', error); - } - - console.log(`best #${header.number.toString()}`); - }) - .then((subscriptionId) => { - // id for the subscription, can unsubscribe via - // api.chain.newHead.unsubscribe(subscriptionId) - }) - .catch((error) => { - console.error('error subscribing:', error); - }); -``` - diff --git a/docs/api/SUMMARY.md b/docs/api/SUMMARY.md deleted file mode 100644 index 2ed853f1bf..0000000000 --- a/docs/api/SUMMARY.md +++ /dev/null @@ -1,4 +0,0 @@ -* ["index"](modules/_index_.md) - * [Api](classes/_index_.api.md) -* ["types.d"](modules/_types_d_.md) - * [ApiInterface$Section$Method](interfaces/_types_d_.apiinterface_section_method.md) diff --git a/docs/api/classes/_index_.api.html b/docs/api/classes/_index_.api.html deleted file mode 100644 index 6deec51f6c..0000000000 --- a/docs/api/classes/_index_.api.html +++ /dev/null @@ -1,543 +0,0 @@ - - - - - - - Api · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            -
            - - - - - - - - -
            - -
            - -
            - - - - - - - - -
            -
            - -
            -
            - -
            - -

            name: Api

            -

            summary: The API may use a HTTP or WebSockets provider.

            -

            description: It allows for querying a Polkadot Client Node.

            -

            example:

            -
            import Api from '@polkadot/api';
            -import WsProvider from '@polkadot/api-provider/ws';
            -
            -const provider = new WsProvider('ws://127.0.0.1:9944');
            -const api = new Api(provider);
            -
            -

            Hierarchy

            -

            Api

            -

            Implements

            -
              -
            • object
            • -
            -

            Constructors

            -

            -

            constructor

            -

            ⊕ new Api(provider: ProviderInterface): Api

            -

            Defined in index.ts:37

            -

            constructor: Default constructor for the Api Object

            -

            Parameters:

            - - - - - - - - - - - - - - - -
            ParamTypeDescription
            providerProviderInterfaceAn API provider using HTTP or WebSocket
            -

            Returns: Api

            -
            -

            Properties

            -

            -

            author

            -

            ● author: ApiInterface$Section

            -

            Defined in index.ts:34

            -
            -

            -

            chain

            -

            ● chain: ApiInterface$Section

            -

            Defined in index.ts:35

            -
            -

            -

            state

            -

            ● state: ApiInterface$Section

            -

            Defined in index.ts:36

            -
            -

            -

            system

            -

            ● system: ApiInterface$Section

            -

            Defined in index.ts:37

            -
            -

            Methods

            -

            -

            <Static> signature

            -

            ▸ signature(__namedParameters: object): string

            -

            Defined in index.ts:72

            -

            name: signature

            -

            summary: Returns a string representation of the method with inputs and outputs.

            -

            description: Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type.

            -

            example:

            -
            import Api from '@polkadot/api';
            -
            -Api.signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' }); // => test_method (dest: Address): Address
            -
            -

            Parameters:

            - - - - - - - - - - - - - -
            ParamType
            __namedParametersobject
            -

            Returns: string

            -
            - - -
            - -
            -
            -
            - -

            results matching ""

            -
              - -
              -
              - -

              No results matching ""

              - -
              -
              -
              - -
              -
              - -
              - - - - - - - - - - - - - - -
              - - -
              - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api/classes/_index_.api.md b/docs/api/classes/_index_.api.md deleted file mode 100644 index 3abc9316f6..0000000000 --- a/docs/api/classes/_index_.api.md +++ /dev/null @@ -1,119 +0,0 @@ - - -*__name__*: Api - -*__summary__*: The API may use a HTTP or WebSockets provider. - -*__description__*: It allows for querying a Polkadot Client Node. - -*__example__*: -```javascript -import Api from '@polkadot/api'; -import WsProvider from '@polkadot/api-provider/ws'; - -const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); -``` - -# Hierarchy - -**Api** - -# Implements - -* `object` - -# Constructors - - - -## constructor - -⊕ **new Api**(provider: *`ProviderInterface`*): [Api](_index_.api.md) - -*Defined in [index.ts:37](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L37)* - -*__constructor__*: Default constructor for the Api Object - -**Parameters:** - -| Param | Type | Description | -| ------ | ------ | ------ | -| provider | `ProviderInterface` | An API provider using HTTP or WebSocket | - -**Returns:** [Api](_index_.api.md) - -___ - -# Properties - - - -## author - -**● author**: *[ApiInterface$Section](../modules/_types_d_.md#apiinterface_section)* - -*Defined in [index.ts:34](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L34)* - -___ - - -## chain - -**● chain**: *[ApiInterface$Section](../modules/_types_d_.md#apiinterface_section)* - -*Defined in [index.ts:35](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L35)* - -___ - - -## state - -**● state**: *[ApiInterface$Section](../modules/_types_d_.md#apiinterface_section)* - -*Defined in [index.ts:36](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L36)* - -___ - - -## system - -**● system**: *[ApiInterface$Section](../modules/_types_d_.md#apiinterface_section)* - -*Defined in [index.ts:37](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L37)* - -___ - -# Methods - - - -## `` signature - -▸ **signature**(__namedParameters: *`object`*): `string` - -*Defined in [index.ts:72](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L72)* - -*__name__*: signature - -*__summary__*: Returns a string representation of the method with inputs and outputs. - -*__description__*: Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type. - -*__example__*: -```javascript -import Api from '@polkadot/api'; - -Api.signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' }); // => test_method (dest: Address): Address -``` - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| __namedParameters | `object` | - -**Returns:** `string` - -___ - diff --git a/docs/api/index.html b/docs/api/index.html deleted file mode 100644 index 50a8352956..0000000000 --- a/docs/api/index.html +++ /dev/null @@ -1,500 +0,0 @@ - - - - - - - api · Polkadot API Book - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
              -
              - - - - - - - - -
              - -
              - -
              - - - - - - - - -
              -
              - -
              -
              - -
              - -

              polkadotjs isc style npm travis maintainability coverage dependency devDependency

              -

              @polkadot/api

              -

              This library provides a clean wrapper around all the methods exposed by a Polkadot network client.

              -

              Usage

              -

              Installation -

              -
              npm install --save @polkadot/api
              -

              Initialisation -

              -
              import Api from '@polkadot/api';
              -import WsProvider from '@polkadot/api-provider/ws';
              -
              -const provider = new WsProvider('http://127.0.0.1:9944');
              -const api = new Api(provider);
              -
              -

              Making calls -

              -
              api.chain
              -  .getHeader('0x1234567890')
              -  .then((header) => console.log(header))
              -  .catch((error) => console.error(error));
              -
              -

              Retrieving the best block (once-off) -

              -
              api.chain
              -  .getHead()
              -  .then((headerHash) => {
              -    return api.chain.getHeader(headerHash);
              -  })
              -  .then((header) => {
              -    console.log(`best #${header.number.toString()}`);
              -  })
              -  .catch((error) => {
              -    console.error('error:', error);
              -  });
              -
              -

              Retrieving best header via subscription -

              -
              api.chain
              -  .newHead((error, header) => {
              -    if (error) {
              -      console.error('error:', error);
              -    }
              -
              -    console.log(`best #${header.number.toString()}`);
              -  })
              -  .then((subscriptionId) => {
              -    // id for the subscription, can unsubscribe via
              -    // api.chain.newHead.unsubscribe(subscriptionId)
              -  })
              -  .catch((error) => {
              -    console.error('error subscribing:', error);
              -  });
              -
              - - -
              - -
              -
              -
              - -

              results matching ""

              -
                - -
                -
                - -

                No results matching ""

                - -
                -
                -
                - -
                -
                - -
                - - - - - - - - - - - - - - -
                - - -
                - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/api/interfaces/_types_d_.apiinterface_section_method.md b/docs/api/interfaces/_types_d_.apiinterface_section_method.md deleted file mode 100644 index 2539cb6fe5..0000000000 --- a/docs/api/interfaces/_types_d_.apiinterface_section_method.md +++ /dev/null @@ -1,51 +0,0 @@ - - -# Hierarchy - -**ApiInterface$Section$Method** - -# Callable -▸ **__call**(...params: *`Array`<`any`>*): `Promise`<`any`> - -*Defined in [types.d.ts:7](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/types.d.ts#L7)* - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| `Rest` params | `Array`<`any`> | - -**Returns:** `Promise`<`any`> - -# Properties - - - -## subscription - -**● subscription**: *`string`* - -*Defined in [types.d.ts:10](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/types.d.ts#L10)* - -___ - - -## unsubscribe - -**● unsubscribe**: *`function`* - -*Defined in [types.d.ts:11](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/types.d.ts#L11)* - -#### Type declaration -▸(id: *`number`*): `Promise`<`any`> - -**Parameters:** - -| Param | Type | -| ------ | ------ | -| id | `number` | - -**Returns:** `Promise`<`any`> - -___ - diff --git a/docs/api/modules/_index_.md b/docs/api/modules/_index_.md deleted file mode 100644 index 7e08da8069..0000000000 --- a/docs/api/modules/_index_.md +++ /dev/null @@ -1,10 +0,0 @@ - - -# Index - -### Classes - -* [Api](../classes/_index_.api.md) - ---- - diff --git a/docs/api/modules/_types_d_.md b/docs/api/modules/_types_d_.md deleted file mode 100644 index 70cf952124..0000000000 --- a/docs/api/modules/_types_d_.md +++ /dev/null @@ -1,29 +0,0 @@ - - -# Type aliases - - - -## ApiInterface - -**Ƭ ApiInterface**: *`object`* - -*Defined in [types.d.ts:18](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/types.d.ts#L18)* - -#### Type declaration - -___ - - -## ApiInterface$Section - -**Ƭ ApiInterface$Section**: *`object`* - -*Defined in [types.d.ts:14](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/types.d.ts#L14)* - -#### Type declaration - -[index: `string`]: [ApiInterface$Section$Method](../interfaces/_types_d_.apiinterface_section_method.md) - -___ - diff --git a/docs/examples/02_listen_to_blocks/index.js b/docs/examples/02_listen_to_blocks/index.js index 11ee1ed17b..e27fa66a53 100755 --- a/docs/examples/02_listen_to_blocks/index.js +++ b/docs/examples/02_listen_to_blocks/index.js @@ -1,16 +1,21 @@ -const BN = require('bn.js'); const Rpc = require('@polkadot/rpc-core').default; const WsProvider = require('@polkadot/rpc-provider/ws').default; const provider = new WsProvider('ws://127.0.0.1:9944'); const api = new Rpc(provider); -function main () { - console.log('Blocks will be shown as they come in, CTRL+C to stop:'); - api.chain.newHead((_, header) => { - const bnBlockNumber = new BN(header.number, 16); +api.chain + .newHead((error, header) => { + if (error) { + console.error('error:', error); + } - console.log('#' + bnBlockNumber.toString(10)); + console.log(`best #${header.blockNumber.toString()}`); + }) + .then((subscriptionId) => { + console.log(`subscriptionId: ${subscriptionId}`); + // id for the subscription, can unsubscribe via + // api.chain.newHead.unsubscribe(subscriptionId); + }) + .catch((error) => { + console.error('error subscribing:', error); }); -} - -main(); diff --git a/docs/guides/create_api.md b/docs/guides/create_api.md deleted file mode 100644 index 9749df9ff3..0000000000 --- a/docs/guides/create_api.md +++ /dev/null @@ -1,8 +0,0 @@ - -```javascript -import Rpc from '@polkadot/rpc-core'; -import WsProvider from '@polkadot/rpc-provider/ws'; - -const provider = new WsProvider('ws://127.0.0.1:9944'); -const rpc = new Rpc(provider); -``` diff --git a/packages/api-observable/README.md b/packages/api-observable/README.md index d658e75c3e..8cbde013d5 100644 --- a/packages/api-observable/README.md +++ b/packages/api-observable/README.md @@ -10,4 +10,4 @@ # @polkadot/api-observable -An RxJs wrapper around the [@polkadot/api](../api). +An RxJs wrapper around the [@polkadot/rpc-core](../rpc-core). diff --git a/packages/api-observable/src/Base.ts b/packages/api-observable/src/Base.ts index d98ecefa0e..0dc2179ff6 100644 --- a/packages/api-observable/src/Base.ts +++ b/packages/api-observable/src/Base.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/api-observable/src/Calls.ts b/packages/api-observable/src/Calls.ts index 1eb4be7937..de7fdcf70b 100644 --- a/packages/api-observable/src/Calls.ts +++ b/packages/api-observable/src/Calls.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/api-observable/src/Combined.ts b/packages/api-observable/src/Combined.ts index b0a7c590df..f5b3c325ed 100644 --- a/packages/api-observable/src/Combined.ts +++ b/packages/api-observable/src/Combined.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/api-observable/src/Queries.ts b/packages/api-observable/src/Queries.ts index 1acf4a9584..29de32952f 100644 --- a/packages/api-observable/src/Queries.ts +++ b/packages/api-observable/src/Queries.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/api-observable/src/classes.ts b/packages/api-observable/src/classes.ts index ac1407d3fd..150597cdcc 100644 --- a/packages/api-observable/src/classes.ts +++ b/packages/api-observable/src/classes.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/api-observable/src/index.ts b/packages/api-observable/src/index.ts index fc38fd51cd..7ab1c8e8b9 100644 --- a/packages/api-observable/src/index.ts +++ b/packages/api-observable/src/index.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/api-observable/src/types.d.ts b/packages/api-observable/src/types.d.ts index 5237a26c35..858450028a 100644 --- a/packages/api-observable/src/types.d.ts +++ b/packages/api-observable/src/types.d.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2018 @polkadot/ui-observable authors & contributors +// Copyright 2017-2018 @polkadot/api-observable authors & contributors // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. diff --git a/packages/rpc-core/README.md b/packages/rpc-core/README.md index 9b10ee3e40..14798580b4 100644 --- a/packages/rpc-core/README.md +++ b/packages/rpc-core/README.md @@ -8,7 +8,7 @@ [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core#info=devDependencies) -# @polkadot/api +# @polkadot/rpc-core This library provides a clean wrapper around all the methods exposed by a Polkadot network client. @@ -17,20 +17,20 @@ This library provides a clean wrapper around all the methods exposed by a Polkad Installation - ``` -npm install --save @polkadot/rpc-core +yarn add @polkadot/rpc-core ``` Initialisation - ```js -import Api from '@polkadot/rpc-core'; +import Rpc from '@polkadot/rpc-core'; import WsProvider from '@polkadot/rpc-provider/ws'; const provider = new WsProvider('http://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); ``` -Making calls - +Retrieving the block header object for a given block header hash (a 0x-prefixed hex string with length of 64) - ```js api.chain @@ -39,7 +39,7 @@ api.chain .catch((error) => console.error(error)); ``` -Retrieving the best block (once-off) - +Retrieving the best block number, parent hash, state root hash, extrinsics root hash, and digest (once-off) - ```js api.chain @@ -48,7 +48,11 @@ api.chain return api.chain.getHeader(headerHash); }) .then((header) => { - console.log(`best #${header.number.toString()}`); + console.log(`best #${header.blockNumber.toString()}`); + console.log(`parentHash: ${header.parentHash.toString()}`); + console.log(`stateRoot: ${header.stateRoot.toString()}`); + console.log(`extrinsicsRoot: ${header.extrinsicsRoot.toString()}`); + console.log(`digest: ${header.digest.toString()}`); }) .catch((error) => { console.error('error:', error); @@ -64,11 +68,12 @@ api.chain console.error('error:', error); } - console.log(`best #${header.number.toString()}`); + console.log(`best #${header.blockNumber.toString()}`); }) .then((subscriptionId) => { + console.log(`subscriptionId: ${subscriptionId}`); // id for the subscription, can unsubscribe via - // api.chain.newHead.unsubscribe(subscriptionId) + // api.chain.newHead.unsubscribe(subscriptionId); }) .catch((error) => { console.error('error subscribing:', error); diff --git a/packages/rpc-core/test/e2e/basics.test.js b/packages/rpc-core/test/e2e/basics.test.js index f05f3dc20f..9089cb4a79 100644 --- a/packages/rpc-core/test/e2e/basics.test.js +++ b/packages/rpc-core/test/e2e/basics.test.js @@ -1,17 +1,17 @@ -// Copyright 2017-2018 @polkadot/api authors & contributors +// 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. import Ws from '@polkadot/rpc-provider/ws'; -import Api from '../../src'; +import Rpc from '../../src'; describe.skip('e2e basics', () => { let api; beforeEach(() => { jest.setTimeout(30000); - api = new Api(new Ws('ws://127.0.0.1:9944')); + api = new Rpc(new Ws('ws://127.0.0.1:9944')); }); it('retrieves the pending extrinsics', () => { diff --git a/packages/rpc-core/test/e2e/chain.test.js b/packages/rpc-core/test/e2e/chain.test.js index 5796daac6c..d5ead09bf6 100644 --- a/packages/rpc-core/test/e2e/chain.test.js +++ b/packages/rpc-core/test/e2e/chain.test.js @@ -1,17 +1,17 @@ -// Copyright 2017-2018 @polkadot/api authors & contributors +// 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. import Ws from '@polkadot/rpc-provider/ws'; -import Api from '../../src'; +import Rpc from '../../src'; describe.skip('e2e chain', () => { let api; beforeEach(() => { jest.setTimeout(30000); - api = new Api(new Ws('ws://127.0.0.1:9944')); + api = new Rpc(new Ws('ws://127.0.0.1:9944')); }); it('subscribes to chain_newHead', (done) => { @@ -19,12 +19,12 @@ describe.skip('e2e chain', () => { // tslint:disable-next-line api.chain - .newHead((error, data) => { + .newHead((error, header) => { if (error) { return done(error); } - expect(data).toBeDefined(); + expect(header).toBeDefined(); if (++count === 3) { done(); diff --git a/packages/rpc-core/test/e2e/krummelanke.test.js b/packages/rpc-core/test/e2e/krummelanke.test.js index d32603bf77..c078af8d42 100644 --- a/packages/rpc-core/test/e2e/krummelanke.test.js +++ b/packages/rpc-core/test/e2e/krummelanke.test.js @@ -1,18 +1,18 @@ -// Copyright 2017-2018 @polkadot/api authors & contributors +// 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. import storage from '@polkadot/storage'; import Ws from '@polkadot/rpc-provider/ws'; -import Api from '../../src'; +import Rpc from '../../src'; describe.skip('e2e krumme lanke', () => { let api; beforeEach(() => { jest.setTimeout(30000); - api = new Api(new Ws('ws://127.0.0.1:9944')); + api = new Rpc(new Ws('ws://127.0.0.1:9944')); }); it('subscribes to storage', (done) => { diff --git a/packages/rpc-core/test/e2e/state.test.js b/packages/rpc-core/test/e2e/state.test.js index 95a7e78b3a..c75bb11826 100644 --- a/packages/rpc-core/test/e2e/state.test.js +++ b/packages/rpc-core/test/e2e/state.test.js @@ -1,11 +1,11 @@ -// Copyright 2017-2018 @polkadot/api authors & contributors +// 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. import Ws from '@polkadot/rpc-provider/ws'; import storage from '@polkadot/storage/static'; -import Api from '../../src'; +import Rpc from '../../src'; const ALICE = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ'; @@ -14,7 +14,7 @@ describe.skip('e2e state', () => { beforeEach(() => { jest.setTimeout(30000); - api = new Api(new Ws('ws://127.0.0.1:9944')); + api = new Rpc(new Ws('ws://127.0.0.1:9944')); }); it('retrieves code', () => { diff --git a/packages/rpc-core/test/e2e/subscribe.test.js b/packages/rpc-core/test/e2e/subscribe.test.js index 26f3ad742d..11faddf0c5 100644 --- a/packages/rpc-core/test/e2e/subscribe.test.js +++ b/packages/rpc-core/test/e2e/subscribe.test.js @@ -1,18 +1,18 @@ -// Copyright 2017-2018 @polkadot/api authors & contributors +// 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. import Ws from '@polkadot/rpc-provider/ws'; import storage from '@polkadot/storage/static'; -import Api from '../../src'; +import Rpc from '../../src'; describe.skip('e2e subscriptions', () => { let api; beforeEach(() => { jest.setTimeout(30000); - api = new Api(new Ws('ws://127.0.0.1:9944')); + api = new Rpc(new Ws('ws://127.0.0.1:9944')); }); it('retrieves current timestamp', (done) => { diff --git a/packages/rpc-core/test/mockHttp.ts b/packages/rpc-core/test/mockHttp.ts deleted file mode 100644 index 3738c5753a..0000000000 --- a/packages/rpc-core/test/mockHttp.ts +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017-2018 @polkadot/rpc-provider authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. - -import nock from 'nock'; - -const TEST_HTTP_URL = 'http://localhost:9944'; - -function mockHttp (requests: any[]) { - nock.cleanAll(); - - return requests.reduce((scope, request: any, index: number) => { - return scope - .post('/') - .reply(request.code || 200, (uri: string, body: { id: string }) => { - scope.body = scope.body || {}; - scope.body[request.method] = body; - - return Object.assign({ id: body.id, jsonrpc: '2.0' }, request.reply || {}); - }); - }, nock(TEST_HTTP_URL)); -} - -export { - TEST_HTTP_URL, - mockHttp -}; diff --git a/packages/rpc-core/test/mockWs.ts b/packages/rpc-core/test/mockWs.ts deleted file mode 100644 index cda2cff953..0000000000 --- a/packages/rpc-core/test/mockWs.ts +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2017-2018 @polkadot/rpc-provider authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. - -import { Server } from 'mock-socket'; - -const TEST_WS_URL = 'ws://localhost:9955'; - -let server: Server; - -type ErrorDef = { - id: number, - error: { - code: number, - message: string - } -}; - -type ReplyDef = { - id: number, - reply: { - result: any - } -}; - -function createError ({ id, error: { code, message } }: ErrorDef) { - return { - id, - jsonrpc: '2.0', - error: { - code, - message - } - }; -} - -function createReply ({ id, reply: { result } }: ReplyDef) { - return { - id, - jsonrpc: '2.0', - result - }; -} - -function mockWs (requests: Array<{ method: string }>) { - server = new Server(TEST_WS_URL); - - let requestCount = 0; - const scope: { body: { [index: string]: {} }, requests: number, server: Server, done: any } = { - body: {}, - requests: 0, - server, - done: () => - server.stop(() => { - // ignore - }) - }; - - server.on('connection', (socket) => { - // @ts-ignore definitions are wrong, this is 'on', not 'onmessage' - socket.on('message', (body: {}) => { - const request = requests[requestCount]; - // @ts-ignore Yes, SHOULD be fixed, this is a mess - const response = request.error - // @ts-ignore Yes, SHOULD be fixed, this is a mess - ? createError(request) - // @ts-ignore Yes, SHOULD be fixed, this is a mess - : createReply(request); - - scope.body[request.method] = body; - requestCount++; - - socket.send(JSON.stringify(response)); - }); - }); - - return scope; -} - -export { - TEST_WS_URL, - mockWs -}; diff --git a/packages/rpc-provider/README.md b/packages/rpc-provider/README.md index f5e75975c7..e54d768781 100644 --- a/packages/rpc-provider/README.md +++ b/packages/rpc-provider/README.md @@ -17,7 +17,7 @@ Generic transport providers to handle the transport of method calls to and from Installation - ``` -npm install --save @polkadot/rpc-provider +yarn add @polkadot/rpc-provider ``` Initialisation - diff --git a/packages/rpc-provider/src/http/index.ts b/packages/rpc-provider/src/http/index.ts index e394290970..7fd45d7593 100644 --- a/packages/rpc-provider/src/http/index.ts +++ b/packages/rpc-provider/src/http/index.ts @@ -25,11 +25,11 @@ const ERROR_SUBSCRIBE = 'HTTP Provider does not have subscriptions, use WebSocke *
                * * ```javascript - * import Api from '@polkadot/rpc-core'; + * import Rpc from '@polkadot/rpc-core'; * import HttpProvider from '@polkadot/rpc-provider/http'; * * const provider = new HttpProvider('http://127.0.0.1:9933'); - * const api = new Api(provider); + * const api = new Rpc(provider); * ``` * * @see [[WsProvider]] diff --git a/packages/rpc-provider/src/mock/index.ts b/packages/rpc-provider/src/mock/index.ts index c397012141..e89029f8b7 100644 --- a/packages/rpc-provider/src/mock/index.ts +++ b/packages/rpc-provider/src/mock/index.ts @@ -12,7 +12,7 @@ import subscribe from './subscribe'; import unsubscribe from './unsubscribe'; /** - * A moock provider mainly used for testing. + * A mock provider mainly used for testing. * @return {ProviderInterface} The mock provider */ export default function mockProvider (): ProviderInterface { diff --git a/packages/rpc-provider/src/ws/index.ts b/packages/rpc-provider/src/ws/index.ts index 6069de3e47..cedbd055b0 100644 --- a/packages/rpc-provider/src/ws/index.ts +++ b/packages/rpc-provider/src/ws/index.ts @@ -46,11 +46,11 @@ interface WSProviderInterface extends ProviderInterface { *
                * * ```javascript - * import Api from '@polkadot/rpc-core'; + * import Rpc from '@polkadot/rpc-core'; * import WsProvider from '@polkadot/rpc-provider/ws'; * * const provider = new WsProvider('ws://127.0.0.1:9944'); - * const api = new Api(provider); + * const api = new Rpc(provider); * ``` * * @see [[HttpProvider]] @@ -182,7 +182,7 @@ export default class WsProvider extends E3.EventEmitter implements WSProviderInt * * ```javascript * const provider = new WsProvider('ws://127.0.0.1:9944'); - * const api = new Api(provider); + * const api = new Rpc(provider); * * api.state.storage([[storage.balances.freeBalance,
                ]], (_, values) => { * console.log(values) diff --git a/packages/rpc-rx/README.md b/packages/rpc-rx/README.md index 3c7a46f8f7..2a8e85a822 100644 --- a/packages/rpc-rx/README.md +++ b/packages/rpc-rx/README.md @@ -10,4 +10,4 @@ # @polkadot/rpc-rx -An RxJs wrapper around the [@polkadot/api](../api). +An RxJs wrapper around the [@polkadot/rpc-core](../rpc-core). diff --git a/packages/rpc-rx/src/cached.spec.js b/packages/rpc-rx/src/cached.spec.js index 0f8e5b36b8..fc9d3753b9 100644 --- a/packages/rpc-rx/src/cached.spec.js +++ b/packages/rpc-rx/src/cached.spec.js @@ -8,7 +8,7 @@ jest.mock('@polkadot/rpc-provider/ws', () => class { send = () => true; }); -const Api = require('./index').default; +const RpcRx = require('./index').default; describe('createCachedObservable', () => { let api; @@ -16,7 +16,7 @@ describe('createCachedObservable', () => { let section; beforeEach(() => { - api = new Api(); + api = new RpcRx(); }); beforeEach(() => { diff --git a/packages/rpc-rx/src/index.spec.js b/packages/rpc-rx/src/index.spec.js index cfe94a2e21..9341293ff7 100644 --- a/packages/rpc-rx/src/index.spec.js +++ b/packages/rpc-rx/src/index.spec.js @@ -10,13 +10,13 @@ jest.mock('@polkadot/rpc-provider/ws', () => class { send = () => true; }); -const Api = require('./index').default; +const RpcRx = require('./index').default; -describe('Api', () => { +describe('RpcRx', () => { let api; beforeEach(() => { - api = new Api(); + api = new RpcRx(); }); it('creates an instance with all sections', () => { diff --git a/packages/rpc-rx/src/index.ts b/packages/rpc-rx/src/index.ts index 130e1a5393..61dd804160 100644 --- a/packages/rpc-rx/src/index.ts +++ b/packages/rpc-rx/src/index.ts @@ -29,11 +29,11 @@ type CachedMap = { *
                * * ```javascript - * import Rpc from '@polkadot/rpc-rx'; + * import RpcRx from '@polkadot/rpc-rx'; * import WsProvider from '@polkadot/rpc-provider/ws'; * * const provider = new WsProvider('http://127.0.0.1:9944'); - * const api = new Rpc(provider); + * const api = new RpcRx(provider); * ``` */ export default class RpcRx implements RxRpcInterface { diff --git a/packages/rpc-rx/src/subject.spec.js b/packages/rpc-rx/src/subject.spec.js index 06285ff820..c2a58f1ac4 100644 --- a/packages/rpc-rx/src/subject.spec.js +++ b/packages/rpc-rx/src/subject.spec.js @@ -8,7 +8,7 @@ jest.mock('@polkadot/rpc-provider/ws', () => class { send = () => true; }); -const Api = require('./index').default; +const RpcRx = require('./index').default; describe('subject', () => { const params = [123, false]; @@ -19,7 +19,7 @@ describe('subject', () => { let observable; beforeEach(() => { - api = new Api(); + api = new RpcRx(); }); beforeEach(() => { diff --git a/packages/rpc-rx/test/e2e/subscribe.test.js b/packages/rpc-rx/test/e2e/subscribe.test.js index 30d8ab260b..e2176c5bb9 100644 --- a/packages/rpc-rx/test/e2e/subscribe.test.js +++ b/packages/rpc-rx/test/e2e/subscribe.test.js @@ -5,7 +5,7 @@ import Ws from '@polkadot/rpc-provider/ws'; import storage from '@polkadot/storage/static'; -import RxApi from '../../src'; +import RpcRx from '../../src'; describe.skip('e2e subscriptions', () => { let api; @@ -13,7 +13,7 @@ describe.skip('e2e subscriptions', () => { beforeEach(() => { jest.setTimeout(30000); - api = new RxApi(new Ws('ws://127.0.0.1:9944')); + api = new RpcRx(new Ws('ws://127.0.0.1:9944')); }); it('retrieves current timestamp', (done) => { diff --git a/packages/type-extrinsics/src/fromMetadata.ts b/packages/type-extrinsics/src/fromMetadata.ts index 3f3391b161..341a13db2e 100644 --- a/packages/type-extrinsics/src/fromMetadata.ts +++ b/packages/type-extrinsics/src/fromMetadata.ts @@ -4,9 +4,9 @@ import camelCase from '@polkadot/util/string/camelCase'; import Metadata, { RuntimeModuleMetadata } from '@polkadot/types/Metadata'; +import { Extrinsics, ModuleExtrinsics } from './types'; import createUnchecked from './utils/createUnchecked'; -import { Extrinsics, ModuleExtrinsics } from './types'; import extrinsics from './index'; /** diff --git a/packages/type-extrinsics/test/e2e/transfer.spec.js b/packages/type-extrinsics/test/e2e/transfer.spec.js index e3ba2a61d4..58252b2578 100644 --- a/packages/type-extrinsics/test/e2e/transfer.spec.js +++ b/packages/type-extrinsics/test/e2e/transfer.spec.js @@ -2,7 +2,7 @@ // This software may be modified and distributed under the terms // of the ISC license. See the LICENSE file for details. -import Api from '@polkadot/rpc-core'; +import Rpc from '@polkadot/rpc-core'; import Ws from '@polkadot/rpc-provider/ws'; import testingPairs from '@polkadot/util-keyring/testingPairs'; @@ -15,7 +15,7 @@ describe.skip('e2e transfer', () => { beforeAll(() => { // check other e2e tests here... - api = new Api(new Ws('ws://127.0.0.1:9944')); + api = new Rpc(new Ws('ws://127.0.0.1:9944')); }); // Error: [1002]: Inherent transactions cannot be queued. diff --git a/packages/type-jsonrpc/README.md b/packages/type-jsonrpc/README.md index 288f4b6274..6102aded2b 100644 --- a/packages/type-jsonrpc/README.md +++ b/packages/type-jsonrpc/README.md @@ -10,7 +10,7 @@ # @polkadot/jsonrpc -A defintion of all the methods exposed in a general Polkadot client application. These are used not only to provide a comprehensive code-generated document of the available methods, but are also used in the API to auto-generate endpoints with the required type-checking. +A definition of all the methods exposed in a general Polkadot client application. These are used not only to provide a comprehensive code-generated document of the available methods, but are also used in the API to auto-generate endpoints with the required type-checking. For a list of currently exposed methods, see the [method documentation](docs/README.md). @@ -19,7 +19,7 @@ For a list of currently exposed methods, see the [method documentation](docs/REA Installation - ``` -npm install --save @polkadot/jsonrpc +yarn add @polkadot/jsonrpc ``` ## Adding methods @@ -27,4 +27,4 @@ npm install --save @polkadot/jsonrpc As methods are added, simply adding the name, inputs & output will prepare it for use. - Add the method to the correct file in [src/rpc/](src/rpc/) (Input/Output types as cross-referenced from the canonical implementation and match one-to-one) -- Should a new type be required, add it to the type list, [src/types.js](src/types.js) (Required for flow type checking) +- Should a new type be required, add it to the type list, [src/types.js](src/types.js) (Required for TSLint type checking) diff --git a/packages/type-storage/src/types.d.ts b/packages/type-storage/src/types.d.ts index 8f266487ec..ec6f418bc3 100644 --- a/packages/type-storage/src/types.d.ts +++ b/packages/type-storage/src/types.d.ts @@ -3,8 +3,8 @@ // of the ISC license. See the LICENSE file for details. import { StorageFunction } from '@polkadot/types/StorageKey'; -import BN from 'bn.js'; +import BN from 'bn.js'; import * as substrate from './substrate'; type Substrate = keyof typeof substrate; diff --git a/packages/types/README.md b/packages/types/README.md index bf30724c43..f36931fb46 100644 --- a/packages/types/README.md +++ b/packages/types/README.md @@ -1,3 +1,3 @@ # @polkadot/types -Implementation of the types and their (de-)serialisation via parity-codec. +Implementation of the types and their (de-)serialisation via [parity-codec](https://github.com/paritytech/parity-codec). diff --git a/packages/types/src/PropIndex.ts b/packages/types/src/PropIndex.ts index 2640f83cbb..b4152ac447 100644 --- a/packages/types/src/PropIndex.ts +++ b/packages/types/src/PropIndex.ts @@ -4,6 +4,6 @@ import U32 from './U32'; -// An increasing number that represents a specific proposal in the system +// An increasing number that represents a specific public proposal index in the system export default class PropIndex extends U32 { } diff --git a/packages/types/src/ProposalIndex.ts b/packages/types/src/ProposalIndex.ts index b8d90f2414..07ef9e5175 100644 --- a/packages/types/src/ProposalIndex.ts +++ b/packages/types/src/ProposalIndex.ts @@ -4,6 +4,6 @@ import U32 from './U32'; -// An increasing number that represents a specific proposal in the system +// An increasing number that represents a specific council proposal index in the system export default class ProposalIndex extends U32 { } diff --git a/typedoc.js b/typedoc.js index 99723a1808..12cc85ad61 100644 --- a/typedoc.js +++ b/typedoc.js @@ -5,7 +5,6 @@ module.exports = { excludeNotExported: true, excludePrivate: true, hideGenerator: true, - includes: './docs/guides', includeDeclarations: true, out: 'docs', module: 'commonjs',