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:
@@ -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)
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user