Import type-* from common repo (#125)

* Import type-* from common repo

* Update links

* Fix lint links (package index)
This commit is contained in:
Jaco Greeff
2018-08-11 11:14:20 +02:00
committed by GitHub
parent 2cd40a2b97
commit ad968ec794
191 changed files with 6071 additions and 94 deletions
+15
View File
@@ -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.
+30
View File
@@ -0,0 +1,30 @@
[![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/jsonrpc.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/jsonrpc)
[![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/type-jsonrpc)](https://david-dm.org/polkadot-js/api?path=packages/type-jsonrpc)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&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)
+40
View File
@@ -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"
}
}
+30
View File
@@ -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)
}
}));
+46
View File
@@ -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)
}
}));
+12
View File
@@ -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);
});
});
+19
View File
@@ -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;
+105
View File
@@ -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)
}
}));
+42
View File
@@ -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)
}
}));
+14
View File
@@ -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;