Kagome
Polkadot Runtime Engine in C++17
submit_extrinsic.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_SUBMIT_EXTRINSIC_HPP
7 #define KAGOME_SUBMIT_EXTRINSIC_HPP
8 
9 #include <jsonrpc-lean/request.h>
10 
12 #include "primitives/extrinsic.hpp"
13 
15 
16  class SubmitExtrinsic final
17  : public details::RequestType<common::Hash256, std::string> {
18  public:
19  explicit SubmitExtrinsic(std::shared_ptr<AuthorApi> api)
20  : api_(std::move(api)) {
21  BOOST_ASSERT(api_);
22  };
23 
24  outcome::result<common::Hash256> execute() override {
25  auto ext_hex = getParam<0>();
26  OUTCOME_TRY(buffer, common::unhexWith0x(ext_hex));
27  OUTCOME_TRY(extrinsic, scale::decode<primitives::Extrinsic>(buffer));
28  return api_->submitExtrinsic(primitives::TransactionSource::External,
29  extrinsic);
30  }
31 
32  private:
33  std::shared_ptr<AuthorApi> api_;
34  };
35 
36 } // namespace kagome::api::author::request
37 
38 #endif // KAGOME_SUBMIT_EXTRINSIC_HPP
outcome::result< common::Hash256 > execute() override
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
SubmitExtrinsic(std::shared_ptr< AuthorApi > api)
STL namespace.