Mortal -> Extrinsic, expand for decoding start (#212)
* Mortal -> Extrinsic, expand for decoding start
* Method, Section -> Rpc{Method, Section}
* Only expose callIndex
* CallIndex -> MethodIndex in spec
This commit is contained in:
@@ -2,18 +2,18 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { MethodOpt, Section } from './types';
|
||||
import { RpcMethodOpt, RpcSection } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
const pendingExtrinsics: MethodOpt = {
|
||||
const pendingExtrinsics: RpcMethodOpt = {
|
||||
description: 'Returns all pending extrinsics, potentially grouped by sender',
|
||||
params: [],
|
||||
type: 'PendingExtrinsics'
|
||||
};
|
||||
|
||||
const submitExtrinsic: MethodOpt = {
|
||||
const submitExtrinsic: RpcMethodOpt = {
|
||||
isSigned: true,
|
||||
description: 'Submit a fully formatted extrinsic for block inclusion',
|
||||
params: [
|
||||
@@ -36,4 +36,4 @@ export default {
|
||||
pendingExtrinsics: createMethod(section, 'pendingExtrinsics', pendingExtrinsics),
|
||||
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic)
|
||||
}
|
||||
} as Section;
|
||||
} as RpcSection;
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { MethodOpt, Section } from './types';
|
||||
import { RpcMethodOpt, RpcSection } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
const getBlock: MethodOpt = {
|
||||
const getBlock: RpcMethodOpt = {
|
||||
description: 'Get header and body of a relay chain block',
|
||||
params: [
|
||||
createParam('hash', 'Hash')
|
||||
@@ -15,7 +15,7 @@ const getBlock: MethodOpt = {
|
||||
type: 'SignedBlock'
|
||||
};
|
||||
|
||||
const getBlockHash: MethodOpt = {
|
||||
const getBlockHash: RpcMethodOpt = {
|
||||
description: 'Get the block hash for a specific block',
|
||||
params: [
|
||||
createParam('blockNumber', 'BlockNumber', { isOptional: true })
|
||||
@@ -23,13 +23,13 @@ const getBlockHash: MethodOpt = {
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getHead: MethodOpt = {
|
||||
const getHead: RpcMethodOpt = {
|
||||
description: 'Retrieves the best headerHash',
|
||||
params: [],
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getHeader: MethodOpt = {
|
||||
const getHeader: RpcMethodOpt = {
|
||||
description: 'Retrieves the header for a specific block',
|
||||
params: [
|
||||
createParam('hash', 'Hash')
|
||||
@@ -37,13 +37,13 @@ const getHeader: MethodOpt = {
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const getRuntimeVersion: MethodOpt = {
|
||||
const getRuntimeVersion: RpcMethodOpt = {
|
||||
description: ' Get the runtime version',
|
||||
params: [],
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
|
||||
const getRuntimeVersionAt: MethodOpt = {
|
||||
const getRuntimeVersionAt: RpcMethodOpt = {
|
||||
description: ' Get the runtime version at a specific block',
|
||||
params: [
|
||||
createParam('hash', 'Hash')
|
||||
@@ -51,7 +51,7 @@ const getRuntimeVersionAt: MethodOpt = {
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
|
||||
const newHead: MethodOpt = {
|
||||
const newHead: RpcMethodOpt = {
|
||||
description: 'Retrieves the best header via subscription',
|
||||
subscribe: [
|
||||
'chain_subscribeNewHead',
|
||||
@@ -80,4 +80,4 @@ export default {
|
||||
getRuntimeVersionAt: createMethod(section, 'getRuntimeVersionAt', getRuntimeVersionAt),
|
||||
newHead: createMethod(section, 'newHead', newHead)
|
||||
}
|
||||
} as Section;
|
||||
} as RpcSection;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { MethodOpt, Method } from '../types';
|
||||
import { RpcMethodOpt, RpcMethod } from '../types';
|
||||
|
||||
import isUndefined from '@polkadot/util/is/undefined';
|
||||
|
||||
export default function createMethod (section: string, method: string, { description, params, type, isDeprecated = false, isHidden = false, isSigned = false, subscribe }: MethodOpt): Method {
|
||||
export default function createMethod (section: string, method: string, { description, params, type, isDeprecated = false, isHidden = false, isSigned = false, subscribe }: RpcMethodOpt): RpcMethod {
|
||||
return {
|
||||
description,
|
||||
isDeprecated,
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { CodecTypes } from '@polkadot/types/types';
|
||||
import { Param } from '../types';
|
||||
import { RpcParam } from '../types';
|
||||
|
||||
type ParamOptions = {
|
||||
type RpcParamOptions = {
|
||||
isOptional?: boolean
|
||||
};
|
||||
|
||||
export default function createParam (name: string, type: CodecTypes, { isOptional = false }: ParamOptions = { isOptional: false }): Param {
|
||||
export default function createParam (name: string, type: CodecTypes, { isOptional = false }: RpcParamOptions = { isOptional: false }): RpcParam {
|
||||
return {
|
||||
isOptional,
|
||||
name,
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { MethodOpt, Section } from './types';
|
||||
import { RpcMethodOpt, RpcSection } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
const call: MethodOpt = {
|
||||
const call: RpcMethodOpt = {
|
||||
description: 'Perform a call to a builtin on the chain',
|
||||
params: [
|
||||
createParam('method', 'Text'),
|
||||
@@ -16,7 +16,7 @@ const call: MethodOpt = {
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const callAt: MethodOpt = {
|
||||
const callAt: RpcMethodOpt = {
|
||||
description: 'Perform a call to a builtin on the chain (At block)',
|
||||
params: [
|
||||
createParam('method', 'Text'),
|
||||
@@ -26,13 +26,13 @@ const callAt: MethodOpt = {
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const getMetadata: MethodOpt = {
|
||||
const getMetadata: RpcMethodOpt = {
|
||||
description: 'Returns the runtime metadata',
|
||||
params: [],
|
||||
type: 'Metadata'
|
||||
};
|
||||
|
||||
const getMetadataAt: MethodOpt = {
|
||||
const getMetadataAt: RpcMethodOpt = {
|
||||
description: 'Returns the runtime metadata',
|
||||
params: [
|
||||
createParam('block', 'Hash')
|
||||
@@ -40,7 +40,7 @@ const getMetadataAt: MethodOpt = {
|
||||
type: 'Metadata'
|
||||
};
|
||||
|
||||
const getStorage: MethodOpt = {
|
||||
const getStorage: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage for a key',
|
||||
params: [
|
||||
createParam('key', 'StorageKey')
|
||||
@@ -48,7 +48,7 @@ const getStorage: MethodOpt = {
|
||||
type: 'StorageData'
|
||||
};
|
||||
|
||||
const getStorageAt: MethodOpt = {
|
||||
const getStorageAt: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage for a key at a specific block',
|
||||
params: [
|
||||
createParam('key', 'Bytes'),
|
||||
@@ -57,7 +57,7 @@ const getStorageAt: MethodOpt = {
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const getStorageHash: MethodOpt = {
|
||||
const getStorageHash: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage hash',
|
||||
params: [
|
||||
createParam('key', 'Bytes')
|
||||
@@ -65,7 +65,7 @@ const getStorageHash: MethodOpt = {
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getStorageHashAt: MethodOpt = {
|
||||
const getStorageHashAt: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage hash at a specific block',
|
||||
params: [
|
||||
createParam('key', 'Bytes'),
|
||||
@@ -74,7 +74,7 @@ const getStorageHashAt: MethodOpt = {
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getStorageSize: MethodOpt = {
|
||||
const getStorageSize: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage size',
|
||||
params: [
|
||||
createParam('key', 'Bytes')
|
||||
@@ -82,7 +82,7 @@ const getStorageSize: MethodOpt = {
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
const getStorageSizeAt: MethodOpt = {
|
||||
const getStorageSizeAt: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage size at a specific block',
|
||||
params: [
|
||||
createParam('key', 'Bytes'),
|
||||
@@ -91,7 +91,7 @@ const getStorageSizeAt: MethodOpt = {
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
const storage: MethodOpt = {
|
||||
const storage: RpcMethodOpt = {
|
||||
description: 'Subscribes to storage changes for the provided keys',
|
||||
subscribe: [
|
||||
'state_subscribeStorage',
|
||||
@@ -127,4 +127,4 @@ export default {
|
||||
getStorageSizeAt: createMethod(section, 'getStorageSizeAt', getStorageSizeAt),
|
||||
storage: createMethod(section, 'storage', storage)
|
||||
}
|
||||
} as Section;
|
||||
} as RpcSection;
|
||||
|
||||
@@ -2,23 +2,23 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
|
||||
import { MethodOpt, Section } from './types';
|
||||
import { RpcMethodOpt, RpcSection } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
|
||||
const chain: MethodOpt = {
|
||||
const chain: RpcMethodOpt = {
|
||||
description: 'Retrieves the chain',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const name: MethodOpt = {
|
||||
const name: RpcMethodOpt = {
|
||||
description: 'Retrieves the node name',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const version: MethodOpt = {
|
||||
const version: RpcMethodOpt = {
|
||||
description: 'Retrieves the version of the node',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
@@ -39,4 +39,4 @@ export default {
|
||||
name: createMethod(section, 'name', name),
|
||||
version: createMethod(section, 'version', version)
|
||||
}
|
||||
} as Section;
|
||||
} as RpcSection;
|
||||
|
||||
Vendored
+7
-7
@@ -4,24 +4,24 @@
|
||||
|
||||
import { CodecTypes } from '@polkadot/types/types';
|
||||
|
||||
export type Param = {
|
||||
export type RpcParam = {
|
||||
isOptional: boolean,
|
||||
name: string,
|
||||
type: CodecTypes
|
||||
};
|
||||
|
||||
export type MethodOpt = {
|
||||
export type RpcMethodOpt = {
|
||||
description: string,
|
||||
isDeprecated?: boolean,
|
||||
isHidden?: boolean,
|
||||
isSigned?: boolean,
|
||||
isSubscription?: boolean,
|
||||
params: Array<Param>,
|
||||
params: Array<RpcParam>,
|
||||
subscribe?: [string, string],
|
||||
type: CodecTypes
|
||||
};
|
||||
|
||||
export type Method = {
|
||||
export type RpcMethod = {
|
||||
alias?: string,
|
||||
description: string,
|
||||
isDeprecated: boolean,
|
||||
@@ -29,18 +29,18 @@ export type Method = {
|
||||
isSigned: boolean,
|
||||
isSubscription: boolean,
|
||||
method: string,
|
||||
params: Array<Param>,
|
||||
params: Array<RpcParam>,
|
||||
section: string,
|
||||
subscribe: [string, string],
|
||||
type: CodecTypes
|
||||
};
|
||||
|
||||
export type Section = {
|
||||
export type RpcSection = {
|
||||
isDeprecated: boolean,
|
||||
isHidden: boolean,
|
||||
description: string,
|
||||
section: string,
|
||||
methods: {
|
||||
[index: string]: Method
|
||||
[index: string]: RpcMethod
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user