Kagome
Polkadot Runtime Engine in C++17
has_key.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_REQUESTS_HAS_KEY_HPP
7 #define KAGOME_REQUESTS_HAS_KEY_HPP
8 
9 #include <jsonrpc-lean/request.h>
10 
13 #include "outcome/outcome.hpp"
14 
16 
17  class HasKey final
18  : public details::RequestType<bool, std::string, std::string> {
19  public:
20  explicit HasKey(std::shared_ptr<AuthorApi> api) : api_(std::move(api)) {
21  BOOST_ASSERT(api_);
22  };
23 
24  outcome::result<Return> execute() override {
25  OUTCOME_TRY(public_key, common::unhexWith0x(getParam<0>()));
26  return api_->hasKey(gsl::span(public_key.data(), public_key.size()),
27  crypto::decodeKeyTypeIdFromStr(getParam<1>()));
28  }
29 
30  private:
31  std::shared_ptr<AuthorApi> api_;
32  };
33 
34 } // namespace kagome::api::author::request
35 
36 #endif // KAGOME_REQUESTS_HAS_KEY_HPP
outcome::result< std::vector< uint8_t > > unhexWith0x(std::string_view hex_with_prefix)
Unhex hex-string with 0x in the begining.
Definition: hexutil.cpp:89
STL namespace.
HasKey(std::shared_ptr< AuthorApi > api)
Definition: has_key.hpp:20
std::shared_ptr< AuthorApi > api_
Definition: has_key.hpp:31
outcome::result< Return > execute() override
Definition: has_key.hpp:24
KeyTypeId decodeKeyTypeIdFromStr(std::string_view str)
restores KeyTypeId from its string representation
Definition: key_type.cpp:35