First stage renames, rpc-{core,provider,rx} (#220)

* Docs renames (& removal for re-gen)

* Rename api, api-provider & api-rx

* Apoi -> Rpc, RxApi -> RpcRx (classes)

* Add .nodoc

* Bump version

* Link updates (summary)

* Cleanup deleted (master version)

* Deleted re-instated

* More... ;)

* Types...

* Revert .nodoc
This commit is contained in:
Jaco Greeff
2018-10-10 10:01:34 +02:00
committed by GitHub
parent cd7c17b265
commit 4344f33de8
102 changed files with 257 additions and 233 deletions
+7 -7
View File
@@ -1,12 +1,12 @@
## Packages ## Packages
- [api](api/README.md) - [rpc-core](rpc-core/README.md)
- [Api](api/classes/_index_.api.md) - [Rpc](rpc-core/classes/_index_.rpc.md)
- [api-provider](api-provider/README.md) - [rpc-provider](rpc-provider/README.md)
- [HttpProvider](api-provider/classes/_http_index_.httpprovider.md) - [HttpProvider](rpc-provider/classes/_http_index_.httpprovider.md)
- [WsProvider](api-provider/classes/_ws_index_.wsprovider.md) - [WsProvider](rpc-provider/classes/_ws_index_.wsprovider.md)
- [api-rx](api-rx/README.md) - [rpc-rx](rpc-rx/README.md)
- [ApiRx](api-rx/classes/_index_.rxapi.md) - [RpcRx](rpc-rx/classes/_index_.rxapi.md)
## Examples ## Examples
+3 -3
View File
@@ -1,7 +1,7 @@
const Api = require('@polkadot/api').default; const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/api-provider/ws').default; const WsProvider = require('@polkadot/rpc-provider/ws').default;
const provider = new WsProvider('ws://127.0.0.1:9944'); const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider); const api = new Rpc(provider);
async function getChain () { async function getChain () {
return api.system.chain(); return api.system.chain();
+2 -2
View File
@@ -11,8 +11,8 @@
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"@polkadot/api-provider": "^0.29.1" "@polkadot/rpc-provider": "^0.31.1"
}, },
"devDependencies": { "devDependencies": {
"rimraf": "^2.6.2" "rimraf": "^2.6.2"
+3 -3
View File
@@ -1,8 +1,8 @@
const BN = require('bn.js'); const BN = require('bn.js');
const Api = require('@polkadot/api').default; const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/api-provider/ws').default; const WsProvider = require('@polkadot/rpc-provider/ws').default;
const provider = new WsProvider('ws://127.0.0.1:9944'); const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider); const api = new Rpc(provider);
function main () { function main () {
console.log('Blocks will be shown as they come in, CTRL+C to stop:'); console.log('Blocks will be shown as they come in, CTRL+C to stop:');
@@ -10,7 +10,7 @@
"start": "node index.js" "start": "node index.js"
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"bn.js": "^4.11.8" "bn.js": "^4.11.8"
}, },
"devDependencies": { "devDependencies": {
@@ -1,9 +1,10 @@
const BN = require('bn.js'); const BN = require('bn.js');
const Api = require('@polkadot/api').default; const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/api-provider/ws').default; const WsProvider = require('@polkadot/rpc-provider/ws').default;
const storage = require('@polkadot/storage').default; const storage = require('@polkadot/storage').default;
const provider = new WsProvider('ws://127.0.0.1:9944'); const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider); const api = new Rpc(provider);
const Alice = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ'; const Alice = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ';
console.log('You may leave this example running and start example 06 or send DOTs to ' + Alice); console.log('You may leave this example running and start example 06 or send DOTs to ' + Alice);
@@ -10,7 +10,7 @@
"start": "node index.js" "start": "node index.js"
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"bn.js": "^4.11.8" "bn.js": "^4.11.8"
}, },
"devDependencies": { "devDependencies": {
@@ -10,7 +10,7 @@
"start": "node index.js" "start": "node index.js"
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"@polkadot/util": "0.30.3", "@polkadot/util": "0.30.3",
"@polkadot/util-keyring": "0.30.3" "@polkadot/util-keyring": "0.30.3"
}, },
+3 -3
View File
@@ -1,10 +1,10 @@
const BN = require('bn.js'); const BN = require('bn.js');
const Api = require('@polkadot/api').default; const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/api-provider/ws').default; const WsProvider = require('@polkadot/rpc-provider/ws').default;
const storage = require('@polkadot/storage').default; const storage = require('@polkadot/storage').default;
const provider = new WsProvider('ws://127.0.0.1:9944'); const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider); const api = new Rpc(provider);
async function getAccountIndex (address) { async function getAccountIndex (address) {
return api.state.getStorage([storage.system.public.accountIndexOf, address]); return api.state.getStorage([storage.system.public.accountIndexOf, address]);
+1 -1
View File
@@ -10,7 +10,7 @@
"start": "node index.js" "start": "node index.js"
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"bn.js": "^4.11.8" "bn.js": "^4.11.8"
}, },
"devDependencies": { "devDependencies": {
+3 -3
View File
@@ -1,6 +1,6 @@
const BN = require('bn.js'); const BN = require('bn.js');
const Api = require('@polkadot/api').default; const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/api-provider/ws').default; const WsProvider = require('@polkadot/rpc-provider/ws').default;
const extrinsics = require('@polkadot/extrinsics').default; const extrinsics = require('@polkadot/extrinsics').default;
const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode').default; const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode').default;
const encodeLength = require('@polkadot/extrinsics/codec/encode/length').default; const encodeLength = require('@polkadot/extrinsics/codec/encode/length').default;
@@ -10,7 +10,7 @@ const storage = require('@polkadot/storage').default;
const Encoder = new TextEncoder(); const Encoder = new TextEncoder();
const keyring = new Keyring(); const keyring = new Keyring();
const provider = new WsProvider('ws://127.0.0.1:9944'); const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider); const api = new Rpc(provider);
async function getAccountIndex (address) { async function getAccountIndex (address) {
return api.state.getStorage([storage.system.public.accountIndexOf, address]); return api.state.getStorage([storage.system.public.accountIndexOf, address]);
@@ -10,7 +10,7 @@
"start": "node index.js" "start": "node index.js"
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"bn.js": "^4.11.8" "bn.js": "^4.11.8"
}, },
"devDependencies": { "devDependencies": {
+3 -3
View File
@@ -1,6 +1,6 @@
const BN = require('bn.js'); const BN = require('bn.js');
const Api = require('@polkadot/api').default; const Rpc = require('@polkadot/rpc-core').default;
const WsProvider = require('@polkadot/api-provider/ws').default; const WsProvider = require('@polkadot/rpc-provider/ws').default;
const extrinsics = require('@polkadot/extrinsics').default; const extrinsics = require('@polkadot/extrinsics').default;
const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode/uncheckedLength').default; const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode/uncheckedLength').default;
const Keyring = require('@polkadot/util-keyring').default; const Keyring = require('@polkadot/util-keyring').default;
@@ -9,7 +9,7 @@ const storage = require('@polkadot/storage').default;
const Encoder = new TextEncoder(); const Encoder = new TextEncoder();
const keyring = new Keyring(); const keyring = new Keyring();
const provider = new WsProvider('ws://127.0.0.1:9944'); const provider = new WsProvider('ws://127.0.0.1:9944');
const api = new Api(provider); const api = new Rpc(provider);
async function getAccountIndex (address) { async function getAccountIndex (address) {
return api.state.getStorage([storage.system.public.accountIndexOf, address]); return api.state.getStorage([storage.system.public.accountIndexOf, address]);
+1 -1
View File
@@ -10,7 +10,7 @@
"start": "node index.js" "start": "node index.js"
}, },
"dependencies": { "dependencies": {
"@polkadot/api": "0.29.1", "@polkadot/rpc-core": "^0.31.1",
"bn.js": "^4.11.8" "bn.js": "^4.11.8"
}, },
"devDependencies": { "devDependencies": {
-8
View File
@@ -1,8 +0,0 @@
```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);
```
+8
View File
@@ -0,0 +1,8 @@
```javascript
import Rpc from '@polkadot/rpc-core';
import WsProvider from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('ws://127.0.0.1:9944');
const rpc = new Rpc(provider);
```
+2 -2
View File
@@ -2,8 +2,8 @@ const config = require('@polkadot/dev/config/jest');
module.exports = Object.assign({}, config, { module.exports = Object.assign({}, config, {
moduleNameMapper: { moduleNameMapper: {
'@polkadot/api-(jsonrpc|observable|provider|rx)(.*)$': '<rootDir>/packages/api-$1/src/$2', '@polkadot/api-observable(.*)$': '<rootDir>/packages/api-observable/src/$1',
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1', '@polkadot/rpc-(core|provider|rx)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/extrinsics(.*)$': '<rootDir>/packages/type-extrinsics/src/$1', '@polkadot/extrinsics(.*)$': '<rootDir>/packages/type-extrinsics/src/$1',
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1', '@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
'@polkadot/params(.*)$': '<rootDir>/packages/type-params/src/$1', '@polkadot/params(.*)$': '<rootDir>/packages/type-params/src/$1',
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [ "packages": [
"packages/*" "packages/*"
], ],
"version": "0.30.45" "version": "0.31.0"
} }
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"version": "0.30.45", "version": "0.31.0",
"private": true, "private": true,
"engines": { "engines": {
"node": "^10.1.0", "node": "^10.1.0",
+6 -6
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api-observable", "name": "@polkadot/api-observable",
"version": "0.30.45", "version": "0.31.0",
"description": "An Observable wrapper around the Polkadot JS API", "description": "An Observable wrapper around the Polkadot JS API",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
@@ -27,13 +27,13 @@
"bugs": { "bugs": {
"url": "https://github.com/polkadot-js/api/issues" "url": "https://github.com/polkadot-js/api/issues"
}, },
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-rx#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-rx#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.0.0", "@babel/runtime": "^7.0.0",
"@polkadot/api": "^0.30.45", "@polkadot/rpc-core": "^0.31.0",
"@polkadot/api-provider": "^0.30.45", "@polkadot/rpc-provider": "^0.31.0",
"@polkadot/extrinsics": "^0.30.45", "@polkadot/extrinsics": "^0.31.0",
"@polkadot/storage": "^0.30.45", "@polkadot/storage": "^0.31.0",
"@types/rx": "^4.1.1", "@types/rx": "^4.1.1",
"rxjs": "^6.3.2" "rxjs": "^6.3.2"
} }
+5 -5
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import { RxApiInterface, RxApiInterface$Method, RxApiInterface$Section } from '@polkadot/api-rx/types'; import { RxRpcInterface, RxRpcInterface$Method, RxRpcInterface$Section } from '@polkadot/rpc-rx/types';
import { RpcMethod } from '@polkadot/jsonrpc/types'; import { RpcMethod } from '@polkadot/jsonrpc/types';
import { EMPTY, Observable, combineLatest, from } from 'rxjs'; import { EMPTY, Observable, combineLatest, from } from 'rxjs';
@@ -25,13 +25,13 @@ const defaultMapFn = (result: any): any =>
// Raw base implementation for the observable API. It simply provides access to raw calls, allowing // Raw base implementation for the observable API. It simply provides access to raw calls, allowing
// decendants to make direct queries to either API methods or actual storage // decendants to make direct queries to either API methods or actual storage
export default class ApiBase { export default class ApiBase {
protected _api: RxApiInterface; protected _api: RxRpcInterface;
protected _genesisHash: Hash; protected _genesisHash: Hash;
// Observable that returns the first time we are connected and loaded // Observable that returns the first time we are connected and loaded
whenReady: Observable<boolean>; whenReady: Observable<boolean>;
constructor (api: RxApiInterface) { constructor (api: RxRpcInterface) {
this._api = api; this._api = api;
this._genesisHash = new Hash(); this._genesisHash = new Hash();
this.whenReady = from(this.init()); this.whenReady = from(this.init());
@@ -86,11 +86,11 @@ export default class ApiBase {
} }
rawCall = <T> ({ method, section }: RpcMethod, ...params: Array<any>): Observable<T> => { rawCall = <T> ({ method, section }: RpcMethod, ...params: Array<any>): Observable<T> => {
const apiSection = this._api[section as keyof RxApiInterface] as RxApiInterface$Section; const apiSection = this._api[section as keyof RxRpcInterface] as RxRpcInterface$Section;
assert(apiSection, `Unable to find 'api.${section}'`); assert(apiSection, `Unable to find 'api.${section}'`);
const fn: RxApiInterface$Method = apiSection[method]; const fn: RxRpcInterface$Method = apiSection[method];
assert(fn, `Unable to find 'api.${section}.${method}'`); assert(fn, `Unable to find 'api.${section}.${method}'`);
-22
View File
@@ -1,22 +0,0 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { BehaviorSubject, Observable } from 'rxjs';
import interfaces from '@polkadot/jsonrpc/types';
export type RxApiInterface$Method = (...params: Array<any>) => Observable<any> | BehaviorSubject<any>;
export type RxApiInterface$Section = {
[index: string]: RxApiInterface$Method
};
export type RxApiInterface = {
readonly author: RxApiInterface$Section;
readonly chain: RxApiInterface$Section;
readonly state: RxApiInterface$Section;
readonly system: RxApiInterface$Section;
isConnected: () => BehaviorSubject<boolean>
}
@@ -1,6 +1,6 @@
ISC License (ISC) ISC License (ISC)
Copyright 2017-2018 @polkadot/api authors & contributors Copyright 2017-2018 @polkadot/rpc-core authors & contributors
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@@ -5,8 +5,8 @@
[![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api)](https://david-dm.org/polkadot-js/api?path=packages/api) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api)](https://david-dm.org/polkadot-js/api?path=packages/api#info=devDependencies) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core#info=devDependencies)
# @polkadot/api # @polkadot/api
@@ -17,14 +17,14 @@ This library provides a clean wrapper around all the methods exposed by a Polkad
Installation - Installation -
``` ```
npm install --save @polkadot/api npm install --save @polkadot/rpc-core
``` ```
Initialisation - Initialisation -
```js ```js
import Api from '@polkadot/api'; import Api from '@polkadot/rpc-core';
import WsProvider from '@polkadot/api-provider/ws'; import WsProvider from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('http://127.0.0.1:9944'); const provider = new WsProvider('http://127.0.0.1:9944');
const api = new Api(provider); const api = new Api(provider);
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api", "name": "@polkadot/rpc-core",
"version": "0.30.45", "version": "0.31.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
@@ -27,11 +27,11 @@
"bugs": { "bugs": {
"url": "https://github.com/polkadot-js/api/issues" "url": "https://github.com/polkadot-js/api/issues"
}, },
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.0.0", "@babel/runtime": "^7.0.0",
"@polkadot/api-provider": "^0.30.45", "@polkadot/jsonrpc": "^0.31.0",
"@polkadot/jsonrpc": "^0.30.45", "@polkadot/rpc-provider": "^0.31.0",
"@polkadot/util": "^0.30.7" "@polkadot/util": "^0.30.7"
} }
} }
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api authors & contributors // Copyright 2017-2018 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api authors & contributors // Copyright 2017-2018 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,10 +1,10 @@
// Copyright 2017-2018 @polkadot/api authors & contributors // Copyright 2017-2018 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import { ProviderInterface, ProviderInterface$Callback } from '@polkadot/api-provider/types'; import { ProviderInterface, ProviderInterface$Callback } from '@polkadot/rpc-provider/types';
import { RpcSection, RpcMethod } from '@polkadot/jsonrpc/types'; import { RpcSection, RpcMethod } from '@polkadot/jsonrpc/types';
import { ApiInterface, ApiInterface$Section, ApiInterface$Section$Method } from './types'; import { RpcInterface, RpcInterface$Section, RpcInterface$Section$Method } from './types';
import interfaces from '@polkadot/jsonrpc/index'; import interfaces from '@polkadot/jsonrpc/index';
import extrinsicsFromMeta from '@polkadot/extrinsics/fromMetadata'; import extrinsicsFromMeta from '@polkadot/extrinsics/fromMetadata';
@@ -15,26 +15,26 @@ import ExtError from '@polkadot/util/ext/error';
import isFunction from '@polkadot/util/is/function'; import isFunction from '@polkadot/util/is/function';
/** /**
* @name Api * @name Rpc
* @summary The API may use a HTTP or WebSockets provider. * @summary The API may use a HTTP or WebSockets provider.
* @description It allows for querying a Polkadot Client Node. * @description It allows for querying a Polkadot Client Node.
* @example * @example
* <BR> * <BR>
* *
* ```javascript * ```javascript
* import Api from '@polkadot/api'; * import Api from '@polkadot/rpc-core';
* import WsProvider from '@polkadot/api-provider/ws'; * import WsProvider from '@polkadot/rpc-provider/ws';
* *
* const provider = new WsProvider('ws://127.0.0.1:9944'); * const provider = new WsProvider('ws://127.0.0.1:9944');
* const api = new Api(provider); * const api = new Api(provider);
* ``` * ```
*/ */
export default class Api implements ApiInterface { export default class Rpc implements RpcInterface {
private _provider: ProviderInterface; private _provider: ProviderInterface;
readonly author: ApiInterface$Section; readonly author: RpcInterface$Section;
readonly chain: ApiInterface$Section; readonly chain: RpcInterface$Section;
readonly state: ApiInterface$Section; readonly state: RpcInterface$Section;
readonly system: ApiInterface$Section; readonly system: RpcInterface$Section;
/** /**
* @constructor * @constructor
@@ -64,7 +64,7 @@ export default class Api implements ApiInterface {
* <BR> * <BR>
* *
* ```javascript * ```javascript
* import Api from '@polkadot/api'; * import Api from '@polkadot/rpc-core';
* *
* Api.signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' }); // => test_method (dest: Address): Address * Api.signature({ name: 'test_method', params: [ { name: 'dest', type: 'Address' } ], type: 'Address' }); // => test_method (dest: Address): Address
* ``` * ```
@@ -93,7 +93,7 @@ export default class Api implements ApiInterface {
}); });
} }
private createInterface ({ methods, section }: RpcSection): ApiInterface$Section { private createInterface ({ methods, section }: RpcSection): RpcInterface$Section {
return Object return Object
.keys(methods) .keys(methods)
.reduce((exposed, method) => { .reduce((exposed, method) => {
@@ -105,10 +105,10 @@ export default class Api implements ApiInterface {
: this.createMethodSend(rpcName, def); : this.createMethodSend(rpcName, def);
return exposed; return exposed;
}, {} as ApiInterface$Section); }, {} as RpcInterface$Section);
} }
private createMethodSend (rpcName: string, method: RpcMethod): ApiInterface$Section$Method { private createMethodSend (rpcName: string, method: RpcMethod): RpcInterface$Section$Method {
const call = async (...values: Array<any>): Promise<any> => { const call = async (...values: Array<any>): Promise<any> => {
// TODO Warn on deprecated methods // TODO Warn on deprecated methods
try { try {
@@ -118,7 +118,7 @@ export default class Api implements ApiInterface {
return this.formatOutput(method, params, result); return this.formatOutput(method, params, result);
} catch (error) { } catch (error) {
const message = `${Api.signature(method)}:: ${error.message}`; const message = `${Rpc.signature(method)}:: ${error.message}`;
console.error(message, error); console.error(message, error);
@@ -126,10 +126,10 @@ export default class Api implements ApiInterface {
} }
}; };
return call as ApiInterface$Section$Method; return call as RpcInterface$Section$Method;
} }
private createMethodSubscribe (rpcName: string, method: RpcMethod): ApiInterface$Section$Method { private createMethodSubscribe (rpcName: string, method: RpcMethod): RpcInterface$Section$Method {
const unsubscribe = (subscriptionId: any): Promise<any> => const unsubscribe = (subscriptionId: any): Promise<any> =>
this._provider.unsubscribe(rpcName, method.subscribe[1], subscriptionId); this._provider.unsubscribe(rpcName, method.subscribe[1], subscriptionId);
const _call = async (...values: Array<any>): Promise<any> => { const _call = async (...values: Array<any>): Promise<any> => {
@@ -146,7 +146,7 @@ export default class Api implements ApiInterface {
return this._provider.subscribe(rpcName, method.subscribe[0], paramsJson, update); return this._provider.subscribe(rpcName, method.subscribe[0], paramsJson, update);
} catch (error) { } catch (error) {
const message = `${Api.signature(method)}:: ${error.message}`; const message = `${Rpc.signature(method)}:: ${error.message}`;
console.error(message, error); console.error(message, error);
@@ -154,7 +154,7 @@ export default class Api implements ApiInterface {
} }
}; };
const call = _call as ApiInterface$Section$Method; const call = _call as RpcInterface$Section$Method;
call.unsubscribe = unsubscribe; call.unsubscribe = unsubscribe;
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api authors & contributors // Copyright 2017-2018 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,20 +1,20 @@
// Copyright 2017-2018 @polkadot/api authors & contributors // Copyright 2017-2018 @polkadot/rpc-core authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import interfaces from '@polkadot/jsonrpc/index'; import interfaces from '@polkadot/jsonrpc/index';
export interface ApiInterface$Section$Method { export interface RpcInterface$Section$Method {
(...params: Array<any>): Promise<any>; (...params: Array<any>): Promise<any>;
subscription: string; subscription: string;
unsubscribe: (id: number) => Promise<any>; unsubscribe: (id: number) => Promise<any>;
} }
export type ApiInterface$Section = { export type RpcInterface$Section = {
[index: string]: ApiInterface$Section$Method [index: string]: RpcInterface$Section$Method
}; };
export type ApiInterface = { export type RpcInterface = {
readonly [key in keyof typeof interfaces]: ApiInterface$Section readonly [key in keyof typeof interfaces]: RpcInterface$Section
} }
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import Api from '../../src'; import Api from '../../src';
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import Api from '../../src'; import Api from '../../src';
@@ -3,7 +3,7 @@
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import storage from '@polkadot/storage'; import storage from '@polkadot/storage';
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import Api from '../../src'; import Api from '../../src';
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import storage from '@polkadot/storage/static'; import storage from '@polkadot/storage/static';
import Api from '../../src'; import Api from '../../src';
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import storage from '@polkadot/storage/static'; import storage from '@polkadot/storage/static';
import Api from '../../src'; import Api from '../../src';
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,6 +1,6 @@
ISC License (ISC) ISC License (ISC)
Copyright 2017-2018 @polkadot/api-provider authors & contributors Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@@ -1,14 +1,14 @@
[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org) [![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org)
![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square) ![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square)
[![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard) [![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard)
[![npm](https://img.shields.io/npm/v/@polkadot/api-provider.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api-provider) [![npm](https://img.shields.io/npm/v/@polkadot/rpc-provider.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/rpc-provider)
[![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api-provider)](https://david-dm.org/polkadot-js/api?path=packages/api-provider) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/rpc-provider)](https://david-dm.org/polkadot-js/api?path=packages/rpc-provider)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api-provider)](https://david-dm.org/polkadot-js/api?path=packages/api-provider#info=devDependencies) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/rpc-provider)](https://david-dm.org/polkadot-js/api?path=packages/rpc-provider#info=devDependencies)
# @polkadot/api-provider # @polkadot/rpc-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. 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.
@@ -17,13 +17,13 @@ Generic transport providers to handle the transport of method calls to and from
Installation - Installation -
``` ```
npm install --save @polkadot/api-provider npm install --save @polkadot/rpc-provider
``` ```
Initialisation - Initialisation -
```js ```js
import WsProvider from '@polkadot/api-provider/ws'; import WsProvider from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('http://127.0.0.1:9944'); const provider = new WsProvider('http://127.0.0.1:9944');
const version = await provider.send('client_version', []); const version = await provider.send('client_version', []);
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api-provider", "name": "@polkadot/rpc-provider",
"version": "0.30.45", "version": "0.31.0",
"description": "Transport providers for the API", "description": "Transport providers for the API",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
@@ -27,10 +27,10 @@
"bugs": { "bugs": {
"url": "https://github.com/polkadot-js/api/issues" "url": "https://github.com/polkadot-js/api/issues"
}, },
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-provider#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.0.0", "@babel/runtime": "^7.0.0",
"@polkadot/storage": "^0.30.45", "@polkadot/storage": "^0.31.0",
"@polkadot/util": "^0.30.7", "@polkadot/util": "^0.30.7",
"@polkadot/util-crypto": "^0.30.7", "@polkadot/util-crypto": "^0.30.7",
"@polkadot/util-keyring": "^0.30.7", "@polkadot/util-keyring": "^0.30.7",
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -25,8 +25,8 @@ const ERROR_SUBSCRIBE = 'HTTP Provider does not have subscriptions, use WebSocke
* <BR> * <BR>
* *
* ```javascript * ```javascript
* import Api from '@polkadot/api'; * import Api from '@polkadot/rpc-core';
* import HttpProvider from '@polkadot/api-provider/http'; * import HttpProvider from '@polkadot/rpc-provider/http';
* *
* const provider = new HttpProvider('http://127.0.0.1:9933'); * const provider = new HttpProvider('http://127.0.0.1:9933');
* const api = new Api(provider); * const api = new Api(provider);
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -46,8 +46,8 @@ interface WSProviderInterface extends ProviderInterface {
* <BR> * <BR>
* *
* ```javascript * ```javascript
* import Api from '@polkadot/api'; * import Api from '@polkadot/rpc-core';
* import WsProvider from '@polkadot/api-provider/ws'; * import WsProvider from '@polkadot/rpc-provider/ws';
* *
* const provider = new WsProvider('ws://127.0.0.1:9944'); * const provider = new WsProvider('ws://127.0.0.1:9944');
* const api = new Api(provider); * const api = new Api(provider);
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-provider authors & contributors // Copyright 2017-2018 @polkadot/rpc-provider authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,6 +1,6 @@
ISC License (ISC) ISC License (ISC)
Copyright 2017-2018 @polkadot/api-rx authors & contributors Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@@ -1,13 +1,13 @@
[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org) [![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org)
![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square) ![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square)
[![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard) [![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard)
[![npm](https://img.shields.io/npm/v/@polkadot/api-rx.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api-rx) [![npm](https://img.shields.io/npm/v/@polkadot/rpc-rx.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/rpc-rx)
[![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api) [![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability) [![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master) [![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api-rx)](https://david-dm.org/polkadot-js/api?path=packages/api-rx) [![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/rpc-rx)](https://david-dm.org/polkadot-js/api?path=packages/rpc-rx)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api-rx)](https://david-dm.org/polkadot-js/api?path=packages/api-rx#info=devDependencies) [![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/rpc-rx)](https://david-dm.org/polkadot-js/api?path=packages/rpc-rx#info=devDependencies)
# @polkadot/api-rx # @polkadot/rpc-rx
An RxJs wrapper around the [@polkadot/api](../api). An RxJs wrapper around the [@polkadot/api](../api).
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api-rx", "name": "@polkadot/rpc-rx",
"version": "0.30.45", "version": "0.31.0",
"description": "An RxJs wrapper around the Polkadot JS API", "description": "An RxJs wrapper around the Polkadot JS API",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
@@ -27,11 +27,11 @@
"bugs": { "bugs": {
"url": "https://github.com/polkadot-js/api/issues" "url": "https://github.com/polkadot-js/api/issues"
}, },
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-rx#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-rx#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.0.0", "@babel/runtime": "^7.0.0",
"@polkadot/api": "^0.30.45", "@polkadot/rpc-core": "^0.31.0",
"@polkadot/api-provider": "^0.30.45", "@polkadot/rpc-provider": "^0.31.0",
"@types/rx": "^4.1.1", "@types/rx": "^4.1.1",
"rxjs": "^6.3.2" "rxjs": "^6.3.2"
} }
@@ -1,8 +1,8 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors // Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
jest.mock('@polkadot/api-provider/ws', () => class { jest.mock('@polkadot/rpc-provider/ws', () => class {
isConnected = () => true; isConnected = () => true;
on = () => true; on = () => true;
send = () => true; send = () => true;
@@ -1,4 +1,4 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors // Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
@@ -1,10 +1,10 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors // Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import isFunction from '@polkadot/util/is/function'; import isFunction from '@polkadot/util/is/function';
jest.mock('@polkadot/api-provider/ws', () => class { jest.mock('@polkadot/rpc-provider/ws', () => class {
isConnected = () => true; isConnected = () => true;
on = () => true; on = () => true;
send = () => true; send = () => true;
@@ -1,14 +1,14 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors // Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import { ApiInterface, ApiInterface$Section } from '@polkadot/api/types'; import { RpcInterface, RpcInterface$Section } from '@polkadot/rpc-core/types';
import { ProviderInterface } from '@polkadot/api-provider/types'; import { ProviderInterface } from '@polkadot/rpc-provider/types';
import { RxApiInterface, RxApiInterface$Section } from './types'; import { RxRpcInterface, RxRpcInterface$Section } from './types';
import { BehaviorSubject, Observable, Subscriber, from } from 'rxjs'; import { BehaviorSubject, Observable, Subscriber, from } from 'rxjs';
import Api from '@polkadot/api/index'; import Rpc from '@polkadot/rpc-core/index';
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import isFunction from '@polkadot/util/is/function'; import isFunction from '@polkadot/util/is/function';
import isUndefined from '@polkadot/util/is/undefined'; import isUndefined from '@polkadot/util/is/undefined';
@@ -21,7 +21,7 @@ type CachedMap = {
}; };
/** /**
* @name RxApi * @name RpcRx
* @summary The RxJS API is a wrapper around the API. * @summary The RxJS API is a wrapper around the API.
* @description It allows wrapping API components with observables using RxJS. * @description It allows wrapping API components with observables using RxJS.
* *
@@ -29,27 +29,27 @@ type CachedMap = {
* <BR> * <BR>
* *
* ```javascript * ```javascript
* import RxApi from '@polkadot/api'; * import Rpc from '@polkadot/rpc-rx';
* import WsProvider from '@polkadot/api-provider/ws'; * import WsProvider from '@polkadot/rpc-provider/ws';
* *
* const provider = new WsProvider('http://127.0.0.1:9944'); * const provider = new WsProvider('http://127.0.0.1:9944');
* const rxapi = new RxApi(provider); * const api = new Rpc(provider);
* ``` * ```
*/ */
export default class RxApi implements RxApiInterface { export default class RpcRx implements RxRpcInterface {
private _api: ApiInterface; private _api: RpcInterface;
private _cacheMap: CachedMap; private _cacheMap: CachedMap;
private _isConnected: BehaviorSubject<boolean>; private _isConnected: BehaviorSubject<boolean>;
readonly author: RxApiInterface$Section; readonly author: RxRpcInterface$Section;
readonly chain: RxApiInterface$Section; readonly chain: RxRpcInterface$Section;
readonly state: RxApiInterface$Section; readonly state: RxRpcInterface$Section;
readonly system: RxApiInterface$Section; readonly system: RxRpcInterface$Section;
/** /**
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket * @param {ProviderInterface} provider An API provider using HTTP or WebSocket
*/ */
constructor (provider: ProviderInterface = new Ws(defaults.WS_URL)) { constructor (provider: ProviderInterface = new Ws(defaults.WS_URL)) {
this._api = new Api(provider); this._api = new Rpc(provider);
this._cacheMap = {}; this._cacheMap = {};
this._isConnected = new BehaviorSubject(provider.isConnected()); this._isConnected = new BehaviorSubject(provider.isConnected());
@@ -66,7 +66,7 @@ export default class RxApi implements RxApiInterface {
return this._isConnected; return this._isConnected;
} }
private createInterface (sectionName: string, section: ApiInterface$Section): RxApiInterface$Section { private createInterface (sectionName: string, section: RpcInterface$Section): RxRpcInterface$Section {
return Object return Object
.keys(section) .keys(section)
.filter((name) => !['subscribe', 'unsubscribe'].includes(name)) .filter((name) => !['subscribe', 'unsubscribe'].includes(name))
@@ -74,10 +74,10 @@ export default class RxApi implements RxApiInterface {
observables[name] = this.createObservable(`${sectionName}_${name}`, name, section); observables[name] = this.createObservable(`${sectionName}_${name}`, name, section);
return observables; return observables;
}, ({} as RxApiInterface$Section)); }, ({} as RxRpcInterface$Section));
} }
private createObservable (subName: string, name: string, section: ApiInterface$Section): (...params: Array<any>) => Observable<any> | BehaviorSubject<any> { private createObservable (subName: string, name: string, section: RpcInterface$Section): (...params: Array<any>) => Observable<any> | BehaviorSubject<any> {
if (isFunction(section[name].unsubscribe)) { if (isFunction(section[name].unsubscribe)) {
return this.createCachedObservable(subName, name, section); return this.createCachedObservable(subName, name, section);
} }
@@ -92,7 +92,7 @@ export default class RxApi implements RxApiInterface {
); );
} }
private createCachedObservable (subName: string, name: string, section: ApiInterface$Section): (...params: Array<any>) => BehaviorSubject<any> { private createCachedObservable (subName: string, name: string, section: RpcInterface$Section): (...params: Array<any>) => BehaviorSubject<any> {
if (!this._cacheMap[subName]) { if (!this._cacheMap[subName]) {
this._cacheMap[subName] = {}; this._cacheMap[subName] = {};
} }
@@ -108,7 +108,7 @@ export default class RxApi implements RxApiInterface {
}; };
} }
private createSubject (name: string, params: Array<any>, section: ApiInterface$Section, unsubCallback?: () => void): BehaviorSubject<any> { private createSubject (name: string, params: Array<any>, section: RpcInterface$Section, unsubCallback?: () => void): BehaviorSubject<any> {
const subject = new BehaviorSubject(undefined); const subject = new BehaviorSubject(undefined);
Observable Observable
@@ -1,8 +1,8 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors // Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
jest.mock('@polkadot/api-provider/ws', () => class { jest.mock('@polkadot/rpc-provider/ws', () => class {
isConnected = () => true; isConnected = () => true;
on = () => true; on = () => true;
send = () => true; send = () => true;
+22
View File
@@ -0,0 +1,22 @@
// Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { BehaviorSubject, Observable } from 'rxjs';
import interfaces from '@polkadot/jsonrpc/types';
export type RxRpcInterface$Method = (...params: Array<any>) => Observable<any> | BehaviorSubject<any>;
export type RxRpcInterface$Section = {
[index: string]: RxRpcInterface$Method
};
export type RxRpcInterface = {
readonly author: RxRpcInterface$Section;
readonly chain: RxRpcInterface$Section;
readonly state: RxRpcInterface$Section;
readonly system: RxRpcInterface$Section;
isConnected: () => BehaviorSubject<boolean>
}
@@ -1,8 +1,8 @@
// Copyright 2017-2018 @polkadot/api-rx authors & contributors // Copyright 2017-2018 @polkadot/rpc-rx authors & contributors
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws'; import Ws from '@polkadot/rpc-provider/ws';
import storage from '@polkadot/storage/static'; import storage from '@polkadot/storage/static';
import RxApi from '../../src'; import RxApi from '../../src';
View File
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/extrinsics", "name": "@polkadot/extrinsics",
"version": "0.30.45", "version": "0.31.0",
"main": "index.js", "main": "index.js",
"repository": "https://github.com/polkadot-js/api.git", "repository": "https://github.com/polkadot-js/api.git",
"author": "Jaco Greeff <jacogr@gmail.com>", "author": "Jaco Greeff <jacogr@gmail.com>",
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms // This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details. // of the ISC license. See the LICENSE file for details.
import Api from '@polkadot/api'; import Api from '@polkadot/rpc-core';
import Ws from '@polkadot/rpc-provider/ws';
import testingPairs from '@polkadot/util-keyring/testingPairs'; import testingPairs from '@polkadot/util-keyring/testingPairs';
import Ws from '@polkadot/api-provider/ws';
import extrinsics from '../../src/static'; import extrinsics from '../../src/static';
View File
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/jsonrpc", "name": "@polkadot/jsonrpc",
"version": "0.30.45", "version": "0.31.0",
"description": "Method definitions for the Polkadot RPC layer", "description": "Method definitions for the Polkadot RPC layer",
"main": "index.js", "main": "index.js",
"engines": { "engines": {
View File
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/storage", "name": "@polkadot/storage",
"version": "0.30.45", "version": "0.31.0",
"description": "Generic wrapper wrapper around state storage", "description": "Generic wrapper wrapper around state storage",
"main": "index.js", "main": "index.js",
"engines": { "engines": {
@@ -32,7 +32,7 @@
"@babel/runtime": "^7.0.0", "@babel/runtime": "^7.0.0",
"@polkadot/params": "^0.30.3", "@polkadot/params": "^0.30.3",
"@polkadot/primitives": "^0.30.3", "@polkadot/primitives": "^0.30.3",
"@polkadot/types": "^0.30.45", "@polkadot/types": "^0.31.0",
"@polkadot/util": "^0.30.7", "@polkadot/util": "^0.30.7",
"@polkadot/util-crypto": "^0.30.7", "@polkadot/util-crypto": "^0.30.7",
"@polkadot/util-keyring": "^0.30.7" "@polkadot/util-keyring": "^0.30.7"
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/types", "name": "@polkadot/types",
"version": "0.30.45", "version": "0.31.0",
"description": "Implementation of the Parity codec", "description": "Implementation of the Parity codec",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [

Some files were not shown because too many files have changed in this diff Show More