diff --git a/packages/api-jsonrpc/src/extra/getBlockNumber.js b/packages/api-jsonrpc/src/extra/getBlockNumber.js deleted file mode 100644 index c941ef0d82..0000000000 --- a/packages/api-jsonrpc/src/extra/getBlockNumber.js +++ /dev/null @@ -1,19 +0,0 @@ -// 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 getBlockNumber - @signature extra_getBlockNumber (): BlockNumber - @summary Retrieves the best blockNumber - @description - Returns the best blockNumber available on the client -*/ -module.exports = ({ - isSubscription: true, - inputs: [], - output: { type: 'BlockNumber' } -}: InterfaceMethodDefinition); diff --git a/packages/api-jsonrpc/src/extra/getClientTime.js b/packages/api-jsonrpc/src/extra/getClientTime.js deleted file mode 100644 index 0bef7ad2f4..0000000000 --- a/packages/api-jsonrpc/src/extra/getClientTime.js +++ /dev/null @@ -1,19 +0,0 @@ -// 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 getClientTime - @signature extra_getClientTime (): U64 - @summary Retrieves the current time - @description - Returns the current time on the running node -*/ -module.exports = ({ - isSubscription: true, - inputs: [], - output: { type: 'U64' } -}: InterfaceMethodDefinition); diff --git a/packages/api-jsonrpc/src/extra/index.js b/packages/api-jsonrpc/src/extra/index.js deleted file mode 100644 index e7ada3fbda..0000000000 --- a/packages/api-jsonrpc/src/extra/index.js +++ /dev/null @@ -1,19 +0,0 @@ -// 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 { InterfaceDefinition } from '../types'; - -const getBlockNumber = require('./getBlockNumber'); -const getClientTime = require('./getClientTime'); - -/** - @summary Extended methods not available in all clients. -*/ -module.exports = ({ - methods: { - getBlockNumber, - getClientTime - } -}: InterfaceDefinition); diff --git a/packages/api-jsonrpc/src/index.js b/packages/api-jsonrpc/src/index.js index ab2b2722d0..a9611a81aa 100644 --- a/packages/api-jsonrpc/src/index.js +++ b/packages/api-jsonrpc/src/index.js @@ -7,7 +7,6 @@ import type { InterfaceDefinitions } from './types'; const author = require('./author'); const chain = require('./chain'); -const extra = require('./extra'); const state = require('./state'); /** @@ -16,6 +15,5 @@ const state = require('./state'); module.exports = ({ author, chain, - extra, state }: InterfaceDefinitions); diff --git a/packages/api-jsonrpc/src/types.js b/packages/api-jsonrpc/src/types.js index 9366a36787..6493a5f201 100644 --- a/packages/api-jsonrpc/src/types.js +++ b/packages/api-jsonrpc/src/types.js @@ -3,7 +3,7 @@ // of the ISC license. See the LICENSE file for details. // @flow -export type InterfaceTypes = 'author' | 'chain' | 'extra' | 'state'; +export type InterfaceTypes = 'author' | 'chain' | 'state'; export type FormatInputType = 'Bytes' | 'H256' | 'HeaderHash' | 'String'; diff --git a/packages/api-provider/src/mock/mocks.js b/packages/api-provider/src/mock/mocks.js index 0ae3102bfd..8b6bce582f 100644 --- a/packages/api-provider/src/mock/mocks.js +++ b/packages/api-provider/src/mock/mocks.js @@ -45,11 +45,6 @@ module.exports = function mocks ({ subscriptions }: MockState): void { setInterval(() => { newHead = makeBlockHeader(newHead.number); - updateSubs('extra_getBlockNumber', `0x${(newHead.number).toString(16)}`); - updateSubs('chain_newHead', newHead); + updateSubs('subscribe_newHead', newHead); }, 5000); - - setInterval(() => { - updateSubs('extra_getClientTime', `0x${Date.now().toString(16)}`); - }, 1000); }; diff --git a/packages/api-provider/src/mock/state.js b/packages/api-provider/src/mock/state.js index 3110ff2ecb..aa58ecf98d 100644 --- a/packages/api-provider/src/mock/state.js +++ b/packages/api-provider/src/mock/state.js @@ -13,7 +13,7 @@ const METHODS = Array.prototype.concat.apply( return Object .keys(interfaces[section].methods) .filter((method) => interfaces[section].methods[method].isSubscription) - .map((method) => `${section}_${method}`); + .map((method) => `subscribe_${method}`); }) ); diff --git a/packages/api-provider/src/mock/state.spec.js b/packages/api-provider/src/mock/state.spec.js index e628639c7b..f3ed44b747 100644 --- a/packages/api-provider/src/mock/state.spec.js +++ b/packages/api-provider/src/mock/state.spec.js @@ -24,7 +24,7 @@ describe('state', () => { expect( state.subscriptions ).toMatchObject({ - 'extra_getBlockNumber': { + 'subscribe_newHead': { callbacks: {}, lastValue: null } diff --git a/packages/api-provider/src/mock/subscribe.spec.js b/packages/api-provider/src/mock/subscribe.spec.js index c42d2b77c1..5876652521 100644 --- a/packages/api-provider/src/mock/subscribe.spec.js +++ b/packages/api-provider/src/mock/subscribe.spec.js @@ -19,7 +19,7 @@ describe('subscribe', () => { }); it('returns a subscription id', () => { - return subscribe(state, 'extra_getBlockNumber', [() => void 0]).then((id) => { + return subscribe(state, 'subscribe_newHead', [() => void 0]).then((id) => { expect(id).toEqual(state.subscriptionId); }); }); @@ -27,16 +27,16 @@ describe('subscribe', () => { it('stores the mapping values', () => { const cb = () => void 0; - return subscribe(state, 'extra_getBlockNumber', [cb]).then((id) => { - expect(state.subscriptionMap[id]).toEqual('extra_getBlockNumber'); - expect(state.subscriptions['extra_getBlockNumber'].callbacks[id]).toEqual(cb); + return subscribe(state, 'subscribe_newHead', [cb]).then((id) => { + expect(state.subscriptionMap[id]).toEqual('subscribe_newHead'); + expect(state.subscriptions['subscribe_newHead'].callbacks[id]).toEqual(cb); }); }); it('calls back with the last known value', (done) => { - state.subscriptions['extra_getBlockNumber'].lastValue = 'testValue'; + state.subscriptions['subscribe_newHead'].lastValue = 'testValue'; - subscribe(state, 'extra_getBlockNumber', [(_, value) => { + subscribe(state, 'subscribe_newHead', [(_, value) => { expect(value).toEqual('testValue'); done(); }]); diff --git a/packages/api-provider/src/mock/unsubscribe.js b/packages/api-provider/src/mock/unsubscribe.js index 5ed40caf19..28d24c4b24 100644 --- a/packages/api-provider/src/mock/unsubscribe.js +++ b/packages/api-provider/src/mock/unsubscribe.js @@ -5,7 +5,7 @@ import type { MockState } from './types'; -module.exports = async function subscribe (self: MockState, _: string, id: number): Promise { +module.exports = async function unsubscribe (self: MockState, _: string, id: number): Promise { const method = self.subscriptionMap[id]; self.l.debug(() => ['unsubscribe', id, method]); diff --git a/packages/api-provider/src/mock/unsubscribe.spec.js b/packages/api-provider/src/mock/unsubscribe.spec.js index 6d3efadd3c..a064d2c9aa 100644 --- a/packages/api-provider/src/mock/unsubscribe.spec.js +++ b/packages/api-provider/src/mock/unsubscribe.spec.js @@ -13,23 +13,23 @@ describe('unsubscribe', () => { beforeEach(() => { state = createState(); - return subscribe(state, 'extra_getBlockNumber', [() => void 0]).then((_id) => { + return subscribe(state, 'subscribe_newHead', [() => void 0]).then((_id) => { id = _id; }); }); it('fails on unknown ids', () => { - return unsubscribe(state, 'extra_getBlockNumber', 5).catch((error) => { + return unsubscribe(state, 'subscribe_newHead', 5).catch((error) => { expect(error.message).toMatch(/Unable to find/); }); }); it('unsubscribes successfully', () => { - return unsubscribe(state, 'extra_getBlockNumber', id); + return unsubscribe(state, 'subscribe_newHead', id); }); it('fails on double unsubscribe', () => { - return unsubscribe(state, 'extra_getBlockNumber', id) + return unsubscribe(state, 'subscribe_newHead', id) .then(() => unsubscribe(state, id)) .catch((error) => { expect(error.message).toMatch(/Unable to find/); @@ -37,9 +37,9 @@ describe('unsubscribe', () => { }); it('clears the subscriptions', () => { - return unsubscribe(state, 'extra_getBlockNumber', id).then(() => { + return unsubscribe(state, 'subscribe_newHead', id).then(() => { expect(state.subscriptionMap[id]).not.toBeDefined(); - expect(state.subscriptions['extra_getBlockNumber'].callbacks[id]).not.toBeDefined(); + expect(state.subscriptions['subscribe_newHead'].callbacks[id]).not.toBeDefined(); }); }); });