COOPENOMICS  v1
Кооперативная Экономика
shared_approver.hpp
См. документацию.
1namespace Approver {
13 struct [[eosio::table, eosio::contract(SOVIET)]] approval {
14 uint64_t id;
15 eosio::name coopname;
16 eosio::name username;
17 eosio::name type;
19 checksum256 approval_hash;
20 eosio::name callback_contract;
23 std::string meta;
24 eosio::time_point_sec created_at;
25
26 uint64_t primary_key() const { return id; }
27 checksum256 by_hash() const { return approval_hash; }
28 uint64_t by_username() const { return username.value; }
29 uint64_t by_type() const { return type.value; }
30 };
31
32 typedef eosio::multi_index<
33 "approvals"_n, approval,
34 eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<approval, checksum256, &approval::by_hash>>,
35 eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<approval, uint64_t, &approval::by_username>>,
36 eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<approval, uint64_t, &approval::by_type>>
40 inline std::optional<approval> get_approval(eosio::name coopname, const checksum256 &hash) {
41 approvals_index primary_index(_soviet, coopname.value);
42 auto secondary_index = primary_index.get_index<"byhash"_n>();
43
44 auto itr = secondary_index.find(hash);
45 if (itr == secondary_index.end()) {
46 return std::nullopt;
47 }
48
49 return *itr;
50 }
51
52}
static constexpr eosio::name _soviet
Definition: consts.hpp:156
contract
Definition: eosio.msig_tests.cpp:977
Definition: shared_approver.hpp:1
std::optional< approval > get_approval(eosio::name coopname, const checksum256 &hash)
Definition: shared_approver.hpp:40
eosio::multi_index< "approvals"_n, approval, eosio::indexed_by<"byhash"_n, eosio::const_mem_fun< approval, checksum256, &approval::by_hash > >, eosio::indexed_by<"byusername"_n, eosio::const_mem_fun< approval, uint64_t, &approval::by_username > >, eosio::indexed_by<"bytype"_n, eosio::const_mem_fun< approval, uint64_t, &approval::by_type > > > approvals_index
Definition: shared_approver.hpp:37
Definition: eosio.msig.hpp:34
Таблица утверждений
Definition: shared_approver.hpp:13
eosio::name callback_contract
Контракт для обратного вызова
Definition: shared_approver.hpp:20
std::string meta
Метаданные
Definition: shared_approver.hpp:23
checksum256 by_hash() const
Индекс по хэшу утверждения
Definition: shared_approver.hpp:27
eosio::name callback_action_decline
Действие при отклонении
Definition: shared_approver.hpp:22
eosio::name username
Имя пользователя
Definition: shared_approver.hpp:16
uint64_t by_username() const
Индекс по имени пользователя
Definition: shared_approver.hpp:28
eosio::name callback_action_approve
Действие при одобрении
Definition: shared_approver.hpp:21
eosio::time_point_sec created_at
Время создания
Definition: shared_approver.hpp:24
eosio::name coopname
Имя кооператива
Definition: shared_approver.hpp:15
checksum256 approval_hash
Хэш утверждения
Definition: shared_approver.hpp:19
document2 document
Документ для утверждения
Definition: shared_approver.hpp:18
eosio::name type
Тип утверждения
Definition: shared_approver.hpp:17
uint64_t by_type() const
Индекс по типу утверждения
Definition: shared_approver.hpp:29
uint64_t primary_key() const
Definition: shared_approver.hpp:26
uint64_t id
Уникальный идентификатор утверждения
Definition: shared_approver.hpp:14
Definition: drafts.hpp:28