6 #ifndef KAGOME_API_REQUESTS_QUERY_STORAGE_H 7 #define KAGOME_API_REQUESTS_QUERY_STORAGE_H 11 #include <boost/range/adaptor/transformed.hpp> 12 #include <boost/range/algorithm_ext/push_back.hpp> 21 std::vector<jsonrpc::Value::Array> j_changes;
22 boost::range::push_back(
24 changes.
changes | boost::adaptors::transformed([](
auto &change) {
25 return jsonrpc::Value::Array{makeValue(change.key),
26 makeValue(change.data)};
29 return jsonrpc::Value::Struct{
31 std::pair{
"changes",
makeValue(j_changes)}};
40 std::vector<std::string>,
42 std::optional<std::string>> {
49 outcome::result<std::vector<StateApi::StorageChangeSet>>
execute()
51 std::vector<common::Buffer> keys;
52 keys.reserve(getParam<0>().size());
53 for (
auto &str_key : getParam<0>()) {
55 keys.emplace_back(std::move(key));
59 std::optional<primitives::BlockHash> to{};
60 if (
auto opt_to = getParam<2>(); opt_to.has_value()) {
65 return api_->queryStorage(keys, from, std::move(to));
69 std::shared_ptr<StateApi>
api_;
74 std::vector<std::string>,
75 std::optional<std::string>> {
82 outcome::result<std::vector<StateApi::StorageChangeSet>>
execute()
84 std::vector<common::Buffer> keys;
85 keys.reserve(getParam<0>().size());
86 for (
auto &str_key : getParam<0>()) {
88 keys.emplace_back(std::move(key));
90 std::optional<primitives::BlockHash> at{};
91 if (
auto opt_at = getParam<1>(); opt_at.has_value()) {
97 return api_->queryStorageAt(keys, std::move(at));
101 std::shared_ptr<StateApi>
api_;
106 #endif // KAGOME_API_REQUESTS_QUERY_STORAGE_H
std::shared_ptr< StateApi > api_
outcome::result< std::vector< uint8_t > > unhexWith0x(std::string_view hex_with_prefix)
Unhex hex-string with 0x in the begining.
outcome::result< std::vector< StateApi::StorageChangeSet > > execute() override
QueryStorageAt(std::shared_ptr< StateApi > api)
std::vector< Change > changes
static outcome::result< Blob< size_ > > fromHexWithPrefix(std::string_view hex)
QueryStorage(std::shared_ptr< StateApi > api)
std::string hex_lower_0x(gsl::span< const uint8_t > bytes) noexcept
Converts bytes to hex representation with prefix 0x.
jsonrpc::Value makeValue(const uint32_t &)
std::shared_ptr< StateApi > api_
outcome::result< std::vector< StateApi::StorageChangeSet > > execute() override