Scorum
base.hpp
Go to the documentation of this file.
1 #pragma once
2 
7 
8 #include <fc/time.hpp>
9 #include <fc/utf8.hpp>
10 #include <fc/io/json.hpp>
11 
12 namespace scorum {
13 namespace protocol {
14 
15 inline void validate_account_name(const std::string& name)
16 {
17  FC_ASSERT(is_valid_account_name(name), "Account name ${n} is invalid", ("n", name));
18 }
19 
20 inline void validate_permlink(const std::string& permlink)
21 {
22  FC_ASSERT(permlink.size() < SCORUM_MAX_PERMLINK_LENGTH, "permlink is too long");
23  FC_ASSERT(fc::is_utf8(permlink), "permlink not formatted in UTF8");
24 }
25 
26 inline void validate_json_metadata(const std::string& json_metadata)
27 {
28  if (!json_metadata.empty())
29  {
30  FC_ASSERT(fc::is_utf8(json_metadata), "JSON Metadata not formatted in UTF8");
31  FC_ASSERT(fc::json::is_valid(json_metadata), "JSON Metadata not valid JSON");
32  }
33 }
34 
36 {
37  void get_required_authorities(std::vector<authority>&) const
38  {
39  }
40 
41  void get_required_active_authorities(flat_set<account_name_type>&) const
42  {
43  }
44  void get_required_posting_authorities(flat_set<account_name_type>&) const
45  {
46  }
47 
48  void get_required_owner_authorities(flat_set<account_name_type>&) const
49  {
50  }
51 
52  bool is_virtual() const
53  {
54  return false;
55  }
56 
57  void validate() const
58  {
59  }
60 };
61 
63 {
64  bool is_virtual() const
65  {
66  return true;
67  }
68  void validate() const
69  {
70  FC_ASSERT(false, "This is a virtual operation");
71  }
72 };
73 
74 typedef static_variant<void_t,
75  version, // Normal witness version reporting, for diagnostics and voting
76  hardfork_version_vote // Voting for the next hardfork to trigger
77  >
79 
80 typedef static_variant<void_t> future_extensions;
81 
82 typedef flat_set<block_header_extensions> block_header_extensions_type;
83 typedef flat_set<future_extensions> extensions_type;
84 }
85 } // scorum::protocol
86 
88 FC_REFLECT_TYPENAME(scorum::protocol::future_extensions)
void validate_json_metadata(const std::string &json_metadata)
Definition: base.hpp:26
void validate_permlink(const std::string &permlink)
Definition: base.hpp:20
bool is_valid_account_name(const std::string &name)
Definition: authority.cpp:58
static_variant< void_t, version, hardfork_version_vote > block_header_extensions
Definition: base.hpp:78
static_variant< void_t > future_extensions
Definition: base.hpp:80
flat_set< block_header_extensions > block_header_extensions_type
Definition: base.hpp:82
flat_set< future_extensions > extensions_type
Definition: base.hpp:83
void validate_account_name(const std::string &name)
Definition: base.hpp:15
Definition: asset.cpp:15
void get_required_active_authorities(flat_set< account_name_type > &) const
Definition: base.hpp:41
void get_required_authorities(std::vector< authority > &) const
Definition: base.hpp:37
void get_required_posting_authorities(flat_set< account_name_type > &) const
Definition: base.hpp:44
void get_required_owner_authorities(flat_set< account_name_type > &) const
Definition: base.hpp:48