diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index 797c99da05..94d7ad6073 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -1,12 +1,12 @@ ## Packages -- [api](api/README.md) - - [Api](api/classes/_index_.api.md) -- [api-provider](api-provider/README.md) - - [HttpProvider](api-provider/classes/_http_index_.httpprovider.md) - - [WsProvider](api-provider/classes/_ws_index_.wsprovider.md) -- [api-rx](api-rx/README.md) - - [ApiRx](api-rx/classes/_index_.rxapi.md) +- [rpc-core](rpc-core/README.md) + - [Rpc](rpc-core/classes/_index_.rpc.md) +- [rpc-provider](rpc-provider/README.md) + - [HttpProvider](rpc-provider/classes/_http_index_.httpprovider.md) + - [WsProvider](rpc-provider/classes/_ws_index_.wsprovider.md) +- [rpc-rx](rpc-rx/README.md) + - [RpcRx](rpc-rx/classes/_index_.rxapi.md) ## Examples diff --git a/docs/examples/01_simple_connect/index.js b/docs/examples/01_simple_connect/index.js index d6cf71571e..166b720e7f 100755 --- a/docs/examples/01_simple_connect/index.js +++ b/docs/examples/01_simple_connect/index.js @@ -1,7 +1,7 @@ -const Api = require('@polkadot/api').default; -const WsProvider = require('@polkadot/api-provider/ws').default; +const Rpc = require('@polkadot/rpc-core').default; +const WsProvider = require('@polkadot/rpc-provider/ws').default; const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); async function getChain () { return api.system.chain(); diff --git a/docs/examples/01_simple_connect/package.json b/docs/examples/01_simple_connect/package.json index bdbfd99ff2..a6bad168b0 100644 --- a/docs/examples/01_simple_connect/package.json +++ b/docs/examples/01_simple_connect/package.json @@ -11,8 +11,8 @@ }, "dependencies": { - "@polkadot/api": "0.29.1", - "@polkadot/api-provider": "^0.29.1" + "@polkadot/rpc-core": "^0.31.1", + "@polkadot/rpc-provider": "^0.31.1" }, "devDependencies": { "rimraf": "^2.6.2" diff --git a/docs/examples/02_listen_to_blocks/index.js b/docs/examples/02_listen_to_blocks/index.js index 6b708d6c52..11ee1ed17b 100755 --- a/docs/examples/02_listen_to_blocks/index.js +++ b/docs/examples/02_listen_to_blocks/index.js @@ -1,8 +1,8 @@ const BN = require('bn.js'); -const Api = require('@polkadot/api').default; -const WsProvider = require('@polkadot/api-provider/ws').default; +const Rpc = require('@polkadot/rpc-core').default; +const WsProvider = require('@polkadot/rpc-provider/ws').default; const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); function main () { console.log('Blocks will be shown as they come in, CTRL+C to stop:'); diff --git a/docs/examples/02_listen_to_blocks/package.json b/docs/examples/02_listen_to_blocks/package.json index 50e21797a5..06ef3515ff 100644 --- a/docs/examples/02_listen_to_blocks/package.json +++ b/docs/examples/02_listen_to_blocks/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "0.29.1", + "@polkadot/rpc-core": "^0.31.1", "bn.js": "^4.11.8" }, "devDependencies": { diff --git a/docs/examples/03_listen_to_balance_change/index.js b/docs/examples/03_listen_to_balance_change/index.js index c87522518e..7ac81fc77b 100755 --- a/docs/examples/03_listen_to_balance_change/index.js +++ b/docs/examples/03_listen_to_balance_change/index.js @@ -1,9 +1,10 @@ const BN = require('bn.js'); -const Api = require('@polkadot/api').default; -const WsProvider = require('@polkadot/api-provider/ws').default; +const Rpc = require('@polkadot/rpc-core').default; +const WsProvider = require('@polkadot/rpc-provider/ws').default; const storage = require('@polkadot/storage').default; const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); + const Alice = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ'; console.log('You may leave this example running and start example 06 or send DOTs to ' + Alice); diff --git a/docs/examples/03_listen_to_balance_change/package.json b/docs/examples/03_listen_to_balance_change/package.json index 050b3fec31..a298c02816 100644 --- a/docs/examples/03_listen_to_balance_change/package.json +++ b/docs/examples/03_listen_to_balance_change/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "0.29.1", + "@polkadot/rpc-core": "^0.31.1", "bn.js": "^4.11.8" }, "devDependencies": { diff --git a/docs/examples/04_generate_account/package.json b/docs/examples/04_generate_account/package.json index ba36320c6e..b06a27f1c4 100644 --- a/docs/examples/04_generate_account/package.json +++ b/docs/examples/04_generate_account/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "0.29.1", + "@polkadot/rpc-core": "^0.31.1", "@polkadot/util": "0.30.3", "@polkadot/util-keyring": "0.30.3" }, diff --git a/docs/examples/05_read_storage/index.js b/docs/examples/05_read_storage/index.js index 1e71dfc313..23e3250ea1 100755 --- a/docs/examples/05_read_storage/index.js +++ b/docs/examples/05_read_storage/index.js @@ -1,10 +1,10 @@ const BN = require('bn.js'); -const Api = require('@polkadot/api').default; -const WsProvider = require('@polkadot/api-provider/ws').default; +const Rpc = require('@polkadot/rpc-core').default; +const WsProvider = require('@polkadot/rpc-provider/ws').default; const storage = require('@polkadot/storage').default; const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); async function getAccountIndex (address) { return api.state.getStorage([storage.system.public.accountIndexOf, address]); diff --git a/docs/examples/05_read_storage/package.json b/docs/examples/05_read_storage/package.json index 1b65dd2367..abb7ca6b75 100644 --- a/docs/examples/05_read_storage/package.json +++ b/docs/examples/05_read_storage/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "0.29.1", + "@polkadot/rpc-core": "^0.31.1", "bn.js": "^4.11.8" }, "devDependencies": { diff --git a/docs/examples/06_craft_extrinsic/index.js b/docs/examples/06_craft_extrinsic/index.js index d35f2b1234..fb36f722bc 100755 --- a/docs/examples/06_craft_extrinsic/index.js +++ b/docs/examples/06_craft_extrinsic/index.js @@ -1,6 +1,6 @@ const BN = require('bn.js'); -const Api = require('@polkadot/api').default; -const WsProvider = require('@polkadot/api-provider/ws').default; +const Rpc = require('@polkadot/rpc-core').default; +const WsProvider = require('@polkadot/rpc-provider/ws').default; const extrinsics = require('@polkadot/extrinsics').default; const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode').default; const encodeLength = require('@polkadot/extrinsics/codec/encode/length').default; @@ -10,7 +10,7 @@ const storage = require('@polkadot/storage').default; const Encoder = new TextEncoder(); const keyring = new Keyring(); const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); async function getAccountIndex (address) { return api.state.getStorage([storage.system.public.accountIndexOf, address]); diff --git a/docs/examples/06_craft_extrinsic/package.json b/docs/examples/06_craft_extrinsic/package.json index 09d5bdef45..211b10fdda 100644 --- a/docs/examples/06_craft_extrinsic/package.json +++ b/docs/examples/06_craft_extrinsic/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "0.29.1", + "@polkadot/rpc-core": "^0.31.1", "bn.js": "^4.11.8" }, "devDependencies": { diff --git a/docs/examples/07_transfer_dots/index.js b/docs/examples/07_transfer_dots/index.js index 0a24bac62c..45a8d3b53b 100755 --- a/docs/examples/07_transfer_dots/index.js +++ b/docs/examples/07_transfer_dots/index.js @@ -1,6 +1,6 @@ const BN = require('bn.js'); -const Api = require('@polkadot/api').default; -const WsProvider = require('@polkadot/api-provider/ws').default; +const Rpc = require('@polkadot/rpc-core').default; +const WsProvider = require('@polkadot/rpc-provider/ws').default; const extrinsics = require('@polkadot/extrinsics').default; const encodeExtrinsic = require('@polkadot/extrinsics/codec/encode/uncheckedLength').default; const Keyring = require('@polkadot/util-keyring').default; @@ -9,7 +9,7 @@ const storage = require('@polkadot/storage').default; const Encoder = new TextEncoder(); const keyring = new Keyring(); const provider = new WsProvider('ws://127.0.0.1:9944'); -const api = new Api(provider); +const api = new Rpc(provider); async function getAccountIndex (address) { return api.state.getStorage([storage.system.public.accountIndexOf, address]); diff --git a/docs/examples/07_transfer_dots/package.json b/docs/examples/07_transfer_dots/package.json index a3353aaa9b..d59657541e 100644 --- a/docs/examples/07_transfer_dots/package.json +++ b/docs/examples/07_transfer_dots/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "0.29.1", + "@polkadot/rpc-core": "^0.31.1", "bn.js": "^4.11.8" }, "devDependencies": { diff --git a/docs/guides/create_api.adoc b/docs/guides/create_api.adoc deleted file mode 100644 index 2a4749efa6..0000000000 --- a/docs/guides/create_api.adoc +++ /dev/null @@ -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); -``` diff --git a/docs/guides/create_api.md b/docs/guides/create_api.md new file mode 100644 index 0000000000..9749df9ff3 --- /dev/null +++ b/docs/guides/create_api.md @@ -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); +``` diff --git a/jest.config.js b/jest.config.js index 7f4cb51f08..78a8588b4a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,8 +2,8 @@ const config = require('@polkadot/dev/config/jest'); module.exports = Object.assign({}, config, { moduleNameMapper: { - '@polkadot/api-(jsonrpc|observable|provider|rx)(.*)$': '/packages/api-$1/src/$2', - '@polkadot/api(.*)$': '/packages/api/src/$1', + '@polkadot/api-observable(.*)$': '/packages/api-observable/src/$1', + '@polkadot/rpc-(core|provider|rx)(.*)$': '/packages/rpc-$1/src/$2', '@polkadot/extrinsics(.*)$': '/packages/type-extrinsics/src/$1', '@polkadot/jsonrpc(.*)$': '/packages/type-jsonrpc/src/$1', '@polkadot/params(.*)$': '/packages/type-params/src/$1', diff --git a/lerna.json b/lerna.json index 303214265b..34970b4329 100644 --- a/lerna.json +++ b/lerna.json @@ -9,5 +9,5 @@ "packages": [ "packages/*" ], - "version": "0.30.45" + "version": "0.31.0" } diff --git a/package.json b/package.json index bbf9c0befa..57d370c6c7 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.30.45", + "version": "0.31.0", "private": true, "engines": { "node": "^10.1.0", diff --git a/packages/api-observable/package.json b/packages/api-observable/package.json index 57ad716b54..910e3c0d98 100644 --- a/packages/api-observable/package.json +++ b/packages/api-observable/package.json @@ -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" } diff --git a/packages/api-observable/src/Base.ts b/packages/api-observable/src/Base.ts index c2ba81d75b..d98ecefa0e 100644 --- a/packages/api-observable/src/Base.ts +++ b/packages/api-observable/src/Base.ts @@ -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; - 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 = ({ method, section }: RpcMethod, ...params: Array): Observable => { - 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}'`); diff --git a/packages/api-rx/src/types.d.ts b/packages/api-rx/src/types.d.ts deleted file mode 100644 index ad25821f5d..0000000000 --- a/packages/api-rx/src/types.d.ts +++ /dev/null @@ -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) => Observable | BehaviorSubject; - -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 -} diff --git a/packages/api/LICENSE b/packages/rpc-core/LICENSE similarity index 92% rename from packages/api/LICENSE rename to packages/rpc-core/LICENSE index a47c81152d..fd985c7440 100644 --- a/packages/api/LICENSE +++ b/packages/rpc-core/LICENSE @@ -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 diff --git a/packages/api/README.md b/packages/rpc-core/README.md similarity index 86% rename from packages/api/README.md rename to packages/rpc-core/README.md index d7947536e3..9b10ee3e40 100644 --- a/packages/api/README.md +++ b/packages/rpc-core/README.md @@ -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); diff --git a/packages/api/package.json b/packages/rpc-core/package.json similarity index 82% rename from packages/api/package.json rename to packages/rpc-core/package.json index 1783b557b9..6fc3309218 100644 --- a/packages/api/package.json +++ b/packages/rpc-core/package.json @@ -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" } } diff --git a/packages/api/src/formatting.spec.js b/packages/rpc-core/src/formatting.spec.js similarity index 96% rename from packages/api/src/formatting.spec.js rename to packages/rpc-core/src/formatting.spec.js index 299ca8e14a..7e2896cbf5 100644 --- a/packages/api/src/formatting.spec.js +++ b/packages/rpc-core/src/formatting.spec.js @@ -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. diff --git a/packages/api/src/index.spec.js b/packages/rpc-core/src/index.spec.js similarity index 92% rename from packages/api/src/index.spec.js rename to packages/rpc-core/src/index.spec.js index 8f489ba343..d62ed4dc0b 100644 --- a/packages/api/src/index.spec.js +++ b/packages/rpc-core/src/index.spec.js @@ -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. diff --git a/packages/api/src/index.ts b/packages/rpc-core/src/index.ts similarity index 87% rename from packages/api/src/index.ts rename to packages/rpc-core/src/index.ts index 66e0ea0a68..76b96808b1 100644 --- a/packages/api/src/index.ts +++ b/packages/rpc-core/src/index.ts @@ -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 *
* * ```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 { *
* * ```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): Promise => { // 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 => this._provider.unsubscribe(rpcName, method.subscribe[1], subscriptionId); const _call = async (...values: Array): Promise => { @@ -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; diff --git a/packages/api/src/methodSend.spec.js b/packages/rpc-core/src/methodSend.spec.js similarity index 95% rename from packages/api/src/methodSend.spec.js rename to packages/rpc-core/src/methodSend.spec.js index 239b148b7d..636679844a 100644 --- a/packages/api/src/methodSend.spec.js +++ b/packages/rpc-core/src/methodSend.spec.js @@ -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. diff --git a/packages/api/src/types.d.ts b/packages/rpc-core/src/types.d.ts similarity index 50% rename from packages/api/src/types.d.ts rename to packages/rpc-core/src/types.d.ts index c37212d445..8c626f40bb 100644 --- a/packages/api/src/types.d.ts +++ b/packages/rpc-core/src/types.d.ts @@ -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): Promise; subscription: string; unsubscribe: (id: number) => Promise; } -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 } diff --git a/packages/api/test/e2e/basics.test.js b/packages/rpc-core/test/e2e/basics.test.js similarity index 93% rename from packages/api/test/e2e/basics.test.js rename to packages/rpc-core/test/e2e/basics.test.js index 489894c937..f05f3dc20f 100644 --- a/packages/api/test/e2e/basics.test.js +++ b/packages/rpc-core/test/e2e/basics.test.js @@ -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'; diff --git a/packages/api/test/e2e/chain.test.js b/packages/rpc-core/test/e2e/chain.test.js similarity index 96% rename from packages/api/test/e2e/chain.test.js rename to packages/rpc-core/test/e2e/chain.test.js index 026d545bf8..5796daac6c 100644 --- a/packages/api/test/e2e/chain.test.js +++ b/packages/rpc-core/test/e2e/chain.test.js @@ -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'; diff --git a/packages/api/test/e2e/krummelanke.test.js b/packages/rpc-core/test/e2e/krummelanke.test.js similarity index 97% rename from packages/api/test/e2e/krummelanke.test.js rename to packages/rpc-core/test/e2e/krummelanke.test.js index d2bdefc0ba..d32603bf77 100644 --- a/packages/api/test/e2e/krummelanke.test.js +++ b/packages/rpc-core/test/e2e/krummelanke.test.js @@ -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'; diff --git a/packages/api/test/e2e/state.test.js b/packages/rpc-core/test/e2e/state.test.js similarity index 97% rename from packages/api/test/e2e/state.test.js rename to packages/rpc-core/test/e2e/state.test.js index 4041c993b3..95a7e78b3a 100644 --- a/packages/api/test/e2e/state.test.js +++ b/packages/rpc-core/test/e2e/state.test.js @@ -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'; diff --git a/packages/api/test/e2e/subscribe.test.js b/packages/rpc-core/test/e2e/subscribe.test.js similarity index 95% rename from packages/api/test/e2e/subscribe.test.js rename to packages/rpc-core/test/e2e/subscribe.test.js index bea59b4c05..26f3ad742d 100644 --- a/packages/api/test/e2e/subscribe.test.js +++ b/packages/rpc-core/test/e2e/subscribe.test.js @@ -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'; diff --git a/packages/api-provider/test/mockHttp.ts b/packages/rpc-core/test/mockHttp.ts similarity index 91% rename from packages/api-provider/test/mockHttp.ts rename to packages/rpc-core/test/mockHttp.ts index a994a7b188..3738c5753a 100644 --- a/packages/api-provider/test/mockHttp.ts +++ b/packages/rpc-core/test/mockHttp.ts @@ -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. diff --git a/packages/api/test/mockWs.ts b/packages/rpc-core/test/mockWs.ts similarity index 96% rename from packages/api/test/mockWs.ts rename to packages/rpc-core/test/mockWs.ts index bae2b36718..cda2cff953 100644 --- a/packages/api/test/mockWs.ts +++ b/packages/rpc-core/test/mockWs.ts @@ -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. diff --git a/packages/api-provider/LICENSE b/packages/rpc-provider/LICENSE similarity index 91% rename from packages/api-provider/LICENSE rename to packages/rpc-provider/LICENSE index 1fecc4af44..c0f5736950 100644 --- a/packages/api-provider/LICENSE +++ b/packages/rpc-provider/LICENSE @@ -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 diff --git a/packages/api-provider/README.md b/packages/rpc-provider/README.md similarity index 76% rename from packages/api-provider/README.md rename to packages/rpc-provider/README.md index 2e8bc12303..f5e75975c7 100644 --- a/packages/api-provider/README.md +++ b/packages/rpc-provider/README.md @@ -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', []); diff --git a/packages/api-provider/package.json b/packages/rpc-provider/package.json similarity index 88% rename from packages/api-provider/package.json rename to packages/rpc-provider/package.json index 2b674f1b60..40ac76d257 100644 --- a/packages/api-provider/package.json +++ b/packages/rpc-provider/package.json @@ -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", diff --git a/packages/api-provider/src/coder/json/decodeResponse.spec.js b/packages/rpc-provider/src/coder/json/decodeResponse.spec.js similarity index 94% rename from packages/api-provider/src/coder/json/decodeResponse.spec.js rename to packages/rpc-provider/src/coder/json/decodeResponse.spec.js index 0d05a173cf..b45d982e00 100644 --- a/packages/api-provider/src/coder/json/decodeResponse.spec.js +++ b/packages/rpc-provider/src/coder/json/decodeResponse.spec.js @@ -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. diff --git a/packages/api-provider/src/coder/json/decodeResponse.ts b/packages/rpc-provider/src/coder/json/decodeResponse.ts similarity index 95% rename from packages/api-provider/src/coder/json/decodeResponse.ts rename to packages/rpc-provider/src/coder/json/decodeResponse.ts index 59ccfa0568..1e2da14c82 100644 --- a/packages/api-provider/src/coder/json/decodeResponse.ts +++ b/packages/rpc-provider/src/coder/json/decodeResponse.ts @@ -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. diff --git a/packages/api-provider/src/coder/json/encodeJson.spec.js b/packages/rpc-provider/src/coder/json/encodeJson.spec.js similarity index 87% rename from packages/api-provider/src/coder/json/encodeJson.spec.js rename to packages/rpc-provider/src/coder/json/encodeJson.spec.js index 09ec29d062..36cf337374 100644 --- a/packages/api-provider/src/coder/json/encodeJson.spec.js +++ b/packages/rpc-provider/src/coder/json/encodeJson.spec.js @@ -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. diff --git a/packages/api-provider/src/coder/json/encodeJson.ts b/packages/rpc-provider/src/coder/json/encodeJson.ts similarity index 85% rename from packages/api-provider/src/coder/json/encodeJson.ts rename to packages/rpc-provider/src/coder/json/encodeJson.ts index e1c035e2a1..48de8f82c0 100644 --- a/packages/api-provider/src/coder/json/encodeJson.ts +++ b/packages/rpc-provider/src/coder/json/encodeJson.ts @@ -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. diff --git a/packages/api-provider/src/coder/json/encodeObject.spec.js b/packages/rpc-provider/src/coder/json/encodeObject.spec.js similarity index 90% rename from packages/api-provider/src/coder/json/encodeObject.spec.js rename to packages/rpc-provider/src/coder/json/encodeObject.spec.js index 573b054a94..c1f21d0daa 100644 --- a/packages/api-provider/src/coder/json/encodeObject.spec.js +++ b/packages/rpc-provider/src/coder/json/encodeObject.spec.js @@ -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. diff --git a/packages/api-provider/src/coder/json/encodeObject.ts b/packages/rpc-provider/src/coder/json/encodeObject.ts similarity index 86% rename from packages/api-provider/src/coder/json/encodeObject.ts rename to packages/rpc-provider/src/coder/json/encodeObject.ts index e9d4706285..170f6238c3 100644 --- a/packages/api-provider/src/coder/json/encodeObject.ts +++ b/packages/rpc-provider/src/coder/json/encodeObject.ts @@ -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. diff --git a/packages/api-provider/src/coder/json/index.ts b/packages/rpc-provider/src/coder/json/index.ts similarity index 92% rename from packages/api-provider/src/coder/json/index.ts rename to packages/rpc-provider/src/coder/json/index.ts index d54a530324..73c905801d 100644 --- a/packages/api-provider/src/coder/json/index.ts +++ b/packages/rpc-provider/src/coder/json/index.ts @@ -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. diff --git a/packages/api-provider/src/coder/json/types.d.ts b/packages/rpc-provider/src/coder/json/types.d.ts similarity index 88% rename from packages/api-provider/src/coder/json/types.d.ts rename to packages/rpc-provider/src/coder/json/types.d.ts index 9459a736b5..33dc6a627a 100644 --- a/packages/api-provider/src/coder/json/types.d.ts +++ b/packages/rpc-provider/src/coder/json/types.d.ts @@ -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. diff --git a/packages/api-provider/src/http/index.spec.js b/packages/rpc-provider/src/http/index.spec.js similarity index 94% rename from packages/api-provider/src/http/index.spec.js rename to packages/rpc-provider/src/http/index.spec.js index 7b68ba6c49..21d8211326 100644 --- a/packages/api-provider/src/http/index.spec.js +++ b/packages/rpc-provider/src/http/index.spec.js @@ -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. diff --git a/packages/api-provider/src/http/index.ts b/packages/rpc-provider/src/http/index.ts similarity index 95% rename from packages/api-provider/src/http/index.ts rename to packages/rpc-provider/src/http/index.ts index 08624755d3..e394290970 100644 --- a/packages/api-provider/src/http/index.ts +++ b/packages/rpc-provider/src/http/index.ts @@ -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 *
* * ```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); diff --git a/packages/api-provider/src/http/polyfill.spec.js b/packages/rpc-provider/src/http/polyfill.spec.js similarity index 90% rename from packages/api-provider/src/http/polyfill.spec.js rename to packages/rpc-provider/src/http/polyfill.spec.js index 0ca2744dcd..b85dba8983 100644 --- a/packages/api-provider/src/http/polyfill.spec.js +++ b/packages/rpc-provider/src/http/polyfill.spec.js @@ -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. diff --git a/packages/api-provider/src/http/polyfill.ts b/packages/rpc-provider/src/http/polyfill.ts similarity index 77% rename from packages/api-provider/src/http/polyfill.ts rename to packages/rpc-provider/src/http/polyfill.ts index 55cfc6015b..51ed107008 100644 --- a/packages/api-provider/src/http/polyfill.ts +++ b/packages/rpc-provider/src/http/polyfill.ts @@ -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. diff --git a/packages/api-provider/src/http/send.spec.js b/packages/rpc-provider/src/http/send.spec.js similarity index 94% rename from packages/api-provider/src/http/send.spec.js rename to packages/rpc-provider/src/http/send.spec.js index ee47d29a93..75e05770af 100644 --- a/packages/api-provider/src/http/send.spec.js +++ b/packages/rpc-provider/src/http/send.spec.js @@ -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. diff --git a/packages/api-provider/src/http/types.d.ts b/packages/rpc-provider/src/http/types.d.ts similarity index 82% rename from packages/api-provider/src/http/types.d.ts rename to packages/rpc-provider/src/http/types.d.ts index 150ddff683..4afc55da8e 100644 --- a/packages/api-provider/src/http/types.d.ts +++ b/packages/rpc-provider/src/http/types.d.ts @@ -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. diff --git a/packages/api-provider/src/index.ts b/packages/rpc-provider/src/index.ts similarity index 77% rename from packages/api-provider/src/index.ts rename to packages/rpc-provider/src/index.ts index f2502b9f3f..354ffa212e 100644 --- a/packages/api-provider/src/index.ts +++ b/packages/rpc-provider/src/index.ts @@ -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. diff --git a/packages/api-provider/src/mock/index.ts b/packages/rpc-provider/src/mock/index.ts similarity index 94% rename from packages/api-provider/src/mock/index.ts rename to packages/rpc-provider/src/mock/index.ts index 5bd79ea28a..c397012141 100644 --- a/packages/api-provider/src/mock/index.ts +++ b/packages/rpc-provider/src/mock/index.ts @@ -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. diff --git a/packages/api-provider/src/mock/mocks.ts b/packages/rpc-provider/src/mock/mocks.ts similarity index 97% rename from packages/api-provider/src/mock/mocks.ts rename to packages/rpc-provider/src/mock/mocks.ts index 92aea6e252..b5b0193622 100644 --- a/packages/api-provider/src/mock/mocks.ts +++ b/packages/rpc-provider/src/mock/mocks.ts @@ -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. diff --git a/packages/api-provider/src/mock/on.ts b/packages/rpc-provider/src/mock/on.ts similarity index 86% rename from packages/api-provider/src/mock/on.ts rename to packages/rpc-provider/src/mock/on.ts index 36def5b390..dcea57fb25 100644 --- a/packages/api-provider/src/mock/on.ts +++ b/packages/rpc-provider/src/mock/on.ts @@ -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. diff --git a/packages/api-provider/src/mock/send.ts b/packages/rpc-provider/src/mock/send.ts similarity index 86% rename from packages/api-provider/src/mock/send.ts rename to packages/rpc-provider/src/mock/send.ts index 256c9ac557..187ac33658 100644 --- a/packages/api-provider/src/mock/send.ts +++ b/packages/rpc-provider/src/mock/send.ts @@ -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. diff --git a/packages/api-provider/src/mock/state.spec.js b/packages/rpc-provider/src/mock/state.spec.js similarity index 90% rename from packages/api-provider/src/mock/state.spec.js rename to packages/rpc-provider/src/mock/state.spec.js index 060721f587..795b68544f 100644 --- a/packages/api-provider/src/mock/state.spec.js +++ b/packages/rpc-provider/src/mock/state.spec.js @@ -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. diff --git a/packages/api-provider/src/mock/state.ts b/packages/rpc-provider/src/mock/state.ts similarity index 95% rename from packages/api-provider/src/mock/state.ts rename to packages/rpc-provider/src/mock/state.ts index 55518d556b..273140e0cd 100644 --- a/packages/api-provider/src/mock/state.ts +++ b/packages/rpc-provider/src/mock/state.ts @@ -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. diff --git a/packages/api-provider/src/mock/subscribe.spec.js b/packages/rpc-provider/src/mock/subscribe.spec.js similarity index 95% rename from packages/api-provider/src/mock/subscribe.spec.js rename to packages/rpc-provider/src/mock/subscribe.spec.js index 2112e37d7f..34fd6095e5 100644 --- a/packages/api-provider/src/mock/subscribe.spec.js +++ b/packages/rpc-provider/src/mock/subscribe.spec.js @@ -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. diff --git a/packages/api-provider/src/mock/subscribe.ts b/packages/rpc-provider/src/mock/subscribe.ts similarity index 92% rename from packages/api-provider/src/mock/subscribe.ts rename to packages/rpc-provider/src/mock/subscribe.ts index 759ef43c7f..5b830e873f 100644 --- a/packages/api-provider/src/mock/subscribe.ts +++ b/packages/rpc-provider/src/mock/subscribe.ts @@ -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. diff --git a/packages/api-provider/src/mock/types.d.ts b/packages/rpc-provider/src/mock/types.d.ts similarity index 93% rename from packages/api-provider/src/mock/types.d.ts rename to packages/rpc-provider/src/mock/types.d.ts index 8bb1520de2..1988ecd0ab 100644 --- a/packages/api-provider/src/mock/types.d.ts +++ b/packages/rpc-provider/src/mock/types.d.ts @@ -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. diff --git a/packages/api-provider/src/mock/unsubscribe.spec.js b/packages/rpc-provider/src/mock/unsubscribe.spec.js similarity index 95% rename from packages/api-provider/src/mock/unsubscribe.spec.js rename to packages/rpc-provider/src/mock/unsubscribe.spec.js index e9200666c1..544736717d 100644 --- a/packages/api-provider/src/mock/unsubscribe.spec.js +++ b/packages/rpc-provider/src/mock/unsubscribe.spec.js @@ -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. diff --git a/packages/api-provider/src/mock/unsubscribe.ts b/packages/rpc-provider/src/mock/unsubscribe.ts similarity index 89% rename from packages/api-provider/src/mock/unsubscribe.ts rename to packages/rpc-provider/src/mock/unsubscribe.ts index f83ca3a4c0..04135cd4dd 100644 --- a/packages/api-provider/src/mock/unsubscribe.ts +++ b/packages/rpc-provider/src/mock/unsubscribe.ts @@ -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. diff --git a/packages/api-provider/src/types.d.ts b/packages/rpc-provider/src/types.d.ts similarity index 95% rename from packages/api-provider/src/types.d.ts rename to packages/rpc-provider/src/types.d.ts index 5e2b69d04e..c12a0163b0 100644 --- a/packages/api-provider/src/types.d.ts +++ b/packages/rpc-provider/src/types.d.ts @@ -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. diff --git a/packages/api-provider/src/ws/connect.spec.js b/packages/rpc-provider/src/ws/connect.spec.js similarity index 91% rename from packages/api-provider/src/ws/connect.spec.js rename to packages/rpc-provider/src/ws/connect.spec.js index 7c13e6bd5d..174c4fdf3c 100644 --- a/packages/api-provider/src/ws/connect.spec.js +++ b/packages/rpc-provider/src/ws/connect.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/index.spec.js b/packages/rpc-provider/src/ws/index.spec.js similarity index 90% rename from packages/api-provider/src/ws/index.spec.js rename to packages/rpc-provider/src/ws/index.spec.js index b01b1309fe..7745b293d7 100644 --- a/packages/api-provider/src/ws/index.spec.js +++ b/packages/rpc-provider/src/ws/index.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/index.ts b/packages/rpc-provider/src/ws/index.ts similarity index 98% rename from packages/api-provider/src/ws/index.ts rename to packages/rpc-provider/src/ws/index.ts index 82510a4bb5..6069de3e47 100644 --- a/packages/api-provider/src/ws/index.ts +++ b/packages/rpc-provider/src/ws/index.ts @@ -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 { *
* * ```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); diff --git a/packages/api-provider/src/ws/onError.spec.js b/packages/rpc-provider/src/ws/onError.spec.js similarity index 89% rename from packages/api-provider/src/ws/onError.spec.js rename to packages/rpc-provider/src/ws/onError.spec.js index 2766ff7b0f..016ac52c4d 100644 --- a/packages/api-provider/src/ws/onError.spec.js +++ b/packages/rpc-provider/src/ws/onError.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/onMessageResult.spec.js b/packages/rpc-provider/src/ws/onMessageResult.spec.js similarity index 93% rename from packages/api-provider/src/ws/onMessageResult.spec.js rename to packages/rpc-provider/src/ws/onMessageResult.spec.js index cbe11a8032..8fb303a740 100644 --- a/packages/api-provider/src/ws/onMessageResult.spec.js +++ b/packages/rpc-provider/src/ws/onMessageResult.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/onMessageSubscribe.spec.js b/packages/rpc-provider/src/ws/onMessageSubscribe.spec.js similarity index 96% rename from packages/api-provider/src/ws/onMessageSubscribe.spec.js rename to packages/rpc-provider/src/ws/onMessageSubscribe.spec.js index 4ced0407f4..c617bcf3ef 100644 --- a/packages/api-provider/src/ws/onMessageSubscribe.spec.js +++ b/packages/rpc-provider/src/ws/onMessageSubscribe.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/onOpen.spec.js b/packages/rpc-provider/src/ws/onOpen.spec.js similarity index 92% rename from packages/api-provider/src/ws/onOpen.spec.js rename to packages/rpc-provider/src/ws/onOpen.spec.js index 279919e379..6bb9a0eab0 100644 --- a/packages/api-provider/src/ws/onOpen.spec.js +++ b/packages/rpc-provider/src/ws/onOpen.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/polyfill.spec.js b/packages/rpc-provider/src/ws/polyfill.spec.js similarity index 90% rename from packages/api-provider/src/ws/polyfill.spec.js rename to packages/rpc-provider/src/ws/polyfill.spec.js index 1f1dee7f67..bb8691fe74 100644 --- a/packages/api-provider/src/ws/polyfill.spec.js +++ b/packages/rpc-provider/src/ws/polyfill.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/polyfill.ts b/packages/rpc-provider/src/ws/polyfill.ts similarity index 80% rename from packages/api-provider/src/ws/polyfill.ts rename to packages/rpc-provider/src/ws/polyfill.ts index e606563fba..8cbe861982 100644 --- a/packages/api-provider/src/ws/polyfill.ts +++ b/packages/rpc-provider/src/ws/polyfill.ts @@ -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. diff --git a/packages/api-provider/src/ws/send.spec.js b/packages/rpc-provider/src/ws/send.spec.js similarity index 96% rename from packages/api-provider/src/ws/send.spec.js rename to packages/rpc-provider/src/ws/send.spec.js index e0695608cb..23bae3ec4c 100644 --- a/packages/api-provider/src/ws/send.spec.js +++ b/packages/rpc-provider/src/ws/send.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/state.spec.js b/packages/rpc-provider/src/ws/state.spec.js similarity index 87% rename from packages/api-provider/src/ws/state.spec.js rename to packages/rpc-provider/src/ws/state.spec.js index c594826632..8f96506d62 100644 --- a/packages/api-provider/src/ws/state.spec.js +++ b/packages/rpc-provider/src/ws/state.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/subscribe.spec.js b/packages/rpc-provider/src/ws/subscribe.spec.js similarity index 93% rename from packages/api-provider/src/ws/subscribe.spec.js rename to packages/rpc-provider/src/ws/subscribe.spec.js index ad7412cd3c..f44d82d224 100644 --- a/packages/api-provider/src/ws/subscribe.spec.js +++ b/packages/rpc-provider/src/ws/subscribe.spec.js @@ -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. diff --git a/packages/api-provider/src/ws/unsubscribe.spec.js b/packages/rpc-provider/src/ws/unsubscribe.spec.js similarity index 96% rename from packages/api-provider/src/ws/unsubscribe.spec.js rename to packages/rpc-provider/src/ws/unsubscribe.spec.js index 1df76b027e..a086e733d5 100644 --- a/packages/api-provider/src/ws/unsubscribe.spec.js +++ b/packages/rpc-provider/src/ws/unsubscribe.spec.js @@ -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. diff --git a/packages/api/test/mockHttp.ts b/packages/rpc-provider/test/mockHttp.ts similarity index 91% rename from packages/api/test/mockHttp.ts rename to packages/rpc-provider/test/mockHttp.ts index a994a7b188..3738c5753a 100644 --- a/packages/api/test/mockHttp.ts +++ b/packages/rpc-provider/test/mockHttp.ts @@ -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. diff --git a/packages/api-provider/test/mockWs.ts b/packages/rpc-provider/test/mockWs.ts similarity index 96% rename from packages/api-provider/test/mockWs.ts rename to packages/rpc-provider/test/mockWs.ts index bae2b36718..cda2cff953 100644 --- a/packages/api-provider/test/mockWs.ts +++ b/packages/rpc-provider/test/mockWs.ts @@ -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. diff --git a/packages/api-rx/LICENSE b/packages/rpc-rx/LICENSE similarity index 92% rename from packages/api-rx/LICENSE rename to packages/rpc-rx/LICENSE index 34f3755044..b9ab3e9f0c 100644 --- a/packages/api-rx/LICENSE +++ b/packages/rpc-rx/LICENSE @@ -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 diff --git a/packages/api-rx/README.md b/packages/rpc-rx/README.md similarity index 72% rename from packages/api-rx/README.md rename to packages/rpc-rx/README.md index d2f465c2c4..3c7a46f8f7 100644 --- a/packages/api-rx/README.md +++ b/packages/rpc-rx/README.md @@ -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). diff --git a/packages/api-rx/package.json b/packages/rpc-rx/package.json similarity index 83% rename from packages/api-rx/package.json rename to packages/rpc-rx/package.json index c11150d45a..2d09217f53 100644 --- a/packages/api-rx/package.json +++ b/packages/rpc-rx/package.json @@ -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" } diff --git a/packages/api-rx/src/cached.spec.js b/packages/rpc-rx/src/cached.spec.js similarity index 94% rename from packages/api-rx/src/cached.spec.js rename to packages/rpc-rx/src/cached.spec.js index dca495bdc5..0f8e5b36b8 100644 --- a/packages/api-rx/src/cached.spec.js +++ b/packages/rpc-rx/src/cached.spec.js @@ -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; diff --git a/packages/api-rx/src/defaults.ts b/packages/rpc-rx/src/defaults.ts similarity index 75% rename from packages/api-rx/src/defaults.ts rename to packages/rpc-rx/src/defaults.ts index 813dc70a85..eb6c30ea45 100644 --- a/packages/api-rx/src/defaults.ts +++ b/packages/rpc-rx/src/defaults.ts @@ -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. diff --git a/packages/api-rx/src/index.spec.js b/packages/rpc-rx/src/index.spec.js similarity index 86% rename from packages/api-rx/src/index.spec.js rename to packages/rpc-rx/src/index.spec.js index c2686bd2fb..cfe94a2e21 100644 --- a/packages/api-rx/src/index.spec.js +++ b/packages/rpc-rx/src/index.spec.js @@ -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; diff --git a/packages/api-rx/src/index.ts b/packages/rpc-rx/src/index.ts similarity index 79% rename from packages/api-rx/src/index.ts rename to packages/rpc-rx/src/index.ts index c0f53a4d9b..130e1a5393 100644 --- a/packages/api-rx/src/index.ts +++ b/packages/rpc-rx/src/index.ts @@ -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 = { *
* * ```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; - 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) => Observable | BehaviorSubject { + private createObservable (subName: string, name: string, section: RpcInterface$Section): (...params: Array) => Observable | BehaviorSubject { 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) => BehaviorSubject { + private createCachedObservable (subName: string, name: string, section: RpcInterface$Section): (...params: Array) => BehaviorSubject { if (!this._cacheMap[subName]) { this._cacheMap[subName] = {}; } @@ -108,7 +108,7 @@ export default class RxApi implements RxApiInterface { }; } - private createSubject (name: string, params: Array, section: ApiInterface$Section, unsubCallback?: () => void): BehaviorSubject { + private createSubject (name: string, params: Array, section: RpcInterface$Section, unsubCallback?: () => void): BehaviorSubject { const subject = new BehaviorSubject(undefined); Observable diff --git a/packages/api-rx/src/subject.spec.js b/packages/rpc-rx/src/subject.spec.js similarity index 93% rename from packages/api-rx/src/subject.spec.js rename to packages/rpc-rx/src/subject.spec.js index 07c901819e..06285ff820 100644 --- a/packages/api-rx/src/subject.spec.js +++ b/packages/rpc-rx/src/subject.spec.js @@ -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; diff --git a/packages/rpc-rx/src/types.d.ts b/packages/rpc-rx/src/types.d.ts new file mode 100644 index 0000000000..0a79430f15 --- /dev/null +++ b/packages/rpc-rx/src/types.d.ts @@ -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) => Observable | BehaviorSubject; + +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 +} diff --git a/packages/api-rx/test/e2e/subscribe.test.js b/packages/rpc-rx/test/e2e/subscribe.test.js similarity index 90% rename from packages/api-rx/test/e2e/subscribe.test.js rename to packages/rpc-rx/test/e2e/subscribe.test.js index 710ccf2112..30d8ab260b 100644 --- a/packages/api-rx/test/e2e/subscribe.test.js +++ b/packages/rpc-rx/test/e2e/subscribe.test.js @@ -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'; diff --git a/packages/type-extrinsics/.nodoc b/packages/type-extrinsics/.nodoc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/type-extrinsics/package.json b/packages/type-extrinsics/package.json index 6fedb5516a..ed84ec57a9 100644 --- a/packages/type-extrinsics/package.json +++ b/packages/type-extrinsics/package.json @@ -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 ", diff --git a/packages/type-extrinsics/test/e2e/transfer.spec.js b/packages/type-extrinsics/test/e2e/transfer.spec.js index 68138d3b84..e3ba2a61d4 100644 --- a/packages/type-extrinsics/test/e2e/transfer.spec.js +++ b/packages/type-extrinsics/test/e2e/transfer.spec.js @@ -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'; diff --git a/packages/type-jsonrpc/.nodoc b/packages/type-jsonrpc/.nodoc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/type-jsonrpc/package.json b/packages/type-jsonrpc/package.json index 2a7960f5fe..e81ae7291f 100644 --- a/packages/type-jsonrpc/package.json +++ b/packages/type-jsonrpc/package.json @@ -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": { diff --git a/packages/type-storage/.nodoc b/packages/type-storage/.nodoc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/type-storage/package.json b/packages/type-storage/package.json index 51dbd0752c..f70bde397f 100644 --- a/packages/type-storage/package.json +++ b/packages/type-storage/package.json @@ -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" diff --git a/packages/types/package.json b/packages/types/package.json index dec2576cb4..d5c222a041 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -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": [ diff --git a/tsconfig.json b/tsconfig.json index 19270bd7bd..b189402d53 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,9 @@ "paths": { "@polkadot/api-observable/*": ["packages/api-observable/src/*"], - "@polkadot/api-provider/*": ["packages/api-provider/src/*"], - "@polkadot/api-rx/*": ["packages/api-rx/src/*"], - "@polkadot/api/*": ["packages/api/src/*"], + "@polkadot/rpc-core/*": ["packages/rpc-core/src/*"], + "@polkadot/rpc-provider/*": ["packages/rpc-provider/src/*"], + "@polkadot/rpc-rx/*": ["packages/rpc-rx/src/*"], "@polkadot/extrinsics/*": ["packages/type-extrinsics/src/*"], "@polkadot/jsonrpc/*": ["packages/type-jsonrpc/src/*"], "@polkadot/params/*": ["packages/type-params/src/*"], diff --git a/yarn.lock b/yarn.lock index 8e16a6ef7f..d4d02fa6d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1170,6 +1170,29 @@ version "1.1.0" resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.0.tgz#50c1e2260ac0ed9439a181de3725a0168d59c48a" +"@polkadot/api-provider@^0.30.44": + version "0.30.44" + resolved "https://registry.yarnpkg.com/@polkadot/api-provider/-/api-provider-0.30.44.tgz#bb6e93bb9cf3c89a29d3e3de8aefcf9a75e14e48" + dependencies: + "@babel/runtime" "^7.0.0" + "@polkadot/storage" "^0.30.44" + "@polkadot/util" "^0.30.7" + "@polkadot/util-crypto" "^0.30.7" + "@polkadot/util-keyring" "^0.30.7" + "@types/nock" "^9.1.3" + eventemitter3 "^3.1.0" + isomorphic-fetch "^2.2.1" + websocket "^1.0.25" + +"@polkadot/api@^0.30.44": + version "0.30.44" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.30.44.tgz#a9519d9c4cc226b856e9248764a93e67d5c29987" + dependencies: + "@babel/runtime" "^7.0.0" + "@polkadot/api-provider" "^0.30.44" + "@polkadot/jsonrpc" "^0.30.44" + "@polkadot/util" "^0.30.7" + "@polkadot/dev@^0.20.24": version "0.20.24" resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.20.24.tgz#e88af950aa4e0e1a549d0a4860b2b3f8d63ce723"