Skip to content
10 changes: 10 additions & 0 deletions prdoc/pr_10329.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: 'fix: support `paginationStartKey` parameter for `archive_v1_storage`'
doc:
- audience: Node Dev
description: |-
Fixes #10185

This PR is to add support for `paginationStartKey` parameter in `archive_v1_storage` JSON RPC API for query type: `descendantsValues` and `descendantsHashes` per [the latest specs](https://paritytech.github.io/json-rpc-interface-spec/api/archive_v1_storage.html).
crates:
- name: sc-rpc-spec-v2
bump: major
22 changes: 19 additions & 3 deletions substrate/client/rpc-spec-v2/src/archive/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,29 @@ where
.into_iter()
.map(|query| {
let key = StorageKey(parse_hex_param(query.key)?);
Ok(StorageQuery { key, query_type: query.query_type })

// Validate that paginationStartKey is only used with descendant queries
if query.pagination_start_key.is_some() &&
!query.query_type.is_descendant_query()
{
return Err(ArchiveError::InvalidParam(
"paginationStartKey is only valid for descendantsValues and descendantsHashes query types"
.to_string(),
));
}

let pagination_start_key = query
.pagination_start_key
.map(|key| parse_hex_param(key).map(StorageKey))
.transpose()?;

Ok(StorageQuery { key, query_type: query.query_type, pagination_start_key })
})
.collect::<Result<Vec<_>, ArchiveError>>()
{
Ok(items) => items,
Err(error) => {
let _ = sink.send(&ArchiveStorageEvent::err(error.to_string()));
let _ = sink.send(&ArchiveStorageEvent::err(error.to_string())).await;
return
},
};
Expand All @@ -246,7 +262,7 @@ where
let child_trie = match child_trie {
Ok(child_trie) => child_trie.map(ChildInfo::new_default_from_vec),
Err(error) => {
let _ = sink.send(&ArchiveStorageEvent::err(error.to_string()));
let _ = sink.send(&ArchiveStorageEvent::err(error.to_string())).await;
return
},
};
Expand Down
Loading
Loading