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
+2 -2
View File
@@ -37,7 +37,7 @@
"@polkadot/extrinsics": "^0.28.11",
"@polkadot/params": "^0.28.11",
"@polkadot/primitives": "^0.28.11",
"@polkadot/util": "^0.28.1",
"@polkadot/util-keyring": "^0.28.1"
"@polkadot/util": "^0.28.2",
"@polkadot/util-keyring": "^0.28.2"
}
}
@@ -24,7 +24,7 @@ export default function call (decode: Decoder, input: Uint8Array | null | undefi
} as Param$Decoded;
}
const section: Section<Extrinsics> | undefined = Object.values(extrinsics).find(({ index }) =>
const section: Section<Extrinsics, any, any> | undefined = Object.values(extrinsics).find(({ index }) =>
index[0] === input[0]
);
+2 -2
View File
@@ -8,9 +8,9 @@ import bnToU8a from '@polkadot/util/bn/toU8a';
import createMethod from './method';
export default function createSection <T> (name: keyof T, _index: number = 0): CreateSection<T> {
export default function createSection <T> (name: keyof T, _index: number = 0): CreateSection<T, any, any> {
const index = bnToU8a(_index, 8, true);
const creator = (optOrFn: CreateSectionOptions<T>): Section<T> => {
const creator = (optOrFn: CreateSectionOptions<T, any, any>): Section<T, any, any> => {
if (typeof optOrFn === 'function') {
return creator(
optOrFn(
+31 -13
View File
@@ -14,7 +14,7 @@ export type EncodingVersions = 'poc-1' | 'latest';
// - @polkadot/storage/key/params.ts
// - decode/value/index.js
// - encode/type/index.js
export type Param$Type = 'AccountId' | 'AccountIndex' | 'Balance' | 'BlockNumber' | 'bool' | 'Bytes' | 'Call' | 'CandidateReceipt' | 'Code' | 'Digest' | 'Gas' | 'Hash' | 'Header' | 'KeyValue' | 'MisbehaviorReport' | 'ParachainId' | 'PropIndex' | 'Proposal' | 'ReferendumIndex' | 'SessionKey' | 'Signature' | 'StorageKey' | 'StorageKeyValue' | 'StorageResult' | 'StorageResultSet' | 'String' | 'Timestamp' | 'u32' | 'u64' | 'u128' | 'VoteIndex' | 'VoteThreshold';
export type Param$Type = 'AccountId' | 'AccountIndex' | 'Balance' | 'BlockNumber' | 'bool' | 'Bytes' | 'Call' | 'CandidateReceipt' | 'Code' | 'Digest' | 'Gas' | 'Hash' | 'Header' | 'KeyValue' | 'MisbehaviorReport' | 'ParachainId' | 'PrendingExtrinsics' | 'PropIndex' | 'Proposal' | 'ReferendumIndex' | 'SessionKey' | 'Signature' | 'SignedBlock' | 'StorageKey' | 'StorageKeyValue' | 'StorageResult' | 'StorageResultSet' | 'String' | 'Timestamp' | 'u32' | 'u64' | 'u128' | 'VoteIndex' | 'VoteThreshold';
export type Param$Type$Array = Array<Param$Type | Array<Param$Type | Array<Param$Type>>>;
@@ -25,6 +25,20 @@ export type ExtrinsicDecoded = {
params: Array<any>
}
export type BlockExtrinsicDecoded = {
address: string,
nonce: BN,
extrinsic: SectionItem<Extrinsics>,
params: Array<any>,
signature: Uint8Array
}
export type BlockDecoded = {
header: Header,
extrinsics: Array<BlockExtrinsicDecoded>,
justification: any
};
export type KeyValue = {
key: Uint8Array,
value: Uint8Array
@@ -68,21 +82,21 @@ export type SectionItem<T> = {
type: Param$Types
};
export type SectionItems<T> = {
[index: string]: SectionItem<T>
export type SectionItems<T, K> = {
[key in keyof K]: SectionItem<T>
};
export type Section<T> = {
export type Section<T, Priv, Pub> = {
isDeprecated: boolean,
isHidden: boolean,
description: string,
index: Uint8Array,
name: keyof T,
private: SectionItems<T>,
public: SectionItems<T>
private: SectionItems<T, Priv>,
public: SectionItems<T, Pub>
};
export type Sections<T> = Map<T, Section<T>>;
export type Sections<T, Priv, Pub> = Map<T, Section<T, Priv, Pub>>;
export type CreateItemOptions = {
description: string,
@@ -96,20 +110,24 @@ export type CreateItemOptions = {
type: Param$Types
};
export type CreateItemOptionsMap = {
[index: string]: CreateItemOptions
};
export type CreateItem<T> = (options: CreateItemOptions) => SectionItem<T>;
export type CreateItems<T> = (name: string, index?: number) => CreateItem<T>;
export type CreateSectionOptions$Only<T> = {
export type CreateSectionOptions$Only<T, Priv, Pub> = {
description: string,
isDeprecated?: boolean,
isHidden?: boolean,
'private'?: SectionItems<T>,
'public'?: SectionItems<T>
'private'?: SectionItems<T, Priv>,
'public'?: SectionItems<T, Pub>
};
export type CreateSectionOptions$Fn<T> = (method: CreateItems<T>) => CreateSectionOptions$Only<T>;
export type CreateSectionOptions$Fn<T, Priv, Pub> = (method: CreateItems<T>) => CreateSectionOptions$Only<T, Priv, Pub>;
export type CreateSectionOptions<T> = CreateSectionOptions$Only<T> | CreateSectionOptions$Fn<T>;
export type CreateSectionOptions<T, Priv, Pub> = CreateSectionOptions$Only<T, Priv, Pub> | CreateSectionOptions$Fn<T, Priv, Pub>;
export type CreateSection<T> = (options: CreateSectionOptions<T>) => Section<T>;
export type CreateSection<T, Priv, Pub> = (options: CreateSectionOptions<T, Priv, Pub>) => Section<T, Priv, Pub>;