Skip to content

Commit

Permalink
Merge 87b8317 into cd7c17b
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Oct 10, 2018
2 parents cd7c17b + 87b8317 commit 0e48de4
Show file tree
Hide file tree
Showing 102 changed files with 257 additions and 233 deletions.
14 changes: 7 additions & 7 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 3 additions & 3 deletions docs/examples/01_simple_connect/index.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/01_simple_connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/02_listen_to_blocks/index.js
Original file line number Diff line number Diff line change
@@ -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:');
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/02_listen_to_blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/03_listen_to_balance_change/index.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/03_listen_to_balance_change/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/04_generate_account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/05_read_storage/index.js
Original file line number Diff line number Diff line change
@@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/05_read_storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/06_craft_extrinsic/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/06_craft_extrinsic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/07_transfer_dots/index.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/07_transfer_dots/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 0 additions & 8 deletions docs/guides/create_api.adoc

This file was deleted.

8 changes: 8 additions & 0 deletions docs/guides/create_api.md
Original file line number Diff line number Diff line change
@@ -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);
```
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const config = require('@polkadot/dev/config/jest');

module.exports = Object.assign({}, config, {
moduleNameMapper: {
'@polkadot/api-(jsonrpc|observable|provider|rx)(.*)$': '<rootDir>/packages/api-$1/src/$2',
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
'@polkadot/api-observable(.*)$': '<rootDir>/packages/api-observable/src/$1',
'@polkadot/rpc-(core|provider|rx)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/extrinsics(.*)$': '<rootDir>/packages/type-extrinsics/src/$1',
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
'@polkadot/params(.*)$': '<rootDir>/packages/type-params/src/$1',
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "0.30.45"
"version": "0.31.0"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.30.45",
"version": "0.31.0",
"private": true,
"engines": {
"node": "^10.1.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/api-observable/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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"
}
Expand Down
10 changes: 5 additions & 5 deletions packages/api-observable/src/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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());
Expand Down Expand Up @@ -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}'`);

Expand Down
22 changes: 0 additions & 22 deletions packages/api-rx/src/types.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/api/LICENSE → packages/rpc-core/LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions packages/api/README.md → packages/rpc-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions packages/api/package.json → packages/rpc-core/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Loading

0 comments on commit 0e48de4

Please sign in to comment.