COOPENOMICS  v1
Кооперативная Экономика
table_gateway_incomes.hpp
См. документацию.
1#pragma once
2
3
4#include "../core/ram_payer.hpp"
5#include <eosio/asset.hpp>
6#include <eosio/crypto.hpp>
7#include <eosio/eosio.hpp>
8#include <optional>
9#include <string>
10
11#include "../consts.hpp"
12
13namespace Gateway {
14
20struct [[eosio::table, eosio::contract(GATEWAY)]] income {
21 uint64_t id;
22 eosio::name coopname;
23 eosio::name username;
24 eosio::name type;
25 checksum256 income_hash;
26 eosio::name callback_contract;
27 eosio::name confirm_callback;
28 eosio::name decline_callback;
29
30 eosio::asset quantity;
31 eosio::name status;
32
33 eosio::time_point_sec created_at = current_time_point();
34
35 uint64_t primary_key() const { return id; }
36 uint64_t by_username() const { return username.value; }
37 checksum256 by_hash() const { return income_hash; }
38 uint64_t by_status() const { return status.value; }
39};
40
41typedef eosio::multi_index<
42 "incomes"_n, income,
43 eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<income, checksum256, &income::by_hash>>,
44 eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<income, uint64_t, &income::by_username>>,
45 eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<income, uint64_t, &income::by_status>>>
47
48inline std::optional<income> get_income(eosio::name coopname, const checksum256 &hash) {
49 incomes_index primary_index(_gateway, coopname.value);
50 auto secondary_index = primary_index.get_index<"byhash"_n>();
51
52 auto itr = secondary_index.find(hash);
53 if (itr == secondary_index.end()) {
54 return std::nullopt;
55 }
56
57 return *itr;
58}
59
60} // namespace Gateway
61
62// Плательщик за оперативную память строк таблицы — правило в lib/core/ram_payer.hpp.
static constexpr eosio::name _gateway
Definition: consts.hpp:173
contract
Definition: eosio.msig_tests.cpp:977
Definition: gateway.hpp:20
std::optional< income > get_income(eosio::name coopname, const checksum256 &hash)
Definition: table_gateway_incomes.hpp:48
eosio::multi_index< "incomes"_n, income, eosio::indexed_by<"byhash"_n, eosio::const_mem_fun< income, checksum256, &income::by_hash > >, eosio::indexed_by<"byusername"_n, eosio::const_mem_fun< income, uint64_t, &income::by_username > >, eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun< income, uint64_t, &income::by_status > > > incomes_index
Definition: table_gateway_incomes.hpp:46
Definition: eosio.msig.hpp:34
Definition: table_gateway_incomes.hpp:20
eosio::name coopname
Definition: table_gateway_incomes.hpp:22
checksum256 income_hash
Definition: table_gateway_incomes.hpp:25
uint64_t by_username() const
Definition: table_gateway_incomes.hpp:36
eosio::asset quantity
Definition: table_gateway_incomes.hpp:30
checksum256 by_hash() const
Definition: table_gateway_incomes.hpp:37
eosio::name callback_contract
Definition: table_gateway_incomes.hpp:26
uint64_t by_status() const
Definition: table_gateway_incomes.hpp:38
eosio::name confirm_callback
Definition: table_gateway_incomes.hpp:27
uint64_t primary_key() const
Definition: table_gateway_incomes.hpp:35
eosio::name status
Definition: table_gateway_incomes.hpp:31
eosio::name decline_callback
Definition: table_gateway_incomes.hpp:28
eosio::name username
Definition: table_gateway_incomes.hpp:23
uint64_t id
Definition: table_gateway_incomes.hpp:21
eosio::name type
Definition: table_gateway_incomes.hpp:24
Definition: table_registrator_orgs.hpp:17
RAM_PAYER_CLASS(Gateway::income, cooperative)