COOPENOMICS  v1
Кооперативная Экономика
table_registrator_exits.hpp
См. документацию.
1#pragma once
2
3#include <eosio/binary_extension.hpp>
4
5#include "../core/ram_payer.hpp"
6#include <optional>
7
8#include <eosio/asset.hpp>
9#include <eosio/crypto.hpp>
10#include <eosio/eosio.hpp>
11
12#include "../consts.hpp"
13#include "document_core.hpp"
14
15namespace Registrator {
16
17using namespace eosio;
18
43struct [[eosio::table, eosio::contract(REGISTRATOR)]] exit {
46 name status;
47 time_point_sec created_at;
50 checksum256 exit_hash;
51 asset quantity;
55 eosio::binary_extension<document2> annulment_statement;
56
60 bool has_annulment() const {
61 return annulment_statement.has_value() && !is_empty_document(annulment_statement.value());
62 }
63
64 uint64_t primary_key() const { return username.value; }
65 checksum256 by_hash() const { return exit_hash; }
66};
67
68typedef multi_index<
69 "exits"_n, exit,
70 indexed_by<"byhash"_n, const_mem_fun<exit, checksum256, &exit::by_hash>>>
72
73inline std::optional<exit> get_exit_by_hash(name coopname, const checksum256 &hash) {
74 exits_index primary_index(_registrator, coopname.value);
75 auto secondary_index = primary_index.get_index<"byhash"_n>();
76
77 auto itr = secondary_index.find(hash);
78 if (itr == secondary_index.end()) {
79 return std::nullopt;
80 }
81
82 return *itr;
83}
84
85} // namespace Registrator
86
87// Плательщик за оперативную память строк таблицы — правило в lib/core/ram_payer.hpp.
static constexpr eosio::name _registrator
Definition: consts.hpp:195
bool is_empty_document(const document2 &doc)
Definition: document_core.hpp:72
contract
Definition: eosio.msig_tests.cpp:977
Вспомогательные функции процедуры выхода пайщика из кооператива.
Definition: table_registrator_candidates.hpp:15
multi_index< "exits"_n, exit, indexed_by<"byhash"_n, const_mem_fun< exit, checksum256, &exit::by_hash > > > exits_index
Definition: table_registrator_exits.hpp:71
std::optional< exit > get_exit_by_hash(name coopname, const checksum256 &hash)
Definition: table_registrator_exits.hpp:73
Definition: eosio.msig.hpp:34
Заявление пайщика на выход из кооператива и сопровождающий его процесс возврата паевого взноса.
Definition: table_registrator_exits.hpp:43
uint64_t primary_key() const
Definition: table_registrator_exits.hpp:64
checksum256 by_hash() const
Definition: table_registrator_exits.hpp:65
eosio::binary_extension< document2 > annulment_statement
Definition: table_registrator_exits.hpp:55
name coopname
Definition: table_registrator_exits.hpp:45
time_point_sec created_at
Definition: table_registrator_exits.hpp:47
name status
pending | authorized
Definition: table_registrator_exits.hpp:46
document2 approved_statement
решение совета о выходе (авторизация)
Definition: table_registrator_exits.hpp:49
name username
Definition: table_registrator_exits.hpp:44
asset quantity
Definition: table_registrator_exits.hpp:51
bool has_annulment() const
Definition: table_registrator_exits.hpp:60
document2 statement
заявление о выходе (registry 200)
Definition: table_registrator_exits.hpp:48
checksum256 exit_hash
Definition: table_registrator_exits.hpp:50
Definition: table_registrator_orgs.hpp:17
Definition: document_core.hpp:27
RAM_PAYER_CLASS(Registrator::exit, cooperative)