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
transformation.hpp
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <regex>
4#include <algorithm>
5
6#include <absl/hash/hash.h>
7#include <spdlog/spdlog.h>
8
9#include "transformation.pb.h"
10
11#include "parser.hpp"
12#include "chain.hpp"
13
14namespace dcn
15{
24 template <typename H>
25 inline H AbslHashValue(H h, const Transformation& t) {
26 return H::combine(std::move(h), t.name(), t.args_count());
27 }
28
34 parse::Result<std::uint32_t> countTransformationArgs(const std::string & sol_src);
35
36 parse::Result<std::string> constructTransformationSolidityCode(const Transformation & transformation);
37}
38
39namespace dcn::pt
40{
49
50 std::optional<TransformationAddedEvent> decodeTransformationAddedEvent(
51 const std::uint8_t* data,
52 std::size_t data_size,
53 const evmc::bytes32 topics[],
54 std::size_t num_topics);
55
56 std::optional<TransformationAddedEvent> decodeTransformationAddedEvent(
57 const std::string & data_hex,
58 const std::vector<std::string> & topics_hex);
59
60}
61
62namespace dcn::parse
63{
68 template<>
69 Result<json> parseToJson(Transformation transformation, use_json_t);
70
75 template<>
76 Result<Transformation> parseFromJson(json json_obj, use_json_t);
77
83 template<>
84 Result<std::string> parseToJson(Transformation transformation, use_protobuf_t);
85
90 template<>
91 Result<Transformation> parseFromJson(std::string json_str, use_protobuf_t);
92
93
98 template<>
99 Result<json> parseToJson(TransformationRecord transformation_record, use_json_t);
100
105 template<>
106 Result<std::string> parseToJson(TransformationRecord transformation_record, use_protobuf_t);
107
112 template<>
113 Result<TransformationRecord> parseFromJson(json json_obj, use_json_t);
114
119 template<>
120 Result<TransformationRecord> parseFromJson(std::string json_str, use_protobuf_t);
121
122}
evmc::address Address
Definition address.hpp:18
Definition hex.hpp:28
Result< json > parseToJson(T message, use_json_t)
Converts a T to a JSON object using JSON.
Result< T > parseFromJson(json json, use_json_t)
Converts a JSON string to a T using JSON.
std::expected< T, ParseError > Result
Definition parse_error.hpp:26
Definition condition.hpp:40
std::optional< TransformationAddedEvent > decodeTransformationAddedEvent(const std::uint8_t *data, std::size_t data_size, const evmc::bytes32 topics[], std::size_t num_topics)
Definition transformation.cpp:95
Definition decentralised_art.hpp:35
parse::Result< std::string > constructTransformationSolidityCode(const Transformation &transformation)
Definition transformation.cpp:45
parse::Result< std::uint32_t > countTransformationArgs(const std::string &sol_src)
Counts the number of distinct args[N] slots referenced by a transformation's source....
Definition transformation.cpp:10
H AbslHashValue(H h, const Condition &c)
Combines hash values for a Condition object.
Definition condition.hpp:25
nlohmann::json json
Definition parser.hpp:7
Definition transformation.hpp:42
chain::Address caller
Definition transformation.hpp:43
std::string name
Definition transformation.hpp:44
std::uint32_t args_count
Definition transformation.hpp:47
chain::Address transformation_address
Definition transformation.hpp:45
chain::Address owner
Definition transformation.hpp:46