Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
 
Loading...
Searching...
No Matches
decoded_event.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <optional>
6#include <string>
7
8#include "parser.hpp"
9
10namespace dcn::events
11{
12 constexpr std::string_view CONNECTOR_ADDED_TYPE = "connector_added";
13 constexpr std::string_view TRANSFORMATION_ADDED_TYPE = "transformation_added";
14 constexpr std::string_view CONDITION_ADDED_TYPE = "condition_added";
15
16 constexpr std::string_view OBSERVED_STATE = "observed";
17 constexpr std::string_view SAFE_STATE = "safe";
18 constexpr std::string_view FINALIZED_STATE = "finalized";
19 constexpr std::string_view REMOVED_STATE = "removed";
20
21 enum class EventState : std::uint8_t
22 {
23 OBSERVED = 0,
24 SAFE = 1,
25 FINALIZED = 2,
26 REMOVED = 3
27 };
28
29 enum class EventType : std::uint8_t
30 {
34 };
35
37 {
38 int chain_id = 1;
39 std::int64_t block_number = 0;
40 std::string block_hash;
41 std::string parent_hash;
42 std::int64_t tx_index = 0;
43 std::string tx_hash;
44 std::int64_t log_index = 0;
45 std::string address;
46 std::array<std::optional<std::string>, 4> topics{};
47 std::string data_hex;
48 bool removed = false;
49 std::optional<std::int64_t> block_time = std::nullopt;
50 std::int64_t seen_at_ms = 0;
51 };
52
54 {
58
59 std::string name;
60 std::string caller;
61 std::string owner;
62 std::string entity_address;
63 std::optional<std::uint32_t> args_count = std::nullopt;
64 std::optional<std::string> format_hash = std::nullopt;
65
66 std::string decoded_json;
67 };
68
69 std::string toString(EventState state);
70 std::string toString(EventType type);
71}
72
73namespace dcn::parse
74{
75 Result<dcn::events::EventState> parseEventState(const std::string & value);
76 Result<dcn::events::EventType> parseEventType(const std::string & value);
77
78 Result<dcn::events::RawChainLog> parseRawLog(const json & log_json, const std::int64_t seen_at_ms, int chain_id);
79}
Definition decoded_event.hpp:11
EventType
Definition decoded_event.hpp:30
EventState
Definition decoded_event.hpp:22
constexpr std::string_view TRANSFORMATION_ADDED_TYPE
Definition decoded_event.hpp:13
constexpr std::string_view OBSERVED_STATE
Definition decoded_event.hpp:16
constexpr std::string_view SAFE_STATE
Definition decoded_event.hpp:17
constexpr std::string_view FINALIZED_STATE
Definition decoded_event.hpp:18
constexpr std::string_view REMOVED_STATE
Definition decoded_event.hpp:19
std::string toString(EventState state)
Definition decoded_events.cpp:8
constexpr std::string_view CONNECTOR_ADDED_TYPE
Definition decoded_event.hpp:12
constexpr std::string_view CONDITION_ADDED_TYPE
Definition decoded_event.hpp:14
Definition hex.hpp:28
Result< dcn::events::EventType > parseEventType(const std::string &value)
Definition decoded_events.cpp:65
Result< dcn::events::EventState > parseEventState(const std::string &value)
Definition decoded_events.cpp:43
Result< dcn::events::RawChainLog > parseRawLog(const json &log_json, const std::int64_t seen_at_ms, int chain_id)
Definition decoded_events.cpp:83
nlohmann::json json
Definition parser.hpp:7
Definition decoded_event.hpp:54
std::string owner
Definition decoded_event.hpp:61
std::optional< std::uint32_t > args_count
Definition decoded_event.hpp:63
std::string entity_address
Definition decoded_event.hpp:62
std::string name
Definition decoded_event.hpp:59
EventState state
Definition decoded_event.hpp:57
std::string caller
Definition decoded_event.hpp:60
std::optional< std::string > format_hash
Definition decoded_event.hpp:64
EventType event_type
Definition decoded_event.hpp:56
std::string decoded_json
Definition decoded_event.hpp:66
RawChainLog raw
Definition decoded_event.hpp:55
Definition decoded_event.hpp:37
std::int64_t tx_index
Definition decoded_event.hpp:42
std::int64_t block_number
Definition decoded_event.hpp:39
std::string tx_hash
Definition decoded_event.hpp:43
std::int64_t log_index
Definition decoded_event.hpp:44
int chain_id
Definition decoded_event.hpp:38
std::optional< std::int64_t > block_time
Definition decoded_event.hpp:49
std::string address
Definition decoded_event.hpp:45
std::array< std::optional< std::string >, 4 > topics
Definition decoded_event.hpp:46
std::string data_hex
Definition decoded_event.hpp:47
std::string parent_hash
Definition decoded_event.hpp:41
std::string block_hash
Definition decoded_event.hpp:40
bool removed
Definition decoded_event.hpp:48
std::int64_t seen_at_ms
Definition decoded_event.hpp:50