Add storage subscription API endpoints (#126)

* Add storage subscriptions

* StorageResult formatting

* Decoding WIP

* Storage subsciptions in place

* Allow null decodes, ref https://github.com/polkadot-js/apps/issues/215

* e2e tests for subscribeStorage

* Cache subscription results, return with changeset
This commit is contained in:
Jaco Greeff
2018-08-11 20:50:57 +02:00
committed by GitHub
parent 4d815ef726
commit 187c66f600
50 changed files with 463 additions and 278 deletions
+3 -3
View File
@@ -22,7 +22,7 @@ const getHeader: CreateItemOptions = {
type: 'Header'
};
const newHead: CreateItemOptions = {
const subscribeNewHead: CreateItemOptions = {
description: 'Retrieves the best header via subscription',
isSubscription: true,
params: [],
@@ -40,7 +40,7 @@ export default (name: Interface$Sections): Section<Interfaces> =>
createMethod('getHead')(getHead),
getHeader:
createMethod('getHeader')(getHeader),
newHead:
createMethod('newHead')(newHead)
subscribeNewHead:
createMethod('subscribeNewHead')(subscribeNewHead)
}
}));
+14 -3
View File
@@ -30,9 +30,9 @@ const callAt: CreateItemOptions = {
const getStorage: CreateItemOptions = {
description: 'Retrieves the storage for a key',
params: [
param('key', 'Bytes')
param('key', 'StorageKey')
],
type: 'Bytes'
type: 'StorageResult'
};
const getStorageAt: CreateItemOptions = {
@@ -78,6 +78,15 @@ const getStorageSizeAt: CreateItemOptions = {
type: 'u64'
};
const subscribeStorage: CreateItemOptions = {
description: 'Subscribes to storage changes for the provided keys',
isSubscription: true,
params: [
param('keys', ['StorageKey'])
],
type: 'StorageResultSet'
};
/**
* @summary Query the state and state storage.
*/
@@ -100,6 +109,8 @@ export default (name: Interface$Sections): Section<Interfaces> =>
getStorageSize:
createMethod('getStorageSize')(getStorageSize),
getStorageSizeAt:
createMethod('getStorageSizeAt')(getStorageSizeAt)
createMethod('getStorageSizeAt')(getStorageSizeAt),
subscribeStorage:
createMethod('subscribeStorage')(subscribeStorage)
}
}));