API Subscriptions (#62)
* Upgrades * Add getHead & newHead * Handle pubsub interfaces * Flow fixes
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
// Copyright 2017-2018 Jaco Greeff
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
import type { InterfaceMethodDefinition } from '../types';
|
||||
|
||||
/**
|
||||
@name getHead
|
||||
@signature chain_getHead (): HeaderHash
|
||||
@summary Retrieves the best headerHash.
|
||||
@description
|
||||
Return the block hash for the lastest/best.
|
||||
*/
|
||||
module.exports = ({
|
||||
inputs: [],
|
||||
output: {
|
||||
type: 'HeaderHash'
|
||||
}
|
||||
}: InterfaceMethodDefinition);
|
||||
@@ -5,13 +5,17 @@
|
||||
|
||||
import type { InterfaceDefinition } from '../types';
|
||||
|
||||
const getHead = require('./getHead');
|
||||
const getHeader = require('./getHeader');
|
||||
const newHead = require('./newHead');
|
||||
|
||||
/**
|
||||
@summary Methods to retrieve chain data.
|
||||
*/
|
||||
module.exports = ({
|
||||
methods: {
|
||||
getHeader
|
||||
getHead,
|
||||
getHeader,
|
||||
newHead
|
||||
}
|
||||
}: InterfaceDefinition);
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright 2017-2018 Jaco Greeff
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the ISC license. See the LICENSE file for details.
|
||||
// @flow
|
||||
|
||||
import type { InterfaceMethodDefinition } from '../types';
|
||||
|
||||
/**
|
||||
@name getHead
|
||||
@signature chain_newHead (): HeaderHash
|
||||
@summary Retrieves the best headerHash via subscription.
|
||||
@description
|
||||
Return the block hash for the lastest/best.
|
||||
*/
|
||||
module.exports = ({
|
||||
isSubscription: true,
|
||||
inputs: [],
|
||||
output: {
|
||||
type: 'HeaderHash'
|
||||
}
|
||||
}: InterfaceMethodDefinition);
|
||||
@@ -7,7 +7,7 @@ export type InterfaceTypes = 'author' | 'chain' | 'extra' | 'state';
|
||||
|
||||
export type FormatInputType = 'Bytes' | 'H256' | 'HeaderHash' | 'String';
|
||||
|
||||
export type FormatOutputType = 'BlockNumber' | 'Bytes' | 'Header' | 'U64';
|
||||
export type FormatOutputType = 'BlockNumber' | 'Bytes' | 'Header' | 'HeaderHash' | 'U64';
|
||||
|
||||
export type InterfaceInputType = {
|
||||
name: string,
|
||||
@@ -18,8 +18,14 @@ export type InterfaceOutputType = {
|
||||
type: FormatOutputType
|
||||
};
|
||||
|
||||
export type InterfaceMethodDefinition$Subscribe = {
|
||||
subscribe: string,
|
||||
unsubscribe: string
|
||||
}
|
||||
|
||||
export type InterfaceMethodDefinition = {
|
||||
deprecated?: boolean,
|
||||
isDeprecated?: boolean,
|
||||
isSubscription?: boolean,
|
||||
inputs: Array<InterfaceInputType>,
|
||||
output: InterfaceOutputType
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user