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