8 #include "scale/scale.hpp" 13 const jsonrpc::Request::Parameters ¶ms) {
14 if (params.size() > 4 or params.size() <= 1) {
15 throw jsonrpc::InvalidParametersFault(
"Incorrect number of params");
17 auto ¶m0 = params[0];
19 if (not param0.IsString() and not param0.IsNil()) {
20 throw jsonrpc::InvalidParametersFault(
21 "Parameter '[prefix]' must be a hex string");
27 }
else if (param0.IsString()) {
29 prefix_.emplace(std::move(key));
31 throw jsonrpc::InvalidParametersFault(
32 "Parameter '[prefix]' must be a hex string");
35 if (not params[1].IsInteger32()) {
36 throw jsonrpc::InvalidParametersFault(
37 "Parameter '[key_amount]' must be a uint32_t");
41 if (params.size() == 2) {
42 return outcome::success();
46 if (not params[2].IsNil()) {
47 if (not params[2].IsString()) {
48 throw jsonrpc::InvalidParametersFault(
49 "Parameter '[prev_key]' must be a hex string representation of an " 50 "encoded optional byte sequence");
56 if (params.size() == 3) {
57 return outcome::success();
61 if (not params[3].IsString()) {
62 throw jsonrpc::InvalidParametersFault(
63 "Parameter '[at]' must be a hex string representation of an encoded " 64 "optional byte sequence");
70 return outcome::success();
outcome::result< std::vector< common::Buffer > > execute()
outcome::result< void > init(const jsonrpc::Request::Parameters ¶ms)
outcome::result< std::vector< uint8_t > > unhexWith0x(std::string_view hex_with_prefix)
Unhex hex-string with 0x in the begining.
std::optional< primitives::BlockHash > at_
std::optional< common::Buffer > prev_key_
static outcome::result< Blob< size_ > > fromSpan(const gsl::span< const uint8_t > &span)
std::optional< common::Buffer > prefix_
std::shared_ptr< StateApi > api_