Align all RPC methods with Rust (#264)
* Align all RPC methods with Rust * Adjust tests for extrinsicUpdate (e2e & working) * Update transfer.spec.js Auto-complete imports removed
This commit is contained in:
@@ -22,6 +22,20 @@ const submitExtrinsic: RpcMethodOpt = {
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const extrinsicUpdate: RpcMethodOpt = {
|
||||
description: 'Subscribe and watch an extrinsic until unsubscribed',
|
||||
isSigned: true,
|
||||
isSubscription: true,
|
||||
subscribe: [
|
||||
'author_submitAndWatchExtrinsic',
|
||||
'author_unwatchExtrinsic'
|
||||
],
|
||||
params: [
|
||||
createParam('extinsic', 'Extrinsic')
|
||||
],
|
||||
type: 'ExtrinsicStatus'
|
||||
};
|
||||
|
||||
const section = 'author';
|
||||
|
||||
/**
|
||||
@@ -34,6 +48,7 @@ export default {
|
||||
section,
|
||||
methods: {
|
||||
pendingExtrinsics: createMethod(section, 'pendingExtrinsics', pendingExtrinsics),
|
||||
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic)
|
||||
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic),
|
||||
extrinsicUpdate: createMethod(section, 'extrinsicUpdate', extrinsicUpdate)
|
||||
}
|
||||
} as RpcSection;
|
||||
|
||||
@@ -7,10 +7,20 @@ import { RpcMethodOpt, RpcSection } from './types';
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE Order is the same as in Rust
|
||||
|
||||
const getHeader: RpcMethodOpt = {
|
||||
description: 'Retrieves the header for a specific block',
|
||||
params: [
|
||||
createParam('hash', 'Hash', { isOptional: true })
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const getBlock: RpcMethodOpt = {
|
||||
description: 'Get header and body of a relay chain block',
|
||||
params: [
|
||||
createParam('hash', 'Hash')
|
||||
createParam('hash', 'Hash', { isOptional: true })
|
||||
],
|
||||
type: 'SignedBlock'
|
||||
};
|
||||
@@ -29,24 +39,10 @@ const getHead: RpcMethodOpt = {
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const getHeader: RpcMethodOpt = {
|
||||
description: 'Retrieves the header for a specific block',
|
||||
params: [
|
||||
createParam('hash', 'Hash')
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
const getRuntimeVersion: RpcMethodOpt = {
|
||||
description: ' Get the runtime version',
|
||||
params: [],
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
|
||||
const getRuntimeVersionAt: RpcMethodOpt = {
|
||||
description: ' Get the runtime version at a specific block',
|
||||
params: [
|
||||
createParam('hash', 'Hash')
|
||||
createParam('hash', 'Hash', { isOptional: true })
|
||||
],
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
@@ -77,7 +73,6 @@ export default {
|
||||
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 RpcSection;
|
||||
|
||||
@@ -7,6 +7,8 @@ import { RpcMethodOpt, RpcSection } from './types';
|
||||
import createMethod from './create/method';
|
||||
import createParam from './create/param';
|
||||
|
||||
// NOTE Order here is the same as in the Rust code
|
||||
|
||||
const call: RpcMethodOpt = {
|
||||
description: 'Perform a call to a builtin on the chain',
|
||||
params: [
|
||||
@@ -26,20 +28,6 @@ const callAt: RpcMethodOpt = {
|
||||
type: 'Bytes'
|
||||
};
|
||||
|
||||
const getMetadata: RpcMethodOpt = {
|
||||
description: 'Returns the runtime metadata',
|
||||
params: [],
|
||||
type: 'Metadata'
|
||||
};
|
||||
|
||||
const getMetadataAt: RpcMethodOpt = {
|
||||
description: 'Returns the runtime metadata',
|
||||
params: [
|
||||
createParam('block', 'Hash')
|
||||
],
|
||||
type: 'Metadata'
|
||||
};
|
||||
|
||||
const getStorage: RpcMethodOpt = {
|
||||
description: 'Retrieves the storage for a key',
|
||||
params: [
|
||||
@@ -91,6 +79,26 @@ const getStorageSizeAt: RpcMethodOpt = {
|
||||
type: 'u64'
|
||||
};
|
||||
|
||||
const getMetadata: RpcMethodOpt = {
|
||||
description: 'Returns the runtime metadata',
|
||||
params: [
|
||||
createParam('block', 'Hash', { isOptional: true })
|
||||
],
|
||||
type: 'Metadata'
|
||||
};
|
||||
|
||||
const queryStorage: RpcMethodOpt = {
|
||||
description: 'Query historical storage entries (by key) starting from a start block',
|
||||
params: [
|
||||
// @ts-ignore The Vec<> wrap is fine
|
||||
createParam('keys', 'Vec<StorageKey>'),
|
||||
createParam('startBlock', 'Hash'),
|
||||
createParam('block', 'Hash', { isOptional: true })
|
||||
],
|
||||
// @ts-ignore The Vec<> wrap is fine
|
||||
type: 'Vec<StorageChangeSet>'
|
||||
};
|
||||
|
||||
const storage: RpcMethodOpt = {
|
||||
description: 'Subscribes to storage changes for the provided keys',
|
||||
subscribe: [
|
||||
@@ -118,13 +126,13 @@ export default {
|
||||
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),
|
||||
queryStorage: createMethod(section, 'queryStorage', queryStorage),
|
||||
storage: createMethod(section, 'storage', storage)
|
||||
}
|
||||
} as RpcSection;
|
||||
|
||||
@@ -6,11 +6,7 @@ import { RpcMethodOpt, RpcSection } from './types';
|
||||
|
||||
import createMethod from './create/method';
|
||||
|
||||
const chain: RpcMethodOpt = {
|
||||
description: 'Retrieves the chain',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
// NOTE order here is the same as in Rust, alphabetical below
|
||||
|
||||
const name: RpcMethodOpt = {
|
||||
description: 'Retrieves the node name',
|
||||
@@ -24,6 +20,12 @@ const version: RpcMethodOpt = {
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const chain: RpcMethodOpt = {
|
||||
description: 'Retrieves the chain',
|
||||
params: [],
|
||||
type: 'Text'
|
||||
};
|
||||
|
||||
const section = 'system';
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user