8 #include "scale/scale.hpp" 13 const jsonrpc::Request::Parameters ¶ms) {
16 if (params.size() > 5 or params.size() < 3) {
17 throw jsonrpc::InvalidParametersFault(
"Incorrect number of params");
20 auto ¶m0 = params[0];
22 if (not param0.IsString() or param0.IsNil()) {
23 throw jsonrpc::InvalidParametersFault(
24 "Parameter '[child_storage_key]' must be a hex string");
30 auto ¶m1 = params[1];
32 if (not param1.IsString() and not param1.IsNil()) {
33 throw jsonrpc::InvalidParametersFault(
34 "Parameter '[prefix]' must be a hex string");
39 }
else if (param1.IsString()) {
43 throw jsonrpc::InvalidParametersFault(
44 "Parameter '[prefix]' must be a hex string");
47 if (not params[2].IsInteger32()) {
48 throw jsonrpc::InvalidParametersFault(
49 "Parameter '[key_amount]' must be a uint32_t");
53 if (params.size() == 3) {
54 return outcome::success();
58 if (not params[3].IsNil()) {
59 if (not params[3].IsString()) {
60 throw jsonrpc::InvalidParametersFault(
61 "Parameter '[prev_key]' must be a hex string representation of an " 62 "encoded optional byte sequence");
68 if (params.size() == 4) {
69 return outcome::success();
73 if (not params[4].IsString()) {
74 throw jsonrpc::InvalidParametersFault(
75 "Parameter '[at]' must be a hex string representation of an encoded " 76 "optional byte sequence");
82 return outcome::success();
86 return api_->getKeysPaged(
Class represents arbitrary (including empty) byte buffer.
outcome::result< std::vector< uint8_t > > unhexWith0x(std::string_view hex_with_prefix)
Unhex hex-string with 0x in the begining.
std::optional< common::Buffer > prefix_
outcome::result< void > init(const jsonrpc::Request::Parameters ¶ms)
SLBuffer< std::numeric_limits< size_t >::max()> Buffer
std::optional< common::Buffer > prev_key_
static outcome::result< Blob< size_ > > fromSpan(const gsl::span< const uint8_t > &span)
outcome::result< std::vector< common::Buffer > > execute()
common::Buffer child_storage_key_
std::optional< primitives::BlockHash > at_
std::shared_ptr< ChildStateApi > api_