Kagome
Polkadot Runtime Engine in C++17
submit_and_watch_extrinsic.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_SUBMIT_AND_WATCH_EXTRINSIC_HPP
7 #define KAGOME_SUBMIT_AND_WATCH_EXTRINSIC_HPP
8 
9 #include <jsonrpc-lean/request.h>
10 
12 #include "primitives/extrinsic.hpp"
13 
15 
17  : public details::RequestType<primitives::SubscriptionId, std::string> {
18  public:
19  explicit SubmitAndWatchExtrinsic(std::shared_ptr<AuthorApi> api)
20  : api_(std::move(api)) {
21  BOOST_ASSERT(api_);
22  };
23 
24  outcome::result<primitives::SubscriptionId> 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_->submitAndWatchExtrinsic(extrinsic);
29  }
30 
31  private:
32  std::shared_ptr<AuthorApi> api_;
33  };
34 
35 } // namespace kagome::api::author::request
36 
37 #endif // KAGOME_SUBMIT_AND_WATCH_EXTRINSIC_HPP
outcome::result< primitives::SubscriptionId > 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
STL namespace.