Add chain_getBlock & author_pendingExtrinsics (#132)

* Add chain_getBlock & author_pendingExtrinsics

* Remove sample

* TSLint
This commit is contained in:
Jaco Greeff
2018-08-15 15:34:16 +02:00
committed by GitHub
parent 5756a7a30d
commit a369c8804a
44 changed files with 306 additions and 132 deletions
+22 -6
View File
@@ -2,12 +2,18 @@
// 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 { CreateItems, CreateItemOptions, CreateItemOptionsMap, Section, SectionItems } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from './types';
import param from '@polkadot/params/param';
import createSection from '@polkadot/params/section';
const pendingExtrinsics: CreateItemOptions = {
description: 'Returns all pending extrinsics, potentially grouped by sender',
params: [],
type: 'PrendingExtrinsics'
};
const submitExtrinsic: CreateItemOptions = {
isSigned: true,
description: 'Submit a fully formatted extrinsic for block inclusion',
@@ -17,14 +23,24 @@ const submitExtrinsic: CreateItemOptions = {
type: 'Hash'
};
const privateMethods: CreateItemOptionsMap = {};
const publicMethods: CreateItemOptionsMap = {
pendingExtrinsics, submitExtrinsic
};
export type PrivateMethods = typeof privateMethods;
export type PublicMethods = typeof publicMethods;
/**
* @summary Methods to work with authors & contributors.
*/
export default (name: Interface$Sections): Section<Interfaces> =>
export default (name: Interface$Sections): Section<Interfaces, PrivateMethods, PublicMethods> =>
createSection(name)((createMethod: CreateItems<Interfaces>) => ({
description: 'Authoring of network items',
public: {
submitExtrinsic:
createMethod('submitExtrinsic')(submitExtrinsic)
}
public: Object.keys(publicMethods).reduce((result, key) => {
result[key] = createMethod(key)(publicMethods[key]);
return result;
}, {} as SectionItems<Interfaces, PublicMethods>)
}));
+24 -10
View File
@@ -2,12 +2,20 @@
// 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 { CreateItems, CreateItemOptions, CreateItemOptionsMap, Section, SectionItems } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from './types';
import param from '@polkadot/params/param';
import createSection from '@polkadot/params/section';
const getBlock: CreateItemOptions = {
description: 'Get header and body of a relay chain block',
params: [
param('hash', 'Hash')
],
type: 'SignedBlock'
};
const getHead: CreateItemOptions = {
description: 'Retrieves the best headerHash',
params: [],
@@ -29,18 +37,24 @@ const subscribeNewHead: CreateItemOptions = {
type: 'Header'
};
const privateMethods: CreateItemOptionsMap = {};
const publicMethods: CreateItemOptionsMap = {
getBlock, getHead, getHeader, subscribeNewHead
};
export type PublicMethods = typeof publicMethods;
export type PrivateMethods = typeof privateMethods;
/**
* @summary Methods to retrieve chain data.
*/
export default (name: Interface$Sections): Section<Interfaces> =>
export default (name: Interface$Sections): Section<Interfaces, PrivateMethods, PublicMethods> =>
createSection(name)((createMethod: CreateItems<Interfaces>) => ({
description: 'Retrieval of chain data',
public: {
getHead:
createMethod('getHead')(getHead),
getHeader:
createMethod('getHeader')(getHeader),
subscribeNewHead:
createMethod('subscribeNewHead')(subscribeNewHead)
}
public: Object.keys(publicMethods).reduce((result, key) => {
result[key] = createMethod(key)(publicMethods[key]);
return result;
}, {} as SectionItems<Interfaces, PublicMethods>)
}));
+11 -2
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types';
import { CreateItems, CreateItemOptions, CreateItemOptionsMap, Section } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from './types';
import param from '@polkadot/params/param';
@@ -87,10 +87,19 @@ const subscribeStorage: CreateItemOptions = {
type: 'StorageResultSet'
};
const privateMethods: CreateItemOptionsMap = {};
const publicMethods: CreateItemOptionsMap = {
call, callAt, getStorage, getStorageAt, getStorageHash, getStorageHashAt, getStorageSize, getStorageSizeAt, subscribeStorage
};
export type PrivateMethods = typeof privateMethods;
export type PublicMethods = typeof publicMethods;
/**
* @summary Query the state and state storage.
*/
export default (name: Interface$Sections): Section<Interfaces> =>
export default (name: Interface$Sections): Section<Interfaces, PrivateMethods, PublicMethods> =>
createSection(name)((createMethod: CreateItems<Interfaces>) => ({
description: 'Query of state',
public: {
+11 -2
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types';
import { CreateItems, CreateItemOptions, CreateItemOptionsMap, Section } from '@polkadot/params/types';
import { Interfaces, Interface$Sections } from './types';
import createSection from '@polkadot/params/section';
@@ -25,10 +25,19 @@ const version: CreateItemOptions = {
type: 'String'
};
const privateMethods: CreateItemOptionsMap = {};
const publicMethods: CreateItemOptionsMap = {
chain, name, version
};
export type PrivateMethods = typeof privateMethods;
export type PublicMethods = typeof publicMethods;
/**
* @summary Methods to retrieve system info.
*/
export default (sname: Interface$Sections): Section<Interfaces> =>
export default (sname: Interface$Sections): Section<Interfaces, PrivateMethods, PublicMethods> =>
createSection(sname)((createMethod: CreateItems<Interfaces>) => ({
description: 'Methods to retrieve system info',
public: {
+8 -4
View File
@@ -3,12 +3,16 @@
// of the ISC license. See the LICENSE file for details.
import { Section } from '@polkadot/params/types';
import { PrivateMethods as AuthorPrivate, PublicMethods as AuthorPublic} from './author';
import { PrivateMethods as ChainPrivate, PublicMethods as ChainPublic} from './chain';
import { PrivateMethods as StatePrivate, PublicMethods as StatePublic} from './state';
import { PrivateMethods as SystemPrivate, PublicMethods as SystemPublic} from './system';
export type Interfaces = {
author: Section<Interfaces>,
chain: Section<Interfaces>,
state: Section<Interfaces>,
system:Section<Interfaces>
author: Section<Interfaces, AuthorPrivate, AuthorPrivate>,
chain: Section<Interfaces, ChainPrivate, ChainPublic>,
state: Section<Interfaces, StatePrivate, StatePublic>,
system: Section<Interfaces, SystemPrivate, SystemPublic>
}
export type Interface$Sections = keyof Interfaces;