Add documentation and examples (#145)
* Add documentation * Justification u8a decoding and json encoding (#146) * Decode Justifications * Json encoding for justifications * Bump deps * Allow extrinsic length encoding to operate on u8a[] (#148) * Fix config and move generated doc to a subfolder * Cleanup extrinsic encoding (#150) * Cleanup extrinsic encoding * Removed now-defunct type * Add uncheckedLength encoding * Add examples * Ignore package-lock since we use yarn * Cleanup examples * Add gitbook config and some base files for the doc * Do not make full doc mandatory for now * Add contributing guide, polish doc and samples * Update the deps of all samples and add yarn scripts Fix and regenerate the doc * Fix Contributing guide
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
= Contributing
|
||||
|
||||
== What?
|
||||
|
||||
Individuals making significant and valuable contributions are given commit-access to a project to contribute as they see fit.
|
||||
A project is more like an open wiki than a standard guarded open source project.
|
||||
|
||||
== Rules
|
||||
|
||||
There are a few basic ground-rules for contributors (including the maintainer(s) of the project):
|
||||
|
||||
. **No `--force` pushes** or modifying the Git history in any way. If you need to rebase, ensure you do it in your own repo.
|
||||
. **Non-master branches**, prefixed with a short name moniker (e.g. `gav-my-feature`) must be used for ongoing work.
|
||||
. **All modifications** must be made in a **pull-request** to solicit feedback from other contributors.
|
||||
. A pull-request *must not be merged until CI* has finished successfully.
|
||||
|
||||
Merging pull requests once CI is successful:
|
||||
|
||||
. A pull request with no large change to logic that is an urgent fix may be merged after a non-author contributor has reviewed it well.
|
||||
. No PR should be merged until all reviews' comments are addressed.
|
||||
|
||||
.Reviewing pull requests:
|
||||
When reviewing a pull request, the end-goal is to suggest useful changes to the author. Reviews should finish with approval unless there are issues that would result in:
|
||||
|
||||
. Buggy behaviour.
|
||||
. Undue maintenance burden.
|
||||
. Breaking with house coding style.
|
||||
. Pessimisation (i.e. reduction of speed as measured in the projects benchmarks).
|
||||
. Feature reduction (i.e. it removes some aspect of functionality that a significant minority of users rely on).
|
||||
. Uselessness (i.e. it does not strictly add a feature or fix a known issue).
|
||||
|
||||
.Reviews may not be used as an effective veto for a PR because:
|
||||
. There exists a somewhat cleaner/better/faster way of accomplishing the same feature/fix.
|
||||
. It does not fit well with some other contributors' longer-term vision for the project.
|
||||
|
||||
== Releases
|
||||
|
||||
Declaring formal releases remains the prerogative of the project maintainer(s).
|
||||
|
||||
== Changes to this arrangement
|
||||
|
||||
This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.
|
||||
|
||||
== Heritage
|
||||
|
||||
These contributing guidelines are modified from the "OPEN Open Source Project" guidelines for the Level project: https://github.com/Level/community/blob/master/CONTRIBUTING.md
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
== DOT
|
||||
|
||||
some def
|
||||
|
||||
== Another term
|
||||
|
||||
some explanation
|
||||
@@ -0,0 +1,24 @@
|
||||
= Polkadot Javascript API
|
||||
:toc:
|
||||
|
||||
You can query a node and interact with the Polkadot network using Javascript. This guide describes the Polkadot Javascript API.
|
||||
|
||||
== The Polkadot Project
|
||||
|
||||
You can read more about the Polkadot Network at https://polkadot.network/
|
||||
|
||||
== Github repositories
|
||||
|
||||
You can find the Polkadot repositories at:
|
||||
|
||||
- https://github.com/polkadot-js
|
||||
- https://github.com/paritytech/polkadot
|
||||
- https://github.com/paritytech/substrate
|
||||
|
||||
This documentation is generated from https://github.com/polkadot-js/api
|
||||
|
||||
== Contributing
|
||||
|
||||
Contribution to the Polkadot JS API are more than welcome. You can https://github.com/polkadot-js/api/issues/new[report issues] and https://github.com/polkadot-js/api/issues/new[feature requests].
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
= Summary
|
||||
|
||||
== Intro
|
||||
|
||||
// Leave this emtpy, the README.adoc will be linked here.
|
||||
|
||||
== API
|
||||
|
||||
- link:api/README.md[api]
|
||||
- link:api-format/README.md[api-format]
|
||||
- link:api-provider/README.md[api-provider]
|
||||
- link:api-rx/README.md[api-rx]
|
||||
- link:type-extrinsics/README.md[type-extrinsics]
|
||||
- link:type-jsonrpc/README.md[type-jsonrpc]
|
||||
- link:type-params/README.md[type-params]
|
||||
- link:type-primitives/README.md[type-primitives]
|
||||
- link:type-storage/README.md[type-storage]
|
||||
|
||||
== Examples
|
||||
|
||||
- link:examples/README.adoc[Overview]
|
||||
- link:examples/01_simple_connect/README.adoc[Simple connect]
|
||||
- link:examples/02_listen_to_blocks/README.adoc[Listen to blocks]
|
||||
- link:examples/03_listen_to_balance_change/README.adoc[Listen to balance change]
|
||||
- link:examples/04_generate_account/README.adoc[Generate Accounts]
|
||||
- link:examples/05_read_storage/README.adoc[Read Storage]
|
||||
- link:examples/06_craft_extrinsic/README.adoc[Craft Extrinsic]
|
||||
- link:examples/07_transfer_dots/README.adoc[Transfer DOTs]
|
||||
|
||||
// Making this section ready for the upcoming guides
|
||||
// == Guides
|
||||
|
||||
// - link:guides/create_api.adoc[Create API]
|
||||
|
||||
== Contributing
|
||||
|
||||
- link:CONTRIBUTING.adoc[Contributing guide]
|
||||
@@ -0,0 +1,133 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/api-format) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?path=packages/api-format) [](https://david-dm.org/polkadot-js/api?path=packages/api-format#info=devDependencies)
|
||||
|
||||
@polkadot/api-format
|
||||
====================
|
||||
|
||||
Formatters that are used by the application API interface, taking care of transparently formatting parameters (inputs) and the results (output) for requests made over the client RPC interfaces.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
npm install --save @polkadot/api-format
|
||||
```
|
||||
|
||||
## Index
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [FormatterFunction](#formatterfunction)
|
||||
|
||||
### Functions
|
||||
|
||||
* [echo](#echo)
|
||||
* [format](#format)
|
||||
* [formatInputs](#formatinputs)
|
||||
* [formatOutput](#formatoutput)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="formatterfunction"></a>
|
||||
|
||||
### FormatterFunction
|
||||
|
||||
**Ƭ FormatterFunction**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-format/src/types.d.ts#L7)*
|
||||
|
||||
#### Type declaration
|
||||
▸(value: *`any`*): `any`
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| value | `any` |
|
||||
|
||||
**Returns:** `any`
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="echo"></a>
|
||||
|
||||
### echo
|
||||
|
||||
▸ **echo**(value: *`any`*): `any`
|
||||
|
||||
*Defined in [echo.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-format/src/echo.ts#L10)*
|
||||
|
||||
A function returning any value passed to it
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| value | `any` | The input value |
|
||||
|
||||
**Returns:** `any`
|
||||
The value passed as input
|
||||
|
||||
___
|
||||
<a id="format"></a>
|
||||
|
||||
### format
|
||||
|
||||
▸ **format**(formatters: *`FormattersFunctionMap`*, types: *`Array`<`Param$Types`>*, values: *`Array`<`any`>*): `Array`<`any`>
|
||||
|
||||
*Defined in [format.ts:49](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-format/src/format.ts#L49)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| formatters | `FormattersFunctionMap` |
|
||||
| types | `Array`<`Param$Types`> |
|
||||
| values | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Array`<`any`>
|
||||
|
||||
___
|
||||
<a id="formatinputs"></a>
|
||||
|
||||
### formatInputs
|
||||
|
||||
▸ **formatInputs**(params: *`Params`*, values: *`Array`<`any`>*): `Array`<`any`>
|
||||
|
||||
*Defined in [input.ts:22](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-format/src/input.ts#L22)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| params | `Params` |
|
||||
| values | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Array`<`any`>
|
||||
|
||||
___
|
||||
<a id="formatoutput"></a>
|
||||
|
||||
### formatOutput
|
||||
|
||||
▸ **formatOutput**(type: *`Param$Types`*, value?: *`any`*): `any` | `null`
|
||||
|
||||
*Defined in [output.ts:30](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-format/src/output.ts#L30)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | `Param$Types` |
|
||||
| `Optional` value | `any` |
|
||||
|
||||
**Returns:** `any` | `null`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,485 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/api-provider) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?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);
|
||||
```
|
||||
|
||||
## Index
|
||||
|
||||
### Classes
|
||||
|
||||
* [HttpProvider](classes/httpprovider.md)
|
||||
* [WsProvider](classes/wsprovider.md)
|
||||
|
||||
### Interfaces
|
||||
|
||||
* [ProviderInterface](interfaces/providerinterface.md)
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [HttpState](#httpstate)
|
||||
* [JsonRpcObject](#jsonrpcobject)
|
||||
* [JsonRpcRequest](#jsonrpcrequest)
|
||||
* [JsonRpcResponse](#jsonrpcresponse)
|
||||
* [JsonRpcResponseBase](#jsonrpcresponsebase)
|
||||
* [JsonRpcResponseBase$Error](#jsonrpcresponsebase_error)
|
||||
* [MockState](#mockstate)
|
||||
* [MockState$Requests](#mockstate_requests)
|
||||
* [MockState$Storage](#mockstate_storage)
|
||||
* [MockState$Subscription$Callback](#mockstate_subscription_callback)
|
||||
* [MockState$Subscriptions](#mockstate_subscriptions)
|
||||
* [ProviderInterface$Callback](#providerinterface_callback)
|
||||
* [ProviderInterface$EmitCb](#providerinterface_emitcb)
|
||||
* [ProviderInterface$Emitted](#providerinterface_emitted)
|
||||
* [RpcCoder](#rpccoder)
|
||||
* [RpcCoderState](#rpccoderstate)
|
||||
|
||||
### Functions
|
||||
|
||||
* [decodeResponse](#decoderesponse)
|
||||
* [encodeJson](#encodejson)
|
||||
* [encodeObject](#encodeobject)
|
||||
* [mockProvider](#mockprovider)
|
||||
* [mocks](#mocks)
|
||||
* [on](#on)
|
||||
* [rpcCoder](#rpccoder)
|
||||
* [send](#send)
|
||||
* [state](#state)
|
||||
* [subscribe](#subscribe)
|
||||
* [unsubscribe](#unsubscribe)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="httpstate"></a>
|
||||
|
||||
### HttpState
|
||||
|
||||
**Ƭ HttpState**: *`object`*
|
||||
|
||||
*Defined in [http/types.d.ts:8](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/types.d.ts#L8)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="jsonrpcobject"></a>
|
||||
|
||||
### JsonRpcObject
|
||||
|
||||
**Ƭ JsonRpcObject**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:5](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L5)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="jsonrpcrequest"></a>
|
||||
|
||||
### JsonRpcRequest
|
||||
|
||||
**Ƭ JsonRpcRequest**: * [JsonRpcObject](#jsonrpcobject) & `object`
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L10)*
|
||||
|
||||
___
|
||||
<a id="jsonrpcresponse"></a>
|
||||
|
||||
### JsonRpcResponse
|
||||
|
||||
**Ƭ JsonRpcResponse**: * [JsonRpcObject](#jsonrpcobject) & [JsonRpcResponseBase](#jsonrpcresponsebase)
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:36](https://github.com/chevdor/polkadot-js-api/blob/461228c/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/chevdor/polkadot-js-api/blob/461228c/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/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L15)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="mockstate"></a>
|
||||
|
||||
### MockState
|
||||
|
||||
**Ƭ MockState**: *`object`*
|
||||
|
||||
*Defined in [mock/types.d.ts:27](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/types.d.ts#L27)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="mockstate_requests"></a>
|
||||
|
||||
### MockState$Requests
|
||||
|
||||
**Ƭ MockState$Requests**: *`object`*
|
||||
|
||||
*Defined in [mock/types.d.ts:23](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/types.d.ts#L23)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: `function`
|
||||
|
||||
▸(storage: *[MockState$Storage](#mockstate_storage)*, params: *`Array`<`any`>*): `string`
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| storage | [MockState$Storage](#mockstate_storage) |
|
||||
| params | `Array`<`any`> |
|
||||
|
||||
**Returns:** `string`
|
||||
|
||||
___
|
||||
<a id="mockstate_storage"></a>
|
||||
|
||||
### MockState$Storage
|
||||
|
||||
**Ƭ MockState$Storage**: *`object`*
|
||||
|
||||
*Defined in [mock/types.d.ts:19](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/types.d.ts#L19)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="mockstate_subscription_callback"></a>
|
||||
|
||||
### MockState$Subscription$Callback
|
||||
|
||||
**Ƭ MockState$Subscription$Callback**: *`function`*
|
||||
|
||||
*Defined in [mock/types.d.ts:8](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/types.d.ts#L8)*
|
||||
|
||||
#### Type declaration
|
||||
▸(error: * `Error` | `null`*, value: *`any`*): `void`
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| error | `Error` | `null`|
|
||||
| value | `any` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="mockstate_subscriptions"></a>
|
||||
|
||||
### MockState$Subscriptions
|
||||
|
||||
**Ƭ MockState$Subscriptions**: *`object`*
|
||||
|
||||
*Defined in [mock/types.d.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/types.d.ts#L10)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: `object`
|
||||
|
||||
___
|
||||
<a id="providerinterface_callback"></a>
|
||||
|
||||
### ProviderInterface$Callback
|
||||
|
||||
**Ƭ ProviderInterface$Callback**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:38](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L38)*
|
||||
|
||||
#### Type declaration
|
||||
▸(error: * `Error` | `null`*, result: *`any`*): `void`
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| error | `Error` | `null`|
|
||||
| result | `any` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="providerinterface_emitcb"></a>
|
||||
|
||||
### ProviderInterface$EmitCb
|
||||
|
||||
**Ƭ ProviderInterface$EmitCb**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:42](https://github.com/chevdor/polkadot-js-api/blob/461228c/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" | "disconnected"
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:40](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L40)*
|
||||
|
||||
___
|
||||
<a id="rpccoder"></a>
|
||||
|
||||
### RpcCoder
|
||||
|
||||
**Ƭ RpcCoder**: *`object`*
|
||||
|
||||
*Defined in [coder/json/types.d.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/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/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/coder/json/types.d.ts#L14)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="decoderesponse"></a>
|
||||
|
||||
### decodeResponse
|
||||
|
||||
▸ **decodeResponse**(self: *[RpcCoderState](#rpccoderstate)*, response: *[JsonRpcResponse](#jsonrpcresponse)*): `any`
|
||||
|
||||
*Defined in [coder/json/decodeResponse.ts:22](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/coder/json/decodeResponse.ts#L22)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| self | [RpcCoderState](#rpccoderstate) |
|
||||
| response | [JsonRpcResponse](#jsonrpcresponse) |
|
||||
|
||||
**Returns:** `any`
|
||||
|
||||
___
|
||||
<a id="encodejson"></a>
|
||||
|
||||
### encodeJson
|
||||
|
||||
▸ **encodeJson**(self: *[RpcCoderState](#rpccoderstate)*, method: *`string`*, params: *`Array`<`any`>*): `string`
|
||||
|
||||
*Defined in [coder/json/encodeJson.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/coder/json/encodeJson.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| self | [RpcCoderState](#rpccoderstate) |
|
||||
| method | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
|
||||
**Returns:** `string`
|
||||
|
||||
___
|
||||
<a id="encodeobject"></a>
|
||||
|
||||
### encodeObject
|
||||
|
||||
▸ **encodeObject**(self: *[RpcCoderState](#rpccoderstate)*, method: *`string`*, params: *`Array`<`any`>*): [JsonRpcRequest](#jsonrpcrequest)
|
||||
|
||||
*Defined in [coder/json/encodeObject.ts:8](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/coder/json/encodeObject.ts#L8)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| self | [RpcCoderState](#rpccoderstate) |
|
||||
| method | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
|
||||
**Returns:** [JsonRpcRequest](#jsonrpcrequest)
|
||||
|
||||
___
|
||||
<a id="mockprovider"></a>
|
||||
|
||||
### mockProvider
|
||||
|
||||
▸ **mockProvider**(): [ProviderInterface](interfaces/providerinterface.md)
|
||||
|
||||
*Defined in [mock/index.ts:18](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/index.ts#L18)*
|
||||
|
||||
A moock provider mainly used for testing.
|
||||
|
||||
**Returns:** [ProviderInterface](interfaces/providerinterface.md)
|
||||
The mock provider
|
||||
|
||||
___
|
||||
<a id="mocks"></a>
|
||||
|
||||
### mocks
|
||||
|
||||
▸ **mocks**(__namedParameters: *`object`*): `void`
|
||||
|
||||
*Defined in [mock/mocks.ts:68](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/mocks.ts#L68)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| __namedParameters | `object` |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="on"></a>
|
||||
|
||||
### on
|
||||
|
||||
▸ **on**(self: *[MockState](#mockstate)*, type: *[ProviderInterface$Emitted](#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](#providerinterface_emitcb)*): `void`
|
||||
|
||||
*Defined in [mock/on.ts:8](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/on.ts#L8)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| self | [MockState](#mockstate) |
|
||||
| type | [ProviderInterface$Emitted](#providerinterface_emitted) |
|
||||
| sub | [ProviderInterface$EmitCb](#providerinterface_emitcb) |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="rpccoder"></a>
|
||||
|
||||
### rpcCoder
|
||||
|
||||
▸ **rpcCoder**(): [RpcCoder](#rpccoder)
|
||||
|
||||
*Defined in [coder/json/index.ts:12](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/coder/json/index.ts#L12)*
|
||||
|
||||
**Returns:** [RpcCoder](#rpccoder)
|
||||
|
||||
___
|
||||
<a id="send"></a>
|
||||
|
||||
### send
|
||||
|
||||
▸ **send**(__namedParameters: *`object`*, method: *`string`*, params: *`Array`<`any`>*): `Promise`<`any`>
|
||||
|
||||
*Defined in [mock/send.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/send.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| __namedParameters | `object` |
|
||||
| method | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Promise`<`any`>
|
||||
|
||||
___
|
||||
<a id="state"></a>
|
||||
|
||||
### state
|
||||
|
||||
▸ **state**(): [MockState](#mockstate)
|
||||
|
||||
*Defined in [mock/state.ts:38](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/state.ts#L38)*
|
||||
|
||||
**Returns:** [MockState](#mockstate)
|
||||
|
||||
___
|
||||
<a id="subscribe"></a>
|
||||
|
||||
### subscribe
|
||||
|
||||
▸ **subscribe**(self: *[MockState](#mockstate)*, type: *`string`*, method: *`string`*, params: *`Array`<`any`>*): `Promise`<`number`>
|
||||
|
||||
*Defined in [mock/subscribe.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/subscribe.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| self | [MockState](#mockstate) |
|
||||
| type | `string` |
|
||||
| method | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Promise`<`number`>
|
||||
|
||||
___
|
||||
<a id="unsubscribe"></a>
|
||||
|
||||
### unsubscribe
|
||||
|
||||
▸ **unsubscribe**(self: *[MockState](#mockstate)*, type: *`string`*, name: *`string`*, id: *`number`*): `Promise`<`boolean`>
|
||||
|
||||
*Defined in [mock/unsubscribe.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/mock/unsubscribe.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| self | [MockState](#mockstate) |
|
||||
| type | `string` |
|
||||
| name | `string` |
|
||||
| id | `number` |
|
||||
|
||||
**Returns:** `Promise`<`boolean`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
[Polkadot JS API](../README.md) > [HttpProvider](../classes/httpprovider.md)
|
||||
|
||||
# Class: HttpProvider
|
||||
|
||||
The HTTP Provider allows sending requests using HTTP. 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](wsprovider.md).
|
||||
*__example__*: ```javascript
|
||||
import createApi from '@polkadot/api';
|
||||
import WsProvider from '@polkadot/api-provider/ws';
|
||||
const provider = new WsProvider('http://127.0.0.1:9933');
|
||||
const api = createApi(provider);
|
||||
```
|
||||
|
||||
*__see__*: [WsProvider](wsprovider.md)
|
||||
|
||||
## Hierarchy
|
||||
|
||||
**HttpProvider**
|
||||
|
||||
## Implements
|
||||
|
||||
* [ProviderInterface](../interfaces/providerinterface.md)
|
||||
|
||||
## Index
|
||||
|
||||
### Constructors
|
||||
|
||||
* [constructor](httpprovider.md#constructor)
|
||||
|
||||
### Methods
|
||||
|
||||
* [isConnected](httpprovider.md#isconnected)
|
||||
* [on](httpprovider.md#on)
|
||||
* [send](httpprovider.md#send)
|
||||
* [subscribe](httpprovider.md#subscribe)
|
||||
* [unsubscribe](httpprovider.md#unsubscribe)
|
||||
|
||||
---
|
||||
|
||||
## Constructors
|
||||
|
||||
<a id="constructor"></a>
|
||||
|
||||
### constructor
|
||||
|
||||
⊕ **new HttpProvider**(endpoint: *`string`*): [HttpProvider](httpprovider.md)
|
||||
|
||||
*Defined in [http/index.ts:35](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/index.ts#L35)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| endpoint | `string` |
|
||||
|
||||
**Returns:** [HttpProvider](httpprovider.md)
|
||||
|
||||
___
|
||||
|
||||
## Methods
|
||||
|
||||
<a id="isconnected"></a>
|
||||
|
||||
### isConnected
|
||||
|
||||
▸ **isConnected**(): `boolean`
|
||||
|
||||
*Implementation of [ProviderInterface](../interfaces/providerinterface.md).[isConnected](../interfaces/providerinterface.md#isconnected)*
|
||||
|
||||
*Defined in [http/index.ts:49](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/index.ts#L49)*
|
||||
|
||||
Whether the node is connected or not.
|
||||
|
||||
**Returns:** `boolean`
|
||||
true if connected
|
||||
|
||||
___
|
||||
<a id="on"></a>
|
||||
|
||||
### on
|
||||
|
||||
▸ **on**(type: *[ProviderInterface$Emitted](../#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](../#providerinterface_emitcb)*): `void`
|
||||
|
||||
*Implementation of [ProviderInterface](../interfaces/providerinterface.md).[on](../interfaces/providerinterface.md#on)*
|
||||
|
||||
*Defined in [http/index.ts:56](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/index.ts#L56)*
|
||||
|
||||
Events are not supported with the HttpProvider, see [WsProvider](wsprovider.md).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | [ProviderInterface$Emitted](../#providerinterface_emitted) |
|
||||
| sub | [ProviderInterface$EmitCb](../#providerinterface_emitcb) |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
___
|
||||
<a id="send"></a>
|
||||
|
||||
### send
|
||||
|
||||
▸ **send**(method: *`string`*, params: *`Array`<`any`>*): `Promise`<`any`>
|
||||
|
||||
*Implementation of [ProviderInterface](../interfaces/providerinterface.md).[send](../interfaces/providerinterface.md#send)*
|
||||
|
||||
*Defined in [http/index.ts:60](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/index.ts#L60)*
|
||||
|
||||
**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](../#providerinterface_callback)*): `Promise`<`number`>
|
||||
|
||||
*Implementation of [ProviderInterface](../interfaces/providerinterface.md).[subscribe](../interfaces/providerinterface.md#subscribe)*
|
||||
|
||||
*Defined in [http/index.ts:82](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/index.ts#L82)*
|
||||
|
||||
Subscriptions are not supported with the HttpProvider, see [WsProvider](wsprovider.md).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| types | `string` |
|
||||
| method | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
| cb | [ProviderInterface$Callback](../#providerinterface_callback) |
|
||||
|
||||
**Returns:** `Promise`<`number`>
|
||||
|
||||
___
|
||||
<a id="unsubscribe"></a>
|
||||
|
||||
### unsubscribe
|
||||
|
||||
▸ **unsubscribe**(type: *`string`*, method: *`string`*, id: *`number`*): `Promise`<`boolean`>
|
||||
|
||||
*Implementation of [ProviderInterface](../interfaces/providerinterface.md).[unsubscribe](../interfaces/providerinterface.md#unsubscribe)*
|
||||
|
||||
*Defined in [http/index.ts:91](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/http/index.ts#L91)*
|
||||
|
||||
Subscriptions are not supported with the HttpProvider, see [WsProvider](wsprovider.md).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | `string` |
|
||||
| method | `string` |
|
||||
| id | `number` |
|
||||
|
||||
**Returns:** `Promise`<`boolean`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,419 @@
|
||||
[Polkadot JS API](../README.md) > [WsProvider](../classes/wsprovider.md)
|
||||
|
||||
# Class: WsProvider
|
||||
|
||||
The WebSocket Provider allows sending requests using WebSocket. Unlike the [HttpProvider](httpprovider.md), it does support subscriptions and allows listening to events such as new blocks or balance changes.
|
||||
|
||||
```javascript
|
||||
import createApi from '@polkadot/api';
|
||||
import WsProvider from '@polkadot/api-provider/ws';
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
const api = createApi(provider);
|
||||
```
|
||||
*__example__*: ```javascript
|
||||
import createApi from '@polkadot/api';
|
||||
import WsProvider from '@polkadot/api-provider/ws';
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
const api = createApi(provider);
|
||||
```
|
||||
|
||||
*__see__*: [HttpProvider](httpprovider.md)
|
||||
|
||||
## Type parameters
|
||||
#### EventTypes : `string` | `symbol`
|
||||
|
||||
## Hierarchy
|
||||
|
||||
`EventEmitter`
|
||||
|
||||
**↳ WsProvider**
|
||||
|
||||
## Implements
|
||||
|
||||
* `WSProviderInterface`
|
||||
|
||||
## Index
|
||||
|
||||
### Modules
|
||||
|
||||
* [EventEmitter](../modules/wsprovider.eventemitter.md)
|
||||
|
||||
### Constructors
|
||||
|
||||
* [constructor](wsprovider.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
* [prefixed](wsprovider.md#prefixed)
|
||||
|
||||
### Methods
|
||||
|
||||
* [addListener](wsprovider.md#addlistener)
|
||||
* [connect](wsprovider.md#connect)
|
||||
* [emit](wsprovider.md#emit)
|
||||
* [eventNames](wsprovider.md#eventnames)
|
||||
* [isConnected](wsprovider.md#isconnected)
|
||||
* [listenerCount](wsprovider.md#listenercount)
|
||||
* [listeners](wsprovider.md#listeners)
|
||||
* [off](wsprovider.md#off)
|
||||
* [on](wsprovider.md#on)
|
||||
* [once](wsprovider.md#once)
|
||||
* [removeAllListeners](wsprovider.md#removealllisteners)
|
||||
* [removeListener](wsprovider.md#removelistener)
|
||||
* [send](wsprovider.md#send)
|
||||
* [subscribe](wsprovider.md#subscribe)
|
||||
* [unsubscribe](wsprovider.md#unsubscribe)
|
||||
|
||||
---
|
||||
|
||||
## Constructors
|
||||
|
||||
<a id="constructor"></a>
|
||||
|
||||
### constructor
|
||||
|
||||
⊕ **new WsProvider**(endpoint: *`string`*, autoConnect?: *`boolean`*): [WsProvider](wsprovider.md)
|
||||
|
||||
*Defined in [ws/index.ts:69](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L69)*
|
||||
|
||||
**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](wsprovider.md)
|
||||
|
||||
___
|
||||
|
||||
## Properties
|
||||
|
||||
<a id="prefixed"></a>
|
||||
|
||||
### `<Static>` prefixed
|
||||
|
||||
**● prefixed**: * `string` | `boolean`
|
||||
*
|
||||
|
||||
*Inherited from EventEmitter.prefixed*
|
||||
|
||||
*Defined in /Users/will/projects/paritytech/polka/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 /Users/will/projects/paritytech/polka/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:99](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L99)*
|
||||
|
||||
The [WsProvider](wsprovider.md) connects automatically by default. 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 /Users/will/projects/paritytech/polka/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 /Users/will/projects/paritytech/polka/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:116](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L116)*
|
||||
|
||||
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 /Users/will/projects/paritytech/polka/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 /Users/will/projects/paritytech/polka/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/wsprovider.eventemitter.listenerfn.md)*, context?: *`any`*, once?: * `undefined` | `false` | `true`*): `this`
|
||||
|
||||
*Inherited from EventEmitter.off*
|
||||
|
||||
*Defined in /Users/will/projects/paritytech/polka/polkadot-js-api/node_modules/eventemitter3/index.d.ts:44*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| event | `EventTypes` |
|
||||
| `Optional` fn | [ListenerFn](../interfaces/wsprovider.eventemitter.listenerfn.md) |
|
||||
| `Optional` context | `any` |
|
||||
| `Optional` once | `undefined` | `false` | `true`|
|
||||
|
||||
**Returns:** `this`
|
||||
|
||||
___
|
||||
<a id="on"></a>
|
||||
|
||||
### on
|
||||
|
||||
▸ **on**(type: *[ProviderInterface$Emitted](../#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](../#providerinterface_emitcb)*): `this`
|
||||
|
||||
*Overrides EventEmitter.on*
|
||||
|
||||
*Defined in [ws/index.ts:126](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L126)*
|
||||
|
||||
Listens on events after having subscribed using the [subscribe](wsprovider.md#subscribe) function.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| type | [ProviderInterface$Emitted](../#providerinterface_emitted) | Event |
|
||||
| sub | [ProviderInterface$EmitCb](../#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 /Users/will/projects/paritytech/polka/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 /Users/will/projects/paritytech/polka/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/wsprovider.eventemitter.listenerfn.md)*, context?: *`any`*, once?: * `undefined` | `false` | `true`*): `this`
|
||||
|
||||
*Inherited from EventEmitter.removeListener*
|
||||
|
||||
*Defined in /Users/will/projects/paritytech/polka/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/wsprovider.eventemitter.listenerfn.md) |
|
||||
| `Optional` context | `any` |
|
||||
| `Optional` once | `undefined` | `false` | `true`|
|
||||
|
||||
**Returns:** `this`
|
||||
|
||||
___
|
||||
<a id="send"></a>
|
||||
|
||||
### send
|
||||
|
||||
▸ **send**(method: *`string`*, params: *`Array`<`any`>*, subscription?: *`SubscriptionHandler`*): `Promise`<`any`>
|
||||
|
||||
*Defined in [ws/index.ts:130](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L130)*
|
||||
|
||||
**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](../#providerinterface_callback)*): `Promise`<`number`>
|
||||
|
||||
*Defined in [ws/index.ts:182](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L182)*
|
||||
|
||||
Allows subscribing to a specific event.
|
||||
*__example__*: ```javascript
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = createApi(provider)
|
||||
api.state.storage([[storage.staking.public.freeBalanceOf, <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](../#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:191](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/ws/index.ts#L191)*
|
||||
|
||||
Allows unsubscribing to subscriptions made with [subscribe](wsprovider.md#subscribe).
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | `string` |
|
||||
| method | `string` |
|
||||
| id | `number` |
|
||||
|
||||
**Returns:** `Promise`<`boolean`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
[Polkadot JS API](../README.md) > [ProviderInterface](../interfaces/providerinterface.md)
|
||||
|
||||
# Interface: ProviderInterface
|
||||
|
||||
## Hierarchy
|
||||
|
||||
**ProviderInterface**
|
||||
|
||||
## Implemented by
|
||||
|
||||
* [HttpProvider](../classes/httpprovider.md)
|
||||
|
||||
## Index
|
||||
|
||||
### Methods
|
||||
|
||||
* [isConnected](providerinterface.md#isconnected)
|
||||
* [on](providerinterface.md#on)
|
||||
* [send](providerinterface.md#send)
|
||||
* [subscribe](providerinterface.md#subscribe)
|
||||
* [unsubscribe](providerinterface.md#unsubscribe)
|
||||
|
||||
---
|
||||
|
||||
## Methods
|
||||
|
||||
<a id="isconnected"></a>
|
||||
|
||||
### isConnected
|
||||
|
||||
▸ **isConnected**(): `boolean`
|
||||
|
||||
*Defined in [types.d.ts:45](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L45)*
|
||||
|
||||
**Returns:** `boolean`
|
||||
|
||||
___
|
||||
<a id="on"></a>
|
||||
|
||||
### on
|
||||
|
||||
▸ **on**(type: *[ProviderInterface$Emitted](../#providerinterface_emitted)*, sub: *[ProviderInterface$EmitCb](../#providerinterface_emitcb)*): `void`
|
||||
|
||||
*Defined in [types.d.ts:46](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L46)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | [ProviderInterface$Emitted](../#providerinterface_emitted) |
|
||||
| sub | [ProviderInterface$EmitCb](../#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/chevdor/polkadot-js-api/blob/461228c/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](../#providerinterface_callback)*): `Promise`<`number`>
|
||||
|
||||
*Defined in [types.d.ts:48](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L48)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | `string` |
|
||||
| method | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
| cb | [ProviderInterface$Callback](../#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/chevdor/polkadot-js-api/blob/461228c/packages/api-provider/src/types.d.ts#L49)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | `string` |
|
||||
| method | `string` |
|
||||
| id | `number` |
|
||||
|
||||
**Returns:** `Promise`<`boolean`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
[Polkadot JS API](../README.md) > [WsProvider](../classes/wsprovider.md) > [EventEmitter](../modules/wsprovider.eventemitter.md) > [EventEmitterStatic](../interfaces/wsprovider.eventemitter.eventemitterstatic.md)
|
||||
|
||||
# Interface: EventEmitterStatic
|
||||
|
||||
## Hierarchy
|
||||
|
||||
**EventEmitterStatic**
|
||||
|
||||
## Index
|
||||
|
||||
### Constructors
|
||||
|
||||
* [constructor](wsprovider.eventemitter.eventemitterstatic.md#constructor)
|
||||
|
||||
---
|
||||
|
||||
## Constructors
|
||||
|
||||
<a id="constructor"></a>
|
||||
|
||||
### constructor
|
||||
|
||||
⊕ **new EventEmitterStatic**<`EventTypes`>(): `EventEmitter`<`EventTypes`>
|
||||
|
||||
*Defined in /Users/will/projects/paritytech/polka/polkadot-js-api/node_modules/eventemitter3/index.d.ts:57*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
#### EventTypes : `string` | `symbol`
|
||||
|
||||
**Returns:** `EventEmitter`<`EventTypes`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
[Polkadot JS API](../README.md) > [WsProvider](../classes/wsprovider.md) > [EventEmitter](../modules/wsprovider.eventemitter.md) > [ListenerFn](../interfaces/wsprovider.eventemitter.listenerfn.md)
|
||||
|
||||
# Interface: ListenerFn
|
||||
|
||||
## Hierarchy
|
||||
|
||||
**ListenerFn**
|
||||
|
||||
## Callable
|
||||
▸ **__call**(...args: *`Array`<`any`>*): `void`
|
||||
|
||||
*Defined in /Users/will/projects/paritytech/polka/polkadot-js-api/node_modules/eventemitter3/index.d.ts:53*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Rest` args | `Array`<`any`> |
|
||||
|
||||
**Returns:** `void`
|
||||
|
||||
## Index
|
||||
|
||||
---
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
[Polkadot JS API](../README.md) > [WsProvider](../classes/wsprovider.md) > [EventEmitter](../modules/wsprovider.eventemitter.md)
|
||||
|
||||
# Module: EventEmitter
|
||||
|
||||
## Index
|
||||
|
||||
### Interfaces
|
||||
|
||||
* [EventEmitterStatic](../interfaces/wsprovider.eventemitter.eventemitterstatic.md)
|
||||
* [ListenerFn](../interfaces/wsprovider.eventemitter.listenerfn.md)
|
||||
|
||||
### Variables
|
||||
|
||||
* [EventEmitter](wsprovider.eventemitter.md#eventemitter)
|
||||
|
||||
---
|
||||
|
||||
## Variables
|
||||
|
||||
<a id="eventemitter"></a>
|
||||
|
||||
### `<Const>` EventEmitter
|
||||
|
||||
**● EventEmitter**: *`EventEmitterStatic`*
|
||||
|
||||
*Defined in /Users/will/projects/paritytech/polka/polkadot-js-api/node_modules/eventemitter3/index.d.ts:61*
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/api-rx) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?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).
|
||||
|
||||
## Index
|
||||
|
||||
### Classes
|
||||
|
||||
* [RxApi](classes/rxapi.md)
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [RxApiInterface](#rxapiinterface)
|
||||
* [RxApiInterface$Method](#rxapiinterface_method)
|
||||
* [RxApiInterface$Section](#rxapiinterface_section)
|
||||
|
||||
### Functions
|
||||
|
||||
* [cached](#cached)
|
||||
* [createInterface](#createinterface)
|
||||
* [observable](#observable)
|
||||
* [subscription](#subscription)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="rxapiinterface"></a>
|
||||
|
||||
### RxApiInterface
|
||||
|
||||
**Ƭ RxApiInterface**: * `RxApiInterface$Keys` & `object`
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:19](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/types.d.ts#L19)*
|
||||
|
||||
___
|
||||
<a id="rxapiinterface_method"></a>
|
||||
|
||||
### RxApiInterface$Method
|
||||
|
||||
**Ƭ RxApiInterface$Method**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/types.d.ts#L9)*
|
||||
|
||||
#### Type declaration
|
||||
▸(...params: *`Array`<`any`>*): `Observable`<`any`> | `BehaviorSubject`<`any`>
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Rest` params | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Observable`<`any`> | `BehaviorSubject`<`any`>
|
||||
|
||||
___
|
||||
<a id="rxapiinterface_section"></a>
|
||||
|
||||
### RxApiInterface$Section
|
||||
|
||||
**Ƭ RxApiInterface$Section**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/types.d.ts#L11)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: [RxApiInterface$Method](#rxapiinterface_method)
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="cached"></a>
|
||||
|
||||
### cached
|
||||
|
||||
▸ **cached**(subName: *`string`*, name: *`string`*, section: *`ApiInterface$Section`*): `function`
|
||||
|
||||
*Defined in [observable/cached.ts:19](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/observable/cached.ts#L19)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| subName | `string` |
|
||||
| name | `string` |
|
||||
| section | `ApiInterface$Section` |
|
||||
|
||||
**Returns:** `function`
|
||||
|
||||
___
|
||||
<a id="createinterface"></a>
|
||||
|
||||
### createInterface
|
||||
|
||||
▸ **createInterface**(api: *`ApiInterface`*, sectionName: *`Interface$Sections`*): [RxApiInterface$Section](#rxapiinterface_section)
|
||||
|
||||
*Defined in [interface.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/interface.ts#L11)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| api | `ApiInterface` |
|
||||
| sectionName | `Interface$Sections` |
|
||||
|
||||
**Returns:** [RxApiInterface$Section](#rxapiinterface_section)
|
||||
|
||||
___
|
||||
<a id="observable"></a>
|
||||
|
||||
### observable
|
||||
|
||||
▸ **observable**(subName: *`string`*, name: *`string`*, section: *`ApiInterface$Section`*): `function`
|
||||
|
||||
*Defined in [observable/index.ts:14](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/observable/index.ts#L14)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| subName | `string` |
|
||||
| name | `string` |
|
||||
| section | `ApiInterface$Section` |
|
||||
|
||||
**Returns:** `function`
|
||||
|
||||
___
|
||||
<a id="subscription"></a>
|
||||
|
||||
### subscription
|
||||
|
||||
▸ **subscription**(name: *`string`*, params: *`Array`<`any`>*, section: *`ApiInterface$Section`*, unsubCallback?: * `undefined` | `function`*): `BehaviorSubject`<`any`>
|
||||
|
||||
*Defined in [observable/subject.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/observable/subject.ts#L10)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| name | `string` |
|
||||
| params | `Array`<`any`> |
|
||||
| section | `ApiInterface$Section` |
|
||||
| `Optional` unsubCallback | `undefined` | `function`|
|
||||
|
||||
**Returns:** `BehaviorSubject`<`any`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
[Polkadot JS API](../README.md) > [RxApi](../classes/rxapi.md)
|
||||
|
||||
# Class: RxApi
|
||||
|
||||
An RxJs wrapper around the \[\[api\]\].
|
||||
*__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` & `object`
|
||||
|
||||
## Index
|
||||
|
||||
### Constructors
|
||||
|
||||
* [constructor](rxapi.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
* [author](rxapi.md#author)
|
||||
* [chain](rxapi.md#chain)
|
||||
* [state](rxapi.md#state)
|
||||
* [system](rxapi.md#system)
|
||||
|
||||
### Methods
|
||||
|
||||
* [isConnected](rxapi.md#isconnected)
|
||||
|
||||
---
|
||||
|
||||
## Constructors
|
||||
|
||||
<a id="constructor"></a>
|
||||
|
||||
### constructor
|
||||
|
||||
⊕ **new RxApi**(provider?: *`ProviderInterface`*): [RxApi](rxapi.md)
|
||||
|
||||
*Defined in [index.ts:33](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/index.ts#L33)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value | Description |
|
||||
| ------ | ------ | ------ | ------ |
|
||||
| `Default value` provider | `ProviderInterface` | new Ws(defaults.WS_URL) | An API provider using HTTP or WebSocket |
|
||||
|
||||
**Returns:** [RxApi](rxapi.md)
|
||||
|
||||
___
|
||||
|
||||
## Properties
|
||||
|
||||
<a id="author"></a>
|
||||
|
||||
### author
|
||||
|
||||
**● author**: *[RxApiInterface$Section](../#rxapiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:30](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/index.ts#L30)*
|
||||
|
||||
___
|
||||
<a id="chain"></a>
|
||||
|
||||
### chain
|
||||
|
||||
**● chain**: *[RxApiInterface$Section](../#rxapiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:31](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/index.ts#L31)*
|
||||
|
||||
___
|
||||
<a id="state"></a>
|
||||
|
||||
### state
|
||||
|
||||
**● state**: *[RxApiInterface$Section](../#rxapiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:32](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/index.ts#L32)*
|
||||
|
||||
___
|
||||
<a id="system"></a>
|
||||
|
||||
### system
|
||||
|
||||
**● system**: *[RxApiInterface$Section](../#rxapiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:33](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/index.ts#L33)*
|
||||
|
||||
___
|
||||
|
||||
## Methods
|
||||
|
||||
<a id="isconnected"></a>
|
||||
|
||||
### isConnected
|
||||
|
||||
▸ **isConnected**(): `BehaviorSubject`<`boolean`>
|
||||
|
||||
*Defined in [index.ts:51](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api-rx/src/index.ts#L51)*
|
||||
|
||||
**Returns:** `BehaviorSubject`<`boolean`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/api) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?path=packages/api) [](https://david-dm.org/polkadot-js/api?path=packages/api#info=devDependencies)
|
||||
|
||||
@polkadot/api
|
||||
=============
|
||||
|
||||
Warning - currently this does not actually do all that much, it is an attempt to put into code some thoughts about how to maintain the endpoints. This library provides a clean wrapper around all the methods exposed by a Polkadot network client.
|
||||
|
||||
Methods are auto-generated for the [JsonRPC interface definitions](https://github.com/polkadot-js/api/packages/type-jsonrpc), containing a full list of all sections and the methods contained within.
|
||||
|
||||
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);
|
||||
});
|
||||
```
|
||||
|
||||
## Index
|
||||
|
||||
### Classes
|
||||
|
||||
* [Api](classes/api.md)
|
||||
|
||||
### Interfaces
|
||||
|
||||
* [ApiInterface$Section$Method](interfaces/apiinterface_section_method.md)
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [ApiInterface](#apiinterface)
|
||||
* [ApiInterface$Section](#apiinterface_section)
|
||||
|
||||
### Functions
|
||||
|
||||
* [createInterface](#createinterface)
|
||||
* [createMethodSend](#createmethodsend)
|
||||
* [createParams](#createparams)
|
||||
* [formatResult](#formatresult)
|
||||
* [methodSubscribe](#methodsubscribe)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="apiinterface"></a>
|
||||
|
||||
### ApiInterface
|
||||
|
||||
**Ƭ ApiInterface**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:18](https://github.com/chevdor/polkadot-js-api/blob/461228c/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/chevdor/polkadot-js-api/blob/461228c/packages/api/src/types.d.ts#L14)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: [ApiInterface$Section$Method](interfaces/apiinterface_section_method.md)
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="createinterface"></a>
|
||||
|
||||
### createInterface
|
||||
|
||||
▸ **createInterface**(provider: *`ProviderInterface`*, section: *`Interface$Sections`*): [ApiInterface$Section](#apiinterface_section)
|
||||
|
||||
*Defined in [create/interface.ts:16](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/create/interface.ts#L16)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| provider | `ProviderInterface` |
|
||||
| section | `Interface$Sections` |
|
||||
|
||||
**Returns:** [ApiInterface$Section](#apiinterface_section)
|
||||
|
||||
___
|
||||
<a id="createmethodsend"></a>
|
||||
|
||||
### createMethodSend
|
||||
|
||||
▸ **createMethodSend**(provider: *`ProviderInterface`*, rpcName: *`string`*, method: *`SectionItem`<`Interfaces`>*): [ApiInterface$Section$Method](interfaces/apiinterface_section_method.md)
|
||||
|
||||
*Defined in [create/methodSend.ts:16](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/create/methodSend.ts#L16)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| provider | `ProviderInterface` |
|
||||
| rpcName | `string` |
|
||||
| method | `SectionItem`<`Interfaces`> |
|
||||
|
||||
**Returns:** [ApiInterface$Section$Method](interfaces/apiinterface_section_method.md)
|
||||
|
||||
___
|
||||
<a id="createparams"></a>
|
||||
|
||||
### createParams
|
||||
|
||||
▸ **createParams**(params: *`Params`*, values: *`Array`<`any`>*): `Array`<`any`>
|
||||
|
||||
*Defined in [create/params.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/create/params.ts#L10)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| params | `Params` |
|
||||
| values | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Array`<`any`>
|
||||
|
||||
___
|
||||
<a id="formatresult"></a>
|
||||
|
||||
### formatResult
|
||||
|
||||
▸ **formatResult**(method: *`SectionItem`<`Interfaces`>*, params: *`Array`<`any`>*, inputs: *`Array`<`any`>*, result?: *`any`*): `any`
|
||||
|
||||
*Defined in [create/formatResult.ts:16](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/create/formatResult.ts#L16)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| method | `SectionItem`<`Interfaces`> |
|
||||
| params | `Array`<`any`> |
|
||||
| inputs | `Array`<`any`> |
|
||||
| `Optional` result | `any` |
|
||||
|
||||
**Returns:** `any`
|
||||
|
||||
___
|
||||
<a id="methodsubscribe"></a>
|
||||
|
||||
### methodSubscribe
|
||||
|
||||
▸ **methodSubscribe**(provider: *`ProviderInterface`*, rpcName: *`string`*, method: *`SectionItem`<`Interfaces`>*): [ApiInterface$Section$Method](interfaces/apiinterface_section_method.md)
|
||||
|
||||
*Defined in [create/methodSubscribe.ts:18](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/create/methodSubscribe.ts#L18)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| provider | `ProviderInterface` |
|
||||
| rpcName | `string` |
|
||||
| method | `SectionItem`<`Interfaces`> |
|
||||
|
||||
**Returns:** [ApiInterface$Section$Method](interfaces/apiinterface_section_method.md)
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
[Polkadot JS API](../README.md) > [Api](../classes/api.md)
|
||||
|
||||
# Class: Api
|
||||
|
||||
*__example__*: ```javascript
|
||||
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);
|
||||
```
|
||||
|
||||
## Hierarchy
|
||||
|
||||
**Api**
|
||||
|
||||
## Implements
|
||||
|
||||
* `object`
|
||||
|
||||
## Index
|
||||
|
||||
### Constructors
|
||||
|
||||
* [constructor](api.md#constructor)
|
||||
|
||||
### Properties
|
||||
|
||||
* [author](api.md#author)
|
||||
* [chain](api.md#chain)
|
||||
* [state](api.md#state)
|
||||
* [system](api.md#system)
|
||||
|
||||
---
|
||||
|
||||
## Constructors
|
||||
|
||||
<a id="constructor"></a>
|
||||
|
||||
### constructor
|
||||
|
||||
⊕ **new Api**(provider: *`ProviderInterface`*): [Api](api.md)
|
||||
|
||||
*Defined in [index.ts:26](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/index.ts#L26)*
|
||||
|
||||
*__constructor__*: Default constructor for the Api Object
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Description |
|
||||
| ------ | ------ | ------ |
|
||||
| provider | `ProviderInterface` | An API provider using HTTP or WebSocket |
|
||||
|
||||
**Returns:** [Api](api.md)
|
||||
|
||||
___
|
||||
|
||||
## Properties
|
||||
|
||||
<a id="author"></a>
|
||||
|
||||
### author
|
||||
|
||||
**● author**: *[ApiInterface$Section](../#apiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:23](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/index.ts#L23)*
|
||||
|
||||
___
|
||||
<a id="chain"></a>
|
||||
|
||||
### chain
|
||||
|
||||
**● chain**: *[ApiInterface$Section](../#apiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:24](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/index.ts#L24)*
|
||||
|
||||
___
|
||||
<a id="state"></a>
|
||||
|
||||
### state
|
||||
|
||||
**● state**: *[ApiInterface$Section](../#apiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:25](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/index.ts#L25)*
|
||||
|
||||
___
|
||||
<a id="system"></a>
|
||||
|
||||
### system
|
||||
|
||||
**● system**: *[ApiInterface$Section](../#apiinterface_section)*
|
||||
|
||||
*Defined in [index.ts:26](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/index.ts#L26)*
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
[Polkadot JS API](../README.md) > [ApiInterface$Section$Method](../interfaces/apiinterface_section_method.md)
|
||||
|
||||
# Interface: ApiInterface$Section$Method
|
||||
|
||||
## Hierarchy
|
||||
|
||||
**ApiInterface$Section$Method**
|
||||
|
||||
## Callable
|
||||
▸ **__call**(...params: *`Array`<`any`>*): `Promise`<`any`>
|
||||
|
||||
*Defined in [types.d.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/types.d.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Rest` params | `Array`<`any`> |
|
||||
|
||||
**Returns:** `Promise`<`any`>
|
||||
|
||||
## Index
|
||||
|
||||
### Properties
|
||||
|
||||
* [subscription](apiinterface_section_method.md#subscription)
|
||||
* [unsubscribe](apiinterface_section_method.md#unsubscribe)
|
||||
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
<a id="subscription"></a>
|
||||
|
||||
### subscription
|
||||
|
||||
**● subscription**: *`string`*
|
||||
|
||||
*Defined in [types.d.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/types.d.ts#L10)*
|
||||
|
||||
___
|
||||
<a id="unsubscribe"></a>
|
||||
|
||||
### unsubscribe
|
||||
|
||||
**● unsubscribe**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/api/src/types.d.ts#L11)*
|
||||
|
||||
#### Type declaration
|
||||
▸(id: *`number`*): `Promise`<`any`>
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| id | `number` |
|
||||
|
||||
**Returns:** `Promise`<`any`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
yarn.lock
|
||||
@@ -0,0 +1,8 @@
|
||||
= Simple Connect
|
||||
|
||||
The following example shows how to instantiate a Polkadot API object and use it to connect to a node.
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
const Api = require('@polkadot/api').default
|
||||
const WsProvider = require('@polkadot/api-provider/ws').default
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = new Api(provider)
|
||||
|
||||
async function getChain () {
|
||||
return api.system.chain()
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const chain = await getChain()
|
||||
console.log('You are connected to chain:', chain)
|
||||
}
|
||||
|
||||
main().finally(_ => process.exit())
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "01_simple_connect",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to connect using a WebSocket",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"@polkadot/api-provider": "^0.29.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
= Listen to new blocks
|
||||
|
||||
This example shows how to subscribe to new blocks.
|
||||
|
||||
It displays the block number every time a new block is seen by the node you are connected to.
|
||||
|
||||
NOTE: The example runs until you stop it wit CTRL+C
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
const BN = require('bn.js')
|
||||
const Api = require('@polkadot/api').default
|
||||
const WsProvider = require('@polkadot/api-provider/ws').default
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = new Api(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)
|
||||
console.log('#' + bnBlockNumber.toString(10))
|
||||
})
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "02_listen_to_blocks",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to use subscriptions",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"bn.js": "^4.11.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
= Listen to balance changes
|
||||
|
||||
This example shows how to instantiate a Polkadot API object and use it to connect to a node.
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
const Api = require('@polkadot/api').default
|
||||
const WsProvider = require('@polkadot/api-provider/ws').default
|
||||
const storage = require('@polkadot/storage').default
|
||||
const BN = require('bn.js')
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = new Api(provider)
|
||||
const Alice = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ'
|
||||
|
||||
console.log('You may let this example running and start the example 06 or send DOTs to ' + Alice)
|
||||
api.state.storage([[storage.staking.public.freeBalanceOf, Alice]], (_, values) => {
|
||||
console.log(`Balance of ${Alice}: ${new BN(values[0]).toString(10)} DOTs`)
|
||||
}).then((subscriptionId) => {
|
||||
console.log('Balance changes subscription id:', subscriptionId)
|
||||
})
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "03_listen_to_balance_change",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to subscribe to balance change",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"bn.js": "^4.11.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
= Generate accounts
|
||||
|
||||
If you want to develop a wallet or a program that will accept payments in DOTs, you likely will need to generate addresses. This sample shows you how to generate accounts in several ways.
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
const Keyring = require('@polkadot/util-keyring').default
|
||||
const u8aToHex = require('@polkadot/util/u8a/toHex').default
|
||||
const Encoder = new TextEncoder() // always utf-8
|
||||
const crypto = require('crypto')
|
||||
|
||||
// A fixed seed from an array
|
||||
const SEED1 = new Uint8Array(
|
||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
|
||||
22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0])
|
||||
|
||||
// A fixed seed from a 32 chars string
|
||||
const SEED2 = Encoder.encode('correct horse battery and staple')
|
||||
|
||||
const keyring = new Keyring()
|
||||
const pair1 = keyring.addFromSeed(SEED1)
|
||||
const pair2 = keyring.addFromSeed(SEED2)
|
||||
|
||||
console.log('Deterministic addresses (same for each run):')
|
||||
console.log(`Address 1\t ${pair1.address()}\t Seed: ${u8aToHex(SEED1)}`)
|
||||
console.log(`Address 2\t ${pair2.address()}\t Seed: ${u8aToHex(SEED2)}`)
|
||||
|
||||
// A random seed
|
||||
const SEED = new Uint8Array(32)
|
||||
console.log('Random Addresses (random for each run):')
|
||||
for (var i = 3; i < 13; i++) {
|
||||
Buffer.from(crypto.randomFillSync(SEED))
|
||||
const pair3 = keyring.addFromSeed(SEED)
|
||||
console.log(`Address ${i}\t ${pair3.address()}\t Seed: ${u8aToHex(SEED)}`)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "04_generate_account",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to connect using a WebSocket",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"@polkadot/util": "0.30.3",
|
||||
"@polkadot/util-keyring": "0.30.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
= Read storage
|
||||
|
||||
Many important variable are available through the storage API. This example shows how to call a few of those APIs.
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
const Api = require('@polkadot/api').default
|
||||
const WsProvider = require('@polkadot/api-provider/ws').default
|
||||
const storage = require('@polkadot/storage').default
|
||||
const BN = require('bn.js')
|
||||
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = new Api(provider)
|
||||
|
||||
async function getAccountIndex (address) {
|
||||
return api.state.getStorage([storage.system.public.accountIndexOf, address])
|
||||
}
|
||||
|
||||
async function getValidators () {
|
||||
return api.state.getStorage([storage.session.public.validators])
|
||||
}
|
||||
|
||||
async function getBlockPeriod () {
|
||||
return api.state.getStorage([storage.timestamp.public.blockPeriod])
|
||||
}
|
||||
|
||||
async function main () {
|
||||
const address = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ'
|
||||
const validators = await getValidators()
|
||||
const bn = await getAccountIndex(address)
|
||||
const blockPeriod = await getBlockPeriod()
|
||||
|
||||
const index = new BN(bn)
|
||||
console.log(`BlockPeriod: ${new BN(blockPeriod).toString(10)} seconds`)
|
||||
console.log(`Account Index of ${address}: ${index.toString(10)}`)
|
||||
console.log('Current validators', validators)
|
||||
}
|
||||
|
||||
main().finally(_ => process.exit())
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "04_read_storage",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to transfer DOTs",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"bn.js": "^4.11.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
= Craft Extrinsic
|
||||
|
||||
In the current version, crafting an extrinsic is a rather cumbersome process. This sample guides you though it and shows how to tranfer DOTs from an account to another.
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
Executable
+55
@@ -0,0 +1,55 @@
|
||||
const Api = require('@polkadot/api').default
|
||||
const WsProvider = require('@polkadot/api-provider/ws').default
|
||||
const extrinsics = require('@polkadot/extrinsics').default
|
||||
const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode').default
|
||||
const encodeLength = require('@polkadot/extrinsics/codec/encode/length').default
|
||||
const Keyring = require('@polkadot/util-keyring').default
|
||||
const storage = require('@polkadot/storage').default
|
||||
const BN = require('bn.js')
|
||||
|
||||
const Encoder = new TextEncoder()
|
||||
const keyring = new Keyring()
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = new Api(provider)
|
||||
|
||||
async function getAccountIndex (address) {
|
||||
return api.state.getStorage([storage.system.public.accountIndexOf, address])
|
||||
}
|
||||
|
||||
async function transfer (keyRingFrom, addressTo, amount) {
|
||||
const accountIndex = await getAccountIndex(keyRingFrom.address())
|
||||
console.log(`Current accountIndex: ${accountIndex}`)
|
||||
|
||||
// encode the call for signing
|
||||
const message = encodeExtrinsic(
|
||||
keyRingFrom.publicKey(),
|
||||
accountIndex,
|
||||
extrinsics.staking.public.transfer,
|
||||
[addressTo, amount]
|
||||
)
|
||||
|
||||
// get the signature
|
||||
const signature = keyRingFrom.sign(message)
|
||||
|
||||
// encode the extrinsic for submission, adding the length (prefix) and the
|
||||
// signature (postfix)Rödl
|
||||
const encoded = encodeLength(
|
||||
// When working with publicKeys, the prefix is 0xff for poc-2+
|
||||
new Uint8Array([0xff]),
|
||||
message,
|
||||
signature
|
||||
)
|
||||
|
||||
return api.author.submitExtrinsic(encoded)
|
||||
}
|
||||
|
||||
const Alice = keyring.addFromSeed(Encoder.encode('Alice '))
|
||||
const addressBob = '5Gw3s7q4QLkSWwknsiPtjujPv3XM4Trxi5d4PgKMMk3gfGTE'
|
||||
const amount = new BN(999) // on dev chain, the fee is 1, that makes it a round 1000
|
||||
|
||||
console.log(`Crafting and sending an extrinsic for Alice to send Bob ${amount} DOTs`)
|
||||
transfer(Alice, addressBob, amount)
|
||||
.then(() => console.log('Sent'))
|
||||
.catch((e) => console.log(
|
||||
'HINT: Make sure you wait for the storage to update before sending the next extrinsic', e))
|
||||
.finally(_ => process.exit(0))
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "06_craft_extrinsic",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to transfer DOTs",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"bn.js": "^4.11.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
= Tranfer DOTs
|
||||
|
||||
This sample is more 'straight to the point' and shows the easiest way to transfer DOTs from an account to another.
|
||||
|
||||
[source, javascript]
|
||||
----
|
||||
include::index.js[]
|
||||
----
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
const Api = require('@polkadot/api').default
|
||||
const WsProvider = require('@polkadot/api-provider/ws').default
|
||||
const extrinsics = require('@polkadot/extrinsics').default
|
||||
const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode/uncheckedLength').default
|
||||
const encodeLength = require('@polkadot/extrinsics/codec/encode/length').default
|
||||
const Keyring = require('@polkadot/util-keyring').default
|
||||
const storage = require('@polkadot/storage').default
|
||||
const BN = require('bn.js')
|
||||
|
||||
const Encoder = new TextEncoder()
|
||||
const keyring = new Keyring()
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944')
|
||||
const api = new Api(provider)
|
||||
|
||||
async function getAccountIndex (address) {
|
||||
return api.state.getStorage([storage.system.public.accountIndexOf, address])
|
||||
}
|
||||
|
||||
async function transfer (keyRingFrom, addressTo, amount) {
|
||||
const nextAccountIndex = await getAccountIndex(keyRingFrom.address())
|
||||
|
||||
// encode the call for signing
|
||||
const encoded = encodeExtrinsic(
|
||||
keyRingFrom,
|
||||
nextAccountIndex,
|
||||
extrinsics.staking.public.transfer,
|
||||
[addressTo, amount]
|
||||
)
|
||||
|
||||
await api.author.submitExtrinsic(encoded)
|
||||
.catch(e => console.log)
|
||||
}
|
||||
|
||||
const Alice = keyring.addFromSeed(Encoder.encode('Alice '))
|
||||
const addressBob = '5Gw3s7q4QLkSWwknsiPtjujPv3XM4Trxi5d4PgKMMk3gfGTE'
|
||||
const amount = new BN(999) // on dev chain, the fee is 1, that makes it a round 1000
|
||||
|
||||
console.log(`Crafting and sending an extrinsic for Alice to send Bob ${amount} DOTs`)
|
||||
transfer(Alice, addressBob, amount)
|
||||
.then(() => console.log('Done'))
|
||||
.catch((e) => console.log(e))
|
||||
.finally(_ => process.exit(0))
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "07_transfer_dots",
|
||||
"version": "0.1.0",
|
||||
"description": "Example showing how to transfer DOTs",
|
||||
"main": "index.js",
|
||||
"author": "chevdor",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"clean": "rimraf node_modules",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/api": "0.29.1",
|
||||
"bn.js": "^4.11.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "2.6.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
= Examples
|
||||
|
||||
For the following examples, you need a local node. It is usually convenient testing with:
|
||||
|
||||
```
|
||||
polkadot --dev
|
||||
```
|
||||
|
||||
Some of the examples use the following accounts:
|
||||
|
||||
- Alice: `5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ`
|
||||
- Bob: `5Gw3s7q4QLkSWwknsiPtjujPv3XM4Trxi5d4PgKMMk3gfGTE`
|
||||
|
||||
Those accounts are easy to add if you don´t have/see them. The seed of Alice´s account is `Alice␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣␣` and the seed of Bob is... well you guess...
|
||||
|
||||
NOTE: Note the spaces padding Alice´s key up to 32 chars.
|
||||
|
||||
== Install
|
||||
|
||||
From each folder, run `yarn` to install the required dependencies
|
||||
|
||||
== Running the examples
|
||||
|
||||
From each folder, run:
|
||||
```
|
||||
yarn start
|
||||
```
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
```javascript
|
||||
import createApi from '@polkadot/api';
|
||||
import WsProvider from '@polkadot/api-provider/ws';
|
||||
const provider = new WsProvider('ws://127.0.0.1:9944');
|
||||
const api = createApi(provider);
|
||||
```
|
||||
@@ -0,0 +1,215 @@
|
||||
|
||||
@polkadot/extrinsics
|
||||
====================
|
||||
|
||||
## Index
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [Extrinsic$Sections](#extrinsic_sections)
|
||||
* [ExtrinsicUnchecked](#extrinsicunchecked)
|
||||
* [ExtrinsicWithAccount](#extrinsicwithaccount)
|
||||
* [ExtrinsicWithIndex](#extrinsicwithindex)
|
||||
* [Extrinsics](#extrinsics)
|
||||
|
||||
### Functions
|
||||
|
||||
* [decodeLength](#decodelength)
|
||||
* [encode](#encode)
|
||||
* [encodeCall](#encodecall)
|
||||
* [encodeExtrinsic](#encodeextrinsic)
|
||||
* [encodeLength](#encodelength)
|
||||
* [unchecked](#unchecked)
|
||||
* [uncheckedLength](#uncheckedlength)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="extrinsic_sections"></a>
|
||||
|
||||
### Extrinsic$Sections
|
||||
|
||||
**Ƭ Extrinsic$Sections**: *`keyof Extrinsics`*
|
||||
|
||||
*Defined in [types.d.ts:21](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/types.d.ts#L21)*
|
||||
|
||||
___
|
||||
<a id="extrinsicunchecked"></a>
|
||||
|
||||
### ExtrinsicUnchecked
|
||||
|
||||
**Ƭ ExtrinsicUnchecked**: *`Uint8Array`*
|
||||
|
||||
*Defined in [codec/types.d.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/types.d.ts#L9)*
|
||||
|
||||
___
|
||||
<a id="extrinsicwithaccount"></a>
|
||||
|
||||
### ExtrinsicWithAccount
|
||||
|
||||
**Ƭ ExtrinsicWithAccount**: *`Uint8Array`*
|
||||
|
||||
*Defined in [codec/types.d.ts:5](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/types.d.ts#L5)*
|
||||
|
||||
___
|
||||
<a id="extrinsicwithindex"></a>
|
||||
|
||||
### ExtrinsicWithIndex
|
||||
|
||||
**Ƭ ExtrinsicWithIndex**: *`Uint8Array`*
|
||||
|
||||
*Defined in [codec/types.d.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/types.d.ts#L7)*
|
||||
|
||||
___
|
||||
<a id="extrinsics"></a>
|
||||
|
||||
### Extrinsics
|
||||
|
||||
**Ƭ Extrinsics**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/types.d.ts#L7)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="decodelength"></a>
|
||||
|
||||
### decodeLength
|
||||
|
||||
▸ **decodeLength**(unchecked: *`Uint8Array`*): `UncheckedRaw`
|
||||
|
||||
*Defined in [codec/decode/length.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/decode/length.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| unchecked | `Uint8Array` |
|
||||
|
||||
**Returns:** `UncheckedRaw`
|
||||
|
||||
___
|
||||
<a id="encode"></a>
|
||||
|
||||
### encode
|
||||
|
||||
▸ **encode**(publicKey: *`Uint8Array`*, index: * `number` | `BN`*, extrinsic: *`SectionItem`<[Extrinsics](#extrinsics)>*, values: *`Array`<`any`>*, version: *`EncodingVersions`*): [ExtrinsicWithAccount](#extrinsicwithaccount)
|
||||
|
||||
*Defined in [codec/encode/index.ts:13](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/encode/index.ts#L13)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| publicKey | `Uint8Array` |
|
||||
| index | `number` | `BN`|
|
||||
| extrinsic | `SectionItem`<[Extrinsics](#extrinsics)> |
|
||||
| values | `Array`<`any`> |
|
||||
| version | `EncodingVersions` |
|
||||
|
||||
**Returns:** [ExtrinsicWithAccount](#extrinsicwithaccount)
|
||||
|
||||
___
|
||||
<a id="encodecall"></a>
|
||||
|
||||
### encodeCall
|
||||
|
||||
▸ **encodeCall**(publicKey: *`Uint8Array`*, nonce: * `number` | `BN`*, data: *[ExtrinsicWithIndex](#extrinsicwithindex)*, version: *`EncodingVersions`*): [ExtrinsicWithAccount](#extrinsicwithaccount)
|
||||
|
||||
*Defined in [codec/encode/call.ts:14](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/encode/call.ts#L14)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| publicKey | `Uint8Array` |
|
||||
| nonce | `number` | `BN`|
|
||||
| data | [ExtrinsicWithIndex](#extrinsicwithindex) |
|
||||
| version | `EncodingVersions` |
|
||||
|
||||
**Returns:** [ExtrinsicWithAccount](#extrinsicwithaccount)
|
||||
|
||||
___
|
||||
<a id="encodeextrinsic"></a>
|
||||
|
||||
### encodeExtrinsic
|
||||
|
||||
▸ **encodeExtrinsic**(extrinsic: *`SectionItem`<[Extrinsics](#extrinsics)>*, values: *`Array`<`any`>*, version: *`EncodingVersions`*): [ExtrinsicWithIndex](#extrinsicwithindex)
|
||||
|
||||
*Defined in [codec/encode/extrinsic.ts:12](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/encode/extrinsic.ts#L12)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| extrinsic | `SectionItem`<[Extrinsics](#extrinsics)> |
|
||||
| values | `Array`<`any`> |
|
||||
| version | `EncodingVersions` |
|
||||
|
||||
**Returns:** [ExtrinsicWithIndex](#extrinsicwithindex)
|
||||
|
||||
___
|
||||
<a id="encodelength"></a>
|
||||
|
||||
### encodeLength
|
||||
|
||||
▸ **encodeLength**(...values: *`Array`<`Uint8Array`>*): `Uint8Array`
|
||||
|
||||
*Defined in [codec/encode/length.ts:8](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/encode/length.ts#L8)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Rest` values | `Array`<`Uint8Array`> |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="unchecked"></a>
|
||||
|
||||
### unchecked
|
||||
|
||||
▸ **unchecked**(pair: *`KeyringPair`*, index: * `number` | `BN`*, extrinsic: *`SectionItem`<[Extrinsics](#extrinsics)>*, values: *`Array`<`any`>*, version?: *`EncodingVersions`*): `UncheckedRaw`
|
||||
|
||||
*Defined in [codec/encode/unchecked.ts:16](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/encode/unchecked.ts#L16)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| pair | `KeyringPair` | - |
|
||||
| index | `number` | `BN`| - |
|
||||
| extrinsic | `SectionItem`<[Extrinsics](#extrinsics)> | - |
|
||||
| values | `Array`<`any`> | - |
|
||||
| `Default value` version | `EncodingVersions` | "latest" |
|
||||
|
||||
**Returns:** `UncheckedRaw`
|
||||
|
||||
___
|
||||
<a id="uncheckedlength"></a>
|
||||
|
||||
### uncheckedLength
|
||||
|
||||
▸ **uncheckedLength**(pair: *`KeyringPair`*, index: * `number` | `BN`*, extrinsic: *`SectionItem`<[Extrinsics](#extrinsics)>*, values: *`Array`<`any`>*, version?: *`EncodingVersions`*): `UncheckedRaw`
|
||||
|
||||
*Defined in [codec/encode/uncheckedLength.ts:14](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-extrinsics/src/codec/encode/uncheckedLength.ts#L14)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| pair | `KeyringPair` | - |
|
||||
| index | `number` | `BN`| - |
|
||||
| extrinsic | `SectionItem`<[Extrinsics](#extrinsics)> | - |
|
||||
| values | `Array`<`any`> | - |
|
||||
| `Default value` version | `EncodingVersions` | "latest" |
|
||||
|
||||
**Returns:** `UncheckedRaw`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/jsonrpc) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?path=packages/type-jsonrpc) [](https://david-dm.org/polkadot-js/api?path=packages/type-jsonrpc#info=devDependencies)
|
||||
|
||||
@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.
|
||||
|
||||
For a list of currently exposed methods, see the [method documentation](docs/README.md).
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
npm install --save @polkadot/jsonrpc
|
||||
```
|
||||
|
||||
Adding methods
|
||||
--------------
|
||||
|
||||
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)
|
||||
|
||||
## Index
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [Interface$Sections](#interface_sections)
|
||||
* [Interfaces](#interfaces)
|
||||
* [PrivateMethods](#privatemethods)
|
||||
* [PublicMethods](#publicmethods)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="interface_sections"></a>
|
||||
|
||||
### Interface$Sections
|
||||
|
||||
**Ƭ Interface$Sections**: *`keyof Interfaces`*
|
||||
|
||||
*Defined in [types.d.ts:18](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/types.d.ts#L18)*
|
||||
|
||||
___
|
||||
<a id="interfaces"></a>
|
||||
|
||||
### Interfaces
|
||||
|
||||
**Ƭ Interfaces**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/types.d.ts#L11)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="privatemethods"></a>
|
||||
|
||||
### PrivateMethods
|
||||
|
||||
**Ƭ PrivateMethods**: *`object`*
|
||||
|
||||
*Defined in [chain.ts:50](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/chain.ts#L50)*
|
||||
*Defined in [state.ts:99](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/state.ts#L99)*
|
||||
*Defined in [system.ts:34](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/system.ts#L34)*
|
||||
*Defined in [author.ts:32](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/author.ts#L32)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: `CreateItemOptions`
|
||||
|
||||
___
|
||||
<a id="publicmethods"></a>
|
||||
|
||||
### PublicMethods
|
||||
|
||||
**Ƭ PublicMethods**: *`object`*
|
||||
|
||||
*Defined in [chain.ts:49](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/chain.ts#L49)*
|
||||
*Defined in [state.ts:100](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/state.ts#L100)*
|
||||
*Defined in [system.ts:35](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/system.ts#L35)*
|
||||
*Defined in [author.ts:33](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-jsonrpc/src/author.ts#L33)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: `CreateItemOptions`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,918 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/primitives) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?path=packages/type-params) [](https://david-dm.org/polkadot-js/api?path=packages/type-params#info=devDependencies)
|
||||
|
||||
## Index
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [BlockDecoded](#blockdecoded)
|
||||
* [BlockExtrinsicDecoded](#blockextrinsicdecoded)
|
||||
* [BlockJustificationDecoded](#blockjustificationdecoded)
|
||||
* [CreateItem](#createitem)
|
||||
* [CreateItemOptions](#createitemoptions)
|
||||
* [CreateItemOptionsMap](#createitemoptionsmap)
|
||||
* [CreateItems](#createitems)
|
||||
* [CreateSection](#createsection)
|
||||
* [CreateSectionOptions](#createsectionoptions)
|
||||
* [CreateSectionOptions$Fn](#createsectionoptions_fn)
|
||||
* [CreateSectionOptions$Only](#createsectionoptions_only)
|
||||
* [Decoder](#decoder)
|
||||
* [EncodingVersions](#encodingversions)
|
||||
* [ExtrinsicDecoded](#extrinsicdecoded)
|
||||
* [KeyValue](#keyvalue)
|
||||
* [Param](#param)
|
||||
* [Param$Decoded](#param_decoded)
|
||||
* [Param$Options](#param_options)
|
||||
* [Param$Type](#param_type)
|
||||
* [Param$Type$Array](#param_type_array)
|
||||
* [Param$Types](#param_types)
|
||||
* [Param$Value](#param_value)
|
||||
* [Param$Value$Array](#param_value_array)
|
||||
* [Param$Values](#param_values)
|
||||
* [Params](#params)
|
||||
* [Section](#section)
|
||||
* [SectionItem](#sectionitem)
|
||||
* [SectionItems](#sectionitems)
|
||||
* [Sections](#sections)
|
||||
|
||||
### Functions
|
||||
|
||||
* [accountId](#accountid)
|
||||
* [bn](#bn)
|
||||
* [bool](#bool)
|
||||
* [byte](#byte)
|
||||
* [bytes](#bytes)
|
||||
* [call](#call)
|
||||
* [code](#code)
|
||||
* [createMethod](#createmethod)
|
||||
* [createParam](#createparam)
|
||||
* [createSection](#createsection)
|
||||
* [decode](#decode)
|
||||
* [decodeValue](#decodevalue)
|
||||
* [digest](#digest)
|
||||
* [encodeParam](#encodeparam)
|
||||
* [encodeParams](#encodeparams)
|
||||
* [encodeType](#encodetype)
|
||||
* [header](#header)
|
||||
* [keyValue](#keyvalue)
|
||||
* [misbehavior](#misbehavior)
|
||||
* [passThrough](#passthrough)
|
||||
* [signature](#signature)
|
||||
* [storageKey](#storagekey)
|
||||
* [string](#string)
|
||||
* [time](#time)
|
||||
* [typeToString](#typetostring)
|
||||
* [u8a](#u8a)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="blockdecoded"></a>
|
||||
|
||||
### BlockDecoded
|
||||
|
||||
**Ƭ BlockDecoded**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:45](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L45)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="blockextrinsicdecoded"></a>
|
||||
|
||||
### BlockExtrinsicDecoded
|
||||
|
||||
**Ƭ BlockExtrinsicDecoded**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:28](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L28)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="blockjustificationdecoded"></a>
|
||||
|
||||
### BlockJustificationDecoded
|
||||
|
||||
**Ƭ BlockJustificationDecoded**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:36](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L36)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="createitem"></a>
|
||||
|
||||
### CreateItem
|
||||
|
||||
**Ƭ CreateItem**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:127](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L127)*
|
||||
|
||||
#### Type declaration
|
||||
▸(options: *[CreateItemOptions](#createitemoptions)*): [SectionItem](#sectionitem)<`T`>
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| options | [CreateItemOptions](#createitemoptions) |
|
||||
|
||||
**Returns:** [SectionItem](#sectionitem)<`T`>
|
||||
|
||||
___
|
||||
<a id="createitemoptions"></a>
|
||||
|
||||
### CreateItemOptions
|
||||
|
||||
**Ƭ CreateItemOptions**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:111](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L111)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="createitemoptionsmap"></a>
|
||||
|
||||
### CreateItemOptionsMap
|
||||
|
||||
**Ƭ CreateItemOptionsMap**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:123](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L123)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
[index: `string`]: [CreateItemOptions](#createitemoptions)
|
||||
|
||||
___
|
||||
<a id="createitems"></a>
|
||||
|
||||
### CreateItems
|
||||
|
||||
**Ƭ CreateItems**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:129](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L129)*
|
||||
|
||||
#### Type declaration
|
||||
▸(name: *`string`*, index?: * `undefined` | `number`*): [CreateItem](#createitem)<`T`>
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| name | `string` |
|
||||
| `Optional` index | `undefined` | `number`|
|
||||
|
||||
**Returns:** [CreateItem](#createitem)<`T`>
|
||||
|
||||
___
|
||||
<a id="createsection"></a>
|
||||
|
||||
### CreateSection
|
||||
|
||||
**Ƭ CreateSection**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:143](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L143)*
|
||||
|
||||
#### Type declaration
|
||||
▸(options: *[CreateSectionOptions](#createsectionoptions)<`T`, `Priv`, `Pub`>*): [Section](#section)<`T`, `Priv`, `Pub`>
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| options | [CreateSectionOptions](#createsectionoptions)<`T`, `Priv`, `Pub`> |
|
||||
|
||||
**Returns:** [Section](#section)<`T`, `Priv`, `Pub`>
|
||||
|
||||
___
|
||||
<a id="createsectionoptions"></a>
|
||||
|
||||
### CreateSectionOptions
|
||||
|
||||
**Ƭ CreateSectionOptions**: * [CreateSectionOptions$Only](#createsectionoptions_only)<`T`, `Priv`, `Pub`> | [CreateSectionOptions$Fn](#createsectionoptions_fn)<`T`, `Priv`, `Pub`>
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:141](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L141)*
|
||||
|
||||
___
|
||||
<a id="createsectionoptions_fn"></a>
|
||||
|
||||
### CreateSectionOptions$Fn
|
||||
|
||||
**Ƭ CreateSectionOptions$Fn**: *`function`*
|
||||
|
||||
*Defined in [types.d.ts:139](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L139)*
|
||||
|
||||
#### Type declaration
|
||||
▸(method: *[CreateItems](#createitems)<`T`>*): [CreateSectionOptions$Only](#createsectionoptions_only)<`T`, `Priv`, `Pub`>
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| method | [CreateItems](#createitems)<`T`> |
|
||||
|
||||
**Returns:** [CreateSectionOptions$Only](#createsectionoptions_only)<`T`, `Priv`, `Pub`>
|
||||
|
||||
___
|
||||
<a id="createsectionoptions_only"></a>
|
||||
|
||||
### CreateSectionOptions$Only
|
||||
|
||||
**Ƭ CreateSectionOptions$Only**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:131](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L131)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="decoder"></a>
|
||||
|
||||
### Decoder
|
||||
|
||||
**Ƭ Decoder**: *`function`*
|
||||
|
||||
*Defined in [decode/types.d.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/types.d.ts#L7)*
|
||||
|
||||
#### Type declaration
|
||||
▸(type: *[Param$Types](#param_types)*, input: *`Uint8Array`*, version: *[EncodingVersions](#encodingversions)*, isStorage: *`boolean`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | [Param$Types](#param_types) |
|
||||
| input | `Uint8Array` |
|
||||
| version | [EncodingVersions](#encodingversions) |
|
||||
| isStorage | `boolean` |
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="encodingversions"></a>
|
||||
|
||||
### EncodingVersions
|
||||
|
||||
**Ƭ EncodingVersions**: * "poc-1" | "latest"
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L11)*
|
||||
|
||||
___
|
||||
<a id="extrinsicdecoded"></a>
|
||||
|
||||
### ExtrinsicDecoded
|
||||
|
||||
**Ƭ ExtrinsicDecoded**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:23](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L23)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="keyvalue"></a>
|
||||
|
||||
### KeyValue
|
||||
|
||||
**Ƭ KeyValue**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:51](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L51)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="param"></a>
|
||||
|
||||
### Param
|
||||
|
||||
**Ƭ Param**: * [Param$Options](#param_options) & `object`
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:71](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L71)*
|
||||
|
||||
___
|
||||
<a id="param_decoded"></a>
|
||||
|
||||
### Param$Decoded
|
||||
|
||||
**Ƭ Param$Decoded**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:62](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L62)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="param_options"></a>
|
||||
|
||||
### Param$Options
|
||||
|
||||
**Ƭ Param$Options**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:67](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L67)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="param_type"></a>
|
||||
|
||||
### Param$Type
|
||||
|
||||
**Ƭ Param$Type**: * "AccountId" | "AccountIndex" | "Balance" | "BlockNumber" | "bool" | "Bytes" | "Call" | "CandidateReceipt" | "Code" | "Digest" | "Gas" | "Hash" | "Header" | "KeyValue" | "MisbehaviorReport" | "ParachainId" | "PrendingExtrinsics" | "PropIndex" | "Proposal" | "ReferendumIndex" | "SessionKey" | "Signature" | "SignedBlock" | "StorageKey" | "StorageKeyValue" | "StorageResult" | "StorageResultSet" | "String" | "Timestamp" | "u32" | "u64" | "u128" | "VoteIndex" | "VoteThreshold"
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:17](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L17)*
|
||||
|
||||
___
|
||||
<a id="param_type_array"></a>
|
||||
|
||||
### Param$Type$Array
|
||||
|
||||
**Ƭ Param$Type$Array**: *`Array`< [Param$Type](#param_type) | `Array`< [Param$Type](#param_type) | `Array`<[Param$Type](#param_type)>>>*
|
||||
|
||||
*Defined in [types.d.ts:19](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L19)*
|
||||
|
||||
___
|
||||
<a id="param_types"></a>
|
||||
|
||||
### Param$Types
|
||||
|
||||
**Ƭ Param$Types**: * [Param$Type](#param_type) | [Param$Type$Array](#param_type_array)
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:21](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L21)*
|
||||
|
||||
___
|
||||
<a id="param_value"></a>
|
||||
|
||||
### Param$Value
|
||||
|
||||
**Ƭ Param$Value**: * `Digest` | `Header` | [KeyValue](#keyvalue) | `MisbehaviorReport` | [ExtrinsicDecoded](#extrinsicdecoded) | `BN` | `Date` | `Uint8Array` | `boolean` | `number` | `string` | `null`
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:56](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L56)*
|
||||
|
||||
___
|
||||
<a id="param_value_array"></a>
|
||||
|
||||
### Param$Value$Array
|
||||
|
||||
**Ƭ Param$Value$Array**: *`Array`< [Param$Value](#param_value) | `Array`< [Param$Value](#param_value) | `Array`<[Param$Value](#param_value)>>>*
|
||||
|
||||
*Defined in [types.d.ts:58](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L58)*
|
||||
|
||||
___
|
||||
<a id="param_values"></a>
|
||||
|
||||
### Param$Values
|
||||
|
||||
**Ƭ Param$Values**: * [Param$Value](#param_value) | [Param$Value$Array](#param_value_array)
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:60](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L60)*
|
||||
|
||||
___
|
||||
<a id="params"></a>
|
||||
|
||||
### Params
|
||||
|
||||
**Ƭ Params**: *`Array`<[Param](#param)>*
|
||||
|
||||
*Defined in [types.d.ts:76](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L76)*
|
||||
|
||||
___
|
||||
<a id="section"></a>
|
||||
|
||||
### Section
|
||||
|
||||
**Ƭ Section**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:99](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L99)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="sectionitem"></a>
|
||||
|
||||
### SectionItem
|
||||
|
||||
**Ƭ SectionItem**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:79](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L79)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="sectionitems"></a>
|
||||
|
||||
### SectionItems
|
||||
|
||||
**Ƭ SectionItems**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:95](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L95)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
<a id="sections"></a>
|
||||
|
||||
### Sections
|
||||
|
||||
**Ƭ Sections**: *`Map`<`T`, [Section](#section)<`T`, `Priv`, `Pub`>>*
|
||||
|
||||
*Defined in [types.d.ts:109](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/types.d.ts#L109)*
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="accountid"></a>
|
||||
|
||||
### accountId
|
||||
|
||||
▸ **accountId**(input: * `Uint8Array` | `null` | `undefined`*, version: *[EncodingVersions](#encodingversions)*, isStorage: *`boolean`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/accountId.ts:13](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/accountId.ts#L13)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
| version | [EncodingVersions](#encodingversions) |
|
||||
| isStorage | `boolean` |
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="bn"></a>
|
||||
|
||||
### bn
|
||||
|
||||
▸ **bn**(input: * `Uint8Array` | `null` | `undefined`*, bitLength: * `32` | `64` | `128`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/bn.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/bn.ts#L10)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
| bitLength | `32` | `64` | `128`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="bool"></a>
|
||||
|
||||
### bool
|
||||
|
||||
▸ **bool**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/bool.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/bool.ts#L10)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="byte"></a>
|
||||
|
||||
### byte
|
||||
|
||||
▸ **byte**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/byte.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/byte.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="bytes"></a>
|
||||
|
||||
### bytes
|
||||
|
||||
▸ **bytes**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/bytes.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/bytes.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="call"></a>
|
||||
|
||||
### call
|
||||
|
||||
▸ **call**(decode: *[Decoder](#decoder)*, input: * `Uint8Array` | `null` | `undefined`*, isPublic: *`boolean`*, version: *[EncodingVersions](#encodingversions)*, isStorage: *`boolean`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/method.ts:19](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/method.ts#L19)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | [Decoder](#decoder) |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
| isPublic | `boolean` |
|
||||
| version | [EncodingVersions](#encodingversions) |
|
||||
| isStorage | `boolean` |
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="code"></a>
|
||||
|
||||
### code
|
||||
|
||||
▸ **code**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/code.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/code.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="createmethod"></a>
|
||||
|
||||
### createMethod
|
||||
|
||||
▸ **createMethod**<`T`>(section: *`keyof T`*, sectionIndex: *`Uint8Array`*): [CreateItems](#createitems)<`T`>
|
||||
|
||||
*Defined in [method.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/method.ts#L11)*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
#### T
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| section | `keyof T` |
|
||||
| sectionIndex | `Uint8Array` |
|
||||
|
||||
**Returns:** [CreateItems](#createitems)<`T`>
|
||||
|
||||
___
|
||||
<a id="createparam"></a>
|
||||
|
||||
### createParam
|
||||
|
||||
▸ **createParam**(name: *`string`*, type: *[Param$Types](#param_types)*, __namedParameters?: *`object`*): [Param](#param)
|
||||
|
||||
*Defined in [param.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/param.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| name | `string` | - |
|
||||
| type | [Param$Types](#param_types) | - |
|
||||
| `Default value` __namedParameters | `object` | { isOptional: false } |
|
||||
|
||||
**Returns:** [Param](#param)
|
||||
|
||||
___
|
||||
<a id="createsection"></a>
|
||||
|
||||
### createSection
|
||||
|
||||
▸ **createSection**<`T`>(name: *`keyof T`*, _index?: *`number`*): [CreateSection](#createsection)<`T`, `any`, `any`>
|
||||
|
||||
*Defined in [section.ts:11](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/section.ts#L11)*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
#### T
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| name | `keyof T` | - |
|
||||
| `Default value` _index | `number` | 0 |
|
||||
|
||||
**Returns:** [CreateSection](#createsection)<`T`, `any`, `any`>
|
||||
|
||||
___
|
||||
<a id="decode"></a>
|
||||
|
||||
### decode
|
||||
|
||||
▸ **decode**(type: *[Param$Types](#param_types)*, _input: * `Uint8Array` | `string` | `null` | `undefined`*, version: *[EncodingVersions](#encodingversions)*, isStorage?: *`boolean`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/index.ts:65](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/index.ts#L65)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| type | [Param$Types](#param_types) | - |
|
||||
| _input | `Uint8Array` | `string` | `null` | `undefined`| - |
|
||||
| version | [EncodingVersions](#encodingversions) | - |
|
||||
| `Default value` isStorage | `boolean` | false |
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="decodevalue"></a>
|
||||
|
||||
### decodeValue
|
||||
|
||||
▸ **decodeValue**(decode: *[Decoder](#decoder)*, type: *[Param$Type](#param_type)*, _input: * `Uint8Array` | `string` | `null` | `undefined`*, version: *[EncodingVersions](#encodingversions)*, isStorage: *`boolean`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/index.ts:30](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/index.ts#L30)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | [Decoder](#decoder) |
|
||||
| type | [Param$Type](#param_type) |
|
||||
| _input | `Uint8Array` | `string` | `null` | `undefined`|
|
||||
| version | [EncodingVersions](#encodingversions) |
|
||||
| isStorage | `boolean` |
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="digest"></a>
|
||||
|
||||
### digest
|
||||
|
||||
▸ **digest**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/digest.ts:12](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/digest.ts#L12)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="encodeparam"></a>
|
||||
|
||||
### encodeParam
|
||||
|
||||
▸ **encodeParam**(param: *[Param](#param)*, value: *`any`*, version?: *[EncodingVersions](#encodingversions)*): `Uint8Array`
|
||||
|
||||
*Defined in [encode/param.ts:14](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/encode/param.ts#L14)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| param | [Param](#param) | - |
|
||||
| value | `any` | - |
|
||||
| `Default value` version | [EncodingVersions](#encodingversions) | "latest" |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="encodeparams"></a>
|
||||
|
||||
### encodeParams
|
||||
|
||||
▸ **encodeParams**(params: *[Params](#params)*, values: *`Array`<`any`>*, version: *[EncodingVersions](#encodingversions)*): `Uint8Array`
|
||||
|
||||
*Defined in [encode/index.ts:12](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/encode/index.ts#L12)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| params | [Params](#params) |
|
||||
| values | `Array`<`any`> |
|
||||
| version | [EncodingVersions](#encodingversions) |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="encodetype"></a>
|
||||
|
||||
### encodeType
|
||||
|
||||
▸ **encodeType**(type: *[Param$Type](#param_type)*, value: *`any`*, version: *[EncodingVersions](#encodingversions)*): `Uint8Array`
|
||||
|
||||
*Defined in [encode/type/index.ts:19](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/encode/type/index.ts#L19)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | [Param$Type](#param_type) |
|
||||
| value | `any` |
|
||||
| version | [EncodingVersions](#encodingversions) |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="header"></a>
|
||||
|
||||
### header
|
||||
|
||||
▸ **header**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/header.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/header.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="keyvalue"></a>
|
||||
|
||||
### keyValue
|
||||
|
||||
▸ **keyValue**(__namedParameters: *`object`*): `Uint8Array`
|
||||
|
||||
*Defined in [encode/type/keyValue.ts:12](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/encode/type/keyValue.ts#L12)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| __namedParameters | `object` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="misbehavior"></a>
|
||||
|
||||
### misbehavior
|
||||
|
||||
▸ **misbehavior**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/misbehavior.ts:21](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/misbehavior.ts#L21)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="passthrough"></a>
|
||||
|
||||
### passThrough
|
||||
|
||||
▸ **passThrough**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/passThrough.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/passThrough.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="signature"></a>
|
||||
|
||||
### signature
|
||||
|
||||
▸ **signature**<`T`>(__namedParameters: *`object`*): `string`
|
||||
|
||||
*Defined in [signature.ts:20](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/signature.ts#L20)*
|
||||
|
||||
*__name__*: signature
|
||||
|
||||
*__signature__*: jsonrpcSignature (method: InterfaceMethodDefinition): string
|
||||
|
||||
*__summary__*: Returns a string representation of the method with inputs and outputs.
|
||||
|
||||
*__description__*: Formats the name, inputs and outputs into a human-readable string. This contains the input parameter names input types and output type.
|
||||
|
||||
*__example__*: import signature from '@polkadot/params/signature';
|
||||
|
||||
signature({ name: 'test\_method', params: \[ { name: 'dest', type: 'Address' } \], type: 'Address' }); // => test\_method (dest: Address): Address
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
#### T
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| __namedParameters | `object` |
|
||||
|
||||
**Returns:** `string`
|
||||
|
||||
___
|
||||
<a id="storagekey"></a>
|
||||
|
||||
### storageKey
|
||||
|
||||
▸ **storageKey**(__namedParameters: *[`object`, `Array`]*): `Uint8Array`
|
||||
|
||||
*Defined in [encode/type/storageKey.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/encode/type/storageKey.ts#L10)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| __namedParameters | [`object`, `Array`] |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="string"></a>
|
||||
|
||||
### string
|
||||
|
||||
▸ **string**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/string.ts:12](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/string.ts#L12)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="time"></a>
|
||||
|
||||
### time
|
||||
|
||||
▸ **time**(input: * `Uint8Array` | `null` | `undefined`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/time.ts:9](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/time.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
<a id="typetostring"></a>
|
||||
|
||||
### typeToString
|
||||
|
||||
▸ **typeToString**(type: *[Param$Types](#param_types)*): `string`
|
||||
|
||||
*Defined in [typeToString.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/typeToString.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| type | [Param$Types](#param_types) |
|
||||
|
||||
**Returns:** `string`
|
||||
|
||||
___
|
||||
<a id="u8a"></a>
|
||||
|
||||
### u8a
|
||||
|
||||
▸ **u8a**(input: * `Uint8Array` | `null` | `undefined`*, bitLength: *`number`*, offset: *`number`*): [Param$Decoded](#param_decoded)
|
||||
|
||||
*Defined in [decode/value/u8a.ts:7](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-params/src/decode/value/u8a.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` | `null` | `undefined`|
|
||||
| bitLength | `number` |
|
||||
| offset | `number` |
|
||||
|
||||
**Returns:** [Param$Decoded](#param_decoded)
|
||||
|
||||
___
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,118 @@
|
||||
|
||||
[](https://polkadot.js.org)  [](https://github.com/Flet/semistandard) [](https://www.npmjs.com/package/@polkadot/storage) [](https://travis-ci.org/polkadot-js/api) [](https://codeclimate.com/github/polkadot-js/api/maintainability) [](https://coveralls.io/github/polkadot-js/api?branch=master) [](https://david-dm.org/polkadot-js/api?path=packages/type-storage) [](https://david-dm.org/polkadot-js/api?path=packages/type-storage#info=devDependencies)
|
||||
|
||||
@polkadot/storage
|
||||
=================
|
||||
|
||||
An base interface to the storage layer
|
||||
|
||||
## Index
|
||||
|
||||
### Type aliases
|
||||
|
||||
* [Keygen](#keygen)
|
||||
* [Storage$Key$Value](#storage_key_value)
|
||||
* [Storage$Sections](#storage_sections)
|
||||
* [Storages](#storages)
|
||||
|
||||
### Functions
|
||||
|
||||
* [bindKey](#bindkey)
|
||||
* [formatParams](#formatparams)
|
||||
|
||||
---
|
||||
|
||||
## Type aliases
|
||||
|
||||
<a id="keygen"></a>
|
||||
|
||||
### Keygen
|
||||
|
||||
**Ƭ Keygen**: *`function`*
|
||||
|
||||
*Defined in [key/index.ts:14](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-storage/src/key/index.ts#L14)*
|
||||
|
||||
#### Type declaration
|
||||
▸(...keyParams: *`Array`<[Storage$Key$Value](#storage_key_value)>*): `Uint8Array`
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Rest` keyParams | `Array`<[Storage$Key$Value](#storage_key_value)> |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
<a id="storage_key_value"></a>
|
||||
|
||||
### Storage$Key$Value
|
||||
|
||||
**Ƭ Storage$Key$Value**: * `number` | `BN` | `Uint8Array` | `string`
|
||||
*
|
||||
|
||||
*Defined in [types.d.ts:8](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-storage/src/types.d.ts#L8)*
|
||||
|
||||
___
|
||||
<a id="storage_sections"></a>
|
||||
|
||||
### Storage$Sections
|
||||
|
||||
**Ƭ Storage$Sections**: *`keyof Storages`*
|
||||
|
||||
*Defined in [types.d.ts:23](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-storage/src/types.d.ts#L23)*
|
||||
|
||||
___
|
||||
<a id="storages"></a>
|
||||
|
||||
### Storages
|
||||
|
||||
**Ƭ Storages**: *`object`*
|
||||
|
||||
*Defined in [types.d.ts:10](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-storage/src/types.d.ts#L10)*
|
||||
|
||||
#### Type declaration
|
||||
|
||||
___
|
||||
|
||||
## Functions
|
||||
|
||||
<a id="bindkey"></a>
|
||||
|
||||
### bindKey
|
||||
|
||||
▸ **bindKey**<`T`>(__namedParameters: *`object`*): [Keygen](#keygen)
|
||||
|
||||
*Defined in [key/index.ts:16](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-storage/src/key/index.ts#L16)*
|
||||
|
||||
**Type parameters:**
|
||||
|
||||
#### T
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| __namedParameters | `object` |
|
||||
|
||||
**Returns:** [Keygen](#keygen)
|
||||
|
||||
___
|
||||
<a id="formatparams"></a>
|
||||
|
||||
### formatParams
|
||||
|
||||
▸ **formatParams**(params: *`Params`*, values?: *[Storage$Key$Value](#storage_key_value)[]*): `Array`<`Uint8Array`>
|
||||
|
||||
*Defined in [key/params.ts:15](https://github.com/chevdor/polkadot-js-api/blob/461228c/packages/type-storage/src/key/params.ts#L15)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type | Default value |
|
||||
| ------ | ------ | ------ |
|
||||
| params | `Params` | - |
|
||||
| `Default value` values | [Storage$Key$Value](#storage_key_value)[] | [] |
|
||||
|
||||
**Returns:** `Array`<`Uint8Array`>
|
||||
|
||||
___
|
||||
|
||||
Reference in New Issue
Block a user