hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
engine_receipt.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SHARED_MODEL_INTERFACE_ENGINE_RECEIPT_HPP
7 #define IROHA_SHARED_MODEL_INTERFACE_ENGINE_RECEIPT_HPP
8 
9 #include <iosfwd>
10 
11 #include <boost/optional.hpp>
15 
16 namespace shared_model {
17  namespace interface {
18 
20  class EngineReceipt : public ModelPrimitive<EngineReceipt> {
21  public:
22  enum struct PayloadType {
26  };
27 
28  struct CallResult {
30  std::optional<types::EvmDataHexString> const &response_data;
31 
32  bool operator==(CallResult const &c) const {
33  return c.callee == callee && c.response_data == response_data;
34  }
35 
36  std::string toString() const;
37  };
38 
39  static char const *payloadTypeToStr(PayloadType pt) {
40  switch (pt) {
42  return "Call result";
44  return "Contract address";
45  default:
46  return "Unknown";
47  }
48  }
49 
50  using EngineLogsPtr = std::unique_ptr<interface::EngineLog>;
51  using EngineLogsCollectionType = std::vector<EngineLogsPtr>;
52 
54  virtual int32_t getCommandIndex() const = 0;
55 
57  virtual types::AccountIdType getCaller() const = 0;
58 
60  virtual PayloadType getPayloadType() const = 0;
61 
64  virtual std::optional<CallResult> const &getResponseData() const = 0;
65 
67  virtual std::optional<types::EvmAddressHexString> const &
68  getContractAddress() const = 0;
69 
71  virtual EngineLogsCollectionType const &getEngineLogs() const = 0;
72 
73  std::string toString() const override;
74 
75  bool operator==(const ModelType &rhs) const override;
76  };
77 
78  std::ostream &operator<<(std::ostream &os, EngineReceipt const &);
79 
80  std::ostream &operator<<(std::ostream &os,
82 
83  } // namespace interface
84 } // namespace shared_model
85 
86 #endif // IROHA_SHARED_MODEL_INTERFACE_ENGINE_RECEIPT_HPP
std::string EvmDataHexString
Types of evm data.
Definition: types.hpp:42
Provides a response for a single corresponding EngineCall command.
Definition: engine_receipt.hpp:20
virtual types::AccountIdType getCaller() const =0
Get sender account id.
bool operator==(const ModelType &rhs) const override
Definition: engine_receipt.cpp:14
virtual std::optional< CallResult > const & getResponseData() const =0
virtual EngineLogsCollectionType const & getEngineLogs() const =0
Return engine logs collection.
EngineReceipt ModelType
Definition: model_primitive.hpp:27
PayloadType
Definition: engine_receipt.hpp:22
virtual int32_t getCommandIndex() const =0
Get command index.
virtual PayloadType getPayloadType() const =0
Returns the payload data type.
std::string AccountIdType
Type of account id.
Definition: types.hpp:38
std::vector< EngineLogsPtr > EngineLogsCollectionType
Definition: engine_receipt.hpp:51
std::ostream & operator<<(std::ostream &os, EngineReceipt const &)
Definition: engine_receipt.cpp:46
std::unique_ptr< interface::EngineLog > EngineLogsPtr
Definition: engine_receipt.hpp:50
static char const * payloadTypeToStr(PayloadType pt)
Definition: engine_receipt.hpp:39
std::optional< types::EvmDataHexString > const & response_data
Definition: engine_receipt.hpp:30
Definition: model_primitive.hpp:22
bool operator==(CallResult const &c) const
Definition: engine_receipt.hpp:32
types::EvmDataHexString const & callee
Definition: engine_receipt.hpp:29
Definition: command_executor.hpp:12
virtual std::optional< types::EvmAddressHexString > const & getContractAddress() const =0
Returns payload data.
std::string toString() const override
Definition: engine_receipt.cpp:29