Various minor tweaks all-around (#194)

* Fix exports for provider

* Cleanu jsonrpc method exposure

* name -> section
This commit is contained in:
Jaco Greeff
2018-10-03 20:31:23 +02:00
committed by GitHub
parent 01b10aa520
commit 6ff847170d
7 changed files with 55 additions and 68 deletions
+2 -7
View File
@@ -2,10 +2,5 @@
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
import http from './http';
import ws from './ws';
export {
http,
ws
};
export { default as HttpProvider } from './http';
export { default as WsProvider } from './ws';
+2 -2
View File
@@ -63,11 +63,11 @@ export default class Api implements ApiInterface {
return `${method} (${inputs}): ${type}`;
}
private createInterface ({ methods, name }: Section<any>): ApiInterface$Section {
private createInterface ({ methods, section }: Section): ApiInterface$Section {
return Object
.keys(methods)
.reduce((exposed, method) => {
const rpcName = `${name}_${method}`;
const rpcName = `${section}_${method}`;
const def = methods[method];
exposed[method] = def.isSubscription
+8 -13
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 { MethodOpt, Section, SectionMethods } from './types';
import { MethodOpt, Section } from './types';
import createMethod from './create/method';
import createParam from './create/param';
@@ -22,11 +22,7 @@ const submitExtrinsic: MethodOpt = {
type: 'Hash'
};
const methods: { [index: string]: MethodOpt } = {
pendingExtrinsics, submitExtrinsic
};
export type Methods = typeof methods;
const section = 'author';
/**
* @summary Methods to work with authors & contributors.
@@ -35,10 +31,9 @@ export default {
isDeprecated: false,
isHidden: false,
description: 'Authoring of network items',
name: 'author',
methods: Object.keys(methods).reduce((result, key) => {
result[key] = createMethod('author', key, methods[key]);
return result;
}, {} as SectionMethods<Methods>)
} as Section<Methods>;
section,
methods: {
pendingExtrinsics: createMethod(section, 'pendingExtrinsics', pendingExtrinsics),
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic)
}
} as Section;
+12 -13
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 { MethodOpt, Section, SectionMethods } from './types';
import { MethodOpt, Section } from './types';
import createMethod from './create/method';
import createParam from './create/param';
@@ -53,11 +53,7 @@ const newHead: MethodOpt = {
type: 'Header'
};
const methods: { [index: string]: MethodOpt } = {
getBlock, getHead, getHeader, getRuntimeVersion, getRuntimeVersionAt, newHead
};
export type Methods = typeof methods;
const section = 'chain';
/**
* @summary Methods to retrieve chain data.
@@ -66,10 +62,13 @@ export default {
isDeprecated: false,
isHidden: false,
description: 'Retrieval of chain data',
name: 'chain',
methods: Object.keys(methods).reduce((result, key) => {
result[key] = createMethod('chain', key, methods[key]);
return result;
}, {} as SectionMethods<Methods>)
} as Section<Methods>;
section,
methods: {
getBlock: createMethod(section, 'getBlock', getBlock),
getHead: createMethod(section, 'getHead', getHead),
getHeader: createMethod(section, 'getHeader', getHeader),
getRuntimeVersion: createMethod(section, 'getRuntimeVersion', getRuntimeVersion),
getRuntimeVersionAt: createMethod(section, 'getRuntimeVersionAt', getRuntimeVersionAt),
newHead: createMethod(section, 'newHead', newHead)
}
} as Section;
+17 -13
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 { MethodOpt, Section, SectionMethods } from './types';
import { MethodOpt, Section } from './types';
import createMethod from './create/method';
import createParam from './create/param';
@@ -104,11 +104,7 @@ const storage: MethodOpt = {
type: 'StorageChangeSet'
};
const methods: { [index: string]: MethodOpt } = {
call, callAt, getMetadata, getMetadataAt, getStorage, getStorageAt, getStorageHash, getStorageHashAt, getStorageSize, getStorageSizeAt, storage
};
export type Methods = typeof methods;
const section = 'state';
/**
* @summary Query the state and state storage.
@@ -117,10 +113,18 @@ export default {
isDeprecated: false,
isHidden: false,
description: 'Query of state',
name: 'state',
methods: Object.keys(methods).reduce((result, key) => {
result[key] = createMethod('state', key, methods[key]);
return result;
}, {} as SectionMethods<Methods>)
} as Section<Methods>;
section,
methods: {
call: createMethod(section, 'call', call),
callAt: createMethod(section, 'callAt', callAt),
getMetadata: createMethod(section, 'getMetadata', getMetadata),
getMetadataAt: createMethod(section, 'getMetadataAt', getMetadataAt),
getStorage: createMethod(section, 'getStorage', getStorage),
getStorageAt: createMethod(section, 'getStorageAt', getStorageAt),
getStorageHash: createMethod(section, 'getStorageHash', getStorageHash),
getStorageHashAt: createMethod(section, 'getStorageHashAt', getStorageHashAt),
getStorageSize: createMethod(section, 'getStorageSize', getStorageSize),
getStorageSizeAt: createMethod(section, 'getStorageSizeAt', getStorageSizeAt),
storage: createMethod(section, 'storage', storage)
}
} as Section;
+9 -13
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 { MethodOpt, Section, SectionMethods } from './types';
import { MethodOpt, Section } from './types';
import createMethod from './create/method';
@@ -24,11 +24,7 @@ const version: MethodOpt = {
type: 'Text'
};
const methods: { [index: string]: MethodOpt } = {
chain, name, version
};
export type Methods = typeof methods;
const section = 'system';
/**
* @summary Methods to retrieve system info.
@@ -37,10 +33,10 @@ export default {
isDeprecated: false,
isHidden: false,
description: 'Methods to retrieve system info',
name: 'system',
methods: Object.keys(methods).reduce((result, key) => {
result[key] = createMethod('system', key, methods[key]);
return result;
}, {} as SectionMethods<Methods>)
} as Section<Methods>;
section,
methods: {
chain: createMethod(section, 'chain', chain),
name: createMethod(section, 'name', name),
version: createMethod(section, 'version', version)
}
} as Section;
+5 -7
View File
@@ -34,14 +34,12 @@ export type Method = {
type: CodecTypes
};
export type SectionMethods<M> = {
[key in keyof M]: Method
};
export type Section<M> = {
export type Section = {
isDeprecated: boolean,
isHidden: boolean,
description: string,
name: string,
methods: SectionMethods<M>
section: string,
methods: {
[index: string]: Method
}
};