[CI Skip] 0.30.33
This commit is contained in:
@@ -370,14 +370,14 @@
|
||||
<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.</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'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> <span class="sunlight-ident">createApi</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api'</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">WsProvider</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api-provider/ws'</span><span class="sunlight-punctuation">;</span>
|
||||
<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> <span class="sunlight-ident">Api</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api'</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">HttpProvider</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api-provider/http'</span><span class="sunlight-punctuation">;</span>
|
||||
|
||||
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">provider</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">'http://127.0.0.1:9933'</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-ident">createApi</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-reservedWord">const</span> <span class="sunlight-ident">provider</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <span class="sunlight-ident">HttpProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">'http://127.0.0.1:9933'</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <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>
|
||||
@@ -390,7 +390,7 @@
|
||||
<p><a id="constructor"></a></p>
|
||||
<h2 id="constructor">constructor</h2>
|
||||
<p>⊕ <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/a8305c9/packages/api-provider/src/http/index.ts#L40" target="_blank">http/index.ts:40</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L40" target="_blank">http/index.ts:40</a></em></p>
|
||||
<p><strong>Parameters:</strong></p>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -415,7 +415,7 @@
|
||||
<h2 id="isconnected">isConnected</h2>
|
||||
<p>▸ <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/a8305c9/packages/api-provider/src/http/index.ts#L57" target="_blank">http/index.ts:57</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -424,7 +424,7 @@ true if connected</p>
|
||||
<h2 id="on">on</h2>
|
||||
<p>▸ <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/a8305c9/packages/api-provider/src/http/index.ts#L65" target="_blank">http/index.ts:65</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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 'on' emitters. WebSockets should be used instead.</p>
|
||||
<p><strong>Parameters:</strong></p>
|
||||
@@ -452,7 +452,7 @@ true if connected</p>
|
||||
<h2 id="send">send</h2>
|
||||
<p>▸ <strong>send</strong>(method: <em><code>string</code></em>, params: <em><code>Array</code><<code>any</code>></em>): <code>Promise</code><<code>any</code>></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/a8305c9/packages/api-provider/src/http/index.ts#L72" target="_blank">http/index.ts:72</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -479,7 +479,7 @@ true if connected</p>
|
||||
<h2 id="subscribe">subscribe</h2>
|
||||
<p>▸ <strong>subscribe</strong>(types: <em><code>string</code></em>, method: <em><code>string</code></em>, params: <em><code>Array</code><<code>any</code>></em>, cb: <em><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></em>): <code>Promise</code><<code>number</code>></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/a8305c9/packages/api-provider/src/http/index.ts#L94" target="_blank">http/index.ts:94</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -514,7 +514,7 @@ true if connected</p>
|
||||
<h2 id="unsubscribe">unsubscribe</h2>
|
||||
<p>▸ <strong>unsubscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, id: <em><code>number</code></em>): <code>Promise</code><<code>boolean</code>></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/a8305c9/packages/api-provider/src/http/index.ts#L103" target="_blank">http/index.ts:103</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -584,7 +584,7 @@ true if connected</p>
|
||||
<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-05T16:07:45.150Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-05T16:08:29.042Z"},"basePath":"../..","book":{"language":""}});
|
||||
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-05T21:03:45.743Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-05T21:04:29.559Z"},"basePath":"../..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
*__name__*: HttpProvider
|
||||
|
||||
*__summary__*: The HTTP Provider allows sending requests using HTTP.
|
||||
*__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 createApi from '@polkadot/api';
|
||||
import WsProvider from '@polkadot/api-provider/ws';
|
||||
import Api from '@polkadot/api';
|
||||
import HttpProvider from '@polkadot/api-provider/http';
|
||||
|
||||
const provider = new WsProvider('http://127.0.0.1:9933');
|
||||
const api = createApi(provider);
|
||||
const provider = new HttpProvider('http://127.0.0.1:9933');
|
||||
const api = new Api(provider);
|
||||
```
|
||||
|
||||
*__see__*: [WsProvider](_ws_index_.wsprovider.md)
|
||||
@@ -33,7 +33,7 @@ const api = createApi(provider);
|
||||
|
||||
⊕ **new HttpProvider**(endpoint: *`string`*): [HttpProvider](_http_index_.httpprovider.md)
|
||||
|
||||
*Defined in [http/index.ts:40](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/http/index.ts#L40)*
|
||||
*Defined in [http/index.ts:40](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L40)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
@@ -55,7 +55,7 @@ ___
|
||||
|
||||
*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/a8305c9/packages/api-provider/src/http/index.ts#L57)*
|
||||
*Defined in [http/index.ts:57](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L57)*
|
||||
|
||||
*__summary__*: Whether the node is connected or not.
|
||||
|
||||
@@ -71,7 +71,7 @@ ___
|
||||
|
||||
*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/a8305c9/packages/api-provider/src/http/index.ts#L65)*
|
||||
*Defined in [http/index.ts:65](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L65)*
|
||||
|
||||
*__summary__*: Events are not supported with the HttpProvider, see [WsProvider](_ws_index_.wsprovider.md).
|
||||
|
||||
@@ -95,7 +95,7 @@ ___
|
||||
|
||||
*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/a8305c9/packages/api-provider/src/http/index.ts#L72)*
|
||||
*Defined in [http/index.ts:72](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L72)*
|
||||
|
||||
*__summary__*: Send HTTP POST Request with Body to configured HTTP Endpoint.
|
||||
|
||||
@@ -117,7 +117,7 @@ ___
|
||||
|
||||
*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/a8305c9/packages/api-provider/src/http/index.ts#L94)*
|
||||
*Defined in [http/index.ts:94](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L94)*
|
||||
|
||||
*__summary__*: Subscriptions are not supported with the HttpProvider, see [WsProvider](_ws_index_.wsprovider.md).
|
||||
|
||||
@@ -141,7 +141,7 @@ ___
|
||||
|
||||
*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/a8305c9/packages/api-provider/src/http/index.ts#L103)*
|
||||
*Defined in [http/index.ts:103](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/http/index.ts#L103)*
|
||||
|
||||
*__summary__*: Subscriptions are not supported with the HttpProvider, see [WsProvider](_ws_index_.wsprovider.md).
|
||||
|
||||
|
||||
@@ -370,14 +370,14 @@
|
||||
<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.</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> <span class="sunlight-ident">createApi</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api'</span><span class="sunlight-punctuation">;</span>
|
||||
<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> <span class="sunlight-ident">Api</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api'</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">import</span> <span class="sunlight-ident">WsProvider</span> <span class="sunlight-ident">from</span> <span class="sunlight-string">'@polkadot/api-provider/ws'</span><span class="sunlight-punctuation">;</span>
|
||||
|
||||
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">provider</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">'ws://127.0.0.1:9944'</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-ident">createApi</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-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <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>
|
||||
@@ -393,7 +393,7 @@
|
||||
<p><a id="constructor"></a></p>
|
||||
<h2 id="constructor">constructor</h2>
|
||||
<p>⊕ <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/a8305c9/packages/api-provider/src/ws/index.ts#L73" target="_blank">ws/index.ts:73</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L73" target="_blank">ws/index.ts:73</a></em></p>
|
||||
<p><strong>Parameters:</strong></p>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -463,7 +463,7 @@
|
||||
<p><a id="connect"></a></p>
|
||||
<h2 id="connect">connect</h2>
|
||||
<p>▸ <strong>connect</strong>(): <code>void</code></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L104" target="_blank">ws/index.ts:104</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -506,7 +506,7 @@
|
||||
<p><a id="isconnected"></a></p>
|
||||
<h2 id="isconnected">isConnected</h2>
|
||||
<p>▸ <strong>isConnected</strong>(): <code>boolean</code></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L121" target="_blank">ws/index.ts:121</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -595,7 +595,7 @@ true if connected</p>
|
||||
<h2 id="on">on</h2>
|
||||
<p>▸ <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/a8305c9/packages/api-provider/src/ws/index.ts#L131" target="_blank">ws/index.ts:131</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -714,7 +714,7 @@ true if connected</p>
|
||||
<p><a id="send"></a></p>
|
||||
<h2 id="send">send</h2>
|
||||
<p>▸ <strong>send</strong>(method: <em><code>string</code></em>, params: <em><code>Array</code><<code>any</code>></em>, subscription?: <em><code>SubscriptionHandler</code></em>): <code>Promise</code><<code>any</code>></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L138" target="_blank">ws/index.ts:138</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -744,12 +744,12 @@ true if connected</p>
|
||||
<p><a id="subscribe"></a></p>
|
||||
<h2 id="subscribe">subscribe</h2>
|
||||
<p>▸ <strong>subscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, params: <em><code>Array</code><<code>any</code>></em>, callback: <em><a href="../modules/_types_d_.md#providerinterface_callback">ProviderInterface$Callback</a></em>): <code>Promise</code><<code>number</code>></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L194" target="_blank">ws/index.ts:194</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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> <span class="sunlight-ident">provider</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <span class="sunlight-ident">WsProvider</span><span class="sunlight-punctuation">(</span><span class="sunlight-string">'ws://127.0.0.1:9944'</span><span class="sunlight-punctuation">)</span><span class="sunlight-punctuation">;</span>
|
||||
<span class="sunlight-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-ident">createApi</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-reservedWord">const</span> <span class="sunlight-ident">api</span> <span class="sunlight-operator">=</span> <span class="sunlight-keyword">new</span> <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> <span class="sunlight-operator"><</span><span class="sunlight-ident">Address</span><span class="sunlight-operator">></span><span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">]</span><span class="sunlight-punctuation">,</span> <span class="sunlight-punctuation">(</span><span class="sunlight-ident">_</span><span class="sunlight-punctuation">,</span> <span class="sunlight-ident">values</span><span class="sunlight-punctuation">)</span> <span class="sunlight-operator">=</span><span class="sunlight-operator">></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-ident">values</span><span class="sunlight-punctuation">)</span>
|
||||
@@ -795,7 +795,7 @@ Promise resolving to the dd of the subscription you can use with [[unsubscribe]]
|
||||
<p><a id="unsubscribe"></a></p>
|
||||
<h2 id="unsubscribe">unsubscribe</h2>
|
||||
<p>▸ <strong>unsubscribe</strong>(type: <em><code>string</code></em>, method: <em><code>string</code></em>, id: <em><code>number</code></em>): <code>Promise</code><<code>boolean</code>></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L203" target="_blank">ws/index.ts:203</a></em></p>
|
||||
<p><em>Defined in <a href="https://github.com/polkadot-js/api/blob/ae54a71/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>
|
||||
@@ -865,7 +865,7 @@ Promise resolving to the dd of the subscription you can use with [[unsubscribe]]
|
||||
<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-05T16:07:45.246Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-05T16:08:29.042Z"},"basePath":"../..","book":{"language":""}});
|
||||
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-05T21:03:45.843Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-10-05T21:04:29.559Z"},"basePath":"../..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
*__name__*: WsProvider
|
||||
|
||||
*__summary__*: The WebSocket Provider allows sending requests using WebSocket.
|
||||
*__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 createApi from '@polkadot/api';
|
||||
import Api from '@polkadot/api';
|
||||
import WsProvider from '@polkadot/api-provider/ws';
|
||||
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
const api = createApi(provider);
|
||||
const api = new Api(provider);
|
||||
```
|
||||
|
||||
*__see__*: [HttpProvider](_http_index_.httpprovider.md)
|
||||
@@ -38,7 +38,7 @@ const api = createApi(provider);
|
||||
|
||||
⊕ **new WsProvider**(endpoint: *`string`*, autoConnect?: *`boolean`*): [WsProvider](_ws_index_.wsprovider.md)
|
||||
|
||||
*Defined in [ws/index.ts:73](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L73)*
|
||||
*Defined in [ws/index.ts:73](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L73)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
@@ -95,7 +95,7 @@ ___
|
||||
|
||||
▸ **connect**(): `void`
|
||||
|
||||
*Defined in [ws/index.ts:104](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L104)*
|
||||
*Defined in [ws/index.ts:104](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L104)*
|
||||
|
||||
*__summary__*: Manually connect
|
||||
|
||||
@@ -147,7 +147,7 @@ ___
|
||||
|
||||
▸ **isConnected**(): `boolean`
|
||||
|
||||
*Defined in [ws/index.ts:121](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L121)*
|
||||
*Defined in [ws/index.ts:121](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L121)*
|
||||
|
||||
*__summary__*: Whether the node is connected or not.
|
||||
|
||||
@@ -227,7 +227,7 @@ ___
|
||||
|
||||
*Overrides EventEmitter.on*
|
||||
|
||||
*Defined in [ws/index.ts:131](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L131)*
|
||||
*Defined in [ws/index.ts:131](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L131)*
|
||||
|
||||
*__summary__*: Listens on events after having subscribed using the [subscribe](_ws_index_.wsprovider.md#subscribe) function.
|
||||
|
||||
@@ -316,7 +316,7 @@ ___
|
||||
|
||||
▸ **send**(method: *`string`*, params: *`Array`<`any`>*, subscription?: *`SubscriptionHandler`*): `Promise`<`any`>
|
||||
|
||||
*Defined in [ws/index.ts:138](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L138)*
|
||||
*Defined in [ws/index.ts:138](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L138)*
|
||||
|
||||
*__summary__*: Send JSON data using WebSockets to configured HTTP Endpoint or queue.
|
||||
|
||||
@@ -337,7 +337,7 @@ ___
|
||||
|
||||
▸ **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/a8305c9/packages/api-provider/src/ws/index.ts#L194)*
|
||||
*Defined in [ws/index.ts:194](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L194)*
|
||||
|
||||
*__name__*: subscribe
|
||||
|
||||
@@ -346,7 +346,7 @@ ___
|
||||
*__example__*:
|
||||
```javascript
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
const api = createApi(provider);
|
||||
const api = new Api(provider);
|
||||
|
||||
api.state.storage([[storage.balances.freeBalance, <Address>]], (_, values) => {
|
||||
console.log(values)
|
||||
@@ -374,7 +374,7 @@ ___
|
||||
|
||||
▸ **unsubscribe**(type: *`string`*, method: *`string`*, id: *`number`*): `Promise`<`boolean`>
|
||||
|
||||
*Defined in [ws/index.ts:203](https://github.com/polkadot-js/api/blob/a8305c9/packages/api-provider/src/ws/index.ts#L203)*
|
||||
*Defined in [ws/index.ts:203](https://github.com/polkadot-js/api/blob/ae54a71/packages/api-provider/src/ws/index.ts#L203)*
|
||||
|
||||
*__summary__*: Allows unsubscribing to subscriptions made with [subscribe](_ws_index_.wsprovider.md#subscribe).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user