Update subscription naming handling (#266)
This commit is contained in:
committed by
Amaury Martiny
parent
1a4d60efcb
commit
78101e1292
@@ -22,17 +22,17 @@ const submitExtrinsic: RpcMethodOpt = {
|
||||
type: 'Hash'
|
||||
};
|
||||
|
||||
const extrinsicUpdate: RpcMethodOpt = {
|
||||
const submitAndWatchExtrinsic: RpcMethodOpt = {
|
||||
description: 'Subscribe and watch an extrinsic until unsubscribed',
|
||||
isSigned: true,
|
||||
isSubscription: true,
|
||||
subscribe: [
|
||||
'author_submitAndWatchExtrinsic',
|
||||
'author_unwatchExtrinsic'
|
||||
],
|
||||
params: [
|
||||
createParam('extinsic', 'Extrinsic')
|
||||
],
|
||||
pubsub: [
|
||||
'extrinsicUpdate',
|
||||
'submitAndWatchExtrinsic',
|
||||
'unwatchExtrinsic'
|
||||
],
|
||||
type: 'ExtrinsicStatus'
|
||||
};
|
||||
|
||||
@@ -49,6 +49,6 @@ export default {
|
||||
methods: {
|
||||
pendingExtrinsics: createMethod(section, 'pendingExtrinsics', pendingExtrinsics),
|
||||
submitExtrinsic: createMethod(section, 'submitExtrinsic', submitExtrinsic),
|
||||
extrinsicUpdate: createMethod(section, 'extrinsicUpdate', extrinsicUpdate)
|
||||
submitAndWatchExtrinsic: createMethod(section, 'submitAndWatchExtrinsic', submitAndWatchExtrinsic)
|
||||
}
|
||||
} as RpcSection;
|
||||
|
||||
@@ -47,13 +47,14 @@ const getRuntimeVersion: RpcMethodOpt = {
|
||||
type: 'RuntimeVersion'
|
||||
};
|
||||
|
||||
const newHead: RpcMethodOpt = {
|
||||
const subscribeNewHead: RpcMethodOpt = {
|
||||
description: 'Retrieves the best header via subscription',
|
||||
subscribe: [
|
||||
'chain_subscribeNewHead',
|
||||
'chain_unsubscribeNewHead'
|
||||
],
|
||||
params: [],
|
||||
pubsub: [
|
||||
'newHead',
|
||||
'subscribeNewHead',
|
||||
'unsubscribeNewHead'
|
||||
],
|
||||
type: 'Header'
|
||||
};
|
||||
|
||||
@@ -73,6 +74,6 @@ export default {
|
||||
getHead: createMethod(section, 'getHead', getHead),
|
||||
getHeader: createMethod(section, 'getHeader', getHeader),
|
||||
getRuntimeVersion: createMethod(section, 'getRuntimeVersion', getRuntimeVersion),
|
||||
newHead: createMethod(section, 'newHead', newHead)
|
||||
subscribeNewHead: createMethod(section, 'subscribeNewHead', subscribeNewHead)
|
||||
}
|
||||
} as RpcSection;
|
||||
|
||||
@@ -6,17 +6,17 @@ 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 }: RpcMethodOpt): RpcMethod {
|
||||
export default function createMethod (section: string, method: string, { description, isDeprecated = false, isHidden = false, isSigned = false, params, pubsub, type }: RpcMethodOpt): RpcMethod {
|
||||
return {
|
||||
description,
|
||||
isDeprecated,
|
||||
isHidden,
|
||||
isSigned,
|
||||
isSubscription: !isUndefined(subscribe),
|
||||
isSubscription: !isUndefined(pubsub),
|
||||
method,
|
||||
params,
|
||||
pubsub: pubsub || ['', '', ''],
|
||||
section,
|
||||
subscribe: subscribe || ['', ''],
|
||||
type
|
||||
};
|
||||
}
|
||||
|
||||
@@ -99,16 +99,17 @@ const queryStorage: RpcMethodOpt = {
|
||||
type: 'Vec<StorageChangeSet>'
|
||||
};
|
||||
|
||||
const storage: RpcMethodOpt = {
|
||||
const subscribeStorage: RpcMethodOpt = {
|
||||
description: 'Subscribes to storage changes for the provided keys',
|
||||
subscribe: [
|
||||
'state_subscribeStorage',
|
||||
'state_unsubscribeStorage'
|
||||
],
|
||||
params: [
|
||||
// @ts-ignore The Vec<> wrap is fine
|
||||
createParam('keys', 'Vec<StorageKey>')
|
||||
],
|
||||
pubsub: [
|
||||
'storage',
|
||||
'subscribeStorage',
|
||||
'unsubscribeStorage'
|
||||
],
|
||||
type: 'StorageChangeSet'
|
||||
};
|
||||
|
||||
@@ -133,6 +134,6 @@ export default {
|
||||
getStorageSize: createMethod(section, 'getStorageSize', getStorageSize),
|
||||
getStorageSizeAt: createMethod(section, 'getStorageSizeAt', getStorageSizeAt),
|
||||
queryStorage: createMethod(section, 'queryStorage', queryStorage),
|
||||
storage: createMethod(section, 'storage', storage)
|
||||
subscribeStorage: createMethod(section, 'subscribeStorage', subscribeStorage)
|
||||
}
|
||||
} as RpcSection;
|
||||
|
||||
Vendored
+2
-2
@@ -17,7 +17,7 @@ export type RpcMethodOpt = {
|
||||
isSigned?: boolean,
|
||||
isSubscription?: boolean,
|
||||
params: Array<RpcParam>,
|
||||
subscribe?: [string, string],
|
||||
pubsub?: [string, string, string],
|
||||
type: CodecTypes
|
||||
};
|
||||
|
||||
@@ -30,8 +30,8 @@ export type RpcMethod = {
|
||||
isSubscription: boolean,
|
||||
method: string,
|
||||
params: Array<RpcParam>,
|
||||
pubsub: [string, string, string],
|
||||
section: string,
|
||||
subscribe: [string, string],
|
||||
type: CodecTypes
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user