fix: Fixes #235 TypeDoc updates consistent with renaming (#236)

* fix: Remove docs/api since replaced with docs/rpc-core

* fix: Remove docs/api-provider since replaced with docs/rpc-provider

* fix: Remove docs/api-rx since replaced with docs/rpc-rx

* fix: Remove the guide file that serves no purpose

* fix: Change license from ui-observable to api-observable

* fix: Remove disused mockHttp and mockWs that are duplicates of those in rpc-provider

* fix: Clarifies difference between PropIndex and ProposalIndex from Issue #226

* fix: Update api-observable Readme to refer to rpc-core, previously called api

* misc: Update Readme of rpc-core. See commit message details.

* Update name to be @polkadot/rpc-core instead of @polkadot/api

* Use Yarn instead of NPM for instructions adding dependencies

* Refer to @polkadot/rpc-core as `Rpc`

* Highlight that given block header hash should be a 0x-prefixed hex string with length of 64 (not only length of 10 as shown in the example)

* Showcase more information that you can obtain from the header object (i.e. best block number, parentHash, stateRoot, extrinsicsRoot, and digest)

* Use `header.raw` instead of just `header` to access properties of the header object

* Update the example to console.log the subscription ID

* Add missing semicolon

* fix: Fix name in license header and rename Api to Rpc for rpc-core e2e tests

* fix: Update rpc-provider Readme to use Yarn instead of NPM install

* fix: Fix minor typo

* fix: Rename Api to Rpc for rpc-provider ws

* fix: Refer to rpc-core instead of api in the rpc-rx Readme

* fix: Update rpc-rx files to refer to it as RpcRx instead of RxApi or just Api

* fix: Refer to rpc-core as Rpc instead of Api

* fix: Update type-jsonrpc Readme. Fix typo. Use Yarn not NPM. Refer to TSLint not Flow

* refactor: Move non-type dependency import with non-type dependencies

* docs: Add link to parity-codec repo

* fix: Avoid use of .raw. Fix listen to blocks example

* fix: Add missing error to newHead in listen to blocks example
This commit is contained in:
Luke Schoen
2018-10-10 20:11:22 +02:00
committed by Jaco Greeff
parent 8e9243fdd6
commit 267411d778
83 changed files with 82 additions and 5934 deletions
-28
View File
@@ -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);
```
-23
View File
@@ -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)
@@ -1,623 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>HttpProvider · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="_ws_index_.wsprovider.html" />
<link rel="prev" href="../" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../../api/">
<a href="../../api/">
api
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../../api/classes/_index_.api.html">
<a href="../../api/classes/_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../">
<a href="../">
api-provider
</a>
<ul class="articles">
<li class="chapter active" data-level="1.3.1" data-path="_http_index_.httpprovider.html">
<a href="_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="_ws_index_.wsprovider.html">
<a href="_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../../api-rx/">
<a href="../../api-rx/">
api-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../../api-rx/classes/_index_.rxapi.html">
<a href="../../api-rx/classes/_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../../examples/">
<a href="../../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../examples/01_simple_connect/">
<a href="../../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../examples/02_listen_to_blocks/">
<a href="../../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../examples/03_listen_to_balance_change/">
<a href="../../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../../examples/04_generate_account/">
<a href="../../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../../examples/05_read_storage/">
<a href="../../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../../examples/06_craft_extrinsic/">
<a href="../../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../../examples/07_transfer_dots/">
<a href="../../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >HttpProvider</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><em><strong>name</strong></em>: HttpProvider</p>
<p><em><strong>summary</strong></em>: The HTTP Provider allows sending requests using HTTP to a HTTP RPC server TCP port.</p>
<p><em><strong>description</strong></em>: It does not support subscriptions so you won&apos;t be able to listen to events such as new blocks or balance changes. It is usually preferrable using the <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">HttpProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api-provider/http&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">HttpProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;http://127.0.0.1:9933&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><em><strong>see</strong></em>: <a href="_ws_index_.wsprovider.html">WsProvider</a></p>
<h1 id="hierarchy">Hierarchy</h1>
<p><strong>HttpProvider</strong></p>
<h1 id="implements">Implements</h1>
<ul>
<li><a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a></li>
</ul>
<h1 id="constructors">Constructors</h1>
<p><a id="constructor"></a></p>
<h2 id="constructor">constructor</h2>
<p>&#x2295; <strong>new HttpProvider</strong>(endpoint: <em><code>string</code></em>): <a href="_http_index_.httpprovider.html">HttpProvider</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L40" target="_blank">http/index.ts:40</a></em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>endpoint</td>
<td><code>string</code></td>
<td>The endpoint url starting with http://</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <a href="_http_index_.httpprovider.html">HttpProvider</a></p>
<hr>
<h1 id="methods">Methods</h1>
<p><a id="isconnected"></a></p>
<h2 id="isconnected">isConnected</h2>
<p>&#x25B8; <strong>isConnected</strong>(): <code>boolean</code></p>
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#isconnected">isConnected</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L57" target="_blank">http/index.ts:57</a></em></p>
<p><em><strong>summary</strong></em>: Whether the node is connected or not.</p>
<p><strong>Returns:</strong> <code>boolean</code>
true if connected</p>
<hr>
<p><a id="on"></a></p>
<h2 id="on">on</h2>
<p>&#x25B8; <strong>on</strong>(type: <em><a href="../modules/_types_d_.md#providerinterface_emitted">ProviderInterface$Emitted</a></em>, sub: <em><a href="../modules/_types_d_.md#providerinterface_emitcb">ProviderInterface$EmitCb</a></em>): <code>void</code></p>
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#on">on</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L65" target="_blank">http/index.ts:65</a></em></p>
<p><em><strong>summary</strong></em>: Events are not supported with the HttpProvider, see <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
<p><em><strong>description</strong></em>: HTTP Provider does not have &apos;on&apos; emitters. WebSockets should be used instead.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td><a href="../modules/_types_d_.md#providerinterface_emitted">ProviderInterface$Emitted</a></td>
</tr>
<tr>
<td>sub</td>
<td><a href="../modules/_types_d_.md#providerinterface_emitcb">ProviderInterface$EmitCb</a></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>void</code></p>
<hr>
<p><a id="send"></a></p>
<h2 id="send">send</h2>
<p>&#x25B8; <strong>send</strong>(method: <em><code>string</code></em>, params: <em><code>Array</code>&lt;<code>any</code>&gt;</em>): <code>Promise</code>&lt;<code>any</code>&gt;</p>
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#send">send</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L72" target="_blank">http/index.ts:72</a></em></p>
<p><em><strong>summary</strong></em>: Send HTTP POST Request with Body to configured HTTP Endpoint.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>method</td>
<td><code>string</code></td>
</tr>
<tr>
<td>params</td>
<td><code>Array</code>&lt;<code>any</code>&gt;</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Promise</code>&lt;<code>any</code>&gt;</p>
<hr>
<p><a id="subscribe"></a></p>
<h2 id="subscribe">subscribe</h2>
<p>&#x25B8; <strong>subscribe</strong>(types: <em><code>string</code></em>, method: <em><code>string</code></em>, params: <em><code>Array</code>&lt;<code>any</code>&gt;</em>, cb: <em><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></em>): <code>Promise</code>&lt;<code>number</code>&gt;</p>
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#subscribe">subscribe</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L94" target="_blank">http/index.ts:94</a></em></p>
<p><em><strong>summary</strong></em>: Subscriptions are not supported with the HttpProvider, see <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>types</td>
<td><code>string</code></td>
</tr>
<tr>
<td>method</td>
<td><code>string</code></td>
</tr>
<tr>
<td>params</td>
<td><code>Array</code>&lt;<code>any</code>&gt;</td>
</tr>
<tr>
<td>cb</td>
<td><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Promise</code>&lt;<code>number</code>&gt;</p>
<hr>
<p><a id="unsubscribe"></a></p>
<h2 id="unsubscribe">unsubscribe</h2>
<p>&#x25B8; <strong>unsubscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, id: <em><code>number</code></em>): <code>Promise</code>&lt;<code>boolean</code>&gt;</p>
<p><em>Implementation of <a href="../interfaces/_types_d_.providerinterface.md">ProviderInterface</a>.<a href="../interfaces/_types_d_.providerinterface.md#unsubscribe">unsubscribe</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/http/index.ts#L103" target="_blank">http/index.ts:103</a></em></p>
<p><em><strong>summary</strong></em>: Subscriptions are not supported with the HttpProvider, see <a href="_ws_index_.wsprovider.html">WsProvider</a>.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td><code>string</code></td>
</tr>
<tr>
<td>method</td>
<td><code>string</code></td>
</tr>
<tr>
<td>id</td>
<td><code>number</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Promise</code>&lt;<code>boolean</code>&gt;</p>
<hr>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../" class="navigation navigation-prev " aria-label="Previous page: api-provider">
<i class="fa fa-angle-left"></i>
</a>
<a href="_ws_index_.wsprovider.html" class="navigation navigation-next " aria-label="Next page: WsProvider">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"HttpProvider","level":"1.3.1","depth":2,"next":{"title":"WsProvider","level":"1.3.2","depth":2,"path":"api-provider/classes/_ws_index_.wsprovider.md","ref":"api-provider/classes/_ws_index_.wsprovider.md","articles":[]},"previous":{"title":"api-provider","level":"1.3","depth":1,"path":"api-provider/README.md","ref":"api-provider/README.md","articles":[{"title":"HttpProvider","level":"1.3.1","depth":2,"path":"api-provider/classes/_http_index_.httpprovider.md","ref":"api-provider/classes/_http_index_.httpprovider.md","articles":[]},{"title":"WsProvider","level":"1.3.2","depth":2,"path":"api-provider/classes/_ws_index_.wsprovider.md","ref":"api-provider/classes/_ws_index_.wsprovider.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api-provider/classes/_http_index_.httpprovider.md","mtime":"2018-10-10T07:30:39.963Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
@@ -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
<a id="constructor"></a>
## 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
<a id="isconnected"></a>
## 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
___
<a id="on"></a>
## 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`
___
<a id="send"></a>
## 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`>
___
<a id="subscribe"></a>
## 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`>
___
<a id="unsubscribe"></a>
## 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`>
___
@@ -1,904 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>WsProvider · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="../../api-rx/" />
<link rel="prev" href="_http_index_.httpprovider.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../../api/">
<a href="../../api/">
api
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../../api/classes/_index_.api.html">
<a href="../../api/classes/_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../">
<a href="../">
api-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="_http_index_.httpprovider.html">
<a href="_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter active" data-level="1.3.2" data-path="_ws_index_.wsprovider.html">
<a href="_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../../api-rx/">
<a href="../../api-rx/">
api-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../../api-rx/classes/_index_.rxapi.html">
<a href="../../api-rx/classes/_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../../examples/">
<a href="../../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../examples/01_simple_connect/">
<a href="../../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../examples/02_listen_to_blocks/">
<a href="../../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../examples/03_listen_to_balance_change/">
<a href="../../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../../examples/04_generate_account/">
<a href="../../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../../examples/05_read_storage/">
<a href="../../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../../examples/06_craft_extrinsic/">
<a href="../../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../../examples/07_transfer_dots/">
<a href="../../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >WsProvider</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><em><strong>name</strong></em>: WsProvider</p>
<p><em><strong>summary</strong></em>: The WebSocket Provider allows sending requests using WebSocket to a WebSocket RPC server TCP port.</p>
<p><em><strong>description</strong></em>: Unlike the <a href="_http_index_.httpprovider.html">HttpProvider</a>, it does support subscriptions and allows listening to events such as new blocks or balance changes.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;ws://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p><em><strong>see</strong></em>: <a href="_http_index_.httpprovider.html">HttpProvider</a></p>
<h1 id="type-parameters">Type parameters</h1>
<h4 id="eventtypes----string--symbol">EventTypes : <code>string</code> | <code>symbol</code></h4>
<h1 id="hierarchy">Hierarchy</h1>
<p> <code>EventEmitter</code></p>
<p><strong>&#x21B3; WsProvider</strong></p>
<h1 id="implements">Implements</h1>
<ul>
<li><code>WSProviderInterface</code></li>
</ul>
<h1 id="constructors">Constructors</h1>
<p><a id="constructor"></a></p>
<h2 id="constructor">constructor</h2>
<p>&#x2295; <strong>new WsProvider</strong>(endpoint: <em><code>string</code></em>, autoConnect?: <em><code>boolean</code></em>): <a href="_ws_index_.wsprovider.html">WsProvider</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L73" target="_blank">ws/index.ts:73</a></em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>endpoint</td>
<td><code>string</code></td>
<td>-</td>
<td>The endpoint url. Usually `ws://ip:9944` or `wss://ip:9944`</td>
</tr>
<tr>
<td><code>Default value</code> autoConnect</td>
<td><code>boolean</code></td>
<td>true</td>
<td>Whether to connect automatically or not.</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <a href="_ws_index_.wsprovider.html">WsProvider</a></p>
<hr>
<h1 id="properties">Properties</h1>
<p><a id="prefixed"></a></p>
<h2 id="static-prefixed"><code>&lt;Static&gt;</code> prefixed</h2>
<p><strong>&#x25CF; prefixed</strong>: <em> <code>string</code> | <code>boolean</code>
</em></p>
<p><em>Inherited from EventEmitter.prefixed</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:6</em></p>
<hr>
<h1 id="methods">Methods</h1>
<p><a id="addlistener"></a></p>
<h2 id="addlistener">addListener</h2>
<p>&#x25B8; <strong>addListener</strong>(event: <em><code>EventTypes</code></em>, fn: <em><code>ListenerFn</code></em>, context?: <em><code>any</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.addListener</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:33</em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td>fn</td>
<td><code>ListenerFn</code></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="connect"></a></p>
<h2 id="connect">connect</h2>
<p>&#x25B8; <strong>connect</strong>(): <code>void</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L104" target="_blank">ws/index.ts:104</a></em></p>
<p><em><strong>summary</strong></em>: Manually connect</p>
<p><em><strong>description</strong></em>: The <a href="_ws_index_.wsprovider.html">WsProvider</a> connects automatically by default, however if you decided otherwise, you may connect manually using this method.</p>
<p><strong>Returns:</strong> <code>void</code></p>
<hr>
<p><a id="emit"></a></p>
<h2 id="emit">emit</h2>
<p>&#x25B8; <strong>emit</strong>(event: <em><code>EventTypes</code></em>, ...args: <em><code>Array</code>&lt;<code>any</code>&gt;</em>): <code>boolean</code></p>
<p><em>Inherited from EventEmitter.emit</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:27</em></p>
<p>Calls each of the listeners registered for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td><code>Rest</code> args</td>
<td><code>Array</code>&lt;<code>any</code>&gt;</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>boolean</code></p>
<hr>
<p><a id="eventnames"></a></p>
<h2 id="eventnames">eventNames</h2>
<p>&#x25B8; <strong>eventNames</strong>(): <code>Array</code>&lt;<code>EventTypes</code>&gt;</p>
<p><em>Inherited from EventEmitter.eventNames</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:12</em></p>
<p>Return an array listing the events for which the emitter has registered listeners.</p>
<p><strong>Returns:</strong> <code>Array</code>&lt;<code>EventTypes</code>&gt;</p>
<hr>
<p><a id="isconnected"></a></p>
<h2 id="isconnected">isConnected</h2>
<p>&#x25B8; <strong>isConnected</strong>(): <code>boolean</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L121" target="_blank">ws/index.ts:121</a></em></p>
<p><em><strong>summary</strong></em>: Whether the node is connected or not.</p>
<p><strong>Returns:</strong> <code>boolean</code>
true if connected</p>
<hr>
<p><a id="listenercount"></a></p>
<h2 id="listenercount">listenerCount</h2>
<p>&#x25B8; <strong>listenerCount</strong>(event: <em><code>EventTypes</code></em>): <code>number</code></p>
<p><em>Inherited from EventEmitter.listenerCount</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:22</em></p>
<p>Return the number of listeners listening to a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>number</code></p>
<hr>
<p><a id="listeners"></a></p>
<h2 id="listeners">listeners</h2>
<p>&#x25B8; <strong>listeners</strong>(event: <em><code>EventTypes</code></em>): <code>Array</code>&lt;<code>ListenerFn</code>&gt;</p>
<p><em>Inherited from EventEmitter.listeners</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:17</em></p>
<p>Return the listeners registered for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Array</code>&lt;<code>ListenerFn</code>&gt;</p>
<hr>
<p><a id="off"></a></p>
<h2 id="off">off</h2>
<p>&#x25B8; <strong>off</strong>(event: <em><code>EventTypes</code></em>, fn?: <em><a href="../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md">ListenerFn</a></em>, context?: <em><code>any</code></em>, once?: <em> <code>undefined</code> | <code>false</code> | <code>true</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.off</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:44</em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td><code>Optional</code> fn</td>
<td><a href="../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md">ListenerFn</a></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
<tr>
<td><code>Optional</code> once</td>
<td><code>undefined</code> | <code>false</code> | <code>true</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="on"></a></p>
<h2 id="on">on</h2>
<p>&#x25B8; <strong>on</strong>(type: <em><a href="../modules/_types_d_.md#providerinterface_emitted">ProviderInterface$Emitted</a></em>, sub: <em><a href="../modules/_types_d_.md#providerinterface_emitcb">ProviderInterface$EmitCb</a></em>): <code>this</code></p>
<p><em>Overrides EventEmitter.on</em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L131" target="_blank">ws/index.ts:131</a></em></p>
<p><em><strong>summary</strong></em>: Listens on events after having subscribed using the <a href="_ws_index_.wsprovider.html#subscribe">subscribe</a> function.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td><a href="../modules/_types_d_.md#providerinterface_emitted">ProviderInterface$Emitted</a></td>
<td>Event</td>
</tr>
<tr>
<td>sub</td>
<td><a href="../modules/_types_d_.md#providerinterface_emitcb">ProviderInterface$EmitCb</a></td>
<td>Callback</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code>
[description]</p>
<hr>
<p><a id="once"></a></p>
<h2 id="once">once</h2>
<p>&#x25B8; <strong>once</strong>(event: <em><code>EventTypes</code></em>, fn: <em><code>ListenerFn</code></em>, context?: <em><code>any</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.once</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:38</em></p>
<p>Add a one-time listener for a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td>fn</td>
<td><code>ListenerFn</code></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="removealllisteners"></a></p>
<h2 id="removealllisteners">removeAllListeners</h2>
<p>&#x25B8; <strong>removeAllListeners</strong>(event?: <em><a href="">EventTypes</a></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.removeAllListeners</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:49</em></p>
<p>Remove all listeners, or those of the specified event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Optional</code> event</td>
<td><a href="">EventTypes</a></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="removelistener"></a></p>
<h2 id="removelistener">removeListener</h2>
<p>&#x25B8; <strong>removeListener</strong>(event: <em><code>EventTypes</code></em>, fn?: <em><a href="../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md">ListenerFn</a></em>, context?: <em><code>any</code></em>, once?: <em> <code>undefined</code> | <code>false</code> | <code>true</code></em>): <code>this</code></p>
<p><em>Inherited from EventEmitter.removeListener</em></p>
<p><em>Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:43</em></p>
<p>Remove the listeners of a given event.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>event</td>
<td><code>EventTypes</code></td>
</tr>
<tr>
<td><code>Optional</code> fn</td>
<td><a href="../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md">ListenerFn</a></td>
</tr>
<tr>
<td><code>Optional</code> context</td>
<td><code>any</code></td>
</tr>
<tr>
<td><code>Optional</code> once</td>
<td><code>undefined</code> | <code>false</code> | <code>true</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>this</code></p>
<hr>
<p><a id="send"></a></p>
<h2 id="send">send</h2>
<p>&#x25B8; <strong>send</strong>(method: <em><code>string</code></em>, params: <em><code>Array</code>&lt;<code>any</code>&gt;</em>, subscription?: <em><code>SubscriptionHandler</code></em>): <code>Promise</code>&lt;<code>any</code>&gt;</p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L138" target="_blank">ws/index.ts:138</a></em></p>
<p><em><strong>summary</strong></em>: Send JSON data using WebSockets to configured HTTP Endpoint or queue.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>method</td>
<td><code>string</code></td>
</tr>
<tr>
<td>params</td>
<td><code>Array</code>&lt;<code>any</code>&gt;</td>
</tr>
<tr>
<td><code>Optional</code> subscription</td>
<td><code>SubscriptionHandler</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Promise</code>&lt;<code>any</code>&gt;</p>
<hr>
<p><a id="subscribe"></a></p>
<h2 id="subscribe">subscribe</h2>
<p>&#x25B8; <strong>subscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, params: <em><code>Array</code>&lt;<code>any</code>&gt;</em>, callback: <em><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></em>): <code>Promise</code>&lt;<code>number</code>&gt;</p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L194" target="_blank">ws/index.ts:194</a></em></p>
<p><em><strong>name</strong></em>: subscribe</p>
<p><em><strong>summary</strong></em>: Allows subscribing to a specific event.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;ws://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">state</span><span class="sunlight-operator">.</span><span class="sunlight-ident">storage</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">[</span><span class="sunlight-punctuation">[</span><span class="sunlight-ident">storage</span><span class="sunlight-operator">.</span><span class="sunlight-ident">balances</span><span class="sunlight-operator">.</span><span class="sunlight-ident">freeBalance</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-operator">&lt;</span><span class="sunlight-ident">Address</span><span class="sunlight-operator">&gt;</span><span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-punctuation">(</span><span class="sunlight-ident">_</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">values</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">values</span><span class="sunlight-punctuation">)</span>
<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">subscriptionId</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;balance&#xA0;changes&#xA0;subscription&#xA0;id:&#xA0;&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">subscriptionId</span><span class="sunlight-punctuation">)</span>
<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
</span></pre></div></div></code></pre>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td><code>string</code></td>
<td>Subscription type</td>
</tr>
<tr>
<td>method</td>
<td><code>string</code></td>
<td>Subscription method</td>
</tr>
<tr>
<td>params</td>
<td><code>Array</code>&lt;<code>any</code>&gt;</td>
<td>Parameters</td>
</tr>
<tr>
<td>callback</td>
<td><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></td>
<td>Callback</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Promise</code>&lt;<code>number</code>&gt;
Promise resolving to the dd of the subscription you can use with [[unsubscribe]].</p>
<hr>
<p><a id="unsubscribe"></a></p>
<h2 id="unsubscribe">unsubscribe</h2>
<p>&#x25B8; <strong>unsubscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, id: <em><code>number</code></em>): <code>Promise</code>&lt;<code>boolean</code>&gt;</p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/ws/index.ts#L203" target="_blank">ws/index.ts:203</a></em></p>
<p><em><strong>summary</strong></em>: Allows unsubscribing to subscriptions made with <a href="_ws_index_.wsprovider.html#subscribe">subscribe</a>.</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>type</td>
<td><code>string</code></td>
</tr>
<tr>
<td>method</td>
<td><code>string</code></td>
</tr>
<tr>
<td>id</td>
<td><code>number</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>Promise</code>&lt;<code>boolean</code>&gt;</p>
<hr>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="_http_index_.httpprovider.html" class="navigation navigation-prev " aria-label="Previous page: HttpProvider">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../api-rx/" class="navigation navigation-next " aria-label="Next page: api-rx">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"WsProvider","level":"1.3.2","depth":2,"next":{"title":"api-rx","level":"1.4","depth":1,"path":"api-rx/README.md","ref":"api-rx/README.md","articles":[{"title":"ApiRx","level":"1.4.1","depth":2,"path":"api-rx/classes/_index_.rxapi.md","ref":"api-rx/classes/_index_.rxapi.md","articles":[]}]},"previous":{"title":"HttpProvider","level":"1.3.1","depth":2,"path":"api-provider/classes/_http_index_.httpprovider.md","ref":"api-provider/classes/_http_index_.httpprovider.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api-provider/classes/_ws_index_.wsprovider.md","mtime":"2018-10-10T07:30:40.079Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
@@ -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` &#124; `symbol`
# Hierarchy
`EventEmitter`
**↳ WsProvider**
# Implements
* `WSProviderInterface`
# Constructors
<a id="constructor"></a>
## 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
<a id="prefixed"></a>
## `<Static>` prefixed
**● prefixed**: * `string` &#124; `boolean`
*
*Inherited from EventEmitter.prefixed*
*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:6*
___
# Methods
<a id="addlistener"></a>
## 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`
___
<a id="connect"></a>
## 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`
___
<a id="emit"></a>
## 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`
___
<a id="eventnames"></a>
## 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`>
___
<a id="isconnected"></a>
## 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
___
<a id="listenercount"></a>
## 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`
___
<a id="listeners"></a>
## 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`>
___
<a id="off"></a>
## off
▸ **off**(event: *`EventTypes`*, fn?: *[ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md)*, context?: *`any`*, once?: * `undefined` &#124; `false` &#124; `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` &#124; `false` &#124; `true`|
**Returns:** `this`
___
<a id="on"></a>
## 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]
___
<a id="once"></a>
## 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`
___
<a id="removealllisteners"></a>
## 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`
___
<a id="removelistener"></a>
## removeListener
▸ **removeListener**(event: *`EventTypes`*, fn?: *[ListenerFn](../interfaces/_ws_index_.wsprovider.eventemitter.listenerfn.md)*, context?: *`any`*, once?: * `undefined` &#124; `false` &#124; `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` &#124; `false` &#124; `true`|
**Returns:** `this`
___
<a id="send"></a>
## 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`>
___
<a id="subscribe"></a>
## 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, <Address>]], (_, 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]].
___
<a id="unsubscribe"></a>
## 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`>
___
-465
View File
@@ -1,465 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>api-provider · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../gitbook/style.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="classes/_http_index_.httpprovider.html" />
<link rel="prev" href="../api/classes/_index_.api.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../">
<a href="../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../api/">
<a href="../api/">
api
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../api/classes/_index_.api.html">
<a href="../api/classes/_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter active" data-level="1.3" data-path="./">
<a href="./">
api-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="classes/_http_index_.httpprovider.html">
<a href="classes/_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="classes/_ws_index_.wsprovider.html">
<a href="classes/_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../api-rx/">
<a href="../api-rx/">
api-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../api-rx/classes/_index_.rxapi.html">
<a href="../api-rx/classes/_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../examples/">
<a href="../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../examples/01_simple_connect/">
<a href="../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../examples/02_listen_to_blocks/">
<a href="../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../examples/03_listen_to_balance_change/">
<a href="../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../examples/04_generate_account/">
<a href="../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../examples/05_read_storage/">
<a href="../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../examples/06_craft_extrinsic/">
<a href="../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../examples/07_transfer_dots/">
<a href="../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href=".." >api-provider</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><a href="https://polkadot.js.org" target="_blank"><img src="https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square" alt="polkadotjs"></a> <img src="https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square" alt="isc"> <a href="https://github.com/Flet/semistandard" target="_blank"><img src="https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square" alt="style"></a> <a href="https://www.npmjs.com/package/@polkadot/api-provider" target="_blank"><img src="https://img.shields.io/npm/v/@polkadot/api-provider.svg?style=flat-square" alt="npm"></a> <a href="https://travis-ci.org/polkadot-js/api" target="_blank"><img src="https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square" alt="travis"></a> <a href="https://codeclimate.com/github/polkadot-js/api/maintainability" target="_blank"><img src="https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square" alt="maintainability"></a> <a href="https://coveralls.io/github/polkadot-js/api?branch=master" target="_blank"><img src="https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square" alt="coverage"></a> <a href="https://david-dm.org/polkadot-js/api?path=packages/api-provider" target="_blank"><img src="https://david-dm.org/polkadot-js/api.svg?style=flat-square&amp;path=packages/api-provider" alt="dependency"></a> <a href="https://david-dm.org/polkadot-js/api?path=packages/api-provider#info=devDependencies" target="_blank"><img src="https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&amp;path=packages/api-provider" alt="devDependency"></a></p>
<h1 id="polkadotapi-provider">@polkadot/api-provider</h1>
<p>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&apos;t be directly used. API interfaces building on top these providers can support various transports with the same underlying interfaces.</p>
<h2 id="usage">Usage</h2>
<p>Installation -</p>
<pre><code>npm install --save @polkadot/api-provider
</code></pre><p>Initialisation -</p>
<pre><code class="lang-js"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;http://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">version</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-ident">await</span>&#xA0;<span class="sunlight-ident">provider</span><span class="sunlight-operator">.</span><span class="sunlight-ident">send</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;client_version&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-punctuation">[</span><span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;clientVersion&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">version</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../api/classes/_index_.api.html" class="navigation navigation-prev " aria-label="Previous page: Api">
<i class="fa fa-angle-left"></i>
</a>
<a href="classes/_http_index_.httpprovider.html" class="navigation navigation-next " aria-label="Next page: HttpProvider">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"api-provider","level":"1.3","depth":1,"next":{"title":"HttpProvider","level":"1.3.1","depth":2,"path":"api-provider/classes/_http_index_.httpprovider.md","ref":"api-provider/classes/_http_index_.httpprovider.md","articles":[]},"previous":{"title":"Api","level":"1.2.1","depth":2,"path":"api/classes/_index_.api.md","ref":"api/classes/_index_.api.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api-provider/README.md","mtime":"2018-10-10T07:30:39.787Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
@@ -1,99 +0,0 @@
# Hierarchy
**ProviderInterface**
# Implemented by
* [HttpProvider](../classes/_http_index_.httpprovider.md)
# Methods
<a id="isconnected"></a>
## 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`
___
<a id="on"></a>
## 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`
___
<a id="send"></a>
## 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`>
___
<a id="subscribe"></a>
## 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`>
___
<a id="unsubscribe"></a>
## 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`>
___
@@ -1,24 +0,0 @@
# Hierarchy
**EventEmitterStatic**
# Constructors
<a id="constructor"></a>
## 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` &#124; `symbol`
**Returns:** `EventEmitter`<`EventTypes`>
___
@@ -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`
@@ -1,23 +0,0 @@
# Functions
<a id="decoderesponse"></a>
## 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`
___
@@ -1,24 +0,0 @@
# Functions
<a id="encodejson"></a>
## 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`
___
@@ -1,24 +0,0 @@
# Functions
<a id="encodeobject"></a>
## 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)
___
@@ -1,16 +0,0 @@
# Functions
<a id="rpccoder"></a>
## 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)
___
@@ -1,27 +0,0 @@
# Type aliases
<a id="rpccoder"></a>
## 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
___
<a id="rpccoderstate"></a>
## 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
___
-10
View File
@@ -1,10 +0,0 @@
# Index
### Classes
* [HttpProvider](../classes/_http_index_.httpprovider.md)
---
@@ -1,2 +0,0 @@
@@ -1,16 +0,0 @@
# Type aliases
<a id="httpstate"></a>
## 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
___
-2
View File
@@ -1,2 +0,0 @@
-19
View File
@@ -1,19 +0,0 @@
# Functions
<a id="mockprovider"></a>
## 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
___
-22
View File
@@ -1,22 +0,0 @@
# Functions
<a id="mocks"></a>
## 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`
___
-24
View File
@@ -1,24 +0,0 @@
# Functions
<a id="on"></a>
## 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`
___
-24
View File
@@ -1,24 +0,0 @@
# Functions
<a id="send"></a>
## 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`>
___
-16
View File
@@ -1,16 +0,0 @@
# Functions
<a id="state"></a>
## 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)
___
@@ -1,25 +0,0 @@
# Functions
<a id="subscribe"></a>
## 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`>
___
@@ -1,87 +0,0 @@
# Type aliases
<a id="mockstate"></a>
## 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
___
<a id="mockstate_db"></a>
## 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`
___
<a id="mockstate_requests"></a>
## 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`
___
<a id="mockstate_subscription_callback"></a>
## 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` &#124; `null`*, value: *`any`*): `void`
**Parameters:**
| Param | Type |
| ------ | ------ |
| error | `Error` &#124; `null`|
| value | `any` |
**Returns:** `void`
___
<a id="mockstate_subscriptions"></a>
## 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`
___
@@ -1,25 +0,0 @@
# Functions
<a id="unsubscribe"></a>
## 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`>
___
-108
View File
@@ -1,108 +0,0 @@
# Type aliases
<a id="jsonrpcobject"></a>
## 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
___
<a id="jsonrpcrequest"></a>
## 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)*
___
<a id="jsonrpcresponse"></a>
## 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)*
___
<a id="jsonrpcresponsebase"></a>
## 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)*
___
<a id="jsonrpcresponsebase_error"></a>
## 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
___
<a id="providerinterface_callback"></a>
## 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` &#124; `null`*, result: *`any`*): `void`
**Parameters:**
| Param | Type |
| ------ | ------ |
| error | `Error` &#124; `null`|
| result | `any` |
**Returns:** `void`
___
<a id="providerinterface_emitcb"></a>
## 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`
___
<a id="providerinterface_emitted"></a>
## ProviderInterface$Emitted
**Ƭ ProviderInterface$Emitted**: * "connected" &#124; "disconnected"
*
*Defined in [types.d.ts:40](https://github.com/polkadot-js/api/blob/7f270cb/packages/api-provider/src/types.d.ts#L40)*
___
-10
View File
@@ -1,10 +0,0 @@
# Index
### Classes
* [WsProvider](../classes/_ws_index_.wsprovider.md)
---
@@ -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
<a id="eventemitter"></a>
## `<Const>` EventEmitter
**● EventEmitter**: *`EventEmitterStatic`*
*Defined in /home/travis/build/polkadot-js/api/node_modules/eventemitter3/index.d.ts:61*
___
@@ -1,2 +0,0 @@
-8
View File
@@ -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).
-4
View File
@@ -1,4 +0,0 @@
* [&quot;defaults&quot;](modules/_defaults_.md)
* [&quot;index&quot;](modules/_index_.md)
* [RxApi](classes/_index_.rxapi.md)
* [&quot;types.d&quot;](modules/_types_d_.md)
-521
View File
@@ -1,521 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>ApiRx · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="../../examples/" />
<link rel="prev" href="../" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../../api/">
<a href="../../api/">
api
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../../api/classes/_index_.api.html">
<a href="../../api/classes/_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../../api-provider/">
<a href="../../api-provider/">
api-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../../api-provider/classes/_http_index_.httpprovider.html">
<a href="../../api-provider/classes/_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="../../api-provider/classes/_ws_index_.wsprovider.html">
<a href="../../api-provider/classes/_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../">
<a href="../">
api-rx
</a>
<ul class="articles">
<li class="chapter active" data-level="1.4.1" data-path="_index_.rxapi.html">
<a href="_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../../examples/">
<a href="../../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../examples/01_simple_connect/">
<a href="../../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../examples/02_listen_to_blocks/">
<a href="../../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../examples/03_listen_to_balance_change/">
<a href="../../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../../examples/04_generate_account/">
<a href="../../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../../examples/05_read_storage/">
<a href="../../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../../examples/06_craft_extrinsic/">
<a href="../../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../../examples/07_transfer_dots/">
<a href="../../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >ApiRx</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><em><strong>name</strong></em>: RxApi</p>
<p><em><strong>summary</strong></em>: The RxJS API is a wrapper around the API.</p>
<p><em><strong>description</strong></em>: It allows wrapping API components with observables using RxJS.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">RxApi</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;http://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">rxapi</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">RxApi</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<h1 id="hierarchy">Hierarchy</h1>
<p><strong>RxApi</strong></p>
<h1 id="implements">Implements</h1>
<ul>
<li><code>object</code></li>
</ul>
<h1 id="constructors">Constructors</h1>
<p><a id="constructor"></a></p>
<h2 id="constructor">constructor</h2>
<p>&#x2295; <strong>new RxApi</strong>(provider?: <em><code>ProviderInterface</code></em>): <a href="_index_.rxapi.html">RxApi</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L46" target="_blank">index.ts:46</a></em></p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Default value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Default value</code> provider</td>
<td><code>ProviderInterface</code></td>
<td>new Ws(defaults.WS_URL)</td>
<td>An API provider using HTTP or WebSocket</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <a href="_index_.rxapi.html">RxApi</a></p>
<hr>
<h1 id="properties">Properties</h1>
<p><a id="author"></a></p>
<h2 id="author">author</h2>
<p><strong>&#x25CF; author</strong>: <em><a href="../modules/_types_d_.md#rxapiinterface_section">RxApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L43" target="_blank">index.ts:43</a></em></p>
<hr>
<p><a id="chain"></a></p>
<h2 id="chain">chain</h2>
<p><strong>&#x25CF; chain</strong>: <em><a href="../modules/_types_d_.md#rxapiinterface_section">RxApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L44" target="_blank">index.ts:44</a></em></p>
<hr>
<p><a id="state"></a></p>
<h2 id="state">state</h2>
<p><strong>&#x25CF; state</strong>: <em><a href="../modules/_types_d_.md#rxapiinterface_section">RxApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L45" target="_blank">index.ts:45</a></em></p>
<hr>
<p><a id="system"></a></p>
<h2 id="system">system</h2>
<p><strong>&#x25CF; system</strong>: <em><a href="../modules/_types_d_.md#rxapiinterface_section">RxApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L46" target="_blank">index.ts:46</a></em></p>
<hr>
<h1 id="methods">Methods</h1>
<p><a id="isconnected"></a></p>
<h2 id="isconnected">isConnected</h2>
<p>&#x25B8; <strong>isConnected</strong>(): <code>BehaviorSubject</code>&lt;<code>boolean</code>&gt;</p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api-rx/src/index.ts#L65" target="_blank">index.ts:65</a></em></p>
<p><strong>Returns:</strong> <code>BehaviorSubject</code>&lt;<code>boolean</code>&gt;</p>
<hr>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../" class="navigation navigation-prev " aria-label="Previous page: api-rx">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../examples/" class="navigation navigation-next " aria-label="Next page: Overview">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"ApiRx","level":"1.4.1","depth":2,"next":{"title":"Overview","level":"2.1","depth":1,"path":"examples/README.md","ref":"examples/README.md","articles":[]},"previous":{"title":"api-rx","level":"1.4","depth":1,"path":"api-rx/README.md","ref":"api-rx/README.md","articles":[{"title":"ApiRx","level":"1.4.1","depth":2,"path":"api-rx/classes/_index_.rxapi.md","ref":"api-rx/classes/_index_.rxapi.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api-rx/classes/_index_.rxapi.md","mtime":"2018-10-10T07:30:48.420Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
-98
View File
@@ -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
<a id="constructor"></a>
## 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
<a id="author"></a>
## 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)*
___
<a id="chain"></a>
## 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)*
___
<a id="state"></a>
## 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)*
___
<a id="system"></a>
## 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
<a id="isconnected"></a>
## 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`>
___
-454
View File
@@ -1,454 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>api-rx · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../gitbook/style.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="classes/_index_.rxapi.html" />
<link rel="prev" href="../api-provider/classes/_ws_index_.wsprovider.html" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../">
<a href="../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../api/">
<a href="../api/">
api
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="../api/classes/_index_.api.html">
<a href="../api/classes/_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../api-provider/">
<a href="../api-provider/">
api-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../api-provider/classes/_http_index_.httpprovider.html">
<a href="../api-provider/classes/_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="../api-provider/classes/_ws_index_.wsprovider.html">
<a href="../api-provider/classes/_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter active" data-level="1.4" data-path="./">
<a href="./">
api-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="classes/_index_.rxapi.html">
<a href="classes/_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../examples/">
<a href="../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../examples/01_simple_connect/">
<a href="../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../examples/02_listen_to_blocks/">
<a href="../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../examples/03_listen_to_balance_change/">
<a href="../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../examples/04_generate_account/">
<a href="../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../examples/05_read_storage/">
<a href="../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../examples/06_craft_extrinsic/">
<a href="../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../examples/07_transfer_dots/">
<a href="../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href=".." >api-rx</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><a href="https://polkadot.js.org" target="_blank"><img src="https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square" alt="polkadotjs"></a> <img src="https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square" alt="isc"> <a href="https://github.com/Flet/semistandard" target="_blank"><img src="https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square" alt="style"></a> <a href="https://www.npmjs.com/package/@polkadot/api-rx" target="_blank"><img src="https://img.shields.io/npm/v/@polkadot/api-rx.svg?style=flat-square" alt="npm"></a> <a href="https://travis-ci.org/polkadot-js/api" target="_blank"><img src="https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square" alt="travis"></a> <a href="https://codeclimate.com/github/polkadot-js/api/maintainability" target="_blank"><img src="https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square" alt="maintainability"></a> <a href="https://coveralls.io/github/polkadot-js/api?branch=master" target="_blank"><img src="https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square" alt="coverage"></a> <a href="https://david-dm.org/polkadot-js/api?path=packages/api-rx" target="_blank"><img src="https://david-dm.org/polkadot-js/api.svg?style=flat-square&amp;path=packages/api-rx" alt="dependency"></a> <a href="https://david-dm.org/polkadot-js/api?path=packages/api-rx#info=devDependencies" target="_blank"><img src="https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&amp;path=packages/api-rx" alt="devDependency"></a></p>
<h1 id="polkadotapi-rx">@polkadot/api-rx</h1>
<p>An RxJs wrapper around the <a href="../api">@polkadot/api</a>.</p>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../api-provider/classes/_ws_index_.wsprovider.html" class="navigation navigation-prev " aria-label="Previous page: WsProvider">
<i class="fa fa-angle-left"></i>
</a>
<a href="classes/_index_.rxapi.html" class="navigation navigation-next " aria-label="Next page: ApiRx">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"api-rx","level":"1.4","depth":1,"next":{"title":"ApiRx","level":"1.4.1","depth":2,"path":"api-rx/classes/_index_.rxapi.md","ref":"api-rx/classes/_index_.rxapi.md","articles":[]},"previous":{"title":"WsProvider","level":"1.3.2","depth":2,"path":"api-provider/classes/_ws_index_.wsprovider.md","ref":"api-provider/classes/_ws_index_.wsprovider.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api-rx/README.md","mtime":"2018-10-10T07:30:48.304Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
-2
View File
@@ -1,2 +0,0 @@
-10
View File
@@ -1,10 +0,0 @@
# Index
### Classes
* [RxApi](../classes/_index_.rxapi.md)
---
-49
View File
@@ -1,49 +0,0 @@
# Type aliases
<a id="rxapiinterface"></a>
## 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
___
<a id="rxapiinterface_method"></a>
## 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`> &#124; `BehaviorSubject`<`any`>
**Parameters:**
| Param | Type |
| ------ | ------ |
| `Rest` params | `Array`<`any`> |
**Returns:** `Observable`<`any`> &#124; `BehaviorSubject`<`any`>
___
<a id="rxapiinterface_section"></a>
## 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)
___
-72
View File
@@ -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);
});
```
-4
View File
@@ -1,4 +0,0 @@
* [&quot;index&quot;](modules/_index_.md)
* [Api](classes/_index_.api.md)
* [&quot;types.d&quot;](modules/_types_d_.md)
* [ApiInterface$Section$Method](interfaces/_types_d_.apiinterface_section_method.md)
-543
View File
@@ -1,543 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Api · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../../gitbook/style.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="../../api-provider/" />
<link rel="prev" href="../" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../../">
<a href="../../">
Introduction
</a>
</li>
<li class="chapter " data-level="1.2" data-path="../">
<a href="../">
api
</a>
<ul class="articles">
<li class="chapter active" data-level="1.2.1" data-path="_index_.api.html">
<a href="_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../../api-provider/">
<a href="../../api-provider/">
api-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../../api-provider/classes/_http_index_.httpprovider.html">
<a href="../../api-provider/classes/_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="../../api-provider/classes/_ws_index_.wsprovider.html">
<a href="../../api-provider/classes/_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../../api-rx/">
<a href="../../api-rx/">
api-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../../api-rx/classes/_index_.rxapi.html">
<a href="../../api-rx/classes/_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../../examples/">
<a href="../../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../../examples/01_simple_connect/">
<a href="../../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../../examples/02_listen_to_blocks/">
<a href="../../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../../examples/03_listen_to_balance_change/">
<a href="../../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../../examples/04_generate_account/">
<a href="../../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../../examples/05_read_storage/">
<a href="../../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../../examples/06_craft_extrinsic/">
<a href="../../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../../examples/07_transfer_dots/">
<a href="../../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="../.." >Api</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><em><strong>name</strong></em>: Api</p>
<p><em><strong>summary</strong></em>: The API may use a HTTP or WebSockets provider.</p>
<p><em><strong>description</strong></em>: It allows for querying a Polkadot Client Node.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;ws://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<h1 id="hierarchy">Hierarchy</h1>
<p><strong>Api</strong></p>
<h1 id="implements">Implements</h1>
<ul>
<li><code>object</code></li>
</ul>
<h1 id="constructors">Constructors</h1>
<p><a id="constructor"></a></p>
<h2 id="constructor">constructor</h2>
<p>&#x2295; <strong>new Api</strong>(provider: <em><code>ProviderInterface</code></em>): <a href="_index_.api.html">Api</a></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L37" target="_blank">index.ts:37</a></em></p>
<p><em><strong>constructor</strong></em>: Default constructor for the Api Object</p>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>provider</td>
<td><code>ProviderInterface</code></td>
<td>An API provider using HTTP or WebSocket</td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <a href="_index_.api.html">Api</a></p>
<hr>
<h1 id="properties">Properties</h1>
<p><a id="author"></a></p>
<h2 id="author">author</h2>
<p><strong>&#x25CF; author</strong>: <em><a href="../modules/_types_d_.md#apiinterface_section">ApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L34" target="_blank">index.ts:34</a></em></p>
<hr>
<p><a id="chain"></a></p>
<h2 id="chain">chain</h2>
<p><strong>&#x25CF; chain</strong>: <em><a href="../modules/_types_d_.md#apiinterface_section">ApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L35" target="_blank">index.ts:35</a></em></p>
<hr>
<p><a id="state"></a></p>
<h2 id="state">state</h2>
<p><strong>&#x25CF; state</strong>: <em><a href="../modules/_types_d_.md#apiinterface_section">ApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L36" target="_blank">index.ts:36</a></em></p>
<hr>
<p><a id="system"></a></p>
<h2 id="system">system</h2>
<p><strong>&#x25CF; system</strong>: <em><a href="../modules/_types_d_.md#apiinterface_section">ApiInterface$Section</a></em></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L37" target="_blank">index.ts:37</a></em></p>
<hr>
<h1 id="methods">Methods</h1>
<p><a id="signature"></a></p>
<h2 id="static-signature"><code>&lt;Static&gt;</code> signature</h2>
<p>&#x25B8; <strong>signature</strong>(__namedParameters: <em><code>object</code></em>): <code>string</code></p>
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/index.ts#L72" target="_blank">index.ts:72</a></em></p>
<p><em><strong>name</strong></em>: signature</p>
<p><em><strong>summary</strong></em>: Returns a string representation of the method with inputs and outputs.</p>
<p><em><strong>description</strong></em>: Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type.</p>
<p><em><strong>example</strong></em>: </p>
<pre><code class="lang-javascript"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-ident">Api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">signature</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">{</span>&#xA0;<span class="sunlight-ident">name</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;test_method&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">params</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-punctuation">[</span>&#xA0;<span class="sunlight-punctuation">{</span>&#xA0;<span class="sunlight-ident">name</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;dest&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">type</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;Address&apos;</span>&#xA0;<span class="sunlight-punctuation">}</span>&#xA0;<span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">type</span><span class="sunlight-operator">:</span>&#xA0;<span class="sunlight-string">&apos;Address&apos;</span>&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>&#xA0;<span class="sunlight-comment">//&#xA0;=&gt;&#xA0;test_method&#xA0;(dest:&#xA0;Address):&#xA0;Address</span>
</span></pre></div></div></code></pre>
<p><strong>Parameters:</strong></p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>__namedParameters</td>
<td><code>object</code></td>
</tr>
</tbody>
</table>
<p><strong>Returns:</strong> <code>string</code></p>
<hr>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../" class="navigation navigation-prev " aria-label="Previous page: api">
<i class="fa fa-angle-left"></i>
</a>
<a href="../../api-provider/" class="navigation navigation-next " aria-label="Next page: api-provider">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"Api","level":"1.2.1","depth":2,"next":{"title":"api-provider","level":"1.3","depth":1,"path":"api-provider/README.md","ref":"api-provider/README.md","articles":[{"title":"HttpProvider","level":"1.3.1","depth":2,"path":"api-provider/classes/_http_index_.httpprovider.md","ref":"api-provider/classes/_http_index_.httpprovider.md","articles":[]},{"title":"WsProvider","level":"1.3.2","depth":2,"path":"api-provider/classes/_ws_index_.wsprovider.md","ref":"api-provider/classes/_ws_index_.wsprovider.md","articles":[]}]},"previous":{"title":"api","level":"1.2","depth":1,"path":"api/README.md","ref":"api/README.md","articles":[{"title":"Api","level":"1.2.1","depth":2,"path":"api/classes/_index_.api.md","ref":"api/classes/_index_.api.md","articles":[]}]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api/classes/_index_.api.md","mtime":"2018-10-10T07:30:23.059Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"../..","book":{"language":""}});
});
</script>
</div>
<script src="../../gitbook/gitbook.js"></script>
<script src="../../gitbook/theme.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
-119
View File
@@ -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
<a id="constructor"></a>
## 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
<a id="author"></a>
## 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)*
___
<a id="chain"></a>
## 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)*
___
<a id="state"></a>
## 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)*
___
<a id="system"></a>
## 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
<a id="signature"></a>
## `<Static>` 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`
___
-500
View File
@@ -1,500 +0,0 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>api · Polkadot API Book</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="description" content="">
<meta name="generator" content="GitBook 3.2.3">
<link rel="stylesheet" href="../gitbook/style.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-sunlight-highlighter/sunlight.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
<meta name="HandheldFriendly" content="true"/>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
<link rel="next" href="classes/_index_.api.html" />
<link rel="prev" href="../" />
</head>
<body>
<div class="book">
<div class="book-summary">
<div id="book-search-input" role="search">
<input type="text" placeholder="Type to search" />
</div>
<nav role="navigation">
<ul class="summary">
<li class="header">Packages</li>
<li class="chapter " data-level="1.1" data-path="../">
<a href="../">
Introduction
</a>
</li>
<li class="chapter active" data-level="1.2" data-path="./">
<a href="./">
api
</a>
<ul class="articles">
<li class="chapter " data-level="1.2.1" data-path="classes/_index_.api.html">
<a href="classes/_index_.api.html">
Api
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.3" data-path="../api-provider/">
<a href="../api-provider/">
api-provider
</a>
<ul class="articles">
<li class="chapter " data-level="1.3.1" data-path="../api-provider/classes/_http_index_.httpprovider.html">
<a href="../api-provider/classes/_http_index_.httpprovider.html">
HttpProvider
</a>
</li>
<li class="chapter " data-level="1.3.2" data-path="../api-provider/classes/_ws_index_.wsprovider.html">
<a href="../api-provider/classes/_ws_index_.wsprovider.html">
WsProvider
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.4" data-path="../api-rx/">
<a href="../api-rx/">
api-rx
</a>
<ul class="articles">
<li class="chapter " data-level="1.4.1" data-path="../api-rx/classes/_index_.rxapi.html">
<a href="../api-rx/classes/_index_.rxapi.html">
ApiRx
</a>
</li>
</ul>
</li>
<li class="header">Examples</li>
<li class="chapter " data-level="2.1" data-path="../examples/">
<a href="../examples/">
Overview
</a>
</li>
<li class="chapter " data-level="2.2" data-path="../examples/01_simple_connect/">
<a href="../examples/01_simple_connect/">
Simple connect
</a>
</li>
<li class="chapter " data-level="2.3" data-path="../examples/02_listen_to_blocks/">
<a href="../examples/02_listen_to_blocks/">
Listen to blocks
</a>
</li>
<li class="chapter " data-level="2.4" data-path="../examples/03_listen_to_balance_change/">
<a href="../examples/03_listen_to_balance_change/">
Listen to balance change
</a>
</li>
<li class="chapter " data-level="2.5" data-path="../examples/04_generate_account/">
<a href="../examples/04_generate_account/">
Generate Accounts
</a>
</li>
<li class="chapter " data-level="2.6" data-path="../examples/05_read_storage/">
<a href="../examples/05_read_storage/">
Read Storage
</a>
</li>
<li class="chapter " data-level="2.7" data-path="../examples/06_craft_extrinsic/">
<a href="../examples/06_craft_extrinsic/">
Craft Extrinsic
</a>
</li>
<li class="chapter " data-level="2.8" data-path="../examples/07_transfer_dots/">
<a href="../examples/07_transfer_dots/">
Transfer DOTs
</a>
</li>
<li class="divider"></li>
<li>
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
Published with GitBook
</a>
</li>
</ul>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<div class="book-header" role="navigation">
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href=".." >api</a>
</h1>
</div>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<div id="book-search-results">
<div class="search-noresults">
<section class="normal markdown-section">
<p><a href="https://polkadot.js.org" target="_blank"><img src="https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square" alt="polkadotjs"></a> <img src="https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square" alt="isc"> <a href="https://github.com/Flet/semistandard" target="_blank"><img src="https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square" alt="style"></a> <a href="https://www.npmjs.com/package/@polkadot/api" target="_blank"><img src="https://img.shields.io/npm/v/@polkadot/api.svg?style=flat-square" alt="npm"></a> <a href="https://travis-ci.org/polkadot-js/api" target="_blank"><img src="https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square" alt="travis"></a> <a href="https://codeclimate.com/github/polkadot-js/api/maintainability" target="_blank"><img src="https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square" alt="maintainability"></a> <a href="https://coveralls.io/github/polkadot-js/api?branch=master" target="_blank"><img src="https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square" alt="coverage"></a> <a href="https://david-dm.org/polkadot-js/api?path=packages/api" target="_blank"><img src="https://david-dm.org/polkadot-js/api.svg?style=flat-square&amp;path=packages/api" alt="dependency"></a> <a href="https://david-dm.org/polkadot-js/api?path=packages/api#info=devDependencies" target="_blank"><img src="https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&amp;path=packages/api" alt="devDependency"></a></p>
<h1 id="polkadotapi">@polkadot/api</h1>
<p>This library provides a clean wrapper around all the methods exposed by a Polkadot network client.</p>
<h2 id="usage">Usage</h2>
<p>Installation -</p>
<pre><code>npm install --save @polkadot/api
</code></pre><p>Initialisation -</p>
<pre><code class="lang-js"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">Api</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">import</span>&#xA0;<span class="sunlight-ident">WsProvider</span>&#xA0;<span class="sunlight-ident">from</span>&#xA0;<span class="sunlight-string">&apos;@polkadot/api-provider/ws&apos;</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">provider</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;http://127.0.0.1:9944&apos;</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
<span class="sunlight-reservedWord">const</span>&#xA0;<span class="sunlight-ident">api</span>&#xA0;<span class="sunlight-operator">=</span>&#xA0;<span class="sunlight-keyword">new</span>&#xA0;<span class="sunlight-ident">Api</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">provider</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p>Making calls -</p>
<pre><code class="lang-js"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">getHeader</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;0x1234567890&apos;</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-keyword">catch</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p>Retrieving the best block (once-off) -</p>
<pre><code class="lang-js"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">getHead</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">headerHash</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-keyword">return</span>&#xA0;<span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span><span class="sunlight-operator">.</span><span class="sunlight-ident">getHeader</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">headerHash</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-ident">best</span>&#xA0;<span class="sunlight-punctuation">#</span><span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">header</span><span class="sunlight-operator">.</span><span class="sunlight-ident">number</span><span class="sunlight-operator">.</span><span class="sunlight-ident">toString</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-keyword">catch</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;error:&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
<p>Retrieving best header via subscription -</p>
<pre><code class="lang-js"><div class="sunlight-container sunlight-theme-gitbook"><div class="sunlight-code-container"><pre class="sunlight-highlight-javascript sunlight-highlighted"><span class="sunlight-javascript"><span class="sunlight-ident">api</span><span class="sunlight-operator">.</span><span class="sunlight-ident">chain</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">newHead</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">header</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-keyword">if</span>&#xA0;<span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;error:&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-punctuation">}</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">log</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">`</span><span class="sunlight-ident">best</span>&#xA0;<span class="sunlight-punctuation">#</span><span class="sunlight-ident">$</span><span class="sunlight-punctuation">{</span><span class="sunlight-ident">header</span><span class="sunlight-operator">.</span><span class="sunlight-ident">number</span><span class="sunlight-operator">.</span><span class="sunlight-ident">toString</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">`</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-ident">then</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">subscriptionId</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-comment">//&#xA0;id&#xA0;for&#xA0;the&#xA0;subscription,&#xA0;can&#xA0;unsubscribe&#xA0;via</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-comment">//&#xA0;api.chain.newHead.unsubscribe(subscriptionId)</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span>
&#xA0;&#xA0;<span class="sunlight-operator">.</span><span class="sunlight-keyword">catch</span><span class="sunlight-punctuation">(</span><span class="sunlight-punctuation">(</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span>&#xA0;<span class="sunlight-operator">=</span><span class="sunlight-operator">&gt;</span>&#xA0;<span class="sunlight-punctuation">{</span>
&#xA0;&#xA0;&#xA0;&#xA0;<span class="sunlight-ident">console</span><span class="sunlight-operator">.</span><span class="sunlight-ident">error</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">&apos;error&#xA0;subscribing:&apos;</span><span class="sunlight-punctuation">,</span>&#xA0;<span class="sunlight-ident">error</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
&#xA0;&#xA0;<span class="sunlight-punctuation">}</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
</span></pre></div></div></code></pre>
</section>
</div>
<div class="search-results">
<div class="has-results">
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
<ul class="search-results-list"></ul>
</div>
<div class="no-results">
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
</div>
</div>
</div>
</div>
</div>
</div>
<a href="../" class="navigation navigation-prev " aria-label="Previous page: Introduction">
<i class="fa fa-angle-left"></i>
</a>
<a href="classes/_index_.api.html" class="navigation navigation-next " aria-label="Next page: Api">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"api","level":"1.2","depth":1,"next":{"title":"Api","level":"1.2.1","depth":2,"path":"api/classes/_index_.api.md","ref":"api/classes/_index_.api.md","articles":[]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[]},"dir":"ltr"},"config":{"plugins":["include-codeblock","-highlight","sunlight-highlighter"],"root":"docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"sunlight-highlighter":{"theme":"gitbook","lineNumbers":false},"include-codeblock":{"check":false,"edit":false,"lang":"","fixlang":false,"template":"default","theme":"chrome","unindent":false},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Polkadot API Book","gitbook":">=2.4.0"},"file":{"path":"api/README.md","mtime":"2018-10-10T07:30:22.927Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-10T07:31:27.069Z"},"basePath":"..","book":{"language":""}});
});
</script>
</div>
<script src="../gitbook/gitbook.js"></script>
<script src="../gitbook/theme.js"></script>
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
</body>
</html>
@@ -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
<a id="subscription"></a>
## subscription
**● subscription**: *`string`*
*Defined in [types.d.ts:10](https://github.com/polkadot-js/api/blob/7f270cb/packages/api/src/types.d.ts#L10)*
___
<a id="unsubscribe"></a>
## 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`>
___
-10
View File
@@ -1,10 +0,0 @@
# Index
### Classes
* [Api](../classes/_index_.api.md)
---
-29
View File
@@ -1,29 +0,0 @@
# Type aliases
<a id="apiinterface"></a>
## 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
___
<a id="apiinterface_section"></a>
## 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)
___
+14 -9
View File
@@ -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();
-8
View File
@@ -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);
```
+1 -1
View File
@@ -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).
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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.
+14 -9
View File
@@ -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);
+3 -3
View File
@@ -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', () => {
+5 -5
View File
@@ -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();
@@ -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) => {
+3 -3
View File
@@ -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', () => {
+3 -3
View File
@@ -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) => {
-27
View File
@@ -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
};
-83
View File
@@ -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
};
+1 -1
View File
@@ -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 -
+2 -2
View File
@@ -25,11 +25,11 @@ const ERROR_SUBSCRIBE = 'HTTP Provider does not have subscriptions, use WebSocke
* <BR>
*
* ```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]]
+1 -1
View File
@@ -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 {
+3 -3
View File
@@ -46,11 +46,11 @@ interface WSProviderInterface extends ProviderInterface {
* <BR>
*
* ```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, <Address>]], (_, values) => {
* console.log(values)
+1 -1
View File
@@ -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).
+2 -2
View File
@@ -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(() => {
+3 -3
View File
@@ -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', () => {
+2 -2
View File
@@ -29,11 +29,11 @@ type CachedMap = {
* <BR>
*
* ```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 {
+2 -2
View File
@@ -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(() => {
+2 -2
View File
@@ -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) => {
+1 -1
View File
@@ -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';
/**
@@ -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.
+3 -3
View File
@@ -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)
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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).
+1 -1
View File
@@ -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 {
}
+1 -1
View File
@@ -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 {
}
-1
View File
@@ -5,7 +5,6 @@ module.exports = {
excludeNotExported: true,
excludePrivate: true,
hideGenerator: true,
includes: './docs/guides',
includeDeclarations: true,
out: 'docs',
module: 'commonjs',