refactor: replace common.hpp with index.hpp in multiple contract headers and remove unused files
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
/**
|
||||
\defgroup public_branch Контракт BRANCH
|
||||
|
||||
@@ -46,7 +46,7 @@ constexpr uint128_t CRPS_PRECISION_FACTOR = 100000000000000ULL; ///< Масшт
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
#include "domain/index.hpp"
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
using std::string;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
/**
|
||||
\defgroup public_draft Контракт DRAFT
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
/**
|
||||
\defgroup public_fund Контракт FUND
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
/**
|
||||
\defgroup public_gateway Контракт GATEWAY
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
* @brief Константы контракта процессинга платежей
|
||||
*/
|
||||
// Константы определены в shared_gateway.hpp:
|
||||
// Константы определены в lib/core/gateway/gateway.hpp:
|
||||
// gateway_income_actions = {"deposit"_n}
|
||||
// gateway_outcome_actions = {"withdraw"_n}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
|
||||
@@ -1,411 +0,0 @@
|
||||
#include <eosio/binary_extension.hpp>
|
||||
|
||||
bool check_auth_and_get_payer(const std::vector<eosio::name>& payers) {
|
||||
for (const auto& payer : payers) {
|
||||
if (has_auth(payer)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
eosio::name check_auth_and_get_payer_or_fail(const std::vector<eosio::name>& payers) {
|
||||
for (const auto& payer : payers) {
|
||||
if (has_auth(payer)) {
|
||||
return payer;
|
||||
}
|
||||
}
|
||||
eosio::check(false, "Недостаточно прав доступа");
|
||||
return eosio::name{}; // code will never reach here due to check
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Структура, представляющая верификацию.
|
||||
* @details Тип процедуры верификации (procedure) может принимать следующие значения:
|
||||
* - 0: Online
|
||||
* - 1: Video Call
|
||||
* - 2: Qualified Signature
|
||||
* - 3: Gosuslugi
|
||||
* - 4: С помощью мобильного приложения (App)
|
||||
* - 5: Некоторые платежные системы проводят верификацию в Связном (Agent Store)
|
||||
* - 6: Верификация в банке (Bank)
|
||||
* - 7: Верификация в кооперативе (In Person)
|
||||
*/
|
||||
struct verification {
|
||||
eosio::name verificator; ///< Организация, которая произвела верификацию
|
||||
bool is_verified; ///< Флаг, указывающий, прошла ли верификация
|
||||
eosio::name procedure; ///< Тип процедуры верификации
|
||||
// ('online')),
|
||||
// ('video call')),
|
||||
// ('qualified signature')),
|
||||
// ('gosuslugi')),
|
||||
// ('app')), - с помощью мобильного приложения
|
||||
// (('agent store')), - некоторые платежные системы
|
||||
// проводят верификацию в Связном
|
||||
// (('bank')), - верификация в банке
|
||||
// (('in person')), - верификация в кооперативе
|
||||
|
||||
eosio::time_point_sec created_at; ///< Время создания записи
|
||||
eosio::time_point_sec last_update; ///< Время последнего обновления записи
|
||||
std::string notice; ///< Дополнительная информация
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Структура, представляющая учетные записи аккаунтов.
|
||||
* @details Эта структура хранит информацию о пользователях аккаунта и их статусе, репутации и других параметрах.
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] account {
|
||||
eosio::name username; ///< Имя аккаунта гостя. Имя пользователя в системе.
|
||||
eosio::name referer; ///< Имя аккаунта, который был реферером при регистрации.
|
||||
eosio::name registrator; ///< Имя аккаунта регистратора, который создал этот аккаунт.
|
||||
eosio::name type; ///< Тип аккаунта: individual | entrepreneur | org
|
||||
eosio::name status; ///< Статус аккаунта
|
||||
std::string meta; ///< Дополнительная мета-информация о аккаунте.
|
||||
|
||||
std::vector<eosio::name> storages; ///< Хранилища персональных данных и идентификаторы данных в них.
|
||||
std::vector<verification> verifications; ///< Информация о верификации пользователя.
|
||||
|
||||
eosio::time_point_sec registered_at; ///< Время регистрации аккаунта.
|
||||
|
||||
/**
|
||||
* @brief Возвращает первичный ключ учетной записи аккаунта.
|
||||
* @return uint64_t - первичный ключ, равный значению имени аккаунта.
|
||||
*/
|
||||
uint64_t primary_key() const {
|
||||
return username.value;
|
||||
} /*!< return username - primary_key */
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ по рефереру.
|
||||
* @return uint64_t - ключ, равный значению имени реферера.
|
||||
*/
|
||||
uint64_t by_referer() const { return referer.value; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ по типу аккаунта.
|
||||
* @return uint64_t - ключ, равный значению типа аккаунта.
|
||||
*/
|
||||
uint64_t by_type() const { return type.value; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ по статусу аккаунта.
|
||||
* @return uint64_t - ключ, равный значению статуса аккаунта.
|
||||
*/
|
||||
uint64_t by_status() const { return status.value; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ по регистратору.
|
||||
* @return uint64_t - ключ, равный значению имени регистратора.
|
||||
*/
|
||||
uint64_t by_registr() const { return registrator.value; }
|
||||
|
||||
bool is_active() const {
|
||||
return status == "active"_n;
|
||||
}
|
||||
|
||||
uint64_t by_registered_at() const {
|
||||
return registered_at.sec_since_epoch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Проверяет, верифицирована ли организация.
|
||||
* @return bool - true, если организация верифицирована, иначе false.
|
||||
*/
|
||||
bool is_verified() const {
|
||||
for (const auto& v : verifications) {
|
||||
if (v.is_verified) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Возвращает индекс для определения, является ли организация верифицированной.
|
||||
* @return uint64_t - ключ, равный 1, если организация верифицирована, иначе 0.
|
||||
*/
|
||||
uint64_t is_verified_index() const {
|
||||
for (const auto& v : verifications) {
|
||||
if (v.is_verified) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"accounts"_n, account,
|
||||
eosio::indexed_by< "byreferer"_n, eosio::const_mem_fun<account, uint64_t, &account::by_referer>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<account, uint64_t, &account::by_type>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<account, uint64_t, &account::by_status>>,
|
||||
eosio::indexed_by<"byregistr"_n, eosio::const_mem_fun<account, uint64_t, &account::by_registr>>,
|
||||
eosio::indexed_by<"byregistred"_n, eosio::const_mem_fun<account, uint64_t, &account::by_registered_at>>,
|
||||
eosio::indexed_by<"byverif"_n, eosio::const_mem_fun<account, uint64_t,&account::is_verified_index>>
|
||||
>
|
||||
accounts_index;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\brief Структура данных нового юридического лица
|
||||
*
|
||||
* Данная структура содержит всю необходимую информацию для регистрации нового юридического лица в блокчейне.
|
||||
*/
|
||||
struct org_data {
|
||||
bool is_cooperative = false; ///< Является ли кооперативом
|
||||
eosio::name coop_type; ///< Тип кооператива (union, conscoop, prodcoop, agricoop, builderscoop, nonprofitorg)
|
||||
std::string announce; ///< Анонс
|
||||
std::string description; ///< Описание
|
||||
eosio::asset initial; ///< Вступительный взнос физического лица / ип
|
||||
eosio::asset minimum; ///< Минимальный паевой взнос физического лица / ип
|
||||
|
||||
eosio::asset org_initial; ///< Вступительный взнос юридического лица
|
||||
eosio::asset org_minimum; ///< Минимальный паевой взнос юридического лица
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Структура, представляющая организации.
|
||||
* @details Эта структура содержит информацию о юридических лицах (организациях), их верификации и других параметрах.
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] cooperative {
|
||||
eosio::name username; ///< Имя аккаунта организации.
|
||||
eosio::name parent_username; ///< Имя родительской организации, если есть.
|
||||
|
||||
std::string announce; ///< Анонс организации.
|
||||
std::string description; ///< Описание организации.
|
||||
bool is_cooperative = false; ///< Флаг, указывающий, является ли организация кооперативом.
|
||||
|
||||
bool is_branched = false; ///< Флаг, указывающий, перешел ли кооператив на собрания уполномоченных
|
||||
bool is_enrolled = false; ///< Флаг, указывающий, активен ли кооператив в системе
|
||||
|
||||
eosio::name coop_type; ///< Тип некоммерческой организации (если это кооператив).
|
||||
|
||||
eosio::asset registration; ///< Регистрационный взнос физического лица / ип
|
||||
eosio::asset initial; ///< Вступительный членский взнос физического лица / ип
|
||||
eosio::asset minimum; ///< Минимальный паевой взнос физического лица / ип
|
||||
|
||||
eosio::binary_extension<eosio::asset> org_registration; ///< Регистрационный взнос юридического лица
|
||||
eosio::binary_extension<eosio::asset> org_initial; ///< Вступительный членский взнос юридического лица
|
||||
eosio::binary_extension<eosio::asset> org_minimum; ///< Минимальный паевой взнос юридического лица
|
||||
|
||||
eosio::binary_extension<eosio::name> status; ///< Статус процесса подключения
|
||||
eosio::binary_extension<eosio::time_point_sec> created_at; ///< Дата поступления заявки на подключение (pending | ... | active | blocked)
|
||||
eosio::binary_extension<document> document; ///< Подписанный документ соглашения на подключение
|
||||
|
||||
|
||||
/**
|
||||
* @brief Возвращает первичный ключ учетной записи организации.
|
||||
* @return uint64_t - первичный ключ, равный значению имени аккаунта организации.
|
||||
*/
|
||||
|
||||
uint64_t primary_key() const {
|
||||
return username.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Сравнивает символ токена кооператива и представленный
|
||||
*/
|
||||
void check_symbol_or_fail(eosio::asset contribution) {
|
||||
eosio::check(initial.symbol == contribution.symbol && minimum.symbol == contribution.symbol, "Неверный контракт токена");
|
||||
}
|
||||
|
||||
uint64_t by_status() const {
|
||||
return status.has_value() ? status.value().value : 0;
|
||||
}
|
||||
|
||||
uint64_t by_created() const {
|
||||
return created_at.has_value() ? created_at.value().sec_since_epoch() : 0;
|
||||
}
|
||||
/**
|
||||
* @brief Возвращает ключ по родительской организации.
|
||||
* @return uint64_t - ключ, равный значению имени родительской организации.
|
||||
*/
|
||||
uint64_t by_parent() const {
|
||||
return parent_username.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индекса кооперативных подразделений организации.
|
||||
* @return uint128_t - составной ключ, включающий значения имени организации и родительской организации.
|
||||
*/
|
||||
uint128_t by_coop_childs() const {
|
||||
return combine_ids(username.value, parent_username.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает индекс для определения, является ли организация кооперативом.
|
||||
* @return uint64_t - ключ, равный 1, если организация является кооперативом, иначе 0.
|
||||
*/
|
||||
uint64_t is_coop_index() const {
|
||||
return is_cooperative == true ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индекса по типу некоммерческой организации (если это кооператив).
|
||||
* @return uint64_t - ключ, равный значению типа некоммерческой организации.
|
||||
*/
|
||||
uint64_t bycooptype() const {
|
||||
return coop_type.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Проверяет, является ли организация кооперативом.
|
||||
* @return bool - true, если организация является кооперативом, иначе false.
|
||||
*/
|
||||
bool is_coop() const {
|
||||
return is_cooperative;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"orgs"_n, cooperative,
|
||||
eosio::indexed_by<"iscoop"_n, eosio::const_mem_fun<cooperative, uint64_t,
|
||||
&cooperative::is_coop_index>>,
|
||||
eosio::indexed_by<"byparent"_n, eosio::const_mem_fun<cooperative, uint64_t,
|
||||
&cooperative::by_parent>>,
|
||||
eosio::indexed_by<"bycoopchilds"_n, eosio::const_mem_fun<cooperative, uint128_t, &cooperative::by_coop_childs>>,
|
||||
eosio::indexed_by<"bycooptype"_n, eosio::const_mem_fun<cooperative, uint64_t, &cooperative::bycooptype>>
|
||||
|
||||
// eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<cooperative, uint64_t, &cooperative::by_status>>,
|
||||
// eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<cooperative, uint64_t, &cooperative::by_created>>
|
||||
|
||||
> cooperatives_index;
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Структура, представляющая организации с новым документом document2.
|
||||
* @details Эта структура содержит информацию о юридических лицах (организациях), их верификации и других параметрах.
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] cooperative2 {
|
||||
eosio::name username; ///< Имя аккаунта организации.
|
||||
eosio::name parent_username; ///< Имя родительской организации, если есть.
|
||||
|
||||
std::string announce; ///< Анонс организации.
|
||||
std::string description; ///< Описание организации.
|
||||
bool is_cooperative = false; ///< Флаг, указывающий, является ли организация кооперативом.
|
||||
|
||||
bool is_branched = false; ///< Флаг, указывающий, перешел ли кооператив на собрания уполномоченных
|
||||
bool is_enrolled = false; ///< Флаг, указывающий, активен ли кооператив в системе
|
||||
|
||||
eosio::name coop_type; ///< Тип некоммерческой организации (если это кооператив).
|
||||
|
||||
eosio::asset registration; ///< Регистрационный взнос физического лица / ип
|
||||
eosio::asset initial; ///< Вступительный членский взнос физического лица / ип
|
||||
eosio::asset minimum; ///< Минимальный паевой взнос физического лица / ип
|
||||
|
||||
eosio::binary_extension<eosio::asset> org_registration; ///< Регистрационный взнос юридического лица
|
||||
eosio::binary_extension<eosio::asset> org_initial; ///< Вступительный членский взнос юридического лица
|
||||
eosio::binary_extension<eosio::asset> org_minimum; ///< Минимальный паевой взнос юридического лица
|
||||
|
||||
eosio::binary_extension<eosio::name> status; ///< Статус процесса подключения
|
||||
eosio::binary_extension<eosio::time_point_sec> created_at; ///< Дата поступления заявки на подключение (pending | ... | active | blocked)
|
||||
eosio::binary_extension<document2> document; ///< Подписанный документ соглашения на подключение
|
||||
eosio::binary_extension<uint64_t> active_participants_count; ///< Счетчик активных пайщиков в кооперативе
|
||||
|
||||
|
||||
/**
|
||||
* @brief Возвращает первичный ключ учетной записи организации.
|
||||
* @return uint64_t - первичный ключ, равный значению имени аккаунта организации.
|
||||
*/
|
||||
|
||||
uint64_t primary_key() const {
|
||||
return username.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Сравнивает символ токена кооператива и представленный
|
||||
*/
|
||||
void check_symbol_or_fail(eosio::asset contribution) {
|
||||
eosio::check(initial.symbol == contribution.symbol && minimum.symbol == contribution.symbol, "Неверный контракт токена");
|
||||
}
|
||||
|
||||
uint64_t by_status() const {
|
||||
return status.has_value() ? status.value().value : 0;
|
||||
}
|
||||
|
||||
uint64_t by_created() const {
|
||||
return created_at.has_value() ? created_at.value().sec_since_epoch() : 0;
|
||||
}
|
||||
/**
|
||||
* @brief Возвращает ключ по родительской организации.
|
||||
* @return uint64_t - ключ, равный значению имени родительской организации.
|
||||
*/
|
||||
uint64_t by_parent() const {
|
||||
return parent_username.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индекса кооперативных подразделений организации.
|
||||
* @return uint128_t - составной ключ, включающий значения имени организации и родительской организации.
|
||||
*/
|
||||
uint128_t by_coop_childs() const {
|
||||
return combine_ids(username.value, parent_username.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает индекс для определения, является ли организация кооперативом.
|
||||
* @return uint64_t - ключ, равный 1, если организация является кооперативом, иначе 0.
|
||||
*/
|
||||
uint64_t is_coop_index() const {
|
||||
return is_cooperative == true ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индекса по типу некоммерческой организации (если это кооператив).
|
||||
* @return uint64_t - ключ, равный значению типа некоммерческой организации.
|
||||
*/
|
||||
uint64_t bycooptype() const {
|
||||
return coop_type.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Проверяет, является ли организация кооперативом.
|
||||
* @return bool - true, если организация является кооперативом, иначе false.
|
||||
*/
|
||||
bool is_coop() const {
|
||||
return is_cooperative;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"coops"_n, cooperative2,
|
||||
eosio::indexed_by<"iscoop"_n, eosio::const_mem_fun<cooperative2, uint64_t,
|
||||
&cooperative2::is_coop_index>>,
|
||||
eosio::indexed_by<"byparent"_n, eosio::const_mem_fun<cooperative2, uint64_t,
|
||||
&cooperative2::by_parent>>,
|
||||
eosio::indexed_by<"bycoopchilds"_n, eosio::const_mem_fun<cooperative2, uint128_t, &cooperative2::by_coop_childs>>,
|
||||
eosio::indexed_by<"bycooptype"_n, eosio::const_mem_fun<cooperative2, uint64_t, &cooperative2::bycooptype>>
|
||||
> cooperatives2_index;
|
||||
|
||||
|
||||
cooperative2 get_cooperative_or_fail(eosio::name coopname) {
|
||||
cooperatives2_index coops(_registrator, _registrator.value);
|
||||
auto org = coops.find(coopname.value);
|
||||
eosio::check(org != coops.end(), "Организация не найдена");
|
||||
eosio::check(org -> is_coop(), "Организация - не кооператив");
|
||||
eosio::check(org -> status.value() == "active"_n, "Кооператив не активен");
|
||||
|
||||
return *org;
|
||||
};
|
||||
|
||||
|
||||
account get_account_or_fail(eosio::name username) {
|
||||
accounts_index accounts(_registrator, _registrator.value);
|
||||
auto account = accounts.find(username.value);
|
||||
eosio::check(account != accounts.end(), "Аккаунт не найден");
|
||||
|
||||
return *account;
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
void check_auth_or_fail(eosio::name contract, eosio::name coopname, eosio::name admin, eosio::name action_name)
|
||||
{
|
||||
// если подписывает ключ кооператива или контракт - разрешено всё.
|
||||
if (has_auth(coopname) || has_auth(contract))
|
||||
return;
|
||||
|
||||
// если нет подписи кооператива, то требуем подпись админа, кем бы он небыл
|
||||
require_auth(admin);
|
||||
|
||||
//проверяем, а админ - это председатель?
|
||||
auto board = get_board_by_type_or_fail(coopname, "soviet"_n);
|
||||
bool is_valid = board.is_valid_chairman(admin);
|
||||
|
||||
if (!is_valid)
|
||||
{ // если не председатель - проверяем гранулы прав доступа админа к действию
|
||||
staff_index staff(_soviet, coopname.value);
|
||||
auto administrator = staff.find(admin.value);
|
||||
eosio::check(administrator != staff.end(), "Администратор не найден");
|
||||
bool has_right = administrator->has_right(_gateway, action_name);
|
||||
|
||||
eosio::check(has_right, "Недостаточно прав доступа к действию");
|
||||
} else {
|
||||
// если председатель - разрешено всё.
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,121 +0,0 @@
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица типовых соглашений кооператива
|
||||
*
|
||||
* Таблица содержит типовые соглашения кооператива, которые должны подписывать участники.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): coagreements
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] coagreement {
|
||||
eosio::name type; ///< Тип соглашения (wallet | user | signature | privacy | ...)
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
uint64_t program_id; ///< Идентификатор программы
|
||||
uint64_t draft_id; ///< Идентификатор шаблона документа
|
||||
|
||||
uint64_t primary_key() const { return type.value;};
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"coagreements"_n, coagreement> coagreements_index;
|
||||
|
||||
|
||||
coagreement get_coagreement_or_fail(eosio::name coopname, eosio::name type) {
|
||||
coagreements_index coagreements(_soviet, coopname.value);
|
||||
auto coagreement = coagreements.find(type.value);
|
||||
eosio::check(coagreement != coagreements.end(), "Соглашение указанного типа не найдено");
|
||||
|
||||
return *coagreement;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица соглашений (устаревшая версия)
|
||||
*
|
||||
* Таблица содержит соглашения, которые подписали участники кооператива.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): agreements
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] agreement {
|
||||
uint64_t id; ///< Уникальный идентификатор соглашения
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
eosio::name username; ///< Имя пользователя
|
||||
eosio::name type; ///< Тип принимаемого документа (соответствует действию в контракте)
|
||||
uint64_t program_id; ///< Вторичный индекс используется для связи с типовой таблицей
|
||||
uint64_t draft_id; ///< Шаблон документа по регистру
|
||||
uint64_t version; ///< Версия шаблона (draft), связанного с типовым документом
|
||||
document document; ///< Документ соглашения
|
||||
eosio::name status; ///< Статус приёма документа
|
||||
eosio::time_point_sec updated_at; ///< Дата-время последнего обновления
|
||||
uint64_t primary_key() const { return id; };
|
||||
uint64_t by_username() const { return username.value; };
|
||||
uint64_t by_status() const {return coopname.value; };
|
||||
uint64_t by_draft() const {return draft_id; };
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индекса указанного соглашения пользователя.
|
||||
* @return uint128_t - составной ключ, включающий значения имени пользователя и идентификатор шаблона по реестру.
|
||||
*/
|
||||
uint128_t by_user_and_draft() const {
|
||||
return combine_ids(username.value, draft_id);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"agreements"_n, agreement,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<agreement, uint64_t, &agreement::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<agreement, uint64_t, &agreement::by_status>>,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<agreement, uint64_t, &agreement::by_draft>>,
|
||||
eosio::indexed_by<"byuserdraft"_n, eosio::const_mem_fun<agreement, uint128_t, &agreement::by_user_and_draft>>
|
||||
> agreements_index;
|
||||
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица соглашений (новая версия)
|
||||
*
|
||||
* Таблица содержит соглашения, которые подписали участники кооператива.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): agreements3
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] agreement2 {
|
||||
uint64_t id; ///< Уникальный идентификатор соглашения
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
eosio::name username; ///< Имя пользователя
|
||||
eosio::name type; ///< Тип принимаемого документа (соответствует действию в контракте)
|
||||
uint64_t program_id; ///< Вторичный индекс используется для связи с типовой таблицей
|
||||
uint64_t draft_id; ///< Шаблон документа по регистру
|
||||
uint64_t version; ///< Версия шаблона (draft), связанного с типовым документом
|
||||
document2 document; ///< Документ соглашения
|
||||
eosio::name status; ///< Статус приёма документа
|
||||
eosio::time_point_sec updated_at; ///< Дата-время последнего обновления
|
||||
uint64_t primary_key() const { return id; };
|
||||
uint64_t by_username() const { return username.value; };
|
||||
uint64_t by_status() const {return coopname.value; };
|
||||
uint64_t by_draft() const {return draft_id; };
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индекса указанного соглашения пользователя.
|
||||
* @return uint128_t - составной ключ, включающий значения имени пользователя и идентификатор шаблона по реестру.
|
||||
*/
|
||||
uint128_t by_user_and_draft() const {
|
||||
return combine_ids(username.value, draft_id);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"agreements3"_n, agreement2,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<agreement2, uint64_t, &agreement2::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<agreement2, uint64_t, &agreement2::by_status>>,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<agreement2, uint64_t, &agreement2::by_draft>>,
|
||||
eosio::indexed_by<"byuserdraft"_n, eosio::const_mem_fun<agreement2, uint128_t, &agreement2::by_user_and_draft>>
|
||||
> agreements2_index;
|
||||
@@ -1,79 +0,0 @@
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\brief Структура таблицы баланса.
|
||||
|
||||
@details Структура, представляющая записи баланса в контрактах. Используется при отправке токенов в контракты _marketplace или _registrator.
|
||||
|
||||
@note Таблица хранится в области памяти пользователя (_registrator | _marketplace, username)
|
||||
*/
|
||||
struct balances_base {
|
||||
uint64_t id; /*!< идентификатор баланса */
|
||||
eosio::name contract; /*!< имя контракта токена */
|
||||
eosio::asset quantity; /*!< количество токенов на балансе */
|
||||
|
||||
uint64_t primary_key() const { return id; } /*!< return id - primary_key */
|
||||
|
||||
uint128_t byconsym() const {
|
||||
return combine_ids(contract.value, quantity.symbol.code().raw());
|
||||
} /*!< возвращает уникальный индекс, сформированный из значения contract и символа токена */
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"balances"_n, balances_base, eosio::indexed_by<"byconsym"_n, eosio::const_mem_fun<balances_base, uint128_t, &balances_base::byconsym>>> balances_index; /*!< Тип мультииндекса для таблицы балансов */
|
||||
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// Таблица кошельков конкретных программ
|
||||
// -----------------------------------------------------------------
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица кошельков программ кооператива
|
||||
*
|
||||
* Таблица содержит информацию о кошельках участников кооперативных программ.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): progwallets
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] progwallet {
|
||||
uint64_t id; ///< Уникальный идентификатор кошелька
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
uint64_t program_id; ///< Идентификатор программы
|
||||
uint64_t agreement_id; ///< Идентификатор соглашения
|
||||
eosio::name username; ///< Имя пользователя
|
||||
eosio::asset available; ///< Доступные средства паевого взноса
|
||||
eosio::binary_extension<eosio::asset> blocked; ///< Недоступные средства паевого взноса
|
||||
eosio::binary_extension<eosio::asset> membership_contribution; ///< Внесенный членский взнос
|
||||
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; } ///< Индекс по имени пользователя
|
||||
uint64_t by_program() const { return program_id; } ///< Индекс по идентификатору программы
|
||||
uint64_t by_agreement() const { return agreement_id; } ///< Индекс по идентификатору соглашения
|
||||
|
||||
uint128_t by_username_and_program() const {
|
||||
return combine_ids(username.value, program_id);
|
||||
} ///< Комбинированный индекс по имени пользователя и идентификатору программы
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"progwallets"_n,
|
||||
progwallet,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<progwallet, uint64_t, &progwallet::by_username>>,
|
||||
eosio::indexed_by<"byprogram"_n, eosio::const_mem_fun<progwallet, uint64_t, &progwallet::by_program>>,
|
||||
eosio::indexed_by<"byuserprog"_n, eosio::const_mem_fun<progwallet, uint128_t, &progwallet::by_username_and_program>>,
|
||||
eosio::indexed_by<"byagreement"_n, eosio::const_mem_fun<progwallet, uint64_t, &progwallet::by_agreement>>
|
||||
> progwallets_index; /*!< Тип мультииндекса для таблицы кошелька программ */
|
||||
|
||||
progwallet get_user_program_wallet_or_fail(eosio::name coopname, eosio::name username, uint64_t program_id) {
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
auto wallets_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, program_id);
|
||||
auto wallet = wallets_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
eosio::check(wallet != wallets_by_username_and_program.end(), "Кошелёк не найден");
|
||||
|
||||
return *wallet;
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Таблица статистики кооперативных участков хранит количество участков для каждого кооператива.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_branch_tables
|
||||
|
||||
* @par Область памяти (scope): _branch
|
||||
* @par Имя таблицы (table): branchstat
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(BRANCH)]] branchstat {
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
uint64_t count; ///< Количество кооперативных участков
|
||||
|
||||
uint64_t primary_key() const { return coopname.value; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"branchstat"_n, branchstat> branchstat_index;
|
||||
|
||||
uint64_t add_branch_count(eosio::name coopname){
|
||||
branchstat_index stat(_branch, _branch.value);
|
||||
auto st = stat.find(coopname.value);
|
||||
|
||||
uint64_t new_count = 0;
|
||||
|
||||
if (st == stat.end()){
|
||||
new_count = 1;
|
||||
stat.emplace(coopname, [&](auto &s){
|
||||
s.coopname = coopname;
|
||||
s.count = new_count;
|
||||
});
|
||||
} else {
|
||||
new_count = st -> count + 1;
|
||||
stat.modify(st, coopname, [&](auto &s){
|
||||
s.count += 1;
|
||||
});
|
||||
};
|
||||
|
||||
return new_count;
|
||||
};
|
||||
|
||||
uint64_t sub_branch_count(eosio::name coopname){
|
||||
branchstat_index stat(_branch, _branch.value);
|
||||
auto st = stat.find(coopname.value);
|
||||
uint64_t new_count = 0;
|
||||
|
||||
eosio::check(st != stat.end(), "Нет кооперативных участков");
|
||||
eosio::check( st -> count > 0, "Системная ошибка");
|
||||
|
||||
new_count = st -> count - 1;
|
||||
|
||||
stat.modify(st, coopname, [&](auto &s){
|
||||
s.count -= 1;
|
||||
});
|
||||
|
||||
return new_count;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Таблица кооперативных участков хранит информацию о кооперативных участках и их доверенных лицах.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_branch_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): branches
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(BRANCH)]] coobranch {
|
||||
eosio::name braname; ///< Имя кооперативного участка
|
||||
eosio::name trustee; ///< Председатель кооперативного участка
|
||||
std::vector<eosio::name> trusted; ///< Список доверенных лиц кооперативного участка
|
||||
|
||||
|
||||
uint64_t primary_key() const { return braname.value; } ///< Первичный ключ (1)
|
||||
uint64_t by_trustee() const { return trustee.value; } ///< Индекс по доверенному лицу (2)
|
||||
|
||||
void add_account_to_trusted(const eosio::name& account) {
|
||||
trusted.push_back(account);
|
||||
}
|
||||
|
||||
void remove_account_from_trusted(const eosio::name& account) {
|
||||
auto itr = std::remove(trusted.begin(), trusted.end(), account);
|
||||
check(itr != trusted.end(), "Account not found in trusted list");
|
||||
trusted.erase(itr, trusted.end());
|
||||
}
|
||||
|
||||
bool is_account_in_trusted(const eosio::name& account) const {
|
||||
return std::find(trusted.begin(), trusted.end(), account) != trusted.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Проверяет права доступа пользователя к данному кооперативному участку
|
||||
* @param username Имя пользователя для проверки
|
||||
* @return true если пользователь имеет права доступа, false в противном случае
|
||||
*/
|
||||
bool is_user_authorized(const eosio::name& username) const {
|
||||
// Проверяем является ли пользователь доверенным лицом (trustee)
|
||||
if (trustee == username) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Проверяем находится ли пользователь в списке доверенных (trusted)
|
||||
return is_account_in_trusted(username);
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"branches"_n, coobranch,
|
||||
eosio::indexed_by<"bytrustee"_n, eosio::const_mem_fun<coobranch, uint64_t, &coobranch::by_trustee>>
|
||||
> branch_index;
|
||||
|
||||
|
||||
coobranch get_branch_or_fail(eosio::name coopname, eosio::name braname) {
|
||||
branch_index branches(_branch, coopname.value);
|
||||
auto branch = branches.find(braname.value);
|
||||
|
||||
eosio::check(branch != branches.end(), "Кооперативный Участок не найден");
|
||||
|
||||
return *branch;
|
||||
};
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Структуры exchange_params и request перенесены в shared_marketplace.hpp
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/symbol.hpp>
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/transaction.hpp>
|
||||
#include <eosio/permission.hpp>
|
||||
|
||||
#include "consts.hpp"
|
||||
#include "shared_names.hpp"
|
||||
#include "registry.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "drafts.hpp"
|
||||
#include "shared_document.hpp"
|
||||
#include "accounts.hpp"
|
||||
#include "coops.hpp"
|
||||
#include "counts.hpp"
|
||||
#include "permissions.hpp"
|
||||
#include "rammarket.hpp"
|
||||
#include "balances.hpp"
|
||||
#include "agreements.hpp"
|
||||
#include "programs.hpp"
|
||||
#include "admins.hpp"
|
||||
#include "funds.hpp"
|
||||
#include "branch.hpp"
|
||||
#include "shared_actions.hpp"
|
||||
#include "shared_soviet.hpp"
|
||||
#include "shared_wallet.hpp"
|
||||
#include "shared_fund.hpp"
|
||||
#include "shared_gateway.hpp"
|
||||
#include "shared_ledger.hpp"
|
||||
#include "shared_approver.hpp"
|
||||
#include "shared_registrator.hpp"
|
||||
#include "shared_loan.hpp"
|
||||
#include "shared_branch.hpp"
|
||||
#include "shared_marketplace.hpp"
|
||||
#include "approves.hpp"
|
||||
@@ -1,451 +0,0 @@
|
||||
#pragma once
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Структура, представляющая членов совета (борда).
|
||||
* @details Эта структура содержит информацию о членах борда, включая их уникальные имена, статус участия в голосовании,
|
||||
* название должности и позицию в доске.
|
||||
*/
|
||||
struct board_member {
|
||||
eosio::name username; ///< Уникальное имя члена доски.
|
||||
bool is_voting; ///< Флаг, указывающий, имеет ли член доски право голоса.
|
||||
std::string position_title; ///< Название должности члена доски.
|
||||
eosio::name position; ///< Позиция члена в доске:
|
||||
// (CHAIRMAN, _('chairman')),
|
||||
// (CHAIRMAN_VP, _('vpchairman')),
|
||||
// (SECRETARY, _('secretary')),
|
||||
// (ACCOUNTING, _('accounting')),
|
||||
// (MEMBER, _('member')),
|
||||
// (INVITED, _(‘invited')),
|
||||
};
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица советов кооператива
|
||||
*
|
||||
* Таблица содержит информацию о советах кооператива, их типе, названии, описании и членах.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): boards
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] boards {
|
||||
uint64_t id; ///< Уникальный идентификатор доски.
|
||||
eosio::name type; ///< Тип доски:
|
||||
// (soviet, _('Board of Members')), # Совет кооператива
|
||||
// (executive, _('Executive Board')), # Правление
|
||||
// (audit, _('Audit and Revision Board')), # Ревизионный
|
||||
// (other, _('Other committee')), # Другая комиссия
|
||||
std::string name; ///< Название доски.
|
||||
std::string description; ///< Описание доски.
|
||||
|
||||
std::vector<board_member> members; ///< Список членов доски.
|
||||
|
||||
eosio::time_point_sec created_at; ///< Время создания доски.
|
||||
eosio::time_point_sec last_update; ///< Время последнего обновления информации о доске.
|
||||
|
||||
|
||||
/**
|
||||
* @brief Возвращает первичный ключ доски.
|
||||
* @return uint64_t - первичный ключ, равный уникальному идентификатору доски.
|
||||
*/
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по типу доски.
|
||||
* @return uint64_t - ключ, равный значению типа доски.
|
||||
*/
|
||||
uint64_t by_type() const { return type.value; }
|
||||
|
||||
bool is_valid_member(eosio::name member) const {
|
||||
for (const auto& m : members) {
|
||||
if (m.username == member)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_voting_member(eosio::name member) const {
|
||||
for (const auto& m : members) {
|
||||
if (m.username == member && m.is_voting == true)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool is_valid_chairman(eosio::name chairman) const {
|
||||
for (const auto& m : members) {
|
||||
if (m.username == chairman && (m.position == "chairman"_n || m.position == "vpchairman"_n))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
eosio::name get_chairman() const {
|
||||
for (const auto& m : members) {
|
||||
if (m.position == "chairman"_n)
|
||||
return m.username;
|
||||
}
|
||||
return ""_n;
|
||||
};
|
||||
|
||||
bool is_valid_secretary(eosio::name secretary) const {
|
||||
for (const auto& m : members) {
|
||||
if (m.username == secretary && (m.position == "secretary"_n))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool has_voting_right(eosio::name member) const {
|
||||
for (const auto& m : members) {
|
||||
if (m.username == member && m.is_voting)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
uint64_t get_members_count() const {
|
||||
return members.size();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index< "boards"_n, boards,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<boards, uint64_t,
|
||||
&boards::by_type>>> boards_index;
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup public_structs
|
||||
* @brief Структура, представляющая права доступа.
|
||||
* @details Эта структура содержит информацию о правах доступа, связанных с конкретным контрактом и действием.
|
||||
*/
|
||||
struct right {
|
||||
eosio::name contract; ///< Имя контракта, к которому применяется право доступа.
|
||||
eosio::name action_name; ///< Имя действия, к которому применяется право доступа.
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Структура, представляющая администраторов кооператива.
|
||||
* @details Эта структура содержит информацию об администраторах, их уникальных именах, должностях и правах.
|
||||
*/
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица администраторов кооператива
|
||||
*
|
||||
* Таблица содержит информацию об администраторах кооператива, их правах и ролях.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): staff
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] staff {
|
||||
eosio::name username; ///< Уникальное имя администратора
|
||||
std::string position_title; ///< Название должности администратора
|
||||
std::vector<eosio::name> roles; ///< Список ролей
|
||||
std::vector<right> rights; ///< Список прав администратора
|
||||
eosio::time_point_sec created_at; ///< Время создания записи об администраторе
|
||||
eosio::time_point_sec updated_at; ///< Время последнего обновления информации об администраторе
|
||||
|
||||
uint64_t primary_key() const { return username.value; } ///< Первичный ключ для индексации по имени администратора
|
||||
|
||||
bool has_right(eosio::name contract, eosio::name action_name) const {
|
||||
for (const auto& r : rights) {
|
||||
if (r.contract == contract && r.action_name == action_name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"staff"_n, staff> staff_index; ///< Тип мультииндекса для таблицы администраторов
|
||||
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица участников кооператива
|
||||
*
|
||||
* Таблица содержит информацию о членах кооператива, включая их статус, взносы и права.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): participants
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] participant {
|
||||
eosio::name username; ///< Уникальное имя члена кооператива.
|
||||
eosio::time_point_sec created_at; ///< Время создания записи о члене.
|
||||
eosio::time_point_sec last_update; ///< Время последнего обновления информации о члене.
|
||||
eosio::time_point_sec last_min_pay; ///< Время последнего минимального платежа.
|
||||
|
||||
eosio::name status; //accepted | blocked
|
||||
|
||||
bool is_initial = true; ///< флаг, указывающий, внесен ли регистрационный взнос.
|
||||
bool is_minimum = true; ///< флаг, указывающий, внесен ли минимальный паевой взнос.
|
||||
bool has_vote = true; ///< флаг, указывающий, имеет ли член право голоса.
|
||||
|
||||
eosio::binary_extension<eosio::name> type; ///< individual | entrepreneur | organization
|
||||
eosio::binary_extension<eosio::name> braname; ///< имя кооперативного участка
|
||||
|
||||
eosio::binary_extension<eosio::asset> initial_amount; ///< внесенный вступительный взнос
|
||||
eosio::binary_extension<eosio::asset> minimum_amount; ///< внесенный минимальный паевой взнос
|
||||
|
||||
/**
|
||||
* @brief Возвращает первичный ключ учетной записи члена кооператива.
|
||||
* @return uint64_t - первичный ключ, равный значению имени члена кооператива.
|
||||
*/
|
||||
uint64_t primary_key() const {
|
||||
return username.value;
|
||||
} /*!< return username - primary_key */
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по времени последнего минимального платежа.
|
||||
* @return uint64_t - ключ, равный количеству секунд с начала эпохи Unix.
|
||||
*/
|
||||
uint64_t bylastpay() const {
|
||||
return last_min_pay.sec_since_epoch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по времени создания
|
||||
* @return uint64_t - ключ, равный количеству секунд с начала эпохи Unix.
|
||||
*/
|
||||
uint64_t by_created_at() const {
|
||||
return created_at.sec_since_epoch();
|
||||
}
|
||||
|
||||
bool is_active() const {
|
||||
return status == "accepted"_n;
|
||||
}
|
||||
|
||||
uint64_t by_braname() const {
|
||||
return braname.has_value() ? braname -> value : 0; // Проверка на наличие значения
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index< "participants"_n, participant,
|
||||
eosio::indexed_by<"bylastpay"_n, eosio::const_mem_fun<participant, uint64_t, &participant::bylastpay>>,
|
||||
eosio::indexed_by<"createdat"_n, eosio::const_mem_fun<participant, uint64_t, &participant::by_created_at>>,
|
||||
eosio::indexed_by<"bybranch"_n, eosio::const_mem_fun<participant, uint64_t, &participant::by_braname>>
|
||||
> participants_index;
|
||||
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица решений кооператива
|
||||
*
|
||||
* Таблица содержит информацию о решениях, принимаемых советом кооператива, включая голосование и авторизацию.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): decisions
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] decision {
|
||||
uint64_t id; ///< Уникальный идентификатор решения.
|
||||
eosio::name coopname; ///< Имя кооператива, связанного с решением.
|
||||
eosio::name username; ///< Имя пользователя, связанного с решением.
|
||||
|
||||
eosio::name type; ///< Тип решения: // joincoop | change | ...
|
||||
uint64_t batch_id; ///< Идентификатор карточки, связанной с типом решения.
|
||||
document2 statement; ///< Документ заявления
|
||||
|
||||
std::vector<eosio::name> votes_for; ///< Список имен, голосовавших "за" решение.
|
||||
std::vector<eosio::name> votes_against; ///< Список имен, голосовавших "против" решения.
|
||||
|
||||
bool validated = false; ///< Сигнальный флаг, указывающий, что администратор подтверждает валидность решения.
|
||||
bool approved = false; ///< Сигнальный флаг, указывающий, что решение советом принято.
|
||||
bool authorized = false; ///< Флаг, указывающий, что получена авторизация председателя после голосования и валидации до исполнения.
|
||||
eosio::name authorized_by; ///< Имя аккаунта председателя
|
||||
document2 authorization; ///< Документ подписанного решения председателем
|
||||
|
||||
eosio::time_point_sec created_at; ///< Время создания карточки решения.
|
||||
|
||||
eosio::binary_extension<eosio::time_point_sec> expired_at; ///< Время до истечения
|
||||
eosio::binary_extension<std::string> meta; ///< мета-данные
|
||||
|
||||
eosio::binary_extension<name> callback_contract; ///< контракт для вызова после принятия решения
|
||||
eosio::binary_extension<name> confirm_callback; ///< действие для вызова после принятия решения
|
||||
eosio::binary_extension<name> decline_callback; ///< действие для вызова после отклонения решения
|
||||
eosio::binary_extension<checksum256> hash; ///< входящий идентификатор решения
|
||||
|
||||
/**
|
||||
* @brief Возвращает первичный ключ решения.
|
||||
* @return uint64_t - первичный ключ, равный уникальному идентификатору решения.
|
||||
*/
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по идентификатору карточки.
|
||||
* @return uint64_t - ключ, равный идентификатору карточки.
|
||||
*/
|
||||
uint64_t by_secondary() const { return batch_id; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по типу решения.
|
||||
* @return uint64_t - ключ, равный значению типа решения.
|
||||
*/
|
||||
uint64_t bytype() const { return type.value; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по статусу "принято".
|
||||
* @return uint64_t - ключ, равный статусу "принято" (1, если решение принято, иначе 0).
|
||||
*/
|
||||
uint64_t byapproved() const { return approved; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по статусу "подтверждено".
|
||||
* @return uint64_t - ключ, равный статусу "подтверждено" (1, если решение подтверждено, иначе 0).
|
||||
*/
|
||||
uint64_t byvalidated() const { return validated; }
|
||||
|
||||
/**
|
||||
* @brief Возвращает ключ для индексации по статусу "авторизовано".
|
||||
* @return uint64_t - ключ, равный статусу "авторизовано" (1, если решение авторизовано, иначе 0).
|
||||
*/
|
||||
uint64_t byauthorized() const { return authorized; }
|
||||
|
||||
|
||||
checksum256 byhash() const { return hash.value(); }
|
||||
|
||||
|
||||
void check_for_any_vote_exist(eosio::name member) const {
|
||||
// Проверяем, есть ли имя участника в голосах за
|
||||
eosio::check(std::find(votes_for.begin(), votes_for.end(), member) == votes_for.end(), "Участник уже голосовал за данное решение.");
|
||||
|
||||
// Проверяем, есть ли имя участника в голосах против
|
||||
eosio::check(std::find(votes_against.begin(), votes_against.end(), member) == votes_against.end(), "Участник уже голосовал против данного решения.");
|
||||
};
|
||||
|
||||
std::pair<uint64_t, uint64_t> get_votes_count() const {
|
||||
return std::make_pair(votes_for.size(), votes_against.size());
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
typedef eosio::multi_index< "decisions"_n, decision,
|
||||
eosio::indexed_by<"bysecondary"_n, eosio::const_mem_fun<decision, uint64_t, &decision::by_secondary>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<decision, uint64_t, &decision::bytype>>,
|
||||
eosio::indexed_by<"byapproved"_n, eosio::const_mem_fun<decision, uint64_t, &decision::byapproved>>,
|
||||
eosio::indexed_by<"byvalidated"_n, eosio::const_mem_fun<decision, uint64_t, &decision::byvalidated>>,
|
||||
eosio::indexed_by<"byauthorized"_n, eosio::const_mem_fun<decision, uint64_t, &decision::byauthorized>>,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<decision, checksum256, &decision::byhash>>
|
||||
> decisions_index;
|
||||
|
||||
|
||||
boards get_board_by_id(eosio::name coopname, uint64_t board_id){
|
||||
boards_index boards(_soviet, coopname.value);
|
||||
auto board = boards.find(board_id);
|
||||
|
||||
eosio::check(board != boards.end(), "Совет не найден");
|
||||
|
||||
return *board;
|
||||
|
||||
};
|
||||
|
||||
|
||||
boards get_board_by_type_or_fail(eosio::name coopname, eosio::name type){
|
||||
boards_index boards(_soviet, coopname.value);
|
||||
auto boards_by_type_index = boards.template get_index<"bytype"_n>();
|
||||
auto exist = boards_by_type_index.find(type.value);
|
||||
|
||||
eosio::check(exist != boards_by_type_index.end(), "Совет не найден");
|
||||
|
||||
return *exist;
|
||||
|
||||
};
|
||||
|
||||
|
||||
bool check_for_exist_board_by_type(eosio::name coopname, eosio::name type){
|
||||
boards_index boards(_soviet, coopname.value);
|
||||
|
||||
auto boards_by_type_index = boards.template get_index<"bytype"_n>();
|
||||
|
||||
auto exist = boards_by_type_index.find(type.value);
|
||||
|
||||
if (exist != boards_by_type_index.end())
|
||||
return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
struct address_data {
|
||||
std::string full_address;
|
||||
std::string latitude;
|
||||
std::string longitude;
|
||||
std::string country;
|
||||
std::string state;
|
||||
std::string city;
|
||||
std::string district;
|
||||
std::string street;
|
||||
std::string house_number;
|
||||
std::string building_section;
|
||||
std::string unit_number;
|
||||
std::string directions; //как добраться
|
||||
std::string phone_number;
|
||||
std::string email;
|
||||
std::string business_hours;
|
||||
std::string meta;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица адресов кооператива
|
||||
*
|
||||
* Таблица содержит информацию о адресах кооператива, которые используются как точки приёма-выдачи товаров.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): addresses
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] address {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name braname;
|
||||
address_data data;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
};
|
||||
|
||||
|
||||
typedef eosio::multi_index< "addresses"_n, address> addresses_index;
|
||||
|
||||
|
||||
|
||||
bool is_valid_participant(eosio::name coopname, eosio::name username) {
|
||||
participants_index participants(_soviet, coopname.value);
|
||||
auto participant = participants.find(username.value);
|
||||
accounts_index accounts(_registrator, _registrator.value);
|
||||
auto account = accounts.find(username.value);
|
||||
|
||||
if (
|
||||
participant != participants.end() &&
|
||||
participant->status == "accepted"_n
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
participant get_participant_or_fail(eosio::name coopname, eosio::name username){
|
||||
participants_index participants(_soviet, coopname.value);
|
||||
auto participant = participants.find(username.value);
|
||||
eosio::check(participant != participants.end(), "Пайщик не найден в кооперативе");
|
||||
eosio::check(participant -> status != "blocked"_n, "Пайщик заблокирован");
|
||||
|
||||
return *participant;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
/**
|
||||
* Проверка прав администратора / председателя для действий кооператива.
|
||||
* Требует domain/index.hpp (совет, staff) и consts.hpp (_gateway, _soviet).
|
||||
*/
|
||||
inline void check_auth_or_fail(eosio::name contract, eosio::name coopname, eosio::name admin,
|
||||
eosio::name action_name) {
|
||||
if (has_auth(coopname) || has_auth(contract))
|
||||
return;
|
||||
|
||||
require_auth(admin);
|
||||
|
||||
auto board = get_board_by_type_or_fail(coopname, "soviet"_n);
|
||||
bool is_valid = board.is_valid_chairman(admin);
|
||||
|
||||
if (!is_valid) {
|
||||
staff_index staff(_soviet, coopname.value);
|
||||
auto administrator = staff.find(admin.value);
|
||||
eosio::check(administrator != staff.end(), "Администратор не найден");
|
||||
bool has_right = administrator->has_right(_gateway, action_name);
|
||||
|
||||
eosio::check(has_right, "Недостаточно прав доступа к действию");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
|
||||
/**
|
||||
* Чтение таблиц branch / branchstat (domain/index.hpp — раньше).
|
||||
*/
|
||||
namespace Branch {
|
||||
|
||||
uint64_t get_branch_count(eosio::name coopname) {
|
||||
branchstat_index stat(_branch, _branch.value);
|
||||
auto st = stat.find(coopname.value);
|
||||
|
||||
if (st == stat.end()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return st->count;
|
||||
}
|
||||
|
||||
bool is_trustee(eosio::name coopname, eosio::name username) {
|
||||
branch_index branches(_branch, coopname.value);
|
||||
|
||||
auto by_trustee_index = branches.get_index<"bytrustee"_n>();
|
||||
auto trustee_itr = by_trustee_index.find(username.value);
|
||||
|
||||
return trustee_itr != by_trustee_index.end();
|
||||
}
|
||||
|
||||
bool is_trusted(eosio::name coopname, eosio::name braname, eosio::name username) {
|
||||
branch_index branches(_branch, coopname.value);
|
||||
auto branch_itr = branches.find(braname.value);
|
||||
|
||||
if (branch_itr == branches.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return branch_itr->is_account_in_trusted(username);
|
||||
}
|
||||
|
||||
} // namespace Branch
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "../domain/document_core.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace Document {
|
||||
/**
|
||||
* @brief Проверяет, что переданный документ соответствует ожидаемому шаблону
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
#include "../actions.hpp"
|
||||
#include "../names.hpp"
|
||||
|
||||
#define CREATEOUTPAY_SIGNATURE \
|
||||
name coopname, name username, checksum256 outcome_hash, asset quantity, name callback_contract, \
|
||||
name confirm_callback, name decline_callback
|
||||
|
||||
using createoutpay_interface = void(CREATEOUTPAY_SIGNATURE);
|
||||
|
||||
namespace Gateway {
|
||||
|
||||
static const std::set<eosio::name> gateway_income_actions = {
|
||||
"deposit"_n,
|
||||
};
|
||||
|
||||
static const std::set<eosio::name> gateway_outcome_actions = {
|
||||
"withdraw"_n,
|
||||
};
|
||||
|
||||
inline eosio::name get_valid_income_action(const eosio::name &action) {
|
||||
eosio::check(gateway_income_actions.contains(action), "Недопустимое имя действия");
|
||||
return action;
|
||||
}
|
||||
|
||||
inline eosio::name get_valid_outcome_action(const eosio::name &action) {
|
||||
eosio::check(gateway_outcome_actions.contains(action), "Недопустимое имя действия");
|
||||
return action;
|
||||
}
|
||||
|
||||
inline void create_outcome(name calling_contract, CREATEOUTPAY_SIGNATURE) {
|
||||
Action::send<createoutpay_interface>(_gateway, Names::External::CREATE_OUTPAY, calling_contract, coopname,
|
||||
username, outcome_hash, quantity, callback_contract, confirm_callback,
|
||||
decline_callback);
|
||||
}
|
||||
|
||||
} // namespace Gateway
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Кросс-контрактная логика общей библиотеки (вызовы, проверки, интеграции).
|
||||
* Порядок важен: таблицы — в domain/index.hpp, затем этот файл из lib/index.hpp.
|
||||
*
|
||||
* По смыслу аналогично capital/domain/core/: подпапки по подсистемам.
|
||||
*/
|
||||
#include "programs.hpp"
|
||||
#include "auth.hpp"
|
||||
#include "soviet/soviet.hpp"
|
||||
#include "wallet/wallet.hpp"
|
||||
#include "gateway/gateway.hpp"
|
||||
#include "ledger/ledger.hpp"
|
||||
#include "registrator/registrator.hpp"
|
||||
#include "loan/loan.hpp"
|
||||
#include "branch/branch.hpp"
|
||||
#include "marketplace/marketplace.hpp"
|
||||
+10
-71
@@ -1,81 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Структура бухгалтерского счета
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_ledger_tables
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): accounts
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(LEDGER)]] laccount {
|
||||
uint64_t id; ///< Идентификатор счета
|
||||
std::string name; ///< Название счета
|
||||
eosio::asset available; ///< Доступные средства (было allocation)
|
||||
eosio::asset blocked; ///< Заблокированные средства
|
||||
eosio::asset writeoff; ///< Списанные средства
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
/**
|
||||
* @brief Проверяет, пуст ли счет (все балансы равны нулю)
|
||||
*/
|
||||
bool is_empty() const {
|
||||
return available.amount == 0 && blocked.amount == 0 && writeoff.amount == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Получает общий баланс счета
|
||||
*/
|
||||
eosio::asset get_total() const {
|
||||
return available + blocked + writeoff;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Получает всего доступных + заблокированных средств (без списанных)
|
||||
*/
|
||||
eosio::asset get_balance() const {
|
||||
return available + blocked;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Типы индексов для таблиц ledger
|
||||
*/
|
||||
typedef eosio::multi_index<"accounts"_n, laccount> laccounts_index;
|
||||
|
||||
/**
|
||||
* @brief Структура для операций ожидающих решения совета
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_ledger_tables
|
||||
|
||||
* @par Область памяти (scope): _self
|
||||
* @par Имя таблицы (table): writeoffs
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(LEDGER)]] writeoff_op {
|
||||
uint64_t id; ///< Идентификатор операции
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
eosio::name username; ///< Инициатор операции
|
||||
uint64_t account_id; ///< Счет для операции
|
||||
eosio::asset quantity; ///< Сумма операции
|
||||
std::string reason; ///< Обоснование
|
||||
document2 document; ///< Документ обоснования
|
||||
checksum256 writeoff_hash; ///< Хэш операции списания
|
||||
eosio::name status; ///< Статус: pending, approved, declined, paid
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_coop() const { return coopname.value; }
|
||||
checksum256 by_hash() const { return writeoff_hash; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"writeoffs"_n, writeoff_op,
|
||||
eosio::indexed_by<"bycoop"_n, eosio::const_mem_fun<writeoff_op, uint64_t, &writeoff_op::by_coop>>,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<writeoff_op, checksum256, &writeoff_op::by_hash>>
|
||||
> writeoffs_index;
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
|
||||
/**
|
||||
* @brief Класс Ledger для интеграции с ledger контрактом
|
||||
* @details Требует domain/index.hpp (writeoff_op и др. таблицы ledger) — подключать раньше.
|
||||
*/
|
||||
class Ledger {
|
||||
public:
|
||||
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
#include "../actions.hpp"
|
||||
#include "../names.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
using std::string;
|
||||
|
||||
#define CREATEDEBT_SIGNATURE name coopname, name username, checksum256 debt_hash, time_point_sec repaid_at, asset quantity
|
||||
#define SETTLEDEBT_SIGNATURE name coopname, name username, checksum256 debt_hash, asset quantity
|
||||
|
||||
using createdebt_interface = void(CREATEDEBT_SIGNATURE);
|
||||
using settledebt_interface = void(SETTLEDEBT_SIGNATURE);
|
||||
|
||||
namespace Loan {
|
||||
|
||||
inline std::optional<debt> get_debt(name coopname, const checksum256 &debt_hash) {
|
||||
debts_index debts(_loan, coopname.value);
|
||||
auto by_hash = debts.get_index<"bydebthash"_n>();
|
||||
auto it = by_hash.find(debt_hash);
|
||||
if (it == by_hash.end())
|
||||
return std::nullopt;
|
||||
return *it;
|
||||
}
|
||||
|
||||
inline std::optional<summary> get_summary(name coopname, name username) {
|
||||
summaries_index summaries(_loan, coopname.value);
|
||||
auto it = summaries.find(username.value);
|
||||
if (it == summaries.end())
|
||||
return std::nullopt;
|
||||
return *it;
|
||||
}
|
||||
|
||||
inline void assert_no_expired_debts(name coopname, name username) {
|
||||
debts_index debts(_loan, coopname.value);
|
||||
auto by_repaid = debts.get_index<"byrepaid"_n>();
|
||||
|
||||
uint32_t now = time_point_sec(current_time_point()).sec_since_epoch();
|
||||
|
||||
for (auto itr = by_repaid.begin(); itr != by_repaid.end() && itr->repaid_at.sec_since_epoch() <= now;
|
||||
++itr) {
|
||||
if (itr->username == username) {
|
||||
eosio::check(false, "У пользователя есть просроченные долги");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void create_debt(name calling_contract, CREATEDEBT_SIGNATURE) {
|
||||
Action::send<createdebt_interface>(_loan, Names::Loan::CREATE_DEBT, calling_contract, coopname, username,
|
||||
debt_hash, repaid_at, quantity);
|
||||
}
|
||||
|
||||
inline void settle_debt(name calling_contract, SETTLEDEBT_SIGNATURE) {
|
||||
Action::send<settledebt_interface>(_loan, Names::Loan::SETTLE_DEBT, calling_contract, coopname, username,
|
||||
debt_hash, quantity);
|
||||
}
|
||||
|
||||
} // namespace Loan
|
||||
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
#include "../../domain/document_core.hpp"
|
||||
|
||||
#define AUTH_SIGNATURE eosio::name coopname, checksum256 request_hash, document2 authorization
|
||||
|
||||
using auth_interface = void(AUTH_SIGNATURE);
|
||||
|
||||
namespace Marketplace {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
static const std::set<eosio::name> marketplace_callback_actions = {
|
||||
"authoffs2c"_n,
|
||||
"authoffc2r"_n,
|
||||
"authordcont"_n,
|
||||
"authordret"_n,
|
||||
"declineacc"_n,
|
||||
};
|
||||
|
||||
inline eosio::name get_valid_marketplace_action(const eosio::name &action) {
|
||||
eosio::check(marketplace_callback_actions.contains(action), "Недопустимое имя действия marketplace");
|
||||
return action;
|
||||
}
|
||||
|
||||
static std::optional<request> get_request_by_hash(eosio::name coopname, checksum256 request_hash) {
|
||||
requests_index requests(_marketplace, coopname.value);
|
||||
auto idx = requests.get_index<"byhash"_n>();
|
||||
auto req = idx.find(request_hash);
|
||||
|
||||
if (req != idx.end()) {
|
||||
return *req;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static std::optional<shipment> get_shipment_by_hash(eosio::name coopname, checksum256 shipment_hash) {
|
||||
shipments_index shipments(_marketplace, coopname.value);
|
||||
auto idx = shipments.get_index<"byhash"_n>();
|
||||
auto ship = idx.find(shipment_hash);
|
||||
|
||||
if (ship != idx.end()) {
|
||||
return *ship;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static request get_request_by_hash_or_fail(eosio::name coopname, checksum256 request_hash,
|
||||
const std::string &error_msg = "Заявка не найдена по хэшу") {
|
||||
auto request_opt = get_request_by_hash(coopname, request_hash);
|
||||
eosio::check(request_opt.has_value(), error_msg);
|
||||
return *request_opt;
|
||||
}
|
||||
|
||||
static shipment get_shipment_by_hash_or_fail(eosio::name coopname, checksum256 shipment_hash,
|
||||
const std::string &error_msg = "Перевозка не найдена по хэшу") {
|
||||
auto shipment_opt = get_shipment_by_hash(coopname, shipment_hash);
|
||||
eosio::check(shipment_opt.has_value(), error_msg);
|
||||
return *shipment_opt;
|
||||
}
|
||||
|
||||
namespace DocumentNames {
|
||||
static constexpr const name RETURN_STMT = "returnstmt"_n;
|
||||
static constexpr const name CONVERT_FROM = "convertfrom"_n;
|
||||
static constexpr const name CONVERT_TO = "convertto"_n;
|
||||
static constexpr const name CONTRIB_STMT = "contribstmt"_n;
|
||||
static constexpr const name CONTRIB_AUTH = "contribauth"_n;
|
||||
static constexpr const name RETURN_AUTH = "returnauth"_n;
|
||||
static constexpr const name RECEIVE_ACT = "receiveact"_n;
|
||||
static constexpr const name RECEIVE_ACT_CONF = "receiveconf"_n;
|
||||
static constexpr const name TRANSPORT1 = "transport1"_n;
|
||||
static constexpr const name TRANSPORT2 = "transport2"_n;
|
||||
static constexpr const name TRANSPORT3 = "transport3"_n;
|
||||
static constexpr const name TRANSPORT4 = "transport4"_n;
|
||||
static constexpr const name SUPPLY_ACT = "supplyact"_n;
|
||||
static constexpr const name SUPPLY_ACT_CONF = "supplyconf"_n;
|
||||
static constexpr const name SHIPMENT_ACT = "shipmentact"_n;
|
||||
static constexpr const name DELIVERY_ACT = "deliveryact"_n;
|
||||
|
||||
static constexpr const name SHIPMENT_SEND_ACT = "shsendact"_n;
|
||||
static constexpr const name SHIPMENT_LOADING_ACT = "shloadact"_n;
|
||||
static constexpr const name SHIPMENT_ARRIVE_ACT = "sharriveact"_n;
|
||||
static constexpr const name SHIPMENT_RECV_ACT = "shrecvact"_n;
|
||||
|
||||
static constexpr const name WDISPUTE = "wdispute"_n;
|
||||
static constexpr const name WRETURN_AUTH = "wreturnauth"_n;
|
||||
static constexpr const name WSUPPLY_AUTH = "wsupplyauth"_n;
|
||||
static constexpr const name WRETURN_ACT = "wreturnact"_n;
|
||||
static constexpr const name WOFFER_ACT = "wofferact"_n;
|
||||
static constexpr const name WACCEPT_ACT = "wacceptact"_n;
|
||||
} // namespace DocumentNames
|
||||
|
||||
} // namespace Marketplace
|
||||
@@ -0,0 +1,119 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <optional>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
/**
|
||||
* Логика программ пайщика и кошелька (совет).
|
||||
* Таблицы programs / progwallets / agreements — из domain/index.hpp (подключать раньше).
|
||||
*/
|
||||
|
||||
program get_program_or_fail(eosio::name coopname, uint64_t program_id) {
|
||||
programs_index programs(_soviet, coopname.value);
|
||||
print("program_id: ", program_id);
|
||||
auto program_itr = programs.find(program_id);
|
||||
eosio::check(program_itr != programs.end(), "Программа не найдена");
|
||||
|
||||
return program(*program_itr);
|
||||
}
|
||||
|
||||
bool is_participant_of_cpp_by_program_id(eosio::name coopname, eosio::name username, uint64_t program_id) {
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
auto wallets_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, program_id);
|
||||
auto wallet = wallets_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
if (wallet == wallets_by_username_and_program.end())
|
||||
return false;
|
||||
|
||||
auto program_row = get_program_or_fail(coopname, program_id);
|
||||
|
||||
agreements2_index agreements(_soviet, coopname.value);
|
||||
auto agreement_row = agreements.find(wallet->agreement_id);
|
||||
|
||||
if (agreement_row->status == "declined"_n)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_valid_participant_of_program_by_type(eosio::name coopname, eosio::name username,
|
||||
eosio::name program_type) {
|
||||
programs_index programs(_soviet, coopname.value);
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
coagreements_index coagreements(_soviet, coopname.value);
|
||||
auto coagreement_row = coagreements.find(program_type.value);
|
||||
|
||||
if (coagreement_row == coagreements.end())
|
||||
return false;
|
||||
|
||||
auto exist = programs.find(coagreement_row->program_id);
|
||||
|
||||
if (exist == programs.end())
|
||||
return false;
|
||||
|
||||
auto wallets_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, exist->id);
|
||||
auto wallet = wallets_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
if (wallet == wallets_by_username_and_program.end())
|
||||
return false;
|
||||
|
||||
agreements2_index agreements(_soviet, coopname.value);
|
||||
auto agreement_row = agreements.find(wallet->agreement_id);
|
||||
|
||||
if (agreement_row->status == "declined"_n)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct ProgramInfo {
|
||||
uint64_t program_id;
|
||||
uint64_t draft_id;
|
||||
};
|
||||
|
||||
static const std::map<eosio::name, ProgramInfo> program_map = {
|
||||
{_wallet_program, {1, 1}},
|
||||
{_marketplace_program, {2, 699}},
|
||||
{_source_program, {3, 0}},
|
||||
{_capital_program, {4, 1000}}};
|
||||
|
||||
inline void check_valid_program(const eosio::name &type) {
|
||||
eosio::check(program_map.find(type) != program_map.end(), "Недопустимый тип программы");
|
||||
}
|
||||
|
||||
inline uint64_t get_program_id(const eosio::name &type) {
|
||||
auto it = program_map.find(type);
|
||||
eosio::check(it != program_map.end(), "Недопустимый тип программы");
|
||||
return it->second.program_id;
|
||||
}
|
||||
|
||||
inline uint64_t get_draft_id(const eosio::name &type) {
|
||||
auto it = program_map.find(type);
|
||||
eosio::check(it != program_map.end(), "Недопустимый тип программы");
|
||||
return it->second.draft_id;
|
||||
}
|
||||
|
||||
std::optional<progwallet> get_program_wallet(eosio::name coopname, eosio::name username, eosio::name type) {
|
||||
auto program_id = get_program_id(type);
|
||||
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
auto balances_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, program_id);
|
||||
auto wallet = balances_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
if (wallet == balances_by_username_and_program.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *wallet;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
|
||||
/**
|
||||
* Таблицы регистратора — из domain/index.hpp (подключать раньше).
|
||||
*/
|
||||
namespace Core::Registrator {
|
||||
|
||||
inline account get_account_or_fail(eosio::name username) {
|
||||
accounts_index accounts(_registrator, _registrator.value);
|
||||
auto account_itr = accounts.find(username.value);
|
||||
eosio::check(account_itr != accounts.end(), "Аккаунт не найден");
|
||||
return *account_itr;
|
||||
}
|
||||
|
||||
} // namespace Core::Registrator
|
||||
+6
@@ -1,3 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
inline eosio::name get_valid_soviet_action(const eosio::name& action) {
|
||||
eosio::check(soviet_actions.contains(action), "Недопустимое имя действия");
|
||||
return action;
|
||||
+21
-79
@@ -1,6 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
#include "../actions.hpp"
|
||||
#include "../names.hpp"
|
||||
#include "../../domain/document_core.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
@@ -10,15 +16,12 @@ using createagenda_interface = void(CREATEAGENDA_SIGNATURE);
|
||||
#define CREATEAPPRV_SIGNATURE name coopname, name username, document2 document, name type, checksum256 approval_hash, name callback_contract, name callback_action_approve, name callback_action_decline, std::string meta
|
||||
using createapprv_interface = void(CREATEAPPRV_SIGNATURE);
|
||||
|
||||
// Определение сигнатуры для коллбэка отклонения
|
||||
#define DECLINE_CALLBACK_SIGNATURE name coopname, checksum256 hash, std::string reason
|
||||
using decline_callback_interface = void(DECLINE_CALLBACK_SIGNATURE);
|
||||
|
||||
// Определение сигнатуры для коллбэка подтверждения/авторизации с документом
|
||||
#define AUTHORIZE_CALLBACK_SIGNATURE name coopname, checksum256 hash, document2 authorization
|
||||
using authorize_callback_interface = void(AUTHORIZE_CALLBACK_SIGNATURE);
|
||||
|
||||
// Новые сигнатуры действий для registry
|
||||
#define NEWSUBMITTED_SIGNATURE name coopname, name username, name action, checksum256 package, document2 document
|
||||
using newsubmitted_interface = void(NEWSUBMITTED_SIGNATURE);
|
||||
|
||||
@@ -43,91 +46,30 @@ using newagreement_interface = void(NEWAGREEMENT_SIGNATURE);
|
||||
#define NEWPACKAGE_SIGNATURE name coopname, name username, name action, checksum256 package
|
||||
using newpackage_interface = void(NEWPACKAGE_SIGNATURE);
|
||||
|
||||
#define OPENPROGWALL_SIGNATURE name coopname, name username, name program_type, uint64_t agreement_id
|
||||
#define OPENPROGWALL_SIGNATURE name coopname, name username, name program_type, uint64_t agreement_id
|
||||
using openprogwall_interface = void(OPENPROGWALL_SIGNATURE);
|
||||
|
||||
namespace Soviet {
|
||||
|
||||
/**
|
||||
* @brief Создаёт агенду в совете
|
||||
*/
|
||||
inline void create_agenda(
|
||||
name calling_contract,
|
||||
CREATEAGENDA_SIGNATURE
|
||||
) {
|
||||
Action::send<createagenda_interface>(
|
||||
_soviet,
|
||||
Names::External::CREATE_AGENDA,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
type,
|
||||
hash,
|
||||
callback_contract,
|
||||
confirm_callback,
|
||||
decline_callback,
|
||||
statement,
|
||||
meta
|
||||
);
|
||||
inline void create_agenda(name calling_contract, CREATEAGENDA_SIGNATURE) {
|
||||
Action::send<createagenda_interface>(_soviet, Names::External::CREATE_AGENDA, calling_contract, coopname,
|
||||
username, type, hash, callback_contract, confirm_callback,
|
||||
decline_callback, statement, meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Создаёт аппрув в совете
|
||||
*/
|
||||
inline void create_approval(
|
||||
name calling_contract,
|
||||
CREATEAPPRV_SIGNATURE
|
||||
) {
|
||||
Action::send<createapprv_interface>(
|
||||
_soviet,
|
||||
Names::External::CREATE_APPROVAL,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
document,
|
||||
type,
|
||||
approval_hash,
|
||||
callback_contract,
|
||||
callback_action_approve,
|
||||
callback_action_decline,
|
||||
meta
|
||||
);
|
||||
inline void create_approval(name calling_contract, CREATEAPPRV_SIGNATURE) {
|
||||
Action::send<createapprv_interface>(_soviet, Names::External::CREATE_APPROVAL, calling_contract, coopname,
|
||||
username, document, type, approval_hash, callback_contract,
|
||||
callback_action_approve, callback_action_decline, meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Фиксирует документ в реестре как входящий и принятый
|
||||
*/
|
||||
inline void make_complete_document(
|
||||
name calling_contract,
|
||||
name coopname,
|
||||
name username,
|
||||
name action,
|
||||
checksum256 package,
|
||||
document2 document
|
||||
) {
|
||||
// Фиксируем как входящий документ
|
||||
Action::send<newsubmitted_interface>(
|
||||
_soviet,
|
||||
"newsubmitted"_n,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
action,
|
||||
package,
|
||||
document
|
||||
);
|
||||
inline void make_complete_document(name calling_contract, name coopname, name username, name action,
|
||||
checksum256 package, document2 document) {
|
||||
Action::send<newsubmitted_interface>(_soviet, "newsubmitted"_n, calling_contract, coopname, username, action,
|
||||
package, document);
|
||||
|
||||
// Фиксируем как принятый документ
|
||||
Action::send<newresolved_interface>(
|
||||
_soviet,
|
||||
"newresolved"_n,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
action,
|
||||
package,
|
||||
document
|
||||
);
|
||||
Action::send<newresolved_interface>(_soviet, "newresolved"_n, calling_contract, coopname, username, action,
|
||||
package, document);
|
||||
}
|
||||
|
||||
} // namespace Soviet
|
||||
@@ -1,3 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/transaction.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
@@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../../consts.hpp"
|
||||
#include "../actions.hpp"
|
||||
#include "../programs.hpp"
|
||||
#include "../soviet/soviet.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
#define COMPLETEWTHD_SIGNATURE name coopname, checksum256 withdraw_hash
|
||||
#define DECLINEWTHD_SIGNATURE name coopname, checksum256 withdraw_hash, std::string reason
|
||||
|
||||
using completewthd_interface = void(COMPLETEWTHD_SIGNATURE);
|
||||
using declinewthd_interface = void(DECLINEWTHD_SIGNATURE);
|
||||
|
||||
#define AUTHWTHD_SIGNATURE AUTHORIZE_CALLBACK_SIGNATURE
|
||||
using authwthd_interface = void(AUTHWTHD_SIGNATURE);
|
||||
|
||||
static const std::set<eosio::name> wallet_callback_actions = {
|
||||
"authwthd"_n,
|
||||
"declinewthd"_n,
|
||||
"completewthd"_n,
|
||||
};
|
||||
|
||||
class Wallet {
|
||||
public:
|
||||
using deposit = WalletTables::deposit;
|
||||
using withdraw = WalletTables::withdraw;
|
||||
using deposits_index = WalletTables::deposits_index;
|
||||
using withdraws_index = WalletTables::withdraws_index;
|
||||
|
||||
static eosio::name get_valid_wallet_action(const eosio::name &action) {
|
||||
eosio::check(wallet_callback_actions.contains(action), "Недопустимое имя действия wallet");
|
||||
return action;
|
||||
}
|
||||
|
||||
static void validate_asset(const eosio::asset &amount) {
|
||||
check(amount.symbol == _root_govern_symbol, "Неверный символ токена");
|
||||
check(amount.is_valid(), "Неверный актив");
|
||||
check(amount.amount >= 0, "Сумма должна быть неотрицательной");
|
||||
}
|
||||
|
||||
static void add_available_funds(eosio::name contract, eosio::name coopname, eosio::name username,
|
||||
eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "addbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void sub_available_funds(eosio::name contract, eosio::name coopname, eosio::name username,
|
||||
eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "subbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, false, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void add_blocked_funds(eosio::name contract, eosio::name coopname, eosio::name username,
|
||||
eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "addbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "blockbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void sub_blocked_funds(eosio::name contract, eosio::name coopname, eosio::name username,
|
||||
eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
print("▶ Уменьшаем заблокированные средства кошелька пользователя: ", amount, " для пользователя: ",
|
||||
username);
|
||||
print("▶ Программа: ", program_row.id);
|
||||
print("▶ Доступно: ", program_row.available->amount);
|
||||
print("▶ Заблокированные средства: ", program_row.blocked->amount);
|
||||
print("▶ Сумма для уменьшения: ", amount.amount);
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "unblockbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "subbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, false, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void block_funds(eosio::name contract, eosio::name coopname, eosio::name username,
|
||||
eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "blockbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void unblock_funds(eosio::name contract, eosio::name coopname, eosio::name username,
|
||||
eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "unblockbal"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void pay_membership_fee(name contract, name coopname, name username, eosio::asset amount,
|
||||
uint64_t program_id, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, program_id);
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "addmemberfee"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static void unpay_membership_fee(name contract, name coopname, name username, eosio::asset amount,
|
||||
uint64_t program_id, std::string memo) {
|
||||
auto program_row = get_program_or_fail(coopname, program_id);
|
||||
|
||||
action(permission_level{contract, "active"_n}, _soviet, "submemberfee"_n,
|
||||
std::make_tuple(coopname, username, program_row.id, amount, memo))
|
||||
.send();
|
||||
}
|
||||
|
||||
static std::optional<deposit> get_deposit(eosio::name coopname, const checksum256 &hash) {
|
||||
deposits_index primary_index(_wallet, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
static std::optional<withdraw> get_withdraw(eosio::name coopname, const checksum256 &hash) {
|
||||
withdraws_index primary_index(_wallet, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <vector>
|
||||
|
||||
bool check_auth_and_get_payer(const std::vector<eosio::name> &payers) {
|
||||
for (const auto &payer : payers) {
|
||||
if (has_auth(payer)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
eosio::name check_auth_and_get_payer_or_fail(const std::vector<eosio::name> &payers) {
|
||||
for (const auto &payer : payers) {
|
||||
if (has_auth(payer)) {
|
||||
return payer;
|
||||
}
|
||||
}
|
||||
eosio::check(false, "Недостаточно прав доступа");
|
||||
return eosio::name{};
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "table_soviet_boards.hpp"
|
||||
#include "table_soviet_participants.hpp"
|
||||
|
||||
boards get_board_by_id(eosio::name coopname, uint64_t board_id) {
|
||||
boards_index boards_tbl(_soviet, coopname.value);
|
||||
auto board = boards_tbl.find(board_id);
|
||||
|
||||
eosio::check(board != boards_tbl.end(), "Совет не найден");
|
||||
|
||||
return *board;
|
||||
}
|
||||
|
||||
boards get_board_by_type_or_fail(eosio::name coopname, eosio::name type) {
|
||||
boards_index boards_tbl(_soviet, coopname.value);
|
||||
auto boards_by_type_index = boards_tbl.template get_index<"bytype"_n>();
|
||||
auto exist = boards_by_type_index.find(type.value);
|
||||
|
||||
eosio::check(exist != boards_by_type_index.end(), "Совет не найден");
|
||||
|
||||
return *exist;
|
||||
}
|
||||
|
||||
bool check_for_exist_board_by_type(eosio::name coopname, eosio::name type) {
|
||||
boards_index boards_tbl(_soviet, coopname.value);
|
||||
|
||||
auto boards_by_type_index = boards_tbl.template get_index<"bytype"_n>();
|
||||
|
||||
auto exist = boards_by_type_index.find(type.value);
|
||||
|
||||
if (exist != boards_by_type_index.end())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_valid_participant(eosio::name coopname, eosio::name username) {
|
||||
participants_index participants_tbl(_soviet, coopname.value);
|
||||
auto participant_row = participants_tbl.find(username.value);
|
||||
accounts_index accounts_tbl(_registrator, _registrator.value);
|
||||
auto account_row = accounts_tbl.find(username.value);
|
||||
|
||||
if (participant_row != participants_tbl.end() && participant_row->status == "accepted"_n) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
participant get_participant_or_fail(eosio::name coopname, eosio::name username) {
|
||||
participants_index participants_tbl(_soviet, coopname.value);
|
||||
auto participant_row = participants_tbl.find(username.value);
|
||||
eosio::check(participant_row != participants_tbl.end(), "Пайщик не найден в кооперативе");
|
||||
eosio::check(participant_row->status != "blocked"_n, "Пайщик заблокирован");
|
||||
|
||||
return *participant_row;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct document {
|
||||
checksum256 hash;
|
||||
public_key public_key;
|
||||
signature signature;
|
||||
std::string meta;
|
||||
};
|
||||
|
||||
struct signature_info {
|
||||
uint32_t id;
|
||||
checksum256 signed_hash;
|
||||
name signer;
|
||||
public_key public_key;
|
||||
signature signature;
|
||||
time_point_sec signed_at;
|
||||
std::string meta;
|
||||
};
|
||||
|
||||
struct document2 {
|
||||
std::string version;
|
||||
checksum256 hash;
|
||||
checksum256 doc_hash;
|
||||
checksum256 meta_hash;
|
||||
std::string meta;
|
||||
std::vector<signature_info> signatures;
|
||||
};
|
||||
|
||||
void verify_document_or_fail(
|
||||
const document2 &doc,
|
||||
const std::vector<name> &required_signers = {}) {
|
||||
for (const auto &sig : doc.signatures) {
|
||||
assert_recover_key(sig.signed_hash, sig.signature, sig.public_key);
|
||||
}
|
||||
if (!required_signers.empty()) {
|
||||
for (const auto &required : required_signers) {
|
||||
bool found = false;
|
||||
for (const auto &sig : doc.signatures) {
|
||||
if (sig.signer == required) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
check(found,
|
||||
("Не найдена подпись от обязательного подписанта: " + required.to_string()).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_empty_document(const document2 &doc) {
|
||||
return doc.hash == checksum256{};
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
// Агрегатор определений таблиц и связанных domain-заголовков (раньше — drafts/accounts/coops/… в корне lib).
|
||||
|
||||
// drafts
|
||||
#include "document_core.hpp"
|
||||
#include "table_draft_drafts.hpp"
|
||||
#include "table_draft_translations.hpp"
|
||||
|
||||
// accounts (registrator)
|
||||
#include "account_payer.hpp"
|
||||
#include "org_data.hpp"
|
||||
#include "registrator_account_access.hpp"
|
||||
#include "table_registrator_accounts.hpp"
|
||||
#include "table_registrator_coops.hpp"
|
||||
#include "table_registrator_orgs.hpp"
|
||||
#include "table_registrator_verification.hpp"
|
||||
#include "table_registrator_candidates.hpp"
|
||||
#include "table_registrator_candidates_legacy.hpp"
|
||||
|
||||
// coops (soviet)
|
||||
#include "coops_access_helpers.hpp"
|
||||
#include "table_soviet_addresses.hpp"
|
||||
#include "table_soviet_boards.hpp"
|
||||
#include "table_soviet_decisions.hpp"
|
||||
#include "table_soviet_participants.hpp"
|
||||
#include "table_soviet_staff.hpp"
|
||||
#include "table_soviet_approvals.hpp"
|
||||
|
||||
#include "table_counts.hpp"
|
||||
|
||||
#include "permissions.hpp"
|
||||
#include "rammarket.hpp"
|
||||
|
||||
#include "table_balances_balances.hpp"
|
||||
#include "table_soviet_progwallets.hpp"
|
||||
|
||||
#include "table_soviet_agreements.hpp"
|
||||
#include "table_soviet_agreements3.hpp"
|
||||
#include "table_soviet_coagreements.hpp"
|
||||
#include "table_soviet_programs.hpp"
|
||||
|
||||
#include "table_fund_accfunds.hpp"
|
||||
#include "table_fund_coopwallet.hpp"
|
||||
#include "table_fund_expfunds.hpp"
|
||||
#include "table_fund_fwithdraws.hpp"
|
||||
|
||||
#include "table_branch_branches.hpp"
|
||||
#include "table_branch_branchstat.hpp"
|
||||
|
||||
// wallet / gateway / ledger / loan / marketplace
|
||||
#include "table_wallet_deposits.hpp"
|
||||
#include "table_wallet_withdraws.hpp"
|
||||
#include "table_gateway_incomes.hpp"
|
||||
#include "table_gateway_outcomes.hpp"
|
||||
#include "table_ledger_laccount.hpp"
|
||||
#include "table_ledger_writeoffs.hpp"
|
||||
#include "table_loan_debts.hpp"
|
||||
#include "table_loan_summaries.hpp"
|
||||
#include "table_marketplace_requests.hpp"
|
||||
#include "table_marketplace_segments.hpp"
|
||||
#include "table_marketplace_shipments.hpp"
|
||||
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/name.hpp>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
*/
|
||||
struct org_data {
|
||||
bool is_cooperative = false;
|
||||
eosio::name coop_type;
|
||||
std::string announce;
|
||||
std::string description;
|
||||
eosio::asset initial;
|
||||
eosio::asset minimum;
|
||||
|
||||
eosio::asset org_initial;
|
||||
eosio::asset org_minimum;
|
||||
};
|
||||
+6
@@ -1,3 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/permission.hpp>
|
||||
|
||||
struct permission_level_weight {
|
||||
eosio::permission_level permission;
|
||||
uint16_t weight;
|
||||
+2
@@ -4,6 +4,8 @@
|
||||
#include <cmath>
|
||||
#include <eosio/asset.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
namespace eosiosystem {
|
||||
using eosio::asset;
|
||||
using eosio::symbol;
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "table_registrator_accounts.hpp"
|
||||
|
||||
account get_account_or_fail(eosio::name username) {
|
||||
accounts_index accounts(_registrator, _registrator.value);
|
||||
auto account_row = accounts.find(username.value);
|
||||
eosio::check(account_row != accounts.end(), "Аккаунт не найден");
|
||||
|
||||
return *account_row;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../core/utils.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @par table: balances
|
||||
*/
|
||||
struct balances_base {
|
||||
uint64_t id;
|
||||
eosio::name contract;
|
||||
eosio::asset quantity;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
uint128_t byconsym() const {
|
||||
return combine_ids(contract.value, quantity.symbol.code().raw());
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"balances"_n, balances_base,
|
||||
eosio::indexed_by<"byconsym"_n, eosio::const_mem_fun<balances_base, uint128_t, &balances_base::byconsym>>>
|
||||
balances_index;
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_branch_tables
|
||||
* @par table: branches
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(BRANCH)]] coobranch {
|
||||
eosio::name braname;
|
||||
eosio::name trustee;
|
||||
std::vector<eosio::name> trusted;
|
||||
|
||||
uint64_t primary_key() const { return braname.value; }
|
||||
uint64_t by_trustee() const { return trustee.value; }
|
||||
|
||||
void add_account_to_trusted(const eosio::name &account) { trusted.push_back(account); }
|
||||
|
||||
void remove_account_from_trusted(const eosio::name &account) {
|
||||
auto itr = std::remove(trusted.begin(), trusted.end(), account);
|
||||
eosio::check(itr != trusted.end(), "Account not found in trusted list");
|
||||
trusted.erase(itr, trusted.end());
|
||||
}
|
||||
|
||||
bool is_account_in_trusted(const eosio::name &account) const {
|
||||
return std::find(trusted.begin(), trusted.end(), account) != trusted.end();
|
||||
}
|
||||
|
||||
bool is_user_authorized(const eosio::name &username) const {
|
||||
if (trustee == username) {
|
||||
return true;
|
||||
}
|
||||
return is_account_in_trusted(username);
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"branches"_n, coobranch,
|
||||
eosio::indexed_by<"bytrustee"_n, eosio::const_mem_fun<coobranch, uint64_t, &coobranch::by_trustee>>>
|
||||
branch_index;
|
||||
|
||||
coobranch get_branch_or_fail(eosio::name coopname, eosio::name braname) {
|
||||
branch_index branches(_branch, coopname.value);
|
||||
auto branch = branches.find(braname.value);
|
||||
|
||||
eosio::check(branch != branches.end(), "Кооперативный Участок не найден");
|
||||
|
||||
return *branch;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_branch_tables
|
||||
* @par table: branchstat
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(BRANCH)]] branchstat {
|
||||
eosio::name coopname;
|
||||
uint64_t count;
|
||||
|
||||
uint64_t primary_key() const { return coopname.value; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"branchstat"_n, branchstat> branchstat_index;
|
||||
|
||||
uint64_t add_branch_count(eosio::name coopname) {
|
||||
branchstat_index stat(_branch, _branch.value);
|
||||
auto st = stat.find(coopname.value);
|
||||
|
||||
uint64_t new_count = 0;
|
||||
|
||||
if (st == stat.end()) {
|
||||
new_count = 1;
|
||||
stat.emplace(coopname, [&](auto &s) {
|
||||
s.coopname = coopname;
|
||||
s.count = new_count;
|
||||
});
|
||||
} else {
|
||||
new_count = st->count + 1;
|
||||
stat.modify(st, coopname, [&](auto &s) { s.count += 1; });
|
||||
}
|
||||
|
||||
return new_count;
|
||||
}
|
||||
|
||||
uint64_t sub_branch_count(eosio::name coopname) {
|
||||
branchstat_index stat(_branch, _branch.value);
|
||||
auto st = stat.find(coopname.value);
|
||||
uint64_t new_count = 0;
|
||||
|
||||
eosio::check(st != stat.end(), "Нет кооперативных участков");
|
||||
eosio::check(st->count > 0, "Системная ошибка");
|
||||
|
||||
new_count = st->count - 1;
|
||||
|
||||
stat.modify(st, coopname, [&](auto &s) { s.count -= 1; });
|
||||
|
||||
return new_count;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(CAPITAL)]] debt {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name status = "created"_n;
|
||||
checksum256 debt_hash;
|
||||
checksum256 project_hash;
|
||||
time_point_sec repaid_at;
|
||||
asset amount;
|
||||
document2 statement;
|
||||
document2 approved_statement;
|
||||
document2 authorization;
|
||||
std::string memo;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_debt_hash() const { return debt_hash; }
|
||||
checksum256 by_project_hash() const { return project_hash; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"debts"_n, debt,
|
||||
indexed_by<"byusername"_n, const_mem_fun<debt, uint64_t, &debt::by_username>>,
|
||||
indexed_by<"bydebthash"_n, const_mem_fun<debt, checksum256, &debt::by_debt_hash>>,
|
||||
indexed_by<"byprojhash"_n, const_mem_fun<debt, checksum256, &debt::by_project_hash>>>
|
||||
debts_index;
|
||||
+14
-18
@@ -1,25 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../core/utils.hpp"
|
||||
|
||||
struct counts_base {
|
||||
eosio::name key;
|
||||
eosio::name secondary_key;
|
||||
uint64_t value;
|
||||
|
||||
uint64_t primary_key() const {
|
||||
return key.value;
|
||||
} /*!< return id - primary_key */
|
||||
uint128_t keyskey() const {
|
||||
return combine_ids(key.value, secondary_key.value);
|
||||
} /*!< (contract, blocked_now.symbol) - комбинированный secondary_key для
|
||||
получения курса по имени выходного контракта и символу */
|
||||
uint128_t keyvalue() const {
|
||||
return combine_ids(key.value, value);
|
||||
} /*!< (contract, blocked_now.symbol) - комбинированный secondary_key для
|
||||
получения курса по имени выходного контракта и символу */
|
||||
uint64_t primary_key() const { return key.value; }
|
||||
uint128_t keyskey() const { return combine_ids(key.value, secondary_key.value); }
|
||||
uint128_t keyvalue() const { return combine_ids(key.value, value); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"counts"_n, counts_base,
|
||||
eosio::indexed_by<"keyskey"_n, eosio::const_mem_fun<counts_base, uint128_t,
|
||||
&counts_base::keyskey>>>
|
||||
eosio::indexed_by<"keyskey"_n, eosio::const_mem_fun<counts_base, uint128_t, &counts_base::keyskey>>>
|
||||
counts_index;
|
||||
|
||||
uint64_t get_id(eosio::name code, eosio::name scope, eosio::name key) {
|
||||
@@ -38,7 +35,7 @@ uint64_t get_id(eosio::name code, eosio::name scope, eosio::name key) {
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
}
|
||||
|
||||
uint64_t get_global_id(eosio::name _me, eosio::name key) {
|
||||
counts_index counts(_me, _me.value);
|
||||
@@ -56,10 +53,9 @@ uint64_t get_global_id(eosio::name _me, eosio::name key) {
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
}
|
||||
|
||||
uint64_t get_global_id_in_scope(eosio::name _me, eosio::name scope,
|
||||
eosio::name key) {
|
||||
uint64_t get_global_id_in_scope(eosio::name _me, eosio::name scope, eosio::name key) {
|
||||
counts_index counts(_me, scope.value);
|
||||
auto count = counts.find(key.value);
|
||||
uint64_t id = 1;
|
||||
@@ -75,4 +71,4 @@ uint64_t get_global_id_in_scope(eosio::name _me, eosio::name scope,
|
||||
}
|
||||
|
||||
return id;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/contract.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/system.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_draft_tables
|
||||
* @par scope: scope (кооператив или _draft)
|
||||
* @par table: drafts
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(DRAFT)]] onedraft {
|
||||
uint64_t registry_id;
|
||||
uint64_t version;
|
||||
uint64_t default_translation_id;
|
||||
std::string title;
|
||||
std::string description;
|
||||
std::string context;
|
||||
std::string model;
|
||||
|
||||
uint64_t primary_key() const { return registry_id; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"drafts"_n, onedraft> drafts_index;
|
||||
|
||||
onedraft get_scoped_draft_by_registry_or_fail(eosio::name scope, uint64_t draft_id) {
|
||||
drafts_index drafts(_draft, scope.value);
|
||||
auto draft = drafts.find(draft_id);
|
||||
|
||||
eosio::check(draft != drafts.end(), "Шаблон документа не найден");
|
||||
|
||||
return *draft;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/contract.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_draft_tables
|
||||
* @par scope: scope (кооператив или _draft)
|
||||
* @par table: translations
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(DRAFT)]] translation {
|
||||
uint64_t id;
|
||||
uint64_t draft_id;
|
||||
eosio::name lang;
|
||||
std::string data;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_draft() const { return draft_id; }
|
||||
|
||||
uint128_t by_draft_lang() const { return combine_ids(draft_id, lang.value); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"translations"_n, translation,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<translation, uint64_t, &translation::by_draft>>,
|
||||
eosio::indexed_by<"bydraftlang"_n,
|
||||
eosio::const_mem_fun<translation, uint128_t, &translation::by_draft_lang>>>
|
||||
translations_index;
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
* @par table: accfunds
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] accfund {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name contract;
|
||||
|
||||
std::string name;
|
||||
std::string description;
|
||||
|
||||
uint64_t percent;
|
||||
eosio::asset available;
|
||||
eosio::asset withdrawed;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"accfunds"_n, accfund> accfunds_index;
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
struct simple_wallet {
|
||||
eosio::asset available;
|
||||
eosio::asset withdrawed;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
* @par table: coopwallet
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] coopwallet {
|
||||
uint64_t id = 0;
|
||||
|
||||
eosio::name coopname;
|
||||
|
||||
simple_wallet circulating_account;
|
||||
|
||||
simple_wallet initial_account;
|
||||
|
||||
simple_wallet accumulative_account;
|
||||
|
||||
simple_wallet accumulative_expense_account;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"coopwallet"_n, coopwallet> coopwallet_index;
|
||||
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
* @par table: expfunds
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] expfund {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name contract;
|
||||
|
||||
std::string name;
|
||||
std::string description;
|
||||
|
||||
eosio::asset expended;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"expfunds"_n, expfund> expfunds_index;
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
* @par table: fwithdraws
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] fwithdraw {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name status;
|
||||
eosio::name type;
|
||||
uint64_t fund_id;
|
||||
eosio::asset quantity;
|
||||
document2 document;
|
||||
std::string bank_data_id;
|
||||
eosio::time_point_sec expired_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
|
||||
uint64_t by_expired() const { return expired_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"fwithdraws"_n, fwithdraw,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<fwithdraw, uint64_t, &fwithdraw::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<fwithdraw, uint64_t, &fwithdraw::by_status>>,
|
||||
eosio::indexed_by<"byexpired"_n, eosio::const_mem_fun<fwithdraw, uint64_t, &fwithdraw::by_expired>>>
|
||||
fundwithdraws_index;
|
||||
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
namespace Gateway {
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_gateway_tables
|
||||
* @par table: incomes
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(GATEWAY)]] income {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name type;
|
||||
checksum256 income_hash;
|
||||
eosio::name callback_contract;
|
||||
eosio::name confirm_callback;
|
||||
eosio::name decline_callback;
|
||||
|
||||
eosio::asset quantity;
|
||||
eosio::name status;
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point();
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_hash() const { return income_hash; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
};
|
||||
|
||||
typedef 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;
|
||||
|
||||
inline std::optional<income> get_income(eosio::name coopname, const checksum256 &hash) {
|
||||
incomes_index primary_index(_gateway, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
} // namespace Gateway
|
||||
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
namespace Gateway {
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_gateway_tables
|
||||
* @par table: outcomes
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(GATEWAY)]] outcome {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name type;
|
||||
checksum256 outcome_hash;
|
||||
eosio::name callback_contract;
|
||||
eosio::name confirm_callback;
|
||||
eosio::name decline_callback;
|
||||
|
||||
eosio::asset quantity;
|
||||
eosio::name status;
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point();
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_hash() const { return outcome_hash; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"outcomes"_n, outcome,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<outcome, checksum256, &outcome::by_hash>>,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<outcome, uint64_t, &outcome::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<outcome, uint64_t, &outcome::by_status>>>
|
||||
outcomes_index;
|
||||
|
||||
inline std::optional<outcome> get_outcome(eosio::name coopname, const checksum256 &hash) {
|
||||
outcomes_index primary_index(_gateway, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
} // namespace Gateway
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_ledger_tables
|
||||
* @par table: accounts (ledger)
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(LEDGER)]] laccount {
|
||||
uint64_t id;
|
||||
std::string name;
|
||||
eosio::asset available;
|
||||
eosio::asset blocked;
|
||||
eosio::asset writeoff;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
bool is_empty() const {
|
||||
return available.amount == 0 && blocked.amount == 0 && writeoff.amount == 0;
|
||||
}
|
||||
|
||||
eosio::asset get_total() const { return available + blocked + writeoff; }
|
||||
|
||||
eosio::asset get_balance() const { return available + blocked; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"accounts"_n, laccount> laccounts_index;
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_ledger_tables
|
||||
* @par table: writeoffs
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(LEDGER)]] writeoff_op {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
uint64_t account_id;
|
||||
eosio::asset quantity;
|
||||
std::string reason;
|
||||
document2 document;
|
||||
checksum256 writeoff_hash;
|
||||
eosio::name status;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_coop() const { return coopname.value; }
|
||||
checksum256 by_hash() const { return writeoff_hash; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"writeoffs"_n, writeoff_op,
|
||||
eosio::indexed_by<"bycoop"_n, eosio::const_mem_fun<writeoff_op, uint64_t, &writeoff_op::by_coop>>,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<writeoff_op, checksum256, &writeoff_op::by_hash>>>
|
||||
writeoffs_index;
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
namespace Loan {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(LOAN)]] debt {
|
||||
uint64_t id;
|
||||
name coopname;
|
||||
name username;
|
||||
checksum256 debt_hash;
|
||||
asset amount;
|
||||
time_point_sec created_at;
|
||||
time_point_sec repaid_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_debt_hash() const { return debt_hash; }
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
uint64_t by_repaid() const { return repaid_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef multi_index<
|
||||
"debts"_n, debt,
|
||||
indexed_by<"byusername"_n, const_mem_fun<debt, uint64_t, &debt::by_username>>,
|
||||
indexed_by<"bydebthash"_n, const_mem_fun<debt, checksum256, &debt::by_debt_hash>>,
|
||||
indexed_by<"bycreated"_n, const_mem_fun<debt, uint64_t, &debt::by_created>>,
|
||||
indexed_by<"byrepaid"_n, const_mem_fun<debt, uint64_t, &debt::by_repaid>>>
|
||||
debts_index;
|
||||
|
||||
} // namespace Loan
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
namespace Loan {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(LOAN)]] summary {
|
||||
name username;
|
||||
asset total;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
};
|
||||
|
||||
typedef multi_index<"summaries"_n, summary> summaries_index;
|
||||
|
||||
} // namespace Loan
|
||||
@@ -0,0 +1,109 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/document.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
namespace Marketplace {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(MARKETPLACE)]] request {
|
||||
uint64_t id;
|
||||
checksum256 hash;
|
||||
name coopname;
|
||||
name type;
|
||||
name status;
|
||||
name username;
|
||||
name braname;
|
||||
name warehouse;
|
||||
name token_contract;
|
||||
|
||||
name receiver_braname;
|
||||
name supplier_braname;
|
||||
|
||||
asset unit_cost;
|
||||
asset base_cost;
|
||||
asset membership_fee_amount;
|
||||
asset total_cost;
|
||||
|
||||
uint64_t units;
|
||||
std::string meta;
|
||||
|
||||
name money_contributor;
|
||||
name product_contributor;
|
||||
|
||||
std::vector<Document::named_document> documents;
|
||||
|
||||
uint64_t product_lifecycle_secs;
|
||||
uint64_t warranty_period_secs;
|
||||
asset cancellation_fee_amount;
|
||||
|
||||
time_point_sec warranty_delay_until;
|
||||
time_point_sec deadline_for_receipt;
|
||||
|
||||
bool is_warranty_return = false;
|
||||
uint64_t warranty_return_id;
|
||||
|
||||
time_point_sec created_at;
|
||||
time_point_sec accepted_at;
|
||||
time_point_sec supplied_at;
|
||||
time_point_sec delivered_at;
|
||||
time_point_sec received_at;
|
||||
time_point_sec completed_at;
|
||||
time_point_sec declined_at;
|
||||
time_point_sec disputed_at;
|
||||
time_point_sec canceled_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_coop() const { return coopname.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
uint64_t by_type() const { return type.value; }
|
||||
checksum256 by_hash() const { return hash; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
uint64_t by_completed() const { return completed_at.sec_since_epoch(); }
|
||||
uint64_t by_declined() const { return declined_at.sec_since_epoch(); }
|
||||
uint64_t by_canceled() const { return canceled_at.sec_since_epoch(); }
|
||||
uint64_t by_warranty_id() const { return warranty_return_id; }
|
||||
|
||||
name get_money_contributor() const {
|
||||
return is_warranty_return ? product_contributor : money_contributor;
|
||||
}
|
||||
|
||||
name get_product_contributor() const {
|
||||
return is_warranty_return ? money_contributor : product_contributor;
|
||||
}
|
||||
|
||||
name get_payer() const { return get_money_contributor(); }
|
||||
|
||||
name get_supplier() const { return get_product_contributor(); }
|
||||
|
||||
name get_product_backer() const { return money_contributor; }
|
||||
|
||||
name get_defective_supplier() const { return product_contributor; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"requests"_n, request,
|
||||
eosio::indexed_by<"bycoop"_n, eosio::const_mem_fun<request, uint64_t, &request::by_coop>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<request, uint64_t, &request::by_status>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<request, uint64_t, &request::by_type>>,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<request, checksum256, &request::by_hash>>,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<request, uint64_t, &request::by_username>>,
|
||||
eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<request, uint64_t, &request::by_created>>,
|
||||
eosio::indexed_by<"bycompleted"_n, eosio::const_mem_fun<request, uint64_t, &request::by_completed>>,
|
||||
eosio::indexed_by<"bydeclined"_n, eosio::const_mem_fun<request, uint64_t, &request::by_declined>>,
|
||||
eosio::indexed_by<"bycanceled"_n, eosio::const_mem_fun<request, uint64_t, &request::by_canceled>>,
|
||||
eosio::indexed_by<"bywarrantyid"_n, eosio::const_mem_fun<request, uint64_t, &request::by_warranty_id>>>
|
||||
requests_index;
|
||||
|
||||
} // namespace Marketplace
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
namespace Marketplace {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(MARKETPLACE)]] segment {
|
||||
uint64_t id;
|
||||
uint64_t request_id;
|
||||
name type;
|
||||
name status;
|
||||
|
||||
document2 convert_in;
|
||||
document2 statement;
|
||||
uint64_t decision_id;
|
||||
document2 authorization;
|
||||
document2 act1;
|
||||
document2 act2;
|
||||
document2 convert_out;
|
||||
|
||||
document2 transport_act_1;
|
||||
document2 transport_act_2;
|
||||
document2 transport_act_3;
|
||||
document2 transport_act_4;
|
||||
|
||||
name coopactor;
|
||||
name username;
|
||||
name driver_username;
|
||||
name receive_from_driver_coopactor;
|
||||
|
||||
time_point_sec created_at;
|
||||
time_point_sec updated_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_request() const { return request_id; }
|
||||
uint64_t by_type() const { return type.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"segments"_n, segment,
|
||||
eosio::indexed_by<"byrequest"_n, eosio::const_mem_fun<segment, uint64_t, &segment::by_request>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<segment, uint64_t, &segment::by_type>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<segment, uint64_t, &segment::by_status>>>
|
||||
segments_index;
|
||||
|
||||
} // namespace Marketplace
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/document.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
namespace Marketplace {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(MARKETPLACE)]] shipment {
|
||||
uint64_t id;
|
||||
checksum256 hash;
|
||||
name coopname;
|
||||
name driver_username;
|
||||
name source_braname;
|
||||
name destination_braname;
|
||||
name status;
|
||||
|
||||
std::vector<checksum256> request_hashes;
|
||||
|
||||
std::vector<Document::named_document> documents;
|
||||
|
||||
time_point_sec created_at;
|
||||
time_point_sec loaded_at;
|
||||
time_point_sec delivered_at;
|
||||
time_point_sec completed_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
checksum256 by_hash() const { return hash; }
|
||||
uint64_t by_coop() const { return coopname.value; }
|
||||
uint64_t by_driver() const { return driver_username.value; }
|
||||
uint64_t by_source() const { return source_braname.value; }
|
||||
uint64_t by_destination() const { return destination_braname.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"shipments"_n, shipment,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<shipment, checksum256, &shipment::by_hash>>,
|
||||
eosio::indexed_by<"bycoop"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_coop>>,
|
||||
eosio::indexed_by<"bydriver"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_driver>>,
|
||||
eosio::indexed_by<"bysource"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_source>>,
|
||||
eosio::indexed_by<"bydest"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_destination>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_status>>,
|
||||
eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_created>>>
|
||||
shipments_index;
|
||||
|
||||
} // namespace Marketplace
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "table_registrator_verification.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] account {
|
||||
eosio::name username;
|
||||
eosio::name referer;
|
||||
eosio::name registrator;
|
||||
eosio::name type;
|
||||
eosio::name status;
|
||||
std::string meta;
|
||||
|
||||
std::vector<eosio::name> storages;
|
||||
std::vector<verification> verifications;
|
||||
|
||||
eosio::time_point_sec registered_at;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
|
||||
uint64_t by_referer() const { return referer.value; }
|
||||
|
||||
uint64_t by_type() const { return type.value; }
|
||||
|
||||
uint64_t by_status() const { return status.value; }
|
||||
|
||||
uint64_t by_registr() const { return registrator.value; }
|
||||
|
||||
bool is_active() const { return status == "active"_n; }
|
||||
|
||||
uint64_t by_registered_at() const { return registered_at.sec_since_epoch(); }
|
||||
|
||||
bool is_verified() const {
|
||||
for (const auto &v : verifications) {
|
||||
if (v.is_verified) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t is_verified_index() const {
|
||||
for (const auto &v : verifications) {
|
||||
if (v.is_verified) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"accounts"_n, account,
|
||||
eosio::indexed_by<"byreferer"_n, eosio::const_mem_fun<account, uint64_t, &account::by_referer>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<account, uint64_t, &account::by_type>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<account, uint64_t, &account::by_status>>,
|
||||
eosio::indexed_by<"byregistr"_n, eosio::const_mem_fun<account, uint64_t, &account::by_registr>>,
|
||||
eosio::indexed_by<"byregistred"_n, eosio::const_mem_fun<account, uint64_t, &account::by_registered_at>>,
|
||||
eosio::indexed_by<"byverif"_n, eosio::const_mem_fun<account, uint64_t, &account::is_verified_index>>>
|
||||
accounts_index;
|
||||
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
#include "table_registrator_coops.hpp"
|
||||
|
||||
namespace Registrator {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] candidate {
|
||||
name username;
|
||||
name coopname;
|
||||
name braname;
|
||||
name status;
|
||||
time_point_sec created_at;
|
||||
document2 statement;
|
||||
checksum256 registration_hash;
|
||||
asset initial;
|
||||
asset minimum;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
checksum256 by_hash() const { return registration_hash; }
|
||||
};
|
||||
|
||||
typedef multi_index<
|
||||
"candidates2"_n, candidate,
|
||||
indexed_by<"byhash"_n, const_mem_fun<candidate, checksum256, &candidate::by_hash>>>
|
||||
candidates_index;
|
||||
|
||||
inline std::optional<candidate> get_candidate_by_hash(name coopname, const checksum256 &hash) {
|
||||
candidates_index primary_index(_registrator, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
inline uint64_t get_active_participants_count(name coopname) {
|
||||
cooperatives2_index cooperatives(_registrator, _registrator.value);
|
||||
auto coop_itr = cooperatives.find(coopname.value);
|
||||
|
||||
if (coop_itr == cooperatives.end() || !coop_itr->is_cooperative ||
|
||||
!coop_itr->active_participants_count.has_value()) {
|
||||
eosio::check(false, "Счетчик пайщиков кооператива не найден");
|
||||
}
|
||||
|
||||
return coop_itr->active_participants_count.value();
|
||||
}
|
||||
|
||||
} // namespace Registrator
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
namespace Registrator {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] candidate_legacy {
|
||||
name username;
|
||||
name coopname;
|
||||
name braname;
|
||||
name status;
|
||||
time_point_sec created_at;
|
||||
document statement;
|
||||
checksum256 registration_hash;
|
||||
asset initial;
|
||||
asset minimum;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
checksum256 by_hash() const { return registration_hash; }
|
||||
};
|
||||
|
||||
typedef multi_index<
|
||||
"candidates"_n, candidate_legacy,
|
||||
indexed_by<"byhash"_n, const_mem_fun<candidate_legacy, checksum256, &candidate_legacy::by_hash>>>
|
||||
candidates_legacy_index;
|
||||
|
||||
} // namespace Registrator
|
||||
@@ -0,0 +1,82 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] cooperative2 {
|
||||
eosio::name username;
|
||||
eosio::name parent_username;
|
||||
|
||||
std::string announce;
|
||||
std::string description;
|
||||
bool is_cooperative = false;
|
||||
|
||||
bool is_branched = false;
|
||||
bool is_enrolled = false;
|
||||
|
||||
eosio::name coop_type;
|
||||
|
||||
eosio::asset registration;
|
||||
eosio::asset initial;
|
||||
eosio::asset minimum;
|
||||
|
||||
eosio::binary_extension<eosio::asset> org_registration;
|
||||
eosio::binary_extension<eosio::asset> org_initial;
|
||||
eosio::binary_extension<eosio::asset> org_minimum;
|
||||
|
||||
eosio::binary_extension<eosio::name> status;
|
||||
eosio::binary_extension<eosio::time_point_sec> created_at;
|
||||
eosio::binary_extension<document2> document;
|
||||
eosio::binary_extension<uint64_t> active_participants_count;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
|
||||
void check_symbol_or_fail(eosio::asset contribution) {
|
||||
eosio::check(initial.symbol == contribution.symbol && minimum.symbol == contribution.symbol,
|
||||
"Неверный контракт токена");
|
||||
}
|
||||
|
||||
uint64_t by_status() const { return status.has_value() ? status.value().value : 0; }
|
||||
|
||||
uint64_t by_created() const {
|
||||
return created_at.has_value() ? created_at.value().sec_since_epoch() : 0;
|
||||
}
|
||||
|
||||
uint64_t by_parent() const { return parent_username.value; }
|
||||
|
||||
uint128_t by_coop_childs() const { return combine_ids(username.value, parent_username.value); }
|
||||
|
||||
uint64_t is_coop_index() const { return is_cooperative == true ? 1 : 0; }
|
||||
|
||||
uint64_t bycooptype() const { return coop_type.value; }
|
||||
|
||||
bool is_coop() const { return is_cooperative; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"coops"_n, cooperative2,
|
||||
eosio::indexed_by<"iscoop"_n, eosio::const_mem_fun<cooperative2, uint64_t, &cooperative2::is_coop_index>>,
|
||||
eosio::indexed_by<"byparent"_n, eosio::const_mem_fun<cooperative2, uint64_t, &cooperative2::by_parent>>,
|
||||
eosio::indexed_by<"bycoopchilds"_n,
|
||||
eosio::const_mem_fun<cooperative2, uint128_t, &cooperative2::by_coop_childs>>,
|
||||
eosio::indexed_by<"bycooptype"_n, eosio::const_mem_fun<cooperative2, uint64_t, &cooperative2::bycooptype>>>
|
||||
cooperatives2_index;
|
||||
|
||||
cooperative2 get_cooperative_or_fail(eosio::name coopname) {
|
||||
cooperatives2_index coops(_registrator, _registrator.value);
|
||||
auto org = coops.find(coopname.value);
|
||||
eosio::check(org != coops.end(), "Организация не найдена");
|
||||
eosio::check(org->is_coop(), "Организация - не кооператив");
|
||||
eosio::check(org->status.value() == "active"_n, "Кооператив не активен");
|
||||
|
||||
return *org;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] cooperative {
|
||||
eosio::name username;
|
||||
eosio::name parent_username;
|
||||
|
||||
std::string announce;
|
||||
std::string description;
|
||||
bool is_cooperative = false;
|
||||
|
||||
bool is_branched = false;
|
||||
bool is_enrolled = false;
|
||||
|
||||
eosio::name coop_type;
|
||||
|
||||
eosio::asset registration;
|
||||
eosio::asset initial;
|
||||
eosio::asset minimum;
|
||||
|
||||
eosio::binary_extension<eosio::asset> org_registration;
|
||||
eosio::binary_extension<eosio::asset> org_initial;
|
||||
eosio::binary_extension<eosio::asset> org_minimum;
|
||||
|
||||
eosio::binary_extension<eosio::name> status;
|
||||
eosio::binary_extension<eosio::time_point_sec> created_at;
|
||||
eosio::binary_extension<document> document;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
|
||||
void check_symbol_or_fail(eosio::asset contribution) {
|
||||
eosio::check(initial.symbol == contribution.symbol && minimum.symbol == contribution.symbol,
|
||||
"Неверный контракт токена");
|
||||
}
|
||||
|
||||
uint64_t by_status() const { return status.has_value() ? status.value().value : 0; }
|
||||
|
||||
uint64_t by_created() const {
|
||||
return created_at.has_value() ? created_at.value().sec_since_epoch() : 0;
|
||||
}
|
||||
|
||||
uint64_t by_parent() const { return parent_username.value; }
|
||||
|
||||
uint128_t by_coop_childs() const { return combine_ids(username.value, parent_username.value); }
|
||||
|
||||
uint64_t is_coop_index() const { return is_cooperative == true ? 1 : 0; }
|
||||
|
||||
uint64_t bycooptype() const { return coop_type.value; }
|
||||
|
||||
bool is_coop() const { return is_cooperative; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"orgs"_n, cooperative,
|
||||
eosio::indexed_by<"iscoop"_n, eosio::const_mem_fun<cooperative, uint64_t, &cooperative::is_coop_index>>,
|
||||
eosio::indexed_by<"byparent"_n, eosio::const_mem_fun<cooperative, uint64_t, &cooperative::by_parent>>,
|
||||
eosio::indexed_by<"bycoopchilds"_n,
|
||||
eosio::const_mem_fun<cooperative, uint128_t, &cooperative::by_coop_childs>>,
|
||||
eosio::indexed_by<"bycooptype"_n, eosio::const_mem_fun<cooperative, uint64_t, &cooperative::bycooptype>>>
|
||||
cooperatives_index;
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
*/
|
||||
struct verification {
|
||||
eosio::name verificator;
|
||||
bool is_verified;
|
||||
eosio::name procedure;
|
||||
eosio::time_point_sec created_at;
|
||||
eosio::time_point_sec last_update;
|
||||
std::string notice;
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
struct address_data {
|
||||
std::string full_address;
|
||||
std::string latitude;
|
||||
std::string longitude;
|
||||
std::string country;
|
||||
std::string state;
|
||||
std::string city;
|
||||
std::string district;
|
||||
std::string street;
|
||||
std::string house_number;
|
||||
std::string building_section;
|
||||
std::string unit_number;
|
||||
std::string directions;
|
||||
std::string phone_number;
|
||||
std::string email;
|
||||
std::string business_hours;
|
||||
std::string meta;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: addresses
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] address {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name braname;
|
||||
address_data data;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"addresses"_n, address> addresses_index;
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: agreements
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] agreement {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name type;
|
||||
uint64_t program_id;
|
||||
uint64_t draft_id;
|
||||
uint64_t version;
|
||||
document document;
|
||||
eosio::name status;
|
||||
eosio::time_point_sec updated_at;
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
uint64_t by_status() const { return coopname.value; }
|
||||
uint64_t by_draft() const { return draft_id; }
|
||||
|
||||
uint128_t by_user_and_draft() const { return combine_ids(username.value, draft_id); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"agreements"_n, agreement,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<agreement, uint64_t, &agreement::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<agreement, uint64_t, &agreement::by_status>>,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<agreement, uint64_t, &agreement::by_draft>>,
|
||||
eosio::indexed_by<"byuserdraft"_n, eosio::const_mem_fun<agreement, uint128_t, &agreement::by_user_and_draft>>>
|
||||
agreements_index;
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: agreements3
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] agreement2 {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name type;
|
||||
uint64_t program_id;
|
||||
uint64_t draft_id;
|
||||
uint64_t version;
|
||||
document2 document;
|
||||
eosio::name status;
|
||||
eosio::time_point_sec updated_at;
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
uint64_t by_status() const { return coopname.value; }
|
||||
uint64_t by_draft() const { return draft_id; }
|
||||
|
||||
uint128_t by_user_and_draft() const { return combine_ids(username.value, draft_id); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"agreements3"_n, agreement2,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<agreement2, uint64_t, &agreement2::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<agreement2, uint64_t, &agreement2::by_status>>,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<agreement2, uint64_t, &agreement2::by_draft>>,
|
||||
eosio::indexed_by<"byuserdraft"_n, eosio::const_mem_fun<agreement2, uint128_t, &agreement2::by_user_and_draft>>>
|
||||
agreements2_index;
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
namespace Approver {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] approval {
|
||||
uint64_t id;
|
||||
name coopname;
|
||||
name username;
|
||||
name type;
|
||||
document2 document;
|
||||
checksum256 approval_hash;
|
||||
name callback_contract;
|
||||
name callback_action_approve;
|
||||
name callback_action_decline;
|
||||
std::string meta;
|
||||
time_point_sec created_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
checksum256 by_hash() const { return approval_hash; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
uint64_t by_type() const { return type.value; }
|
||||
};
|
||||
|
||||
typedef 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;
|
||||
|
||||
inline std::optional<approval> get_approval(name coopname, const checksum256 &hash) {
|
||||
approvals_index primary_index(_soviet, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
} // namespace Approver
|
||||
@@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
struct board_member {
|
||||
eosio::name username;
|
||||
bool is_voting;
|
||||
std::string position_title;
|
||||
eosio::name position;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: boards
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] boards {
|
||||
uint64_t id;
|
||||
eosio::name type;
|
||||
std::string name;
|
||||
std::string description;
|
||||
|
||||
std::vector<board_member> members;
|
||||
|
||||
eosio::time_point_sec created_at;
|
||||
eosio::time_point_sec last_update;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
uint64_t by_type() const { return type.value; }
|
||||
|
||||
bool is_valid_member(eosio::name member) const {
|
||||
for (const auto &m : members) {
|
||||
if (m.username == member)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_voting_member(eosio::name member) const {
|
||||
for (const auto &m : members) {
|
||||
if (m.username == member && m.is_voting == true)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_valid_chairman(eosio::name chairman) const {
|
||||
for (const auto &m : members) {
|
||||
if (m.username == chairman && (m.position == "chairman"_n || m.position == "vpchairman"_n))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
eosio::name get_chairman() const {
|
||||
for (const auto &m : members) {
|
||||
if (m.position == "chairman"_n)
|
||||
return m.username;
|
||||
}
|
||||
return ""_n;
|
||||
}
|
||||
|
||||
bool is_valid_secretary(eosio::name secretary) const {
|
||||
for (const auto &m : members) {
|
||||
if (m.username == secretary && (m.position == "secretary"_n))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool has_voting_right(eosio::name member) const {
|
||||
for (const auto &m : members) {
|
||||
if (m.username == member && m.is_voting)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t get_members_count() const { return members.size(); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"boards"_n, boards,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<boards, uint64_t, &boards::by_type>>>
|
||||
boards_index;
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: coagreements
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] coagreement {
|
||||
eosio::name type;
|
||||
eosio::name coopname;
|
||||
uint64_t program_id;
|
||||
uint64_t draft_id;
|
||||
|
||||
uint64_t primary_key() const { return type.value; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"coagreements"_n, coagreement> coagreements_index;
|
||||
|
||||
coagreement get_coagreement_or_fail(eosio::name coopname, eosio::name type) {
|
||||
coagreements_index coagreements(_soviet, coopname.value);
|
||||
auto coagreement_row = coagreements.find(type.value);
|
||||
eosio::check(coagreement_row != coagreements.end(), "Соглашение указанного типа не найдено");
|
||||
|
||||
return *coagreement_row;
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: decisions
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] decision {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
|
||||
eosio::name type;
|
||||
uint64_t batch_id;
|
||||
document2 statement;
|
||||
|
||||
std::vector<eosio::name> votes_for;
|
||||
std::vector<eosio::name> votes_against;
|
||||
|
||||
bool validated = false;
|
||||
bool approved = false;
|
||||
bool authorized = false;
|
||||
eosio::name authorized_by;
|
||||
document2 authorization;
|
||||
|
||||
eosio::time_point_sec created_at;
|
||||
|
||||
eosio::binary_extension<eosio::time_point_sec> expired_at;
|
||||
eosio::binary_extension<std::string> meta;
|
||||
|
||||
eosio::binary_extension<name> callback_contract;
|
||||
eosio::binary_extension<name> confirm_callback;
|
||||
eosio::binary_extension<name> decline_callback;
|
||||
eosio::binary_extension<checksum256> hash;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
uint64_t by_secondary() const { return batch_id; }
|
||||
|
||||
uint64_t bytype() const { return type.value; }
|
||||
|
||||
uint64_t byapproved() const { return approved; }
|
||||
|
||||
uint64_t byvalidated() const { return validated; }
|
||||
|
||||
uint64_t byauthorized() const { return authorized; }
|
||||
|
||||
checksum256 byhash() const { return hash.value(); }
|
||||
|
||||
void check_for_any_vote_exist(eosio::name member) const {
|
||||
eosio::check(std::find(votes_for.begin(), votes_for.end(), member) == votes_for.end(),
|
||||
"Участник уже голосовал за данное решение.");
|
||||
|
||||
eosio::check(std::find(votes_against.begin(), votes_against.end(), member) == votes_against.end(),
|
||||
"Участник уже голосовал против данного решения.");
|
||||
}
|
||||
|
||||
std::pair<uint64_t, uint64_t> get_votes_count() const {
|
||||
return std::make_pair(votes_for.size(), votes_against.size());
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"decisions"_n, decision,
|
||||
eosio::indexed_by<"bysecondary"_n, eosio::const_mem_fun<decision, uint64_t, &decision::by_secondary>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<decision, uint64_t, &decision::bytype>>,
|
||||
eosio::indexed_by<"byapproved"_n, eosio::const_mem_fun<decision, uint64_t, &decision::byapproved>>,
|
||||
eosio::indexed_by<"byvalidated"_n, eosio::const_mem_fun<decision, uint64_t, &decision::byvalidated>>,
|
||||
eosio::indexed_by<"byauthorized"_n, eosio::const_mem_fun<decision, uint64_t, &decision::byauthorized>>,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<decision, checksum256, &decision::byhash>>>
|
||||
decisions_index;
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: participants
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] participant {
|
||||
eosio::name username;
|
||||
eosio::time_point_sec created_at;
|
||||
eosio::time_point_sec last_update;
|
||||
eosio::time_point_sec last_min_pay;
|
||||
|
||||
eosio::name status;
|
||||
|
||||
bool is_initial = true;
|
||||
bool is_minimum = true;
|
||||
bool has_vote = true;
|
||||
|
||||
eosio::binary_extension<eosio::name> type;
|
||||
eosio::binary_extension<eosio::name> braname;
|
||||
|
||||
eosio::binary_extension<eosio::asset> initial_amount;
|
||||
eosio::binary_extension<eosio::asset> minimum_amount;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
|
||||
uint64_t bylastpay() const { return last_min_pay.sec_since_epoch(); }
|
||||
|
||||
uint64_t by_created_at() const { return created_at.sec_since_epoch(); }
|
||||
|
||||
bool is_active() const { return status == "accepted"_n; }
|
||||
|
||||
uint64_t by_braname() const { return braname.has_value() ? braname->value : 0; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"participants"_n, participant,
|
||||
eosio::indexed_by<"bylastpay"_n, eosio::const_mem_fun<participant, uint64_t, &participant::bylastpay>>,
|
||||
eosio::indexed_by<"createdat"_n, eosio::const_mem_fun<participant, uint64_t, &participant::by_created_at>>,
|
||||
eosio::indexed_by<"bybranch"_n, eosio::const_mem_fun<participant, uint64_t, &participant::by_braname>>>
|
||||
participants_index;
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: programs
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] program {
|
||||
uint64_t id;
|
||||
uint64_t draft_id;
|
||||
eosio::name program_type;
|
||||
|
||||
eosio::name coopname;
|
||||
bool is_active;
|
||||
std::string title;
|
||||
std::string announce;
|
||||
std::string description;
|
||||
std::string preview;
|
||||
std::string images;
|
||||
std::string meta;
|
||||
|
||||
eosio::name calculation_type;
|
||||
uint64_t membership_percent_fee;
|
||||
eosio::asset fixed_membership_contribution;
|
||||
|
||||
eosio::time_point_sec start_at;
|
||||
eosio::time_point_sec expired_at;
|
||||
|
||||
eosio::binary_extension<eosio::asset> available;
|
||||
eosio::binary_extension<eosio::asset> spendeded;
|
||||
eosio::binary_extension<eosio::asset> blocked;
|
||||
|
||||
eosio::binary_extension<bool> is_can_coop_spend_share_contributions;
|
||||
|
||||
eosio::binary_extension<eosio::asset> share_contributions;
|
||||
eosio::binary_extension<eosio::asset> membership_contributions;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_program_type() const { return program_type.value; }
|
||||
uint64_t by_draft() const { return draft_id; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"programs"_n, program,
|
||||
eosio::indexed_by<"programtype"_n, eosio::const_mem_fun<program, uint64_t, &program::by_program_type>>,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<program, uint64_t, &program::by_draft>>>
|
||||
programs_index;
|
||||
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/binary_extension.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "../core/utils.hpp"
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: progwallets
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] progwallet {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
uint64_t program_id;
|
||||
uint64_t agreement_id;
|
||||
eosio::name username;
|
||||
eosio::asset available;
|
||||
eosio::binary_extension<eosio::asset> blocked;
|
||||
eosio::binary_extension<eosio::asset> membership_contribution;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
uint64_t by_program() const { return program_id; }
|
||||
uint64_t by_agreement() const { return agreement_id; }
|
||||
|
||||
uint128_t by_username_and_program() const {
|
||||
return combine_ids(username.value, program_id);
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"progwallets"_n, progwallet,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<progwallet, uint64_t, &progwallet::by_username>>,
|
||||
eosio::indexed_by<"byprogram"_n, eosio::const_mem_fun<progwallet, uint64_t, &progwallet::by_program>>,
|
||||
eosio::indexed_by<"byuserprog"_n,
|
||||
eosio::const_mem_fun<progwallet, uint128_t, &progwallet::by_username_and_program>>,
|
||||
eosio::indexed_by<"byagreement"_n, eosio::const_mem_fun<progwallet, uint64_t, &progwallet::by_agreement>>>
|
||||
progwallets_index;
|
||||
|
||||
progwallet get_user_program_wallet_or_fail(eosio::name coopname, eosio::name username, uint64_t program_id) {
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
auto wallets_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, program_id);
|
||||
auto wallet = wallets_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
eosio::check(wallet != wallets_by_username_and_program.end(), "Кошелёк не найден");
|
||||
|
||||
return *wallet;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
struct right {
|
||||
eosio::name contract;
|
||||
eosio::name action_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_soviet_tables
|
||||
* @par table: staff
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] staff {
|
||||
eosio::name username;
|
||||
std::string position_title;
|
||||
std::vector<eosio::name> roles;
|
||||
std::vector<right> rights;
|
||||
eosio::time_point_sec created_at;
|
||||
eosio::time_point_sec updated_at;
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
|
||||
bool has_right(eosio::name contract, eosio::name action_name) const {
|
||||
for (const auto &r : rights) {
|
||||
if (r.contract == contract && r.action_name == action_name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"staff"_n, staff> staff_index;
|
||||
@@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
|
||||
namespace WalletTables {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @par table: deposits
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(WALLET)]] deposit {
|
||||
uint64_t id;
|
||||
name coopname;
|
||||
name username;
|
||||
checksum256 deposit_hash;
|
||||
|
||||
asset quantity;
|
||||
name status;
|
||||
|
||||
time_point_sec created_at = current_time_point();
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_hash() const { return deposit_hash; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef multi_index<
|
||||
"deposits"_n, deposit,
|
||||
indexed_by<"byhash"_n, const_mem_fun<deposit, checksum256, &deposit::by_hash>>,
|
||||
indexed_by<"byusername"_n, const_mem_fun<deposit, uint64_t, &deposit::by_username>>,
|
||||
indexed_by<"bystatus"_n, const_mem_fun<deposit, uint64_t, &deposit::by_status>>,
|
||||
indexed_by<"bycreated"_n, const_mem_fun<deposit, uint64_t, &deposit::by_created>>>
|
||||
deposits_index;
|
||||
|
||||
} // namespace WalletTables
|
||||
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/eosio.hpp>
|
||||
|
||||
#include "../consts.hpp"
|
||||
#include "document_core.hpp"
|
||||
|
||||
namespace WalletTables {
|
||||
|
||||
using namespace eosio;
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @par table: withdraws
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(WALLET)]] withdraw {
|
||||
uint64_t id;
|
||||
name username;
|
||||
name coopname;
|
||||
checksum256 withdraw_hash;
|
||||
name status;
|
||||
|
||||
asset quantity;
|
||||
document2 statement;
|
||||
document2 approved_statement;
|
||||
document2 authorization;
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point();
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
checksum256 by_hash() const { return withdraw_hash; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef multi_index<
|
||||
"withdraws"_n, withdraw,
|
||||
indexed_by<"byusername"_n, const_mem_fun<withdraw, uint64_t, &withdraw::by_username>>,
|
||||
indexed_by<"byhash"_n, const_mem_fun<withdraw, checksum256, &withdraw::by_hash>>,
|
||||
indexed_by<"bystatus"_n, const_mem_fun<withdraw, uint64_t, &withdraw::by_status>>,
|
||||
indexed_by<"bycreated"_n, const_mem_fun<withdraw, uint64_t, &withdraw::by_created>>>
|
||||
withdraws_index;
|
||||
|
||||
} // namespace WalletTables
|
||||
@@ -1,138 +0,0 @@
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/contract.hpp>
|
||||
#include <eosio/system.hpp>
|
||||
|
||||
struct document
|
||||
{
|
||||
// Чексумма документа (SHA256)
|
||||
checksum256 hash;
|
||||
// Публичный ключ
|
||||
public_key public_key;
|
||||
// Подпись чексуммы
|
||||
signature signature;
|
||||
// Публичные мета-данные документа
|
||||
std::string meta;
|
||||
};
|
||||
|
||||
struct signature_info {
|
||||
uint32_t id; // идентификатор номера подписи
|
||||
checksum256 signed_hash; // подписанный хэш, включающий доп. данные (дату подписи)
|
||||
eosio::name signer; // аккаунт подписавшего
|
||||
eosio::public_key public_key; // публичный ключ
|
||||
eosio::signature signature; // подпись хэша
|
||||
eosio::time_point_sec signed_at; // время подписания
|
||||
std::string meta; // мета-данные подписи
|
||||
};
|
||||
|
||||
struct document2 {
|
||||
|
||||
// Версия стандарта документа
|
||||
std::string version;
|
||||
|
||||
// uint64_t template_id; ///< было бы удобно но этого нет
|
||||
|
||||
// Хэши
|
||||
eosio::checksum256 hash; // общий хэш (doc_hash + meta_hash)
|
||||
eosio::checksum256 doc_hash; // хэш содержимого документа
|
||||
eosio::checksum256 meta_hash; // хэш мета-данных
|
||||
|
||||
// Мета-данные документа
|
||||
std::string meta;
|
||||
|
||||
// Вектор подписей (может содержать несколько подписантов)
|
||||
std::vector<signature_info> signatures;
|
||||
};
|
||||
|
||||
void verify_document_or_fail(
|
||||
const document2 &doc,
|
||||
const std::vector<eosio::name>& required_signers = {}
|
||||
) {
|
||||
for (const auto &sig : doc.signatures) {
|
||||
// Проверка завершится прерыванием, если восстановление подписи провалится
|
||||
assert_recover_key(sig.signed_hash, sig.signature, sig.public_key);
|
||||
}
|
||||
if (!required_signers.empty()) {
|
||||
for (const auto& required : required_signers) {
|
||||
bool found = false;
|
||||
for (const auto& sig : doc.signatures) {
|
||||
if (sig.signer == required) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
eosio::check(found, ("Не найдена подпись от обязательного подписанта: " + required.to_string()).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_empty_document(const document2 &doc)
|
||||
{
|
||||
constexpr checksum256 EMPTY_HASH = checksum256(); // Все нули по умолчанию
|
||||
|
||||
return doc.hash == EMPTY_HASH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Таблица шаблонов документов хранит информацию о шаблонах документов и их версиях.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_draft_tables
|
||||
|
||||
* @par Область памяти (scope): scope (кооператив или _draft)
|
||||
* @par Имя таблицы (table): drafts
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(DRAFT)]] onedraft
|
||||
{
|
||||
uint64_t registry_id; ///< Реестровый идентификатор шаблона
|
||||
uint64_t version; ///< Версия шаблона
|
||||
uint64_t default_translation_id; ///< Идентификатор перевода по умолчанию
|
||||
std::string title; ///< Заголовок шаблона
|
||||
std::string description; ///< Описание шаблона
|
||||
std::string context; ///< Контекст шаблона
|
||||
std::string model; ///< Модель шаблона
|
||||
|
||||
uint64_t primary_key() const { return registry_id; }; ///< Первичный ключ (1)
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"drafts"_n, onedraft> drafts_index;
|
||||
|
||||
|
||||
onedraft get_scoped_draft_by_registry_or_fail(eosio::name scope, uint64_t draft_id) {
|
||||
drafts_index drafts(_draft, scope.value);
|
||||
auto draft = drafts.find(draft_id);
|
||||
|
||||
eosio::check(draft != drafts.end(), "Шаблон документа не найден");
|
||||
|
||||
return *draft;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Таблица переводов шаблонов документов хранит переводы шаблонов на различные языки.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_draft_tables
|
||||
|
||||
* @par Область памяти (scope): scope (кооператив или _draft)
|
||||
* @par Имя таблицы (table): translations
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(DRAFT)]] translation
|
||||
{
|
||||
uint64_t id; ///< Идентификатор перевода
|
||||
uint64_t draft_id; ///< Идентификатор шаблона документа
|
||||
eosio::name lang; ///< Язык перевода
|
||||
std::string data; ///< Данные перевода
|
||||
|
||||
uint64_t primary_key() const { return id; }; ///< Первичный ключ (1)
|
||||
uint64_t by_draft() const { return draft_id; }; ///< Индекс по шаблону (2)
|
||||
|
||||
uint128_t by_draft_lang() const { return combine_ids(draft_id, lang.value); }; ///< Индекс по шаблону и языку (3)
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"translations"_n, translation,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<translation, uint64_t, &translation::by_draft>>,
|
||||
eosio::indexed_by<
|
||||
"bydraftlang"_n,
|
||||
eosio::const_mem_fun<translation, uint128_t, &translation::by_draft_lang>>>
|
||||
translations_index;
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
/**
|
||||
* @brief Структура простого кошелька содержит информацию о доступных и выведенных средствах.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
|
||||
*/
|
||||
struct simple_wallet {
|
||||
eosio::asset available; ///< Доступные средства
|
||||
eosio::asset withdrawed; ///< Выведенные средства
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Таблица кооперативного кошелька хранит информацию о различных счетах кооператива.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): coopwallet
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] coopwallet {
|
||||
uint64_t id = 0; ///< Только нулевой идентификатор
|
||||
|
||||
eosio::name coopname; ///< Идентификатор кооператива
|
||||
|
||||
simple_wallet circulating_account; ///< Паевой счет
|
||||
|
||||
simple_wallet initial_account; ///< Счет вступительных взносов
|
||||
|
||||
simple_wallet accumulative_account; ///< Сводный накопительный счет
|
||||
|
||||
simple_wallet accumulative_expense_account; ///< Накопительный счет списания
|
||||
|
||||
uint64_t primary_key() const { return id; } ///< Первичный ключ (1)
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"coopwallet"_n, coopwallet> coopwallet_index;
|
||||
|
||||
/**
|
||||
* @brief Таблица фондов накопления хранит информацию о фондах накопления кооператива.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): accfunds
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] accfund { // фонды накопления
|
||||
uint64_t id; ///< Идентификатор фонда
|
||||
eosio::name coopname; ///< Идентификатор кооператива
|
||||
eosio::name
|
||||
contract; ///< Внешний контракт, которому передано управление фондом
|
||||
|
||||
std::string name; ///< Название фонда
|
||||
std::string description; ///< Описание фонда
|
||||
|
||||
uint64_t percent; ///< Процент отчислений (1000000 == 100%)
|
||||
eosio::asset available; ///< Количество средств, накопленных в фонде
|
||||
eosio::asset withdrawed; ///< Количество средств, изъятых из фонда накопления
|
||||
|
||||
uint64_t primary_key() const {
|
||||
return id;
|
||||
} ///< Первичный ключ (1)
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"accfunds"_n, accfund> accfunds_index;
|
||||
|
||||
/**
|
||||
* @brief Таблица фондов списания хранит информацию о фондах списания кооператива.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): expfunds
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(FUND)]] expfund { // фонды списания
|
||||
uint64_t id; ///< Идентификатор фонда
|
||||
eosio::name coopname; ///< Идентификатор кооператива
|
||||
eosio::name
|
||||
contract; ///< Внешний контракт, которому передано управление фондом
|
||||
|
||||
std::string name; ///< Название фонда
|
||||
std::string description; ///< Описание фонда
|
||||
|
||||
eosio::asset expended; ///< Количество средств, списанных по фонду
|
||||
|
||||
uint64_t primary_key() const {
|
||||
return id;
|
||||
} ///< Первичный ключ (1)
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"expfunds"_n, expfund> expfunds_index;
|
||||
|
||||
/**
|
||||
* @brief Таблица запросов на вывод средств из фондов накопления хранит информацию о запросах на использование фондов.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_fund_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): fwithdraws
|
||||
*/
|
||||
struct [[eosio::table,
|
||||
eosio::contract(
|
||||
FUND)]] fwithdraw { // таблица ожидания решения совета о
|
||||
// использовании фонда накопления
|
||||
uint64_t id; ///< Идентификатор запроса
|
||||
eosio::name coopname; ///< Идентификатор кооператива
|
||||
eosio::name username; ///< Имя пользователя, запросившего вывод
|
||||
eosio::name status; ///< Статус запроса
|
||||
eosio::name type; ///< Тип запроса
|
||||
uint64_t fund_id; ///< Идентификатор фонда
|
||||
eosio::asset quantity; ///< Количество средств для вывода
|
||||
document2 document; ///< Документ с обоснованием
|
||||
std::string bank_data_id; ///< Идентификатор банковских данных
|
||||
eosio::time_point_sec expired_at; ///< Время истечения запроса
|
||||
|
||||
uint64_t primary_key() const {
|
||||
return id;
|
||||
} ///< Первичный ключ (1)
|
||||
uint64_t by_username() const { return username.value; } ///< Индекс по имени пользователя (2)
|
||||
uint64_t by_status() const { return status.value; } ///< Индекс по статусу (3)
|
||||
|
||||
uint64_t by_expired() const {
|
||||
return expired_at.sec_since_epoch();
|
||||
} ///< Индекс по времени истечения (4)
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"fwithdraws"_n, fwithdraw,
|
||||
eosio::indexed_by<
|
||||
"byusername"_n,
|
||||
eosio::const_mem_fun<fwithdraw, uint64_t, &fwithdraw::by_username>>,
|
||||
eosio::indexed_by<
|
||||
"bystatus"_n,
|
||||
eosio::const_mem_fun<fwithdraw, uint64_t, &fwithdraw::by_status>>,
|
||||
eosio::indexed_by<
|
||||
"byexpired"_n,
|
||||
eosio::const_mem_fun<fwithdraw, uint64_t, &fwithdraw::by_expired>>>
|
||||
fundwithdraws_index;
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/symbol.hpp>
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/crypto.hpp>
|
||||
#include <eosio/transaction.hpp>
|
||||
#include <eosio/permission.hpp>
|
||||
|
||||
#include "consts.hpp"
|
||||
#include "core/registry.hpp"
|
||||
#include "core/utils.hpp"
|
||||
#include "core/names.hpp"
|
||||
#include "core/document.hpp"
|
||||
#include "domain/index.hpp"
|
||||
#include "core/actions.hpp"
|
||||
#include "core/index.hpp"
|
||||
@@ -1,170 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица программ кооператива
|
||||
*
|
||||
* Таблица содержит информацию о кооперативных программах (кошелёк, маркетплейс, капитал).
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): programs
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] program {
|
||||
uint64_t id; ///< Уникальный идентификатор программы
|
||||
uint64_t draft_id; ///< Ссылка на шаблон условий
|
||||
eosio::name program_type; ///< Тип кооперативной программы (wallet | market | capital)
|
||||
|
||||
eosio::name coopname; ///< Имя аккаунта кооператива
|
||||
bool is_active; ///< Флаг активности программы
|
||||
std::string title; ///< Название программы
|
||||
std::string announce; ///< Анонс программы
|
||||
std::string description; ///< Описание программы
|
||||
std::string preview; ///< Предварительный просмотр
|
||||
std::string images; ///< Изображения программы
|
||||
std::string meta; ///< Метаданные программы
|
||||
|
||||
eosio::name calculation_type; ///< LEGACY тип настройки платежей по программе ( absolute | relative | free )
|
||||
uint64_t membership_percent_fee; ///< LEGACY процент комиссии со взноса
|
||||
eosio::asset fixed_membership_contribution; ///< LEGACY Членский взнос
|
||||
|
||||
eosio::time_point_sec start_at; ///< Время открытия программы
|
||||
eosio::time_point_sec expired_at; ///< Время истечения программы
|
||||
|
||||
eosio::binary_extension<eosio::asset> available; ///< Доступные паевые взносы для расходов по ЦПП
|
||||
eosio::binary_extension<eosio::asset> spendeded; ///< Расходы из числа паевых взносов ЦПП
|
||||
eosio::binary_extension<eosio::asset> blocked; ///< Недоступные средства из числа паевых взносов для расходов по ЦПП
|
||||
|
||||
eosio::binary_extension<bool> is_can_coop_spend_share_contributions; ///< Может ли кооператив использовать паевые взносы программы на расходы
|
||||
|
||||
eosio::binary_extension<eosio::asset> share_contributions; ///< Паевые взносы ///< собранные паевые взносы
|
||||
eosio::binary_extension<eosio::asset> membership_contributions; ///< собранные членские взносы
|
||||
|
||||
uint64_t primary_key() const { return id; } /*!< return id - primary_key */
|
||||
uint64_t by_program_type() const { return program_type.value;} /*!< return program_type - secondary_key */
|
||||
uint64_t by_draft() const { return draft_id; };
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"programs"_n,
|
||||
program,
|
||||
eosio::indexed_by<"programtype"_n, eosio::const_mem_fun<program, uint64_t, &program::by_program_type>>,
|
||||
eosio::indexed_by<"bydraft"_n, eosio::const_mem_fun<program, uint64_t, &program::by_draft>>
|
||||
> programs_index; /*!< Тип мультииндекса для таблицы целевых программ */
|
||||
|
||||
|
||||
program get_program_or_fail(eosio::name coopname, uint64_t program_id) {
|
||||
programs_index programs(_soviet, coopname.value);
|
||||
print("program_id: ", program_id);
|
||||
auto program_itr = programs.find(program_id);
|
||||
eosio::check(program_itr != programs.end(), "Программа не найдена");
|
||||
|
||||
return program(*program_itr);
|
||||
};
|
||||
|
||||
|
||||
bool is_participant_of_cpp_by_program_id(eosio::name coopname, eosio::name username, uint64_t program_id) {
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
auto wallets_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, program_id);
|
||||
auto wallet = wallets_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
if (wallet == wallets_by_username_and_program.end())
|
||||
return false;
|
||||
|
||||
auto program = get_program_or_fail(coopname, program_id);
|
||||
|
||||
//достать agreement и проверить статус
|
||||
agreements2_index agreements(_soviet, coopname.value);
|
||||
auto agreement = agreements.find(wallet -> agreement_id);
|
||||
|
||||
if (agreement -> status == "declined"_n)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool is_valid_participant_of_program_by_type(eosio::name coopname, eosio::name username, eosio::name program_type) {
|
||||
programs_index programs(_soviet, coopname.value);
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
coagreements_index coagreements(_soviet, coopname.value);
|
||||
auto coagreement = coagreements.find(program_type.value);
|
||||
|
||||
if (coagreement == coagreements.end())
|
||||
return false;
|
||||
|
||||
auto exist = programs.find(coagreement -> program_id);
|
||||
|
||||
if (exist == programs.end())
|
||||
return false;
|
||||
|
||||
auto wallets_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, exist -> id);
|
||||
auto wallet = wallets_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
if (wallet == wallets_by_username_and_program.end())
|
||||
return false;
|
||||
|
||||
//достать agreement и проверить статус
|
||||
agreements2_index agreements(_soviet, coopname.value);
|
||||
auto agreement = agreements.find(wallet -> agreement_id);
|
||||
|
||||
if (agreement -> status == "declined"_n)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
struct ProgramInfo {
|
||||
uint64_t program_id;
|
||||
uint64_t draft_id;
|
||||
};
|
||||
|
||||
static const std::map<eosio::name, ProgramInfo> program_map = {
|
||||
{_wallet_program, {1, 1}}, // program_id = 1, draft_id = 1
|
||||
{_marketplace_program, {2, 699}}, // program_id = 2, draft_id = 699
|
||||
{_source_program, {3, 0}}, // program_id = 3, draft_id = 0
|
||||
{_capital_program, {4, 1000}} // program_id = 4, draft_id = 1000
|
||||
};
|
||||
|
||||
// Проверка валидности программы
|
||||
inline void check_valid_program(const eosio::name& type) {
|
||||
eosio::check(program_map.find(type) != program_map.end(), "Недопустимый тип программы");
|
||||
}
|
||||
|
||||
// Получение ID программы
|
||||
inline uint64_t get_program_id(const eosio::name& type) {
|
||||
auto it = program_map.find(type);
|
||||
eosio::check(it != program_map.end(), "Недопустимый тип программы");
|
||||
return it->second.program_id;
|
||||
}
|
||||
|
||||
// Получение draft_id программы
|
||||
inline uint64_t get_draft_id(const eosio::name& type) {
|
||||
auto it = program_map.find(type);
|
||||
eosio::check(it != program_map.end(), "Недопустимый тип программы");
|
||||
return it->second.draft_id;
|
||||
}
|
||||
|
||||
|
||||
std::optional<progwallet> get_program_wallet (eosio::name coopname, eosio::name username, name type) {
|
||||
auto program_id = get_program_id(type);
|
||||
|
||||
progwallets_index progwallets(_soviet, coopname.value);
|
||||
|
||||
auto balances_by_username_and_program = progwallets.template get_index<"byuserprog"_n>();
|
||||
auto username_and_program_index = combine_ids(username.value, program_id);
|
||||
auto wallet = balances_by_username_and_program.find(username_and_program_index);
|
||||
|
||||
if (wallet == balances_by_username_and_program.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *wallet;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
namespace Approver {
|
||||
/**
|
||||
\ingroup public_tables
|
||||
\ingroup public_soviet_tables
|
||||
\brief Таблица утверждений
|
||||
*
|
||||
* Таблица содержит запросы на утверждение документов и других действий.
|
||||
*
|
||||
* @note Таблица хранится в области памяти с именем аккаунта: @p _soviet и скоупом: @p coopname
|
||||
* @par Имя таблицы (table): approvals
|
||||
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(SOVIET)]] approval {
|
||||
uint64_t id; ///< Уникальный идентификатор утверждения
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
eosio::name username; ///< Имя пользователя
|
||||
eosio::name type; ///< Тип утверждения
|
||||
document2 document; ///< Документ для утверждения
|
||||
checksum256 approval_hash; ///< Хэш утверждения
|
||||
eosio::name callback_contract; ///< Контракт для обратного вызова
|
||||
eosio::name callback_action_approve; ///< Действие при одобрении
|
||||
eosio::name callback_action_decline; ///< Действие при отклонении
|
||||
std::string meta; ///< Метаданные
|
||||
eosio::time_point_sec created_at; ///< Время создания
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
checksum256 by_hash() const { return approval_hash; } ///< Индекс по хэшу утверждения
|
||||
uint64_t by_username() const { return username.value; } ///< Индекс по имени пользователя
|
||||
uint64_t by_type() const { return type.value; } ///< Индекс по типу утверждения
|
||||
};
|
||||
|
||||
typedef 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; /*!< Мультииндекс для доступа и манипуляции данными таблицы `approvals` */
|
||||
|
||||
|
||||
inline std::optional<approval> get_approval(eosio::name coopname, const checksum256 &hash) {
|
||||
approvals_index primary_index(_soviet, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace Branch {
|
||||
/**
|
||||
* @brief Получает количество кооперативных участков для данного кооператива
|
||||
* @param coopname Имя кооператива
|
||||
* @return Количество участков кооператива
|
||||
*/
|
||||
uint64_t get_branch_count(eosio::name coopname) {
|
||||
branchstat_index stat(_branch, _branch.value);
|
||||
auto st = stat.find(coopname.value);
|
||||
|
||||
if (st == stat.end()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return st->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Проверяет, является ли пользователь уполномоченным лицом (trustee) кооперативного участка
|
||||
* @param coopname Имя кооператива
|
||||
* @param username Имя пользователя для проверки
|
||||
* @return true если пользователь является уполномоченным, false в противном случае
|
||||
*/
|
||||
bool is_trustee(eosio::name coopname, eosio::name username) {
|
||||
branch_index branches(_branch, coopname.value);
|
||||
|
||||
auto by_trustee_index = branches.get_index<"bytrustee"_n>();
|
||||
auto trustee_itr = by_trustee_index.find(username.value);
|
||||
|
||||
return trustee_itr != by_trustee_index.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Проверяет, является ли пользователь доверенным лицом (trusted) в указанном участке кооператива
|
||||
* @param coopname Имя кооператива
|
||||
* @param braname Имя участка
|
||||
* @param username Имя пользователя для проверки
|
||||
* @return true если пользователь является доверенным, false в противном случае
|
||||
*/
|
||||
bool is_trusted(eosio::name coopname, eosio::name braname, eosio::name username) {
|
||||
branch_index branches(_branch, coopname.value);
|
||||
auto branch_itr = branches.find(braname.value);
|
||||
|
||||
if (branch_itr == branches.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return branch_itr->is_account_in_trusted(username);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
struct [[eosio::table, eosio::contract(CAPITAL)]] debt {
|
||||
uint64_t id;
|
||||
eosio::name coopname;
|
||||
eosio::name username;
|
||||
eosio::name status = "created"_n;
|
||||
checksum256 debt_hash;
|
||||
checksum256 project_hash;
|
||||
time_point_sec repaid_at;
|
||||
asset amount;
|
||||
document2 statement;
|
||||
document2 approved_statement;
|
||||
document2 authorization;
|
||||
std::string memo;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_debt_hash() const { return debt_hash; }
|
||||
checksum256 by_project_hash() const { return project_hash; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"debts"_n,
|
||||
debt,
|
||||
indexed_by<"byusername"_n, const_mem_fun<debt, uint64_t, &debt::by_username>>,
|
||||
indexed_by<"bydebthash"_n, const_mem_fun<debt, checksum256, &debt::by_debt_hash>>,
|
||||
indexed_by<"byprojhash"_n, const_mem_fun<debt, checksum256, &debt::by_project_hash>>
|
||||
> debts_index;
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Fund {
|
||||
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
#define CREATEOUTPAY_SIGNATURE name coopname, name username, checksum256 outcome_hash, asset quantity, name callback_contract, name confirm_callback, name decline_callback
|
||||
|
||||
using createoutpay_interface = void(CREATEOUTPAY_SIGNATURE);
|
||||
|
||||
namespace Gateway {
|
||||
|
||||
/**
|
||||
* @ingroup public_consts
|
||||
* @ingroup public_gateway_consts
|
||||
|
||||
* @brief Допустимые действия для входящих платежей
|
||||
*/
|
||||
static const std::set<eosio::name> gateway_income_actions = {
|
||||
"deposit"_n, //паевой взнос по ЦПП Кошелёк
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup public_consts
|
||||
* @ingroup public_gateway_consts
|
||||
|
||||
* @brief Допустимые действия для исходящих платежей
|
||||
*/
|
||||
static const std::set<eosio::name> gateway_outcome_actions = {
|
||||
"withdraw"_n, //возврат паевого взноса по ЦПП Кошелёк
|
||||
};
|
||||
|
||||
|
||||
inline eosio::name get_valid_income_action(const eosio::name& action) {
|
||||
eosio::check(gateway_income_actions.contains(action), "Недопустимое имя действия");
|
||||
return action;
|
||||
}
|
||||
|
||||
inline eosio::name get_valid_outcome_action(const eosio::name& action) {
|
||||
eosio::check(gateway_outcome_actions.contains(action), "Недопустимое имя действия");
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Таблица входящих платежей хранит информацию о входящих платежах в кооператив.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_gateway_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): incomes
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(GATEWAY)]] income {
|
||||
uint64_t id; ///< Уникальный идентификатор записи входящего платежа
|
||||
eosio::name coopname; ///< Имя аккаунта кооператива, в контексте которого совершается платеж
|
||||
eosio::name username; ///< Имя аккаунта пользователя, совершившего платеж
|
||||
eosio::name type; ///< Тип платежа
|
||||
checksum256 income_hash; ///< Хэш входящего платежа
|
||||
name callback_contract; ///< Контракт для вызова коллбэков
|
||||
name confirm_callback; ///< Действие успеха
|
||||
name decline_callback; ///< Действие отклонения
|
||||
|
||||
eosio::asset quantity; ///< Количество средств во внутренней валюте
|
||||
eosio::name status; ///< Статус платежа
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point(); ///< Время создания записи
|
||||
|
||||
uint64_t primary_key() const { return id; } ///< Первичный ключ (1)
|
||||
uint64_t by_username() const { return username.value; } ///< Индекс по имени пользователя (2)
|
||||
checksum256 by_hash() const { return income_hash; } ///< Индекс по хэшу платежа (3)
|
||||
uint64_t by_status() const { return status.value; } ///< Индекс по статусу платежа (4)
|
||||
};
|
||||
|
||||
typedef 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; /*!< Мультииндекс для доступа и манипуляции данными таблицы `incomes` */
|
||||
|
||||
|
||||
/**
|
||||
* @brief Получает возврат из кошелька по хэшу.
|
||||
* @param coopname Имя кооператива (scope таблицы).
|
||||
* @param hash Хэш возврата.
|
||||
* @return `std::optional<income>` - найденное действие или `std::nullopt`, если его нет.
|
||||
*/
|
||||
inline std::optional<income> get_income(eosio::name coopname, const checksum256 &hash) {
|
||||
incomes_index primary_index(_gateway, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Таблица исходящих платежей хранит информацию об исходящих платежах из кооператива.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_gateway_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): outcomes
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(GATEWAY)]] outcome {
|
||||
uint64_t id; ///< Уникальный идентификатор записи исходящего платежа
|
||||
eosio::name coopname; ///< Имя аккаунта кооператива, в контексте которого совершается платеж
|
||||
eosio::name username; ///< Имя аккаунта пользователя, совершившего платеж
|
||||
eosio::name type; ///< Тип платежа
|
||||
checksum256 outcome_hash; ///< Хэш исходящего платежа
|
||||
name callback_contract; ///< Контракт для вызова коллбэков
|
||||
name confirm_callback; ///< Действие успеха
|
||||
name decline_callback; ///< Действие отклонения
|
||||
|
||||
eosio::asset quantity; ///< Количество средств во внутренней валюте
|
||||
eosio::name status; ///< Статус платежа
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point(); ///< Время создания записи
|
||||
|
||||
uint64_t primary_key() const { return id; } ///< Первичный ключ (1)
|
||||
uint64_t by_username() const { return username.value; } ///< Индекс по имени пользователя (2)
|
||||
checksum256 by_hash() const { return outcome_hash; } ///< Индекс по хэшу платежа (3)
|
||||
uint64_t by_status() const { return status.value; } ///< Индекс по статусу платежа (4)
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"outcomes"_n, outcome,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<outcome, checksum256, &outcome::by_hash>>,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<outcome, uint64_t, &outcome::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<outcome, uint64_t, &outcome::by_status>>
|
||||
> outcomes_index; /*!< Мультииндекс для доступа и манипуляции данными таблицы `outcome` */
|
||||
|
||||
|
||||
inline std::optional<outcome> get_outcome(eosio::name coopname, const checksum256 &hash) {
|
||||
outcomes_index primary_index(_gateway, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
inline void create_outcome(
|
||||
name calling_contract,
|
||||
CREATEOUTPAY_SIGNATURE
|
||||
) {
|
||||
Action::send<createoutpay_interface>(
|
||||
_gateway,
|
||||
Names::External::CREATE_OUTPAY,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
outcome_hash,
|
||||
quantity,
|
||||
callback_contract,
|
||||
confirm_callback,
|
||||
decline_callback
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include <optional>
|
||||
|
||||
using namespace eosio;
|
||||
using std::string;
|
||||
|
||||
/**
|
||||
* @brief Сигнатуры действий контракта loan.
|
||||
* @ingroup public_consts
|
||||
* @ingroup public_loan_consts
|
||||
|
||||
*/
|
||||
// Сигнатуры как макросы
|
||||
#define CREATEDEBT_SIGNATURE name coopname, name username, checksum256 debt_hash, time_point_sec repaid_at, asset quantity
|
||||
#define SETTLEDEBT_SIGNATURE name coopname, name username, checksum256 debt_hash, asset quantity
|
||||
|
||||
// Типы для compile-time проверки
|
||||
using createdebt_interface = void(CREATEDEBT_SIGNATURE);
|
||||
using settledebt_interface = void(SETTLEDEBT_SIGNATURE);
|
||||
|
||||
|
||||
namespace Loan {
|
||||
using namespace eosio;
|
||||
|
||||
/**
|
||||
* @brief Структура долгового обязательства.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_loan_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): debts
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(LOAN)]] debt {
|
||||
uint64_t id; ///< Идентификатор долга
|
||||
name coopname; ///< Имя кооператива
|
||||
name username; ///< Имя пользователя-должника
|
||||
checksum256 debt_hash; ///< Хэш долгового обязательства
|
||||
asset amount; ///< Сумма долга
|
||||
time_point_sec created_at; ///< Время создания долга
|
||||
time_point_sec repaid_at; ///< Срок погашения долга
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_username() const { return username.value; }
|
||||
checksum256 by_debt_hash() const { return debt_hash; }
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
uint64_t by_repaid() const { return repaid_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef multi_index<
|
||||
"debts"_n,
|
||||
debt,
|
||||
indexed_by<"byusername"_n, const_mem_fun<debt, uint64_t, &debt::by_username>>,
|
||||
indexed_by<"bydebthash"_n, const_mem_fun<debt, checksum256, &debt::by_debt_hash>>,
|
||||
indexed_by<"bycreated"_n, const_mem_fun<debt, uint64_t, &debt::by_created>>,
|
||||
indexed_by<"byrepaid"_n, const_mem_fun<debt, uint64_t, &debt::by_repaid>>
|
||||
> debts_index;
|
||||
|
||||
/**
|
||||
* @brief Структура сводки по долгам пользователя.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_loan_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): summaries
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(LOAN)]] summary {
|
||||
name username; ///< Имя пользователя
|
||||
asset total; ///< Общая сумма долгов пользователя
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
};
|
||||
|
||||
typedef multi_index<"summaries"_n, summary> summaries_index;
|
||||
|
||||
/**
|
||||
* @brief Получает долговое обязательство по хэшу.
|
||||
* @param coopname Имя кооператива
|
||||
* @param debt_hash Хэш долгового обязательства
|
||||
* @return Опциональное значение долга или nullopt если не найден
|
||||
*/
|
||||
inline std::optional<debt> get_debt(name coopname, const checksum256& debt_hash) {
|
||||
debts_index debts(_loan, coopname.value);
|
||||
auto by_hash = debts.get_index<"bydebthash"_n>();
|
||||
auto it = by_hash.find(debt_hash);
|
||||
if (it == by_hash.end()) return std::nullopt;
|
||||
return *it;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Получает сводку по долгам пользователя.
|
||||
* @param coopname Имя кооператива
|
||||
* @param username Имя пользователя
|
||||
* @return Опциональное значение сводки или nullopt если не найдена
|
||||
*/
|
||||
inline std::optional<summary> get_summary(name coopname, name username) {
|
||||
summaries_index summaries(_loan, coopname.value);
|
||||
auto it = summaries.find(username.value);
|
||||
if (it == summaries.end()) return std::nullopt;
|
||||
return *it;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Проверяет отсутствие просроченных долгов у пользователя.
|
||||
* @param coopname Имя кооператива
|
||||
* @param username Имя пользователя
|
||||
* @throws eosio::check_failure если у пользователя есть просроченные долги
|
||||
*/
|
||||
inline void assert_no_expired_debts(name coopname, name username) {
|
||||
debts_index debts(_loan, coopname.value);
|
||||
auto by_repaid = debts.get_index<"byrepaid"_n>();
|
||||
|
||||
uint32_t now = time_point_sec(current_time_point()).sec_since_epoch();
|
||||
|
||||
for (auto itr = by_repaid.begin(); itr != by_repaid.end() && itr->repaid_at.sec_since_epoch() <= now; ++itr) {
|
||||
if (itr->username == username) {
|
||||
eosio::check(false, "У пользователя есть просроченные долги");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Создает долговое обязательство пайщика.
|
||||
* @param calling_contract Контракт, вызывающий создание долга
|
||||
* @param coopname Имя кооператива
|
||||
* @param username Имя пользователя
|
||||
* @param debt_hash Хэш долгового обязательства
|
||||
* @param repaid_at Срок погашения долга
|
||||
* @param quantity Сумма долга
|
||||
*/
|
||||
inline void create_debt(
|
||||
name calling_contract,
|
||||
CREATEDEBT_SIGNATURE
|
||||
) {
|
||||
//Создаём объект долга в контракте loan
|
||||
Action::send<createdebt_interface>(
|
||||
_loan,
|
||||
Names::Loan::CREATE_DEBT,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
debt_hash,
|
||||
repaid_at,
|
||||
quantity
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Погашает долговое обязательство пайщика.
|
||||
* @param calling_contract Контракт, вызывающий погашение долга
|
||||
* @param coopname Имя кооператива
|
||||
* @param username Имя пользователя
|
||||
* @param debt_hash Хэш долгового обязательства
|
||||
* @param quantity Сумма погашения
|
||||
*/
|
||||
inline void settle_debt(
|
||||
name calling_contract,
|
||||
SETTLEDEBT_SIGNATURE
|
||||
) {
|
||||
Action::send<settledebt_interface>(
|
||||
_loan,
|
||||
Names::Loan::SETTLE_DEBT,
|
||||
calling_contract,
|
||||
coopname,
|
||||
username,
|
||||
debt_hash,
|
||||
quantity
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Сигнатуры для callback действий marketplace
|
||||
#define AUTH_SIGNATURE eosio::name coopname, checksum256 request_hash, document2 authorization
|
||||
|
||||
using auth_interface = void(AUTH_SIGNATURE);
|
||||
|
||||
|
||||
namespace Marketplace {
|
||||
|
||||
/**
|
||||
* @brief Сегмент поставки - унифицированная структура для работы с документами
|
||||
* @ingroup public_tables
|
||||
*
|
||||
* Сегмент представляет собой путь поставки от пайщика в кооператив или из кооператива до пайщика
|
||||
*
|
||||
* Типы сегментов:
|
||||
* - "contribute" - сегмент поставки имущества в кооператив
|
||||
* - "return" - сегмент возврата имущества из кооператива
|
||||
* - "wreturn" - сегмент возврата по гарантии (от заказчика в кооператив)
|
||||
* - "wsupply" - сегмент выдачи по гарантии (из кооператива поставщику)
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(MARKETPLACE)]] segment {
|
||||
uint64_t id; /*!< идентификатор сегмента */
|
||||
uint64_t request_id; /*!< идентификатор заявки, к которой относится сегмент */
|
||||
eosio::name type; /*!< тип сегмента: "contribute", "return", "wreturn", "wsupply" */
|
||||
eosio::name status; /*!< статус сегмента */
|
||||
|
||||
document2 convert_in; /*!< заявление на конвертацию из кошелька */
|
||||
document2 statement; /*!< заявление/документ на взнос или возврат */
|
||||
uint64_t decision_id; /*!< идентификатор решения */
|
||||
document2 authorization; /*!< документ авторизации */
|
||||
document2 act1; /*!< акт приёма-передачи */
|
||||
document2 act2; /*!< акт приёма-передачи */
|
||||
document2 convert_out; /*!< заявление на конвертацию в кошелек */
|
||||
|
||||
// Документы транспортировки
|
||||
document2 transport_act_1; /*!< акт товарно-транспортной накладной - передача имущества на транспортировку */
|
||||
document2 transport_act_2; /*!< акт товарно-транспортной накладной - прием имущества водителем */
|
||||
document2 transport_act_3; /*!< акт товарно-транспортной накладной - доставка до КУ получателя */
|
||||
document2 transport_act_4; /*!< акт товарно-транспортной накладной - прием имущества председателем КУ */
|
||||
|
||||
eosio::name coopactor; /*!< представитель кооператива, который действует в этом сегменте */
|
||||
eosio::name username; /*!< пользователь, который действует в этом сегменте */
|
||||
eosio::name driver_username; /*!< водитель-пайщик, который принимает имущество на транспортировку */
|
||||
eosio::name receive_from_driver_coopactor; /*!< председатель КУ, который принимает имущество от водителя */
|
||||
|
||||
eosio::time_point_sec created_at;
|
||||
eosio::time_point_sec updated_at;
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_request() const { return request_id; }
|
||||
uint64_t by_type() const { return type.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"segments"_n, segment,
|
||||
eosio::indexed_by<"byrequest"_n, eosio::const_mem_fun<segment, uint64_t, &segment::by_request>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<segment, uint64_t, &segment::by_type>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<segment, uint64_t, &segment::by_status>>
|
||||
> segments_index;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Перевозка имущества - объединение нескольких заявок в одну транспортную накладную
|
||||
* @ingroup public_tables
|
||||
*
|
||||
* Перевозка представляет собой процесс транспортировки множества единиц имущества
|
||||
* в рамках одной товарно-транспортной накладной от одного кооперативного участка
|
||||
* к одному или нескольким получателям.
|
||||
*
|
||||
* Статусы перевозки:
|
||||
* - "loading" - идет загрузка товаров в перевозку
|
||||
* - "transit" - перевозка в пути (товары загружены и подписана накладная)
|
||||
* - "arrived" - перевозка прибыла, ожидает подтверждения получателя
|
||||
* - "completed" - все товары из перевозки переданы получателям
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(MARKETPLACE)]] shipment {
|
||||
uint64_t id; /*!< идентификатор перевозки */
|
||||
checksum256 hash; /*!< внешний идентификатор перевозки */
|
||||
eosio::name coopname; /*!< имя кооператива */
|
||||
eosio::name driver_username; /*!< водитель-пайщик */
|
||||
eosio::name source_braname; /*!< КУ отправителя */
|
||||
eosio::name destination_braname; /*!< КУ назначения (может быть промежуточный) */
|
||||
eosio::name status; /*!< статус перевозки */
|
||||
|
||||
std::vector<checksum256> request_hashes; /*!< массив хэшей заявок в перевозке */
|
||||
|
||||
std::vector<Document::named_document> documents; /*!< именованные документы перевозки */
|
||||
|
||||
eosio::time_point_sec created_at; /*!< время создания перевозки */
|
||||
eosio::time_point_sec loaded_at; /*!< время завершения загрузки */
|
||||
eosio::time_point_sec delivered_at; /*!< время доставки */
|
||||
eosio::time_point_sec completed_at; /*!< время завершения перевозки */
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
checksum256 by_hash() const { return hash; }
|
||||
uint64_t by_coop() const { return coopname.value; }
|
||||
uint64_t by_driver() const { return driver_username.value; }
|
||||
uint64_t by_source() const { return source_braname.value; }
|
||||
uint64_t by_destination() const { return destination_braname.value; }
|
||||
uint64_t by_status() const { return status.value; }
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"shipments"_n, shipment,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<shipment, checksum256, &shipment::by_hash>>,
|
||||
eosio::indexed_by<"bycoop"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_coop>>,
|
||||
eosio::indexed_by<"bydriver"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_driver>>,
|
||||
eosio::indexed_by<"bysource"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_source>>,
|
||||
eosio::indexed_by<"bydest"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_destination>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_status>>,
|
||||
eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<shipment, uint64_t, &shipment::by_created>>
|
||||
> shipments_index;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Таблица обменов для контракта "marketplace"
|
||||
* @ingroup public_tables
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(MARKETPLACE)]] request {
|
||||
uint64_t id; /*!< идентификатор обмена */
|
||||
checksum256 hash; /*!< хэш заявки */
|
||||
eosio::name coopname; /*!< имя аккаунта кооператива */
|
||||
eosio::name type; /*!< тип обмена: orderoffer или offerorder */
|
||||
eosio::name status; /*!< статус обмена */
|
||||
eosio::name username; /*!< имя аккаунта владельца заявки */
|
||||
eosio::name braname; /*!< имя кооперативного участка */
|
||||
eosio::name warehouse; /*!< имя КУ где хранится имущество */
|
||||
eosio::name token_contract; /*!< имя контракта токена */
|
||||
|
||||
eosio::name receiver_braname; /*!< КУ заказчика для получения товара */
|
||||
eosio::name supplier_braname; /*!< КУ поставщика для отправки товара */
|
||||
|
||||
eosio::asset unit_cost;/*!< себестоимость единицы товара от поставщика */
|
||||
eosio::asset base_cost; /*!< базовая стоимость заявки */
|
||||
eosio::asset membership_fee_amount; /*!< членский взнос заказчика */
|
||||
eosio::asset total_cost; /*!< общая сумма заявки */
|
||||
|
||||
uint64_t units; /*!< количество единиц товара */
|
||||
std::string meta; /*!< метаданные заявки */
|
||||
|
||||
eosio::name money_contributor; /*!< имя аккаунта, который вносит средства */
|
||||
eosio::name product_contributor; /*!< имя аккаунта, который передаёт товар */
|
||||
|
||||
std::vector<Document::named_document> documents; /*!< именованные документы заявки */
|
||||
|
||||
uint64_t product_lifecycle_secs; // жизненный цикл продукта
|
||||
uint64_t warranty_period_secs; // гарантийный срок в секундах
|
||||
eosio::asset cancellation_fee_amount; // сумма штрафа за отмену заявки
|
||||
|
||||
eosio::time_point_sec warranty_delay_until;
|
||||
eosio::time_point_sec deadline_for_receipt;
|
||||
|
||||
bool is_warranty_return = false;
|
||||
uint64_t warranty_return_id;
|
||||
|
||||
eosio::time_point_sec created_at;
|
||||
eosio::time_point_sec accepted_at;
|
||||
eosio::time_point_sec supplied_at;
|
||||
eosio::time_point_sec delivered_at;
|
||||
eosio::time_point_sec received_at;
|
||||
eosio::time_point_sec completed_at;
|
||||
eosio::time_point_sec declined_at;
|
||||
eosio::time_point_sec disputed_at;
|
||||
eosio::time_point_sec canceled_at;
|
||||
|
||||
|
||||
uint64_t primary_key() const { return id; }
|
||||
uint64_t by_coop() const {return coopname.value;}
|
||||
uint64_t by_status() const { return status.value; }
|
||||
uint64_t by_type() const { return type.value; }
|
||||
checksum256 by_hash() const { return hash; }
|
||||
uint64_t by_username() const { return username.value;}
|
||||
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch();}
|
||||
uint64_t by_completed() const { return completed_at.sec_since_epoch();}
|
||||
uint64_t by_declined() const { return declined_at.sec_since_epoch();}
|
||||
uint64_t by_canceled() const { return canceled_at.sec_since_epoch();}
|
||||
uint64_t by_warranty_id() const { return warranty_return_id;}
|
||||
|
||||
// Логические геттеры для получения актуальных ролей
|
||||
eosio::name get_money_contributor() const {
|
||||
return is_warranty_return ? product_contributor : money_contributor;
|
||||
}
|
||||
|
||||
eosio::name get_product_contributor() const {
|
||||
return is_warranty_return ? money_contributor : product_contributor;
|
||||
}
|
||||
|
||||
// Геттеры для понимания ролей в контексте текущей операции
|
||||
eosio::name get_payer() const {
|
||||
return get_money_contributor();
|
||||
}
|
||||
|
||||
eosio::name get_supplier() const {
|
||||
return get_product_contributor();
|
||||
}
|
||||
|
||||
// Специальные геттеры для гарантийного возврата
|
||||
// Возвращают участников в контексте процесса возврата брака
|
||||
|
||||
/**
|
||||
* @brief Получить пайщика, который возвращает товар в гарантийном возврате
|
||||
* Это тот, кто изначально получил товар и теперь возвращает его как брак
|
||||
*/
|
||||
eosio::name get_product_backer() const {
|
||||
return money_contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Получить поставщика брака в гарантийном возврате
|
||||
* Это тот, кто изначально поставил товар и теперь получает его обратно как брак
|
||||
*/
|
||||
eosio::name get_defective_supplier() const {
|
||||
return product_contributor;
|
||||
}
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"requests"_n, request,
|
||||
eosio::indexed_by<"bycoop"_n, eosio::const_mem_fun<request, uint64_t, &request::by_coop>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<request, uint64_t, &request::by_status>>,
|
||||
eosio::indexed_by<"bytype"_n, eosio::const_mem_fun<request, uint64_t, &request::by_type>>,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<request, checksum256, &request::by_hash>>,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<request, uint64_t, &request::by_username>>,
|
||||
eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<request, uint64_t, &request::by_created>>,
|
||||
eosio::indexed_by<"bycompleted"_n, eosio::const_mem_fun<request, uint64_t, &request::by_completed>>,
|
||||
eosio::indexed_by<"bydeclined"_n, eosio::const_mem_fun<request, uint64_t, &request::by_declined>>,
|
||||
eosio::indexed_by<"bycanceled"_n, eosio::const_mem_fun<request, uint64_t, &request::by_canceled>>,
|
||||
eosio::indexed_by<"bywarrantyid"_n, eosio::const_mem_fun<request, uint64_t, &request::by_warranty_id>>
|
||||
> requests_index;
|
||||
|
||||
static const std::set<eosio::name> marketplace_callback_actions = {
|
||||
"authoffs2c"_n, // авторизация сегмента contribute для направления OFFER → ORDER
|
||||
"authoffc2r"_n, // авторизация сегмента return для направления OFFER → ORDER
|
||||
"authordcont"_n, // авторизация сегмента contribute для направления ORDER → OFFER
|
||||
"authordret"_n, // авторизация сегмента return для направления ORDER → OFFER
|
||||
"declineacc"_n, // отклонение принятия заявки
|
||||
};
|
||||
|
||||
inline eosio::name get_valid_marketplace_action(const eosio::name& action) {
|
||||
eosio::check(marketplace_callback_actions.contains(action), "Недопустимое имя действия marketplace");
|
||||
return action;
|
||||
}
|
||||
|
||||
// Вспомогательные функции для поиска заявок по хэшу
|
||||
static std::optional<request> get_request_by_hash(eosio::name coopname, checksum256 request_hash) {
|
||||
requests_index requests(_marketplace, coopname.value);
|
||||
auto idx = requests.get_index<"byhash"_n>();
|
||||
auto req = idx.find(request_hash);
|
||||
|
||||
if (req != idx.end()) {
|
||||
return *req;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
// Вспомогательные функции для поиска перевозок по хэшу
|
||||
static std::optional<shipment> get_shipment_by_hash(eosio::name coopname, checksum256 shipment_hash) {
|
||||
shipments_index shipments(_marketplace, coopname.value);
|
||||
auto idx = shipments.get_index<"byhash"_n>();
|
||||
auto ship = idx.find(shipment_hash);
|
||||
|
||||
if (ship != idx.end()) {
|
||||
return *ship;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static request get_request_by_hash_or_fail(eosio::name coopname, checksum256 request_hash, const std::string& error_msg = "Заявка не найдена по хэшу") {
|
||||
auto request_opt = get_request_by_hash(coopname, request_hash);
|
||||
eosio::check(request_opt.has_value(), error_msg);
|
||||
return *request_opt;
|
||||
}
|
||||
|
||||
static shipment get_shipment_by_hash_or_fail(eosio::name coopname, checksum256 shipment_hash, const std::string& error_msg = "Перевозка не найдена по хэшу") {
|
||||
auto shipment_opt = get_shipment_by_hash(coopname, shipment_hash);
|
||||
eosio::check(shipment_opt.has_value(), error_msg);
|
||||
return *shipment_opt;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Константы для имен документов маркетплейса (максимум 12 символов)
|
||||
*/
|
||||
namespace DocumentNames {
|
||||
static constexpr const name RETURN_STMT = "returnstmt"_n; // заявление на возврат имущества
|
||||
static constexpr const name CONVERT_FROM = "convertfrom"_n; // заявление на конвертацию из кошелька
|
||||
static constexpr const name CONVERT_TO = "convertto"_n; // заявление на конвертацию в кошелек
|
||||
static constexpr const name CONTRIB_STMT = "contribstmt"_n; // заявление на имущественный паевой взнос
|
||||
static constexpr const name CONTRIB_AUTH = "contribauth"_n; // авторизация взноса
|
||||
static constexpr const name RETURN_AUTH = "returnauth"_n; // авторизация возврата
|
||||
static constexpr const name RECEIVE_ACT = "receiveact"_n; // акт получения
|
||||
static constexpr const name RECEIVE_ACT_CONF = "receiveconf"_n; // подтверждение акта получения
|
||||
static constexpr const name TRANSPORT1 = "transport1"_n; // акт транспортировки 1 (УСТАРЕВШИЙ)
|
||||
static constexpr const name TRANSPORT2 = "transport2"_n; // акт транспортировки 2 (УСТАРЕВШИЙ)
|
||||
static constexpr const name TRANSPORT3 = "transport3"_n; // акт транспортировки 3 (УСТАРЕВШИЙ)
|
||||
static constexpr const name TRANSPORT4 = "transport4"_n; // акт транспортировки 4 (УСТАРЕВШИЙ)
|
||||
static constexpr const name SUPPLY_ACT = "supplyact"_n; // акт поставки
|
||||
static constexpr const name SUPPLY_ACT_CONF = "supplyconf"_n; // подтверждение акта поставки
|
||||
static constexpr const name SHIPMENT_ACT = "shipmentact"_n; // товарно-транспортная накладная
|
||||
static constexpr const name DELIVERY_ACT = "deliveryact"_n; // акт доставки (УСТАРЕВШИЙ)
|
||||
|
||||
// Документы новой системы перевозок
|
||||
static constexpr const name SHIPMENT_SEND_ACT = "shsendact"_n; // акт передачи от отправителя
|
||||
static constexpr const name SHIPMENT_LOADING_ACT = "shloadact"_n; // акт приёма водителем
|
||||
static constexpr const name SHIPMENT_ARRIVE_ACT = "sharriveact"_n; // акт прибытия/доставки на склад, подписанный водителем
|
||||
static constexpr const name SHIPMENT_RECV_ACT = "shrecvact"_n; // акт приёма на складе получателем
|
||||
|
||||
// Документы гарантийного возврата
|
||||
static constexpr const name WDISPUTE = "wdispute"_n; // претензия на гарантийный возврат
|
||||
static constexpr const name WRETURN_AUTH = "wreturnauth"_n; // авторизация гарантийного возврата
|
||||
static constexpr const name WSUPPLY_AUTH = "wsupplyauth"_n; // авторизация гарантийной выдачи
|
||||
static constexpr const name WRETURN_ACT = "wreturnact"_n; // акт гарантийного возврата
|
||||
static constexpr const name WOFFER_ACT = "wofferact"_n; // акт предложения товара поставщику
|
||||
static constexpr const name WACCEPT_ACT = "wacceptact"_n; // акт принятия/отказа поставщика
|
||||
}
|
||||
|
||||
} // namespace Marketplace
|
||||
@@ -1,111 +0,0 @@
|
||||
namespace Core::Registrator {
|
||||
/**
|
||||
* @brief Получает аккаунт по имени пользователя
|
||||
* @param username Имя пользователя
|
||||
* @return account Найденный аккаунт
|
||||
* @throws check если аккаунт не найден
|
||||
*/
|
||||
inline account get_account_or_fail(eosio::name username) {
|
||||
accounts_index accounts(_registrator, _registrator.value);
|
||||
auto account_itr = accounts.find(username.value);
|
||||
eosio::check(account_itr != accounts.end(), "Аккаунт не найден");
|
||||
return *account_itr;
|
||||
}
|
||||
} // namespace Core::Registrator
|
||||
|
||||
namespace Registrator {
|
||||
|
||||
/**
|
||||
* @brief Структура кандидата на вступление (устаревшая версия).
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_registrator_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): candidates
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] candidate_legacy {
|
||||
eosio::name username; ///< Имя аккаунта пайщика
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
eosio::name braname; ///< Имя филиала
|
||||
name status; ///< Статус: created | payed
|
||||
eosio::time_point_sec created_at; ///< Время регистрации аккаунта
|
||||
document statement; ///< Заявление на вступление
|
||||
checksum256 registration_hash; ///< Идентификатор платежа регистрационного взноса
|
||||
eosio::asset initial; ///< Начальный взнос
|
||||
eosio::asset minimum; ///< Минимальный взнос
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
checksum256 by_hash() const { return registration_hash; } ///< Индекс по хэшу платежа
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"candidates"_n, candidate_legacy,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<candidate_legacy, checksum256, &candidate_legacy::by_hash>>
|
||||
> candidates_legacy_index;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Структура кандидата на вступление.
|
||||
* @ingroup public_tables
|
||||
* @ingroup public_registrator_tables
|
||||
|
||||
* @par Область памяти (scope): coopname
|
||||
* @par Имя таблицы (table): candidates2
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(REGISTRATOR)]] candidate {
|
||||
eosio::name username; ///< Имя аккаунта пайщика
|
||||
eosio::name coopname; ///< Имя кооператива
|
||||
eosio::name braname; ///< Имя филиала
|
||||
name status; ///< Статус: created | payed
|
||||
eosio::time_point_sec created_at; ///< Время регистрации аккаунта
|
||||
document2 statement; ///< Заявление на вступление
|
||||
checksum256 registration_hash; ///< Идентификатор платежа регистрационного взноса
|
||||
eosio::asset initial; ///< Начальный взнос
|
||||
eosio::asset minimum; ///< Минимальный взнос
|
||||
|
||||
uint64_t primary_key() const { return username.value; }
|
||||
checksum256 by_hash() const { return registration_hash; } ///< Индекс по хэшу платежа
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<"candidates2"_n, candidate,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<candidate, checksum256, &candidate::by_hash>>
|
||||
> candidates_index;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Получает кандидата по хэшу регистрации.
|
||||
* @param coopname Имя кооператива
|
||||
* @param hash Хэш регистрации
|
||||
* @return Опциональное значение кандидата или nullopt если не найден
|
||||
*/
|
||||
inline std::optional<candidate> get_candidate_by_hash(eosio::name coopname, const checksum256 &hash) {
|
||||
candidates_index primary_index(_registrator, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Получает количество активных пайщиков кооператива.
|
||||
* @param coopname Имя кооператива
|
||||
* @return uint64_t Количество активных пайщиков
|
||||
* @throws eosio::check_failure если счетчик пайщиков не найден
|
||||
*/
|
||||
inline uint64_t get_active_participants_count(eosio::name coopname) {
|
||||
using namespace eosio;
|
||||
|
||||
// Получаем информацию о кооперативе
|
||||
cooperatives2_index cooperatives(_registrator, _registrator.value);
|
||||
auto coop_itr = cooperatives.find(coopname.value);
|
||||
|
||||
if (coop_itr == cooperatives.end() || !coop_itr->is_cooperative || !coop_itr->active_participants_count.has_value()) {
|
||||
eosio::check(false, "Счетчик пайщиков кооператива не найден");
|
||||
}
|
||||
|
||||
return coop_itr->active_participants_count.value();
|
||||
}
|
||||
}
|
||||
@@ -1,264 +0,0 @@
|
||||
#define COMPLETEWTHD_SIGNATURE name coopname, checksum256 withdraw_hash
|
||||
#define DECLINEWTHD_SIGNATURE name coopname, checksum256 withdraw_hash, std::string reason
|
||||
|
||||
using completewthd_interface = void(COMPLETEWTHD_SIGNATURE);
|
||||
using declinewthd_interface = void(DECLINEWTHD_SIGNATURE);
|
||||
|
||||
// Сигнатура для авторизации действия с документом (использует общую из soviet)
|
||||
#define AUTHWTHD_SIGNATURE AUTHORIZE_CALLBACK_SIGNATURE
|
||||
using authwthd_interface = void(AUTHWTHD_SIGNATURE);
|
||||
|
||||
static const std::set<eosio::name> wallet_callback_actions = {
|
||||
"authwthd"_n, // авторизация возврата паевого взноса
|
||||
"declinewthd"_n, // отклонение возврата паевого взноса
|
||||
"completewthd"_n, // завершение возврата паевого взноса
|
||||
};
|
||||
|
||||
|
||||
|
||||
class Wallet {
|
||||
public:
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Таблица `deposits` отслеживает депозиты в контракте WALLET.
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(WALLET)]] deposit {
|
||||
uint64_t id; /*!< Уникальный идентификатор записи ввода */
|
||||
eosio::name coopname; /*!< Имя аккаунта кооператива, в контексте которого совершается депозит */
|
||||
eosio::name username; /*!< Имя аккаунта пользователя, совершившего ввод */
|
||||
checksum256 deposit_hash; ///< Хэш входящего платежа
|
||||
|
||||
eosio::asset quantity; /*!< Количество средств во внутренней валюте */
|
||||
eosio::name status; /*!< Статус ввода */
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point(); ///< Время истечения срока давности
|
||||
|
||||
uint64_t primary_key() const { return id; } /*!< Возвращает id как первичный ключ */
|
||||
uint64_t by_username() const { return username.value; } /*!< Индекс по имени пользователя */
|
||||
checksum256 by_hash() const { return deposit_hash; } /*!< Индекс по хэшу платежа */
|
||||
uint64_t by_status() const { return status.value; } /*!< Индекс по статусу вводу */
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"deposits"_n, deposit,
|
||||
eosio::indexed_by<"byhash"_n, eosio::const_mem_fun<deposit, checksum256, &deposit::by_hash>>,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<deposit, uint64_t, &deposit::by_username>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<deposit, uint64_t, &deposit::by_status>>,
|
||||
eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<deposit, uint64_t, &deposit::by_created>>
|
||||
> deposits_index;
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup public_tables
|
||||
* @brief Таблица `withdraws` отслеживает операции вывода средств в контракте WALLET.
|
||||
*/
|
||||
struct [[eosio::table, eosio::contract(WALLET)]] withdraw {
|
||||
uint64_t id; /*!< Уникальный идентификатор записи вывода */
|
||||
eosio::name username; /*!< Имя пользователя, осуществляющего вывод средств */
|
||||
eosio::name coopname; /*!< Имя аккаунта кооператива, в рамках которого осуществляется вывод */
|
||||
checksum256 withdraw_hash; /*!< Идентификатор возврата */
|
||||
eosio::name status; /*!< Статус операции вывода */
|
||||
|
||||
eosio::asset quantity; /*!< Количество средств для вывода во внутренней валюте */
|
||||
document2 statement; /*!< Заявление на возврат */
|
||||
document2 approved_statement; /*!< Предварительно-принятое заявление */
|
||||
document2 authorization; /*!< Решение совета */
|
||||
|
||||
eosio::time_point_sec created_at = current_time_point(); ///< Время истечения срока давности
|
||||
|
||||
uint64_t primary_key() const { return id; } /*!< Возвращает id как первичный ключ */
|
||||
checksum256 by_hash() const { return withdraw_hash; } ///< Индекс по хэшу задачи.
|
||||
uint64_t by_username() const { return username.value; } /*!< Индекс по имени пользователя */
|
||||
uint64_t by_status() const { return status.value; } /*!< Индекс по статусу операции вывода */
|
||||
uint64_t by_created() const { return created_at.sec_since_epoch(); }
|
||||
|
||||
};
|
||||
|
||||
typedef eosio::multi_index<
|
||||
"withdraws"_n, withdraw,
|
||||
eosio::indexed_by<"byusername"_n, eosio::const_mem_fun<withdraw, uint64_t, &withdraw::by_username>>,
|
||||
eosio::indexed_by<"byhash"_n, const_mem_fun<withdraw, checksum256, &withdraw::by_hash>>,
|
||||
eosio::indexed_by<"bystatus"_n, eosio::const_mem_fun<withdraw, uint64_t, &withdraw::by_status>>,
|
||||
eosio::indexed_by<"bycreated"_n, eosio::const_mem_fun<withdraw, uint64_t, &withdraw::by_created>>
|
||||
> withdraws_index; /*!< Мультииндекс для доступа и манипуляции данными таблицы `withdraws` */
|
||||
|
||||
|
||||
static eosio::name get_valid_wallet_action(const eosio::name& action) {
|
||||
eosio::check(wallet_callback_actions.contains(action), "Недопустимое имя действия wallet");
|
||||
return action;
|
||||
}
|
||||
|
||||
static void validate_asset(const eosio::asset& amount) {
|
||||
check(amount.symbol == _root_govern_symbol, "Неверный символ токена");
|
||||
check(amount.is_valid(), "Неверный актив");
|
||||
check(amount.amount >= 0, "Сумма должна быть неотрицательной");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Добавляет доступные средства на кошелёк пользователя
|
||||
*/
|
||||
static void add_available_funds(eosio::name contract, eosio::name coopname, eosio::name username, eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"addbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Уменьшает доступные средства на кошельке пользователя
|
||||
*/
|
||||
static void sub_available_funds(eosio::name contract, eosio::name coopname, eosio::name username, eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"subbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, false, memo)
|
||||
).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Добавляет заблокированные средства в баланс кошелька пользователя
|
||||
*/
|
||||
static void add_blocked_funds(eosio::name contract, eosio::name coopname, eosio::name username, eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"addbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"blockbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Уменьшает заблокированные средства кошелька пользователя
|
||||
*/
|
||||
static void sub_blocked_funds(eosio::name contract, eosio::name coopname, eosio::name username, eosio::asset amount, eosio::name program_type, std::string memo) {
|
||||
auto program = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
print("▶ Уменьшаем заблокированные средства кошелька пользователя: ", amount, " для пользователя: ", username);
|
||||
print("▶ Программа: ", program.id);
|
||||
print("▶ Доступно: ", program.available->amount);
|
||||
print("▶ Заблокированные средства: ", program.blocked->amount);
|
||||
print("▶ Сумма для уменьшения: ", amount.amount);
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"unblockbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"subbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, false, memo)
|
||||
).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Блокирует средства на кошельке пользователя
|
||||
*/
|
||||
static void block_funds(eosio::name contract, eosio::name coopname, eosio::name username, eosio::asset amount, eosio::name program_type, std::string memo){
|
||||
auto program = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"blockbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Разблокирует средства на кошельке пользователя
|
||||
*/
|
||||
static void unblock_funds(eosio::name contract, eosio::name coopname, eosio::name username, eosio::asset amount, eosio::name program_type, std::string memo){
|
||||
auto program = get_program_or_fail(coopname, get_program_id(program_type));
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"unblockbal"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Оплачивает членский взнос с кошелька пользователя
|
||||
*/
|
||||
static void pay_membership_fee(name contract, name coopname, name username, eosio::asset amount, uint64_t program_id, std::string memo) {
|
||||
auto program = get_program_or_fail(coopname, program_id);
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"addmemberfee"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Отменяет оплату членского взноса с кошелька пользователя
|
||||
*/
|
||||
static void unpay_membership_fee(name contract, name coopname, name username, eosio::asset amount, uint64_t program_id, std::string memo) {
|
||||
auto program = get_program_or_fail(coopname, program_id);
|
||||
|
||||
action(
|
||||
permission_level{ contract, "active"_n },
|
||||
_soviet,
|
||||
"submemberfee"_n,
|
||||
std::make_tuple(coopname, username, program.id, amount, memo)
|
||||
).send();
|
||||
|
||||
}
|
||||
|
||||
|
||||
static std::optional<deposit> get_deposit(eosio::name coopname, const checksum256 &hash) {
|
||||
deposits_index primary_index(_wallet, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief Получает возврат из кошелька по хэшу.
|
||||
* @param coopname Имя кооператива (scope таблицы).
|
||||
* @param hash Хэш возврата.
|
||||
* @return `std::optional<withdraw>` - найденное действие или `std::nullopt`, если его нет.
|
||||
*/
|
||||
static std::optional<withdraw> get_withdraw(eosio::name coopname, const checksum256 &hash) {
|
||||
withdraws_index primary_index(_wallet, coopname.value);
|
||||
auto secondary_index = primary_index.get_index<"byhash"_n>();
|
||||
|
||||
auto itr = secondary_index.find(hash);
|
||||
if (itr == secondary_index.end()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return *itr;
|
||||
};
|
||||
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
/**
|
||||
\defgroup public_loan Контракт LOAN
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
using namespace Marketplace;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#pragma once
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
#include "include/tables/tables.hpp"
|
||||
#include "include/structs/structs.hpp"
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <eosio/system.hpp>
|
||||
#include <eosio/time.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
/**
|
||||
\defgroup public_registrator Контракт REGISTRATOR
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <eosio/asset.hpp>
|
||||
#include <eosio/singleton.hpp>
|
||||
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <eosio.token/eosio.token.hpp>
|
||||
#include "../../../../lib/common.hpp"
|
||||
#include "../../../../lib/index.hpp"
|
||||
|
||||
namespace eosio {
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <eosio/eosio.hpp>
|
||||
#include <eosio/asset.hpp>
|
||||
#include "../lib/common.hpp"
|
||||
#include "../lib/index.hpp"
|
||||
|
||||
using namespace eosio;
|
||||
using std::string;
|
||||
|
||||
Reference in New Issue
Block a user