COOPENOMICS  v1
Кооперативная Экономика
table_soviet_approvals.hpp
См. документацию.
1#pragma once
2
3#include <eosio/crypto.hpp>
4#include <eosio/eosio.hpp>
5#include <optional>
6#include <string>
7#include <vector>
8
9#include "../consts.hpp"
10#include "document_core.hpp"
11
12namespace Approver {
13
14using namespace eosio;
15
16struct [[eosio::table, eosio::contract(SOVIET)]] approval {
17 uint64_t id;
20 name type;
22 checksum256 approval_hash;
26 std::string meta;
27 time_point_sec created_at;
28
29 uint64_t primary_key() const { return id; }
30 checksum256 by_hash() const { return approval_hash; }
31 uint64_t by_username() const { return username.value; }
32 uint64_t by_type() const { return type.value; }
33};
34
35typedef multi_index<
36 "approvals"_n, approval,
37 indexed_by<"byhash"_n, const_mem_fun<approval, checksum256, &approval::by_hash>>,
38 indexed_by<"byusername"_n, const_mem_fun<approval, uint64_t, &approval::by_username>>,
39 indexed_by<"bytype"_n, const_mem_fun<approval, uint64_t, &approval::by_type>>>
41
42inline std::optional<approval> get_approval(name coopname, const checksum256 &hash) {
43 approvals_index primary_index(_soviet, coopname.value);
44 auto secondary_index = primary_index.get_index<"byhash"_n>();
45
46 auto itr = secondary_index.find(hash);
47 if (itr == secondary_index.end()) {
48 return std::nullopt;
49 }
50
51 return *itr;
52}
53
54} // namespace Approver
static constexpr eosio::name _soviet
Definition: consts.hpp:156
contract
Definition: eosio.msig_tests.cpp:977
Definition: table_soviet_approvals.hpp:12
multi_index< "approvals"_n, approval, indexed_by<"byhash"_n, const_mem_fun< approval, checksum256, &approval::by_hash > >, indexed_by<"byusername"_n, const_mem_fun< approval, uint64_t, &approval::by_username > >, indexed_by<"bytype"_n, const_mem_fun< approval, uint64_t, &approval::by_type > > > approvals_index
Definition: table_soviet_approvals.hpp:40
std::optional< approval > get_approval(name coopname, const checksum256 &hash)
Definition: table_soviet_approvals.hpp:42
Definition: eosio.msig.hpp:34
Definition: table_soviet_approvals.hpp:16
name callback_action_approve
Definition: table_soviet_approvals.hpp:24
std::string meta
Definition: table_soviet_approvals.hpp:26
checksum256 by_hash() const
Definition: table_soviet_approvals.hpp:30
name callback_contract
Definition: table_soviet_approvals.hpp:23
name username
Definition: table_soviet_approvals.hpp:19
name type
Definition: table_soviet_approvals.hpp:20
name coopname
Definition: table_soviet_approvals.hpp:18
uint64_t by_username() const
Definition: table_soviet_approvals.hpp:31
name callback_action_decline
Definition: table_soviet_approvals.hpp:25
checksum256 approval_hash
Definition: table_soviet_approvals.hpp:22
document2 document
Definition: table_soviet_approvals.hpp:21
time_point_sec created_at
Definition: table_soviet_approvals.hpp:27
uint64_t by_type() const
Definition: table_soviet_approvals.hpp:32
uint64_t primary_key() const
Definition: table_soviet_approvals.hpp:29
uint64_t id
Definition: table_soviet_approvals.hpp:17
Definition: document_core.hpp:27