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
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-observable",
"version": "0.30.45",
"version": "0.31.0",
"description": "An Observable wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
@@ -27,13 +27,13 @@
"bugs": {
"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": {
"@babel/runtime": "^7.0.0",
"@polkadot/api": "^0.30.45",
"@polkadot/api-provider": "^0.30.45",
"@polkadot/extrinsics": "^0.30.45",
"@polkadot/storage": "^0.30.45",
"@polkadot/rpc-core": "^0.31.0",
"@polkadot/rpc-provider": "^0.31.0",
"@polkadot/extrinsics": "^0.31.0",
"@polkadot/storage": "^0.31.0",
"@types/rx": "^4.1.1",
"rxjs": "^6.3.2"
}
+5 -5
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { 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 { 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
// decendants to make direct queries to either API methods or actual storage
export default class ApiBase {
protected _api: RxApiInterface;
protected _api: RxRpcInterface;
protected _genesisHash: Hash;
// Observable that returns the first time we are connected and loaded
whenReady: Observable<boolean>;
constructor (api: RxApiInterface) {
constructor (api: RxRpcInterface) {
this._api = api;
this._genesisHash = new Hash();
this.whenReady = from(this.init());
@@ -86,11 +86,11 @@ export default class ApiBase {
}
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}'`);
const fn: RxApiInterface$Method = apiSection[method];
const fn: RxRpcInterface$Method = apiSection[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)
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
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)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api)](https://david-dm.org/polkadot-js/api?path=packages/api)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api)](https://david-dm.org/polkadot-js/api?path=packages/api#info=devDependencies)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=package/rpc-core)](https://david-dm.org/polkadot-js/api?path=package/rpc-core#info=devDependencies)
# @polkadot/api
@@ -17,14 +17,14 @@ This library provides a clean wrapper around all the methods exposed by a Polkad
Installation -
```
npm install --save @polkadot/api
npm install --save @polkadot/rpc-core
```
Initialisation -
```js
import Api from '@polkadot/api';
import WsProvider from '@polkadot/api-provider/ws';
import Api from '@polkadot/rpc-core';
import WsProvider from '@polkadot/rpc-provider/ws';
const provider = new WsProvider('http://127.0.0.1:9944');
const api = new Api(provider);
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "0.30.45",
"name": "@polkadot/rpc-core",
"version": "0.31.0",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"keywords": [
@@ -27,11 +27,11 @@
"bugs": {
"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": {
"@babel/runtime": "^7.0.0",
"@polkadot/api-provider": "^0.30.45",
"@polkadot/jsonrpc": "^0.30.45",
"@polkadot/jsonrpc": "^0.31.0",
"@polkadot/rpc-provider": "^0.31.0",
"@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
// 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
// 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
// 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 { ApiInterface, ApiInterface$Section, ApiInterface$Section$Method } from './types';
import { RpcInterface, RpcInterface$Section, RpcInterface$Section$Method } from './types';
import interfaces from '@polkadot/jsonrpc/index';
import extrinsicsFromMeta from '@polkadot/extrinsics/fromMetadata';
@@ -15,26 +15,26 @@ import ExtError from '@polkadot/util/ext/error';
import isFunction from '@polkadot/util/is/function';
/**
* @name Api
* @name Rpc
* @summary The API may use a HTTP or WebSockets provider.
* @description It allows for querying a Polkadot Client Node.
* @example
* <BR>
*
* ```javascript
* import Api from '@polkadot/api';
* import WsProvider from '@polkadot/api-provider/ws';
* import Api from '@polkadot/rpc-core';
* import WsProvider from '@polkadot/rpc-provider/ws';
*
* const provider = new WsProvider('ws://127.0.0.1:9944');
* const api = new Api(provider);
* ```
*/
export default class Api implements ApiInterface {
export default class Rpc implements RpcInterface {
private _provider: ProviderInterface;
readonly author: ApiInterface$Section;
readonly chain: ApiInterface$Section;
readonly state: ApiInterface$Section;
readonly system: ApiInterface$Section;
readonly author: RpcInterface$Section;
readonly chain: RpcInterface$Section;
readonly state: RpcInterface$Section;
readonly system: RpcInterface$Section;
/**
* @constructor
@@ -64,7 +64,7 @@ export default class Api implements ApiInterface {
* <BR>
*
* ```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
* ```
@@ -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
.keys(methods)
.reduce((exposed, method) => {
@@ -105,10 +105,10 @@ export default class Api implements ApiInterface {
: this.createMethodSend(rpcName, def);
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> => {
// TODO Warn on deprecated methods
try {
@@ -118,7 +118,7 @@ export default class Api implements ApiInterface {
return this.formatOutput(method, params, result);
} catch (error) {
const message = `${Api.signature(method)}:: ${error.message}`;
const message = `${Rpc.signature(method)}:: ${error.message}`;
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> =>
this._provider.unsubscribe(rpcName, method.subscribe[1], subscriptionId);
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);
} catch (error) {
const message = `${Api.signature(method)}:: ${error.message}`;
const message = `${Rpc.signature(method)}:: ${error.message}`;
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;
@@ -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
// 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
// of the ISC license. See the LICENSE file for details.
import interfaces from '@polkadot/jsonrpc/index';
export interface ApiInterface$Section$Method {
export interface RpcInterface$Section$Method {
(...params: Array<any>): Promise<any>;
subscription: string;
unsubscribe: (id: number) => Promise<any>;
}
export type ApiInterface$Section = {
[index: string]: ApiInterface$Section$Method
export type RpcInterface$Section = {
[index: string]: RpcInterface$Section$Method
};
export type ApiInterface = {
readonly [key in keyof typeof interfaces]: ApiInterface$Section
export type RpcInterface = {
readonly [key in keyof typeof interfaces]: RpcInterface$Section
}
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws';
import Ws from '@polkadot/rpc-provider/ws';
import Api from '../../src';
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws';
import Ws from '@polkadot/rpc-provider/ws';
import Api from '../../src';
@@ -3,7 +3,7 @@
// of the ISC license. See the LICENSE file for details.
import storage from '@polkadot/storage';
import Ws from '@polkadot/api-provider/ws';
import Ws from '@polkadot/rpc-provider/ws';
import Api from '../../src';
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws';
import Ws from '@polkadot/rpc-provider/ws';
import storage from '@polkadot/storage/static';
import Api from '../../src';
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import Ws from '@polkadot/api-provider/ws';
import Ws from '@polkadot/rpc-provider/ws';
import storage from '@polkadot/storage/static';
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
// 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
// of the ISC license. See the LICENSE file for details.
@@ -1,6 +1,6 @@
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
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)
![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square)
[![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard)
[![npm](https://img.shields.io/npm/v/@polkadot/api-provider.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api-provider)
[![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)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api-provider)](https://david-dm.org/polkadot-js/api?path=packages/api-provider)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api-provider)](https://david-dm.org/polkadot-js/api?path=packages/api-provider#info=devDependencies)
[![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/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.
@@ -17,13 +17,13 @@ Generic transport providers to handle the transport of method calls to and from
Installation -
```
npm install --save @polkadot/api-provider
npm install --save @polkadot/rpc-provider
```
Initialisation -
```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 version = await provider.send('client_version', []);
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-provider",
"version": "0.30.45",
"name": "@polkadot/rpc-provider",
"version": "0.31.0",
"description": "Transport providers for the API",
"main": "index.js",
"keywords": [
@@ -27,10 +27,10 @@
"bugs": {
"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": {
"@babel/runtime": "^7.0.0",
"@polkadot/storage": "^0.30.45",
"@polkadot/storage": "^0.31.0",
"@polkadot/util": "^0.30.7",
"@polkadot/util-crypto": "^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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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>
*
* ```javascript
* import Api from '@polkadot/api';
* import HttpProvider from '@polkadot/api-provider/http';
* import Api from '@polkadot/rpc-core';
* import HttpProvider from '@polkadot/rpc-provider/http';
*
* const provider = new HttpProvider('http://127.0.0.1:9933');
* const api = new Api(provider);
@@ -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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// of the ISC license. See the LICENSE file for details.
@@ -46,8 +46,8 @@ interface WSProviderInterface extends ProviderInterface {
* <BR>
*
* ```javascript
* import Api from '@polkadot/api';
* import WsProvider from '@polkadot/api-provider/ws';
* import Api from '@polkadot/rpc-core';
* import WsProvider from '@polkadot/rpc-provider/ws';
*
* const provider = new WsProvider('ws://127.0.0.1:9944');
* const api = new Api(provider);
@@ -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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// 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
// of the ISC license. See the LICENSE file for details.
@@ -1,6 +1,6 @@
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
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)
![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square)
[![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard)
[![npm](https://img.shields.io/npm/v/@polkadot/api-rx.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/api-rx)
[![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)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/api-rx)](https://david-dm.org/polkadot-js/api?path=packages/api-rx)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/api-rx)](https://david-dm.org/polkadot-js/api?path=packages/api-rx#info=devDependencies)
[![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/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).
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-rx",
"version": "0.30.45",
"name": "@polkadot/rpc-rx",
"version": "0.31.0",
"description": "An RxJs wrapper around the Polkadot JS API",
"main": "index.js",
"keywords": [
@@ -27,11 +27,11 @@
"bugs": {
"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": {
"@babel/runtime": "^7.0.0",
"@polkadot/api": "^0.30.45",
"@polkadot/api-provider": "^0.30.45",
"@polkadot/rpc-core": "^0.31.0",
"@polkadot/rpc-provider": "^0.31.0",
"@types/rx": "^4.1.1",
"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
// 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;
on = () => 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
// 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
// of the ISC license. See the LICENSE file for details.
import isFunction from '@polkadot/util/is/function';
jest.mock('@polkadot/api-provider/ws', () => class {
jest.mock('@polkadot/rpc-provider/ws', () => class {
isConnected = () => true;
on = () => 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
// of the ISC license. See the LICENSE file for details.
import { ApiInterface, ApiInterface$Section } from '@polkadot/api/types';
import { ProviderInterface } from '@polkadot/api-provider/types';
import { RxApiInterface, RxApiInterface$Section } from './types';
import { RpcInterface, RpcInterface$Section } from '@polkadot/rpc-core/types';
import { ProviderInterface } from '@polkadot/rpc-provider/types';
import { RxRpcInterface, RxRpcInterface$Section } from './types';
import { BehaviorSubject, Observable, Subscriber, from } from 'rxjs';
import Api from '@polkadot/api/index';
import Ws from '@polkadot/api-provider/ws';
import Rpc from '@polkadot/rpc-core/index';
import Ws from '@polkadot/rpc-provider/ws';
import isFunction from '@polkadot/util/is/function';
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.
* @description It allows wrapping API components with observables using RxJS.
*
@@ -29,27 +29,27 @@ type CachedMap = {
* <BR>
*
* ```javascript
* import RxApi from '@polkadot/api';
* import WsProvider from '@polkadot/api-provider/ws';
* import Rpc from '@polkadot/rpc-rx';
* import WsProvider from '@polkadot/rpc-provider/ws';
*
* 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 {
private _api: ApiInterface;
export default class RpcRx implements RxRpcInterface {
private _api: RpcInterface;
private _cacheMap: CachedMap;
private _isConnected: BehaviorSubject<boolean>;
readonly author: RxApiInterface$Section;
readonly chain: RxApiInterface$Section;
readonly state: RxApiInterface$Section;
readonly system: RxApiInterface$Section;
readonly author: RxRpcInterface$Section;
readonly chain: RxRpcInterface$Section;
readonly state: RxRpcInterface$Section;
readonly system: RxRpcInterface$Section;
/**
* @param {ProviderInterface} provider An API provider using HTTP or WebSocket
*/
constructor (provider: ProviderInterface = new Ws(defaults.WS_URL)) {
this._api = new Api(provider);
this._api = new Rpc(provider);
this._cacheMap = {};
this._isConnected = new BehaviorSubject(provider.isConnected());
@@ -66,7 +66,7 @@ export default class RxApi implements RxApiInterface {
return this._isConnected;
}
private createInterface (sectionName: string, section: ApiInterface$Section): RxApiInterface$Section {
private createInterface (sectionName: string, section: RpcInterface$Section): RxRpcInterface$Section {
return Object
.keys(section)
.filter((name) => !['subscribe', 'unsubscribe'].includes(name))
@@ -74,10 +74,10 @@ export default class RxApi implements RxApiInterface {
observables[name] = this.createObservable(`${sectionName}_${name}`, name, section);
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)) {
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]) {
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);
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
// 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;
on = () => 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
// 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 RxApi from '../../src';
View File
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/extrinsics",
"version": "0.30.45",
"version": "0.31.0",
"main": "index.js",
"repository": "https://github.com/polkadot-js/api.git",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -2,9 +2,9 @@
// This software may be modified and distributed under the terms
// 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 Ws from '@polkadot/api-provider/ws';
import extrinsics from '../../src/static';
View File
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/jsonrpc",
"version": "0.30.45",
"version": "0.31.0",
"description": "Method definitions for the Polkadot RPC layer",
"main": "index.js",
"engines": {
View File
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/storage",
"version": "0.30.45",
"version": "0.31.0",
"description": "Generic wrapper wrapper around state storage",
"main": "index.js",
"engines": {
@@ -32,7 +32,7 @@
"@babel/runtime": "^7.0.0",
"@polkadot/params": "^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-crypto": "^0.30.7",
"@polkadot/util-keyring": "^0.30.7"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "0.30.45",
"version": "0.31.0",
"description": "Implementation of the Parity codec",
"main": "index.js",
"keywords": [