Import type-* from common repo (#125)
* Import type-* from common repo * Update links * Fix lint links (package index)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
ISC License (ISC)
|
||||
|
||||
Copyright 2017-2018 @polkadot/jsonrpc 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
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
@@ -0,0 +1,30 @@
|
||||
[](https://polkadot.js.org)
|
||||

|
||||
[](https://github.com/Flet/semistandard)
|
||||
[](https://www.npmjs.com/package/@polkadot/jsonrpc)
|
||||
[](https://travis-ci.org/polkadot-js/api)
|
||||
[](https://codeclimate.com/github/polkadot-js/api/maintainability)
|
||||
[](https://coveralls.io/github/polkadot-js/api?branch=master)
|
||||
[](https://david-dm.org/polkadot-js/api?path=packages/type-jsonrpc)
|
||||
[](https://david-dm.org/polkadot-js/api?path=packages/type-jsonrpc#info=devDependencies)
|
||||
|
||||
# @polkadot/jsonrpc
|
||||
|
||||
A defintion of all the methods exposed in a general Polkadot client application. These are used not only to provide a comprehensive code-generated document of the available methods, but are also used in the API to auto-generate endpoints with the required type-checking.
|
||||
|
||||
For a list of currently exposed methods, see the [method documentation](docs/README.md).
|
||||
|
||||
## Usage
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
npm install --save @polkadot/jsonrpc
|
||||
```
|
||||
|
||||
## Adding methods
|
||||
|
||||
As methods are added, simply adding the name, inputs & output will prepare it for use.
|
||||
|
||||
- Add the method to the correct file in [src/rpc/](src/rpc/) (Input/Output types as cross-referenced from the canonical implementation and match one-to-one)
|
||||
- Should a new type be required, add it to the type list, [src/types.js](src/types.js) (Required for flow type checking)
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@polkadot/jsonrpc",
|
||||
"version": "0.28.0",
|
||||
"description": "Method definitions for the Polkadot RPC layer",
|
||||
"main": "index.js",
|
||||
"engines": {
|
||||
"node": ">=6.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
"registry": "https://registry.npmjs.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/polkadot-js/api.git"
|
||||
},
|
||||
"keywords": [
|
||||
"Polkadot",
|
||||
"JsonRPC"
|
||||
],
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [
|
||||
"Jaco Greeff <jacogr@gmail.com>"
|
||||
],
|
||||
"contributors": [],
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/polkadot-js/api/issues"
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-jsonrpc#readme",
|
||||
"scripts": {
|
||||
"build": "polkadot-dev-build-babel && polkadot-dev-build-docs",
|
||||
"check": "eslint src && flow check",
|
||||
"test": "echo \"Tests only available from root wrapper\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/params": "^0.28.0",
|
||||
"babel-runtime": "^6.26.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types';
|
||||
import { Interfaces, Interface$Sections } from './types';
|
||||
|
||||
import param from '@polkadot/params/param';
|
||||
import createSection from '@polkadot/params/section';
|
||||
|
||||
const submitExtrinsic: CreateItemOptions = {
|
||||
isSigned: true,
|
||||
description: 'Submit a fully formatted extrinsic for block inclusion',
|
||||
params: [
|
||||
param('extrinsic', 'Bytes')
|
||||
],
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Methods to work with authors & contributors.
|
||||
*/
|
||||
export default (name: Interface$Sections): Section<Interfaces> =>
|
||||
createSection(name)((createMethod: CreateItems<Interfaces>) => ({
|
||||
description: 'Authoring of network items',
|
||||
public: {
|
||||
submitExtrinsic:
|
||||
createMethod('submitExtrinsic')(submitExtrinsic)
|
||||
}
|
||||
}));
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types';
|
||||
import { Interfaces, Interface$Sections } from './types';
|
||||
|
||||
import param from '@polkadot/params/param';
|
||||
import createSection from '@polkadot/params/section';
|
||||
|
||||
const getHead: CreateItemOptions = {
|
||||
description: 'Retrieves the best headerHash',
|
||||
params: [],
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getHeader: CreateItemOptions = {
|
||||
description: 'Retrieves the header for a specific block',
|
||||
params: [
|
||||
param('hash', 'Hash')
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const newHead: CreateItemOptions = {
|
||||
description: 'Retrieves the best header via subscription',
|
||||
isSubscription: true,
|
||||
params: [],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Methods to retrieve chain data.
|
||||
*/
|
||||
export default (name: Interface$Sections): Section<Interfaces> =>
|
||||
createSection(name)((createMethod: CreateItems<Interfaces>) => ({
|
||||
description: 'Retrieval of chain data',
|
||||
public: {
|
||||
getHead:
|
||||
createMethod('getHead')(getHead),
|
||||
getHeader:
|
||||
createMethod('getHeader')(getHeader),
|
||||
newHead:
|
||||
createMethod('newHead')(newHead)
|
||||
}
|
||||
}));
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc 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 './index';
|
||||
|
||||
describe('jsonrpc', () => {
|
||||
it('exports the available interfaces', () => {
|
||||
expect(interfaces).toBeDefined();
|
||||
expect(Object.keys(interfaces).length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc 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 './types';
|
||||
|
||||
import author from './author';
|
||||
import chain from './chain';
|
||||
import state from './state';
|
||||
import system from './system';
|
||||
|
||||
const interfaces: Interfaces = {
|
||||
author: author('author'),
|
||||
chain: chain('chain'),
|
||||
state: state('state'),
|
||||
system: system('system')
|
||||
};
|
||||
|
||||
export default interfaces;
|
||||
@@ -0,0 +1,105 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types';
|
||||
import { Interfaces, Interface$Sections } from './types';
|
||||
|
||||
import param from '@polkadot/params/param';
|
||||
import createSection from '@polkadot/params/section';
|
||||
|
||||
const call: CreateItemOptions = {
|
||||
description: 'Perform a call to a builtin on the chain',
|
||||
params: [
|
||||
param('method', 'String'),
|
||||
param('data', 'Bytes')
|
||||
],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const callAt: CreateItemOptions = {
|
||||
description: 'Perform a call to a builtin on the chain (At block)',
|
||||
params: [
|
||||
param('method', 'String'),
|
||||
param('data', 'Bytes'),
|
||||
param('block', 'Hash')
|
||||
],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const getStorage: CreateItemOptions = {
|
||||
description: 'Retrieves the storage for a key',
|
||||
params: [
|
||||
param('key', 'Bytes')
|
||||
],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const getStorageAt: CreateItemOptions = {
|
||||
description: 'Retrieves the storage for a key at a specific block',
|
||||
params: [
|
||||
param('key', 'Bytes'),
|
||||
param('block', 'Hash')
|
||||
],
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const getStorageHash: CreateItemOptions = {
|
||||
description: 'Retrieves the storage hash',
|
||||
params: [
|
||||
param('key', 'Bytes')
|
||||
],
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getStorageHashAt: CreateItemOptions = {
|
||||
description: 'Retrieves the storage hash at a specific block',
|
||||
params: [
|
||||
param('key', 'Bytes'),
|
||||
param('block', 'Hash')
|
||||
],
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getStorageSize: CreateItemOptions = {
|
||||
description: 'Retrieves the storage size',
|
||||
params: [
|
||||
param('key', 'Bytes')
|
||||
],
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
const getStorageSizeAt: CreateItemOptions = {
|
||||
description: 'Retrieves the storage size at a specific block',
|
||||
params: [
|
||||
param('key', 'Bytes'),
|
||||
param('block', 'Hash')
|
||||
],
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Query the state and state storage.
|
||||
*/
|
||||
export default (name: Interface$Sections): Section<Interfaces> =>
|
||||
createSection(name)((createMethod: CreateItems<Interfaces>) => ({
|
||||
description: 'Query of state',
|
||||
public: {
|
||||
call:
|
||||
createMethod('call')(call),
|
||||
callAt:
|
||||
createMethod('callAt')(callAt),
|
||||
getStorage:
|
||||
createMethod('getStorage')(getStorage),
|
||||
getStorageAt:
|
||||
createMethod('getStorageAt')(getStorageAt),
|
||||
getStorageHash:
|
||||
createMethod('getStorageHash')(getStorageHash),
|
||||
getStorageHashAt:
|
||||
createMethod('getStrorageHashAt')(getStorageHashAt),
|
||||
getStorageSize:
|
||||
createMethod('getStorageSize')(getStorageSize),
|
||||
getStorageSizeAt:
|
||||
createMethod('getStorageSizeAt')(getStorageSizeAt)
|
||||
}
|
||||
}));
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types';
|
||||
import { Interfaces, Interface$Sections } from './types';
|
||||
|
||||
import createSection from '@polkadot/params/section';
|
||||
|
||||
const chain: CreateItemOptions = {
|
||||
description: 'Retrieves the chain',
|
||||
params: [],
|
||||
type: 'String'
|
||||
};
|
||||
|
||||
const name: CreateItemOptions = {
|
||||
description: 'Retrieves the node name',
|
||||
params: [],
|
||||
type: 'String'
|
||||
};
|
||||
|
||||
const version: CreateItemOptions = {
|
||||
description: 'Retrieves the version of the node',
|
||||
params: [],
|
||||
type: 'String'
|
||||
};
|
||||
|
||||
/**
|
||||
* @summary Methods to retrieve system info.
|
||||
*/
|
||||
export default (sname: Interface$Sections): Section<Interfaces> =>
|
||||
createSection(sname)((createMethod: CreateItems<Interfaces>) => ({
|
||||
description: 'Methods to retrieve system info',
|
||||
public: {
|
||||
chain:
|
||||
createMethod('chain')(chain),
|
||||
name:
|
||||
createMethod('name')(name),
|
||||
version:
|
||||
createMethod('version')(version)
|
||||
}
|
||||
}));
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2018 @polkadot/jsonrpc authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { Section } from '@polkadot/params/types';
|
||||
|
||||
export type Interfaces = {
|
||||
author: Section<Interfaces>,
|
||||
chain: Section<Interfaces>,
|
||||
state: Section<Interfaces>,
|
||||
system:Section<Interfaces>
|
||||
}
|
||||
|
||||
export type Interface$Sections = keyof Interfaces;
|
||||
Reference in New Issue
Block a user