From 1472ec01d051262b9a3c4fda27e8b16d0da9322b Mon Sep 17 00:00:00 2001 From: K-Dimentional Tree Date: Wed, 10 Sep 2025 09:54:51 +0300 Subject: [PATCH 01/10] WIP # Conflicts: # ton-http-api/src/core/tonlib_worker.cpp # ton-http-api/tonlib_postprocessor.cpp # ton-http-api/tonlib_worker.h --- ton-http-api/CMakeLists.txt | 64 +- ton-http-api/cache.cpp | 34 - ton-http-api/cache.hpp | 73 - ton-http-api/handler_api_v2.cpp | 708 ---- ton-http-api/handler_api_v2.h | 29 - ton-http-api/openapi/openapi.json | 2387 ----------- ton-http-api/openapi/openapi_page.hpp | 2434 ------------ ton-http-api/openapi/openapi_page.hpp.in | 11 - ton-http-api/request.hpp | 80 - ton-http-api/schemas/v2.json | 222 ++ .../{ => src/components}/tonlib_component.cpp | 6 +- .../{ => src/components}/tonlib_component.h | 18 +- ton-http-api/src/converters/convert.hpp | 27 + ton-http-api/src/core/tlb/tokens-tlb.cpp | 3486 +++++++++++++++++ ton-http-api/src/core/tlb/tokens-tlb.h | 1291 ++++++ ton-http-api/{ => src/core}/tonlib_worker.cpp | 843 ++-- ton-http-api/src/core/tonlib_worker.h | 238 ++ ton-http-api/src/core/types.hpp | 121 + .../handlers/HandlerGetMasterchainInfo.cpp | 20 + .../src/handlers/HandlerGetMasterchainInfo.h | 16 + .../src/handlers/JsonRpcMiddleware.hpp | 23 + .../src/handlers/TonlibRequestHandler.cpp | 34 + .../src/handlers/TonlibRequestHandler.h | 21 + ton-http-api/{ => src}/main.cpp | 23 +- ton-http-api/src/schemas/v2.cpp | 366 ++ ton-http-api/src/schemas/v2.hpp | 296 ++ ton-http-api/src/schemas/v2_fwd.hpp | 30 + ton-http-api/src/schemas/v2_parsers.ipp | 284 ++ .../chaotic/io/ton_http/types/shard_id.cpp | 15 + .../chaotic/io/ton_http/types/shard_id.hpp | 21 + .../chaotic/io/ton_http/types/ton_addr.hpp | 2 + .../chaotic/io/ton_http/types/ton_hash.cpp | 35 + .../chaotic/io/ton_http/types/ton_hash.hpp | 23 + .../{utils.cpp => src/utils/common.cpp} | 4 +- .../{utils.hpp => src/utils/common.hpp} | 41 - ton-http-api/src/utils/exceptions.hpp | 10 + ton-http-api/static/favicon.ico | Bin 0 -> 111201 bytes .../openapi.html => static/index.html} | 5 +- ton-http-api/static/openapi.json | 283 ++ ton-http-api/tonlib_postprocessor.cpp | 493 --- ton-http-api/tonlib_postprocessor.h | 20 - ton-http-api/tonlib_worker.h | 370 -- tonlib-multiclient/session.h | 4 +- 43 files changed, 7210 insertions(+), 7301 deletions(-) delete mode 100644 ton-http-api/cache.cpp delete mode 100644 ton-http-api/cache.hpp delete mode 100644 ton-http-api/handler_api_v2.cpp delete mode 100644 ton-http-api/handler_api_v2.h delete mode 100644 ton-http-api/openapi/openapi.json delete mode 100644 ton-http-api/openapi/openapi_page.hpp delete mode 100644 ton-http-api/openapi/openapi_page.hpp.in delete mode 100644 ton-http-api/request.hpp create mode 100644 ton-http-api/schemas/v2.json rename ton-http-api/{ => src/components}/tonlib_component.cpp (94%) rename ton-http-api/{ => src/components}/tonlib_component.h (75%) create mode 100644 ton-http-api/src/converters/convert.hpp create mode 100644 ton-http-api/src/core/tlb/tokens-tlb.cpp create mode 100644 ton-http-api/src/core/tlb/tokens-tlb.h rename ton-http-api/{ => src/core}/tonlib_worker.cpp (65%) create mode 100644 ton-http-api/src/core/tonlib_worker.h create mode 100644 ton-http-api/src/core/types.hpp create mode 100644 ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp create mode 100644 ton-http-api/src/handlers/HandlerGetMasterchainInfo.h create mode 100644 ton-http-api/src/handlers/JsonRpcMiddleware.hpp create mode 100644 ton-http-api/src/handlers/TonlibRequestHandler.cpp create mode 100644 ton-http-api/src/handlers/TonlibRequestHandler.h rename ton-http-api/{ => src}/main.cpp (66%) create mode 100644 ton-http-api/src/schemas/v2.cpp create mode 100644 ton-http-api/src/schemas/v2.hpp create mode 100644 ton-http-api/src/schemas/v2_fwd.hpp create mode 100644 ton-http-api/src/schemas/v2_parsers.ipp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.hpp rename ton-http-api/{utils.cpp => src/utils/common.cpp} (99%) rename ton-http-api/{utils.hpp => src/utils/common.hpp} (65%) create mode 100644 ton-http-api/src/utils/exceptions.hpp create mode 100644 ton-http-api/static/favicon.ico rename ton-http-api/{openapi/openapi.html => static/index.html} (88%) create mode 100644 ton-http-api/static/openapi.json delete mode 100644 ton-http-api/tonlib_postprocessor.cpp delete mode 100644 ton-http-api/tonlib_postprocessor.h delete mode 100644 ton-http-api/tonlib_worker.h diff --git a/ton-http-api/CMakeLists.txt b/ton-http-api/CMakeLists.txt index bb6d1a0..007f24c 100644 --- a/ton-http-api/CMakeLists.txt +++ b/ton-http-api/CMakeLists.txt @@ -1,55 +1,59 @@ cmake_minimum_required(VERSION 3.16) project(ton-http-api-cpp CXX) -userver_setup_environment() -file(READ openapi/openapi.html OPENAPI_HTML_CONTENT) -file(READ openapi/openapi.json OPENAPI_JSON_CONTENT) -configure_file(openapi/openapi_page.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/openapi/openapi_page.hpp @ONLY) +userver_setup_environment() set(TON_HTTP_API_CPP_SOURCE - main.cpp - tonlib_component.cpp - tonlib_component.h - tonlib_worker.cpp - tonlib_worker.h - handler_api_v2.cpp - handler_api_v2.h - tonlib_postprocessor.cpp - utils.cpp - tokens-tlb.cpp - cache.cpp - request.hpp + src/main.cpp + src/userver/chaotic/io/ton_http/types/ton_hash.cpp + src/userver/chaotic/io/ton_http/types/shard_id.cpp + src/handlers/HandlerGetMasterchainInfo.cpp + src/handlers/TonlibRequestHandler.cpp + src/components/tonlib_component.cpp + src/schemas/v2.cpp + src/converters/convert.hpp + src/core/types.hpp + src/core/tonlib_worker.cpp + src/core/tlb/tokens-tlb.cpp + src/utils/common.cpp ) - -# generate tokens schemas set(TLB_TOKENS - ${CMAKE_CURRENT_SOURCE_DIR}/tokens-tlb.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/tokens-tlb.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/core/tlb/tokens-tlb.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/core/tlb/tokens-tlb.h ) add_custom_command( - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND tlbc -o tokens-tlb -n tokens::gen -z tlb/tokens.tlb + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/core/tlb/ + COMMAND tlbc -o tokens-tlb -n tokens::gen -z ${CMAKE_CURRENT_SOURCE_DIR}/tlb/tokens.tlb COMMENT "Generate tokes tlb source files" OUTPUT ${TLB_TOKENS} - DEPENDS tlbc tlb/tokens.tlb + DEPENDS tlbc ${CMAKE_CURRENT_SOURCE_DIR}/tlb/tokens.tlb +) +add_custom_target(${PROJECT_NAME}-tlbgen DEPENDS ${TLB_TOKENS}) + +file(GLOB_RECURSE API_SCHEMAS ${CMAKE_CURRENT_SOURCE_DIR}/schemas/v2.json) +userver_target_generate_chaotic( + ${PROJECT_NAME}-chgen + GENERATE_SERIALIZERS + LAYOUT "/components/schemas/([^/]*)/=ton_http::schemas::{stem}::{0}" + OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/ + SCHEMAS ${API_SCHEMAS} + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src + RELATIVE_TO ${CMAKE_CURRENT_SOURCE_DIR}/ ) - -add_custom_target(tlb_generate_tokens DEPENDS ${TLB_TOKENS}) add_executable(${PROJECT_NAME} ${TON_HTTP_API_CPP_SOURCE}) target_include_directories(${PROJECT_NAME} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../external/userver PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../external/ton - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/.. ) -add_dependencies(${PROJECT_NAME} tlb_generate_tokens userver::chaotic) - - +add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-tlbgen ${PROJECT_NAME}-chgen) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) target_link_libraries(${PROJECT_NAME} userver::core tonlib::multiclient) -target_link_options(ton-http-api-cpp PUBLIC -rdynamic) +target_link_options(${PROJECT_NAME} PUBLIC -rdynamic) install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) diff --git a/ton-http-api/cache.cpp b/ton-http-api/cache.cpp deleted file mode 100644 index bd04b33..0000000 --- a/ton-http-api/cache.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "cache.hpp" - -#include "userver/cache/lru_cache_component_base.hpp" -#include "userver/components/component_context.hpp" -#include "userver/components/statistics_storage.hpp" -#include "userver/yaml_config/merge_schemas.hpp" - - -userver::yaml_config::Schema ton_http::cache::impl::GetExpirableLruCacheStaticConfigSchema() { - return userver::yaml_config::MergeSchemas(R"( -type: object -description: Expirable LRU-cache component -additionalProperties: false -properties: - size: - type: integer - description: max amount of items to store in cache - ways: - type: integer - description: number of ways for associative cache - lifetime: - type: string - description: TTL for cache entries (0 is unlimited) - defaultDescription: 0 - background-update: - type: boolean - description: enables asynchronous updates for expiring values - defaultDescription: false - config-settings: - type: boolean - description: enables dynamic reconfiguration with CacheConfigSet - defaultDescription: true -)"); -} \ No newline at end of file diff --git a/ton-http-api/cache.hpp b/ton-http-api/cache.hpp deleted file mode 100644 index 68d5260..0000000 --- a/ton-http-api/cache.hpp +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include - -#include "request.hpp" -#include "userver/cache/expirable_lru_cache.hpp" -#include "userver/components/component_base.hpp" -#include "userver/components/component_context.hpp" -#include "userver/components/statistics_storage.hpp" -#include "userver/utils/statistics/entry.hpp" -#include "userver/yaml_config/schema.hpp" - - -namespace ton_http::cache { - -namespace impl { -userver::yaml_config::Schema GetExpirableLruCacheStaticConfigSchema(); -} - -// clang-format on -template , typename Equal = std::equal_to> -// NOLINTNEXTLINE(fuchsia-multiple-inheritance) -class ExpirableLruCacheComponent : public userver::components::ComponentBase { -public: - using Cache = userver::cache::ExpirableLruCache; - - ExpirableLruCacheComponent(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context) - : ComponentBase(config, context), name_(userver::components::GetCurrentComponentName(context)), - static_config_(config), cache_(std::make_shared(static_config_.ways, static_config_.GetWaySize())) { - cache_->SetMaxLifetime(static_config_.config.lifetime); - cache_->SetBackgroundUpdate(static_config_.config.background_update); - - statistics_holder_ = context.FindComponent().GetStorage().RegisterWriter( - "cache", [this](userver::utils::statistics::Writer& writer) { - writer = *cache_; - }, {{"cache_name", name_}}); - } - ~ExpirableLruCacheComponent() { - statistics_holder_.Unregister(); - } - - static userver::yaml_config::Schema GetStaticConfigSchema() { - return impl::GetExpirableLruCacheStaticConfigSchema(); - } - - std::optional Get(const Key& key) { - return cache_->GetOptionalNoUpdate(key); - } - void Put(const Key& key, const Value& value) { - return cache_->Put(key, value); - } -private: - const std::string name_; - const userver::cache::LruCacheConfigStatic static_config_; - const std::shared_ptr cache_; - - userver::utils::statistics::Entry statistics_holder_; -}; - -class CacheApiV2Component final : public ExpirableLruCacheComponent { -public: - static constexpr std::string_view kName = "cache-api-v2"; - CacheApiV2Component(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context) - : ExpirableLruCacheComponent(config, context) {}; -}; - -class ConstCacheApiV2Component final : public ExpirableLruCacheComponent { -public: - static constexpr std::string_view kName = "const-cache-api-v2"; - ConstCacheApiV2Component(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context) - : ExpirableLruCacheComponent(config, context) {}; -}; -// clang-format off -} diff --git a/ton-http-api/handler_api_v2.cpp b/ton-http-api/handler_api_v2.cpp deleted file mode 100644 index bf75a3b..0000000 --- a/ton-http-api/handler_api_v2.cpp +++ /dev/null @@ -1,708 +0,0 @@ -#include "handler_api_v2.h" - -#include - -#include "auto/tl/tonlib_api.h" -#include "auto/tl/tonlib_api_json.h" -#include "http/http.h" -#include "openapi/openapi_page.hpp" -#include "td/utils/JsonBuilder.h" -#include "tl/tl_json.h" -#include "userver/cache/expirable_lru_cache.hpp" -#include "userver/cache/lru_cache_component_base.hpp" -#include "userver/components/component_context.hpp" -#include "userver/http/common_headers.hpp" -#include "userver/logging/component.hpp" -#include "userver/logging/log.hpp" -#include "utils.hpp" - -namespace ton_http::handlers { -userver::formats::json::Value ApiV2Handler::build_json_response(const core::TonlibWorkerResponse& res) const { - userver::formats::json::ValueBuilder response; - response["ok"] = res.is_ok; - if (res.is_ok) { - if (res.result) { - response["result"] = userver::formats::json::FromString(td::json_encode(td::ToJson(res.result))); - } else if (res.result_str.has_value()) { - try { - response["result"] = userver::formats::json::FromString(res.result_str.value()); - } catch (const std::exception& e) { - LOG_DEBUG_TO(*logger_) << "Failed to parse result_str: " << e.what() << " value: " << res.result_str.value(); - response["result"] = res.result_str.value(); - } - } else { - response["ok"] = false; - response["error"] = "empty response"; - } - } else { - response["error"] = res.error->message().str(); - if (auto code = res.error->code(); code) { - response["code"] = code; - } - } - if (res.session) { - response["@extra"] = res.session->to_string(); - } - return response.ExtractValue(); -} -void ApiV2Handler::log_request( - const userver::server::http::HttpRequest& request, - const TonlibApiRequest& req, - const core::TonlibWorkerResponse& res, - const std::string& response_body -) const { - userver::logging::LogExtra log_extra; - log_extra.Extend("http_method", req.http_method); - log_extra.Extend("ton_api_method", req.ton_api_method); - log_extra.Extend("url", request.GetUrl()); - - auto code = res.is_ok ? 200 : res.error->code(); - if (code == 0) { - code = 500; - } - if (code == -3) { - code = 500; - } - - log_extra.Extend("status_code", res.is_ok ? 200 : res.error->code()); - log_extra.Extend("status_code_fixed", code); - if (is_log_required(req, res)) { - userver::formats::json::ValueBuilder request_params; - for (auto& [k, v] : req.args) { - std::stringstream ss; - bool is_first = true; - for (auto& i : v) { - if (is_first) { - is_first = false; - } else { - ss << ","; - } - ss << i; - } - request_params[k] = ss.str(); - } - log_extra.Extend("request_params", ToString(request_params.ExtractValue())); - log_extra.Extend("response", response_body); - log_extra.Extend("body", request.RequestBody()); - LOG_WARNING_TO(*logger_) << log_extra; - } else { - LOG_INFO_TO(*logger_) << log_extra; - } -} - -std::vector ApiV2Handler::parse_request_body_item(const userver::formats::json::Value& value, int parse_array_depth) const { - if (value.IsArray()) { - if (parse_array_depth == 0) { - return {ToString(value)}; - } - std::vector result; - for (auto item = value.begin(); item != value.end(); ++item) { - auto loc = parse_request_body_item(*item, std::max(parse_array_depth - 1, 0)); - result.push_back(loc[0]); - } - return result; - } - if (value.IsObject()) { - return {ToString(value)}; - } - if (value.IsString()) { - return {value.As()}; - } - if (value.IsInt()) { - return {std::to_string(value.As())}; - } - if (value.IsBool()) { - return {std::to_string(value.As())}; - } - return {}; -} - - -std::string ApiV2Handler::HandleRequestThrow( - const userver::server::http::HttpRequest& request, userver::server::request::RequestContext& context -) const { - TonlibApiRequest req; - req.http_method = request.GetMethodStr(); - { - const auto& debug_request_header = request.GetHeader("X-Debug-Request"); - auto debug_request = utils::stringToBool(debug_request_header); - req.is_debug_request = debug_request.has_value() && debug_request.value(); - } - auto ton_api_method_case_sensitive = request.GetPathArg("ton_api_method"); - std::ranges::copy(std::views::transform(ton_api_method_case_sensitive, ::tolower), std::back_inserter(req.ton_api_method)); - for (auto& name : request.ArgNames()) { - req.SetArgVector(name, request.GetArgVector(name)); - } - if (!request.RequestBody().empty()) { - try { - auto body = userver::formats::json::FromString(request.RequestBody()); - for (auto it = body.begin(); it != body.end(); ++it) { - auto value = parse_request_body_item(*it, 1); - req.SetArgVector(it.GetName(), value); - // std::stringstream ss1; - // for (auto& i : value) { ss1 << i << ";"; } - // LOG_ERROR_TO(*logger_) << "arg: " << it.GetName() << " size: " << value.size() << " value: " << ss1.str(); - } - } catch (const userver::formats::json::ParseException& e) { - request.GetHttpResponse().SetContentType(userver::http::content_type::kApplicationJson); - auto response = userver::formats::json::ValueBuilder(); - response["ok"] = false; - response["code"] = 422; - response["error"] = e.what(); - return userver::formats::json::ToString(response.ExtractValue()); - } - } - - // handle request - if (req.ton_api_method == "index.html" || req.ton_api_method.empty()) { - request.GetHttpResponse().SetHeader(userver::http::headers::kContentType, "text/html; charset=utf-8"); - return openapi::GetOpenApiPage(); - } - if (req.ton_api_method == "openapi.json") { - request.GetHttpResponse().SetContentType(userver::http::content_type::kApplicationJson); - return openapi::GetOpenApiJson(); - } - - if (req.ton_api_method == "jsonrpc") { - TonlibApiRequest jsonrpc_req; - jsonrpc_req.http_method = req.http_method; - auto api_method_case_sensitive = req.GetArg("method"); - std::ranges::copy(std::views::transform(api_method_case_sensitive, ::tolower), std::back_inserter(jsonrpc_req.ton_api_method)); - - auto body = userver::formats::json::FromString(req.GetArg("params")); - for (auto it = body.begin(); it != body.end(); ++it) { - auto value = parse_request_body_item(*it, 1); - jsonrpc_req.SetArgVector(it.GetName(), value); - // std::stringstream ss1; - // for (auto& i : value) { ss1 << i << ";"; } - // LOG_ERROR_TO(*logger_) << "arg: " << it.GetName() << " size: " << value.size() << " value: " << ss1.str(); - } - req = std::move(jsonrpc_req); - } - - // call method - userver::formats::json::Value response; - auto cached_response = cache_component_.Get(req); - if (cached_response.has_value()) { - response = std::move(cached_response.value()); - auto response_builder = userver::formats::json::ValueBuilder(response); - response_builder["@extra"] = response["@extra"].As("") + ":c"; - auto response_str = userver::formats::json::ToString(response_builder.ExtractValue()); - request.GetHttpResponse().SetContentType(userver::http::content_type::kApplicationJson); - request.GetHttpResponse().SetStatus(userver::server::http::HttpStatus::kOk); - return response_str; - } - auto res = HandleTonlibRequest(req); - - // prepare response - request.GetHttpResponse().SetContentType(userver::http::content_type::kApplicationJson); - auto code = res.is_ok ? 200 : res.error->code(); - if (code == 0) { code = 500; } - if (code == -3) { code = 500; } - request.GetHttpResponse().SetStatus(static_cast(code)); - response = build_json_response(res); - auto response_str = userver::formats::json::ToString(response); - log_request(request, req, res, response_str); - if (res.is_ok && res.cache_ttl > 0) { - cache_component_.Put(req, response); - } - return response_str; -} -ApiV2Handler::ApiV2Handler( - const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context -) : - HttpHandlerBase(config, context), - tonlib_component_(context.FindComponent()), - cache_component_(context.FindComponent()), - logger_(context.FindComponent().GetLogger("api-v2")) { -} -core::TonlibWorkerResponse ApiV2Handler::HandleTonlibRequest(const TonlibApiRequest& request) const { - std::string ton_api_method; - std::ranges::copy(std::views::transform(request.ton_api_method, ::tolower), std::back_inserter(ton_api_method)); - - if (ton_api_method == "getaddressinformation") { - auto address = request.GetArg("address"); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getAddressInformation, address, seqno, nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getAddressInformation, address, std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getextendedaddressinformation") { - auto address = request.GetArg("address"); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getExtendedAddressInformation, address, seqno, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getwalletinformation") { - auto address = request.GetArg("address"); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getAddressInformation, address, seqno, nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getWalletInformation, address, std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getaddressbalance") { - auto address = request.GetArg("address"); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getAddressInformation, address, seqno, nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getAddressBalance, address, std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getaddressstate") { - auto address = request.GetArg("address"); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getAddressInformation, address, seqno, nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getAddressState, address, std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "detectaddress") { - auto address = request.GetArg("address"); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::detectAddress, address, nullptr); - if (res.is_error()) { - auto error = res.move_as_error(); - return core::TonlibWorkerResponse::from_error_string(error.to_string(), error.code(), std::move(session)); - } - auto res_str = res.move_as_ok().to_json_string(); - return core::TonlibWorkerResponse::from_result_string(res_str, std::move(session)).Cachable(); - } - - if (ton_api_method == "gettokendata") { - auto address = request.GetArg("address"); - auto skip_verification = utils::stringToBool(request.GetArg("skip_verification")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto archival = utils::stringToBool(request.GetArg("archival")); - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - if (!skip_verification.has_value()) { - skip_verification = false; - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getTokenData, address, skip_verification.value(), seqno, archival, nullptr); - if (res.is_error()) { - auto error = res.move_as_error(); - return core::TonlibWorkerResponse::from_error_string(error.to_string(), error.code(), std::move(session)); - } - auto res_str = res.move_as_ok()->to_json_string(); - return core::TonlibWorkerResponse::from_result_string(res_str, std::move(session)).Cachable(); - } - - if (ton_api_method == "detecthash") { - auto hash = request.GetArg("hash"); - if (hash.empty()) { - return core::TonlibWorkerResponse::from_error_string("hash is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::detectHash, hash, nullptr); - if (res.is_error()) { - auto error = res.move_as_error(); - return core::TonlibWorkerResponse::from_error_string(error.to_string(), error.code(), std::move(session)); - } - auto res_str = res.move_as_ok().to_json_string(); - return core::TonlibWorkerResponse::from_result_string(res_str, std::move(session)).Cachable(); - } - - if (ton_api_method == "getmasterchaininfo") { - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getMasterchainInfo, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - if (ton_api_method == "getconsensusblock") { - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getConsensusBlock, nullptr); - if (res.is_error()) { - auto error = res.move_as_error(); - return core::TonlibWorkerResponse::from_error_string(error.to_string(), error.code(), std::move(session)); - } - auto res_str = res.move_as_ok().to_json_string(); - return core::TonlibWorkerResponse::from_result_string(res_str, std::move(session)).Cachable(); - } - - if (ton_api_method == "getmasterchainblocksignatures") { - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (!seqno.has_value()) { - return core::TonlibWorkerResponse::from_error_string("seqno is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getMasterchainBlockSignatures, seqno.value(), nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getshardblockproof") { - auto workchain = utils::stringToInt(request.GetArg("workchain")); - auto shard = utils::stringToInt(request.GetArg("shard")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto from_seqno = utils::stringToInt(request.GetArg("from_seqno")); - - if (!workchain.has_value()) { - return core::TonlibWorkerResponse::from_error_string("workchain is required", 422, nullptr); - } - if (!shard.has_value()) { - return core::TonlibWorkerResponse::from_error_string("shard is required", 422, nullptr); - } - if (!seqno.has_value()) { - return core::TonlibWorkerResponse::from_error_string("seqno is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getShardBlockProof, - workchain.value(), shard.value(), seqno.value(), from_seqno, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "lookupblock") { - auto workchain = utils::stringToInt(request.GetArg("workchain")); - auto shard = utils::stringToInt(request.GetArg("shard")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto lt = utils::stringToInt(request.GetArg("lt")); - auto unixtime = utils::stringToInt(request.GetArg("unixtime")); - - if (!workchain.has_value()) { - return core::TonlibWorkerResponse::from_error_string("workchain is required", 422, nullptr); - } - if (!shard.has_value()) { - return core::TonlibWorkerResponse::from_error_string("shard is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::lookupBlock, - workchain.value(), shard.value(), seqno, lt, unixtime, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getshards" || ton_api_method == "shards") { - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto lt = utils::stringToInt(request.GetArg("lt")); - auto unixtime = utils::stringToInt(request.GetArg("unixtime")); - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getShards, seqno, lt, unixtime, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getblockheader") { - auto workchain = utils::stringToInt(request.GetArg("workchain")); - auto shard = utils::stringToInt(request.GetArg("shard")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto root_hash = utils::stringToHash(request.GetArg("root_hash")); - auto file_hash = utils::stringToHash(request.GetArg("file_hash")); - - if (!workchain.has_value()) { - return core::TonlibWorkerResponse::from_error_string("workchain is required", 422, nullptr); - } - if (!shard.has_value()) { - return core::TonlibWorkerResponse::from_error_string("shard is required", 422, nullptr); - } - if (!seqno.has_value()) { - return core::TonlibWorkerResponse::from_error_string("seqno is required", 422, nullptr); - } - if (!root_hash.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse root_hash", 422, nullptr); - } - if (!file_hash.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse file_hash", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getBlockHeader, - workchain.value(), shard.value(), seqno.value(), root_hash.value(), file_hash.value(), nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getoutmsgqueuesizes") { - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getOutMsgQueueSizes, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "lookupblock") { - auto workchain = utils::stringToInt(request.GetArg("workchain")); - auto shard = utils::stringToInt(request.GetArg("shard")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto lt = utils::stringToInt(request.GetArg("lt")); - auto unixtime = utils::stringToInt(request.GetArg("unixtime")); - - if (!workchain.has_value()) { - return core::TonlibWorkerResponse::from_error_string("workchain is required", 422, nullptr); - } - if (!shard.has_value()) { - return core::TonlibWorkerResponse::from_error_string("shard is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::lookupBlock, - workchain.value(), shard.value(), seqno, lt, unixtime, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getblocktransactions" || ton_api_method == "getblocktransactionsext") { - auto workchain = utils::stringToInt(request.GetArg("workchain")); - auto shard = utils::stringToInt(request.GetArg("shard")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto root_hash = utils::stringToHash(request.GetArg("root_hash")); - auto file_hash = utils::stringToHash(request.GetArg("file_hash")); - auto after_lt = utils::stringToInt(request.GetArg("after_lt")); - auto after_hash = utils::stringToHash(request.GetArg("after_hash")); - auto count = utils::stringToInt(request.GetArg("count")); - - if (!workchain.has_value()) { - return core::TonlibWorkerResponse::from_error_string("workchain is required", 422, nullptr); - } - if (!shard.has_value()) { - return core::TonlibWorkerResponse::from_error_string("shard is required", 422, nullptr); - } - if (!seqno.has_value()) { - return core::TonlibWorkerResponse::from_error_string("seqno is required", 422, nullptr); - } - if (!root_hash.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse root_hash", 422, nullptr); - } - if (!file_hash.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse file_hash", 422, nullptr); - } - if (!after_hash.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse after_hash", 422, nullptr); - } - if (!count.has_value()) { - count = 40; - } - std::optional archival = std::nullopt; - if (ton_api_method == "getblocktransactions") { - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getBlockTransactions, - workchain.value(), shard.value(), seqno.value(), count.value(), root_hash.value(), file_hash.value(), after_lt, after_hash.value(), archival, nullptr); - - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getBlockTransactions, std::move(res), std::move(session)); - } else if (ton_api_method == "getblocktransactionsext") { - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getBlockTransactionsExt, - workchain.value(), shard.value(), seqno.value(), count.value(), root_hash.value(), file_hash.value(), after_lt, after_hash.value(), archival, nullptr); - - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getBlockTransactionsExt, std::move(res), std::move(session)).Cachable(); - } - } - - if (ton_api_method == "gettransactions" || ton_api_method == "gettransactionsv2") { - auto address = request.GetArg("address"); - auto limit = utils::stringToInt(request.GetArg("limit")); - auto count = utils::stringToInt(request.GetArg("count")); - auto chunk_size = utils::stringToInt(request.GetArg("chunk_size")); - auto from_transaction_lt = utils::stringToInt(request.GetArg("lt")); - auto from_transaction_hash = utils::stringToHash(request.GetArg("hash")); - auto to_transaction_lt = utils::stringToInt(request.GetArg("to_lt")); - auto archival = utils::stringToBool(request.GetArg("archival")); - bool try_decode_messages = true; - - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("address is required", 422, nullptr); - } - if (!from_transaction_hash.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse from_transaction_hash", 422, nullptr); - } - - - if (limit.has_value()) { - count = limit.value(); - } - if (!count.has_value()) { - count = 10; - } - if (!to_transaction_lt.has_value()) { - to_transaction_lt = 0; - } - if (!chunk_size.has_value()) { - chunk_size = 30; - } - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getTransactions, - address, - from_transaction_lt, - from_transaction_hash.value(), - to_transaction_lt.value(), - count.value(), - chunk_size.value(), - try_decode_messages, - archival, - nullptr - ); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getTransactions, std::move(res), ton_api_method == "gettransactionsv2", false, std::move(session)).Cachable(); - } - - if (ton_api_method == "trylocatetx" || ton_api_method == "trylocateresulttx") { - auto source = request.GetArg("source"); - auto destination = request.GetArg("destination"); - auto created_lt = utils::stringToInt(request.GetArg("created_lt")); - - if (source.empty()) { - return core::TonlibWorkerResponse::from_error_string("source is required", 422, nullptr); - } - if (destination.empty()) { - return core::TonlibWorkerResponse::from_error_string("destination is required", 422, nullptr); - } - if (!created_lt.has_value()) { - return core::TonlibWorkerResponse::from_error_string("created_lt is required", 422, nullptr); - } - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::tryLocateTransactionByIncomingMessage, source, destination, created_lt.value(), nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getTransactions, std::move(res), false, true, std::move(session)).Cachable(); - } - if (ton_api_method == "trylocatesourcetx") { - auto source = request.GetArg("source"); - auto destination = request.GetArg("destination"); - auto created_lt = utils::stringToInt(request.GetArg("created_lt")); - - if (source.empty()) { - return core::TonlibWorkerResponse::from_error_string("source is required", 422, nullptr); - } - if (destination.empty()) { - return core::TonlibWorkerResponse::from_error_string("destination is required", 422, nullptr); - } - if (!created_lt.has_value()) { - return core::TonlibWorkerResponse::from_error_string("created_lt is required", 422, nullptr); - } - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::tryLocateTransactionByOutgoingMessage, source, destination, created_lt.value(), nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_getTransactions, std::move(res), false, true, std::move(session)).Cachable(); - } - - if (ton_api_method == "getconfigparam") { - auto config_id = utils::stringToInt(request.GetArg("config_id")); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - if (!config_id.has_value()) { - return core::TonlibWorkerResponse::from_error_string("config_id is required", 422, nullptr); - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getConfigParam, config_id.value(), seqno, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - if (ton_api_method == "getconfigall") { - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getConfigAll, seqno, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "getlibraries") { - std::vector libs; - - std::stringstream ss; - for (auto &l : request.GetArgVector("libraries")) { - auto lib = utils::stringToHash(l); - if (!lib.has_value()) { - return core::TonlibWorkerResponse::from_error_string("failed to parse library", 422, nullptr); - } - ss << lib.value() << ";"; - libs.push_back(std::move(lib.value())); - } - // LOG_ERROR_TO(*logger_) << "getlibraries: " << libs; - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::getLibraries, libs, nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - if (ton_api_method == "sendboc") { - auto boc = request.GetArg("boc"); - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::raw_sendMessage, boc, nullptr); - if (res.is_ok()) { - tonlib_component_.SendBocToExternalRequest(boc); - } - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - if (ton_api_method == "sendbocreturnhash") { - auto boc = request.GetArg("boc"); - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::raw_sendMessageReturnHash, boc, nullptr); - if (res.is_ok()) { - tonlib_component_.SendBocToExternalRequest(boc); - } - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - if (ton_api_method == "sendbocreturnhashnoerror") { - auto boc = request.GetArg("boc"); - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::raw_sendMessageReturnHash, boc, nullptr); - auto result = core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - if (!result.is_ok && result.error.has_value()) { - result.error = td::Status::Error(200, result.error->message()); - } else { - tonlib_component_.SendBocToExternalRequest(boc); - } - return std::move(result); - } - - if (ton_api_method == "rungetmethod") { - auto address = request.GetArg("address"); - auto method = request.GetArg("method"); - auto stack = request.GetArgVector("stack"); - auto seqno = utils::stringToInt(request.GetArg("seqno")); - auto archival = utils::stringToBool(request.GetArg("archival")); - - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::runGetMethod, address, method, stack, seqno, archival, nullptr); - return tonlib_component_.DoPostprocess(&core::TonlibPostProcessor::process_runGetMethod, std::move(res), std::move(session)); - } - - if (ton_api_method == "unpackaddress") { - auto address = request.GetArg("address"); - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::unpackAddress, address, nullptr); - if (res.is_error()) { - auto error = res.move_as_error(); - return core::TonlibWorkerResponse::from_error_string(error.message().str(), error.code(), std::move(session)); - } - return core::TonlibWorkerResponse::from_result_string(res.move_as_ok(), std::move(session)).Cachable(); - } - - if (ton_api_method == "packaddress") { - auto address = request.GetArg("address"); - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::packAddress, address, nullptr); - if (res.is_error()) { - auto error = res.move_as_error(); - return core::TonlibWorkerResponse::from_error_string(error.message().str(), error.code(), std::move(session)); - } - return core::TonlibWorkerResponse::from_result_string(res.move_as_ok(), std::move(session)).Cachable(); - } - - if (ton_api_method == "estimatefee") { - auto address = request.GetArg("address"); - auto body = request.GetArg("body"); - auto init_code = request.GetArg("init_code"); - auto init_data = request.GetArg("init_data"); - auto ignore_chksig = utils::stringToBool(request.GetArg("ignore_chksig")); - - if (address.empty()) { - return core::TonlibWorkerResponse::from_error_string("body is required", 422, nullptr); - } - if (body.empty()) { - return core::TonlibWorkerResponse::from_error_string("body is required", 422, nullptr); - } - if (!ignore_chksig.has_value()) { - ignore_chksig = true; - } - auto [res, session] = tonlib_component_.DoRequest(&core::TonlibWorker::queryEstimateFees, address, body, init_code, init_data, ignore_chksig.value(), nullptr); - return core::TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)).Cachable(); - } - - return {false, nullptr, std::nullopt, td::Status::Error(404, "method not found"), nullptr}; -} -bool ApiV2Handler::is_log_required(const TonlibApiRequest& request, const core::TonlibWorkerResponse& response) const { - if (request.is_debug_request) { - return true; - } - if (response.is_ok) { - return false; - } - if (response.error.has_value()) { - auto& error = response.error.value(); - auto status_code = error.code(); - if (status_code == 404) { - return false; - } - if (status_code == 409) { - return false; - } - if ((status_code == 500 || status_code == 0) && request.ton_api_method.starts_with("sendboc")) { - return false; - } - } - return true; -} - -} // namespace ton_http::handlers diff --git a/ton-http-api/handler_api_v2.h b/ton-http-api/handler_api_v2.h deleted file mode 100644 index b592367..0000000 --- a/ton-http-api/handler_api_v2.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "request.hpp" -#include "cache.hpp" -#include "tonlib_component.h" -#include "userver/server/handlers/http_handler_base.hpp" - -namespace ton_http::handlers { -class ApiV2Handler final : public userver::server::handlers::HttpHandlerBase { -public: - static constexpr std::string_view kName = "handler-api-v2"; - using HttpHandlerBase::HttpHandlerBase; - std::string HandleRequestThrow(const userver::server::http::HttpRequest& request, userver::server::request::RequestContext& context) const override; - ApiV2Handler(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); -private: - core::TonlibComponent& tonlib_component_; - cache::CacheApiV2Component& cache_component_; - userver::logging::LoggerPtr logger_; - [[nodiscard]] core::TonlibWorkerResponse HandleTonlibRequest(const TonlibApiRequest& request) const; - [[nodiscard]] bool is_log_required(const TonlibApiRequest& request, const core::TonlibWorkerResponse& response) const; - [[nodiscard]] userver::formats::json::Value build_json_response(const core::TonlibWorkerResponse& res) const; - [[nodiscard]] std::vector parse_request_body_item(const userver::formats::json::Value& value, int parse_array_depth=0) const; - void log_request( - const userver::server::http::HttpRequest& request, - const TonlibApiRequest& req, - const core::TonlibWorkerResponse& tonlib_response, - const std::string& response_body - ) const; -}; -} diff --git a/ton-http-api/openapi/openapi.json b/ton-http-api/openapi/openapi.json deleted file mode 100644 index cde8f2b..0000000 --- a/ton-http-api/openapi/openapi.json +++ /dev/null @@ -1,2387 +0,0 @@ -{ - "openapi": "3.1.0", - "info": { - "title": "TON HTTP API C++", - "description": "\nThis API enables HTTP access to TON blockchain - getting accounts and wallets information, looking up blocks and transactions, sending messages to the blockchain, calling get methods of smart contracts, and more.\n\nIn addition to REST API, all methods are available through [JSON-RPC endpoint](#json%20rpc) with `method` equal to method name and `params` passed as a dictionary.\n\nThe response contains a JSON object, which always has a boolean field `ok` and either `error` or `result`. If `ok` equals true, the request was successful and the result of the query can be found in the `result` field. In case of an unsuccessful request, `ok` equals false and the error is explained in the `error`.\n\nAPI Key should be sent either as `api_key` query parameter or `X-API-Key` header.\n", - "version": "2.1.0" - }, - "servers": [ - { - "url": "/", - "description": "Current" - }, - { - "url": "https://toncenter.com", - "description": "TON Center API v2 - mainnet" - }, - { - "url": "https://testnet.toncenter.com", - "description": "TON Center API v2 - testnet" - } - ], - "paths": { - "/api/v2/getAddressInformation": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Address Information", - "description": "Get basic information about the address: balance, code, data, last_transaction_id.", - "operationId": "get_address_information_getAddressInformation_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getExtendedAddressInformation": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Extended Address Information", - "description": "Similar to previous one but tries to parse additional information for known contract types. This method is based on tonlib's function *getAccountState*. For detecting wallets we recommend to use *getWalletInformation*.", - "operationId": "get_extended_address_information_getExtendedAddressInformation_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getWalletInformation": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Wallet Information", - "description": "Retrieve wallet information. This method parses contract state and currently supports more wallet types than getExtendedAddressInformation: simple wallet, standart wallet, v3 wallet, v4 wallet.", - "operationId": "get_wallet_information_getWalletInformation_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getAddressBalance": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Address Balance", - "description": "Get balance (in nanotons) of a given address.", - "operationId": "get_address_balance_getAddressBalance_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getAddressState": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Address", - "description": "Get state of a given address. State can be either *unitialized*, *active* or *frozen*.", - "operationId": "get_address_getAddressState_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getTokenData": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Token Data", - "description": "Get NFT or Jetton information.", - "operationId": "get_token_data_getTokenData_get", - "parameters": [ - { - "description": "Address of NFT collection/item or Jetton master/wallet smart contract", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Address of NFT collection/item or Jetton master/wallet smart contract" - }, - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/detectAddress": { - "get": { - "tags": [ - "utils" - ], - "summary": "Detect Address", - "description": "Get all possible address forms.", - "operationId": "detect_address_detectAddress_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/detectHash": { - "get": { - "tags": [ - "utils" - ], - "summary": "Detect Hash", - "description": "Get all possible hash forms.", - "operationId": "detect_address_detectHash_get", - "parameters": [ - { - "description": "The 256 bit hash in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Hash", - "description": "The 256 bit hash in any form." - }, - "name": "hash", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/packAddress": { - "get": { - "tags": [ - "utils" - ], - "summary": "Pack Address", - "description": "Convert an address from raw to human-readable format.", - "operationId": "pack_address_packAddress_get", - "parameters": [ - { - "description": "Identifier of target TON account in raw form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in raw form." - }, - "example": "0:83DFD552E63729B472FCBCC8C45EBCC6691702558B68EC7527E1BA403A0F31A8", - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/unpackAddress": { - "get": { - "tags": [ - "utils" - ], - "summary": "Unpack Address", - "description": "Convert an address from human-readable to raw format.", - "operationId": "unpack_address_unpackAddress_get", - "parameters": [ - { - "description": "Identifier of target TON account in user-friendly form", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in user-friendly form" - }, - "example": "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N", - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getMasterchainInfo": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Masterchain Info", - "description": "Get up-to-date masterchain state.", - "operationId": "get_masterchain_info_getMasterchainInfo_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getMasterchainBlockSignatures": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Masterchain Block Signatures", - "description": "Get up-to-date masterchain state.", - "operationId": "get_masterchain_block_signatures_getMasterchainBlockSignatures_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getShardBlockProof": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Shard Block Proof", - "description": "Get merkle proof of shardchain block.", - "operationId": "get_shard_block_proof_getShardBlockProof_get", - "parameters": [ - { - "description": "Block workchain id", - "required": true, - "schema": { - "type": "integer", - "title": "Workchain", - "description": "Block workchain id" - }, - "name": "workchain", - "in": "query" - }, - { - "description": "Block shard id", - "required": true, - "schema": { - "type": "integer", - "title": "Shard", - "description": "Block shard id" - }, - "name": "shard", - "in": "query" - }, - { - "description": "Block seqno", - "required": true, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Block seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "description": "Seqno of masterchain block starting from which proof is required. If not specified latest masterchain block is used.", - "required": false, - "schema": { - "type": "integer", - "title": "From Seqno", - "description": "Seqno of masterchain block starting from which proof is required. If not specified latest masterchain block is used." - }, - "name": "from_seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getConsensusBlock": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Consensus Block", - "description": "Get consensus block and its update timestamp.", - "operationId": "get_consensus_block_getConsensusBlock_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/lookupBlock": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Lookup Block", - "description": "Look up block by either *seqno*, *lt* or *unixtime*.", - "operationId": "lookup_block_lookupBlock_get", - "parameters": [ - { - "description": "Workchain id to look up block in", - "required": true, - "schema": { - "type": "integer", - "title": "Workchain", - "description": "Workchain id to look up block in" - }, - "name": "workchain", - "in": "query" - }, - { - "description": "Shard id to look up block in", - "required": true, - "schema": { - "type": "integer", - "title": "Shard", - "description": "Shard id to look up block in" - }, - "name": "shard", - "in": "query" - }, - { - "description": "Block's height", - "required": false, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Block's height" - }, - "name": "seqno", - "in": "query" - }, - { - "description": "Block's logical time", - "required": false, - "schema": { - "type": "integer", - "title": "Lt", - "description": "Block's logical time" - }, - "name": "lt", - "in": "query" - }, - { - "description": "Block's unixtime", - "required": false, - "schema": { - "type": "integer", - "title": "Unixtime", - "description": "Block's unixtime" - }, - "name": "unixtime", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getShards": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Shards", - "description": "Get shards information.", - "operationId": "get_shards_shards_get", - "parameters": [ - { - "description": "Masterchain seqno to fetch shards of.", - "required": true, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Masterchain seqno to fetch shards of." - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getBlockHeader": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Block Header", - "description": "Get metadata of a given block.", - "operationId": "get_block_header_getBlockHeader_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Workchain" - }, - "name": "workchain", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Shard" - }, - "name": "shard", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "Root Hash" - }, - "name": "root_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "File Hash" - }, - "name": "file_hash", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getOutMsgQueueSizes": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Out Msg Queue Sizes", - "description": "Get info with current sizes of messages queues by shards.", - "operationId": "get_out_msg_queue_sizes_getOutMsgQueueSizes_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getBlockTransactions": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Block Transactions", - "description": "Get transactions of the given block.", - "operationId": "get_block_transactions_getBlockTransactions_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Workchain" - }, - "name": "workchain", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Shard" - }, - "name": "shard", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "Root Hash" - }, - "name": "root_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "File Hash" - }, - "name": "file_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "After Lt" - }, - "name": "after_lt", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "After Hash" - }, - "name": "after_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Count", - "default": 40 - }, - "name": "count", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getBlockTransactionsExt": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Block Transactions Ext", - "description": "Get transactions of the given block.", - "operationId": "get_block_transactions_ext_getBlockTransactionsExt_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Workchain" - }, - "name": "workchain", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Shard" - }, - "name": "shard", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "Root Hash" - }, - "name": "root_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "File Hash" - }, - "name": "file_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "After Lt" - }, - "name": "after_lt", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "After Hash" - }, - "name": "after_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Count", - "default": 40 - }, - "name": "count", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getTransactions": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Transactions", - "description": "Get transaction history of a given address.", - "operationId": "get_transactions_getTransactions_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "description": "Maximum number of transactions in response.", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "exclusiveMinimum": 0, - "title": "Limit", - "description": "Maximum number of transactions in response.", - "default": 10 - }, - "name": "limit", - "in": "query" - }, - { - "description": "Logical time of transaction to start with, must be sent with *hash*.", - "required": false, - "schema": { - "type": "integer", - "title": "Lt", - "description": "Logical time of transaction to start with, must be sent with *hash*." - }, - "name": "lt", - "in": "query" - }, - { - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*.", - "required": false, - "schema": { - "type": "string", - "title": "Hash", - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*." - }, - "name": "hash", - "in": "query" - }, - { - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "required": false, - "schema": { - "type": "integer", - "title": "To Lt", - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "default": 0 - }, - "name": "to_lt", - "in": "query" - }, - { - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "required": false, - "schema": { - "type": "boolean", - "title": "Archival", - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "default": false - }, - "name": "archival", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getTransactionsV2": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Transactions V2", - "description": "Get transaction history of a given address.", - "operationId": "get_transactions_getTransactionsv2_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "description": "Maximum number of transactions in response.", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "exclusiveMinimum": 0, - "title": "count", - "description": "Maximum number of transactions in response.", - "default": 10 - }, - "name": "count", - "in": "query" - }, - { - "description": "Logical time of transaction to start with, must be sent with *hash*.", - "required": false, - "schema": { - "type": "integer", - "title": "Lt", - "description": "Logical time of transaction to start with, must be sent with *hash*." - }, - "name": "lt", - "in": "query" - }, - { - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*.", - "required": false, - "schema": { - "type": "string", - "title": "Hash", - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*." - }, - "name": "hash", - "in": "query" - }, - { - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "required": false, - "schema": { - "type": "integer", - "title": "To Lt", - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "default": 0 - }, - "name": "to_lt", - "in": "query" - }, - { - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "required": false, - "schema": { - "type": "boolean", - "title": "Archival", - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "default": false - }, - "name": "archival", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/tryLocateTx": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Try Locate Tx", - "description": "Locate outcoming transaction of *destination* address by incoming message.", - "operationId": "get_try_locate_tx_tryLocateTx_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "string", - "title": "Source" - }, - "name": "source", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "string", - "title": "Destination" - }, - "name": "destination", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Created Lt" - }, - "name": "created_lt", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/tryLocateResultTx": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Try Locate Result Tx", - "description": "Same as previous. Locate outcoming transaction of *destination* address by incoming message", - "operationId": "get_try_locate_result_tx_tryLocateResultTx_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "string", - "title": "Source" - }, - "name": "source", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "string", - "title": "Destination" - }, - "name": "destination", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Created Lt" - }, - "name": "created_lt", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/tryLocateSourceTx": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Try Locate Source Tx", - "description": "Locate incoming transaction of *source* address by outcoming message.", - "operationId": "get_try_locate_source_tx_tryLocateSourceTx_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "string", - "title": "Source" - }, - "name": "source", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "string", - "title": "Destination" - }, - "name": "destination", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Created Lt" - }, - "name": "created_lt", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getConfigParam": { - "get": { - "tags": [ - "get config" - ], - "summary": "Get Config Param", - "description": "Get config by id.", - "operationId": "get_config_param_getConfigParam_get", - "parameters": [ - { - "description": "Config id", - "required": true, - "schema": { - "type": "integer", - "title": "Config Id", - "description": "Config id" - }, - "name": "config_id", - "in": "query" - }, - { - "description": "Masterchain seqno. If not specified, latest blockchain state will be used.", - "required": false, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Masterchain seqno. If not specified, latest blockchain state will be used." - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getConfigAll": { - "get": { - "tags": [ - "get config" - ], - "summary": "Get Config All", - "description": "Get cell with full config.", - "operationId": "get_config_all_getConfigAll_get", - "parameters": [ - { - "description": "Masterchain seqno. If not specified, latest blockchain state will be used.", - "required": false, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Masterchain seqno. If not specified, latest blockchain state will be used." - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getLibraries": { - "get": { - "tags": [ - "get config" - ], - "summary": "Get Libraries", - "description": "Get libraries codes.", - "operationId": "get_libraries_getLibraries_get", - "parameters": [ - { - "description": "List of base64 encoded libraries hashes", - "required": true, - "schema": { - "items": { - - }, - "type": "array", - "title": "Libraries", - "description": "List of base64 or hex encoded libraries hashes" - }, - "name": "libraries", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/sendBoc": { - "post": { - "tags": [ - "send" - ], - "summary": "Send Boc", - "description": "Send serialized boc file: fully packed and serialized external message to blockchain.", - "operationId": "send_boc_sendBoc_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_send_boc_sendBoc_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/sendBocReturnHash": { - "post": { - "tags": [ - "send" - ], - "summary": "Send Boc Return Hash", - "description": "Send serialized boc file: fully packed and serialized external message to blockchain. The method returns message hash.", - "operationId": "send_boc_return_hash_sendBocReturnHash_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_send_boc_return_hash_sendBocReturnHash_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/sendQuery": { - "post": { - "tags": [ - "send" - ], - "summary": "Send Query", - "description": "Send query - unpacked external message. This method takes address, body and init-params (if any), packs it to external message and sends to network. All params should be boc-serialized.", - "operationId": "send_query_sendQuery_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_send_query_sendQuery_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/estimateFee": { - "post": { - "tags": [ - "send" - ], - "summary": "Estimate Fee", - "description": "Estimate fees required for query processing. *body*, *init-code* and *init-data* accepted in serialized format (b64-encoded).", - "operationId": "estimate_fee_estimateFee_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_estimate_fee_estimateFee_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/runGetMethod": { - "post": { - "tags": [ - "run method" - ], - "summary": "Run Get Method", - "description": "Run get method on smart contract.", - "operationId": "run_get_method_runGetMethod_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_run_get_method_runGetMethod_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/jsonRPC": { - "post": { - "tags": [ - "json rpc" - ], - "summary": "Jsonrpc Handler", - "description": "All methods in the API are available through JSON-RPC protocol ([spec](https://www.jsonrpc.org/specification)).", - "operationId": "jsonrpc_handler_jsonRPC_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonRequestJsonRPC" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeprecatedTonResponseJsonRPC" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - } - }, - "components": { - "schemas": { - "Body_estimate_fee_estimateFee_post": { - "properties": { - "address": { - "type": "string", - "title": "Address", - "description": "Address in any format" - }, - "body": { - "type": "string", - "title": "Body", - "description": "b64-encoded cell with message body" - }, - "init_code": { - "type": "string", - "title": "Init Code", - "description": "b64-encoded cell with init-code", - "default": "" - }, - "init_data": { - "type": "string", - "title": "Init Data", - "description": "b64-encoded cell with init-data", - "default": "" - }, - "ignore_chksig": { - "type": "boolean", - "title": "Ignore Chksig", - "description": "If true during test query processing assume that all chksig operations return True", - "default": true - } - }, - "type": "object", - "required": [ - "address", - "body" - ], - "title": "Body_estimate_fee_estimateFee_post" - }, - "Body_run_get_method_runGetMethod_post": { - "properties": { - "address": { - "type": "string", - "title": "Address", - "description": "Contract address" - }, - "method": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ], - "title": "Method", - "description": "Method name or method id" - }, - "stack": { - "items": { - "items": { - - }, - "type": "array" - }, - "type": "array", - "title": "Stack", - "description": "Array of stack elements: `[['num',3], ['cell', cell_object], ['slice', slice_object]]`" - }, - "seqno": { - "type": "integer", - "title": "Seqno", - "description": "Seqno of masterchain block at which moment the Get Method is to be executed" - } - }, - "type": "object", - "required": [ - "address", - "method", - "stack" - ], - "title": "Body_run_get_method_runGetMethod_post" - }, - "Body_send_boc_return_hash_sendBocReturnHash_post": { - "properties": { - "boc": { - "type": "string", - "title": "Boc", - "description": "b64 encoded bag of cells" - } - }, - "type": "object", - "required": [ - "boc" - ], - "title": "Body_send_boc_return_hash_sendBocReturnHash_post" - }, - "Body_send_boc_sendBoc_post": { - "properties": { - "boc": { - "type": "string", - "title": "Boc", - "description": "b64 encoded bag of cells" - } - }, - "type": "object", - "required": [ - "boc" - ], - "title": "Body_send_boc_sendBoc_post" - }, - "Body_send_query_sendQuery_post": { - "properties": { - "address": { - "type": "string", - "title": "Address", - "description": "Address in any format" - }, - "body": { - "type": "string", - "title": "Body", - "description": "b64-encoded boc-serialized cell with message body" - }, - "init_code": { - "type": "string", - "title": "Init Code", - "description": "b64-encoded boc-serialized cell with init-code", - "default": "" - }, - "init_data": { - "type": "string", - "title": "Init Data", - "description": "b64-encoded boc-serialized cell with init-data", - "default": "" - } - }, - "type": "object", - "required": [ - "address", - "body" - ], - "title": "Body_send_query_sendQuery_post" - }, - "DeprecatedTonResponseJsonRPC": { - "properties": { - "ok": { - "type": "boolean", - "title": "Ok" - }, - "result": { - "title": "Result" - }, - "error": { - "type": "string", - "title": "Error" - }, - "code": { - "type": "integer", - "title": "Code" - }, - "id": { - "type": "string", - "title": "Id" - }, - "jsonrpc": { - "type": "string", - "title": "Jsonrpc", - "default": "2.0" - } - }, - "type": "object", - "required": [ - "ok", - "id" - ], - "title": "DeprecatedTonResponseJsonRPC" - }, - "TonRequestJsonRPC": { - "properties": { - "method": { - "type": "string", - "title": "Method" - }, - "params": { - "type": "object", - "title": "Params", - "default": { - - } - }, - "id": { - "type": "string", - "title": "Id" - }, - "jsonrpc": { - "type": "string", - "title": "Jsonrpc" - } - }, - "type": "object", - "required": [ - "method" - ], - "title": "TonRequestJsonRPC" - }, - "TonResponse": { - "properties": { - "ok": { - "type": "boolean", - "title": "Ok" - }, - "result": { - "anyOf": [ - { - "type": "string" - }, - { - "items": { - - }, - "type": "array" - }, - { - "type": "object" - } - ], - "title": "Result" - }, - "error": { - "type": "string", - "title": "Error" - }, - "code": { - "type": "integer", - "title": "Code" - } - }, - "type": "object", - "required": [ - "ok" - ], - "title": "TonResponse" - } - }, - "securitySchemes": { - "APIKeyHeader": { - "type": "apiKey", - "in": "header", - "name": "X-API-Key" - }, - "APIKeyQuery": { - "type": "apiKey", - "in": "query", - "name": "api_key" - } - } - }, - "tags": [ - { - "name": "utils", - "description": "Some useful methods for conversion" - }, - { - "name": "accounts", - "description": "Information about accounts." - }, - { - "name": "blocks", - "description": "Information about blocks." - }, - { - "name": "transactions", - "description": "Fetching and locating transactions." - }, - { - "name": "get config", - "description": "Get blockchain config" - }, - { - "name": "run method", - "description": "Run get method of smart contract." - }, - { - "name": "send", - "description": "Send data to blockchain." - }, - { - "name": "json rpc", - "description": "JSON-RPC endpoint." - } - ] -} \ No newline at end of file diff --git a/ton-http-api/openapi/openapi_page.hpp b/ton-http-api/openapi/openapi_page.hpp deleted file mode 100644 index afe9f5b..0000000 --- a/ton-http-api/openapi/openapi_page.hpp +++ /dev/null @@ -1,2434 +0,0 @@ -#pragma once -#include - -namespace ton_http::openapi { -std::string GetOpenApiPage() { - return R"( - - - - - - SwaggerUI - - - -
- - - - - -)"; -} -std::string GetOpenApiJson() { - return R"({ - "openapi": "3.1.0", - "info": { - "title": "TON HTTP API C++", - "description": "\nThis API enables HTTP access to TON blockchain - getting accounts and wallets information, looking up blocks and transactions, sending messages to the blockchain, calling get methods of smart contracts, and more.\n\nIn addition to REST API, all methods are available through [JSON-RPC endpoint](#json%20rpc) with `method` equal to method name and `params` passed as a dictionary.\n\nThe response contains a JSON object, which always has a boolean field `ok` and either `error` or `result`. If `ok` equals true, the request was successful and the result of the query can be found in the `result` field. In case of an unsuccessful request, `ok` equals false and the error is explained in the `error`.\n\nAPI Key should be sent either as `api_key` query parameter or `X-API-Key` header.\n", - "version": "2.1.0" - }, - "servers": [ - { - "url": "/", - "description": "Current" - }, - { - "url": "https://toncenter.com", - "description": "TON Center API v2 - mainnet" - }, - { - "url": "https://testnet.toncenter.com", - "description": "TON Center API v2 - testnet" - } - ], - "paths": { - "/api/v2/getAddressInformation": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Address Information", - "description": "Get basic information about the address: balance, code, data, last_transaction_id.", - "operationId": "get_address_information_getAddressInformation_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getExtendedAddressInformation": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Extended Address Information", - "description": "Similar to previous one but tries to parse additional information for known contract types. This method is based on tonlib's function *getAccountState*. For detecting wallets we recommend to use *getWalletInformation*.", - "operationId": "get_extended_address_information_getExtendedAddressInformation_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getWalletInformation": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Wallet Information", - "description": "Retrieve wallet information. This method parses contract state and currently supports more wallet types than getExtendedAddressInformation: simple wallet, standart wallet, v3 wallet, v4 wallet.", - "operationId": "get_wallet_information_getWalletInformation_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getAddressBalance": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Address Balance", - "description": "Get balance (in nanotons) of a given address.", - "operationId": "get_address_balance_getAddressBalance_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getAddressState": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Address", - "description": "Get state of a given address. State can be either *unitialized*, *active* or *frozen*.", - "operationId": "get_address_getAddressState_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Masterchain block seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getTokenData": { - "get": { - "tags": [ - "accounts" - ], - "summary": "Get Token Data", - "description": "Get NFT or Jetton information.", - "operationId": "get_token_data_getTokenData_get", - "parameters": [ - { - "description": "Address of NFT collection/item or Jetton master/wallet smart contract", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Address of NFT collection/item or Jetton master/wallet smart contract" - }, - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/detectAddress": { - "get": { - "tags": [ - "utils" - ], - "summary": "Detect Address", - "description": "Get all possible address forms.", - "operationId": "detect_address_detectAddress_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/detectHash": { - "get": { - "tags": [ - "utils" - ], - "summary": "Detect Hash", - "description": "Get all possible hash forms.", - "operationId": "detect_address_detectHash_get", - "parameters": [ - { - "description": "The 256 bit hash in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Hash", - "description": "The 256 bit hash in any form." - }, - "name": "hash", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/packAddress": { - "get": { - "tags": [ - "utils" - ], - "summary": "Pack Address", - "description": "Convert an address from raw to human-readable format.", - "operationId": "pack_address_packAddress_get", - "parameters": [ - { - "description": "Identifier of target TON account in raw form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in raw form." - }, - "example": "0:83DFD552E63729B472FCBCC8C45EBCC6691702558B68EC7527E1BA403A0F31A8", - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/unpackAddress": { - "get": { - "tags": [ - "utils" - ], - "summary": "Unpack Address", - "description": "Convert an address from human-readable to raw format.", - "operationId": "unpack_address_unpackAddress_get", - "parameters": [ - { - "description": "Identifier of target TON account in user-friendly form", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in user-friendly form" - }, - "example": "EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N", - "name": "address", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getMasterchainInfo": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Masterchain Info", - "description": "Get up-to-date masterchain state.", - "operationId": "get_masterchain_info_getMasterchainInfo_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getMasterchainBlockSignatures": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Masterchain Block Signatures", - "description": "Get up-to-date masterchain state.", - "operationId": "get_masterchain_block_signatures_getMasterchainBlockSignatures_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getShardBlockProof": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Shard Block Proof", - "description": "Get merkle proof of shardchain block.", - "operationId": "get_shard_block_proof_getShardBlockProof_get", - "parameters": [ - { - "description": "Block workchain id", - "required": true, - "schema": { - "type": "integer", - "title": "Workchain", - "description": "Block workchain id" - }, - "name": "workchain", - "in": "query" - }, - { - "description": "Block shard id", - "required": true, - "schema": { - "type": "integer", - "title": "Shard", - "description": "Block shard id" - }, - "name": "shard", - "in": "query" - }, - { - "description": "Block seqno", - "required": true, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Block seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "description": "Seqno of masterchain block starting from which proof is required. If not specified latest masterchain block is used.", - "required": false, - "schema": { - "type": "integer", - "title": "From Seqno", - "description": "Seqno of masterchain block starting from which proof is required. If not specified latest masterchain block is used." - }, - "name": "from_seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getConsensusBlock": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Consensus Block", - "description": "Get consensus block and its update timestamp.", - "operationId": "get_consensus_block_getConsensusBlock_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/lookupBlock": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Lookup Block", - "description": "Look up block by either *seqno*, *lt* or *unixtime*.", - "operationId": "lookup_block_lookupBlock_get", - "parameters": [ - { - "description": "Workchain id to look up block in", - "required": true, - "schema": { - "type": "integer", - "title": "Workchain", - "description": "Workchain id to look up block in" - }, - "name": "workchain", - "in": "query" - }, - { - "description": "Shard id to look up block in", - "required": true, - "schema": { - "type": "integer", - "title": "Shard", - "description": "Shard id to look up block in" - }, - "name": "shard", - "in": "query" - }, - { - "description": "Block's height", - "required": false, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Block's height" - }, - "name": "seqno", - "in": "query" - }, - { - "description": "Block's logical time", - "required": false, - "schema": { - "type": "integer", - "title": "Lt", - "description": "Block's logical time" - }, - "name": "lt", - "in": "query" - }, - { - "description": "Block's unixtime", - "required": false, - "schema": { - "type": "integer", - "title": "Unixtime", - "description": "Block's unixtime" - }, - "name": "unixtime", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getShards": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Shards", - "description": "Get shards information.", - "operationId": "get_shards_shards_get", - "parameters": [ - { - "description": "Masterchain seqno to fetch shards of.", - "required": true, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Masterchain seqno to fetch shards of." - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getBlockHeader": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Block Header", - "description": "Get metadata of a given block.", - "operationId": "get_block_header_getBlockHeader_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Workchain" - }, - "name": "workchain", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Shard" - }, - "name": "shard", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "Root Hash" - }, - "name": "root_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "File Hash" - }, - "name": "file_hash", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getOutMsgQueueSizes": { - "get": { - "tags": [ - "blocks" - ], - "summary": "Get Out Msg Queue Sizes", - "description": "Get info with current sizes of messages queues by shards.", - "operationId": "get_out_msg_queue_sizes_getOutMsgQueueSizes_get", - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getBlockTransactions": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Block Transactions", - "description": "Get transactions of the given block.", - "operationId": "get_block_transactions_getBlockTransactions_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Workchain" - }, - "name": "workchain", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Shard" - }, - "name": "shard", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "Root Hash" - }, - "name": "root_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "File Hash" - }, - "name": "file_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "After Lt" - }, - "name": "after_lt", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "After Hash" - }, - "name": "after_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Count", - "default": 40 - }, - "name": "count", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getBlockTransactionsExt": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Block Transactions Ext", - "description": "Get transactions of the given block.", - "operationId": "get_block_transactions_ext_getBlockTransactionsExt_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "integer", - "title": "Workchain" - }, - "name": "workchain", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Shard" - }, - "name": "shard", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Seqno" - }, - "name": "seqno", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "Root Hash" - }, - "name": "root_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "File Hash" - }, - "name": "file_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "After Lt" - }, - "name": "after_lt", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "string", - "title": "After Hash" - }, - "name": "after_hash", - "in": "query" - }, - { - "required": false, - "schema": { - "type": "integer", - "title": "Count", - "default": 40 - }, - "name": "count", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getTransactions": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Transactions", - "description": "Get transaction history of a given address.", - "operationId": "get_transactions_getTransactions_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "description": "Maximum number of transactions in response.", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "exclusiveMinimum": 0, - "title": "Limit", - "description": "Maximum number of transactions in response.", - "default": 10 - }, - "name": "limit", - "in": "query" - }, - { - "description": "Logical time of transaction to start with, must be sent with *hash*.", - "required": false, - "schema": { - "type": "integer", - "title": "Lt", - "description": "Logical time of transaction to start with, must be sent with *hash*." - }, - "name": "lt", - "in": "query" - }, - { - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*.", - "required": false, - "schema": { - "type": "string", - "title": "Hash", - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*." - }, - "name": "hash", - "in": "query" - }, - { - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "required": false, - "schema": { - "type": "integer", - "title": "To Lt", - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "default": 0 - }, - "name": "to_lt", - "in": "query" - }, - { - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "required": false, - "schema": { - "type": "boolean", - "title": "Archival", - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "default": false - }, - "name": "archival", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getTransactionsV2": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Transactions V2", - "description": "Get transaction history of a given address.", - "operationId": "get_transactions_getTransactionsv2_get", - "parameters": [ - { - "description": "Identifier of target TON account in any form.", - "required": true, - "schema": { - "type": "string", - "title": "Address", - "description": "Identifier of target TON account in any form." - }, - "name": "address", - "in": "query" - }, - { - "description": "Maximum number of transactions in response.", - "required": false, - "schema": { - "type": "integer", - "maximum": 100, - "exclusiveMinimum": 0, - "title": "count", - "description": "Maximum number of transactions in response.", - "default": 10 - }, - "name": "count", - "in": "query" - }, - { - "description": "Logical time of transaction to start with, must be sent with *hash*.", - "required": false, - "schema": { - "type": "integer", - "title": "Lt", - "description": "Logical time of transaction to start with, must be sent with *hash*." - }, - "name": "lt", - "in": "query" - }, - { - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*.", - "required": false, - "schema": { - "type": "string", - "title": "Hash", - "description": "Hash of transaction to start with, in *base64* or *hex* encoding , must be sent with *lt*." - }, - "name": "hash", - "in": "query" - }, - { - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "required": false, - "schema": { - "type": "integer", - "title": "To Lt", - "description": "Logical time of transaction to finish with (to get tx from *lt* to *to_lt*).", - "default": 0 - }, - "name": "to_lt", - "in": "query" - }, - { - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "required": false, - "schema": { - "type": "boolean", - "title": "Archival", - "description": "By default getTransaction request is processed by any available liteserver. If *archival=true* only liteservers with full history are used.", - "default": false - }, - "name": "archival", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/tryLocateTx": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Try Locate Tx", - "description": "Locate outcoming transaction of *destination* address by incoming message.", - "operationId": "get_try_locate_tx_tryLocateTx_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "string", - "title": "Source" - }, - "name": "source", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "string", - "title": "Destination" - }, - "name": "destination", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Created Lt" - }, - "name": "created_lt", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/tryLocateResultTx": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Try Locate Result Tx", - "description": "Same as previous. Locate outcoming transaction of *destination* address by incoming message", - "operationId": "get_try_locate_result_tx_tryLocateResultTx_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "string", - "title": "Source" - }, - "name": "source", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "string", - "title": "Destination" - }, - "name": "destination", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Created Lt" - }, - "name": "created_lt", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/tryLocateSourceTx": { - "get": { - "tags": [ - "transactions" - ], - "summary": "Get Try Locate Source Tx", - "description": "Locate incoming transaction of *source* address by outcoming message.", - "operationId": "get_try_locate_source_tx_tryLocateSourceTx_get", - "parameters": [ - { - "required": true, - "schema": { - "type": "string", - "title": "Source" - }, - "name": "source", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "string", - "title": "Destination" - }, - "name": "destination", - "in": "query" - }, - { - "required": true, - "schema": { - "type": "integer", - "title": "Created Lt" - }, - "name": "created_lt", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getConfigParam": { - "get": { - "tags": [ - "get config" - ], - "summary": "Get Config Param", - "description": "Get config by id.", - "operationId": "get_config_param_getConfigParam_get", - "parameters": [ - { - "description": "Config id", - "required": true, - "schema": { - "type": "integer", - "title": "Config Id", - "description": "Config id" - }, - "name": "config_id", - "in": "query" - }, - { - "description": "Masterchain seqno. If not specified, latest blockchain state will be used.", - "required": false, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Masterchain seqno. If not specified, latest blockchain state will be used." - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getConfigAll": { - "get": { - "tags": [ - "get config" - ], - "summary": "Get Config All", - "description": "Get cell with full config.", - "operationId": "get_config_all_getConfigAll_get", - "parameters": [ - { - "description": "Masterchain seqno. If not specified, latest blockchain state will be used.", - "required": false, - "schema": { - "type": "integer", - "title": "Seqno", - "description": "Masterchain seqno. If not specified, latest blockchain state will be used." - }, - "name": "seqno", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/getLibraries": { - "get": { - "tags": [ - "get config" - ], - "summary": "Get Libraries", - "description": "Get libraries codes.", - "operationId": "get_libraries_getLibraries_get", - "parameters": [ - { - "description": "List of base64 encoded libraries hashes", - "required": true, - "schema": { - "items": { - - }, - "type": "array", - "title": "Libraries", - "description": "List of base64 or hex encoded libraries hashes" - }, - "name": "libraries", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/sendBoc": { - "post": { - "tags": [ - "send" - ], - "summary": "Send Boc", - "description": "Send serialized boc file: fully packed and serialized external message to blockchain.", - "operationId": "send_boc_sendBoc_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_send_boc_sendBoc_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/sendBocReturnHash": { - "post": { - "tags": [ - "send" - ], - "summary": "Send Boc Return Hash", - "description": "Send serialized boc file: fully packed and serialized external message to blockchain. The method returns message hash.", - "operationId": "send_boc_return_hash_sendBocReturnHash_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_send_boc_return_hash_sendBocReturnHash_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/sendQuery": { - "post": { - "tags": [ - "send" - ], - "summary": "Send Query", - "description": "Send query - unpacked external message. This method takes address, body and init-params (if any), packs it to external message and sends to network. All params should be boc-serialized.", - "operationId": "send_query_sendQuery_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_send_query_sendQuery_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/estimateFee": { - "post": { - "tags": [ - "send" - ], - "summary": "Estimate Fee", - "description": "Estimate fees required for query processing. *body*, *init-code* and *init-data* accepted in serialized format (b64-encoded).", - "operationId": "estimate_fee_estimateFee_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_estimate_fee_estimateFee_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/runGetMethod": { - "post": { - "tags": [ - "run method" - ], - "summary": "Run Get Method", - "description": "Run get method on smart contract.", - "operationId": "run_get_method_runGetMethod_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Body_run_get_method_runGetMethod_post" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonResponse" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - }, - "/api/v2/jsonRPC": { - "post": { - "tags": [ - "json rpc" - ], - "summary": "Jsonrpc Handler", - "description": "All methods in the API are available through JSON-RPC protocol ([spec](https://www.jsonrpc.org/specification)).", - "operationId": "jsonrpc_handler_jsonRPC_post", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TonRequestJsonRPC" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Successful Response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DeprecatedTonResponseJsonRPC" - } - } - } - }, - "422": { - "description": "Validation Error" - }, - "504": { - "description": "Lite Server Timeout" - } - }, - "security": [ - { - "APIKeyHeader": [] - }, - { - "APIKeyQuery": [] - } - ] - } - } - }, - "components": { - "schemas": { - "Body_estimate_fee_estimateFee_post": { - "properties": { - "address": { - "type": "string", - "title": "Address", - "description": "Address in any format" - }, - "body": { - "type": "string", - "title": "Body", - "description": "b64-encoded cell with message body" - }, - "init_code": { - "type": "string", - "title": "Init Code", - "description": "b64-encoded cell with init-code", - "default": "" - }, - "init_data": { - "type": "string", - "title": "Init Data", - "description": "b64-encoded cell with init-data", - "default": "" - }, - "ignore_chksig": { - "type": "boolean", - "title": "Ignore Chksig", - "description": "If true during test query processing assume that all chksig operations return True", - "default": true - } - }, - "type": "object", - "required": [ - "address", - "body" - ], - "title": "Body_estimate_fee_estimateFee_post" - }, - "Body_run_get_method_runGetMethod_post": { - "properties": { - "address": { - "type": "string", - "title": "Address", - "description": "Contract address" - }, - "method": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "integer" - } - ], - "title": "Method", - "description": "Method name or method id" - }, - "stack": { - "items": { - "items": { - - }, - "type": "array" - }, - "type": "array", - "title": "Stack", - "description": "Array of stack elements: `[['num',3], ['cell', cell_object], ['slice', slice_object]]`" - }, - "seqno": { - "type": "integer", - "title": "Seqno", - "description": "Seqno of masterchain block at which moment the Get Method is to be executed" - } - }, - "type": "object", - "required": [ - "address", - "method", - "stack" - ], - "title": "Body_run_get_method_runGetMethod_post" - }, - "Body_send_boc_return_hash_sendBocReturnHash_post": { - "properties": { - "boc": { - "type": "string", - "title": "Boc", - "description": "b64 encoded bag of cells" - } - }, - "type": "object", - "required": [ - "boc" - ], - "title": "Body_send_boc_return_hash_sendBocReturnHash_post" - }, - "Body_send_boc_sendBoc_post": { - "properties": { - "boc": { - "type": "string", - "title": "Boc", - "description": "b64 encoded bag of cells" - } - }, - "type": "object", - "required": [ - "boc" - ], - "title": "Body_send_boc_sendBoc_post" - }, - "Body_send_query_sendQuery_post": { - "properties": { - "address": { - "type": "string", - "title": "Address", - "description": "Address in any format" - }, - "body": { - "type": "string", - "title": "Body", - "description": "b64-encoded boc-serialized cell with message body" - }, - "init_code": { - "type": "string", - "title": "Init Code", - "description": "b64-encoded boc-serialized cell with init-code", - "default": "" - }, - "init_data": { - "type": "string", - "title": "Init Data", - "description": "b64-encoded boc-serialized cell with init-data", - "default": "" - } - }, - "type": "object", - "required": [ - "address", - "body" - ], - "title": "Body_send_query_sendQuery_post" - }, - "DeprecatedTonResponseJsonRPC": { - "properties": { - "ok": { - "type": "boolean", - "title": "Ok" - }, - "result": { - "title": "Result" - }, - "error": { - "type": "string", - "title": "Error" - }, - "code": { - "type": "integer", - "title": "Code" - }, - "id": { - "type": "string", - "title": "Id" - }, - "jsonrpc": { - "type": "string", - "title": "Jsonrpc", - "default": "2.0" - } - }, - "type": "object", - "required": [ - "ok", - "id" - ], - "title": "DeprecatedTonResponseJsonRPC" - }, - "TonRequestJsonRPC": { - "properties": { - "method": { - "type": "string", - "title": "Method" - }, - "params": { - "type": "object", - "title": "Params", - "default": { - - } - }, - "id": { - "type": "string", - "title": "Id" - }, - "jsonrpc": { - "type": "string", - "title": "Jsonrpc" - } - }, - "type": "object", - "required": [ - "method" - ], - "title": "TonRequestJsonRPC" - }, - "TonResponse": { - "properties": { - "ok": { - "type": "boolean", - "title": "Ok" - }, - "result": { - "anyOf": [ - { - "type": "string" - }, - { - "items": { - - }, - "type": "array" - }, - { - "type": "object" - } - ], - "title": "Result" - }, - "error": { - "type": "string", - "title": "Error" - }, - "code": { - "type": "integer", - "title": "Code" - } - }, - "type": "object", - "required": [ - "ok" - ], - "title": "TonResponse" - } - }, - "securitySchemes": { - "APIKeyHeader": { - "type": "apiKey", - "in": "header", - "name": "X-API-Key" - }, - "APIKeyQuery": { - "type": "apiKey", - "in": "query", - "name": "api_key" - } - } - }, - "tags": [ - { - "name": "utils", - "description": "Some useful methods for conversion" - }, - { - "name": "accounts", - "description": "Information about accounts." - }, - { - "name": "blocks", - "description": "Information about blocks." - }, - { - "name": "transactions", - "description": "Fetching and locating transactions." - }, - { - "name": "get config", - "description": "Get blockchain config" - }, - { - "name": "run method", - "description": "Run get method of smart contract." - }, - { - "name": "send", - "description": "Send data to blockchain." - }, - { - "name": "json rpc", - "description": "JSON-RPC endpoint." - } - ] -})"; -} -} diff --git a/ton-http-api/openapi/openapi_page.hpp.in b/ton-http-api/openapi/openapi_page.hpp.in deleted file mode 100644 index efa143b..0000000 --- a/ton-http-api/openapi/openapi_page.hpp.in +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include - -namespace ton_http::openapi { -std::string GetOpenApiPage() { - return R"(@OPENAPI_HTML_CONTENT@)"; -} -std::string GetOpenApiJson() { - return R"(@OPENAPI_JSON_CONTENT@)"; -} -} diff --git a/ton-http-api/request.hpp b/ton-http-api/request.hpp deleted file mode 100644 index 7c67b6a..0000000 --- a/ton-http-api/request.hpp +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include - - -#include "tonlib_component.h" - -namespace ton_http::handlers { -struct TonlibApiRequest { - std::string http_method; - std::string ton_api_method; - std::map> args; - bool is_debug_request{false}; - - [[nodiscard]] std::string GetArg(const std::string& name) const { - const auto it = args.find(name); - if (it == args.end()) { - return ""; - } - if (it->second.empty()) { - return ""; - } - return it->second[0]; - } - [[nodiscard]] std::vector GetArgVector(const std::string& name) const { - const auto it = args.find(name); - if (it == args.end()) { - return {}; - } - return it->second; - } - void SetArg(const std::string& name, const std::string& value) { - args.insert_or_assign(name, std::vector{value}); - } - void SetArgVector(const std::string& name, const std::vector& values) { - args.insert_or_assign(name, values); - } - - friend bool operator==(const TonlibApiRequest& a, const TonlibApiRequest& b) { - if (!(a.http_method == b.http_method && a.ton_api_method == b.ton_api_method)) { - return false; - } - auto& lhs = a.args; - auto& rhs = b.args; - if (lhs.size() != rhs.size()) return false; - for (auto& [k, v] : lhs) { - auto it = rhs.find(k); - if (it == rhs.end()) return false; - - auto v1 = v, v2 = it->second; - std::ranges::sort(v1); - std::ranges::sort(v2); - if (v1 != v2) return false; - } - return true; - } -}; -} - -namespace std { -template<> -struct hash { - std::size_t operator()(const ton_http::handlers::TonlibApiRequest& request) const { - std::stringstream ss; - ss << request.http_method << "/" << request.ton_api_method; - for (auto& [k, v] : request.args) { - ss << "/" << k << ":"; - bool is_first = true; - for (auto& i : v) { - if (is_first) { - is_first = false; - } else { - ss << ","; - } - ss << i; - } - } - return std::hash{}(ss.str()); - } -}; -} diff --git a/ton-http-api/schemas/v2.json b/ton-http-api/schemas/v2.json new file mode 100644 index 0000000..ab772bd --- /dev/null +++ b/ton-http-api/schemas/v2.json @@ -0,0 +1,222 @@ +{ + "components": { + "schemas": { + "TonObject": { + "oneOf": [ + {"$ref": "#/components/schemas/TonBlockIdExt"}, + {"$ref": "#/components/schemas/MasterchainInfo"} + ], + "discriminator": { + "propertyName": "@type", + "mapping": { + "ton.blockIdExt": "#/components/schemas/TonBlockIdExt", + "blocks.masterchainInfo": "#/components/schemas/MasterchainInfo" + } + } + }, + "TonResponse": { + "properties": { + "ok": { + "type": "boolean", + "title": "Ok" + }, + "result": { + "oneOf": [ + {"type": "string"}, + {"$ref": "#/components/schemas/TonObject"}, + {"type": "array", "items": {"$ref": "#/components/schemas/TonObject"}} + ] + }, + "error": { + "type": "string", + "title": "Error desciption" + }, + "code": { + "type": "integer", + "title": "Error code" + }, + "@extra": { + "type": "string", + "title": "Extra information" + } + }, + "type": "object", + "required": [ + "ok", + "@extra" + ], + "additionalProperties": false, + "title": "TonResponse" + }, + "TonAddr": { + "type": "string", + "x-usrv-cpp-type": "ton_http::types::ton_addr" + }, + "TonHash": { + "type": "string", + "x-usrv-cpp-type": "ton_http::types::ton_hash" + }, + "TonShardId": { + "type": "string", + "x-usrv-cpp-type": "ton_http::types::shard_id" + }, + "TonBlockIdExt": { + "type": "object", + "additionalProperties": false, + "properties": { + "@type": { + "type": "string", + "default": "ton.blockIdExt" + }, + "workchain": { + "type": "integer" + }, + "shard": { + "$ref": "#/components/schemas/TonShardId" + }, + "seqno": { + "type": "integer" + }, + "root_hash": { + "$ref": "#/components/schemas/TonHash" + }, + "file_hash": { + "$ref": "#/components/schemas/TonHash" + } + }, + "required": [ + "@type", + "workchain", + "shard", + "seqno", + "root_hash", + "file_hash" + ], + "description": "Extended block identifier." + }, + "MasterchainInfo": { + "type": "object", + "additionalProperties": false, + "description": "Information about the latest masterchain block.", + "properties": { + "@type": { + "type": "string", + "default": "blocks.masterchainInfo" + }, + "last": { + "$ref": "#/components/schemas/TonBlockIdExt" + }, + "state_root_hash": { + "$ref": "#/components/schemas/TonHash" + }, + "init": { + "$ref": "#/components/schemas/TonBlockIdExt" + } + }, + "required": [ + "@type", + "last", + "state_root_hash", + "init" + ] + }, + "DetectAddressBase64Variant": { + "type": "object", + "additionalProperties": false, + "description": "Base64 form of address variant", + "properties": { + "b64": { + "type": "string" + }, + "b64url": { + "type": "string" + } + }, + "required": [ + "b64", + "b64url" + ] + }, + "DetectedAddress": { + "type": "object", + "additionalProperties": false, + "description": "Information about the address.", + "properties": { + "@type": { + "type": "string", + "default": "utils.detectedAddress" + }, + "raw_form": { + "type": "string" + }, + "bounceable": { + "$ref": "#/components/schemas/DetectAddressBase64Variant" + }, + "non_bounceable": { + "$ref": "#/components/schemas/DetectAddressBase64Variant" + }, + "given_type": { + "type": "string", + "enum": ["raw_form", "friendly_bounceable", "friendly_non_bounceable"] + }, + "test_only": { + "type": "boolean" + } + }, + "required": [ + "@type", + "raw_form", + "bounceable", + "non_bounceable", + "given_type", + "test_only" + ] + }, + "DetectedHash": { + "type": "object", + "additionalProperties": false, + "properties": { + "@type": { + "type": "string", + "default": "utils.detectedHash" + }, + "b64": { + "type": "string", + "title": "base64 form" + }, + "b64url": { + "type": "string", + "title": "base64 url-safe form" + }, + "hex": { + "type": "string", + "title": "hex form" + } + } + }, + "PackedAddress": { + "type": "string", + "title": "Address packed in base64" + }, + "UnpackedAddress": { + "type": "string", + "title": "Address unpacked to raw form" + }, + "FullAccountStateRaw": { + "type": "object", + "additionalProperties": false, + "properties": { + "@type": { + "type": "string", + "default": "raw.fullAccountState" + }, + "balance": { + "type": "string", + "x-usrv-cpp-type": "ton_http::types::int256" + } + } + + } + } + } +} diff --git a/ton-http-api/tonlib_component.cpp b/ton-http-api/src/components/tonlib_component.cpp similarity index 94% rename from ton-http-api/tonlib_component.cpp rename to ton-http-api/src/components/tonlib_component.cpp index 6f0680a..0e11605 100644 --- a/ton-http-api/tonlib_component.cpp +++ b/ton-http-api/src/components/tonlib_component.cpp @@ -1,7 +1,6 @@ #include "tonlib_component.h" #include "core/src/curl-ev/form.hpp" -#include "tonlib_postprocessor.h" #include "userver/clients/http/component.hpp" #include "userver/components/component.hpp" #include "userver/components/component_context.hpp" @@ -47,8 +46,11 @@ TonlibComponent::TonlibComponent( LOG_WARNING_TO(*logger_) << "Found endpoints: " << ss.str(); } } +multiclient::SessionPtr TonlibComponent::GetNewSession() const { + return std::make_shared(); +} -bool TonlibComponent::SendBocToExternalRequest(std::string boc_b64) { +bool TonlibComponent::SendBocToExternalRequest(const std::string& boc_b64) const { if (external_message_endpoints_.empty()) { return true; } diff --git a/ton-http-api/tonlib_component.h b/ton-http-api/src/components/tonlib_component.h similarity index 75% rename from ton-http-api/tonlib_component.h rename to ton-http-api/src/components/tonlib_component.h index 79e3048..8d27ba9 100644 --- a/ton-http-api/tonlib_component.h +++ b/ton-http-api/src/components/tonlib_component.h @@ -1,7 +1,6 @@ #pragma once #include "tonlib-multiclient/multi_client.h" -#include "tonlib_postprocessor.h" -#include "tonlib_worker.h" +#include "core/tonlib_worker.h" #include "userver/clients/http/client.hpp" #include "userver/components/component_base.hpp" #include "userver/dynamic_config/source.hpp" @@ -16,6 +15,8 @@ class TonlibComponent final : public userver::components::ComponentBase { TonlibComponent(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); ~TonlibComponent() final = default; + multiclient::SessionPtr GetNewSession() const; + template auto DoRequest(Func&& func, Args&&... args) -> decltype(auto) { auto task = userver::utils::Async(task_processor_, "tonlib_request", [this, func, ...args = std::forward(args)] { @@ -32,23 +33,12 @@ class TonlibComponent final : public userver::components::ComponentBase { return task.Get(); } - template - auto DoPostprocess(Func&& func, Args&&... args) -> decltype(auto) { - return (this->postprocessor_.get()->*func)(std::forward(args)...); - } - - template - auto DoPostprocess(Func&& func) -> decltype(auto) { - return (this->worker_.get()->*func)(); - } - - bool SendBocToExternalRequest(std::string boc_b64); + bool SendBocToExternalRequest(const std::string& boc_b64) const; static userver::yaml_config::Schema GetStaticConfigSchema(); private: userver::dynamic_config::Source config_; std::unique_ptr worker_; - std::unique_ptr postprocessor_; userver::engine::TaskProcessor& task_processor_; std::vector external_message_endpoints_; userver::logging::LoggerPtr logger_; diff --git a/ton-http-api/src/converters/convert.hpp b/ton-http-api/src/converters/convert.hpp new file mode 100644 index 0000000..a98ccc3 --- /dev/null +++ b/ton-http-api/src/converters/convert.hpp @@ -0,0 +1,27 @@ +#pragma once +#include "auto/tl/tonlib_api.h" +#include "schemas/v2.hpp" + +namespace ton_http { +namespace converters { + +inline schemas::v2::TonBlockIdExt Convert(tonlib_api::object_ptr& value) { + schemas::v2::TonBlockIdExt result; + result.workchain = value->workchain_; + result.shard = types::shard_id{value->shard_}; + result.seqno = value->seqno_; + result.root_hash = types::ton_hash{value->root_hash_}; + result.file_hash = types::ton_hash{value->file_hash_}; + return result; +} + +inline schemas::v2::MasterchainInfoResult Convert(tonlib_api::blocks_getMasterchainInfo::ReturnType& value) { + schemas::v2::MasterchainInfoResult result; + result.init = Convert(value->init_); + result.last = Convert(value->last_); + result.state_root_hash = types::ton_hash{value->state_root_hash_}; + return result; +} + +} +} diff --git a/ton-http-api/src/core/tlb/tokens-tlb.cpp b/ton-http-api/src/core/tlb/tokens-tlb.cpp new file mode 100644 index 0000000..fd8bcf3 --- /dev/null +++ b/ton-http-api/src/core/tlb/tokens-tlb.cpp @@ -0,0 +1,3486 @@ +#include "tokens-tlb.h" +/* + * + * AUTO-GENERATED FROM `/Users/ruslixag/Developer/ton-workspace/ton-http-api-cpp/ton-http-api/tlb/tokens.tlb` + * + */ +// uses built-in type `##` +// uses built-in type `#<` +// uses built-in type `#<=` +// uses built-in type `Cell` +// uses built-in type `uint` +// uses built-in type `bits` +// uses built-in type `int8` +// uses built-in type `int32` +// uses built-in type `uint64` +// uses built-in type `bits256` + +namespace tokens { + +namespace gen { +using namespace ::tlb; +using td::Ref; +using vm::CellSlice; +using vm::Cell; +using td::RefInt256; + +// +// code for type `Maybe` +// + +int Maybe::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case nothing: + return cs.have(1) ? nothing : -1; + case just: + return cs.have(1) ? just : -1; + } + return -1; +} + +bool Maybe::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case nothing: + return cs.advance(1); + case just: + return cs.advance(1) + && X_.skip(cs); + } + return false; +} + +bool Maybe::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case nothing: + return cs.advance(1); + case just: + return cs.advance(1) + && X_.validate_skip(ops, cs, weak); + } + return false; +} + +bool Maybe::unpack(vm::CellSlice& cs, Maybe::Record_nothing& data) const { + return cs.fetch_ulong(1) == 0; +} + +bool Maybe::unpack_nothing(vm::CellSlice& cs) const { + return cs.fetch_ulong(1) == 0; +} + +bool Maybe::cell_unpack(Ref cell_ref, Maybe::Record_nothing& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Maybe::cell_unpack_nothing(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_nothing(cs) && cs.empty_ext(); +} + +bool Maybe::unpack(vm::CellSlice& cs, Maybe::Record_just& data) const { + return cs.fetch_ulong(1) == 1 + && X_.fetch_to(cs, data.value); +} + +bool Maybe::unpack_just(vm::CellSlice& cs, Ref& value) const { + return cs.fetch_ulong(1) == 1 + && X_.fetch_to(cs, value); +} + +bool Maybe::cell_unpack(Ref cell_ref, Maybe::Record_just& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Maybe::cell_unpack_just(Ref cell_ref, Ref& value) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_just(cs, value) && cs.empty_ext(); +} + +bool Maybe::pack(vm::CellBuilder& cb, const Maybe::Record_nothing& data) const { + return cb.store_long_bool(0, 1); +} + +bool Maybe::pack_nothing(vm::CellBuilder& cb) const { + return cb.store_long_bool(0, 1); +} + +bool Maybe::cell_pack(Ref& cell_ref, const Maybe::Record_nothing& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Maybe::cell_pack_nothing(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_nothing(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool Maybe::pack(vm::CellBuilder& cb, const Maybe::Record_just& data) const { + return cb.store_long_bool(1, 1) + && X_.store_from(cb, data.value); +} + +bool Maybe::pack_just(vm::CellBuilder& cb, Ref value) const { + return cb.store_long_bool(1, 1) + && X_.store_from(cb, value); +} + +bool Maybe::cell_pack(Ref& cell_ref, const Maybe::Record_just& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Maybe::cell_pack_just(Ref& cell_ref, Ref value) const { + vm::CellBuilder cb; + return pack_just(cb, std::move(value)) && std::move(cb).finalize_to(cell_ref); +} + +bool Maybe::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case nothing: + return cs.advance(1) + && pp.cons("nothing"); + case just: + return cs.advance(1) + && pp.open("just") + && pp.field("value") + && X_.print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for Maybe"); +} + + +// +// code for type `Either` +// + +int Either::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case left: + return cs.have(1) ? left : -1; + case right: + return cs.have(1) ? right : -1; + } + return -1; +} + +bool Either::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case left: + return cs.advance(1) + && X_.skip(cs); + case right: + return cs.advance(1) + && Y_.skip(cs); + } + return false; +} + +bool Either::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case left: + return cs.advance(1) + && X_.validate_skip(ops, cs, weak); + case right: + return cs.advance(1) + && Y_.validate_skip(ops, cs, weak); + } + return false; +} + +bool Either::unpack(vm::CellSlice& cs, Either::Record_left& data) const { + return cs.fetch_ulong(1) == 0 + && X_.fetch_to(cs, data.value); +} + +bool Either::unpack_left(vm::CellSlice& cs, Ref& value) const { + return cs.fetch_ulong(1) == 0 + && X_.fetch_to(cs, value); +} + +bool Either::cell_unpack(Ref cell_ref, Either::Record_left& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Either::cell_unpack_left(Ref cell_ref, Ref& value) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_left(cs, value) && cs.empty_ext(); +} + +bool Either::unpack(vm::CellSlice& cs, Either::Record_right& data) const { + return cs.fetch_ulong(1) == 1 + && Y_.fetch_to(cs, data.value); +} + +bool Either::unpack_right(vm::CellSlice& cs, Ref& value) const { + return cs.fetch_ulong(1) == 1 + && Y_.fetch_to(cs, value); +} + +bool Either::cell_unpack(Ref cell_ref, Either::Record_right& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Either::cell_unpack_right(Ref cell_ref, Ref& value) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_right(cs, value) && cs.empty_ext(); +} + +bool Either::pack(vm::CellBuilder& cb, const Either::Record_left& data) const { + return cb.store_long_bool(0, 1) + && X_.store_from(cb, data.value); +} + +bool Either::pack_left(vm::CellBuilder& cb, Ref value) const { + return cb.store_long_bool(0, 1) + && X_.store_from(cb, value); +} + +bool Either::cell_pack(Ref& cell_ref, const Either::Record_left& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Either::cell_pack_left(Ref& cell_ref, Ref value) const { + vm::CellBuilder cb; + return pack_left(cb, std::move(value)) && std::move(cb).finalize_to(cell_ref); +} + +bool Either::pack(vm::CellBuilder& cb, const Either::Record_right& data) const { + return cb.store_long_bool(1, 1) + && Y_.store_from(cb, data.value); +} + +bool Either::pack_right(vm::CellBuilder& cb, Ref value) const { + return cb.store_long_bool(1, 1) + && Y_.store_from(cb, value); +} + +bool Either::cell_pack(Ref& cell_ref, const Either::Record_right& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Either::cell_pack_right(Ref& cell_ref, Ref value) const { + vm::CellBuilder cb; + return pack_right(cb, std::move(value)) && std::move(cb).finalize_to(cell_ref); +} + +bool Either::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case left: + return cs.advance(1) + && pp.open("left") + && pp.field("value") + && X_.print_skip(pp, cs) + && pp.close(); + case right: + return cs.advance(1) + && pp.open("right") + && pp.field("value") + && Y_.print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for Either"); +} + + +// +// code for type `VarUInteger` +// + +int VarUInteger::check_tag(const vm::CellSlice& cs) const { + return var_uint; +} + +bool VarUInteger::skip(vm::CellSlice& cs) const { + int len; + return cs.fetch_uint_less(m_, len) + && cs.advance(8 * len); +} + +bool VarUInteger::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + int len; + return cs.fetch_uint_less(m_, len) + && cs.advance(8 * len); +} + +bool VarUInteger::unpack(vm::CellSlice& cs, VarUInteger::Record& data) const { + return (data.n = m_) >= 0 + && cs.fetch_uint_less(m_, data.len) + && cs.fetch_uint256_to(8 * data.len, data.value); +} + +bool VarUInteger::unpack_var_uint(vm::CellSlice& cs, int& n, int& len, RefInt256& value) const { + return (n = m_) >= 0 + && cs.fetch_uint_less(m_, len) + && cs.fetch_uint256_to(8 * len, value); +} + +bool VarUInteger::cell_unpack(Ref cell_ref, VarUInteger::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool VarUInteger::cell_unpack_var_uint(Ref cell_ref, int& n, int& len, RefInt256& value) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_var_uint(cs, n, len, value) && cs.empty_ext(); +} + +bool VarUInteger::pack(vm::CellBuilder& cb, const VarUInteger::Record& data) const { + return cb.store_uint_less(m_, data.len) + && cb.store_int256_bool(data.value, 8 * data.len, false); +} + +bool VarUInteger::pack_var_uint(vm::CellBuilder& cb, int len, RefInt256 value) const { + return cb.store_uint_less(m_, len) + && cb.store_int256_bool(value, 8 * len, false); +} + +bool VarUInteger::cell_pack(Ref& cell_ref, const VarUInteger::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool VarUInteger::cell_pack_var_uint(Ref& cell_ref, int len, RefInt256 value) const { + vm::CellBuilder cb; + return pack_var_uint(cb, len, std::move(value)) && std::move(cb).finalize_to(cell_ref); +} + +bool VarUInteger::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + int len; + return pp.open("var_uint") + && cs.fetch_uint_less(m_, len) + && pp.field_int(len, "len") + && pp.fetch_uint256_field(cs, 8 * len, "value") + && pp.close(); +} + + +// +// code for type `MsgAddressExt` +// + +int MsgAddressExt::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case addr_none: + return cs.have(2) ? addr_none : -1; + case addr_extern: + return cs.prefetch_ulong(2) == 1 ? addr_extern : -1; + } + return -1; +} + +bool MsgAddressExt::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case addr_none: + return cs.advance(2); + case addr_extern: { + int len; + return cs.advance(2) + && cs.fetch_uint_to(9, len) + && cs.advance(len); + } + } + return false; +} + +bool MsgAddressExt::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case addr_none: + return cs.advance(2); + case addr_extern: { + int len; + return cs.fetch_ulong(2) == 1 + && cs.fetch_uint_to(9, len) + && cs.advance(len); + } + } + return false; +} + +bool MsgAddressExt::unpack(vm::CellSlice& cs, MsgAddressExt::Record_addr_none& data) const { + return cs.fetch_ulong(2) == 0; +} + +bool MsgAddressExt::unpack_addr_none(vm::CellSlice& cs) const { + return cs.fetch_ulong(2) == 0; +} + +bool MsgAddressExt::cell_unpack(Ref cell_ref, MsgAddressExt::Record_addr_none& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool MsgAddressExt::cell_unpack_addr_none(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_addr_none(cs) && cs.empty_ext(); +} + +bool MsgAddressExt::unpack(vm::CellSlice& cs, MsgAddressExt::Record_addr_extern& data) const { + return cs.fetch_ulong(2) == 1 + && cs.fetch_uint_to(9, data.len) + && cs.fetch_bitstring_to(data.len, data.external_address); +} + +bool MsgAddressExt::unpack_addr_extern(vm::CellSlice& cs, int& len, Ref& external_address) const { + return cs.fetch_ulong(2) == 1 + && cs.fetch_uint_to(9, len) + && cs.fetch_bitstring_to(len, external_address); +} + +bool MsgAddressExt::cell_unpack(Ref cell_ref, MsgAddressExt::Record_addr_extern& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool MsgAddressExt::cell_unpack_addr_extern(Ref cell_ref, int& len, Ref& external_address) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_addr_extern(cs, len, external_address) && cs.empty_ext(); +} + +bool MsgAddressExt::pack(vm::CellBuilder& cb, const MsgAddressExt::Record_addr_none& data) const { + return cb.store_long_bool(0, 2); +} + +bool MsgAddressExt::pack_addr_none(vm::CellBuilder& cb) const { + return cb.store_long_bool(0, 2); +} + +bool MsgAddressExt::cell_pack(Ref& cell_ref, const MsgAddressExt::Record_addr_none& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressExt::cell_pack_addr_none(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_addr_none(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressExt::pack(vm::CellBuilder& cb, const MsgAddressExt::Record_addr_extern& data) const { + return cb.store_long_bool(1, 2) + && cb.store_ulong_rchk_bool(data.len, 9) + && cb.append_bitstring_chk(data.external_address, data.len); +} + +bool MsgAddressExt::pack_addr_extern(vm::CellBuilder& cb, int len, Ref external_address) const { + return cb.store_long_bool(1, 2) + && cb.store_ulong_rchk_bool(len, 9) + && cb.append_bitstring_chk(external_address, len); +} + +bool MsgAddressExt::cell_pack(Ref& cell_ref, const MsgAddressExt::Record_addr_extern& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressExt::cell_pack_addr_extern(Ref& cell_ref, int len, Ref external_address) const { + vm::CellBuilder cb; + return pack_addr_extern(cb, len, std::move(external_address)) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressExt::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case addr_none: + return cs.advance(2) + && pp.cons("addr_none"); + case addr_extern: { + int len; + return cs.fetch_ulong(2) == 1 + && pp.open("addr_extern") + && cs.fetch_uint_to(9, len) + && pp.field_int(len, "len") + && pp.fetch_bits_field(cs, len, "external_address") + && pp.close(); + } + } + return pp.fail("unknown constructor for MsgAddressExt"); +} + +const MsgAddressExt t_MsgAddressExt; + +// +// code for type `Anycast` +// + +int Anycast::check_tag(const vm::CellSlice& cs) const { + return anycast_info; +} + +bool Anycast::skip(vm::CellSlice& cs) const { + int depth; + return cs.fetch_uint_leq(30, depth) + && 1 <= depth + && cs.advance(depth); +} + +bool Anycast::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + int depth; + return cs.fetch_uint_leq(30, depth) + && 1 <= depth + && cs.advance(depth); +} + +bool Anycast::unpack(vm::CellSlice& cs, Anycast::Record& data) const { + return cs.fetch_uint_leq(30, data.depth) + && 1 <= data.depth + && cs.fetch_bitstring_to(data.depth, data.rewrite_pfx); +} + +bool Anycast::unpack_anycast_info(vm::CellSlice& cs, int& depth, Ref& rewrite_pfx) const { + return cs.fetch_uint_leq(30, depth) + && 1 <= depth + && cs.fetch_bitstring_to(depth, rewrite_pfx); +} + +bool Anycast::cell_unpack(Ref cell_ref, Anycast::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Anycast::cell_unpack_anycast_info(Ref cell_ref, int& depth, Ref& rewrite_pfx) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_anycast_info(cs, depth, rewrite_pfx) && cs.empty_ext(); +} + +bool Anycast::pack(vm::CellBuilder& cb, const Anycast::Record& data) const { + return cb.store_uint_leq(30, data.depth) + && 1 <= data.depth + && cb.append_bitstring_chk(data.rewrite_pfx, data.depth); +} + +bool Anycast::pack_anycast_info(vm::CellBuilder& cb, int depth, Ref rewrite_pfx) const { + return cb.store_uint_leq(30, depth) + && 1 <= depth + && cb.append_bitstring_chk(rewrite_pfx, depth); +} + +bool Anycast::cell_pack(Ref& cell_ref, const Anycast::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Anycast::cell_pack_anycast_info(Ref& cell_ref, int depth, Ref rewrite_pfx) const { + vm::CellBuilder cb; + return pack_anycast_info(cb, depth, std::move(rewrite_pfx)) && std::move(cb).finalize_to(cell_ref); +} + +bool Anycast::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + int depth; + return pp.open("anycast_info") + && cs.fetch_uint_leq(30, depth) + && pp.field_int(depth, "depth") + && 1 <= depth + && pp.fetch_bits_field(cs, depth, "rewrite_pfx") + && pp.close(); +} + +const Anycast t_Anycast; + +// +// code for type `MsgAddressInt` +// +constexpr unsigned char MsgAddressInt::cons_tag[2]; + +int MsgAddressInt::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case addr_std: + return cs.have(2) ? addr_std : -1; + case addr_var: + return cs.have(2) ? addr_var : -1; + } + return -1; +} + +bool MsgAddressInt::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case addr_std: + return cs.advance(2) + && t_Maybe_Anycast.skip(cs) + && cs.advance(264); + case addr_var: { + int addr_len; + return cs.advance(2) + && t_Maybe_Anycast.skip(cs) + && cs.fetch_uint_to(9, addr_len) + && cs.advance(32) + && cs.advance(addr_len); + } + } + return false; +} + +bool MsgAddressInt::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case addr_std: + return cs.advance(2) + && t_Maybe_Anycast.validate_skip(ops, cs, weak) + && cs.advance(264); + case addr_var: { + int addr_len; + return cs.advance(2) + && t_Maybe_Anycast.validate_skip(ops, cs, weak) + && cs.fetch_uint_to(9, addr_len) + && cs.advance(32) + && cs.advance(addr_len); + } + } + return false; +} + +bool MsgAddressInt::unpack(vm::CellSlice& cs, MsgAddressInt::Record_addr_std& data) const { + return cs.fetch_ulong(2) == 2 + && t_Maybe_Anycast.fetch_to(cs, data.anycast) + && cs.fetch_int_to(8, data.workchain_id) + && cs.fetch_bits_to(data.address.bits(), 256); +} + +bool MsgAddressInt::unpack_addr_std(vm::CellSlice& cs, Ref& anycast, int& workchain_id, td::BitArray<256>& address) const { + return cs.fetch_ulong(2) == 2 + && t_Maybe_Anycast.fetch_to(cs, anycast) + && cs.fetch_int_to(8, workchain_id) + && cs.fetch_bits_to(address.bits(), 256); +} + +bool MsgAddressInt::cell_unpack(Ref cell_ref, MsgAddressInt::Record_addr_std& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool MsgAddressInt::cell_unpack_addr_std(Ref cell_ref, Ref& anycast, int& workchain_id, td::BitArray<256>& address) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_addr_std(cs, anycast, workchain_id, address) && cs.empty_ext(); +} + +bool MsgAddressInt::unpack(vm::CellSlice& cs, MsgAddressInt::Record_addr_var& data) const { + return cs.fetch_ulong(2) == 3 + && t_Maybe_Anycast.fetch_to(cs, data.anycast) + && cs.fetch_uint_to(9, data.addr_len) + && cs.fetch_int_to(32, data.workchain_id) + && cs.fetch_bitstring_to(data.addr_len, data.address); +} + +bool MsgAddressInt::cell_unpack(Ref cell_ref, MsgAddressInt::Record_addr_var& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool MsgAddressInt::pack(vm::CellBuilder& cb, const MsgAddressInt::Record_addr_std& data) const { + return cb.store_long_bool(2, 2) + && t_Maybe_Anycast.store_from(cb, data.anycast) + && cb.store_long_rchk_bool(data.workchain_id, 8) + && cb.store_bits_bool(data.address.cbits(), 256); +} + +bool MsgAddressInt::pack_addr_std(vm::CellBuilder& cb, Ref anycast, int workchain_id, td::BitArray<256> address) const { + return cb.store_long_bool(2, 2) + && t_Maybe_Anycast.store_from(cb, anycast) + && cb.store_long_rchk_bool(workchain_id, 8) + && cb.store_bits_bool(address.cbits(), 256); +} + +bool MsgAddressInt::cell_pack(Ref& cell_ref, const MsgAddressInt::Record_addr_std& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressInt::cell_pack_addr_std(Ref& cell_ref, Ref anycast, int workchain_id, td::BitArray<256> address) const { + vm::CellBuilder cb; + return pack_addr_std(cb, std::move(anycast), workchain_id, address) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressInt::pack(vm::CellBuilder& cb, const MsgAddressInt::Record_addr_var& data) const { + return cb.store_long_bool(3, 2) + && t_Maybe_Anycast.store_from(cb, data.anycast) + && cb.store_ulong_rchk_bool(data.addr_len, 9) + && cb.store_long_rchk_bool(data.workchain_id, 32) + && cb.append_bitstring_chk(data.address, data.addr_len); +} + +bool MsgAddressInt::cell_pack(Ref& cell_ref, const MsgAddressInt::Record_addr_var& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddressInt::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case addr_std: + return cs.advance(2) + && pp.open("addr_std") + && pp.field("anycast") + && t_Maybe_Anycast.print_skip(pp, cs) + && pp.fetch_int_field(cs, 8, "workchain_id") + && pp.fetch_bits_field(cs, 256, "address") + && pp.close(); + case addr_var: { + int addr_len; + return cs.advance(2) + && pp.open("addr_var") + && pp.field("anycast") + && t_Maybe_Anycast.print_skip(pp, cs) + && cs.fetch_uint_to(9, addr_len) + && pp.field_int(addr_len, "addr_len") + && pp.fetch_int_field(cs, 32, "workchain_id") + && pp.fetch_bits_field(cs, addr_len, "address") + && pp.close(); + } + } + return pp.fail("unknown constructor for MsgAddressInt"); +} + +const MsgAddressInt t_MsgAddressInt; + +// +// code for type `MsgAddress` +// + +int MsgAddress::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case cons1: + return cons1; + case cons2: + return cons2; + } + return -1; +} + +bool MsgAddress::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case cons1: + return t_MsgAddressInt.skip(cs); + case cons2: + return t_MsgAddressExt.skip(cs); + } + return false; +} + +bool MsgAddress::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case cons1: + return t_MsgAddressInt.validate_skip(ops, cs, weak); + case cons2: + return t_MsgAddressExt.validate_skip(ops, cs, weak); + } + return false; +} + +bool MsgAddress::unpack(vm::CellSlice& cs, MsgAddress::Record_cons1& data) const { + return t_MsgAddressInt.fetch_to(cs, data.x); +} + +bool MsgAddress::unpack_cons1(vm::CellSlice& cs, Ref& x) const { + return t_MsgAddressInt.fetch_to(cs, x); +} + +bool MsgAddress::cell_unpack(Ref cell_ref, MsgAddress::Record_cons1& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool MsgAddress::cell_unpack_cons1(Ref cell_ref, Ref& x) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_cons1(cs, x) && cs.empty_ext(); +} + +bool MsgAddress::unpack(vm::CellSlice& cs, MsgAddress::Record_cons2& data) const { + return t_MsgAddressExt.fetch_to(cs, data.x); +} + +bool MsgAddress::unpack_cons2(vm::CellSlice& cs, Ref& x) const { + return t_MsgAddressExt.fetch_to(cs, x); +} + +bool MsgAddress::cell_unpack(Ref cell_ref, MsgAddress::Record_cons2& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool MsgAddress::cell_unpack_cons2(Ref cell_ref, Ref& x) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_cons2(cs, x) && cs.empty_ext(); +} + +bool MsgAddress::pack(vm::CellBuilder& cb, const MsgAddress::Record_cons1& data) const { + return t_MsgAddressInt.store_from(cb, data.x); +} + +bool MsgAddress::pack_cons1(vm::CellBuilder& cb, Ref x) const { + return t_MsgAddressInt.store_from(cb, x); +} + +bool MsgAddress::cell_pack(Ref& cell_ref, const MsgAddress::Record_cons1& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddress::cell_pack_cons1(Ref& cell_ref, Ref x) const { + vm::CellBuilder cb; + return pack_cons1(cb, std::move(x)) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddress::pack(vm::CellBuilder& cb, const MsgAddress::Record_cons2& data) const { + return t_MsgAddressExt.store_from(cb, data.x); +} + +bool MsgAddress::pack_cons2(vm::CellBuilder& cb, Ref x) const { + return t_MsgAddressExt.store_from(cb, x); +} + +bool MsgAddress::cell_pack(Ref& cell_ref, const MsgAddress::Record_cons2& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddress::cell_pack_cons2(Ref& cell_ref, Ref x) const { + vm::CellBuilder cb; + return pack_cons2(cb, std::move(x)) && std::move(cb).finalize_to(cell_ref); +} + +bool MsgAddress::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case cons1: + return pp.open() + && pp.field() + && t_MsgAddressInt.print_skip(pp, cs) + && pp.close(); + case cons2: + return pp.open() + && pp.field() + && t_MsgAddressExt.print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for MsgAddress"); +} + +const MsgAddress t_MsgAddress; + +// +// code for type `InternalMsgBody` +// +constexpr unsigned InternalMsgBody::cons_tag[7]; + +int InternalMsgBody::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case transfer_jetton: + return cs.prefetch_ulong(32) == 0xf8a7ea5 ? transfer_jetton : -1; + case transfer_notification: + return cs.prefetch_ulong(32) == 0x7362d09c ? transfer_notification : -1; + case excesses: + return cs.prefetch_ulong(32) == 0xd53276dbU ? excesses : -1; + case burn: + return cs.prefetch_ulong(32) == 0x595f07bc ? burn : -1; + case transfer_nft: + return cs.prefetch_ulong(32) == 0x5fcc3d14 ? transfer_nft : -1; + case internal_transfer: + return cs.prefetch_ulong(32) == 0x978d4519U ? internal_transfer : -1; + case burn_notification: + return cs.prefetch_ulong(32) == 0x7bdd97de ? burn_notification : -1; + } + return -1; +} + +bool InternalMsgBody::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case transfer_jetton: + return cs.advance(96) + && t_VarUInteger_16.skip(cs) + && t_MsgAddress.skip(cs) + && t_MsgAddress.skip(cs) + && t_Maybe_Ref_Cell.skip(cs) + && t_VarUInteger_16.skip(cs) + && t_Either_Cell_Ref_Cell.skip(cs); + case transfer_notification: + return cs.advance(96) + && t_VarUInteger_16.skip(cs) + && t_MsgAddress.skip(cs) + && t_Either_Cell_Ref_Cell.skip(cs); + case excesses: + return cs.advance(96); + case burn: + return cs.advance(96) + && t_VarUInteger_16.skip(cs) + && t_MsgAddress.skip(cs) + && t_Maybe_Ref_Cell.skip(cs); + case transfer_nft: + return cs.advance(96) + && t_MsgAddress.skip(cs) + && t_MsgAddress.skip(cs) + && t_Maybe_Ref_Cell.skip(cs) + && t_VarUInteger_16.skip(cs) + && t_Either_Cell_Ref_Cell.skip(cs); + case internal_transfer: + return cs.advance(96) + && t_VarUInteger_16.skip(cs) + && t_MsgAddress.skip(cs) + && t_MsgAddress.skip(cs) + && t_VarUInteger_16.skip(cs) + && t_Either_Cell_Ref_Cell.skip(cs); + case burn_notification: + return cs.advance(96) + && t_VarUInteger_16.skip(cs) + && t_MsgAddress.skip(cs) + && t_MsgAddress.skip(cs); + } + return false; +} + +bool InternalMsgBody::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case transfer_jetton: + return cs.fetch_ulong(32) == 0xf8a7ea5 + && cs.advance(64) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_Maybe_Ref_Cell.validate_skip(ops, cs, weak) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_Either_Cell_Ref_Cell.validate_skip(ops, cs, weak); + case transfer_notification: + return cs.fetch_ulong(32) == 0x7362d09c + && cs.advance(64) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_Either_Cell_Ref_Cell.validate_skip(ops, cs, weak); + case excesses: + return cs.fetch_ulong(32) == 0xd53276dbU + && cs.advance(64); + case burn: + return cs.fetch_ulong(32) == 0x595f07bc + && cs.advance(64) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_Maybe_Ref_Cell.validate_skip(ops, cs, weak); + case transfer_nft: + return cs.fetch_ulong(32) == 0x5fcc3d14 + && cs.advance(64) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_Maybe_Ref_Cell.validate_skip(ops, cs, weak) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_Either_Cell_Ref_Cell.validate_skip(ops, cs, weak); + case internal_transfer: + return cs.fetch_ulong(32) == 0x978d4519U + && cs.advance(64) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_Either_Cell_Ref_Cell.validate_skip(ops, cs, weak); + case burn_notification: + return cs.fetch_ulong(32) == 0x7bdd97de + && cs.advance(64) + && t_VarUInteger_16.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak) + && t_MsgAddress.validate_skip(ops, cs, weak); + } + return false; +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_transfer_jetton& data) const { + return cs.fetch_ulong(32) == 0xf8a7ea5 + && cs.fetch_uint_to(64, data.query_id) + && t_VarUInteger_16.fetch_to(cs, data.amount) + && t_MsgAddress.fetch_to(cs, data.destination) + && t_MsgAddress.fetch_to(cs, data.response_destination) + && t_Maybe_Ref_Cell.fetch_to(cs, data.custom_payload) + && t_VarUInteger_16.fetch_to(cs, data.forward_ton_amount) + && t_Either_Cell_Ref_Cell.fetch_to(cs, data.forward_payload); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_transfer_jetton& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_transfer_notification& data) const { + return cs.fetch_ulong(32) == 0x7362d09c + && cs.fetch_uint_to(64, data.query_id) + && t_VarUInteger_16.fetch_to(cs, data.amount) + && t_MsgAddress.fetch_to(cs, data.sender) + && t_Either_Cell_Ref_Cell.fetch_to(cs, data.forward_payload); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_transfer_notification& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_excesses& data) const { + return cs.fetch_ulong(32) == 0xd53276dbU + && cs.fetch_uint_to(64, data.query_id); +} + +bool InternalMsgBody::unpack_excesses(vm::CellSlice& cs, unsigned long long& query_id) const { + return cs.fetch_ulong(32) == 0xd53276dbU + && cs.fetch_uint_to(64, query_id); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_excesses& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::cell_unpack_excesses(Ref cell_ref, unsigned long long& query_id) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_excesses(cs, query_id) && cs.empty_ext(); +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_burn& data) const { + return cs.fetch_ulong(32) == 0x595f07bc + && cs.fetch_uint_to(64, data.query_id) + && t_VarUInteger_16.fetch_to(cs, data.amount) + && t_MsgAddress.fetch_to(cs, data.response_destination) + && t_Maybe_Ref_Cell.fetch_to(cs, data.custom_payload); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_burn& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_transfer_nft& data) const { + return cs.fetch_ulong(32) == 0x5fcc3d14 + && cs.fetch_uint_to(64, data.query_id) + && t_MsgAddress.fetch_to(cs, data.new_owner) + && t_MsgAddress.fetch_to(cs, data.response_destination) + && t_Maybe_Ref_Cell.fetch_to(cs, data.custom_payload) + && t_VarUInteger_16.fetch_to(cs, data.forward_amount) + && t_Either_Cell_Ref_Cell.fetch_to(cs, data.forward_payload); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_transfer_nft& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_internal_transfer& data) const { + return cs.fetch_ulong(32) == 0x978d4519U + && cs.fetch_uint_to(64, data.query_id) + && t_VarUInteger_16.fetch_to(cs, data.amount) + && t_MsgAddress.fetch_to(cs, data.from) + && t_MsgAddress.fetch_to(cs, data.response_address) + && t_VarUInteger_16.fetch_to(cs, data.forward_ton_amount) + && t_Either_Cell_Ref_Cell.fetch_to(cs, data.forward_payload); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_internal_transfer& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::unpack(vm::CellSlice& cs, InternalMsgBody::Record_burn_notification& data) const { + return cs.fetch_ulong(32) == 0x7bdd97de + && cs.fetch_uint_to(64, data.query_id) + && t_VarUInteger_16.fetch_to(cs, data.amount) + && t_MsgAddress.fetch_to(cs, data.sender) + && t_MsgAddress.fetch_to(cs, data.response_destination); +} + +bool InternalMsgBody::cell_unpack(Ref cell_ref, InternalMsgBody::Record_burn_notification& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_transfer_jetton& data) const { + return cb.store_long_bool(0xf8a7ea5, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64) + && t_VarUInteger_16.store_from(cb, data.amount) + && t_MsgAddress.store_from(cb, data.destination) + && t_MsgAddress.store_from(cb, data.response_destination) + && t_Maybe_Ref_Cell.store_from(cb, data.custom_payload) + && t_VarUInteger_16.store_from(cb, data.forward_ton_amount) + && t_Either_Cell_Ref_Cell.store_from(cb, data.forward_payload); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_transfer_jetton& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_transfer_notification& data) const { + return cb.store_long_bool(0x7362d09c, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64) + && t_VarUInteger_16.store_from(cb, data.amount) + && t_MsgAddress.store_from(cb, data.sender) + && t_Either_Cell_Ref_Cell.store_from(cb, data.forward_payload); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_transfer_notification& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_excesses& data) const { + return cb.store_long_bool(0xd53276dbU, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64); +} + +bool InternalMsgBody::pack_excesses(vm::CellBuilder& cb, unsigned long long query_id) const { + return cb.store_long_bool(0xd53276dbU, 32) + && cb.store_ulong_rchk_bool(query_id, 64); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_excesses& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::cell_pack_excesses(Ref& cell_ref, unsigned long long query_id) const { + vm::CellBuilder cb; + return pack_excesses(cb, query_id) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_burn& data) const { + return cb.store_long_bool(0x595f07bc, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64) + && t_VarUInteger_16.store_from(cb, data.amount) + && t_MsgAddress.store_from(cb, data.response_destination) + && t_Maybe_Ref_Cell.store_from(cb, data.custom_payload); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_burn& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_transfer_nft& data) const { + return cb.store_long_bool(0x5fcc3d14, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64) + && t_MsgAddress.store_from(cb, data.new_owner) + && t_MsgAddress.store_from(cb, data.response_destination) + && t_Maybe_Ref_Cell.store_from(cb, data.custom_payload) + && t_VarUInteger_16.store_from(cb, data.forward_amount) + && t_Either_Cell_Ref_Cell.store_from(cb, data.forward_payload); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_transfer_nft& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_internal_transfer& data) const { + return cb.store_long_bool(0x978d4519U, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64) + && t_VarUInteger_16.store_from(cb, data.amount) + && t_MsgAddress.store_from(cb, data.from) + && t_MsgAddress.store_from(cb, data.response_address) + && t_VarUInteger_16.store_from(cb, data.forward_ton_amount) + && t_Either_Cell_Ref_Cell.store_from(cb, data.forward_payload); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_internal_transfer& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::pack(vm::CellBuilder& cb, const InternalMsgBody::Record_burn_notification& data) const { + return cb.store_long_bool(0x7bdd97de, 32) + && cb.store_ulong_rchk_bool(data.query_id, 64) + && t_VarUInteger_16.store_from(cb, data.amount) + && t_MsgAddress.store_from(cb, data.sender) + && t_MsgAddress.store_from(cb, data.response_destination); +} + +bool InternalMsgBody::cell_pack(Ref& cell_ref, const InternalMsgBody::Record_burn_notification& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool InternalMsgBody::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case transfer_jetton: + return cs.fetch_ulong(32) == 0xf8a7ea5 + && pp.open("transfer_jetton") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.field("amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("destination") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("response_destination") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("custom_payload") + && t_Maybe_Ref_Cell.print_skip(pp, cs) + && pp.field("forward_ton_amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("forward_payload") + && t_Either_Cell_Ref_Cell.print_skip(pp, cs) + && pp.close(); + case transfer_notification: + return cs.fetch_ulong(32) == 0x7362d09c + && pp.open("transfer_notification") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.field("amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("sender") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("forward_payload") + && t_Either_Cell_Ref_Cell.print_skip(pp, cs) + && pp.close(); + case excesses: + return cs.fetch_ulong(32) == 0xd53276dbU + && pp.open("excesses") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.close(); + case burn: + return cs.fetch_ulong(32) == 0x595f07bc + && pp.open("burn") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.field("amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("response_destination") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("custom_payload") + && t_Maybe_Ref_Cell.print_skip(pp, cs) + && pp.close(); + case transfer_nft: + return cs.fetch_ulong(32) == 0x5fcc3d14 + && pp.open("transfer_nft") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.field("new_owner") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("response_destination") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("custom_payload") + && t_Maybe_Ref_Cell.print_skip(pp, cs) + && pp.field("forward_amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("forward_payload") + && t_Either_Cell_Ref_Cell.print_skip(pp, cs) + && pp.close(); + case internal_transfer: + return cs.fetch_ulong(32) == 0x978d4519U + && pp.open("internal_transfer") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.field("amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("from") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("response_address") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("forward_ton_amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("forward_payload") + && t_Either_Cell_Ref_Cell.print_skip(pp, cs) + && pp.close(); + case burn_notification: + return cs.fetch_ulong(32) == 0x7bdd97de + && pp.open("burn_notification") + && pp.fetch_uint_field(cs, 64, "query_id") + && pp.field("amount") + && t_VarUInteger_16.print_skip(pp, cs) + && pp.field("sender") + && t_MsgAddress.print_skip(pp, cs) + && pp.field("response_destination") + && t_MsgAddress.print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for InternalMsgBody"); +} + +const InternalMsgBody t_InternalMsgBody; + +// +// code for type `Bit` +// + +int Bit::check_tag(const vm::CellSlice& cs) const { + return bit; +} + +bool Bit::unpack(vm::CellSlice& cs, Bit::Record& data) const { + return cs.fetch_bool_to(data.x); +} + +bool Bit::unpack_bit(vm::CellSlice& cs, bool& x) const { + return cs.fetch_bool_to(x); +} + +bool Bit::cell_unpack(Ref cell_ref, Bit::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Bit::cell_unpack_bit(Ref cell_ref, bool& x) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_bit(cs, x) && cs.empty_ext(); +} + +bool Bit::pack(vm::CellBuilder& cb, const Bit::Record& data) const { + return cb.store_ulong_rchk_bool(data.x, 1); +} + +bool Bit::pack_bit(vm::CellBuilder& cb, bool x) const { + return cb.store_ulong_rchk_bool(x, 1); +} + +bool Bit::cell_pack(Ref& cell_ref, const Bit::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Bit::cell_pack_bit(Ref& cell_ref, bool x) const { + vm::CellBuilder cb; + return pack_bit(cb, x) && std::move(cb).finalize_to(cell_ref); +} + +bool Bit::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + int t1; + return pp.open("bit") + && cs.fetch_bool_to(t1) + && pp.field_int(t1) + && pp.close(); +} + +const Bit t_Bit; + +// +// code for type `Hashmap` +// + +int Hashmap::check_tag(const vm::CellSlice& cs) const { + return hm_edge; +} + +bool Hashmap::skip(vm::CellSlice& cs) const { + int l, m; + return HmLabel{m_}.skip(cs, l) + && add_r1(m, l, m_) + && HashmapNode{m, X_}.skip(cs); +} + +bool Hashmap::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + int l, m; + return HmLabel{m_}.validate_skip(ops, cs, weak, l) + && add_r1(m, l, m_) + && HashmapNode{m, X_}.validate_skip(ops, cs, weak); +} + +bool Hashmap::unpack(vm::CellSlice& cs, Hashmap::Record& data) const { + return (data.n = m_) >= 0 + && HmLabel{m_}.fetch_to(cs, data.label, data.l) + && add_r1(data.m, data.l, m_) + && HashmapNode{data.m, X_}.fetch_to(cs, data.node); +} + +bool Hashmap::cell_unpack(Ref cell_ref, Hashmap::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Hashmap::pack(vm::CellBuilder& cb, const Hashmap::Record& data) const { + int l, m; + return tlb::store_from(cb, HmLabel{m_}, data.label, l) + && add_r1(m, l, m_) + && HashmapNode{m, X_}.store_from(cb, data.node); +} + +bool Hashmap::cell_pack(Ref& cell_ref, const Hashmap::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Hashmap::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + int l, m; + return pp.open("hm_edge") + && pp.field("label") + && HmLabel{m_}.print_skip(pp, cs, l) + && add_r1(m, l, m_) + && pp.field("node") + && HashmapNode{m, X_}.print_skip(pp, cs) + && pp.close(); +} + + +// +// code for type `HashmapNode` +// + +int HashmapNode::get_tag(const vm::CellSlice& cs) const { + // distinguish by parameter `m_` using 1 2 2 2 + return m_ ? hmn_fork : hmn_leaf; +} + +int HashmapNode::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hmn_leaf: + return hmn_leaf; + case hmn_fork: + return hmn_fork; + } + return -1; +} + +bool HashmapNode::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hmn_leaf: + return m_ == 0 + && X_.skip(cs); + case hmn_fork: { + int n; + return add_r1(n, 1, m_) + && cs.advance_refs(2); + } + } + return false; +} + +bool HashmapNode::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case hmn_leaf: + return m_ == 0 + && X_.validate_skip(ops, cs, weak); + case hmn_fork: { + int n; + return add_r1(n, 1, m_) + && Hashmap{n, X_}.validate_skip_ref(ops, cs, weak) + && Hashmap{n, X_}.validate_skip_ref(ops, cs, weak); + } + } + return false; +} + +bool HashmapNode::unpack(vm::CellSlice& cs, HashmapNode::Record_hmn_leaf& data) const { + return m_ == 0 + && X_.fetch_to(cs, data.value); +} + +bool HashmapNode::unpack_hmn_leaf(vm::CellSlice& cs, Ref& value) const { + return m_ == 0 + && X_.fetch_to(cs, value); +} + +bool HashmapNode::cell_unpack(Ref cell_ref, HashmapNode::Record_hmn_leaf& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool HashmapNode::cell_unpack_hmn_leaf(Ref cell_ref, Ref& value) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_hmn_leaf(cs, value) && cs.empty_ext(); +} + +bool HashmapNode::unpack(vm::CellSlice& cs, HashmapNode::Record_hmn_fork& data) const { + return add_r1(data.n, 1, m_) + && cs.fetch_ref_to(data.left) + && cs.fetch_ref_to(data.right); +} + +bool HashmapNode::unpack_hmn_fork(vm::CellSlice& cs, int& n, Ref& left, Ref& right) const { + return add_r1(n, 1, m_) + && cs.fetch_ref_to(left) + && cs.fetch_ref_to(right); +} + +bool HashmapNode::cell_unpack(Ref cell_ref, HashmapNode::Record_hmn_fork& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool HashmapNode::cell_unpack_hmn_fork(Ref cell_ref, int& n, Ref& left, Ref& right) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_hmn_fork(cs, n, left, right) && cs.empty_ext(); +} + +bool HashmapNode::pack(vm::CellBuilder& cb, const HashmapNode::Record_hmn_leaf& data) const { + return m_ == 0 + && X_.store_from(cb, data.value); +} + +bool HashmapNode::pack_hmn_leaf(vm::CellBuilder& cb, Ref value) const { + return m_ == 0 + && X_.store_from(cb, value); +} + +bool HashmapNode::cell_pack(Ref& cell_ref, const HashmapNode::Record_hmn_leaf& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapNode::cell_pack_hmn_leaf(Ref& cell_ref, Ref value) const { + vm::CellBuilder cb; + return pack_hmn_leaf(cb, std::move(value)) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapNode::pack(vm::CellBuilder& cb, const HashmapNode::Record_hmn_fork& data) const { + int n; + return add_r1(n, 1, m_) + && cb.store_ref_bool(data.left) + && cb.store_ref_bool(data.right); +} + +bool HashmapNode::pack_hmn_fork(vm::CellBuilder& cb, Ref left, Ref right) const { + int n; + return add_r1(n, 1, m_) + && cb.store_ref_bool(left) + && cb.store_ref_bool(right); +} + +bool HashmapNode::cell_pack(Ref& cell_ref, const HashmapNode::Record_hmn_fork& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapNode::cell_pack_hmn_fork(Ref& cell_ref, Ref left, Ref right) const { + vm::CellBuilder cb; + return pack_hmn_fork(cb, std::move(left), std::move(right)) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapNode::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hmn_leaf: + return pp.open("hmn_leaf") + && m_ == 0 + && pp.field("value") + && X_.print_skip(pp, cs) + && pp.close(); + case hmn_fork: { + int n; + return pp.open("hmn_fork") + && add_r1(n, 1, m_) + && pp.field("left") + && Hashmap{n, X_}.print_ref(pp, cs.fetch_ref()) + && pp.field("right") + && Hashmap{n, X_}.print_ref(pp, cs.fetch_ref()) + && pp.close(); + } + } + return pp.fail("unknown constructor for HashmapNode"); +} + + +// +// code for type `HmLabel` +// +constexpr char HmLabel::cons_len[3]; +constexpr unsigned char HmLabel::cons_tag[3]; + +int HmLabel::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hml_short: + return cs.have(1) ? hml_short : -1; + case hml_long: + return cs.have(2) ? hml_long : -1; + case hml_same: + return cs.have(2) ? hml_same : -1; + } + return -1; +} + +bool HmLabel::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hml_short: { + int m_; + return cs.advance(1) + && t_Unary.skip(cs, m_) + && m_ <= n_ + && cs.advance(m_); + } + case hml_long: { + int m_; + return cs.advance(2) + && cs.fetch_uint_leq(n_, m_) + && cs.advance(m_); + } + case hml_same: { + int m_; + return cs.advance(3) + && cs.fetch_uint_leq(n_, m_); + } + } + return false; +} + +bool HmLabel::skip(vm::CellSlice& cs, int& m_) const { + switch (get_tag(cs)) { + case hml_short: + return cs.advance(1) + && t_Unary.skip(cs, m_) + && m_ <= n_ + && cs.advance(m_); + case hml_long: + return cs.advance(2) + && cs.fetch_uint_leq(n_, m_) + && cs.advance(m_); + case hml_same: + return cs.advance(3) + && cs.fetch_uint_leq(n_, m_); + } + return false; +} + +bool HmLabel::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case hml_short: { + int m_; + return cs.advance(1) + && t_Unary.validate_skip(ops, cs, weak, m_) + && m_ <= n_ + && cs.advance(m_); + } + case hml_long: { + int m_; + return cs.advance(2) + && cs.fetch_uint_leq(n_, m_) + && cs.advance(m_); + } + case hml_same: { + int m_; + return cs.advance(3) + && cs.fetch_uint_leq(n_, m_); + } + } + return false; +} + +bool HmLabel::validate_skip(int* ops, vm::CellSlice& cs, bool weak, int& m_) const { + switch (get_tag(cs)) { + case hml_short: + return cs.advance(1) + && t_Unary.validate_skip(ops, cs, weak, m_) + && m_ <= n_ + && cs.advance(m_); + case hml_long: + return cs.advance(2) + && cs.fetch_uint_leq(n_, m_) + && cs.advance(m_); + case hml_same: + return cs.advance(3) + && cs.fetch_uint_leq(n_, m_); + } + return false; +} + +bool HmLabel::fetch_to(vm::CellSlice& cs, Ref& res, int& m_) const { + res = Ref{true, cs}; + return skip(cs, m_) && res.unique_write().cut_tail(cs); +} + +bool HmLabel::unpack(vm::CellSlice& cs, HmLabel::Record_hml_short& data, int& m_) const { + return cs.fetch_ulong(1) == 0 + && (data.m = n_) >= 0 + && t_Unary.fetch_to(cs, data.len, data.n) + && data.n <= n_ + && cs.fetch_bitstring_to(data.n, data.s) + && (m_ = data.n) >= 0; +} + +bool HmLabel::cell_unpack(Ref cell_ref, HmLabel::Record_hml_short& data, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data, m_) && cs.empty_ext(); +} + +bool HmLabel::unpack(vm::CellSlice& cs, HmLabel::Record_hml_long& data, int& m_) const { + return cs.fetch_ulong(2) == 2 + && (data.m = n_) >= 0 + && cs.fetch_uint_leq(n_, data.n) + && cs.fetch_bitstring_to(data.n, data.s) + && (m_ = data.n) >= 0; +} + +bool HmLabel::unpack_hml_long(vm::CellSlice& cs, int& m, int& n, Ref& s, int& m_) const { + return cs.fetch_ulong(2) == 2 + && (m = n_) >= 0 + && cs.fetch_uint_leq(n_, n) + && cs.fetch_bitstring_to(n, s) + && (m_ = n) >= 0; +} + +bool HmLabel::cell_unpack(Ref cell_ref, HmLabel::Record_hml_long& data, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data, m_) && cs.empty_ext(); +} + +bool HmLabel::cell_unpack_hml_long(Ref cell_ref, int& m, int& n, Ref& s, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_hml_long(cs, m, n, s, m_) && cs.empty_ext(); +} + +bool HmLabel::unpack(vm::CellSlice& cs, HmLabel::Record_hml_same& data, int& m_) const { + return cs.fetch_ulong(2) == 3 + && (data.m = n_) >= 0 + && cs.fetch_bool_to(data.v) + && cs.fetch_uint_leq(n_, data.n) + && (m_ = data.n) >= 0; +} + +bool HmLabel::unpack_hml_same(vm::CellSlice& cs, int& m, bool& v, int& n, int& m_) const { + return cs.fetch_ulong(2) == 3 + && (m = n_) >= 0 + && cs.fetch_bool_to(v) + && cs.fetch_uint_leq(n_, n) + && (m_ = n) >= 0; +} + +bool HmLabel::cell_unpack(Ref cell_ref, HmLabel::Record_hml_same& data, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data, m_) && cs.empty_ext(); +} + +bool HmLabel::cell_unpack_hml_same(Ref cell_ref, int& m, bool& v, int& n, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_hml_same(cs, m, v, n, m_) && cs.empty_ext(); +} + +bool HmLabel::pack(vm::CellBuilder& cb, const HmLabel::Record_hml_short& data, int& m_) const { + return cb.store_long_bool(0, 1) + && tlb::store_from(cb, t_Unary, data.len, m_) + && m_ <= n_ + && cb.append_bitstring_chk(data.s, m_); +} + +bool HmLabel::cell_pack(Ref& cell_ref, const HmLabel::Record_hml_short& data, int& m_) const { + vm::CellBuilder cb; + return pack(cb, data, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool HmLabel::pack(vm::CellBuilder& cb, const HmLabel::Record_hml_long& data, int& m_) const { + return cb.store_long_bool(2, 2) + && cb.store_uint_leq(n_, data.n) + && cb.append_bitstring_chk(data.s, data.n) + && (m_ = data.n) >= 0; +} + +bool HmLabel::pack_hml_long(vm::CellBuilder& cb, int n, Ref s, int& m_) const { + return cb.store_long_bool(2, 2) + && cb.store_uint_leq(n_, n) + && cb.append_bitstring_chk(s, n) + && (m_ = n) >= 0; +} + +bool HmLabel::cell_pack(Ref& cell_ref, const HmLabel::Record_hml_long& data, int& m_) const { + vm::CellBuilder cb; + return pack(cb, data, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool HmLabel::cell_pack_hml_long(Ref& cell_ref, int n, Ref s, int& m_) const { + vm::CellBuilder cb; + return pack_hml_long(cb, n, std::move(s), m_) && std::move(cb).finalize_to(cell_ref); +} + +bool HmLabel::pack(vm::CellBuilder& cb, const HmLabel::Record_hml_same& data, int& m_) const { + return cb.store_long_bool(3, 2) + && cb.store_ulong_rchk_bool(data.v, 1) + && cb.store_uint_leq(n_, data.n) + && (m_ = data.n) >= 0; +} + +bool HmLabel::pack_hml_same(vm::CellBuilder& cb, bool v, int n, int& m_) const { + return cb.store_long_bool(3, 2) + && cb.store_ulong_rchk_bool(v, 1) + && cb.store_uint_leq(n_, n) + && (m_ = n) >= 0; +} + +bool HmLabel::cell_pack(Ref& cell_ref, const HmLabel::Record_hml_same& data, int& m_) const { + vm::CellBuilder cb; + return pack(cb, data, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool HmLabel::cell_pack_hml_same(Ref& cell_ref, bool v, int n, int& m_) const { + vm::CellBuilder cb; + return pack_hml_same(cb, v, n, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool HmLabel::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hml_short: { + int m_; + return cs.advance(1) + && pp.open("hml_short") + && pp.field("len") + && t_Unary.print_skip(pp, cs, m_) + && m_ <= n_ + && pp.fetch_bits_field(cs, m_, "s") + && pp.close(); + } + case hml_long: { + int m_; + return cs.advance(2) + && pp.open("hml_long") + && cs.fetch_uint_leq(n_, m_) + && pp.field_int(m_, "n") + && pp.fetch_bits_field(cs, m_, "s") + && pp.close(); + } + case hml_same: { + int m_; + return cs.advance(2) + && pp.open("hml_same") + && pp.fetch_uint_field(cs, 1, "v") + && cs.fetch_uint_leq(n_, m_) + && pp.field_int(m_, "n") + && pp.close(); + } + } + return pp.fail("unknown constructor for HmLabel"); +} + +bool HmLabel::print_skip(PrettyPrinter& pp, vm::CellSlice& cs, int& m_) const { + switch (get_tag(cs)) { + case hml_short: + return cs.advance(1) + && pp.open("hml_short") + && pp.field("len") + && t_Unary.print_skip(pp, cs, m_) + && m_ <= n_ + && pp.fetch_bits_field(cs, m_, "s") + && pp.close(); + case hml_long: + return cs.advance(2) + && pp.open("hml_long") + && cs.fetch_uint_leq(n_, m_) + && pp.field_int(m_, "n") + && pp.fetch_bits_field(cs, m_, "s") + && pp.close(); + case hml_same: + return cs.advance(2) + && pp.open("hml_same") + && pp.fetch_uint_field(cs, 1, "v") + && cs.fetch_uint_leq(n_, m_) + && pp.field_int(m_, "n") + && pp.close(); + } + return pp.fail("unknown constructor for HmLabel"); +} + + +// +// code for type `Unary` +// + +int Unary::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case unary_zero: + return cs.have(1) ? unary_zero : -1; + case unary_succ: + return cs.have(1) ? unary_succ : -1; + } + return -1; +} + +bool Unary::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case unary_zero: + return cs.advance(1); + case unary_succ: { + int n; + return cs.advance(1) + && skip(cs, n); + } + } + return false; +} + +bool Unary::skip(vm::CellSlice& cs, int& m_) const { + switch (get_tag(cs)) { + case unary_zero: + return (m_ = 0) >= 0 + && cs.advance(1); + case unary_succ: { + int n; + return cs.advance(1) + && skip(cs, n) + && (m_ = n + 1) >= 0; + } + } + return false; +} + +bool Unary::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case unary_zero: + return cs.advance(1); + case unary_succ: { + int n; + return cs.advance(1) + && validate_skip(ops, cs, weak, n); + } + } + return false; +} + +bool Unary::validate_skip(int* ops, vm::CellSlice& cs, bool weak, int& m_) const { + switch (get_tag(cs)) { + case unary_zero: + return (m_ = 0) >= 0 + && cs.advance(1); + case unary_succ: { + int n; + return cs.advance(1) + && validate_skip(ops, cs, weak, n) + && (m_ = n + 1) >= 0; + } + } + return false; +} + +bool Unary::fetch_to(vm::CellSlice& cs, Ref& res, int& m_) const { + res = Ref{true, cs}; + return skip(cs, m_) && res.unique_write().cut_tail(cs); +} + +bool Unary::unpack(vm::CellSlice& cs, Unary::Record_unary_zero& data, int& m_) const { + return cs.fetch_ulong(1) == 0 + && (m_ = 0) >= 0; +} + +bool Unary::unpack_unary_zero(vm::CellSlice& cs, int& m_) const { + return cs.fetch_ulong(1) == 0 + && (m_ = 0) >= 0; +} + +bool Unary::cell_unpack(Ref cell_ref, Unary::Record_unary_zero& data, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data, m_) && cs.empty_ext(); +} + +bool Unary::cell_unpack_unary_zero(Ref cell_ref, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_unary_zero(cs, m_) && cs.empty_ext(); +} + +bool Unary::unpack(vm::CellSlice& cs, Unary::Record_unary_succ& data, int& m_) const { + return cs.fetch_ulong(1) == 1 + && fetch_to(cs, data.x, data.n) + && (m_ = data.n + 1) >= 0; +} + +bool Unary::unpack_unary_succ(vm::CellSlice& cs, int& n, Ref& x, int& m_) const { + return cs.fetch_ulong(1) == 1 + && fetch_to(cs, x, n) + && (m_ = n + 1) >= 0; +} + +bool Unary::cell_unpack(Ref cell_ref, Unary::Record_unary_succ& data, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data, m_) && cs.empty_ext(); +} + +bool Unary::cell_unpack_unary_succ(Ref cell_ref, int& n, Ref& x, int& m_) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_unary_succ(cs, n, x, m_) && cs.empty_ext(); +} + +bool Unary::pack(vm::CellBuilder& cb, const Unary::Record_unary_zero& data, int& m_) const { + return cb.store_long_bool(0, 1) + && (m_ = 0) >= 0; +} + +bool Unary::pack_unary_zero(vm::CellBuilder& cb, int& m_) const { + return cb.store_long_bool(0, 1) + && (m_ = 0) >= 0; +} + +bool Unary::cell_pack(Ref& cell_ref, const Unary::Record_unary_zero& data, int& m_) const { + vm::CellBuilder cb; + return pack(cb, data, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool Unary::cell_pack_unary_zero(Ref& cell_ref, int& m_) const { + vm::CellBuilder cb; + return pack_unary_zero(cb, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool Unary::pack(vm::CellBuilder& cb, const Unary::Record_unary_succ& data, int& m_) const { + int n; + return cb.store_long_bool(1, 1) + && tlb::store_from(cb, *this, data.x, n) + && (m_ = n + 1) >= 0; +} + +bool Unary::pack_unary_succ(vm::CellBuilder& cb, Ref x, int& m_) const { + int n; + return cb.store_long_bool(1, 1) + && tlb::store_from(cb, *this, x, n) + && (m_ = n + 1) >= 0; +} + +bool Unary::cell_pack(Ref& cell_ref, const Unary::Record_unary_succ& data, int& m_) const { + vm::CellBuilder cb; + return pack(cb, data, m_) && std::move(cb).finalize_to(cell_ref); +} + +bool Unary::cell_pack_unary_succ(Ref& cell_ref, Ref x, int& m_) const { + vm::CellBuilder cb; + return pack_unary_succ(cb, std::move(x), m_) && std::move(cb).finalize_to(cell_ref); +} + +bool Unary::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case unary_zero: + return cs.advance(1) + && pp.cons("unary_zero"); + case unary_succ: { + int n; + return cs.advance(1) + && pp.open("unary_succ") + && pp.field("x") + && print_skip(pp, cs, n) + && pp.close(); + } + } + return pp.fail("unknown constructor for Unary"); +} + +bool Unary::print_skip(PrettyPrinter& pp, vm::CellSlice& cs, int& m_) const { + switch (get_tag(cs)) { + case unary_zero: + return cs.advance(1) + && pp.cons("unary_zero") + && (m_ = 0) >= 0; + case unary_succ: { + int n; + return cs.advance(1) + && pp.open("unary_succ") + && pp.field("x") + && print_skip(pp, cs, n) + && (m_ = n + 1) >= 0 + && pp.close(); + } + } + return pp.fail("unknown constructor for Unary"); +} + +const Unary t_Unary; + +// +// code for type `HashmapE` +// + +int HashmapE::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hme_empty: + return cs.have(1) ? hme_empty : -1; + case hme_root: + return cs.have(1) ? hme_root : -1; + } + return -1; +} + +bool HashmapE::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hme_empty: + return cs.advance(1); + case hme_root: + return cs.advance_ext(0x10001); + } + return false; +} + +bool HashmapE::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case hme_empty: + return cs.advance(1); + case hme_root: + return cs.advance(1) + && Hashmap{m_, X_}.validate_skip_ref(ops, cs, weak); + } + return false; +} + +bool HashmapE::unpack(vm::CellSlice& cs, HashmapE::Record_hme_empty& data) const { + return cs.fetch_ulong(1) == 0; +} + +bool HashmapE::unpack_hme_empty(vm::CellSlice& cs) const { + return cs.fetch_ulong(1) == 0; +} + +bool HashmapE::cell_unpack(Ref cell_ref, HashmapE::Record_hme_empty& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool HashmapE::cell_unpack_hme_empty(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_hme_empty(cs) && cs.empty_ext(); +} + +bool HashmapE::unpack(vm::CellSlice& cs, HashmapE::Record_hme_root& data) const { + return cs.fetch_ulong(1) == 1 + && (data.n = m_) >= 0 + && cs.fetch_ref_to(data.root); +} + +bool HashmapE::unpack_hme_root(vm::CellSlice& cs, int& n, Ref& root) const { + return cs.fetch_ulong(1) == 1 + && (n = m_) >= 0 + && cs.fetch_ref_to(root); +} + +bool HashmapE::cell_unpack(Ref cell_ref, HashmapE::Record_hme_root& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool HashmapE::cell_unpack_hme_root(Ref cell_ref, int& n, Ref& root) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_hme_root(cs, n, root) && cs.empty_ext(); +} + +bool HashmapE::pack(vm::CellBuilder& cb, const HashmapE::Record_hme_empty& data) const { + return cb.store_long_bool(0, 1); +} + +bool HashmapE::pack_hme_empty(vm::CellBuilder& cb) const { + return cb.store_long_bool(0, 1); +} + +bool HashmapE::cell_pack(Ref& cell_ref, const HashmapE::Record_hme_empty& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapE::cell_pack_hme_empty(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_hme_empty(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapE::pack(vm::CellBuilder& cb, const HashmapE::Record_hme_root& data) const { + return cb.store_long_bool(1, 1) + && cb.store_ref_bool(data.root); +} + +bool HashmapE::pack_hme_root(vm::CellBuilder& cb, Ref root) const { + return cb.store_long_bool(1, 1) + && cb.store_ref_bool(root); +} + +bool HashmapE::cell_pack(Ref& cell_ref, const HashmapE::Record_hme_root& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapE::cell_pack_hme_root(Ref& cell_ref, Ref root) const { + vm::CellBuilder cb; + return pack_hme_root(cb, std::move(root)) && std::move(cb).finalize_to(cell_ref); +} + +bool HashmapE::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case hme_empty: + return cs.advance(1) + && pp.cons("hme_empty"); + case hme_root: + return cs.advance(1) + && pp.open("hme_root") + && pp.field("root") + && Hashmap{m_, X_}.print_ref(pp, cs.fetch_ref()) + && pp.close(); + } + return pp.fail("unknown constructor for HashmapE"); +} + + +// +// code for type `ChunkedData` +// + +int ChunkedData::check_tag(const vm::CellSlice& cs) const { + return chunked_data; +} + +bool ChunkedData::skip(vm::CellSlice& cs) const { + return t_HashmapE_32_Ref_Cell.skip(cs); +} + +bool ChunkedData::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + return t_HashmapE_32_Ref_Cell.validate_skip(ops, cs, weak); +} + +bool ChunkedData::unpack(vm::CellSlice& cs, ChunkedData::Record& data) const { + return t_HashmapE_32_Ref_Cell.fetch_to(cs, data.data); +} + +bool ChunkedData::unpack_chunked_data(vm::CellSlice& cs, Ref& data) const { + return t_HashmapE_32_Ref_Cell.fetch_to(cs, data); +} + +bool ChunkedData::cell_unpack(Ref cell_ref, ChunkedData::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool ChunkedData::cell_unpack_chunked_data(Ref cell_ref, Ref& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_chunked_data(cs, data) && cs.empty_ext(); +} + +bool ChunkedData::pack(vm::CellBuilder& cb, const ChunkedData::Record& data) const { + return t_HashmapE_32_Ref_Cell.store_from(cb, data.data); +} + +bool ChunkedData::pack_chunked_data(vm::CellBuilder& cb, Ref data) const { + return t_HashmapE_32_Ref_Cell.store_from(cb, data); +} + +bool ChunkedData::cell_pack(Ref& cell_ref, const ChunkedData::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool ChunkedData::cell_pack_chunked_data(Ref& cell_ref, Ref data) const { + vm::CellBuilder cb; + return pack_chunked_data(cb, std::move(data)) && std::move(cb).finalize_to(cell_ref); +} + +bool ChunkedData::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + return pp.open("chunked_data") + && pp.field("data") + && t_HashmapE_32_Ref_Cell.print_skip(pp, cs) + && pp.close(); +} + +const ChunkedData t_ChunkedData; + +// +// code for type `Text` +// + +int Text::check_tag(const vm::CellSlice& cs) const { + return text; +} + +bool Text::skip(vm::CellSlice& cs) const { + return t_Anything.skip(cs); +} + +bool Text::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + return t_Anything.validate_skip(ops, cs, weak); +} + +bool Text::unpack(vm::CellSlice& cs, Text::Record& data) const { + return t_Anything.fetch_to(cs, data.data); +} + +bool Text::unpack_text(vm::CellSlice& cs, Ref& data) const { + return t_Anything.fetch_to(cs, data); +} + +bool Text::cell_unpack(Ref cell_ref, Text::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Text::cell_unpack_text(Ref cell_ref, Ref& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_text(cs, data) && cs.empty_ext(); +} + +bool Text::pack(vm::CellBuilder& cb, const Text::Record& data) const { + return t_Anything.store_from(cb, data.data); +} + +bool Text::pack_text(vm::CellBuilder& cb, Ref data) const { + return t_Anything.store_from(cb, data); +} + +bool Text::cell_pack(Ref& cell_ref, const Text::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Text::cell_pack_text(Ref& cell_ref, Ref data) const { + vm::CellBuilder cb; + return pack_text(cb, std::move(data)) && std::move(cb).finalize_to(cell_ref); +} + +bool Text::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + return pp.open("text") + && pp.field("data") + && t_Anything.print_skip(pp, cs) + && pp.close(); +} + +const Text t_Text; + +// +// code for type `ContentData` +// + +int ContentData::get_tag(const vm::CellSlice& cs) const { + switch (cs.bselect(6, 3)) { + case 0: + return cs.bit_at(7) ? chunks : snake; + default: + return -1; + } +} + +int ContentData::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case snake: + return cs.prefetch_ulong(8) == 0 ? snake : -1; + case chunks: + return cs.prefetch_ulong(8) == 1 ? chunks : -1; + } + return -1; +} + +bool ContentData::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case snake: + return cs.advance(8) + && t_Anything.skip(cs); + case chunks: + return cs.advance(8) + && t_ChunkedData.skip(cs); + } + return false; +} + +bool ContentData::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case snake: + return cs.fetch_ulong(8) == 0 + && t_Anything.validate_skip(ops, cs, weak); + case chunks: + return cs.fetch_ulong(8) == 1 + && t_ChunkedData.validate_skip(ops, cs, weak); + } + return false; +} + +bool ContentData::unpack(vm::CellSlice& cs, ContentData::Record_snake& data) const { + return cs.fetch_ulong(8) == 0 + && t_Anything.fetch_to(cs, data.data); +} + +bool ContentData::unpack_snake(vm::CellSlice& cs, Ref& data) const { + return cs.fetch_ulong(8) == 0 + && t_Anything.fetch_to(cs, data); +} + +bool ContentData::cell_unpack(Ref cell_ref, ContentData::Record_snake& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool ContentData::cell_unpack_snake(Ref cell_ref, Ref& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_snake(cs, data) && cs.empty_ext(); +} + +bool ContentData::unpack(vm::CellSlice& cs, ContentData::Record_chunks& data) const { + return cs.fetch_ulong(8) == 1 + && t_ChunkedData.fetch_to(cs, data.data); +} + +bool ContentData::unpack_chunks(vm::CellSlice& cs, Ref& data) const { + return cs.fetch_ulong(8) == 1 + && t_ChunkedData.fetch_to(cs, data); +} + +bool ContentData::cell_unpack(Ref cell_ref, ContentData::Record_chunks& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool ContentData::cell_unpack_chunks(Ref cell_ref, Ref& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_chunks(cs, data) && cs.empty_ext(); +} + +bool ContentData::pack(vm::CellBuilder& cb, const ContentData::Record_snake& data) const { + return cb.store_long_bool(0, 8) + && t_Anything.store_from(cb, data.data); +} + +bool ContentData::pack_snake(vm::CellBuilder& cb, Ref data) const { + return cb.store_long_bool(0, 8) + && t_Anything.store_from(cb, data); +} + +bool ContentData::cell_pack(Ref& cell_ref, const ContentData::Record_snake& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool ContentData::cell_pack_snake(Ref& cell_ref, Ref data) const { + vm::CellBuilder cb; + return pack_snake(cb, std::move(data)) && std::move(cb).finalize_to(cell_ref); +} + +bool ContentData::pack(vm::CellBuilder& cb, const ContentData::Record_chunks& data) const { + return cb.store_long_bool(1, 8) + && t_ChunkedData.store_from(cb, data.data); +} + +bool ContentData::pack_chunks(vm::CellBuilder& cb, Ref data) const { + return cb.store_long_bool(1, 8) + && t_ChunkedData.store_from(cb, data); +} + +bool ContentData::cell_pack(Ref& cell_ref, const ContentData::Record_chunks& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool ContentData::cell_pack_chunks(Ref& cell_ref, Ref data) const { + vm::CellBuilder cb; + return pack_chunks(cb, std::move(data)) && std::move(cb).finalize_to(cell_ref); +} + +bool ContentData::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case snake: + return cs.fetch_ulong(8) == 0 + && pp.open("snake") + && pp.field("data") + && t_Anything.print_skip(pp, cs) + && pp.close(); + case chunks: + return cs.fetch_ulong(8) == 1 + && pp.open("chunks") + && pp.field("data") + && t_ChunkedData.print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for ContentData"); +} + +const ContentData t_ContentData; + +// +// code for type `FullContent` +// + +int FullContent::get_tag(const vm::CellSlice& cs) const { + switch (cs.bselect(6, 3)) { + case 0: + return cs.bit_at(7) ? offchain : onchain; + default: + return -1; + } +} + +int FullContent::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case onchain: + return cs.prefetch_ulong(8) == 0 ? onchain : -1; + case offchain: + return cs.prefetch_ulong(8) == 1 ? offchain : -1; + } + return -1; +} + +bool FullContent::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case onchain: + return cs.advance(8) + && t_HashmapE_256_Ref_ContentData.skip(cs); + case offchain: + return cs.advance(8) + && t_Text.skip(cs); + } + return false; +} + +bool FullContent::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case onchain: + return cs.fetch_ulong(8) == 0 + && t_HashmapE_256_Ref_ContentData.validate_skip(ops, cs, weak); + case offchain: + return cs.fetch_ulong(8) == 1 + && t_Text.validate_skip(ops, cs, weak); + } + return false; +} + +bool FullContent::unpack(vm::CellSlice& cs, FullContent::Record_onchain& data) const { + return cs.fetch_ulong(8) == 0 + && t_HashmapE_256_Ref_ContentData.fetch_to(cs, data.data); +} + +bool FullContent::unpack_onchain(vm::CellSlice& cs, Ref& data) const { + return cs.fetch_ulong(8) == 0 + && t_HashmapE_256_Ref_ContentData.fetch_to(cs, data); +} + +bool FullContent::cell_unpack(Ref cell_ref, FullContent::Record_onchain& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool FullContent::cell_unpack_onchain(Ref cell_ref, Ref& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_onchain(cs, data) && cs.empty_ext(); +} + +bool FullContent::unpack(vm::CellSlice& cs, FullContent::Record_offchain& data) const { + return cs.fetch_ulong(8) == 1 + && t_Text.fetch_to(cs, data.uri); +} + +bool FullContent::unpack_offchain(vm::CellSlice& cs, Ref& uri) const { + return cs.fetch_ulong(8) == 1 + && t_Text.fetch_to(cs, uri); +} + +bool FullContent::cell_unpack(Ref cell_ref, FullContent::Record_offchain& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool FullContent::cell_unpack_offchain(Ref cell_ref, Ref& uri) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_offchain(cs, uri) && cs.empty_ext(); +} + +bool FullContent::pack(vm::CellBuilder& cb, const FullContent::Record_onchain& data) const { + return cb.store_long_bool(0, 8) + && t_HashmapE_256_Ref_ContentData.store_from(cb, data.data); +} + +bool FullContent::pack_onchain(vm::CellBuilder& cb, Ref data) const { + return cb.store_long_bool(0, 8) + && t_HashmapE_256_Ref_ContentData.store_from(cb, data); +} + +bool FullContent::cell_pack(Ref& cell_ref, const FullContent::Record_onchain& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool FullContent::cell_pack_onchain(Ref& cell_ref, Ref data) const { + vm::CellBuilder cb; + return pack_onchain(cb, std::move(data)) && std::move(cb).finalize_to(cell_ref); +} + +bool FullContent::pack(vm::CellBuilder& cb, const FullContent::Record_offchain& data) const { + return cb.store_long_bool(1, 8) + && t_Text.store_from(cb, data.uri); +} + +bool FullContent::pack_offchain(vm::CellBuilder& cb, Ref uri) const { + return cb.store_long_bool(1, 8) + && t_Text.store_from(cb, uri); +} + +bool FullContent::cell_pack(Ref& cell_ref, const FullContent::Record_offchain& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool FullContent::cell_pack_offchain(Ref& cell_ref, Ref uri) const { + vm::CellBuilder cb; + return pack_offchain(cb, std::move(uri)) && std::move(cb).finalize_to(cell_ref); +} + +bool FullContent::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case onchain: + return cs.fetch_ulong(8) == 0 + && pp.open("onchain") + && pp.field("data") + && t_HashmapE_256_Ref_ContentData.print_skip(pp, cs) + && pp.close(); + case offchain: + return cs.fetch_ulong(8) == 1 + && pp.open("offchain") + && pp.field("uri") + && t_Text.print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for FullContent"); +} + +const FullContent t_FullContent; + +// +// code for type `Protocol` +// +constexpr unsigned short Protocol::cons_tag[1]; + +int Protocol::check_tag(const vm::CellSlice& cs) const { + return cs.prefetch_ulong(16) == 0x4854 ? proto_http : -1; +} + +bool Protocol::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + return cs.fetch_ulong(16) == 0x4854; +} + +bool Protocol::fetch_enum_to(vm::CellSlice& cs, char& value) const { + value = (cs.fetch_ulong(16) == 0x4854) ? 0 : -1; + return !value; +} + +bool Protocol::store_enum_from(vm::CellBuilder& cb, int value) const { + return !value && cb.store_long_bool(0x4854, 16); +} + +bool Protocol::unpack(vm::CellSlice& cs, Protocol::Record& data) const { + return cs.fetch_ulong(16) == 0x4854; +} + +bool Protocol::unpack_proto_http(vm::CellSlice& cs) const { + return cs.fetch_ulong(16) == 0x4854; +} + +bool Protocol::cell_unpack(Ref cell_ref, Protocol::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool Protocol::cell_unpack_proto_http(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_proto_http(cs) && cs.empty_ext(); +} + +bool Protocol::pack(vm::CellBuilder& cb, const Protocol::Record& data) const { + return cb.store_long_bool(0x4854, 16); +} + +bool Protocol::pack_proto_http(vm::CellBuilder& cb) const { + return cb.store_long_bool(0x4854, 16); +} + +bool Protocol::cell_pack(Ref& cell_ref, const Protocol::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool Protocol::cell_pack_proto_http(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_proto_http(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool Protocol::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + return cs.fetch_ulong(16) == 0x4854 + && pp.cons("proto_http"); +} + +const Protocol t_Protocol; + +// +// code for type `ProtoList` +// + +int ProtoList::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case proto_list_nil: + return cs.have(1) ? proto_list_nil : -1; + case proto_list_next: + return cs.have(1) ? proto_list_next : -1; + } + return -1; +} + +bool ProtoList::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case proto_list_nil: + return cs.advance(1); + case proto_list_next: + return cs.advance(17) + && skip(cs); + } + return false; +} + +bool ProtoList::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case proto_list_nil: + return cs.advance(1); + case proto_list_next: + return cs.advance(1) + && t_Protocol.validate_skip(ops, cs, weak) + && validate_skip(ops, cs, weak); + } + return false; +} + +bool ProtoList::unpack(vm::CellSlice& cs, ProtoList::Record_proto_list_nil& data) const { + return cs.fetch_ulong(1) == 0; +} + +bool ProtoList::unpack_proto_list_nil(vm::CellSlice& cs) const { + return cs.fetch_ulong(1) == 0; +} + +bool ProtoList::cell_unpack(Ref cell_ref, ProtoList::Record_proto_list_nil& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool ProtoList::cell_unpack_proto_list_nil(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_proto_list_nil(cs) && cs.empty_ext(); +} + +bool ProtoList::unpack(vm::CellSlice& cs, ProtoList::Record_proto_list_next& data) const { + return cs.fetch_ulong(1) == 1 + && t_Protocol.fetch_enum_to(cs, data.head) + && fetch_to(cs, data.tail); +} + +bool ProtoList::unpack_proto_list_next(vm::CellSlice& cs, char& head, Ref& tail) const { + return cs.fetch_ulong(1) == 1 + && t_Protocol.fetch_enum_to(cs, head) + && fetch_to(cs, tail); +} + +bool ProtoList::cell_unpack(Ref cell_ref, ProtoList::Record_proto_list_next& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool ProtoList::cell_unpack_proto_list_next(Ref cell_ref, char& head, Ref& tail) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_proto_list_next(cs, head, tail) && cs.empty_ext(); +} + +bool ProtoList::pack(vm::CellBuilder& cb, const ProtoList::Record_proto_list_nil& data) const { + return cb.store_long_bool(0, 1); +} + +bool ProtoList::pack_proto_list_nil(vm::CellBuilder& cb) const { + return cb.store_long_bool(0, 1); +} + +bool ProtoList::cell_pack(Ref& cell_ref, const ProtoList::Record_proto_list_nil& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool ProtoList::cell_pack_proto_list_nil(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_proto_list_nil(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool ProtoList::pack(vm::CellBuilder& cb, const ProtoList::Record_proto_list_next& data) const { + return cb.store_long_bool(1, 1) + && t_Protocol.store_enum_from(cb, data.head) + && store_from(cb, data.tail); +} + +bool ProtoList::pack_proto_list_next(vm::CellBuilder& cb, char head, Ref tail) const { + return cb.store_long_bool(1, 1) + && t_Protocol.store_enum_from(cb, head) + && store_from(cb, tail); +} + +bool ProtoList::cell_pack(Ref& cell_ref, const ProtoList::Record_proto_list_next& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool ProtoList::cell_pack_proto_list_next(Ref& cell_ref, char head, Ref tail) const { + vm::CellBuilder cb; + return pack_proto_list_next(cb, head, std::move(tail)) && std::move(cb).finalize_to(cell_ref); +} + +bool ProtoList::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case proto_list_nil: + return cs.advance(1) + && pp.cons("proto_list_nil"); + case proto_list_next: + return cs.advance(1) + && pp.open("proto_list_next") + && pp.field("head") + && t_Protocol.print_skip(pp, cs) + && pp.field("tail") + && print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for ProtoList"); +} + +const ProtoList t_ProtoList; + +// +// code for type `SmcCapability` +// +constexpr unsigned short SmcCapability::cons_tag[1]; + +int SmcCapability::check_tag(const vm::CellSlice& cs) const { + return cs.prefetch_ulong(16) == 0x2177 ? cap_is_wallet : -1; +} + +bool SmcCapability::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + return cs.fetch_ulong(16) == 0x2177; +} + +bool SmcCapability::fetch_enum_to(vm::CellSlice& cs, char& value) const { + value = (cs.fetch_ulong(16) == 0x2177) ? 0 : -1; + return !value; +} + +bool SmcCapability::store_enum_from(vm::CellBuilder& cb, int value) const { + return !value && cb.store_long_bool(0x2177, 16); +} + +bool SmcCapability::unpack(vm::CellSlice& cs, SmcCapability::Record& data) const { + return cs.fetch_ulong(16) == 0x2177; +} + +bool SmcCapability::unpack_cap_is_wallet(vm::CellSlice& cs) const { + return cs.fetch_ulong(16) == 0x2177; +} + +bool SmcCapability::cell_unpack(Ref cell_ref, SmcCapability::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool SmcCapability::cell_unpack_cap_is_wallet(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_cap_is_wallet(cs) && cs.empty_ext(); +} + +bool SmcCapability::pack(vm::CellBuilder& cb, const SmcCapability::Record& data) const { + return cb.store_long_bool(0x2177, 16); +} + +bool SmcCapability::pack_cap_is_wallet(vm::CellBuilder& cb) const { + return cb.store_long_bool(0x2177, 16); +} + +bool SmcCapability::cell_pack(Ref& cell_ref, const SmcCapability::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool SmcCapability::cell_pack_cap_is_wallet(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_cap_is_wallet(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool SmcCapability::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + return cs.fetch_ulong(16) == 0x2177 + && pp.cons("cap_is_wallet"); +} + +const SmcCapability t_SmcCapability; + +// +// code for type `SmcCapList` +// + +int SmcCapList::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case cap_list_nil: + return cs.have(1) ? cap_list_nil : -1; + case cap_list_next: + return cs.have(1) ? cap_list_next : -1; + } + return -1; +} + +bool SmcCapList::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case cap_list_nil: + return cs.advance(1); + case cap_list_next: + return cs.advance(17) + && skip(cs); + } + return false; +} + +bool SmcCapList::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case cap_list_nil: + return cs.advance(1); + case cap_list_next: + return cs.advance(1) + && t_SmcCapability.validate_skip(ops, cs, weak) + && validate_skip(ops, cs, weak); + } + return false; +} + +bool SmcCapList::unpack(vm::CellSlice& cs, SmcCapList::Record_cap_list_nil& data) const { + return cs.fetch_ulong(1) == 0; +} + +bool SmcCapList::unpack_cap_list_nil(vm::CellSlice& cs) const { + return cs.fetch_ulong(1) == 0; +} + +bool SmcCapList::cell_unpack(Ref cell_ref, SmcCapList::Record_cap_list_nil& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool SmcCapList::cell_unpack_cap_list_nil(Ref cell_ref) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_cap_list_nil(cs) && cs.empty_ext(); +} + +bool SmcCapList::unpack(vm::CellSlice& cs, SmcCapList::Record_cap_list_next& data) const { + return cs.fetch_ulong(1) == 1 + && t_SmcCapability.fetch_enum_to(cs, data.head) + && fetch_to(cs, data.tail); +} + +bool SmcCapList::unpack_cap_list_next(vm::CellSlice& cs, char& head, Ref& tail) const { + return cs.fetch_ulong(1) == 1 + && t_SmcCapability.fetch_enum_to(cs, head) + && fetch_to(cs, tail); +} + +bool SmcCapList::cell_unpack(Ref cell_ref, SmcCapList::Record_cap_list_next& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool SmcCapList::cell_unpack_cap_list_next(Ref cell_ref, char& head, Ref& tail) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_cap_list_next(cs, head, tail) && cs.empty_ext(); +} + +bool SmcCapList::pack(vm::CellBuilder& cb, const SmcCapList::Record_cap_list_nil& data) const { + return cb.store_long_bool(0, 1); +} + +bool SmcCapList::pack_cap_list_nil(vm::CellBuilder& cb) const { + return cb.store_long_bool(0, 1); +} + +bool SmcCapList::cell_pack(Ref& cell_ref, const SmcCapList::Record_cap_list_nil& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool SmcCapList::cell_pack_cap_list_nil(Ref& cell_ref) const { + vm::CellBuilder cb; + return pack_cap_list_nil(cb) && std::move(cb).finalize_to(cell_ref); +} + +bool SmcCapList::pack(vm::CellBuilder& cb, const SmcCapList::Record_cap_list_next& data) const { + return cb.store_long_bool(1, 1) + && t_SmcCapability.store_enum_from(cb, data.head) + && store_from(cb, data.tail); +} + +bool SmcCapList::pack_cap_list_next(vm::CellBuilder& cb, char head, Ref tail) const { + return cb.store_long_bool(1, 1) + && t_SmcCapability.store_enum_from(cb, head) + && store_from(cb, tail); +} + +bool SmcCapList::cell_pack(Ref& cell_ref, const SmcCapList::Record_cap_list_next& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool SmcCapList::cell_pack_cap_list_next(Ref& cell_ref, char head, Ref tail) const { + vm::CellBuilder cb; + return pack_cap_list_next(cb, head, std::move(tail)) && std::move(cb).finalize_to(cell_ref); +} + +bool SmcCapList::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case cap_list_nil: + return cs.advance(1) + && pp.cons("cap_list_nil"); + case cap_list_next: + return cs.advance(1) + && pp.open("cap_list_next") + && pp.field("head") + && t_SmcCapability.print_skip(pp, cs) + && pp.field("tail") + && print_skip(pp, cs) + && pp.close(); + } + return pp.fail("unknown constructor for SmcCapList"); +} + +const SmcCapList t_SmcCapList; + +// +// code for type `DNSRecord` +// +constexpr unsigned short DNSRecord::cons_tag[4]; + +int DNSRecord::check_tag(const vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case dns_smc_address: + return cs.prefetch_ulong(16) == 0x9fd3 ? dns_smc_address : -1; + case dns_next_resolver: + return cs.prefetch_ulong(16) == 0xba93 ? dns_next_resolver : -1; + case dns_adnl_address: + return cs.prefetch_ulong(16) == 0xad01 ? dns_adnl_address : -1; + case dns_storage_address: + return cs.prefetch_ulong(16) == 0x7473 ? dns_storage_address : -1; + } + return -1; +} + +bool DNSRecord::skip(vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case dns_smc_address: { + int flags; + return cs.advance(16) + && t_MsgAddressInt.skip(cs) + && cs.fetch_uint_to(8, flags) + && flags <= 1 + && (!(flags & 1) || t_SmcCapList.skip(cs)); + } + case dns_next_resolver: + return cs.advance(16) + && t_MsgAddressInt.skip(cs); + case dns_adnl_address: { + int flags; + return cs.advance(272) + && cs.fetch_uint_to(8, flags) + && flags <= 1 + && (!(flags & 1) || t_ProtoList.skip(cs)); + } + case dns_storage_address: + return cs.advance(272); + } + return false; +} + +bool DNSRecord::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + switch (get_tag(cs)) { + case dns_smc_address: { + int flags; + return cs.fetch_ulong(16) == 0x9fd3 + && t_MsgAddressInt.validate_skip(ops, cs, weak) + && cs.fetch_uint_to(8, flags) + && flags <= 1 + && (!(flags & 1) || t_SmcCapList.validate_skip(ops, cs, weak)); + } + case dns_next_resolver: + return cs.fetch_ulong(16) == 0xba93 + && t_MsgAddressInt.validate_skip(ops, cs, weak); + case dns_adnl_address: { + int flags; + return cs.fetch_ulong(16) == 0xad01 + && cs.advance(256) + && cs.fetch_uint_to(8, flags) + && flags <= 1 + && (!(flags & 1) || t_ProtoList.validate_skip(ops, cs, weak)); + } + case dns_storage_address: + return cs.fetch_ulong(16) == 0x7473 + && cs.advance(256); + } + return false; +} + +bool DNSRecord::unpack(vm::CellSlice& cs, DNSRecord::Record_dns_smc_address& data) const { + return cs.fetch_ulong(16) == 0x9fd3 + && t_MsgAddressInt.fetch_to(cs, data.smc_addr) + && cs.fetch_uint_to(8, data.flags) + && data.flags <= 1 + && (!(data.flags & 1) || t_SmcCapList.fetch_to(cs, data.cap_list)); +} + +bool DNSRecord::unpack_dns_smc_address(vm::CellSlice& cs, Ref& smc_addr, int& flags, Ref& cap_list) const { + return cs.fetch_ulong(16) == 0x9fd3 + && t_MsgAddressInt.fetch_to(cs, smc_addr) + && cs.fetch_uint_to(8, flags) + && flags <= 1 + && (!(flags & 1) || t_SmcCapList.fetch_to(cs, cap_list)); +} + +bool DNSRecord::cell_unpack(Ref cell_ref, DNSRecord::Record_dns_smc_address& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool DNSRecord::cell_unpack_dns_smc_address(Ref cell_ref, Ref& smc_addr, int& flags, Ref& cap_list) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_dns_smc_address(cs, smc_addr, flags, cap_list) && cs.empty_ext(); +} + +bool DNSRecord::unpack(vm::CellSlice& cs, DNSRecord::Record_dns_next_resolver& data) const { + return cs.fetch_ulong(16) == 0xba93 + && t_MsgAddressInt.fetch_to(cs, data.resolver); +} + +bool DNSRecord::unpack_dns_next_resolver(vm::CellSlice& cs, Ref& resolver) const { + return cs.fetch_ulong(16) == 0xba93 + && t_MsgAddressInt.fetch_to(cs, resolver); +} + +bool DNSRecord::cell_unpack(Ref cell_ref, DNSRecord::Record_dns_next_resolver& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool DNSRecord::cell_unpack_dns_next_resolver(Ref cell_ref, Ref& resolver) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_dns_next_resolver(cs, resolver) && cs.empty_ext(); +} + +bool DNSRecord::unpack(vm::CellSlice& cs, DNSRecord::Record_dns_adnl_address& data) const { + return cs.fetch_ulong(16) == 0xad01 + && cs.fetch_bits_to(data.adnl_addr.bits(), 256) + && cs.fetch_uint_to(8, data.flags) + && data.flags <= 1 + && (!(data.flags & 1) || t_ProtoList.fetch_to(cs, data.proto_list)); +} + +bool DNSRecord::unpack_dns_adnl_address(vm::CellSlice& cs, td::BitArray<256>& adnl_addr, int& flags, Ref& proto_list) const { + return cs.fetch_ulong(16) == 0xad01 + && cs.fetch_bits_to(adnl_addr.bits(), 256) + && cs.fetch_uint_to(8, flags) + && flags <= 1 + && (!(flags & 1) || t_ProtoList.fetch_to(cs, proto_list)); +} + +bool DNSRecord::cell_unpack(Ref cell_ref, DNSRecord::Record_dns_adnl_address& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool DNSRecord::cell_unpack_dns_adnl_address(Ref cell_ref, td::BitArray<256>& adnl_addr, int& flags, Ref& proto_list) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_dns_adnl_address(cs, adnl_addr, flags, proto_list) && cs.empty_ext(); +} + +bool DNSRecord::unpack(vm::CellSlice& cs, DNSRecord::Record_dns_storage_address& data) const { + return cs.fetch_ulong(16) == 0x7473 + && cs.fetch_bits_to(data.bag_id.bits(), 256); +} + +bool DNSRecord::unpack_dns_storage_address(vm::CellSlice& cs, td::BitArray<256>& bag_id) const { + return cs.fetch_ulong(16) == 0x7473 + && cs.fetch_bits_to(bag_id.bits(), 256); +} + +bool DNSRecord::cell_unpack(Ref cell_ref, DNSRecord::Record_dns_storage_address& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool DNSRecord::cell_unpack_dns_storage_address(Ref cell_ref, td::BitArray<256>& bag_id) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_dns_storage_address(cs, bag_id) && cs.empty_ext(); +} + +bool DNSRecord::pack(vm::CellBuilder& cb, const DNSRecord::Record_dns_smc_address& data) const { + return cb.store_long_bool(0x9fd3, 16) + && t_MsgAddressInt.store_from(cb, data.smc_addr) + && cb.store_ulong_rchk_bool(data.flags, 8) + && data.flags <= 1 + && (!(data.flags & 1) || t_SmcCapList.store_from(cb, data.cap_list)); +} + +bool DNSRecord::pack_dns_smc_address(vm::CellBuilder& cb, Ref smc_addr, int flags, Ref cap_list) const { + return cb.store_long_bool(0x9fd3, 16) + && t_MsgAddressInt.store_from(cb, smc_addr) + && cb.store_ulong_rchk_bool(flags, 8) + && flags <= 1 + && (!(flags & 1) || t_SmcCapList.store_from(cb, cap_list)); +} + +bool DNSRecord::cell_pack(Ref& cell_ref, const DNSRecord::Record_dns_smc_address& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::cell_pack_dns_smc_address(Ref& cell_ref, Ref smc_addr, int flags, Ref cap_list) const { + vm::CellBuilder cb; + return pack_dns_smc_address(cb, std::move(smc_addr), flags, std::move(cap_list)) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::pack(vm::CellBuilder& cb, const DNSRecord::Record_dns_next_resolver& data) const { + return cb.store_long_bool(0xba93, 16) + && t_MsgAddressInt.store_from(cb, data.resolver); +} + +bool DNSRecord::pack_dns_next_resolver(vm::CellBuilder& cb, Ref resolver) const { + return cb.store_long_bool(0xba93, 16) + && t_MsgAddressInt.store_from(cb, resolver); +} + +bool DNSRecord::cell_pack(Ref& cell_ref, const DNSRecord::Record_dns_next_resolver& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::cell_pack_dns_next_resolver(Ref& cell_ref, Ref resolver) const { + vm::CellBuilder cb; + return pack_dns_next_resolver(cb, std::move(resolver)) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::pack(vm::CellBuilder& cb, const DNSRecord::Record_dns_adnl_address& data) const { + return cb.store_long_bool(0xad01, 16) + && cb.store_bits_bool(data.adnl_addr.cbits(), 256) + && cb.store_ulong_rchk_bool(data.flags, 8) + && data.flags <= 1 + && (!(data.flags & 1) || t_ProtoList.store_from(cb, data.proto_list)); +} + +bool DNSRecord::pack_dns_adnl_address(vm::CellBuilder& cb, td::BitArray<256> adnl_addr, int flags, Ref proto_list) const { + return cb.store_long_bool(0xad01, 16) + && cb.store_bits_bool(adnl_addr.cbits(), 256) + && cb.store_ulong_rchk_bool(flags, 8) + && flags <= 1 + && (!(flags & 1) || t_ProtoList.store_from(cb, proto_list)); +} + +bool DNSRecord::cell_pack(Ref& cell_ref, const DNSRecord::Record_dns_adnl_address& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::cell_pack_dns_adnl_address(Ref& cell_ref, td::BitArray<256> adnl_addr, int flags, Ref proto_list) const { + vm::CellBuilder cb; + return pack_dns_adnl_address(cb, adnl_addr, flags, std::move(proto_list)) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::pack(vm::CellBuilder& cb, const DNSRecord::Record_dns_storage_address& data) const { + return cb.store_long_bool(0x7473, 16) + && cb.store_bits_bool(data.bag_id.cbits(), 256); +} + +bool DNSRecord::pack_dns_storage_address(vm::CellBuilder& cb, td::BitArray<256> bag_id) const { + return cb.store_long_bool(0x7473, 16) + && cb.store_bits_bool(bag_id.cbits(), 256); +} + +bool DNSRecord::cell_pack(Ref& cell_ref, const DNSRecord::Record_dns_storage_address& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::cell_pack_dns_storage_address(Ref& cell_ref, td::BitArray<256> bag_id) const { + vm::CellBuilder cb; + return pack_dns_storage_address(cb, bag_id) && std::move(cb).finalize_to(cell_ref); +} + +bool DNSRecord::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + switch (get_tag(cs)) { + case dns_smc_address: { + int flags; + return cs.fetch_ulong(16) == 0x9fd3 + && pp.open("dns_smc_address") + && pp.field("smc_addr") + && t_MsgAddressInt.print_skip(pp, cs) + && cs.fetch_uint_to(8, flags) + && pp.field_int(flags, "flags") + && flags <= 1 + && (!(flags & 1) || (pp.field("cap_list") && t_SmcCapList.print_skip(pp, cs))) + && pp.close(); + } + case dns_next_resolver: + return cs.fetch_ulong(16) == 0xba93 + && pp.open("dns_next_resolver") + && pp.field("resolver") + && t_MsgAddressInt.print_skip(pp, cs) + && pp.close(); + case dns_adnl_address: { + int flags; + return cs.fetch_ulong(16) == 0xad01 + && pp.open("dns_adnl_address") + && pp.fetch_bits_field(cs, 256, "adnl_addr") + && cs.fetch_uint_to(8, flags) + && pp.field_int(flags, "flags") + && flags <= 1 + && (!(flags & 1) || (pp.field("proto_list") && t_ProtoList.print_skip(pp, cs))) + && pp.close(); + } + case dns_storage_address: + return cs.fetch_ulong(16) == 0x7473 + && pp.open("dns_storage_address") + && pp.fetch_bits_field(cs, 256, "bag_id") + && pp.close(); + } + return pp.fail("unknown constructor for DNSRecord"); +} + +const DNSRecord t_DNSRecord; + +// +// code for type `DNS_RecordSet` +// + +int DNS_RecordSet::check_tag(const vm::CellSlice& cs) const { + return cons1; +} + +bool DNS_RecordSet::skip(vm::CellSlice& cs) const { + return t_HashmapE_256_Ref_DNSRecord.skip(cs); +} + +bool DNS_RecordSet::validate_skip(int* ops, vm::CellSlice& cs, bool weak) const { + return t_HashmapE_256_Ref_DNSRecord.validate_skip(ops, cs, weak); +} + +bool DNS_RecordSet::unpack(vm::CellSlice& cs, DNS_RecordSet::Record& data) const { + return t_HashmapE_256_Ref_DNSRecord.fetch_to(cs, data.x); +} + +bool DNS_RecordSet::unpack_cons1(vm::CellSlice& cs, Ref& x) const { + return t_HashmapE_256_Ref_DNSRecord.fetch_to(cs, x); +} + +bool DNS_RecordSet::cell_unpack(Ref cell_ref, DNS_RecordSet::Record& data) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack(cs, data) && cs.empty_ext(); +} + +bool DNS_RecordSet::cell_unpack_cons1(Ref cell_ref, Ref& x) const { + if (cell_ref.is_null()) { return false; } + auto cs = load_cell_slice(std::move(cell_ref)); + return unpack_cons1(cs, x) && cs.empty_ext(); +} + +bool DNS_RecordSet::pack(vm::CellBuilder& cb, const DNS_RecordSet::Record& data) const { + return t_HashmapE_256_Ref_DNSRecord.store_from(cb, data.x); +} + +bool DNS_RecordSet::pack_cons1(vm::CellBuilder& cb, Ref x) const { + return t_HashmapE_256_Ref_DNSRecord.store_from(cb, x); +} + +bool DNS_RecordSet::cell_pack(Ref& cell_ref, const DNS_RecordSet::Record& data) const { + vm::CellBuilder cb; + return pack(cb, data) && std::move(cb).finalize_to(cell_ref); +} + +bool DNS_RecordSet::cell_pack_cons1(Ref& cell_ref, Ref x) const { + vm::CellBuilder cb; + return pack_cons1(cb, std::move(x)) && std::move(cb).finalize_to(cell_ref); +} + +bool DNS_RecordSet::print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const { + return pp.open() + && pp.field() + && t_HashmapE_256_Ref_DNSRecord.print_skip(pp, cs) + && pp.close(); +} + +const DNS_RecordSet t_DNS_RecordSet; + +// definitions of constant types used + +const NatWidth t_natwidth_9{9}; +const NatLeq t_natleq_30{30}; +const Maybe t_Maybe_Anycast{t_Anycast}; +const Int t_int8{8}; +const Bits t_bits256{256}; +const Int t_int32{32}; +const UInt t_uint64{64}; +const VarUInteger t_VarUInteger_16{16}; +const Maybe t_Maybe_Ref_Cell{t_RefCell}; +const Either t_Either_Cell_Ref_Cell{t_Anything, t_RefCell}; +const NatWidth t_natwidth_1{1}; +const HashmapE t_HashmapE_32_Ref_Cell{32, t_RefCell}; +const RefT t_Ref_ContentData{t_ContentData}; +const HashmapE t_HashmapE_256_Ref_ContentData{256, t_Ref_ContentData}; +const NatWidth t_natwidth_8{8}; +const RefT t_Ref_DNSRecord{t_DNSRecord}; +const HashmapE t_HashmapE_256_Ref_DNSRecord{256, t_Ref_DNSRecord}; + +// definition of type name registration function +bool register_simple_types(std::function func) { + return func("MsgAddressExt", &t_MsgAddressExt) + && func("Anycast", &t_Anycast) + && func("MsgAddressInt", &t_MsgAddressInt) + && func("MsgAddress", &t_MsgAddress) + && func("InternalMsgBody", &t_InternalMsgBody) + && func("Bit", &t_Bit) + && func("Unary", &t_Unary) + && func("ChunkedData", &t_ChunkedData) + && func("Text", &t_Text) + && func("ContentData", &t_ContentData) + && func("FullContent", &t_FullContent) + && func("Protocol", &t_Protocol) + && func("ProtoList", &t_ProtoList) + && func("SmcCapability", &t_SmcCapability) + && func("SmcCapList", &t_SmcCapList) + && func("DNSRecord", &t_DNSRecord) + && func("DNS_RecordSet", &t_DNS_RecordSet); +} + + +} // namespace gen + +} // namespace tokens diff --git a/ton-http-api/src/core/tlb/tokens-tlb.h b/ton-http-api/src/core/tlb/tokens-tlb.h new file mode 100644 index 0000000..f50a466 --- /dev/null +++ b/ton-http-api/src/core/tlb/tokens-tlb.h @@ -0,0 +1,1291 @@ +#pragma once +#include +/* + * + * AUTO-GENERATED FROM `/Users/ruslixag/Developer/ton-workspace/ton-http-api-cpp/ton-http-api/tlb/tokens.tlb` + * + */ +// uses built-in type `##` +// uses built-in type `#<` +// uses built-in type `#<=` +// uses built-in type `Cell` +// uses built-in type `uint` +// uses built-in type `bits` +// uses built-in type `int8` +// uses built-in type `int32` +// uses built-in type `uint64` +// uses built-in type `bits256` + +namespace tokens { + +namespace gen { +using namespace ::tlb; +using td::Ref; +using vm::CellSlice; +using vm::Cell; +using td::RefInt256; + +// +// headers for type `Maybe` +// + +struct Maybe final : TLB_Complex { + enum { nothing, just }; + static constexpr int cons_len_exact = 1; + const TLB &X_; + Maybe(const TLB& X) : X_(X) {} + struct Record_nothing { + typedef Maybe type_class; + }; + struct Record_just { + typedef Maybe type_class; + Ref value; // value : X + Record_just() = default; + Record_just(Ref _value) : value(std::move(_value)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_nothing& data) const; + bool unpack_nothing(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record_nothing& data) const; + bool cell_unpack_nothing(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record_nothing& data) const; + bool pack_nothing(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record_nothing& data) const; + bool cell_pack_nothing(Ref& cell_ref) const; + bool unpack(vm::CellSlice& cs, Record_just& data) const; + bool unpack_just(vm::CellSlice& cs, Ref& value) const; + bool cell_unpack(Ref cell_ref, Record_just& data) const; + bool cell_unpack_just(Ref cell_ref, Ref& value) const; + bool pack(vm::CellBuilder& cb, const Record_just& data) const; + bool pack_just(vm::CellBuilder& cb, Ref value) const; + bool cell_pack(Ref& cell_ref, const Record_just& data) const; + bool cell_pack_just(Ref& cell_ref, Ref value) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "(Maybe " << X_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +// +// headers for type `Either` +// + +struct Either final : TLB_Complex { + enum { left, right }; + static constexpr int cons_len_exact = 1; + const TLB &X_, &Y_; + Either(const TLB& X, const TLB& Y) : X_(X), Y_(Y) {} + struct Record_left { + typedef Either type_class; + Ref value; // value : X + Record_left() = default; + Record_left(Ref _value) : value(std::move(_value)) {} + }; + struct Record_right { + typedef Either type_class; + Ref value; // value : Y + Record_right() = default; + Record_right(Ref _value) : value(std::move(_value)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_left& data) const; + bool unpack_left(vm::CellSlice& cs, Ref& value) const; + bool cell_unpack(Ref cell_ref, Record_left& data) const; + bool cell_unpack_left(Ref cell_ref, Ref& value) const; + bool pack(vm::CellBuilder& cb, const Record_left& data) const; + bool pack_left(vm::CellBuilder& cb, Ref value) const; + bool cell_pack(Ref& cell_ref, const Record_left& data) const; + bool cell_pack_left(Ref& cell_ref, Ref value) const; + bool unpack(vm::CellSlice& cs, Record_right& data) const; + bool unpack_right(vm::CellSlice& cs, Ref& value) const; + bool cell_unpack(Ref cell_ref, Record_right& data) const; + bool cell_unpack_right(Ref cell_ref, Ref& value) const; + bool pack(vm::CellBuilder& cb, const Record_right& data) const; + bool pack_right(vm::CellBuilder& cb, Ref value) const; + bool cell_pack(Ref& cell_ref, const Record_right& data) const; + bool cell_pack_right(Ref& cell_ref, Ref value) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "(Either " << X_ << " " << Y_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +// +// headers for type `VarUInteger` +// + +struct VarUInteger final : TLB_Complex { + enum { var_uint }; + static constexpr int cons_len_exact = 0; + int m_; + VarUInteger(int m) : m_(m) {} + struct Record; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_var_uint(vm::CellSlice& cs, int& n, int& len, RefInt256& value) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_var_uint(Ref cell_ref, int& n, int& len, RefInt256& value) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_var_uint(vm::CellBuilder& cb, int len, RefInt256 value) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_var_uint(Ref& cell_ref, int len, RefInt256 value) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "(VarUInteger " << m_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +struct VarUInteger::Record { + typedef VarUInteger type_class; + int n; // n : # + int len; // len : #< n + RefInt256 value; // value : uint (8 * len) + Record() = default; + Record(int _len, RefInt256 _value) : n(-1), len(_len), value(std::move(_value)) {} +}; + +// +// headers for type `MsgAddressExt` +// + +struct MsgAddressExt final : TLB_Complex { + enum { addr_none, addr_extern }; + static constexpr int cons_len_exact = 2; + struct Record_addr_none { + typedef MsgAddressExt type_class; + }; + struct Record_addr_extern { + typedef MsgAddressExt type_class; + int len; // len : ## 9 + Ref external_address; // external_address : bits len + Record_addr_extern() = default; + Record_addr_extern(int _len, Ref _external_address) : len(_len), external_address(std::move(_external_address)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_addr_none& data) const; + bool unpack_addr_none(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record_addr_none& data) const; + bool cell_unpack_addr_none(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record_addr_none& data) const; + bool pack_addr_none(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record_addr_none& data) const; + bool cell_pack_addr_none(Ref& cell_ref) const; + bool unpack(vm::CellSlice& cs, Record_addr_extern& data) const; + bool unpack_addr_extern(vm::CellSlice& cs, int& len, Ref& external_address) const; + bool cell_unpack(Ref cell_ref, Record_addr_extern& data) const; + bool cell_unpack_addr_extern(Ref cell_ref, int& len, Ref& external_address) const; + bool pack(vm::CellBuilder& cb, const Record_addr_extern& data) const; + bool pack_addr_extern(vm::CellBuilder& cb, int len, Ref external_address) const; + bool cell_pack(Ref& cell_ref, const Record_addr_extern& data) const; + bool cell_pack_addr_extern(Ref& cell_ref, int len, Ref external_address) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "MsgAddressExt"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return cs.bselect(2, 3); + } +}; + +extern const MsgAddressExt t_MsgAddressExt; + +// +// headers for type `Anycast` +// + +struct Anycast final : TLB_Complex { + enum { anycast_info }; + static constexpr int cons_len_exact = 0; + struct Record { + typedef Anycast type_class; + int depth; // depth : #<= 30 + Ref rewrite_pfx; // rewrite_pfx : bits depth + Record() = default; + Record(int _depth, Ref _rewrite_pfx) : depth(_depth), rewrite_pfx(std::move(_rewrite_pfx)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_anycast_info(vm::CellSlice& cs, int& depth, Ref& rewrite_pfx) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_anycast_info(Ref cell_ref, int& depth, Ref& rewrite_pfx) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_anycast_info(vm::CellBuilder& cb, int depth, Ref rewrite_pfx) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_anycast_info(Ref& cell_ref, int depth, Ref rewrite_pfx) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "Anycast"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const Anycast t_Anycast; + +// +// headers for type `MsgAddressInt` +// + +struct MsgAddressInt final : TLB_Complex { + enum { addr_std, addr_var }; + static constexpr int cons_len_exact = 2; + static constexpr unsigned char cons_tag[2] = { 2, 3 }; + struct Record_addr_std; + struct Record_addr_var; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_addr_std& data) const; + bool unpack_addr_std(vm::CellSlice& cs, Ref& anycast, int& workchain_id, td::BitArray<256>& address) const; + bool cell_unpack(Ref cell_ref, Record_addr_std& data) const; + bool cell_unpack_addr_std(Ref cell_ref, Ref& anycast, int& workchain_id, td::BitArray<256>& address) const; + bool pack(vm::CellBuilder& cb, const Record_addr_std& data) const; + bool pack_addr_std(vm::CellBuilder& cb, Ref anycast, int workchain_id, td::BitArray<256> address) const; + bool cell_pack(Ref& cell_ref, const Record_addr_std& data) const; + bool cell_pack_addr_std(Ref& cell_ref, Ref anycast, int workchain_id, td::BitArray<256> address) const; + bool unpack(vm::CellSlice& cs, Record_addr_var& data) const; + bool cell_unpack(Ref cell_ref, Record_addr_var& data) const; + bool pack(vm::CellBuilder& cb, const Record_addr_var& data) const; + bool cell_pack(Ref& cell_ref, const Record_addr_var& data) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "MsgAddressInt"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return cs.bselect(2, 12); + } +}; + +struct MsgAddressInt::Record_addr_std { + typedef MsgAddressInt type_class; + Ref anycast; // anycast : Maybe Anycast + int workchain_id; // workchain_id : int8 + td::BitArray<256> address; // address : bits256 + Record_addr_std() = default; + Record_addr_std(Ref _anycast, int _workchain_id, const td::BitArray<256>& _address) : anycast(std::move(_anycast)), workchain_id(_workchain_id), address(_address) {} +}; + +struct MsgAddressInt::Record_addr_var { + typedef MsgAddressInt type_class; + Ref anycast; // anycast : Maybe Anycast + int addr_len; // addr_len : ## 9 + int workchain_id; // workchain_id : int32 + Ref address; // address : bits addr_len + Record_addr_var() = default; + Record_addr_var(Ref _anycast, int _addr_len, int _workchain_id, Ref _address) : anycast(std::move(_anycast)), addr_len(_addr_len), workchain_id(_workchain_id), address(std::move(_address)) {} +}; + +extern const MsgAddressInt t_MsgAddressInt; + +// +// headers for type `MsgAddress` +// + +struct MsgAddress final : TLB_Complex { + enum { cons2, cons1 }; + static constexpr int cons_len_exact = 0; + struct Record_cons1 { + typedef MsgAddress type_class; + Ref x; // MsgAddressInt + Record_cons1() = default; + Record_cons1(Ref _x) : x(std::move(_x)) {} + }; + struct Record_cons2 { + typedef MsgAddress type_class; + Ref x; // MsgAddressExt + Record_cons2() = default; + Record_cons2(Ref _x) : x(std::move(_x)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_cons1& data) const; + bool unpack_cons1(vm::CellSlice& cs, Ref& x) const; + bool cell_unpack(Ref cell_ref, Record_cons1& data) const; + bool cell_unpack_cons1(Ref cell_ref, Ref& x) const; + bool pack(vm::CellBuilder& cb, const Record_cons1& data) const; + bool pack_cons1(vm::CellBuilder& cb, Ref x) const; + bool cell_pack(Ref& cell_ref, const Record_cons1& data) const; + bool cell_pack_cons1(Ref& cell_ref, Ref x) const; + bool unpack(vm::CellSlice& cs, Record_cons2& data) const; + bool unpack_cons2(vm::CellSlice& cs, Ref& x) const; + bool cell_unpack(Ref cell_ref, Record_cons2& data) const; + bool cell_unpack_cons2(Ref cell_ref, Ref& x) const; + bool pack(vm::CellBuilder& cb, const Record_cons2& data) const; + bool pack_cons2(vm::CellBuilder& cb, Ref x) const; + bool cell_pack(Ref& cell_ref, const Record_cons2& data) const; + bool cell_pack_cons2(Ref& cell_ref, Ref x) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "MsgAddress"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +extern const MsgAddress t_MsgAddress; + +// +// headers for type `InternalMsgBody` +// + +struct InternalMsgBody final : TLB_Complex { + enum { transfer_jetton, burn, transfer_nft, transfer_notification, burn_notification, internal_transfer, excesses }; + static constexpr int cons_len_exact = 32; + static constexpr unsigned cons_tag[7] = { 0xf8a7ea5, 0x595f07bc, 0x5fcc3d14, 0x7362d09c, 0x7bdd97de, 0x978d4519U, 0xd53276dbU }; + struct Record_transfer_jetton; + struct Record_transfer_notification; + struct Record_excesses { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Record_excesses() = default; + Record_excesses(unsigned long long _query_id) : query_id(_query_id) {} + }; + struct Record_burn; + struct Record_transfer_nft; + struct Record_internal_transfer; + struct Record_burn_notification; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_transfer_jetton& data) const; + bool cell_unpack(Ref cell_ref, Record_transfer_jetton& data) const; + bool pack(vm::CellBuilder& cb, const Record_transfer_jetton& data) const; + bool cell_pack(Ref& cell_ref, const Record_transfer_jetton& data) const; + bool unpack(vm::CellSlice& cs, Record_transfer_notification& data) const; + bool cell_unpack(Ref cell_ref, Record_transfer_notification& data) const; + bool pack(vm::CellBuilder& cb, const Record_transfer_notification& data) const; + bool cell_pack(Ref& cell_ref, const Record_transfer_notification& data) const; + bool unpack(vm::CellSlice& cs, Record_excesses& data) const; + bool unpack_excesses(vm::CellSlice& cs, unsigned long long& query_id) const; + bool cell_unpack(Ref cell_ref, Record_excesses& data) const; + bool cell_unpack_excesses(Ref cell_ref, unsigned long long& query_id) const; + bool pack(vm::CellBuilder& cb, const Record_excesses& data) const; + bool pack_excesses(vm::CellBuilder& cb, unsigned long long query_id) const; + bool cell_pack(Ref& cell_ref, const Record_excesses& data) const; + bool cell_pack_excesses(Ref& cell_ref, unsigned long long query_id) const; + bool unpack(vm::CellSlice& cs, Record_burn& data) const; + bool cell_unpack(Ref cell_ref, Record_burn& data) const; + bool pack(vm::CellBuilder& cb, const Record_burn& data) const; + bool cell_pack(Ref& cell_ref, const Record_burn& data) const; + bool unpack(vm::CellSlice& cs, Record_transfer_nft& data) const; + bool cell_unpack(Ref cell_ref, Record_transfer_nft& data) const; + bool pack(vm::CellBuilder& cb, const Record_transfer_nft& data) const; + bool cell_pack(Ref& cell_ref, const Record_transfer_nft& data) const; + bool unpack(vm::CellSlice& cs, Record_internal_transfer& data) const; + bool cell_unpack(Ref cell_ref, Record_internal_transfer& data) const; + bool pack(vm::CellBuilder& cb, const Record_internal_transfer& data) const; + bool cell_pack(Ref& cell_ref, const Record_internal_transfer& data) const; + bool unpack(vm::CellSlice& cs, Record_burn_notification& data) const; + bool cell_unpack(Ref cell_ref, Record_burn_notification& data) const; + bool pack(vm::CellBuilder& cb, const Record_burn_notification& data) const; + bool cell_pack(Ref& cell_ref, const Record_burn_notification& data) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "InternalMsgBody"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return cs.bselect(6, 0x20002050c00008ULL); + } +}; + +struct InternalMsgBody::Record_transfer_jetton { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Ref amount; // amount : VarUInteger 16 + Ref destination; // destination : MsgAddress + Ref response_destination; // response_destination : MsgAddress + Ref custom_payload; // custom_payload : Maybe ^Cell + Ref forward_ton_amount; // forward_ton_amount : VarUInteger 16 + Ref forward_payload; // forward_payload : Either Cell ^Cell + Record_transfer_jetton() = default; + Record_transfer_jetton(unsigned long long _query_id, Ref _amount, Ref _destination, Ref _response_destination, Ref _custom_payload, Ref _forward_ton_amount, Ref _forward_payload) : query_id(_query_id), amount(std::move(_amount)), destination(std::move(_destination)), response_destination(std::move(_response_destination)), custom_payload(std::move(_custom_payload)), forward_ton_amount(std::move(_forward_ton_amount)), forward_payload(std::move(_forward_payload)) {} +}; + +struct InternalMsgBody::Record_transfer_notification { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Ref amount; // amount : VarUInteger 16 + Ref sender; // sender : MsgAddress + Ref forward_payload; // forward_payload : Either Cell ^Cell + Record_transfer_notification() = default; + Record_transfer_notification(unsigned long long _query_id, Ref _amount, Ref _sender, Ref _forward_payload) : query_id(_query_id), amount(std::move(_amount)), sender(std::move(_sender)), forward_payload(std::move(_forward_payload)) {} +}; + +struct InternalMsgBody::Record_burn { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Ref amount; // amount : VarUInteger 16 + Ref response_destination; // response_destination : MsgAddress + Ref custom_payload; // custom_payload : Maybe ^Cell + Record_burn() = default; + Record_burn(unsigned long long _query_id, Ref _amount, Ref _response_destination, Ref _custom_payload) : query_id(_query_id), amount(std::move(_amount)), response_destination(std::move(_response_destination)), custom_payload(std::move(_custom_payload)) {} +}; + +struct InternalMsgBody::Record_transfer_nft { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Ref new_owner; // new_owner : MsgAddress + Ref response_destination; // response_destination : MsgAddress + Ref custom_payload; // custom_payload : Maybe ^Cell + Ref forward_amount; // forward_amount : VarUInteger 16 + Ref forward_payload; // forward_payload : Either Cell ^Cell + Record_transfer_nft() = default; + Record_transfer_nft(unsigned long long _query_id, Ref _new_owner, Ref _response_destination, Ref _custom_payload, Ref _forward_amount, Ref _forward_payload) : query_id(_query_id), new_owner(std::move(_new_owner)), response_destination(std::move(_response_destination)), custom_payload(std::move(_custom_payload)), forward_amount(std::move(_forward_amount)), forward_payload(std::move(_forward_payload)) {} +}; + +struct InternalMsgBody::Record_internal_transfer { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Ref amount; // amount : VarUInteger 16 + Ref from; // from : MsgAddress + Ref response_address; // response_address : MsgAddress + Ref forward_ton_amount; // forward_ton_amount : VarUInteger 16 + Ref forward_payload; // forward_payload : Either Cell ^Cell + Record_internal_transfer() = default; + Record_internal_transfer(unsigned long long _query_id, Ref _amount, Ref _from, Ref _response_address, Ref _forward_ton_amount, Ref _forward_payload) : query_id(_query_id), amount(std::move(_amount)), from(std::move(_from)), response_address(std::move(_response_address)), forward_ton_amount(std::move(_forward_ton_amount)), forward_payload(std::move(_forward_payload)) {} +}; + +struct InternalMsgBody::Record_burn_notification { + typedef InternalMsgBody type_class; + unsigned long long query_id; // query_id : uint64 + Ref amount; // amount : VarUInteger 16 + Ref sender; // sender : MsgAddress + Ref response_destination; // response_destination : MsgAddress + Record_burn_notification() = default; + Record_burn_notification(unsigned long long _query_id, Ref _amount, Ref _sender, Ref _response_destination) : query_id(_query_id), amount(std::move(_amount)), sender(std::move(_sender)), response_destination(std::move(_response_destination)) {} +}; + +extern const InternalMsgBody t_InternalMsgBody; + +// +// headers for type `Bit` +// + +struct Bit final : TLB_Complex { + enum { bit }; + static constexpr int cons_len_exact = 0; + struct Record { + typedef Bit type_class; + bool x; // ## 1 + Record() = default; + Record(bool _x) : x(_x) {} + }; + int get_size(const vm::CellSlice& cs) const override { + return 1; + } + bool skip(vm::CellSlice& cs) const override { + return cs.advance(1); + } + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override { + return cs.advance(1); + } + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_bit(vm::CellSlice& cs, bool& x) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_bit(Ref cell_ref, bool& x) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_bit(vm::CellBuilder& cb, bool x) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_bit(Ref& cell_ref, bool x) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "Bit"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const Bit t_Bit; + +// +// headers for type `Hashmap` +// + +struct Hashmap final : TLB_Complex { + enum { hm_edge }; + static constexpr int cons_len_exact = 0; + int m_; + const TLB &X_; + Hashmap(int m, const TLB& X) : m_(m), X_(X) {} + struct Record; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "(Hashmap " << m_ << " " << X_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +struct Hashmap::Record { + typedef Hashmap type_class; + int n; // n : # + int l; // l : # + int m; // m : # + Ref label; // label : HmLabel ~l n + Ref node; // node : HashmapNode m X + Record() = default; + Record(Ref _label, Ref _node) : n(-1), l(-1), m(-1), label(std::move(_label)), node(std::move(_node)) {} +}; + +// +// headers for type `HashmapNode` +// + +struct HashmapNode final : TLB_Complex { + enum { hmn_leaf, hmn_fork }; + static constexpr int cons_len_exact = 0; + int m_; + const TLB &X_; + HashmapNode(int m, const TLB& X) : m_(m), X_(X) {} + struct Record_hmn_leaf { + typedef HashmapNode type_class; + Ref value; // value : X + Record_hmn_leaf() = default; + Record_hmn_leaf(Ref _value) : value(std::move(_value)) {} + }; + struct Record_hmn_fork; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_hmn_leaf& data) const; + bool unpack_hmn_leaf(vm::CellSlice& cs, Ref& value) const; + bool cell_unpack(Ref cell_ref, Record_hmn_leaf& data) const; + bool cell_unpack_hmn_leaf(Ref cell_ref, Ref& value) const; + bool pack(vm::CellBuilder& cb, const Record_hmn_leaf& data) const; + bool pack_hmn_leaf(vm::CellBuilder& cb, Ref value) const; + bool cell_pack(Ref& cell_ref, const Record_hmn_leaf& data) const; + bool cell_pack_hmn_leaf(Ref& cell_ref, Ref value) const; + bool unpack(vm::CellSlice& cs, Record_hmn_fork& data) const; + bool unpack_hmn_fork(vm::CellSlice& cs, int& n, Ref& left, Ref& right) const; + bool cell_unpack(Ref cell_ref, Record_hmn_fork& data) const; + bool cell_unpack_hmn_fork(Ref cell_ref, int& n, Ref& left, Ref& right) const; + bool pack(vm::CellBuilder& cb, const Record_hmn_fork& data) const; + bool pack_hmn_fork(vm::CellBuilder& cb, Ref left, Ref right) const; + bool cell_pack(Ref& cell_ref, const Record_hmn_fork& data) const; + bool cell_pack_hmn_fork(Ref& cell_ref, Ref left, Ref right) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "(HashmapNode " << m_ << " " << X_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override; +}; + +struct HashmapNode::Record_hmn_fork { + typedef HashmapNode type_class; + int n; // n : # + Ref left; // left : ^(Hashmap n X) + Ref right; // right : ^(Hashmap n X) + Record_hmn_fork() = default; + Record_hmn_fork(Ref _left, Ref _right) : n(-1), left(std::move(_left)), right(std::move(_right)) {} +}; + +// +// headers for type `HmLabel` +// + +struct HmLabel final : TLB_Complex { + enum { hml_short, hml_long, hml_same }; + static constexpr char cons_len[3] = { 1, 2, 2 }; + static constexpr unsigned char cons_tag[3] = { 0, 2, 3 }; + int n_; + HmLabel(int n) : n_(n) {} + struct Record_hml_short; + struct Record_hml_long; + struct Record_hml_same; + bool skip(vm::CellSlice& cs) const override; + bool skip(vm::CellSlice& cs, int& m_) const; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool validate_skip(int *ops, vm::CellSlice& cs, bool weak, int& m_) const; + bool fetch_to(vm::CellSlice& cs, Ref& res, int& m_) const; + bool unpack(vm::CellSlice& cs, Record_hml_short& data, int& m_) const; + bool cell_unpack(Ref cell_ref, Record_hml_short& data, int& m_) const; + bool pack(vm::CellBuilder& cb, const Record_hml_short& data, int& m_) const; + bool cell_pack(Ref& cell_ref, const Record_hml_short& data, int& m_) const; + bool unpack(vm::CellSlice& cs, Record_hml_long& data, int& m_) const; + bool unpack_hml_long(vm::CellSlice& cs, int& m, int& n, Ref& s, int& m_) const; + bool cell_unpack(Ref cell_ref, Record_hml_long& data, int& m_) const; + bool cell_unpack_hml_long(Ref cell_ref, int& m, int& n, Ref& s, int& m_) const; + bool pack(vm::CellBuilder& cb, const Record_hml_long& data, int& m_) const; + bool pack_hml_long(vm::CellBuilder& cb, int n, Ref s, int& m_) const; + bool cell_pack(Ref& cell_ref, const Record_hml_long& data, int& m_) const; + bool cell_pack_hml_long(Ref& cell_ref, int n, Ref s, int& m_) const; + bool unpack(vm::CellSlice& cs, Record_hml_same& data, int& m_) const; + bool unpack_hml_same(vm::CellSlice& cs, int& m, bool& v, int& n, int& m_) const; + bool cell_unpack(Ref cell_ref, Record_hml_same& data, int& m_) const; + bool cell_unpack_hml_same(Ref cell_ref, int& m, bool& v, int& n, int& m_) const; + bool pack(vm::CellBuilder& cb, const Record_hml_same& data, int& m_) const; + bool pack_hml_same(vm::CellBuilder& cb, bool v, int n, int& m_) const; + bool cell_pack(Ref& cell_ref, const Record_hml_same& data, int& m_) const; + bool cell_pack_hml_same(Ref& cell_ref, bool v, int n, int& m_) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs, int& m_) const; + std::ostream& print_type(std::ostream& os) const override { + return os << "(HmLabel ~m_ " << n_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return cs.bselect(2, 13); + } +}; + +struct HmLabel::Record_hml_short { + typedef HmLabel type_class; + int m; // m : # + int n; // n : # + Ref len; // len : Unary ~n + Ref s; // s : n * Bit + Record_hml_short() = default; + Record_hml_short(Ref _len, Ref _s) : m(-1), n(-1), len(std::move(_len)), s(std::move(_s)) {} +}; + +struct HmLabel::Record_hml_long { + typedef HmLabel type_class; + int m; // m : # + int n; // n : #<= m + Ref s; // s : n * Bit + Record_hml_long() = default; + Record_hml_long(int _n, Ref _s) : m(-1), n(_n), s(std::move(_s)) {} +}; + +struct HmLabel::Record_hml_same { + typedef HmLabel type_class; + int m; // m : # + bool v; // v : Bit + int n; // n : #<= m + Record_hml_same() = default; + Record_hml_same(bool _v, int _n) : m(-1), v(_v), n(_n) {} +}; + +// +// headers for type `Unary` +// + +struct Unary final : TLB_Complex { + enum { unary_zero, unary_succ }; + static constexpr int cons_len_exact = 1; + struct Record_unary_zero { + typedef Unary type_class; + }; + struct Record_unary_succ { + typedef Unary type_class; + int n; // n : # + Ref x; // x : Unary ~n + Record_unary_succ() = default; + Record_unary_succ(Ref _x) : n(-1), x(std::move(_x)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool skip(vm::CellSlice& cs, int& m_) const; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool validate_skip(int *ops, vm::CellSlice& cs, bool weak, int& m_) const; + bool fetch_to(vm::CellSlice& cs, Ref& res, int& m_) const; + bool unpack(vm::CellSlice& cs, Record_unary_zero& data, int& m_) const; + bool unpack_unary_zero(vm::CellSlice& cs, int& m_) const; + bool cell_unpack(Ref cell_ref, Record_unary_zero& data, int& m_) const; + bool cell_unpack_unary_zero(Ref cell_ref, int& m_) const; + bool pack(vm::CellBuilder& cb, const Record_unary_zero& data, int& m_) const; + bool pack_unary_zero(vm::CellBuilder& cb, int& m_) const; + bool cell_pack(Ref& cell_ref, const Record_unary_zero& data, int& m_) const; + bool cell_pack_unary_zero(Ref& cell_ref, int& m_) const; + bool unpack(vm::CellSlice& cs, Record_unary_succ& data, int& m_) const; + bool unpack_unary_succ(vm::CellSlice& cs, int& n, Ref& x, int& m_) const; + bool cell_unpack(Ref cell_ref, Record_unary_succ& data, int& m_) const; + bool cell_unpack_unary_succ(Ref cell_ref, int& n, Ref& x, int& m_) const; + bool pack(vm::CellBuilder& cb, const Record_unary_succ& data, int& m_) const; + bool pack_unary_succ(vm::CellBuilder& cb, Ref x, int& m_) const; + bool cell_pack(Ref& cell_ref, const Record_unary_succ& data, int& m_) const; + bool cell_pack_unary_succ(Ref& cell_ref, Ref x, int& m_) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs, int& m_) const; + std::ostream& print_type(std::ostream& os) const override { + return os << "(Unary ~m_)"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +extern const Unary t_Unary; + +// +// headers for type `HashmapE` +// + +struct HashmapE final : TLB_Complex { + enum { hme_empty, hme_root }; + static constexpr int cons_len_exact = 1; + int m_; + const TLB &X_; + HashmapE(int m, const TLB& X) : m_(m), X_(X) {} + struct Record_hme_empty { + typedef HashmapE type_class; + }; + struct Record_hme_root { + typedef HashmapE type_class; + int n; // n : # + Ref root; // root : ^(Hashmap n X) + Record_hme_root() = default; + Record_hme_root(Ref _root) : n(-1), root(std::move(_root)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_hme_empty& data) const; + bool unpack_hme_empty(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record_hme_empty& data) const; + bool cell_unpack_hme_empty(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record_hme_empty& data) const; + bool pack_hme_empty(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record_hme_empty& data) const; + bool cell_pack_hme_empty(Ref& cell_ref) const; + bool unpack(vm::CellSlice& cs, Record_hme_root& data) const; + bool unpack_hme_root(vm::CellSlice& cs, int& n, Ref& root) const; + bool cell_unpack(Ref cell_ref, Record_hme_root& data) const; + bool cell_unpack_hme_root(Ref cell_ref, int& n, Ref& root) const; + bool pack(vm::CellBuilder& cb, const Record_hme_root& data) const; + bool pack_hme_root(vm::CellBuilder& cb, Ref root) const; + bool cell_pack(Ref& cell_ref, const Record_hme_root& data) const; + bool cell_pack_hme_root(Ref& cell_ref, Ref root) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "(HashmapE " << m_ << " " << X_ << ")"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +// +// headers for type `ChunkedData` +// + +struct ChunkedData final : TLB_Complex { + enum { chunked_data }; + static constexpr int cons_len_exact = 0; + struct Record { + typedef ChunkedData type_class; + Ref data; // data : HashmapE 32 ^Cell + Record() = default; + Record(Ref _data) : data(std::move(_data)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_chunked_data(vm::CellSlice& cs, Ref& data) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_chunked_data(Ref cell_ref, Ref& data) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_chunked_data(vm::CellBuilder& cb, Ref data) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_chunked_data(Ref& cell_ref, Ref data) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "ChunkedData"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const ChunkedData t_ChunkedData; + +// +// headers for type `Text` +// + +struct Text final : TLB_Complex { + enum { text }; + static constexpr int cons_len_exact = 0; + struct Record { + typedef Text type_class; + Ref data; // data : Cell + Record() = default; + Record(Ref _data) : data(std::move(_data)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_text(vm::CellSlice& cs, Ref& data) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_text(Ref cell_ref, Ref& data) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_text(vm::CellBuilder& cb, Ref data) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_text(Ref& cell_ref, Ref data) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "Text"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const Text t_Text; + +// +// headers for type `ContentData` +// + +struct ContentData final : TLB_Complex { + enum { snake, chunks }; + static constexpr int cons_len_exact = 8; + struct Record_snake { + typedef ContentData type_class; + Ref data; // data : Cell + Record_snake() = default; + Record_snake(Ref _data) : data(std::move(_data)) {} + }; + struct Record_chunks { + typedef ContentData type_class; + Ref data; // data : ChunkedData + Record_chunks() = default; + Record_chunks(Ref _data) : data(std::move(_data)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_snake& data) const; + bool unpack_snake(vm::CellSlice& cs, Ref& data) const; + bool cell_unpack(Ref cell_ref, Record_snake& data) const; + bool cell_unpack_snake(Ref cell_ref, Ref& data) const; + bool pack(vm::CellBuilder& cb, const Record_snake& data) const; + bool pack_snake(vm::CellBuilder& cb, Ref data) const; + bool cell_pack(Ref& cell_ref, const Record_snake& data) const; + bool cell_pack_snake(Ref& cell_ref, Ref data) const; + bool unpack(vm::CellSlice& cs, Record_chunks& data) const; + bool unpack_chunks(vm::CellSlice& cs, Ref& data) const; + bool cell_unpack(Ref cell_ref, Record_chunks& data) const; + bool cell_unpack_chunks(Ref cell_ref, Ref& data) const; + bool pack(vm::CellBuilder& cb, const Record_chunks& data) const; + bool pack_chunks(vm::CellBuilder& cb, Ref data) const; + bool cell_pack(Ref& cell_ref, const Record_chunks& data) const; + bool cell_pack_chunks(Ref& cell_ref, Ref data) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "ContentData"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override; +}; + +extern const ContentData t_ContentData; + +// +// headers for type `FullContent` +// + +struct FullContent final : TLB_Complex { + enum { onchain, offchain }; + static constexpr int cons_len_exact = 8; + struct Record_onchain { + typedef FullContent type_class; + Ref data; // data : HashmapE 256 ^ContentData + Record_onchain() = default; + Record_onchain(Ref _data) : data(std::move(_data)) {} + }; + struct Record_offchain { + typedef FullContent type_class; + Ref uri; // uri : Text + Record_offchain() = default; + Record_offchain(Ref _uri) : uri(std::move(_uri)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_onchain& data) const; + bool unpack_onchain(vm::CellSlice& cs, Ref& data) const; + bool cell_unpack(Ref cell_ref, Record_onchain& data) const; + bool cell_unpack_onchain(Ref cell_ref, Ref& data) const; + bool pack(vm::CellBuilder& cb, const Record_onchain& data) const; + bool pack_onchain(vm::CellBuilder& cb, Ref data) const; + bool cell_pack(Ref& cell_ref, const Record_onchain& data) const; + bool cell_pack_onchain(Ref& cell_ref, Ref data) const; + bool unpack(vm::CellSlice& cs, Record_offchain& data) const; + bool unpack_offchain(vm::CellSlice& cs, Ref& uri) const; + bool cell_unpack(Ref cell_ref, Record_offchain& data) const; + bool cell_unpack_offchain(Ref cell_ref, Ref& uri) const; + bool pack(vm::CellBuilder& cb, const Record_offchain& data) const; + bool pack_offchain(vm::CellBuilder& cb, Ref uri) const; + bool cell_pack(Ref& cell_ref, const Record_offchain& data) const; + bool cell_pack_offchain(Ref& cell_ref, Ref uri) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "FullContent"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override; +}; + +extern const FullContent t_FullContent; + +// +// headers for type `Protocol` +// + +struct Protocol final : TLB_Complex { + enum { proto_http }; + static constexpr int cons_len_exact = 16; + static constexpr unsigned short cons_tag[1] = { 0x4854 }; + struct Record { + typedef Protocol type_class; + }; + int get_size(const vm::CellSlice& cs) const override { + return 16; + } + bool skip(vm::CellSlice& cs) const override { + return cs.advance(16); + } + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool fetch_enum_to(vm::CellSlice& cs, char& value) const; + bool store_enum_from(vm::CellBuilder& cb, int value) const; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_proto_http(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_proto_http(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_proto_http(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_proto_http(Ref& cell_ref) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "Protocol"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const Protocol t_Protocol; + +// +// headers for type `ProtoList` +// + +struct ProtoList final : TLB_Complex { + enum { proto_list_nil, proto_list_next }; + static constexpr int cons_len_exact = 1; + struct Record_proto_list_nil { + typedef ProtoList type_class; + }; + struct Record_proto_list_next { + typedef ProtoList type_class; + char head; // head : Protocol + Ref tail; // tail : ProtoList + Record_proto_list_next() = default; + Record_proto_list_next(char _head, Ref _tail) : head(_head), tail(std::move(_tail)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_proto_list_nil& data) const; + bool unpack_proto_list_nil(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record_proto_list_nil& data) const; + bool cell_unpack_proto_list_nil(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record_proto_list_nil& data) const; + bool pack_proto_list_nil(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record_proto_list_nil& data) const; + bool cell_pack_proto_list_nil(Ref& cell_ref) const; + bool unpack(vm::CellSlice& cs, Record_proto_list_next& data) const; + bool unpack_proto_list_next(vm::CellSlice& cs, char& head, Ref& tail) const; + bool cell_unpack(Ref cell_ref, Record_proto_list_next& data) const; + bool cell_unpack_proto_list_next(Ref cell_ref, char& head, Ref& tail) const; + bool pack(vm::CellBuilder& cb, const Record_proto_list_next& data) const; + bool pack_proto_list_next(vm::CellBuilder& cb, char head, Ref tail) const; + bool cell_pack(Ref& cell_ref, const Record_proto_list_next& data) const; + bool cell_pack_proto_list_next(Ref& cell_ref, char head, Ref tail) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "ProtoList"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +extern const ProtoList t_ProtoList; + +// +// headers for type `SmcCapability` +// + +struct SmcCapability final : TLB_Complex { + enum { cap_is_wallet }; + static constexpr int cons_len_exact = 16; + static constexpr unsigned short cons_tag[1] = { 0x2177 }; + struct Record { + typedef SmcCapability type_class; + }; + int get_size(const vm::CellSlice& cs) const override { + return 16; + } + bool skip(vm::CellSlice& cs) const override { + return cs.advance(16); + } + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool fetch_enum_to(vm::CellSlice& cs, char& value) const; + bool store_enum_from(vm::CellBuilder& cb, int value) const; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_cap_is_wallet(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_cap_is_wallet(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_cap_is_wallet(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_cap_is_wallet(Ref& cell_ref) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "SmcCapability"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const SmcCapability t_SmcCapability; + +// +// headers for type `SmcCapList` +// + +struct SmcCapList final : TLB_Complex { + enum { cap_list_nil, cap_list_next }; + static constexpr int cons_len_exact = 1; + struct Record_cap_list_nil { + typedef SmcCapList type_class; + }; + struct Record_cap_list_next { + typedef SmcCapList type_class; + char head; // head : SmcCapability + Ref tail; // tail : SmcCapList + Record_cap_list_next() = default; + Record_cap_list_next(char _head, Ref _tail) : head(_head), tail(std::move(_tail)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_cap_list_nil& data) const; + bool unpack_cap_list_nil(vm::CellSlice& cs) const; + bool cell_unpack(Ref cell_ref, Record_cap_list_nil& data) const; + bool cell_unpack_cap_list_nil(Ref cell_ref) const; + bool pack(vm::CellBuilder& cb, const Record_cap_list_nil& data) const; + bool pack_cap_list_nil(vm::CellBuilder& cb) const; + bool cell_pack(Ref& cell_ref, const Record_cap_list_nil& data) const; + bool cell_pack_cap_list_nil(Ref& cell_ref) const; + bool unpack(vm::CellSlice& cs, Record_cap_list_next& data) const; + bool unpack_cap_list_next(vm::CellSlice& cs, char& head, Ref& tail) const; + bool cell_unpack(Ref cell_ref, Record_cap_list_next& data) const; + bool cell_unpack_cap_list_next(Ref cell_ref, char& head, Ref& tail) const; + bool pack(vm::CellBuilder& cb, const Record_cap_list_next& data) const; + bool pack_cap_list_next(vm::CellBuilder& cb, char head, Ref tail) const; + bool cell_pack(Ref& cell_ref, const Record_cap_list_next& data) const; + bool cell_pack_cap_list_next(Ref& cell_ref, char head, Ref tail) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "SmcCapList"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return (int)cs.prefetch_ulong(1); + } +}; + +extern const SmcCapList t_SmcCapList; + +// +// headers for type `DNSRecord` +// + +struct DNSRecord final : TLB_Complex { + enum { dns_storage_address, dns_smc_address, dns_adnl_address, dns_next_resolver }; + static constexpr int cons_len_exact = 16; + static constexpr unsigned short cons_tag[4] = { 0x7473, 0x9fd3, 0xad01, 0xba93 }; + struct Record_dns_smc_address; + struct Record_dns_next_resolver { + typedef DNSRecord type_class; + Ref resolver; // resolver : MsgAddressInt + Record_dns_next_resolver() = default; + Record_dns_next_resolver(Ref _resolver) : resolver(std::move(_resolver)) {} + }; + struct Record_dns_adnl_address; + struct Record_dns_storage_address { + typedef DNSRecord type_class; + td::BitArray<256> bag_id; // bag_id : bits256 + Record_dns_storage_address() = default; + Record_dns_storage_address(const td::BitArray<256>& _bag_id) : bag_id(_bag_id) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record_dns_smc_address& data) const; + bool unpack_dns_smc_address(vm::CellSlice& cs, Ref& smc_addr, int& flags, Ref& cap_list) const; + bool cell_unpack(Ref cell_ref, Record_dns_smc_address& data) const; + bool cell_unpack_dns_smc_address(Ref cell_ref, Ref& smc_addr, int& flags, Ref& cap_list) const; + bool pack(vm::CellBuilder& cb, const Record_dns_smc_address& data) const; + bool pack_dns_smc_address(vm::CellBuilder& cb, Ref smc_addr, int flags, Ref cap_list) const; + bool cell_pack(Ref& cell_ref, const Record_dns_smc_address& data) const; + bool cell_pack_dns_smc_address(Ref& cell_ref, Ref smc_addr, int flags, Ref cap_list) const; + bool unpack(vm::CellSlice& cs, Record_dns_next_resolver& data) const; + bool unpack_dns_next_resolver(vm::CellSlice& cs, Ref& resolver) const; + bool cell_unpack(Ref cell_ref, Record_dns_next_resolver& data) const; + bool cell_unpack_dns_next_resolver(Ref cell_ref, Ref& resolver) const; + bool pack(vm::CellBuilder& cb, const Record_dns_next_resolver& data) const; + bool pack_dns_next_resolver(vm::CellBuilder& cb, Ref resolver) const; + bool cell_pack(Ref& cell_ref, const Record_dns_next_resolver& data) const; + bool cell_pack_dns_next_resolver(Ref& cell_ref, Ref resolver) const; + bool unpack(vm::CellSlice& cs, Record_dns_adnl_address& data) const; + bool unpack_dns_adnl_address(vm::CellSlice& cs, td::BitArray<256>& adnl_addr, int& flags, Ref& proto_list) const; + bool cell_unpack(Ref cell_ref, Record_dns_adnl_address& data) const; + bool cell_unpack_dns_adnl_address(Ref cell_ref, td::BitArray<256>& adnl_addr, int& flags, Ref& proto_list) const; + bool pack(vm::CellBuilder& cb, const Record_dns_adnl_address& data) const; + bool pack_dns_adnl_address(vm::CellBuilder& cb, td::BitArray<256> adnl_addr, int flags, Ref proto_list) const; + bool cell_pack(Ref& cell_ref, const Record_dns_adnl_address& data) const; + bool cell_pack_dns_adnl_address(Ref& cell_ref, td::BitArray<256> adnl_addr, int flags, Ref proto_list) const; + bool unpack(vm::CellSlice& cs, Record_dns_storage_address& data) const; + bool unpack_dns_storage_address(vm::CellSlice& cs, td::BitArray<256>& bag_id) const; + bool cell_unpack(Ref cell_ref, Record_dns_storage_address& data) const; + bool cell_unpack_dns_storage_address(Ref cell_ref, td::BitArray<256>& bag_id) const; + bool pack(vm::CellBuilder& cb, const Record_dns_storage_address& data) const; + bool pack_dns_storage_address(vm::CellBuilder& cb, td::BitArray<256> bag_id) const; + bool cell_pack(Ref& cell_ref, const Record_dns_storage_address& data) const; + bool cell_pack_dns_storage_address(Ref& cell_ref, td::BitArray<256> bag_id) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "DNSRecord"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return cs.bselect(4, 0xe80); + } +}; + +struct DNSRecord::Record_dns_smc_address { + typedef DNSRecord type_class; + Ref smc_addr; // smc_addr : MsgAddressInt + int flags; // flags : ## 8 + Ref cap_list; // cap_list : flags.0?SmcCapList + Record_dns_smc_address() = default; + Record_dns_smc_address(Ref _smc_addr, int _flags, Ref _cap_list) : smc_addr(std::move(_smc_addr)), flags(_flags), cap_list(std::move(_cap_list)) {} +}; + +struct DNSRecord::Record_dns_adnl_address { + typedef DNSRecord type_class; + td::BitArray<256> adnl_addr; // adnl_addr : bits256 + int flags; // flags : ## 8 + Ref proto_list; // proto_list : flags.0?ProtoList + Record_dns_adnl_address() = default; + Record_dns_adnl_address(const td::BitArray<256>& _adnl_addr, int _flags, Ref _proto_list) : adnl_addr(_adnl_addr), flags(_flags), proto_list(std::move(_proto_list)) {} +}; + +extern const DNSRecord t_DNSRecord; + +// +// headers for type `DNS_RecordSet` +// + +struct DNS_RecordSet final : TLB_Complex { + enum { cons1 }; + static constexpr int cons_len_exact = 0; + struct Record { + typedef DNS_RecordSet type_class; + Ref x; // HashmapE 256 ^DNSRecord + Record() = default; + Record(Ref _x) : x(std::move(_x)) {} + }; + bool skip(vm::CellSlice& cs) const override; + bool validate_skip(int* ops, vm::CellSlice& cs, bool weak = false) const override; + bool unpack(vm::CellSlice& cs, Record& data) const; + bool unpack_cons1(vm::CellSlice& cs, Ref& x) const; + bool cell_unpack(Ref cell_ref, Record& data) const; + bool cell_unpack_cons1(Ref cell_ref, Ref& x) const; + bool pack(vm::CellBuilder& cb, const Record& data) const; + bool pack_cons1(vm::CellBuilder& cb, Ref x) const; + bool cell_pack(Ref& cell_ref, const Record& data) const; + bool cell_pack_cons1(Ref& cell_ref, Ref x) const; + bool print_skip(PrettyPrinter& pp, vm::CellSlice& cs) const override; + std::ostream& print_type(std::ostream& os) const override { + return os << "DNS_RecordSet"; + } + int check_tag(const vm::CellSlice& cs) const override; + int get_tag(const vm::CellSlice& cs) const override { + return 0; + } +}; + +extern const DNS_RecordSet t_DNS_RecordSet; + +// declarations of constant types used + +// ## 9 +extern const NatWidth t_natwidth_9; +// #<= 30 +extern const NatLeq t_natleq_30; +// Maybe Anycast +extern const Maybe t_Maybe_Anycast; +// int8 +extern const Int t_int8; +// bits256 +extern const Bits t_bits256; +// int32 +extern const Int t_int32; +// uint64 +extern const UInt t_uint64; +// VarUInteger 16 +extern const VarUInteger t_VarUInteger_16; +// Maybe ^Cell +extern const Maybe t_Maybe_Ref_Cell; +// Either Cell ^Cell +extern const Either t_Either_Cell_Ref_Cell; +// ## 1 +extern const NatWidth t_natwidth_1; +// HashmapE 32 ^Cell +extern const HashmapE t_HashmapE_32_Ref_Cell; +// ^ContentData +extern const RefT t_Ref_ContentData; +// HashmapE 256 ^ContentData +extern const HashmapE t_HashmapE_256_Ref_ContentData; +// ## 8 +extern const NatWidth t_natwidth_8; +// ^DNSRecord +extern const RefT t_Ref_DNSRecord; +// HashmapE 256 ^DNSRecord +extern const HashmapE t_HashmapE_256_Ref_DNSRecord; + +// declaration of type name registration function +extern bool register_simple_types(std::function func); + +} // namespace gen + +} // namespace tokens diff --git a/ton-http-api/tonlib_worker.cpp b/ton-http-api/src/core/tonlib_worker.cpp similarity index 65% rename from ton-http-api/tonlib_worker.cpp rename to ton-http-api/src/core/tonlib_worker.cpp index 7ef3f44..b4ec057 100644 --- a/ton-http-api/tonlib_worker.cpp +++ b/ton-http-api/src/core/tonlib_worker.cpp @@ -1,219 +1,31 @@ #include "tonlib_worker.h" -#include #include +#include "userver/chaotic/io/ton_http/types/ton_hash.hpp" #include "userver/formats/json.hpp" -#include "utils.hpp" +#include "utils/common.hpp" -namespace ton_http::core { -template -auto tl_to_json(const T& value) { - return userver::formats::json::FromString(td::json_encode(td::ToJson(value))); -} +namespace ton_http::core { template auto value_or_default(const std::optional& arg, const T2& def) { return (arg.has_value() ? arg.value() : (def)); } -std::string DetectAddressResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder; - builder["raw_form"] = to_raw_form(true); - for (const bool bounce : {true, false}) { - block::StdAddress b_addr(address); - b_addr.bounceable = bounce; - const std::string field_name = (bounce ? "bounceable" : "non_bounceable"); - builder[field_name]["b64"] = b_addr.rserialize(false); - builder[field_name]["b64url"] = b_addr.rserialize(true); - } - builder["given_type"] = given_type; - builder["test_only"] = address.testnet; - - auto res = ToString(builder.ExtractValue()); - return std::move(res); -} -std::string DetectAddressResult::to_raw_form(bool lower) const { - td::StringBuilder sb; - sb << address.workchain << ":" << address.addr.to_hex(); - auto raw_form = sb.as_cslice().str(); - if (lower) { - std::ranges::transform(raw_form, raw_form.begin(), ::tolower); - } - return std::move(raw_form); -} -std::string DetectHashResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder; - builder["b64"] = td::base64_encode(hash); - builder["b64url"] = td::base64url_encode(hash); - builder["hex"] = td::hex_encode(hash); - auto res = ToString(builder.ExtractValue()); - return std::move(res); -} -std::string ConsensusBlockResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder; - builder["consensus_block"] = seqno; - builder["timestamp"] = timestamp; - auto res = ToString(builder.ExtractValue()); - return std::move(res); -} -std::string RunGetMethodResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder(tl_to_json(result)); - builder["block_id"] = tl_to_json(state->block_id_); - builder["last_transaction_id"] = tl_to_json(state->last_transaction_id_); - return std::move(ToString(builder.ExtractValue())); -} - -std::string TokenDataResult::to_json_string() const { - return "{\"error\": \"why?\"}"; -} - -std::string JettonMasterDataResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder; - builder["address"] = address_; - builder["contract_type"] = "jetton_master"; - builder["total_supply"] = total_supply_; - builder["mintable"] = mintable_; - builder["admin_address"] = admin_address_; - if (jetton_content_onchain_) { - builder["jetton_content"]["type"] = "onchain"; - for (auto& [k, v] : jetton_content_) { - builder["jetton_content"]["data"][k] = v; - } - } else { - builder["jetton_content"]["type"] = "offchain"; - if (jetton_content_.contains("uri")) { - builder["jetton_content"]["data"] = jetton_content_.at("uri"); - } - } - builder["jetton_wallet_code"] = jetton_wallet_code_; - return std::move(ToString(builder.ExtractValue())); -} - -std::string JettonWalletDataResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder; - builder["address"] = address_; - builder["contract_type"] = "jetton_wallet"; - builder["balance"] = balance_; - builder["owner"] = owner_address_; - builder["jetton"] = jetton_master_address_; - builder["jetton_wallet_code"] = jetton_wallet_code_; - if (mintless_is_claimed_.has_value()) { - builder["mintless_is_claimed"] = mintless_is_claimed_.value(); - } - builder["is_validated"] = is_validated_; - return std::move(ToString(builder.ExtractValue())); -} - -std::string NFTCollectionDataResult::to_json_string() const { - using namespace userver::formats::json; - - ValueBuilder builder; - builder["address"] = address_; - builder["contract_type"] = "nft_collection"; - builder["next_item_index"] = next_item_index_; - if (owner_address_.length() > 0) { - builder["owner_address"] = owner_address_; - } - if (collection_content_onchain_) { - builder["collection_content"]["type"] = "onchain"; - for (auto& [k, v] : collection_content_) { - builder["collection_content"]["data"][k] = v; - } - } else { - builder["collection_content"]["type"] = "offchain"; - if (collection_content_.contains("uri")) { - builder["collection_content"]["data"] = collection_content_.at("uri"); - } - } - return std::move(ToString(builder.ExtractValue())); -} - -std::string NFTItemDataResult::to_json_string() const { - using namespace userver::formats::json; - ValueBuilder builder; - builder["address"] = address_; - builder["contract_type"] = "nft_item"; - builder["init"] = init_; - builder["index"] = index_; - if (!owner_address_.empty()) { - builder["owner_address"] = owner_address_; - } - if (!collection_address_.empty()) { - builder["collection_address"] = collection_address_; - } - if (is_dns_) { - if (!domain_.empty() && !collection_address_.empty()) { - if (auto suffix = utils::TonDnsRoots.find(collection_address_); suffix != utils::TonDnsRoots.end()) { - builder["content"]["domain"] = domain_ + suffix->second; - } - } - auto content_builder = builder["content"]["data"]; - for (auto& [key, value] : dns_content_) { - ValueBuilder item_builder; - if (std::holds_alternative(value)) { - auto& v = std::get(value); - item_builder["@type"] = utils::DnsRecordAdnlAddress::kType; - item_builder["andl_addr"] = v.adnl_addr; - } else if (std::holds_alternative(value)) { - auto& v = std::get(value); - item_builder["@type"] = utils::DnsRecordStorageAddress::kType; - item_builder["bag_id"] = v.bag_id; - } else if (std::holds_alternative(value)) { - auto& v = std::get(value); - item_builder["@type"] = utils::DnsRecordNextResolver::kType; - item_builder["resolver"]["type"] = "addr_std"; - item_builder["resolver"]["workchain_id"] = v.resolver.workchain; - item_builder["resolver"]["address"] = v.resolver.addr.to_hex(); - } else if (std::holds_alternative(value)) { - auto& v = std::get(value); - item_builder["@type"] = utils::DnsRecordSmcAddress::kType; - item_builder["smc_addr"]["type"] = "addr_std"; - item_builder["smc_addr"]["workchain_id"] = v.smc_addr.workchain; - item_builder["smc_addr"]["address"] = v.smc_addr.addr.to_hex(); - } - content_builder[key] = item_builder.ExtractValue(); - } - } else if (content_onchain_) { - builder["content"]["type"] = "onchain"; - for (auto& [k, v] : content_) { - builder["content"]["data"][k] = v; - } - } else { - builder["content"]["type"] = "offchain"; - if (content_.contains("uri")) { - builder["content"]["data"] = content_.at("uri"); - } - } - builder["is_validated"] = is_validated_; - return std::move(ToString(builder.ExtractValue())); -} - -TonlibWorker::Result TonlibWorker::getConsensusBlock(multiclient::SessionPtr session) const { +td::Result TonlibWorker::getConsensusBlock(multiclient::SessionPtr session) const { auto res = tonlib_.get_consensus_block(); if (res.is_error()) { - return {res.move_as_error(), session}; + return res.move_as_error(); } - return {ConsensusBlockResult{ res.move_as_ok(), std::time(nullptr) }, session}; + return ConsensusBlockResult{ res.move_as_ok(), std::time(nullptr) }; } -TonlibWorker::Result TonlibWorker::detectAddress(const std::string& address, multiclient::SessionPtr session) const { +td::Result TonlibWorker::detectAddress(const std::string& address, multiclient::SessionPtr session) const { auto r_std_address = block::StdAddress::parse(address); if (r_std_address.is_error()) { - return {r_std_address.move_as_error(), session}; + return r_std_address.move_as_error(); } const auto std_address = r_std_address.move_as_ok(); std::string given_type = "raw_form"; @@ -221,51 +33,51 @@ TonlibWorker::Result TonlibWorker::detectAddress(const std: given_type = std::string("friendly_") + (std_address.bounceable ? "bounceable" : "non_bounceable"); } DetectAddressResult result{std_address, given_type}; - return {std::move(result), session}; + return std::move(result); } -TonlibWorker::Result TonlibWorker::packAddress(const std::string& address, multiclient::SessionPtr session) const { +td::Result TonlibWorker::packAddress(const std::string& address, multiclient::SessionPtr session) const { auto r_std_address = block::StdAddress::parse(address); if (r_std_address.is_error()) { - return {r_std_address.move_as_error(), session}; + return r_std_address.move_as_error(); } const auto std_address = r_std_address.move_as_ok(); - return {std::move(std_address.rserialize(true)), session}; + return std::move(std_address.rserialize(true)); } -TonlibWorker::Result TonlibWorker::unpackAddress(const std::string& address, multiclient::SessionPtr session) const { +td::Result TonlibWorker::unpackAddress(const std::string& address, multiclient::SessionPtr session) const { block::StdAddress std_address; if (std_address.rdeserialize(address)) { const DetectAddressResult result{std_address, "unknown"}; - return {result.to_raw_form(true), session}; + return result.to_raw_form(true); } } -TonlibWorker::Result TonlibWorker::detectHash( +td::Result TonlibWorker::detectHash( const std::string& hash, multiclient::SessionPtr session ) const { auto raw_hash = utils::stringToHash(hash); if (!raw_hash.has_value()) { - return {td::Status::Error("Invalid hash"), session}; + return td::Status::Error("Invalid hash"); } DetectHashResult result{raw_hash.value()}; - return {std::move(result), session}; + return std::move(result); } -TonlibWorker::Result TonlibWorker::getTokenData( +td::Result TonlibWorker::getTokenData( const std::string& address, bool skip_verification, std::optional seqno, std::optional archival, multiclient::SessionPtr session ) const { - auto [r_jetton_master, _s1] = checkJettonMaster(address, skip_verification, seqno, archival, session); - auto [r_jetton_wallet, _s2] = checkJettonWallet(address, skip_verification, seqno, archival, session); - auto [r_nft_collection, _s3] = checkNFTCollection(address, skip_verification, seqno, archival, session); - auto [r_nft_item, _s4] = checkNFTItem(address, skip_verification, seqno, archival, session); + auto r_jetton_master = checkJettonMaster(address, skip_verification, seqno, archival, session); + auto r_jetton_wallet = checkJettonWallet(address, skip_verification, seqno, archival, session); + auto r_nft_collection = checkNFTCollection(address, skip_verification, seqno, archival, session); + auto r_nft_item = checkNFTItem(address, skip_verification, seqno, archival, session); if (r_jetton_master.is_ok()) { auto data = r_jetton_master.move_as_ok(); if (data) { - return {std::move(data), std::move(session)}; + return std::move(data); } } else { LOG(DEBUG) << "Jetton master: " << r_jetton_master.move_as_error(); @@ -273,7 +85,7 @@ TonlibWorker::Result TonlibWorker::getTokenData( if (r_jetton_wallet.is_ok()) { auto data = r_jetton_wallet.move_as_ok(); if (data) { - return {std::move(data), std::move(session)}; + return std::move(data); } } else { LOG(DEBUG) << "Jetton wallet: " << r_jetton_wallet.move_as_error(); @@ -282,7 +94,7 @@ TonlibWorker::Result TonlibWorker::getTokenData( if (r_nft_collection.is_ok()) { auto data = r_nft_collection.move_as_ok(); if (data) { - return {std::move(data), std::move(session)}; + return std::move(data); } } else { LOG(DEBUG) << "NFT collection: " << r_nft_collection.move_as_error(); @@ -291,47 +103,44 @@ TonlibWorker::Result TonlibWorker::getTokenData( if (r_nft_item.is_ok()) { auto data = r_nft_item.move_as_ok(); if (data) { - return {std::move(data), std::move(session)}; + return std::move(data); } } else { LOG(DEBUG) << "NFT item: " << r_nft_item.move_as_error(); } - return {td::Status::Error(409, PSLICE() << "Smart contract " << address << " is not Jetton or NFT"), std::move(session)}; + return td::Status::Error(409, PSLICE() << "Smart contract " << address << " is not Jetton or NFT"); } -TonlibWorker::Result TonlibWorker::getMasterchainInfo(multiclient::SessionPtr session) const { +td::Result TonlibWorker::getMasterchainInfo(multiclient::SessionPtr session) const { auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, .request_creator = [] { return tonlib_api::make_object(); }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } -TonlibWorker::Result TonlibWorker::getMasterchainBlockSignatures(ton::BlockSeqno seqno, +td::Result TonlibWorker::getMasterchainBlockSignatures(ton::BlockSeqno seqno, multiclient::SessionPtr session) const { auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, .request_creator = [seqno] { return tonlib_api::make_object(seqno); }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), session}; + return send_request_function(std::move(request), true); } -TonlibWorker::Result TonlibWorker::getAddressInformation( - std::string address, +td::Result TonlibWorker::getAddressInformation( + const std::string& address, std::optional seqno, multiclient::SessionPtr session ) const { tonlib_api::object_ptr with_block; if (seqno.has_value()) { - auto [res, new_session] = lookupBlock(ton::masterchainId, + auto res = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value(), std::nullopt, std::nullopt, session); if (!res.is_ok()) { - return {res.move_as_error(), new_session}; + return res.move_as_error(); } with_block = res.move_as_ok(); - session = std::move(new_session); } if (!with_block) { auto request = multiclient::RequestFunction{ @@ -344,8 +153,7 @@ TonlibWorker::Result TonlibWorker:: }, .session = session }; - auto [result, new_sesion] = send_request_function(std::move(request), true); - return {std::move(result), new_sesion}; + return send_request_function(std::move(request), true); } else { auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, @@ -367,27 +175,26 @@ TonlibWorker::Result TonlibWorker:: }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); + auto result = send_request_function(std::move(request), true); if (result.is_error()) { - return {result.move_as_error(), new_session}; + return result.move_as_error(); } - return {ton::move_tl_object_as(result.move_as_ok()), new_session}; + return ton::move_tl_object_as(result.move_as_ok()); } } -TonlibWorker::Result TonlibWorker::getExtendedAddressInformation( - std::string address, +td::Result TonlibWorker::getExtendedAddressInformation( + const std::string& address, std::optional seqno, multiclient::SessionPtr session ) const { tonlib_api::object_ptr with_block; if (seqno.has_value()) { - auto [res, new_session] = lookupBlock(ton::masterchainId, ton::shardIdAll, + auto res = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value(), std::nullopt, std::nullopt, session); if (!res.is_ok()) { - return {res.move_as_error(), new_session}; + return res.move_as_error(); } with_block = res.move_as_ok(); - session = std::move(new_session); } if (!with_block) { auto request = multiclient::RequestFunction{ @@ -400,8 +207,7 @@ TonlibWorker::Result TonlibWorker::getE }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, @@ -423,13 +229,13 @@ TonlibWorker::Result TonlibWorker::getE }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); + auto result = send_request_function(std::move(request), true); if (result.is_error()) { - return {result.move_as_error(), new_session}; + return result.move_as_error(); } - return {ton::move_tl_object_as(result.move_as_ok()), session}; + return ton::move_tl_object_as(result.move_as_ok()); } -TonlibWorker::Result TonlibWorker::lookupBlock( +td::Result TonlibWorker::lookupBlock( const ton::WorkchainId& workchain, const ton::ShardId& shard, const std::optional& seqno, @@ -438,7 +244,7 @@ TonlibWorker::Result TonlibWorker::l multiclient::SessionPtr session ) const { if (!(seqno.has_value() || lt.has_value() || unixtime.has_value())) { - return {td::Status::Error(416, "one of seqno, lt, unixtime should be specified"), session}; + return td::Status::Error(416, "one of seqno, lt, unixtime should be specified"); } int lookupMode = 0; if (seqno.has_value()) { @@ -465,10 +271,10 @@ TonlibWorker::Result TonlibWorker::l }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + auto result = send_request_function(std::move(request), true); + return std::move(result); } -TonlibWorker::Result TonlibWorker::getShardBlockProof( +td::Result TonlibWorker::getShardBlockProof( const ton::WorkchainId& workchain, const ton::ShardId& shard, const ton::BlockSeqno& seqno, @@ -476,13 +282,12 @@ TonlibWorker::Result TonlibWo multiclient::SessionPtr session ) const { std::int32_t mode = 0; - auto [r_blk_id, new_session] = lookupBlock(workchain, shard, seqno, + auto r_blk_id = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); if (r_blk_id.is_error()) { - return {r_blk_id.move_as_error(), new_session}; + return r_blk_id.move_as_error(); } auto blk_id = r_blk_id.move_as_ok(); - session = std::move(new_session); auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, @@ -503,12 +308,11 @@ TonlibWorker::Result TonlibWo tonlib_api::object_ptr from_blk_id = nullptr; if (from_seqno.has_value()) { mode = 1; - auto [r_from_blk_id, new_session] = lookupBlock(ton::masterchainId, ton::shardIdAll, from_seqno.value(), std::nullopt, std::nullopt, session); + auto r_from_blk_id = lookupBlock(ton::masterchainId, ton::shardIdAll, from_seqno.value(), std::nullopt, std::nullopt, session); if (r_from_blk_id.is_error()) { - return {r_from_blk_id.move_as_error_prefix("lookup from block error: "), new_session}; + return r_from_blk_id.move_as_error_prefix("lookup from block error: "); } from_blk_id = r_from_blk_id.move_as_ok(); - session = new_session; request.request_creator = [mode, w = blk_id->workchain_, s = blk_id->shard_, @@ -527,18 +331,18 @@ TonlibWorker::Result TonlibWo ); }; } - auto [result, new_session_2] = send_request_function(std::move(request), true); - return {std::move(result), new_session_2}; + auto result = send_request_function(std::move(request), true); + return std::move(result); } -TonlibWorker::Result TonlibWorker::getShards( +td::Result TonlibWorker::getShards( std::optional mc_seqno, std::optional lt, std::optional unixtime, multiclient::SessionPtr session ) const { - auto [r_blk_id, new_session] = lookupBlock(ton::masterchainId, ton::shardIdAll, mc_seqno, lt, unixtime, session); + auto r_blk_id = lookupBlock(ton::masterchainId, ton::shardIdAll, mc_seqno, lt, unixtime, session); if (r_blk_id.is_error()) { - return {r_blk_id.move_as_error(), new_session}; + return r_blk_id.move_as_error(); } auto blk_id = r_blk_id.move_as_ok(); auto request = multiclient::RequestFunction{ @@ -555,10 +359,9 @@ TonlibWorker::Result TonlibWorker::get }, .session = session }; - auto [result, new_session_2] = send_request_function(std::move(request), true); - return {std::move(result), new_session_2}; + return send_request_function(std::move(request), true); } -TonlibWorker::Result TonlibWorker::getBlockHeader( +td::Result TonlibWorker::getBlockHeader( const ton::WorkchainId& workchain, const ton::ShardId& shard, const ton::BlockSeqno& seqno, @@ -570,12 +373,11 @@ TonlibWorker::Result TonlibWorker if (!root_hash.empty() && !file_hash.empty()) { blk_id = tonlib_api::make_object(workchain, shard, seqno, root_hash, file_hash); } else { - auto [r_blk_id, new_session] = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); + auto r_blk_id = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); if (r_blk_id.is_error()) { - return {r_blk_id.move_as_error(), new_session}; + return r_blk_id.move_as_error(); } blk_id = r_blk_id.move_as_ok(); - session = std::move(new_session); } auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, @@ -591,10 +393,9 @@ TonlibWorker::Result TonlibWorker }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } -TonlibWorker::Result TonlibWorker::getOutMsgQueueSizes(multiclient::SessionPtr session) const { +td::Result TonlibWorker::getOutMsgQueueSizes(multiclient::SessionPtr session) const { auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, .request_creator = @@ -603,22 +404,20 @@ TonlibWorker::Result TonlibW }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } -TonlibWorker::Result TonlibWorker::getConfigParam( +td::Result TonlibWorker::getConfigParam( const std::int32_t& param, std::optional seqno, multiclient::SessionPtr session ) const { tonlib_api::object_ptr with_block; if (seqno.has_value()) { - auto [res, new_session] = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value()); + auto res = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value()); if (!res.is_ok()) { - return {res.move_as_error(), new_session}; + return res.move_as_error(); } with_block = res.move_as_ok(); - session = std::move(new_session); } if (!with_block) { auto request = multiclient::RequestFunction{ @@ -629,8 +428,7 @@ TonlibWorker::Result TonlibWorker::getCo }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } else { auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, @@ -650,22 +448,21 @@ TonlibWorker::Result TonlibWorker::getCo }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); + auto result = send_request_function(std::move(request), true); if (result.is_error()) { - return {result.move_as_error(), new_session}; + return result.move_as_error(); } - return {ton::move_tl_object_as(result.move_as_ok()), new_session}; + return ton::move_tl_object_as(result.move_as_ok()); } } -TonlibWorker::Result TonlibWorker::getConfigAll(std::optional seqno, multiclient::SessionPtr session) const { +td::Result TonlibWorker::getConfigAll(std::optional seqno, multiclient::SessionPtr session) const { tonlib_api::object_ptr with_block; if (seqno.has_value()) { - auto [res, new_session] = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value(), std::nullopt, std::nullopt, session); + auto res = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value(), std::nullopt, std::nullopt, session); if (!res.is_ok()) { - return {res.move_as_error(), new_session}; + return res.move_as_error(); } with_block = res.move_as_ok(); - session = std::move(new_session); } if (!with_block) { auto request = multiclient::RequestFunction{ @@ -676,8 +473,7 @@ TonlibWorker::Result TonlibWorker::getCo }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } else { auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single}, @@ -696,15 +492,14 @@ TonlibWorker::Result TonlibWorker::getCo }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - session = std::move(new_session); + auto result = send_request_function(std::move(request), true); if (result.is_error()) { - return {result.move_as_error(), session}; + return result.move_as_error(); } - return {ton::move_tl_object_as(result.move_as_ok()), session}; + return ton::move_tl_object_as(result.move_as_ok()); } } -TonlibWorker::Result> TonlibWorker::getLibraries( +td::Result> TonlibWorker::getLibraries( std::vector libs, multiclient::SessionPtr session ) const { auto request = multiclient::RequestFunction{ @@ -715,16 +510,15 @@ TonlibWorker::Result> TonlibWorke for (auto& lib : libs) { td::Bits256 hash; hash.as_slice().copy_from(lib); - lib_hashes.push_back(std::move(hash)); + lib_hashes.push_back(hash); } return tonlib_api::make_object(std::move(lib_hashes)); }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), new_session}; + return send_request_function(std::move(request), true); } -TonlibWorker::Result TonlibWorker::raw_getBlockTransactions( +td::Result TonlibWorker::raw_getBlockTransactions( const tonlib_api::object_ptr& blk_id, size_t count, tonlib_api::object_ptr&& after, @@ -765,10 +559,9 @@ TonlibWorker::Result TonlibWorke ); }; } - auto [result, new_session] = send_request_function(std::move(request), !archival.has_value()); - return {std::move(result), new_session}; + return send_request_function(std::move(request), !archival.has_value()); } -TonlibWorker::Result TonlibWorker::raw_getBlockTransactionsExt( +td::Result TonlibWorker::raw_getBlockTransactionsExt( const tonlib_api::object_ptr& blk_id, size_t count, tonlib_api::object_ptr&& after, @@ -809,10 +602,9 @@ TonlibWorker::Result TonlibWo ); }; } - auto [result, new_session] = send_request_function(std::move(request), !archival.has_value()); - return {std::move(result), new_session}; + return send_request_function(std::move(request), !archival.has_value()); } -TonlibWorker::Result TonlibWorker::raw_getTransactions( +td::Result TonlibWorker::raw_getTransactions( const std::string& account_address, const ton::LogicalTime& from_transaction_lt, const std::string& from_transaction_hash, @@ -831,10 +623,9 @@ TonlibWorker::Result TonlibWorker:: }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), !archival.has_value()); - return {std::move(result), new_session}; + return send_request_function(std::move(request), !archival.has_value()); } -TonlibWorker::Result TonlibWorker::raw_getTransactionsV2( +td::Result TonlibWorker::raw_getTransactionsV2( const std::string& account_address, const ton::LogicalTime& from_transaction_lt, const std::string& from_transaction_hash, @@ -855,10 +646,9 @@ TonlibWorker::Result TonlibWorker }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), !archival.has_value()); - return {std::move(result), new_session}; + return send_request_function(std::move(request), !archival.has_value()); } -TonlibWorker::Result TonlibWorker::getBlockTransactions( +td::Result TonlibWorker::getBlockTransactions( const ton::WorkchainId& workchain, const ton::ShardId& shard, const ton::BlockSeqno& seqno, @@ -874,7 +664,7 @@ TonlibWorker::Result TonlibWorke auto options = multiclient::RequestParameters{.mode = multiclient::RequestMode::Single, .archival = archival}; auto r_session = tonlib_.get_session(options, nullptr); if (r_session.is_error()) { - return {td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()), nullptr}; + return td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()); } session = r_session.move_as_ok(); } @@ -882,12 +672,11 @@ TonlibWorker::Result TonlibWorke if (!root_hash.empty() && !file_hash.empty()) { blk_id = tonlib_api::make_object(workchain, shard, seqno, root_hash, file_hash); } else { - auto [r_blk_id, new_session] = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); + auto r_blk_id = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); if (r_blk_id.is_error()) { - return {r_blk_id.move_as_error(), new_session}; + return r_blk_id.move_as_error(); } blk_id = r_blk_id.move_as_ok(); - session = std::move(new_session); } tonlib_api::object_ptr after; @@ -905,17 +694,16 @@ TonlibWorker::Result TonlibWorke tonlib_api::object_ptr txs = tonlib_api::make_object( - nullptr, 0, true, std::move(std::vector>{}) + nullptr, 0, true, std::vector>{} ); txs->transactions_.reserve(count); while (!is_finished) { size_t chunk_size = (left_count > CHUNK_SIZE ? CHUNK_SIZE : left_count); - auto [result, new_session] = raw_getBlockTransactions(blk_id, chunk_size, std::move(after), archival, session); + auto result = raw_getBlockTransactions(blk_id, chunk_size, std::move(after), archival, session); if (result.is_error()) { - return {result.move_as_error(), new_session}; + return result.move_as_error(); } auto local = result.move_as_ok(); - session = std::move(new_session); txs->id_ = std::move(local->id_); txs->incomplete_ = local->incomplete_; @@ -938,9 +726,9 @@ TonlibWorker::Result TonlibWorke } txs->req_count_ = static_cast(count); - return {std::move(txs), session}; + return std::move(txs); } -TonlibWorker::Result TonlibWorker::getBlockTransactionsExt( +td::Result TonlibWorker::getBlockTransactionsExt( const ton::WorkchainId& workchain, const ton::ShardId& shard, const ton::BlockSeqno& seqno, @@ -956,7 +744,7 @@ TonlibWorker::Result TonlibWo auto options = multiclient::RequestParameters{.mode = multiclient::RequestMode::Single, .archival = archival}; auto r_session = tonlib_.get_session(options, nullptr); if (r_session.is_error()) { - return {td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()), nullptr}; + return td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()); } session = r_session.move_as_ok(); } @@ -964,12 +752,11 @@ TonlibWorker::Result TonlibWo if (!root_hash.empty() && !file_hash.empty()) { blk_id = tonlib_api::make_object(workchain, shard, seqno, root_hash, file_hash); } else { - auto [r_blk_id, new_session] = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); + auto r_blk_id = lookupBlock(workchain, shard, seqno, std::nullopt, std::nullopt, session); if (r_blk_id.is_error()) { - return {r_blk_id.move_as_error(), new_session}; + return r_blk_id.move_as_error(); } blk_id = r_blk_id.move_as_ok(); - session = std::move(new_session); } tonlib_api::object_ptr after; @@ -992,12 +779,11 @@ TonlibWorker::Result TonlibWo txs->transactions_.reserve(count); while (!is_finished) { size_t chunk_size = (left_count > CHUNK_SIZE ? CHUNK_SIZE : left_count); - auto [result, new_session] = raw_getBlockTransactionsExt(blk_id, chunk_size, std::move(after), archival, session); + auto result = raw_getBlockTransactionsExt(blk_id, chunk_size, std::move(after), archival, session); if (result.is_error()) { - return {result.move_as_error(), new_session}; + return result.move_as_error(); } auto local = result.move_as_ok(); - session = std::move(new_session); txs->id_ = std::move(local->id_); txs->incomplete_ = local->incomplete_; @@ -1021,9 +807,9 @@ TonlibWorker::Result TonlibWo is_finished = (left_count <= 0) || !local->incomplete_; } txs->req_count_ = static_cast(count); - return {std::move(txs), session}; + return std::move(txs); } -TonlibWorker::Result TonlibWorker::getTransactions( +td::Result TonlibWorker::getTransactions( const std::string& account_address, std::optional from_transaction_lt, std::string from_transaction_hash, @@ -1038,16 +824,15 @@ TonlibWorker::Result TonlibWorker auto options = multiclient::RequestParameters{.mode = multiclient::RequestMode::Single, .archival = archival}; auto r_session = tonlib_.get_session(options, nullptr); if (r_session.is_error()) { - return {td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()), nullptr}; + return td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()); } session = r_session.move_as_ok(); } if (!(from_transaction_lt.has_value() && !from_transaction_hash.empty())) { - auto [r_account_state_, new_session] = getAddressInformation(account_address, std::nullopt, session); + auto r_account_state_ = getAddressInformation(account_address, std::nullopt, session); if (r_account_state_.is_error()) { - return {r_account_state_.move_as_error(), new_session}; + return r_account_state_.move_as_error(); } - session = std::move(new_session); auto account_state_ = r_account_state_.move_as_ok(); from_transaction_lt = account_state_->last_transaction_id_->lt_; from_transaction_hash = account_state_->last_transaction_id_->hash_; @@ -1061,14 +846,13 @@ TonlibWorker::Result TonlibWorker tonlib_api::object_ptr txs = tonlib_api::make_object(); while (!reach_lt && tx_count < count) { size_t local_chunk_size = (count - tx_count > chunk_size ? chunk_size : count - tx_count); - auto [r_local, new_session] = raw_getTransactionsV2( + auto r_local = raw_getTransactionsV2( account_address, current_lt, current_hash, local_chunk_size, try_decode_messages, archival, session ); if (r_local.is_error()) { - return {r_local.move_as_error(), new_session}; + return r_local.move_as_error(); } auto local = r_local.move_as_ok(); - session = std::move(new_session); for (auto& tx : local->transactions_) { if (tx->transaction_id_->lt_ <= to_transaction_lt) { @@ -1100,10 +884,10 @@ TonlibWorker::Result TonlibWorker if (txs->transactions_.size() > tx_count) { txs->transactions_.resize(tx_count); } - return {std::move(txs), session}; + return std::move(txs); } -TonlibWorker::Result TonlibWorker::tryLocateTransactionByIncomingMessage( +td::Result TonlibWorker::tryLocateTransactionByIncomingMessage( const std::string& source, const std::string& destination, ton::LogicalTime created_lt, @@ -1111,47 +895,45 @@ TonlibWorker::Result TonlibWorker ) const { auto r_src_addr = block::StdAddress::parse(source); if (r_src_addr.is_error()) { - return {r_src_addr.move_as_error_prefix("failed to parse source: "), session}; + return r_src_addr.move_as_error_prefix("failed to parse source: "); } auto src = r_src_addr.move_as_ok(); auto r_dest_addr = block::StdAddress::parse(destination); if (r_dest_addr.is_error()) { - return {r_dest_addr.move_as_error_prefix("failed to parse destination: "), session}; + return r_dest_addr.move_as_error_prefix("failed to parse destination: "); } auto dest = r_dest_addr.move_as_ok(); auto workchain = dest.workchain; - auto [r_shards, new_session] = getShards(std::nullopt, created_lt, std::nullopt, session); + auto r_shards = getShards(std::nullopt, created_lt, std::nullopt, session); if (r_shards.is_error()) { - return {r_shards.move_as_error_prefix("failed to get shards at create_lt: "), new_session}; + return r_shards.move_as_error_prefix("failed to get shards at create_lt: "); } auto shards = r_shards.move_as_ok(); for (auto& shard : shards->shards_) { auto shard_id = shard->shard_; for (auto i = 0; i < 3; ++i) { auto lt = created_lt + 1000000 * i; - auto [r_block, new_session] = lookupBlock(workchain, shard_id, std::nullopt, lt, std::nullopt, session); + auto r_block = lookupBlock(workchain, shard_id, std::nullopt, lt, std::nullopt, session); if (r_block.is_error()) { td::StringBuilder sb; sb << "failed to lookup block with lt " << lt << ": "; - return {r_block.move_as_error_prefix(sb.as_cslice().str()), new_session}; + return r_block.move_as_error_prefix(sb.as_cslice().str()); } auto block = r_block.move_as_ok(); - session = std::move(new_session); constexpr size_t tx_count = 40; - auto [r_txs, new_session_2] = getBlockTransactions( + auto r_txs = getBlockTransactions( block->workchain_, block->shard_, block->seqno_, tx_count, block->root_hash_, block->file_hash_, 40, "", std::nullopt, session ); if (r_txs.is_error()) { td::StringBuilder sb; sb << "failed to get transactions for block (" << block->workchain_ << ", " << block->shard_ << ", " << block->seqno_ << "): "; - return {r_txs.move_as_error_prefix(sb.as_cslice().str()), new_session_2}; + return r_txs.move_as_error_prefix(sb.as_cslice().str()); } auto blk_txs = r_txs.move_as_ok(); - session = std::move(new_session_2); tonlib_api::object_ptr candidate = nullptr; size_t tx_found = 0; @@ -1165,13 +947,12 @@ TonlibWorker::Result TonlibWorker } if (candidate != nullptr) { constexpr size_t min_tx_found = 10; - auto [r_candidate_txs, new_session] = + auto r_candidate_txs = getTransactions(destination, candidate->lt_, candidate->hash_, std::max(tx_found, min_tx_found), 10, 30, true, std::nullopt, session); if (r_txs.is_error()) { - return {r_txs.move_as_error_prefix("failed to get candidate transactions: "), new_session}; + return r_txs.move_as_error_prefix("failed to get candidate transactions: "); } auto candidate_txs = r_candidate_txs.move_as_ok(); - session = std::move(new_session); for (auto & candidate_tx : candidate_txs->transactions_) { auto& in_msg = candidate_tx->in_msg_; if (in_msg && in_msg->source_ && !in_msg->source_->account_address_.empty()) { @@ -1180,19 +961,19 @@ TonlibWorker::Result TonlibWorker std::vector> tx_vec; tx_vec.emplace_back(std::move(candidate_tx)); auto prev_tx = tonlib_api::make_object( - 0, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + 0, utils::stringToHash("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=").value() ); - return {tonlib_api::make_object(std::move(tx_vec), std::move(prev_tx)), session}; + return tonlib_api::make_object(std::move(tx_vec), std::move(prev_tx)); } } } } } } - return {td::Status::Error(404, "transaction was not found"), session}; + return td::Status::Error(404, "transaction was not found"); } -TonlibWorker::Result TonlibWorker::tryLocateTransactionByOutgoingMessage( +td::Result TonlibWorker::tryLocateTransactionByOutgoingMessage( const std::string& source, const std::string& destination, ton::LogicalTime created_lt, @@ -1200,44 +981,41 @@ TonlibWorker::Result TonlibWorker ) const { auto r_src_addr = block::StdAddress::parse(source); if (r_src_addr.is_error()) { - return {r_src_addr.move_as_error_prefix("failed to parse source: "), session}; + return r_src_addr.move_as_error_prefix("failed to parse source: "); } auto src = r_src_addr.move_as_ok(); auto r_dest_addr = block::StdAddress::parse(destination); if (r_dest_addr.is_error()) { - return {r_dest_addr.move_as_error_prefix("failed to parse destination: "), session}; + return r_dest_addr.move_as_error_prefix("failed to parse destination: "); } auto dest = r_dest_addr.move_as_ok(); auto workchain = src.workchain; - auto [r_shards, new_session] = getShards(std::nullopt, created_lt, std::nullopt, session); - session = std::move(new_session); + auto r_shards = getShards(std::nullopt, created_lt, std::nullopt, session); if (r_shards.is_error()) { - return {r_shards.move_as_error_prefix("failed to get shards at create_lt: "), session}; + return r_shards.move_as_error_prefix("failed to get shards at create_lt: "); } auto shards = r_shards.move_as_ok(); for (auto& shard : shards->shards_) { auto shard_id = shard->shard_; - auto [r_block, new_session] = lookupBlock(workchain, shard_id, std::nullopt, created_lt, std::nullopt, session); - session = std::move(new_session); + auto r_block = lookupBlock(workchain, shard_id, std::nullopt, created_lt, std::nullopt, session); if (r_block.is_error()) { td::StringBuilder sb; sb << "failed to lookup block with lt " << created_lt << ": "; - return {r_block.move_as_error_prefix(sb.as_cslice().str()), session}; + return r_block.move_as_error_prefix(sb.as_cslice().str()); } auto block = r_block.move_as_ok(); constexpr size_t tx_count = 40; - auto [r_txs, new_session_2] = getBlockTransactions( + auto r_txs = getBlockTransactions( block->workchain_, block->shard_, block->seqno_, tx_count, block->root_hash_, block->file_hash_, std::nullopt, "", std::nullopt, session ); - session = std::move(new_session_2); if (r_txs.is_error()) { td::StringBuilder sb; sb << "failed to get transactions for block (" << block->workchain_ << ", " << block->shard_ << ", " << block->seqno_ << "): "; - return {r_txs.move_as_error_prefix(sb.as_cslice().str()), session}; + return r_txs.move_as_error_prefix(sb.as_cslice().str()); } auto blk_txs = r_txs.move_as_ok(); @@ -1253,11 +1031,10 @@ TonlibWorker::Result TonlibWorker } if (candidate != nullptr) { constexpr size_t min_tx_found = 10; - auto [r_candidate_txs, new_session] = + auto r_candidate_txs = getTransactions(source, candidate->lt_, candidate->hash_, std::max(tx_found, min_tx_found), 10, 30, true, std::nullopt, session); - session = std::move(new_session); if (r_txs.is_error()) { - return {r_txs.move_as_error_prefix("failed to get candidate transactions: "), session}; + return r_txs.move_as_error_prefix("failed to get candidate transactions: "); } auto candidate_txs = r_candidate_txs.move_as_ok(); for (auto& candidate_tx : candidate_txs->transactions_) { @@ -1269,25 +1046,25 @@ TonlibWorker::Result TonlibWorker std::vector> tx_vec; tx_vec.emplace_back(std::move(candidate_tx)); auto prev_tx = tonlib_api::make_object( - 0, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + 0, utils::stringToHash("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=").value() ); - return {tonlib_api::make_object(std::move(tx_vec), std::move(prev_tx)), session}; + return tonlib_api::make_object(std::move(tx_vec), std::move(prev_tx)); } } } } } } - return {td::Status::Error(404, "transaction was not found"), session}; + return td::Status::Error(404, "transaction was not found"); } -TonlibWorker::Result TonlibWorker::raw_sendMessage( +td::Result TonlibWorker::raw_sendMessage( const std::string& boc, multiclient::SessionPtr session ) const { auto r_boc = td::base64_decode(boc); if (r_boc.is_error()) { - return {r_boc.move_as_error(), session}; + return r_boc.move_as_error(); } auto boc_bytes = r_boc.move_as_ok(); auto request = multiclient::RequestFunction{ @@ -1297,16 +1074,15 @@ TonlibWorker::Result TonlibWorker::raw_ }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), false); - return {std::move(result), new_session}; + return send_request_function(std::move(request), false); } -TonlibWorker::Result TonlibWorker::raw_sendMessageReturnHash( +td::Result TonlibWorker::raw_sendMessageReturnHash( const std::string& boc, multiclient::SessionPtr session ) const { auto r_boc = td::base64_decode(boc); if (r_boc.is_error()) { - return {r_boc.move_as_error(), session}; + return r_boc.move_as_error(); } auto boc_bytes = r_boc.move_as_ok(); auto request = multiclient::RequestFunction{ @@ -1315,11 +1091,10 @@ TonlibWorker::Result TonlibWo [boc_bytes]() { return tonlib_api::make_object(boc_bytes); }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), false); - return {std::move(result), new_session}; + return send_request_function(std::move(request), false); } -TonlibWorker::Result> TonlibWorker::loadContract( +td::Result> TonlibWorker::loadContract( const std::string& address, std::optional seqno, std::optional archival, @@ -1329,17 +1104,16 @@ TonlibWorker::Result> TonlibWorker::loadCo auto options = multiclient::RequestParameters{.mode = multiclient::RequestMode::Single, .archival = archival}; auto r_session = tonlib_.get_session(options, nullptr); if (r_session.is_error()) { - return {td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()), nullptr}; + return td::Status::Error(533, r_session.move_as_error_prefix("Failed to get session: ").message()); } session = r_session.move_as_ok(); } tonlib_api::object_ptr with_block; if (seqno.has_value()) { - auto [res, new_session] = + auto res = lookupBlock(ton::masterchainId, ton::shardIdAll, seqno.value(), std::nullopt, std::nullopt, session); - session = std::move(new_session); if (!res.is_ok()) { - return {res.move_as_error(), session}; + return res.move_as_error(); } with_block = res.move_as_ok(); } @@ -1355,8 +1129,7 @@ TonlibWorker::Result> TonlibWorker::loadCo }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), std::move(new_session)}; + return send_request_function(std::move(request), true); } auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single, .archival = archival}, @@ -1376,13 +1149,13 @@ TonlibWorker::Result> TonlibWorker::loadCo }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), false); + auto result = send_request_function(std::move(request), false); if (result.is_error()) { - return {result.move_as_error(), new_session}; + return result.move_as_error(); } - return {ton::move_tl_object_as(result.move_as_ok()), new_session}; + return ton::move_tl_object_as(result.move_as_ok()); } -TonlibWorker::Result> TonlibWorker::forgetContract( +td::Result> TonlibWorker::forgetContract( std::int64_t id, std::optional archival, multiclient::SessionPtr session ) const { auto request = multiclient::RequestFunction{ @@ -1393,10 +1166,10 @@ TonlibWorker::Result> TonlibWorker::forgetContra }, .session = std::move(session) }; - auto [result, new_session] = send_request_function(std::move(request), true); - return {std::move(result), std::move(new_session)}; + auto result = send_request_function(std::move(request), true); + return std::move(result); } -TonlibWorker::Result TonlibWorker::runGetMethod( +td::Result TonlibWorker::runGetMethod( const std::string& address, const std::string& method_name, const std::vector& stack, @@ -1404,15 +1177,14 @@ TonlibWorker::Result TonlibWorker::runGetMethod( std::optional archival, multiclient::SessionPtr session ) const { - auto [r_smc_info, new_session] = loadContract(address, seqno, archival, session); - session = std::move(new_session); + auto r_smc_info = loadContract(address, seqno, archival, session); if (!r_smc_info.is_ok()) { - return {r_smc_info.move_as_error(), session}; + return r_smc_info.move_as_error(); } auto smc_info = r_smc_info.move_as_ok(); auto r_stack = utils::parse_stack(stack); if (r_stack.is_error()) { - return {r_stack.move_as_error(), session}; + return r_stack.move_as_error(); } auto request = multiclient::RequestFunction{ .parameters = {.mode = multiclient::RequestMode::Single, .archival = archival}, @@ -1431,10 +1203,9 @@ TonlibWorker::Result TonlibWorker::runGetMethod( }, .session = session }; - auto [result, new_session_2] = send_request_function(std::move(request), false); - session = std::move(new_session_2); + auto result = send_request_function(std::move(request), false); if (result.is_error()) { - return {result.move_as_error(), session}; + return result.move_as_error(); } auto state_request = multiclient::RequestFunction{ @@ -1443,22 +1214,20 @@ TonlibWorker::Result TonlibWorker::runGetMethod( [id_ = smc_info->id_] { return tonlib_api::make_object(id_); }, .session = session }; - auto [state_result, new_session_3] = send_request_function(std::move(state_request), false); - session = std::move(new_session_3); + auto state_result = send_request_function(std::move(state_request), false); if (state_result.is_error()) { - return {state_result.move_as_error(), session}; + return state_result.move_as_error(); } - auto [forget_result, forget_session] = forgetContract(smc_info->id_, archival, session); - session = std::move(forget_session); + auto forget_result = forgetContract(smc_info->id_, archival, session); if (forget_result.is_error()) { - return {forget_result.move_as_error(), session}; + return forget_result.move_as_error(); } - return {RunGetMethodResult{result.move_as_ok(), state_result.move_as_ok()}, session}; + return RunGetMethodResult{result.move_as_ok(), state_result.move_as_ok()}; } -TonlibWorker::Result> TonlibWorker::queryEstimateFees( +td::Result> TonlibWorker::queryEstimateFees( const std::string& account_address, const std::string& body, const std::string& init_code, @@ -1468,19 +1237,19 @@ TonlibWorker::Result> TonlibWorker::quer ) const { auto r_body = td::base64_decode(body); if (r_body.is_error()) { - return {r_body.move_as_error(), session}; + return r_body.move_as_error(); } auto body_bin = r_body.move_as_ok(); auto r_init_code = td::base64_decode(init_code); if (init_code.length() > 0 && r_init_code.is_error()) { - return {r_init_code.move_as_error(), session}; + return r_init_code.move_as_error(); } auto init_code_bin = r_init_code.move_as_ok(); auto r_init_data = td::base64_decode(init_data); if (init_data.length() > 0 && r_init_data.is_error()) { - return {r_init_data.move_as_error(), session}; + return r_init_data.move_as_error(); } auto init_data_bin = r_init_data.move_as_ok(); @@ -1494,10 +1263,9 @@ TonlibWorker::Result> TonlibWorker::quer }, .session = session }; - auto [result, new_session] = send_request_function(std::move(request), false); - session = std::move(new_session); + auto result = send_request_function(std::move(request), false); if (result.is_error()) { - return {result.move_as_error(), session}; + return result.move_as_error(); } auto query_info = result.move_as_ok(); @@ -1509,25 +1277,23 @@ TonlibWorker::Result> TonlibWorker::quer }, .session = std::move(session) }; - auto [result_2, new_session_2] = send_request_function(std::move(request_2), false); - session = std::move(new_session_2); + auto result_2 = send_request_function(std::move(request_2), false); if (result_2.is_error()) { - return {result_2.move_as_error(), session}; + return result_2.move_as_error(); } - return {result_2.move_as_ok(), session}; + return result_2.move_as_ok(); } -TonlibWorker::Result> TonlibWorker::checkJettonMaster( +td::Result> TonlibWorker::checkJettonMaster( const std::string& address, bool skip_verification, std::optional seqno, std::optional archival, multiclient::SessionPtr session ) const { - auto [r_smc_info, new_session] = loadContract(address, seqno, archival, session); - session = std::move(new_session); + auto r_smc_info = loadContract(address, seqno, archival, session); if (!r_smc_info.is_ok()) { - return {r_smc_info.move_as_error(), session}; + return r_smc_info.move_as_error(); } auto smc_info = r_smc_info.move_as_ok(); @@ -1541,55 +1307,54 @@ TonlibWorker::Result> TonlibWorker::checkJetton }, .session = std::move(session) }; - auto [res, new_session_2] = send_request_function(std::move(request), false); - session = std::move(new_session_2); + auto res = send_request_function(std::move(request), false); if (!res.is_ok()) { - return {nullptr, std::move(session)}; + return nullptr; } auto result = res.move_as_ok(); if (result->exit_code_ != 0) { - return {nullptr, std::move(session)}; + return nullptr; } if (result->stack_.size() < 5) { - return {nullptr, std::move(session)}; + return nullptr; } auto data = std::make_unique(address); // total_supply_ auto r_total_supply = utils::number_from_tvm_stack_entry(result->stack_[0]); if (r_total_supply.is_error()) { - return {r_total_supply.move_as_error(), std::move(session)}; + return r_total_supply.move_as_error(); } data->total_supply_ = r_total_supply.move_as_ok(); // mintable_ auto r_mintable = utils::number_from_tvm_stack_entry(result->stack_[1]); if (r_mintable.is_error()) { - return {r_mintable.move_as_error(), std::move(session)}; + return r_mintable.move_as_error(); } data->mintable_ = std::stoi(r_mintable.move_as_ok()); // admin_address_ auto r_admin_address = utils::address_from_tvm_stack_entry(result->stack_[2]); if (r_admin_address.is_error()) { - return {r_admin_address.move_as_error(), std::move(session)}; + return r_admin_address.move_as_error(); } data->admin_address_ = r_admin_address.move_as_ok(); // jetton_content_ if (result->stack_[3]->get_id() != tonlib_api::tvm_stackEntryCell::ID) { - return {td::Status::Error(500, "stackEntryCell expected at 3 position"), std::move(session)}; + return td::Status::Error(500, "stackEntryCell expected at 3 position"); } auto r_jetton_content_cell_data = static_cast(*result->stack_[3]).cell_->bytes_; auto r_jetton_content_cell = vm::std_boc_deserialize(r_jetton_content_cell_data, true, true); if (r_jetton_content_cell.is_error()) { - return {r_jetton_content_cell.move_as_error_prefix("Failed to parse jetton content cell: "), std::move(session)}; + return r_jetton_content_cell.move_as_error_prefix("Failed to parse jetton content cell: "); } auto jetton_content_cell = r_jetton_content_cell.move_as_ok(); auto r_jetton_content = utils::parse_token_data(std::move(jetton_content_cell)); if (r_jetton_content.is_error()) { - return {r_jetton_content.move_as_error_prefix("Failed to parse jetton content from the cell: "), std::move(session)}; + return r_jetton_content.move_as_error_prefix("Failed to parse jetton content from the cell: "); } auto [jetton_content_onchain, jetton_content] = r_jetton_content.move_as_ok(); data->jetton_content_onchain_ = jetton_content_onchain; @@ -1597,29 +1362,26 @@ TonlibWorker::Result> TonlibWorker::checkJetton // jetton_wallet_code_ if (result->stack_[4]->get_id() != tonlib_api::tvm_stackEntryCell::ID) { - return {td::Status::Error(500, "stackEntryCell expected at 3 position"), std::move(session)}; + return td::Status::Error(500, "stackEntryCell expected at 3 position"); } data->jetton_wallet_code_ = td::base64_encode(static_cast(*result->stack_[4]).cell_->bytes_); - auto [forget_result, forget_session] = forgetContract(smc_info->id_, archival, session); - session = std::move(forget_session); + auto forget_result = forgetContract(smc_info->id_, archival, session); if (forget_result.is_error()) { - return {forget_result.move_as_error(), session}; + return forget_result.move_as_error(); } - - return {std::move(data), std::move(session)}; + return std::move(data); } -TonlibWorker::Result> TonlibWorker::checkJettonWallet( +td::Result> TonlibWorker::checkJettonWallet( const std::string& address, bool skip_verification, std::optional seqno, std::optional archival, multiclient::SessionPtr session ) const { - auto [r_smc_info, new_session] = loadContract(address, seqno, archival, session); - session = std::move(new_session); + auto r_smc_info = loadContract(address, seqno, archival, session); if (!r_smc_info.is_ok()) { - return {r_smc_info.move_as_error(), session}; + return r_smc_info.move_as_error(); } auto smc_info = r_smc_info.move_as_ok(); @@ -1633,69 +1395,66 @@ TonlibWorker::Result> TonlibWorker::checkJetton }, .session = std::move(session) }; - auto [res, new_session_2] = send_request_function(std::move(request), false); - session = std::move(new_session_2); + auto res = send_request_function(std::move(request), false); if (!res.is_ok()) { - return {nullptr, std::move(session)}; + return nullptr; } auto result = res.move_as_ok(); if (result->exit_code_ != 0) { - return {nullptr, std::move(session)}; + return nullptr; } if (result->stack_.size() < 4) { - return {nullptr, std::move(session)}; + return nullptr; } auto data = std::make_unique(address); // balance_ auto r_balance = utils::number_from_tvm_stack_entry(result->stack_[0]); if (r_balance.is_error()) { - return {r_balance.move_as_error(), std::move(session)}; + return r_balance.move_as_error(); } data->balance_ = r_balance.move_as_ok(); // owner_address_ auto r_owner_address_ = utils::address_from_tvm_stack_entry(result->stack_[1]); if (r_owner_address_.is_error()) { - return {r_owner_address_.move_as_error(), std::move(session)}; + return r_owner_address_.move_as_error(); } data->owner_address_ = r_owner_address_.move_as_ok(); // jetton_master_address_ auto r_jetton_master_address = utils::address_from_tvm_stack_entry(result->stack_[2]); if (r_jetton_master_address.is_error()) { - return {r_jetton_master_address.move_as_error(), std::move(session)}; + return r_jetton_master_address.move_as_error(); } data->jetton_master_address_ = r_jetton_master_address.move_as_ok(); // jetton_wallet_code_ if (result->stack_[3]->get_id() != tonlib_api::tvm_stackEntryCell::ID) { - return {td::Status::Error(500, "stackEntryCell expected at 3 position"), std::move(session)}; + return td::Status::Error(500, "stackEntryCell expected at 3 position"); } data->jetton_wallet_code_ = td::base64_encode(static_cast(*result->stack_[3]).cell_->bytes_); - auto [forget_result, forget_session] = forgetContract(smc_info->id_, archival, session); - session = std::move(forget_session); + auto forget_result = forgetContract(smc_info->id_, archival, session); if (forget_result.is_error()) { - return {forget_result.move_as_error(), session}; + return forget_result.move_as_error(); } if (skip_verification) { - return {std::move(data), std::move(session)}; + return std::move(data); } // verification - auto [r_parent_smc_info, new_session_3] = loadContract(data->jetton_master_address_, seqno, archival, session); - session = std::move(new_session_3); + auto r_parent_smc_info = loadContract(data->jetton_master_address_, seqno, archival, session); if (!r_parent_smc_info.is_ok()) { - return {r_parent_smc_info.move_as_error(), session}; + return r_parent_smc_info.move_as_error(); } auto parent_smc_info = r_parent_smc_info.move_as_ok(); // construct owner_address cell auto r_owner_std_address = block::StdAddress::parse(data->owner_address_); if (r_owner_std_address.is_error()) { - return {r_owner_std_address.move_as_error(), std::move(session)}; + return r_owner_std_address.move_as_error(); } auto owner_address_std = r_owner_std_address.move_as_ok(); @@ -1708,7 +1467,7 @@ TonlibWorker::Result> TonlibWorker::checkJetton block::gen::t_MsgAddressInt.pack_addr_std(cb, anycast_cs, owner_address_std.workchain, owner_address_std.addr); auto r_owner_address_cell = vm::std_boc_serialize(cb.finalize()); if (r_owner_address_cell.is_error()) { - return {r_owner_address_cell.move_as_error(), std::move(session)}; + return r_owner_address_cell.move_as_error(); } auto owner_address_cell = r_owner_address_cell.move_as_ok().as_slice().str(); @@ -1727,86 +1486,60 @@ TonlibWorker::Result> TonlibWorker::checkJetton }, .session = std::move(session), }; - auto [res_2, new_session_4] = send_request_function(std::move(request_2)); - session = std::move(new_session_4); + auto res_2 = send_request_function(std::move(request_2)); if (!res_2.is_ok()) { auto error = res_2.move_as_error(); - return {std::move(error), std::move(session)}; + return std::move(error); } auto result_2 = res_2.move_as_ok(); if (result_2->exit_code_ != 0) { LOG(ERROR) << "Exit code " << result_2->exit_code_ << " != 0"; - return {nullptr, std::move(session)}; + return nullptr; } auto& entry = static_cast(*(result_2->stack_[0])); - // { - // auto r_cell = vm::std_boc_deserialize(entry.cell_->bytes_, true, true); - // if (r_cell.is_error()) { - // LOG(ERROR) << "load cell failed: " << r_cell.move_as_error(); - // } - // // te6ccgEBAQEAJAAAQ4AW+iDq6ufjgt/MXgt/cX7iXPwWGOqiQ0OU+vlAGoMXuRA= - // // te6cckEBAQEAJAAAQ4AZHxqOGXySrVi9jb4K0H8twOHNPsDa7RRMlejtyfOKmvAVy/1x - // auto cell = r_cell.move_as_ok(); - // auto cs = vm::load_cell_slice_ref(cell); - // auto tag = block::gen::MsgAddressInt().get_tag(*cs); - // if (tag < 0) { - // LOG(ERROR) << td::Status::Error("Failed to read MsgAddressInt tag"); - // } - // if (tag != block::gen::MsgAddressInt::addr_std) { - // LOG(ERROR) << "non addr_std"; - // } - // block::gen::MsgAddressInt::Record_addr_std addr; - // if (!tlb::csr_unpack(cs, addr)) { - // LOG(ERROR) << td::Status::Error("Failed to unpack MsgAddressInt"); - // } - // LOG(ERROR) << block::StdAddress(addr.workchain_id, addr.address); - // } - auto r_wallet_address_from_master = utils::address_from_tvm_stack_entry(result_2->stack_[0]); if (r_wallet_address_from_master.is_error()) { - return {r_wallet_address_from_master.move_as_error(), std::move(session)}; + return r_wallet_address_from_master.move_as_error(); } auto wallet_address_from_master = r_wallet_address_from_master.move_as_ok(); // check addresses auto r_address_std = block::StdAddress::parse(address); if (r_address_std.is_error()) { - return {r_address_std.move_as_error(), std::move(session)}; + return r_address_std.move_as_error(); } auto address_std = r_address_std.move_as_ok(); auto r_address_from_master_std = block::StdAddress::parse(wallet_address_from_master); if (r_address_from_master_std.is_error()) { - return {r_address_from_master_std.move_as_error(), std::move(session)}; + return r_address_from_master_std.move_as_error(); } auto address_from_master_std = r_address_from_master_std.move_as_ok(); LOG(DEBUG) << "address: " << address_std << " expected: " << address_from_master_std; if (address_from_master_std != address_std) { - return {td::Status::Error(409, "Verification on master failed"), std::move(session)}; + return td::Status::Error(409, "Verification on master failed"); } data->is_validated_ = true; - auto [parent_forget_result, parent_forget_session] = forgetContract(parent_smc_info->id_, archival, session); - session = std::move(parent_forget_session); + auto parent_forget_result = forgetContract(parent_smc_info->id_, archival, session); if (parent_forget_result.is_error()) { - return {parent_forget_result.move_as_error(), session}; + return parent_forget_result.move_as_error(); } - return {std::move(data), std::move(session)}; + return std::move(data); } -TonlibWorker::Result> TonlibWorker::checkNFTCollection( +td::Result> TonlibWorker::checkNFTCollection( const std::string& address, bool skip_verification, std::optional seqno, std::optional archival, multiclient::SessionPtr session ) const { - auto [r_smc_info, new_session] = loadContract(address, seqno, archival, session); - session = std::move(new_session); + auto r_smc_info = loadContract(address, seqno, archival, session); if (!r_smc_info.is_ok()) { - return {r_smc_info.move_as_error(), session}; + return r_smc_info.move_as_error(); } auto smc_info = r_smc_info.move_as_ok(); @@ -1820,44 +1553,43 @@ TonlibWorker::Result> TonlibWorker::checkNFTCol }, .session = std::move(session) }; - auto [res, new_session_2] = send_request_function(std::move(request), false); - session = std::move(new_session_2); + auto res = send_request_function(std::move(request), false); if (!res.is_ok()) { - return {nullptr, std::move(session)}; + return nullptr; } auto result = res.move_as_ok(); if (result->exit_code_ != 0) { - return {nullptr, std::move(session)}; + return nullptr; } if (result->stack_.size() < 3) { - return {nullptr, std::move(session)}; + return nullptr; } auto data = std::make_unique(address); // total_supply_ if (result->stack_[0]->get_id() != tonlib_api::tvm_stackEntryNumber::ID) { - return {td::Status::Error(500, "stackEntryNumber expected at 0 position"), std::move(session)}; + return td::Status::Error(500, "stackEntryNumber expected at 0 position"); } auto r_next_item_index = utils::number_from_tvm_stack_entry(result->stack_[0]); if (r_next_item_index.is_error()) { - return {r_next_item_index.move_as_error(), std::move(session)}; + return r_next_item_index.move_as_error(); } data->next_item_index_ = r_next_item_index.move_as_ok(); // collection_content_ if (result->stack_[1]->get_id() != tonlib_api::tvm_stackEntryCell::ID) { - return {td::Status::Error(500, "stackEntryCell expected at 1 position"), std::move(session)}; + return td::Status::Error(500, "stackEntryCell expected at 1 position"); } auto r_collection_content_cell_data = static_cast(*result->stack_[1]).cell_->bytes_; auto r_collection_content_cell = vm::std_boc_deserialize(r_collection_content_cell_data, true, true); if (r_collection_content_cell.is_error()) { - return {r_collection_content_cell.move_as_error_prefix("Failed to parse jetton content cell: "), std::move(session)}; + return r_collection_content_cell.move_as_error_prefix("Failed to parse jetton content cell: "); } auto collection_content_cell = r_collection_content_cell.move_as_ok(); auto r_collection_content = utils::parse_token_data(std::move(collection_content_cell)); if (r_collection_content.is_error()) { - return {r_collection_content.move_as_error_prefix("Failed to parse jetton content from the cell: "), std::move(session)}; + return r_collection_content.move_as_error_prefix("Failed to parse jetton content from the cell: "); } auto [collection_content_onchain, collection_content] = r_collection_content.move_as_ok(); data->collection_content_onchain_ = collection_content_onchain; @@ -1866,29 +1598,27 @@ TonlibWorker::Result> TonlibWorker::checkNFTCol // owner_address_ auto r_owner_address_ = utils::address_from_tvm_stack_entry(result->stack_[2]); if (r_owner_address_.is_error()) { - return {r_owner_address_.move_as_error(), std::move(session)}; + return r_owner_address_.move_as_error(); } data->owner_address_ = r_owner_address_.move_as_ok(); - auto [forget_result, forget_session] = forgetContract(smc_info->id_, archival, session); - session = std::move(forget_session); + auto forget_result = forgetContract(smc_info->id_, archival, session); if (forget_result.is_error()) { - return {forget_result.move_as_error(), session}; + return forget_result.move_as_error(); } - return {std::move(data), std::move(session)}; + return std::move(data); } -TonlibWorker::Result> TonlibWorker::checkNFTItem( +td::Result> TonlibWorker::checkNFTItem( const std::string& address, bool skip_verification, std::optional seqno, std::optional archival, multiclient::SessionPtr session ) const { - auto [r_smc_info, new_session] = loadContract(address, seqno, archival, session); - session = std::move(new_session); + auto r_smc_info = loadContract(address, seqno, archival, session); if (!r_smc_info.is_ok()) { - return {r_smc_info.move_as_error(), session}; + return r_smc_info.move_as_error(); } auto smc_info = r_smc_info.move_as_ok(); @@ -1902,65 +1632,63 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte }, .session = std::move(session) }; - auto [res, new_session_2] = send_request_function(std::move(request), false); - session = std::move(new_session_2); + auto res = send_request_function(std::move(request), false); if (!res.is_ok()) { - return {nullptr, std::move(session)}; + return nullptr; } auto result = res.move_as_ok(); if (result->exit_code_ != 0) { - return {nullptr, std::move(session)}; + return nullptr; } if (result->stack_.size() < 5) { - return {nullptr, std::move(session)}; + return nullptr; } auto data = std::make_unique(address); // init_ auto r_init = utils::number_from_tvm_stack_entry(result->stack_[0]); if (r_init.is_error()) { - return {r_init.move_as_error(), std::move(session)}; + return r_init.move_as_error(); } data->init_ = std::stoi(r_init.move_as_ok()); - // index_ auto r_index = utils::number_from_tvm_stack_entry(result->stack_[1]); if (r_index.is_error()) { - return {r_index.move_as_error(), std::move(session)}; + return r_index.move_as_error(); } data->index_ = r_index.move_as_ok(); // collection_address_ auto r_collection_address = utils::address_from_tvm_stack_entry(result->stack_[2]); if (r_collection_address.is_error()) { - return {r_collection_address.move_as_error(), std::move(session)}; + return r_collection_address.move_as_error(); } data->collection_address_ = r_collection_address.move_as_ok(); // owner_address_ auto r_owner_address_ = utils::address_from_tvm_stack_entry(result->stack_[3]); if (r_owner_address_.is_error()) { - return {r_owner_address_.move_as_error(), std::move(session)}; + return r_owner_address_.move_as_error(); } data->owner_address_ = r_owner_address_.move_as_ok(); // content_ if (result->stack_[4]->get_id() != tonlib_api::tvm_stackEntryCell::ID) { - return {td::Status::Error(500, "stackEntryCell expected at 4 position"), std::move(session)}; + return td::Status::Error(500, "stackEntryCell expected at 4 position"); } auto ind_content_cell_data = static_cast(*result->stack_[4]).cell_->bytes_; if (data->collection_address_.empty()) { auto r_content_cell = vm::std_boc_deserialize(ind_content_cell_data, true, true); if (r_content_cell.is_error()) { - return {r_content_cell.move_as_error_prefix("Failed to parse jetton content cell: "), std::move(session)}; + return r_content_cell.move_as_error_prefix("Failed to parse jetton content cell: "); } auto content_cell = r_content_cell.move_as_ok(); auto r_content = utils::parse_token_data(std::move(content_cell)); if (r_content.is_error()) { - return {r_content.move_as_error_prefix("Failed to parse jetton content from the cell: "), std::move(session)}; + return r_content.move_as_error_prefix("Failed to parse jetton content from the cell: "); } auto [content_onchain, content] = r_content.move_as_ok(); data->content_onchain_ = content_onchain; @@ -1989,11 +1717,10 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte }, .session = std::move(session), }; - auto [res_dns, session_dns] = send_request_function(std::move(request_dns)); - session = std::move(session_dns); + auto res_dns = send_request_function(std::move(request_dns)); if (!res_dns.is_ok()) { auto error = res_dns.move_as_error(); - return {std::move(error), std::move(session)}; + return std::move(error); } auto result_dns = res_dns.move_as_ok(); if (result_dns->exit_code_ != 0 || result_dns->stack_.size() != 2) { @@ -2015,11 +1742,10 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte }, .session = std::move(session), }; - auto [res_domain, session_domain] = send_request_function(std::move(request_domain)); - session = std::move(session_domain); + auto res_domain = send_request_function(std::move(request_domain)); if (!res_domain.is_ok()) { auto error = res_domain.move_as_error(); - return {std::move(error), std::move(session)}; + return std::move(error); } auto result_domain = res_domain.move_as_ok(); if (result_domain->exit_code_ == 0) { @@ -2045,25 +1771,23 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte } } - auto [forget_result, forget_session] = forgetContract(smc_info->id_, archival, session); - session = std::move(forget_session); + auto forget_result = forgetContract(smc_info->id_, archival, session); if (forget_result.is_error()) { - return {forget_result.move_as_error_prefix("forgetContract failed: "), session}; + return forget_result.move_as_error_prefix("forgetContract failed: "); } if (skip_verification) { - return {std::move(data), std::move(session)}; + return std::move(data); } // verification if (data->collection_address_.empty()) { data->is_validated_ = true; - return {std::move(data), std::move(session)}; + return std::move(data); } - auto [r_parent_smc_info, new_session_3] = loadContract(data->collection_address_, seqno, archival, session); - session = std::move(new_session_3); + auto r_parent_smc_info = loadContract(data->collection_address_, seqno, archival, session); if (!r_parent_smc_info.is_ok()) { - return {r_parent_smc_info.move_as_error_prefix("failed to load parent contract: "), session}; + return r_parent_smc_info.move_as_error_prefix("failed to load parent contract: "); } auto parent_smc_info = r_parent_smc_info.move_as_ok(); @@ -2082,39 +1806,38 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte }, .session = std::move(session), }; - auto [res_2, new_session_4] = send_request_function(std::move(request_2)); - session = std::move(new_session_4); + auto res_2 = send_request_function(std::move(request_2)); if (!res_2.is_ok()) { auto error = res_2.move_as_error(); - return {std::move(error), std::move(session)}; + return std::move(error); } auto result_2 = res_2.move_as_ok(); if (result_2->exit_code_ != 0) { LOG(DEBUG) << "Exit code " << result_2->exit_code_ << " != 0"; - return {nullptr, std::move(session)}; + return nullptr; } auto r_address_from_collection = utils::address_from_tvm_stack_entry(result_2->stack_[0]); if (r_address_from_collection.is_error()) { - return {r_address_from_collection.move_as_error(), std::move(session)}; + return r_address_from_collection.move_as_error(); } auto address_from_collection = r_address_from_collection.move_as_ok(); // check addresses auto r_address_std = block::StdAddress::parse(address); if (r_address_std.is_error()) { - return {r_address_std.move_as_error(), std::move(session)}; + return r_address_std.move_as_error(); } auto address_std = r_address_std.move_as_ok(); auto r_address_from_collection_std = block::StdAddress::parse(address_from_collection); if (r_address_from_collection_std.is_error()) { - return {r_address_from_collection_std.move_as_error(), std::move(session)}; + return r_address_from_collection_std.move_as_error(); } auto address_from_collection_std = r_address_from_collection_std.move_as_ok(); // LOG(ERROR) << "address: " << address_std << " expected: " << address_from_collection_std; if (address_from_collection_std != address_std) { - return {td::Status::Error(409, "Verification on collection failed"), std::move(session)}; + return td::Status::Error(409, "Verification on collection failed"); } data->is_validated_ = true; @@ -2137,29 +1860,26 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte }, .session = std::move(session), }; - auto [res_3, new_session_5] = send_request_function(std::move(request_3)); - session = std::move(new_session_5); + auto res_3 = send_request_function(std::move(request_3)); if (!res_3.is_ok()) { - auto error = res_3.move_as_error(); - return {std::move(error), std::move(session)}; + return res_3.move_as_error(); } auto result_3 = res_3.move_as_ok(); if (result_3->exit_code_ != 0) { LOG(DEBUG) << "Exit code " << result_3->exit_code_ << " != 0"; - return {nullptr, std::move(session)}; + return nullptr; } auto& content_data_str = static_cast(*(result_3->stack_[0])).cell_->bytes_; auto r_content_cell = vm::std_boc_deserialize(content_data_str, true, true); if (r_content_cell.is_error()) { - return {r_content_cell.move_as_error_prefix("Failed to parse nft content cell: "), std::move(session)}; + return r_content_cell.move_as_error_prefix("Failed to parse nft content cell: "); } auto content_cell = r_content_cell.move_as_ok(); - auto r_content = utils::parse_token_data(std::move(content_cell)); if (r_content.is_error()) { - return {r_content.move_as_error_prefix("Failed to parse nft content from the cell: "), std::move(session)}; + return r_content.move_as_error_prefix("Failed to parse nft content from the cell: "); } auto [content_onchain, content] = r_content.move_as_ok(); data->content_onchain_ = content_onchain; @@ -2185,12 +1905,11 @@ TonlibWorker::Result> TonlibWorker::checkNFTIte } // cleanup - auto [parent_forget_result, parent_forget_session] = forgetContract(parent_smc_info->id_, archival, session); - session = std::move(parent_forget_session); + auto parent_forget_result = forgetContract(parent_smc_info->id_, archival, session); if (parent_forget_result.is_error()) { - return {parent_forget_result.move_as_error(), session}; + return parent_forget_result.move_as_error(); } - return {std::move(data), std::move(session)}; + return std::move(data); +} } -} // namespace ton_http::core diff --git a/ton-http-api/src/core/tonlib_worker.h b/ton-http-api/src/core/tonlib_worker.h new file mode 100644 index 0000000..9d9a5ba --- /dev/null +++ b/ton-http-api/src/core/tonlib_worker.h @@ -0,0 +1,238 @@ +#pragma once +#include "tonlib-multiclient/multi_client.h" +#include "tonlib-multiclient/request.h" +#include "userver/engine/future.hpp" +#include "types.hpp" + +namespace ton_http::core { +class TonlibWorker { +public: + explicit TonlibWorker(const multiclient::MultiClientConfig& config) : tonlib_(config) {}; + ~TonlibWorker() = default; + + [[nodiscard]] td::Result getConsensusBlock(multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result detectAddress(const std::string& address, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result packAddress(const std::string& address, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result unpackAddress(const std::string& address, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result detectHash(const std::string& hash, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result getTokenData( + const std::string& address, + bool skip_verification = false, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + [[nodiscard]] td::Result + getMasterchainInfo(multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result + getMasterchainBlockSignatures(ton::BlockSeqno seqno, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result + getAddressInformation(const std::string& address, std::optional seqno = std::nullopt, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result + getExtendedAddressInformation(const std::string& address, std::optional seqno = std::nullopt, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result lookupBlock(const ton::WorkchainId& workchain, + const ton::ShardId& shard, const std::optional& seqno = std::nullopt, + const std::optional& lt = std::nullopt, + const std::optional& unixtime = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result getShardBlockProof(const ton::WorkchainId& workchain, + const ton::ShardId& shard, + const ton::BlockSeqno& seqno, + const std::optional& from_seqno = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result getShards(std::optional mc_seqno = std::nullopt, + std::optional lt = std::nullopt, + std::optional unixtime = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result getBlockHeader( + const ton::WorkchainId& workchain, + const ton::ShardId& shard, + const ton::BlockSeqno& seqno, + const std::string& root_hash = "", + const std::string& file_hash = "", + multiclient::SessionPtr session = nullptr + ) const; + [[nodiscard]] td::Result getOutMsgQueueSizes(multiclient::SessionPtr session = nullptr) const; + + [[nodiscard]] td::Result getConfigParam(const std::int32_t& param, + std::optional seqno = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result getConfigAll(std::optional seqno = std::nullopt, multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result getLibraries( + std::vector libs, + multiclient::SessionPtr session = nullptr) const; + + [[nodiscard]] td::Result raw_getBlockTransactions(const tonlib_api::object_ptr& blk_id, + size_t count, + tonlib_api::object_ptr&& after = nullptr, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result raw_getBlockTransactionsExt(const tonlib_api::object_ptr& blk_id, + size_t count, + tonlib_api::object_ptr&& after = nullptr, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result raw_getTransactions( + const std::string& account_address, + const ton::LogicalTime& from_transaction_lt, + const std::string& from_transaction_hash, + const std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result raw_getTransactionsV2( + const std::string& account_address, + const ton::LogicalTime& from_transaction_lt, + const std::string& from_transaction_hash, + const size_t count, + const bool try_decode_messages, + const std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr) const; + + [[nodiscard]] td::Result getBlockTransactions( + const ton::WorkchainId& workchain, + const ton::ShardId& shard, + const ton::BlockSeqno& seqno, + const size_t count = 40, + const std::string& root_hash = "", + const std::string& file_hash = "", + const std::optional& after_lt = std::nullopt, + const std::string& after_hash = "", + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + [[nodiscard]] td::Result getBlockTransactionsExt( + const ton::WorkchainId& workchain, + const ton::ShardId& shard, + const ton::BlockSeqno& seqno, + const size_t count = 40, + const std::string& root_hash = "", + const std::string& file_hash = "", + const std::optional& after_lt = std::nullopt, + const std::string& after_hash = "", + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + [[nodiscard]] td::Result getTransactions( + const std::string& account_address, + std::optional from_transaction_lt, + std::string from_transaction_hash, + ton::LogicalTime to_transaction_lt = 0, + size_t count = 10, + size_t chunk_size = 30, + bool try_decode_messages = true, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + [[nodiscard]] td::Result tryLocateTransactionByIncomingMessage( + const std::string& source, + const std::string& destination, + ton::LogicalTime created_lt, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result tryLocateTransactionByOutgoingMessage( + const std::string& source, + const std::string& destination, + ton::LogicalTime created_lt, + multiclient::SessionPtr session = nullptr) const; + + [[nodiscard]] td::Result raw_sendMessage( + const std::string& boc, + multiclient::SessionPtr session = nullptr) const; + [[nodiscard]] td::Result raw_sendMessageReturnHash( + const std::string& boc, + multiclient::SessionPtr session = nullptr) const; + + [[nodiscard]] td::Result loadContract( + const std::string& address, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + [[nodiscard]] td::Result forgetContract( + std::int64_t id, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + [[nodiscard]] td::Result runGetMethod( + const std::string& address, + const std::string& method_name, + const std::vector& stack, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + [[nodiscard]] td::Result queryEstimateFees( + const std::string& account_address, + const std::string& body, + const std::string& init_code = "", + const std::string& init_data = "", + bool ignore_chksig = true, + multiclient::SessionPtr session = nullptr + ) const; +private: + multiclient::MultiClient tonlib_; + + [[nodiscard]] td::Result checkJettonMaster( + const std::string& address, + bool skip_verification = false, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + [[nodiscard]] td::Result checkJettonWallet( + const std::string& address, + bool skip_verification = false, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + [[nodiscard]] td::Result checkNFTCollection( + const std::string& address, + bool skip_verification = false, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + [[nodiscard]] td::Result checkNFTItem( + const std::string& address, + bool skip_verification = false, + std::optional seqno = std::nullopt, + std::optional archival = std::nullopt, + multiclient::SessionPtr session = nullptr + ) const; + + template + td::Result send_request_function(multiclient::RequestFunction&& request, bool retry_archival = false) const { + auto result = tonlib_.send_request_function(request); + if (result.is_ok() || !retry_archival) { + return std::move(result); + } + auto error = result.move_as_error(); + + // retry request with archival + { + request.parameters.archival = true; + auto r_session = tonlib_.get_session(request.parameters, std::move(request.session)); + if (r_session.is_error()) { + return r_session.move_as_error(); + } + request.session = r_session.move_as_ok(); + } + + result = tonlib_.send_request_function(request); + if (result.is_error()) { + auto error_archival = result.move_as_error(); + LOG(WARNING) << error_archival.code() << " " << error_archival.message(); + if (error_archival.code() == -3) { + return std::move(error); + } + return std::move(error_archival); + } + return std::move(result); + } +}; +} diff --git a/ton-http-api/src/core/types.hpp b/ton-http-api/src/core/types.hpp new file mode 100644 index 0000000..acf92fb --- /dev/null +++ b/ton-http-api/src/core/types.hpp @@ -0,0 +1,121 @@ +#pragma once + +#include + +#include "auto/tl/tonlib_api.h" +#include "block.h" + +namespace ton_http { +namespace core { +using namespace ton; + +struct DetectAddressResult { + block::StdAddress address; + std::string given_type; + [[nodiscard]] std::string to_raw_form(const bool lower=false) const { + td::StringBuilder sb; + sb << address.workchain << ":" << address.addr.to_hex(); + auto raw_form = sb.as_cslice().str(); + if (lower) { + std::ranges::transform(raw_form, raw_form.begin(), ::tolower); + } + return raw_form; + } +}; + +struct DetectHashResult { + std::string hash; +}; + +struct ConsensusBlockResult { + std::int32_t seqno; + std::time_t timestamp; +}; + +struct RunGetMethodResult { + tonlib_api::smc_runGetMethod::ReturnType result; + tonlib_api::smc_getRawFullAccountState::ReturnType state; +}; + +struct TokenDataResult { + explicit TokenDataResult(std::string address) : address_(std::move(address)) {} + virtual ~TokenDataResult() = default; + std::string address_; +}; +using TokenDataResultPtr = std::unique_ptr; + +struct JettonMasterDataResult final : public TokenDataResult { + std::string total_supply_; + bool mintable_{false}; + std::string admin_address_; + bool jetton_content_onchain_{false}; + std::map jetton_content_; + std::string jetton_wallet_code_; + explicit JettonMasterDataResult(const std::string& address) : TokenDataResult(address) {} +}; + +struct JettonWalletDataResult final : public TokenDataResult { + std::string balance_; + std::string owner_address_; + std::string jetton_master_address_; + std::optional mintless_is_claimed_; + std::string jetton_wallet_code_; + bool is_validated_{false}; + + explicit JettonWalletDataResult(const std::string& address) : TokenDataResult(address) {} +}; + +struct NFTCollectionDataResult final : public TokenDataResult { + std::string next_item_index_; + std::string owner_address_; + bool collection_content_onchain_{false}; + std::map collection_content_; + + explicit NFTCollectionDataResult(const std::string& address) : TokenDataResult(address) {} +}; + + +const std::map TonDnsRoots { + {"EQC3dNlesgVD8YbAazcauIrXBPfiVhMMr5YYk2in0Mtsz0Bz", ".ton"} +};; + +struct DnsRecordStorageAddress { + constexpr static std::string_view kType = "dns_storage_address"; + std::string bag_id; +}; + +struct DnsRecordSmcAddress { + constexpr static std::string_view kType = "dns_smc_address"; + block::StdAddress smc_addr; +}; + +struct DnsRecordAdnlAddress { + constexpr static std::string_view kType = "dns_adnl_address"; + std::string adnl_addr; +}; + +struct DnsRecordNextResolver { + constexpr static std::string_view kType = "dns_next_resolver"; + block::StdAddress resolver; +}; + +using DnsRecord = std::variant; + + +struct NFTItemDataResult final : public TokenDataResult { + bool init_{false}; + std::string index_; + std::string collection_address_; + std::string owner_address_; + bool content_onchain_{false}; + std::map content_; + bool is_validated_{false}; + + std::map dns_content_; + std::string domain_; + bool is_dns_{false}; + // TODO: implement dns entry parsing + explicit NFTItemDataResult(const std::string& address) : TokenDataResult(address) {} +}; +} +} diff --git a/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp new file mode 100644 index 0000000..fdb78b2 --- /dev/null +++ b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp @@ -0,0 +1,20 @@ +#include "HandlerGetMasterchainInfo.h" +#include "converters/convert.hpp" +#include "userver/chaotic/io/userver/utils/datetime/time_point_tz_fraction.hpp" + +ton_http::handlers::HandlerGetMasterchainInfo::HandlerGetMasterchainInfo( + const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context +) : TonlibRequestHandler(config, context) { +} + +td::Result +ton_http::handlers::HandlerGetMasterchainInfo::HandleRequestTonlibThrow( + const HttpRequest& request, const Value& request_json, RequestContext& context, multiclient::SessionPtr& session +) const { + auto result = tonlib_component_.DoRequest(&core::TonlibWorker::getMasterchainInfo, session); + if (result.is_error()) { + return result.move_as_error(); + } + auto result_ok = result.move_as_ok(); + return converters::Convert(result_ok); +} diff --git a/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h new file mode 100644 index 0000000..af17d54 --- /dev/null +++ b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h @@ -0,0 +1,16 @@ +#pragma once +#include "TonlibRequestHandler.h" + +namespace ton_http { +namespace handlers { + +class HandlerGetMasterchainInfo : public TonlibRequestHandler { +public: + static constexpr std::string_view kName = "handler-get-masterchain-info"; + + HandlerGetMasterchainInfo(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); + td::Result HandleRequestTonlibThrow(const HttpRequest& request, const Value& request_json, RequestContext& context, multiclient::SessionPtr& session) const override; +}; + +} // namespace handlers +} // namespace ton_http diff --git a/ton-http-api/src/handlers/JsonRpcMiddleware.hpp b/ton-http-api/src/handlers/JsonRpcMiddleware.hpp new file mode 100644 index 0000000..7d73569 --- /dev/null +++ b/ton-http-api/src/handlers/JsonRpcMiddleware.hpp @@ -0,0 +1,23 @@ +#pragma once +#include +#include "userver/server/middlewares/http_middleware_base.hpp" +#include "userver/logging/log.hpp" + +namespace ton_http::middlewares { +class JsonRpcMiddleware final : public userver::server::middlewares::HttpMiddlewareBase { +public: + // This will be used as a kName for the SimpleHttpMiddlewareFactory + static constexpr std::string_view kName{"jsonrpc-middleware"}; + + explicit JsonRpcMiddleware(const userver::server::handlers::HttpHandlerBase&) {} + +private: + void HandleRequest(userver::server::http::HttpRequest& request, userver::server::request::RequestContext& context) const override { + Next(request, context); + } + + static constexpr userver::http::headers::PredefinedHeader kCustomServerHeader{"X-Some-Server-Header"}; +}; + +using JsonRpcMiddlewareFactory = userver::server::middlewares::SimpleHttpMiddlewareFactory; +} \ No newline at end of file diff --git a/ton-http-api/src/handlers/TonlibRequestHandler.cpp b/ton-http-api/src/handlers/TonlibRequestHandler.cpp new file mode 100644 index 0000000..edcdbf2 --- /dev/null +++ b/ton-http-api/src/handlers/TonlibRequestHandler.cpp @@ -0,0 +1,34 @@ +#include "TonlibRequestHandler.h" + +#include "userver/components/component_context.hpp" +#include "userver/logging/component.hpp" +#include "schemas/v2.hpp" + + +userver::formats::json::Value ton_http::handlers::TonlibRequestHandler::HandleRequestJsonThrow( + const HttpRequest& request, const Value& request_json, RequestContext& context +) const { + auto session = tonlib_component_.GetNewSession(); + + auto result = HandleRequestTonlibThrow(request, request_json, context, session); + + schemas::v2::TonResponse response; + if (result.is_error()) { + auto tonlib_error = result.move_as_error(); + response.ok = false; + response.error = tonlib_error.message().str(); + response.code = tonlib_error.code(); + } else { + response.ok = true; + response.result = result.move_as_ok(); + } + response._extra = session->to_string(); + return userver::formats::json::ValueBuilder{response}.ExtractValue(); +} +ton_http::handlers::TonlibRequestHandler::TonlibRequestHandler( + const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context +) : + HttpHandlerJsonBase(config, context), + tonlib_component_(context.FindComponent()), + logger_(context.FindComponent().GetLogger("api-v2")) { +} diff --git a/ton-http-api/src/handlers/TonlibRequestHandler.h b/ton-http-api/src/handlers/TonlibRequestHandler.h new file mode 100644 index 0000000..f7279c3 --- /dev/null +++ b/ton-http-api/src/handlers/TonlibRequestHandler.h @@ -0,0 +1,21 @@ +#pragma once +#include "userver/server/handlers/http_handler_json_base.hpp" +#include "components/tonlib_component.h" +#include "schemas/v2.hpp" + +namespace ton_http { +namespace handlers { + +class TonlibRequestHandler : public userver::server::handlers::HttpHandlerJsonBase { +public: + using HttpHandlerJsonBase::HttpHandlerJsonBase; + virtual td::Result HandleRequestTonlibThrow(const HttpRequest& request, const Value& request_json, RequestContext& context, multiclient::SessionPtr& session) const = 0; + userver::formats::json::Value HandleRequestJsonThrow(const HttpRequest& request, const Value& request_json, RequestContext& context) const override; + TonlibRequestHandler(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); +protected: + core::TonlibComponent& tonlib_component_; + userver::logging::LoggerPtr logger_; +}; + +} // namespace handlers +} // namespace ton_http diff --git a/ton-http-api/main.cpp b/ton-http-api/src/main.cpp similarity index 66% rename from ton-http-api/main.cpp rename to ton-http-api/src/main.cpp index 0d001c3..d5b2bfa 100644 --- a/ton-http-api/main.cpp +++ b/ton-http-api/src/main.cpp @@ -1,28 +1,35 @@ -#include "handler_api_v2.h" #include "userver/components/minimal_server_component_list.hpp" #include "userver/server/handlers/server_monitor.hpp" #include "userver/server/handlers/ping.hpp" #include "userver/utils/daemon_run.hpp" #include "userver/clients/http/component.hpp" #include "userver/clients/dns/component.hpp" +#include "userver/components/fs_cache.hpp" +#include "userver/server/handlers/http_handler_static.hpp" #include "td/utils/port/signals.h" - #include "tonlib/Logging.h" -#include "tonlib_component.h" -#include "cache.hpp" + +#include "components/tonlib_component.h" +#include "handlers/HandlerGetMasterchainInfo.h" + int main(int argc, char* argv[]) { tonlib::Logging::set_verbosity_level(1); td::set_default_failure_signal_handler().ensure(); auto component_list = userver::components::MinimalServerComponentList(); - component_list.Append(); + // components component_list.Append(); component_list.Append(); - component_list.Append(); + component_list.Append("fs-cache-main"); component_list.Append(); - component_list.Append(); - component_list.Append(); + // common handlers + component_list.Append(); + component_list.Append(); + component_list.Append(); + // api handlers + component_list.Append(); + return userver::utils::DaemonMain(argc, argv, component_list); } diff --git a/ton-http-api/src/schemas/v2.cpp b/ton-http-api/src/schemas/v2.cpp new file mode 100644 index 0000000..64e6886 --- /dev/null +++ b/ton-http-api/src/schemas/v2.cpp @@ -0,0 +1,366 @@ +#include "v2.hpp" + +#include + +#include "v2_parsers.ipp" + + +namespace ton_http { +namespace schemas { +namespace v2 { + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressBase64Variant& lhs, + const ::ton_http::schemas::v2::DetectAddressBase64Variant& rhs +) { + return lhs.b64 == rhs.b64 && lhs.b64url == rhs.b64url && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressBase64Variant& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectAddressBase64Variant Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddressBase64Variant& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["b64"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64}; + + vb["b64url"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64url}; + + + return vb.ExtractValue(); +} + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressResult& lhs, const ::ton_http::schemas::v2::DetectAddressResult& rhs +) { + return lhs._type == rhs._type && lhs.raw_form == rhs.raw_form && lhs.bounceable == rhs.bounceable && + lhs.non_bounceable == rhs.non_bounceable && lhs.given_type == rhs.given_type && lhs.test_only == rhs.test_only && + true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectAddressResult::Given_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> to +) { + return Parse(json, to); +} + + +DetectAddressResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::DetectAddressResult::Given_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +) { + const auto result = k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddressResult::Given_Type", value) + ); +} + +::ton_http::schemas::v2::DetectAddressResult::Given_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddressResult& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; + + vb["raw_form"] = USERVER_NAMESPACE::chaotic::Primitive{value.raw_form}; + + vb["bounceable"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressBase64Variant>{value.bounceable}; + + vb["non_bounceable"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressBase64Variant>{value.non_bounceable}; + + vb["given_type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressResult::Given_Type>{value.given_type}; + + vb["test_only"] = USERVER_NAMESPACE::chaotic::Primitive{value.test_only}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::DetectAddressResult::Given_Type value) { + const auto result = k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::DetectHashResult& lhs, const ::ton_http::schemas::v2::DetectHashResult& rhs +) { + return lhs._type == rhs._type && lhs.b64 == rhs.b64 && lhs.b64url == rhs.b64url && lhs.hex == rhs.hex && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHashResult& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectHashResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHashResult> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectHashResult& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; + + if (value.b64) { + vb["b64"] = USERVER_NAMESPACE::chaotic::Primitive{*value.b64}; + } + + if (value.b64url) { + vb["b64url"] = USERVER_NAMESPACE::chaotic::Primitive{*value.b64url}; + } + + if (value.hex) { + vb["hex"] = USERVER_NAMESPACE::chaotic::Primitive{*value.hex}; + } + + + return vb.ExtractValue(); +} + + +bool operator==(const ::ton_http::schemas::v2::TonBlockIdExt& lhs, const ::ton_http::schemas::v2::TonBlockIdExt& rhs) { + return lhs._type == rhs._type && lhs.workchain == rhs.workchain && lhs.shard == rhs.shard && lhs.seqno == rhs.seqno && + lhs.root_hash == rhs.root_hash && lhs.file_hash == rhs.file_hash && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +TonBlockIdExt Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::TonBlockIdExt& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; + + vb["workchain"] = USERVER_NAMESPACE::chaotic::Primitive{value.workchain}; + + vb["shard"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::shard_id>{value.shard}; + + vb["seqno"] = USERVER_NAMESPACE::chaotic::Primitive{value.seqno}; + + vb["root_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.root_hash}; + + vb["file_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.file_hash}; + + + return vb.ExtractValue(); +} + + +bool operator==( + const ::ton_http::schemas::v2::MasterchainInfoResult& lhs, const ::ton_http::schemas::v2::MasterchainInfoResult& rhs +) { + return lhs._type == rhs._type && lhs.last == rhs.last && lhs.state_root_hash == rhs.state_root_hash && + lhs.init == rhs.init && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfoResult& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MasterchainInfoResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfoResult> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MasterchainInfoResult& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; + + vb["last"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.last}; + + vb["state_root_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.state_root_hash}; + + vb["init"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.init}; + + + return vb.ExtractValue(); +} + + +bool operator==(const ::ton_http::schemas::v2::TonResponse& lhs, const ::ton_http::schemas::v2::TonResponse& rhs) { + return lhs.ok == rhs.ok && lhs.result == rhs.result && lhs.error == rhs.error && lhs.code == rhs.code && + lhs._extra == rhs._extra && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonResponse& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +TonResponse Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonResponse> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::TonResponse& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["ok"] = USERVER_NAMESPACE::chaotic::Primitive{value.ok}; + + if (value.result) { + vb["result"] = USERVER_NAMESPACE::chaotic::Variant< + USERVER_NAMESPACE::chaotic::Primitive, + USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< + &::ton_http::schemas::v2::kTonObject_Settings, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, + USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< + &::ton_http::schemas::v2::kTonObject_Settings, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, + std::vector<::ton_http::schemas::v2::TonObject>>>{*value.result}; + } + + if (value.error) { + vb["error"] = USERVER_NAMESPACE::chaotic::Primitive{*value.error}; + } + + if (value.code) { + vb["code"] = USERVER_NAMESPACE::chaotic::Primitive{*value.code}; + } + + vb["@extra"] = USERVER_NAMESPACE::chaotic::Primitive{value._extra}; + + + return vb.ExtractValue(); +} + + +} // namespace v2 +} // namespace schemas +} // namespace ton_http + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::DetectAddressResult::Given_Type>::format( + const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + diff --git a/ton-http-api/src/schemas/v2.hpp b/ton-http-api/src/schemas/v2.hpp new file mode 100644 index 0000000..28604da --- /dev/null +++ b/ton-http-api/src/schemas/v2.hpp @@ -0,0 +1,296 @@ +#pragma once + +#include "v2_fwd.hpp" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + + +namespace ton_http { +namespace schemas { +namespace v2 { + + +// Base64 form of address variant +struct DetectAddressBase64Variant { + std::string b64{}; + std::string b64url{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressBase64Variant& lhs, + const ::ton_http::schemas::v2::DetectAddressBase64Variant& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressBase64Variant& value +); + + +DetectAddressBase64Variant Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddressBase64Variant& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +// Information about the address. +struct DetectAddressResult { + enum class Given_Type { + kRawForm, + kFriendlyBounceable, + kFriendlyNonBounceable, + }; + + static constexpr Given_Type kGiven_TypeValues[] = { + Given_Type::kRawForm, + Given_Type::kFriendlyBounceable, + Given_Type::kFriendlyNonBounceable, + }; + + + std::string _type{"utils.detectAddress"}; + std::string raw_form{}; + ::ton_http::schemas::v2::DetectAddressBase64Variant bounceable{}; + ::ton_http::schemas::v2::DetectAddressBase64Variant non_bounceable{}; + ::ton_http::schemas::v2::DetectAddressResult::Given_Type given_type{}; + bool test_only{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressResult& lhs, const ::ton_http::schemas::v2::DetectAddressResult& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult& value +); + + +DetectAddressResult::Given_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +); + + +DetectAddressResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult> +); + + +DetectAddressResult::Given_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +); + + +DetectAddressResult::Given_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddressResult& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::DetectAddressResult::Given_Type value); + + +struct DetectHashResult { + std::string _type{"utils.detectHash"}; + std::optional b64{}; + std::optional b64url{}; + std::optional hex{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::DetectHashResult& lhs, const ::ton_http::schemas::v2::DetectHashResult& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHashResult& value +); + + +DetectHashResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHashResult> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectHashResult& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +using TonShardId = std::string; + + +using TonHash = std::string; + + +// Extended block identifier. +struct TonBlockIdExt { + std::string _type{"ton.blockIdExt"}; + int workchain{}; + ton_http::types::shard_id shard{}; + int seqno{}; + ton_http::types::ton_hash root_hash{}; + ton_http::types::ton_hash file_hash{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::TonBlockIdExt& lhs, const ::ton_http::schemas::v2::TonBlockIdExt& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt& value +); + + +TonBlockIdExt Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TonBlockIdExt& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +// Information about the latest masterchain block. +struct MasterchainInfoResult { + std::string _type{"blocks.masterchainInfo"}; + ::ton_http::schemas::v2::TonBlockIdExt last{}; + ton_http::types::ton_hash state_root_hash{}; + ::ton_http::schemas::v2::TonBlockIdExt init{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::MasterchainInfoResult& lhs, const ::ton_http::schemas::v2::MasterchainInfoResult& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfoResult& value +); + + +MasterchainInfoResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfoResult> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainInfoResult& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +using TonAddr = std::string; + + +[[maybe_unused]] static constexpr USERVER_NAMESPACE::chaotic::OneOfStringSettings kTonObject_Settings = { + "@type", USERVER_NAMESPACE::utils::TrivialSet([](auto selector) { + return selector().template Type().Case("ton.blockIdExt").Case("blocks.masterchainInfo"); + }) +}; + + +using TonObject = std::variant<::ton_http::schemas::v2::TonBlockIdExt, ::ton_http::schemas::v2::MasterchainInfoResult>; + + +// TonResponse +struct TonResponse { + using Result = + std::variant>; + + + bool ok{}; + std::optional<::ton_http::schemas::v2::TonResponse::Result> result{}; + std::optional error{}; + std::optional code{}; + std::string _extra{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::TonResponse& lhs, const ::ton_http::schemas::v2::TonResponse& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonResponse& value +); + + +TonResponse Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonResponse> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TonResponse& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +} // namespace v2 +} // namespace schemas +} // namespace ton_http + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::DetectAddressResult::Given_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::DetectAddressResult::Given_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + diff --git a/ton-http-api/src/schemas/v2_fwd.hpp b/ton-http-api/src/schemas/v2_fwd.hpp new file mode 100644 index 0000000..448bb0a --- /dev/null +++ b/ton-http-api/src/schemas/v2_fwd.hpp @@ -0,0 +1,30 @@ +#pragma once + + +namespace ton_http { +namespace schemas { +namespace v2 { + + +struct DetectAddressBase64Variant; + + +struct DetectAddressResult; + + +struct DetectHashResult; + + +struct TonBlockIdExt; + + +struct MasterchainInfoResult; + + +struct TonResponse; + + +} // namespace v2 +} // namespace schemas +} // namespace ton_http + diff --git a/ton-http-api/src/schemas/v2_parsers.ipp b/ton-http-api/src/schemas/v2_parsers.ipp new file mode 100644 index 0000000..71ceda0 --- /dev/null +++ b/ton-http-api/src/schemas/v2_parsers.ipp @@ -0,0 +1,284 @@ +#pragma once + +#include "v2.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +namespace ton_http { +namespace schemas { +namespace v2 { + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet + k__ton_http__schemas__v2__DetectAddressBase64Variant_PropertiesNames = [](auto selector) { + return selector().template Type().Case("b64").Case("b64url"); + }; + + +template +::ton_http::schemas::v2::DetectAddressBase64Variant Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectAddressBase64Variant res; + + res.b64 = value["b64"].template As>(); + res.b64url = value["b64url"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectAddressBase64Variant_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap + k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping = [](auto selector) { + return selector() + .template Type<::ton_http::schemas::v2::DetectAddressResult::Given_Type, std::string_view>() + .Case(::ton_http::schemas::v2::DetectAddressResult::Given_Type::kRawForm, "raw_form") + .Case(::ton_http::schemas::v2::DetectAddressResult::Given_Type::kFriendlyBounceable, "friendly_bounceable") + .Case( + ::ton_http::schemas::v2::DetectAddressResult::Given_Type::kFriendlyNonBounceable, + "friendly_non_bounceable" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectAddressResult_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("raw_form") + .Case("bounceable") + .Case("non_bounceable") + .Case("given_type") + .Case("test_only"); + }; + + +template +::ton_http::schemas::v2::DetectAddressResult::Given_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddressResult::Given_Type", value), + val + ); +} + + +template +::ton_http::schemas::v2::DetectAddressResult Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectAddressResult res; + + res._type = value["@type"].template As>("utils.detectAddress"); + res.raw_form = value["raw_form"].template As>(); + res.bounceable = + value["bounceable"] + .template As>(); + res.non_bounceable = + value["non_bounceable"] + .template As>(); + res.given_type = + value["given_type"] + .template As< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressResult::Given_Type>>(); + res.test_only = value["test_only"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectAddressResult_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectHashResult_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("b64").Case("b64url").Case("hex"); + }; + + +template +::ton_http::schemas::v2::DetectHashResult Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHashResult> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectHashResult res; + + res._type = value["@type"].template As>("utils.detectHash"); + res.b64 = value["b64"].template As>>(); + res.b64url = value["b64url"].template As>>(); + res.hex = value["hex"].template As>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectHashResult_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TonBlockIdExt_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("workchain") + .Case("shard") + .Case("seqno") + .Case("root_hash") + .Case("file_hash"); + }; + + +template +::ton_http::schemas::v2::TonBlockIdExt Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::TonBlockIdExt res; + + res._type = value["@type"].template As>("ton.blockIdExt"); + res.workchain = value["workchain"].template As>(); + res.shard = + value["shard"] + .template As, ton_http::types::shard_id>>(); + res.seqno = value["seqno"].template As>(); + res.root_hash = + value["root_hash"] + .template As, ton_http::types::ton_hash>>(); + res.file_hash = + value["file_hash"] + .template As, ton_http::types::ton_hash>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__TonBlockIdExt_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MasterchainInfoResult_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("last") + .Case("state_root_hash") + .Case("init"); + }; + + +template +::ton_http::schemas::v2::MasterchainInfoResult Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfoResult> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MasterchainInfoResult res; + + res._type = value["@type"].template As>("blocks.masterchainInfo"); + res.last = value["last"].template As>(); + res.state_root_hash = + value["state_root_hash"] + .template As, ton_http::types::ton_hash>>(); + res.init = value["init"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MasterchainInfoResult_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TonResponse_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("ok").Case("result").Case("error").Case("code").Case( + "@extra" + ); + }; + + +template +::ton_http::schemas::v2::TonResponse Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonResponse> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::TonResponse res; + + res.ok = value["ok"].template As>(); + res.result = value["result"] + .template As, + USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< + &::ton_http::schemas::v2::kTonObject_Settings, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, + USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< + &::ton_http::schemas::v2::kTonObject_Settings, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, + std::vector<::ton_http::schemas::v2::TonObject>>>>>(); + res.error = value["error"].template As>>(); + res.code = value["code"].template As>>(); + res._extra = value["@extra"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__TonResponse_PropertiesNames + ); + + return res; +} + + +} // namespace v2 +} // namespace schemas +} // namespace ton_http + diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp new file mode 100644 index 0000000..075da71 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp @@ -0,0 +1,15 @@ +#include "shard_id.hpp" +#include "utils/exceptions.hpp" + +ton_http::types::shard_id +userver::chaotic::convert::Convert(const std::string& value, chaotic::convert::To) { + try { + return ton_http::types::shard_id{std::stoll(value)}; + } catch (...) { + throw ton_http::utils::ParsingException{"Failed to parse shard_id: '" + value + "'"}; + } +} +std::string +userver::chaotic::convert::Convert(const ton_http::types::shard_id& value, chaotic::convert::To) { + return std::to_string(value.GetUnderlying()); +} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp new file mode 100644 index 0000000..eaabd58 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include +#include + +namespace ton_http::types { +class shard_id : public USERVER_NAMESPACE::utils::StrongTypedef { + using StrongTypedef::StrongTypedef; +}; +} + +USERVER_NAMESPACE_BEGIN + +namespace chaotic::convert { + +ton_http::types::shard_id Convert(const std::string& value, chaotic::convert::To); +std::string Convert(const ton_http::types::shard_id& value, chaotic::convert::To); + +} + +USERVER_NAMESPACE_END diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp new file mode 100644 index 0000000..3f59c93 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp @@ -0,0 +1,2 @@ +#pragma once + diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp new file mode 100644 index 0000000..3fc9309 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp @@ -0,0 +1,35 @@ +#include "ton_hash.hpp" + +#include "td/utils/base64.h" +#include "td/utils/misc.h" +#include "utils/exceptions.hpp" + + +ton_http::types::ton_hash +userver::chaotic::convert::Convert(const std::string& str, chaotic::convert::To) { + if (str.empty()) { + return ton_http::types::ton_hash{str}; + } + + if (str.length() == 44) { + if (auto res = td::base64_decode(str); res.is_ok()) { + return ton_http::types::ton_hash{res.move_as_ok()}; + } + if (auto res = td::base64url_decode(str); res.is_ok()) { + return ton_http::types::ton_hash{res.move_as_ok()}; + } + } else if (str.length() == 43) { + if (auto res = td::base64url_decode(str); res.is_ok()) { + return ton_http::types::ton_hash{res.move_as_ok()}; + } + } else if (str.length() == 64) { + if (auto res = td::hex_decode(str); res.is_ok()) { + return ton_http::types::ton_hash{res.move_as_ok()}; + } + } + throw ton_http::utils::ParsingException("invalid hash: '" + str + "'"); +} +std::string +userver::chaotic::convert::Convert(const ton_http::types::ton_hash& hash, chaotic::convert::To) { + return td::base64_encode(hash.GetUnderlying()); +} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.hpp new file mode 100644 index 0000000..73dcac8 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include +#include + +#include + +namespace ton_http::types { +class ton_hash : public USERVER_NAMESPACE::utils::StrongTypedef { + using StrongTypedef::StrongTypedef; +}; +} + +USERVER_NAMESPACE_BEGIN + +namespace chaotic::convert { + +ton_http::types::ton_hash Convert(const std::string& str, chaotic::convert::To); +std::string Convert(const ton_http::types::ton_hash& hash, chaotic::convert::To); + +} + +USERVER_NAMESPACE_END diff --git a/ton-http-api/utils.cpp b/ton-http-api/src/utils/common.cpp similarity index 99% rename from ton-http-api/utils.cpp rename to ton-http-api/src/utils/common.cpp index 9640e7b..437f8f8 100644 --- a/ton-http-api/utils.cpp +++ b/ton-http-api/src/utils/common.cpp @@ -1,4 +1,4 @@ -#include "utils.hpp" +#include "common.hpp" #include @@ -16,7 +16,7 @@ #include "vm/boc.h" #include "vm/cells/CellSlice.h" -#include "tokens-tlb.h" +#include "core/tlb/tokens-tlb.h" #include "common/checksum.h" diff --git a/ton-http-api/utils.hpp b/ton-http-api/src/utils/common.hpp similarity index 65% rename from ton-http-api/utils.hpp rename to ton-http-api/src/utils/common.hpp index 6303eb9..09064b4 100644 --- a/ton-http-api/utils.hpp +++ b/ton-http-api/src/utils/common.hpp @@ -44,47 +44,6 @@ using DnsRecord = std::variant -std::optional stringToInt(const std::string& str) { - static_assert(std::is_integral::value, "Template parameter must be an integral type"); - try { - if constexpr (std::is_same::value) { - return static_cast(std::stoi(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stol(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stoll(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stoul(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stoull(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stoul(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stoi(str)); - } else if constexpr (std::is_same::value) { - return static_cast(std::stoul(str)); - } else { - throw std::invalid_argument("Unsupported integer type"); - } - } catch (...) { - return std::nullopt; - } -} - -inline std::optional stringToBool(std::string str) { - if (str.empty()) { - return std::nullopt; - } - std::ranges::transform(str, str.begin(), ::tolower); - if (str == "y" || str == "yes" || str == "t" || str == "true" || str == "on" || str == "1") { - return true; - } - if (str == "n" || str == "no" || str == "f" || str == "false" || str == "off" || str == "0") { - return false; - } return std::nullopt; -} - inline std::optional stringToHash(const std::string& str) { if (str.empty()) { return str; diff --git a/ton-http-api/src/utils/exceptions.hpp b/ton-http-api/src/utils/exceptions.hpp new file mode 100644 index 0000000..7022cc9 --- /dev/null +++ b/ton-http-api/src/utils/exceptions.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include + +namespace ton_http::utils { +class ParsingException : public userver::utils::TracefulException { +public: + using userver::utils::TracefulException::TracefulException; +}; +} diff --git a/ton-http-api/static/favicon.ico b/ton-http-api/static/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..d0c5765afe35ef66ae35fc9ca4b63ce9c5a876d3 GIT binary patch literal 111201 zcmeDk2|QI#_r8a0$sS4BBUDmCku^mnqP<9IFVen{N0Cxeku4#Lw1`rvY*8UCq|%0@ z?EAjG`<;1tC0|0;`t$pZ`{v%cGiRGKXU?3Ni(v$82!{R$m>^aujbUryH;MEuFTp^- zmW;zNRn?ZfI)>TE5il89|$K z_L3=Hriqi@B|B+LirbGNg&L?b@us?n%{{LzF@}Xp`mIxa_}sjZoHv?_7=6ar-P~}R zPy3Pm7-<`Qb#)>mi^ZB7yfR}{PO-6XK9f#b^K@3&+Q|2cr7u;UDNYjEAo_gUx{?}8 z6`#veD?aY8$=&NyY-JR?Uck_9^<)0H#zRL|C*`fTOe}TUa70|!TActyv{^0vP@dp9f~Gx2$fw`tn_E1>ov4&Ic@~|5W0G{PIJRaCpWMQL3L{ zed3O6Y~rW|N!e~nkHV%J9bHXaBQW~pW@9Zc!K>3r=d>0m*ng%~Uvgdy$IJY^7#n1 z9#Pz>fKA?4-{8g61Wv&d!j{Z?xLzG**uzjIl%XW+l<;sG-%Ao_Ez^hGu>yu{1`Olk zxni^`Oo`TScHerz5Mr0L^w1_XYb-~R!7H(rF=CZ)nuW;Ty*`Y0h@G1hN3O9}gq*XJP6nw;Nb%XXg6Fcnc;=OIiEV9TdRF6}sIXacm}VHrab^)2Dvzw%I!y9qRx?+@Ji&??@hVuwjG7ac zg-Xo6%Xe*k5i2w=qG*wY=_96zbk|3lsdcUvh=h=BkYKLdN4{%@0dB%&XRLVCKBwET!(xRIS5ZCn;R}DZ*_z`9Q|~{G#)Y z5-x6c?6nN?j~x!?Tr5*seV@LjEPsUpzD;RAyOFN*`xzF3>@`{}mRBS!B)<+byjyk4 z^o;Gytq!xZher_8z6u8W5bB3MFeXJGZhjxNHzQnGGe&LIc23XPi>7ZFnUua5Yg}nK zJh}0n_%4pZ6Q91w`KsvnSvw2P8NDM@Pif+*hSbP?tfD(d#?TPPb1_{IUAe^jno!9B zC2Or1@jH9#{OU80Z@^+CGKdbF0_6pw!cQHq$z^U93?*+jG&)@HL}J)b;ZsbJCr*od zVfVhe2^$O%94~0BV|&c?(vYqEk7ouYibq)0h1MIpoH)$?VfDgTzUzlA#9Us*Mmkkw z*fEel8K~GMJjYbD{mgkdRIP?to*jEQW7L;Ljse$*q*Y~@aJAbdFPSs(qm#dE_4B}|t+SVSq;fp>sl)Pl8ze^Lf3_DNkvJ#M>*1<3 zS+=BXEN!jO(J1@Vwe0zg5nFOB1odCsJ6S0`>2p}R#y-VIlNBbYG?yGH)u_td+N4xZ z_VzuJrE$okcBBn)BAc@mlgVgFgIp4;UrFtqFG=)YqZKdOjI|YiJUactoyBF=yn(j~ z_|a57n|*ZIS~Xkgu1^0jS}gR|ayGrZc^g@>R{PFWkf}(lH}?>}BYhDYzTGcNKyjx? z!h5!eli8TzIyE_BcuJI&o-^;{00nnfNo)2TZ~i+K{*{@sGp>u)u*E%$T0N%Dgsk;I z$#5OEiuTP!I>kusp$vA@=~b_8ixR%h8#|+_CeG4iYU#5{@>!oNgky~p3`UO9+^52P zAt!3w1qST0OwkfL=QAE_Ik#nOZ}7>gE_T>YQ_o?zuKE1^$du54qk_gvsh-D9e9n1u zr#@){f#;s3@~qOaq=!*iD^4$S*oYJAX6R@LxoW2#encC6Z`SgI*(84>f`AoUVzX@H zZ6zjAx*3j}rtNdc(8q!w`0YPfKhkPP_FBUyF7~_hyoZPpS(aJ3Ke~HLq81_iRj+<7 zUv5U?vXE=l!OLEZWLg<&ud=UUY8pQLVXU>5Ka)k=wmM}yBFBUP*1*w3TtMM^^J>gR zZh6=u4Y$;ftX2_4=~gmF8p!0&&B=6Y4jBt)(ucoQP_}+k5I1?L`l;#3+z%#CFB1~3 zonj_%K-$|%B620mju7HvrGiYwa=!ay`GzUVjuF}kbJXGz#t6FF^SfTMaJjwxNy2`c zbJvI5okx(asm^Rp;HJHhDJ&hu$i)}VAas3sR46UG8t<4TzWLFI^2QZq)~~<)c*xz^ zY{O^PWm*+{q5UvpL*+|%uVk}x9*vK_lnI_oRh_lwD`Q&bvvKdIGwj%M(RV*rj0MYE zDfZQTTWhM!vutm()9QuHU>N>Uexdp*7FxxiMJltzn&`+MxpO(hu8Wsk)Dra$!GMEEf6u$Iyb(se4n@-dHTlf zESegX)yL)hHFF$=^jQpX5qd2$^9#Atj#C$@%AOX;N~kN<%Zv8b;=X^|cC`On(Ix(= zY=#%f?lxJu5gQ5(&Xz& zGpe~$B#Na?^tm5BBG%}{?|)=GXGOH;hBC3_xpJx7^RHA+oO;AG<#dvv=3>h!=jau- zHHeRJkXaF))L8>=`$ zpfo5q6ePwmyddRBtpWd?BS|;w8?~l6$I~^)(o0$8nmM z58O-mR6cJ$-`yigRp-~-9O{2T)WYU%;*bk|BQMEEC9F81d^}8(-|D)^ht!&IOm^J9 z$922Zr|Vke9X7Cz_Mao|zsPxrT@-(~$IK(21wP;MHvXJvxFWIh>s}>C&^ws?*dj^C{2PjN(cSIvZEcmmyo>QCYCyopa43|K~j9&s+_2 z>yGOR1sEM+sPHOpSj0cQTBk-wGs24b<+~@uJG1H<&*|=bmVChfr32#wk^=GMqEPEP z&SE~^%>r~QADHjp(SAQsKuS1dEnX)6E@jkuRvzEYaC;PCx|4;CZ$tUs-M&x5Xs#~8 zzI;Bi!4#ed9N}P4XCu3ae4b!}SB@+Wpj}!>G@UVh_c3$vtnJz{=C2QB=1p1kz*5!F zXUx%%T%KJ`R`=p*m#!nY$Zg1;cyTYkK%hchvgzn(#^{utw3^2qmRmT>)MfGm)=3=U z8gI95k|u>sP0Aj7d39sFk3N5sh2+aA6(c|DYWhtGm{Kb<|GrJLM&L4Kn;^R3Bqn<8 zue#Bm-mj4$F0 z<*w(AJoq(ej(pzxn{NJ`0)$g%J_nBreI&n-z;7kqp^KU-;I`ODrhBA58*$<9cde!bknSGpeF6z<#Q!0lH+uW!sHHLM| zF=7I7)b4pj0oRO$jnlRL*FM=kBGPH*Sq(Y$FEh~qF=eXq9kRdq@H{=&0Gr$_-GcDV zGmPT$*6qhmSKdT?-*fY)VbZP0063a5Gz1a+ZEm)&|~Op+kljp`gm6lp_Z*m(q`H%zK+} z&iPs^Fd~|-j%j>e+~eU@la5``*Aq%OSQ}!BzmERkK&Sm?CLxGP*mGfnm6JN|81!`M zi{~=q=gnEn;IJ`M<9u$Yb#8ur@Y|iMth7ESmu6Zt$d6@-ba;1#u6gL^M8@@LK&*Q& zvXn=L#(k9{T{&Iq9cZk(c+W`Ju`}k>v8-OgAmn<PpJJ;Ud~R^tn>2W+kB3gAbjRXzV))Or6F@GCLVj`ClnsxkorR9b3*(C zf}R<9U^YFZAwokj(KDW79s?K1aVsgkZaP`sV zkS}GIR9$yA`S8?ESYuOz8hFH7n&1H`SNc2q|dojzTiRA`15yPHH>_; zPf$XVSa7mzZ&7B&?jw!LcQ3vpy<#r(+YvC~m9-uD>Am%7{&HKM%N(2S&%mb7zhixs z4?!W+{OS0Z0%?*ow?%IJ_Ob@%lE~1uX4=0mbG3p zBrE3iysP2rTeqZWhD7Ub2+~|Lb!p|TrL)FVi4dD(?#_+em}+rgk>8iuNddGm3r@Ko zD3)AFOtUEsFC<(m+RSC4S~V9;@wr{g>3RVYdD;pxDU)4{eh5W zs3CMQ@+n5xrY>=H5s{GiWnaL>#OjTY3(t%?P2+a@)`F5JGieH3-LqdXznxwlVpFRh zCGUIx?qd@c+rkVjKLN=}>^sadj7d_Y8>2I}Td6!Bm8kE?wL#9F} zMqB*Tt0e>}&JT9uRVJuC@Hs#As#J!S*C)~en;S-ZKP}jMZPW%lpZPs`->_#7xkwuw zorEUnRc>8_?LW6a6~h z^{z~2(LuJES6(qKKJd3oLb#$>g7Nc|Ng>#&Js)NFZlk+C?YQEX zoP`ZjSbV3S-yW>O;?Gl-wC1w#U-&`)U?skL9|PQ0v} zz~^f>RGg=1``G&@=pRLIurCPo2&T7k*5o2R#OOZlD1Ilury_}$G${PMQK22t*Ka2j%4-R98 zEw?-UhWJE>(MZepWtwr3`T5DTY!~J-LLKY)Ram8OWlgAjbs@pldggO8^>jB{JYLHh z9?{O+IozHtM$2CuJ8(N#18E6TakX@pbgJF zdfmIt`-b^s*fm6MD9O~qxl^lFYTu2OSsya%3TDE$abw(wv`7b$V9D|K?T?&(L*uii z$bI#W{NW5dQlxCmu<#^+0X8Iv?NY|UI1qfK%uQX-oiYc(HM zP9T>_pLpeZKzwfTbpM#$!ghM@8~l!+eQW0vGIm09oVe#ZE<@7vEUA+fUly5XAKsNy z{?2uK!yD$A{=}rq3fFLf{bF|wZ#Y+StF9&ECGonN#yTI9aqg2Fu@e=GSJdmSc#~TY zeo`<#M!w)FxLGhwoy|6+1-?#NEX%KZ9e!-g@WFble3m7hvnDR0ZbfHDo}0GzX_GPI zsYu4=@%gS+cK(-+PvZ_sF(QPWpS(z1(PnN8=e5YY0y~EhK_@bJcw5SC#VuDnr(2#y z3`ns)>9(ZGdW&iBtzf+k)v;G5JvE!dC!tB)@^vNh|Ic9c6i^4*@m8x*X* zL}~XiR#M3YBLWN{{*%}bX|XuxZZmD#h$Zm^((rJp-g*~QIYE?R_otC}Q^~79NEwg% zPQR$2hgmIY$e+P}$&OX`gID#uW__k+ZOK?AnYg@_VQb=ZX1-({pTs{Q9t$&C^}zA; zf|+v~Sp09K2=4r1p5;_dFgxur`K7!7{VZv0?%d`~?{vndm+`x=SNWLim`sdkVY|&7 z_?#~5MLo@a;T&c%?wG(mq}*bXV>-w%-BFUJ%aB+LjfVWaH2W(~a9+B8xPn+=<$Ejd zu*nX3$sl^yLW07c0~7VmV@VtrGOgJ4k6#?VW2AkG4u7?zuS#;`P4_yS`K_{iDV`}8 zLDv*Mxgasu-ekvgqNsP%?iBaB16Y#ueC)B4*n^Tn6$jd7WheLI_9^2eY&XscRZ;y? zpC4FBbAR<7W8o4bA2;bnvDb~yW$rT0V5}fDt*nTRti->#E1da4Yb`UD?|Q?gxI9T( zp>1~?WdCO7fGNkrjkND^R?hOwwjPevioJ?T z+^qU4&~IYobX;Z9;f4Fz!)~QN(;4gaXlbeT>se__&s-KUBUKdDXZQq}zO?c2kRBtL z>Ns`Mw9oeA?}v=xKF{QL(Egq2(eTtO`?I+#%uJ?5*6w&Nl0O+=S57vtijig#Dt##& zULGj^#WqrY>%*9_bi_|DnkQ|Rnku~Fqn+L<_I2aukJgq?Ejq9_QuRiuwxG-?u_wbH zroOA@T56AF986%FWVa>ew!)5C>cQ)73Co_9AZ6?z2n%x6xH^OczjYn6<1ZW1NugZND7-73bHjFJ&V%D+)b-KopP?Yg{pOPIcbS z&10V47iX9G_@q`ev1IQ9TYvrcCoS)saCX0(@P(NDXk&=Q8=1>8?+XsfJc}#QHYm?I z>ZG-W2a9tMSxFzEUf}}*Gx59vy$mtNN?V0w@<2)OA~w|j9(y)Jn)y7uc+`Vi0c-Tk zhhQxJyJx*Wcx3aCEWrZ3x5rLgWpOvzG3}`6r5MxV1)6C>ce%}91G|-pb-XSnk0!Hf z4_(PT{Tcba%&`(N3&Kj0xURjk%gmt{1^Db!ibbWyv$B09&f-!vZtz=z*{4)XFbFLu zKCDR?x>$rQE{~h*{?rE&#|aM12Fx)s$IP^5Eyqr>xe`ch7gW5ll~YJ2RYUg*S`fA= zPoqfydp~ye89HQto)faDrCGjuI>UNitrM%5Vr2Fm2~b>h?D^J>lWWze5&%$PThu%1^r#`0F?{`;5JWk;-MVoYX-(yFx14)=96!t5W; z;p3IzUdgL$6L0u{i9~Zr@XSz|W9L-)eQ$8x(sbq`de0q6=SjDc_v2hpvOX9eCUj@g z9p6{4AwhXUs- zLsy!SOm;{C*J&PWW4gMR;~r8M_S`#Yz$62|z-yf7v(=AK6?ZJDFMpd>@XAc9< zn1`y$Q?@Ct^omJj$k_c^@XZR>z*M~tlGhGO9wMCeEN`kj;r&@)q>fthsKsNSMv2$! z?Wx;*kf-Ubs2{!P)q}<3Tm47}nLR;NjbSDIru`}`qgaLbbUR~$`LE4DIf6-qD@_CCdcrVTL_EdWZtogB_FI{yInk$IoV6o$?f7o(&><;>jdNSbd*d8 zhoWa_ju^?TI-hx^uv~p488-}6yFSd%K4k$z5dEws{F7Cs5c}h(v>euYrs?O@iHSE4 zn(&Tt^7R#R9a|R5L%3re`*gP{d*SWP)9eZuA1Jvqg6P^1)fgU(71qTn391QahKzg} zFy%oaP0mr@;S7_HjgJkKZC;accPG<=B_Eoljx>1Rk)KGTDG-q2#cgAsa$)`auOY11 z*1RV51j84lvp-{Y&-HyS3qKpqB6rM8l_BUU>2oDkG~M_bC!OAOcgwnqb2EoT>0HB* zvU#b$Ttf3Wqiw@MtWphkNh3N>9wx|S`I^agsJ~QMj*ei3SVoh}4W0)4x?v@&MQuuu zYKX3Q1OkDvaugUtKy?6x)8p`gtg)`CqOt+?r&iCn?sIGl-z4fM~SFh^T`7OdAh zHABgB=QU9lwU7*sXFm5rrIjK;G2v4`uPY_2tV%U&O1(UO)LnT@So0BSWCcQ};D==?)!|dx- zSE3K@m$m-HX}Ip$CtFO4X(_vr7e3#2xRk}zv|APSrj1TE8$~urhELDkEPdK8TR@O3 zf!z}yzn{@CVs~FKJOc$bGYXD38Yz{ zYknWiz~Jxi=K5aTr?%8K)8A-C#%`E9j2n;Th+r-!R5pAlNmW<&yvSmfv5)n5LFTCm zQ?E=;mwCtikdEM*cq3kvX=SWyw5XfFt0$f=tW#?n56zH)A);94?45#&zzXAEhqU?$ zYr0B3&yA#*Ww)EhB^m4UUuRUePnj-ir*izAieQ{}eraCCm+gB!R~h-|furIKJ}pk> z^@#HP2R^&QjQJe*?H}*>g|Q+iK8T6_mKBr0sK6H!7MnPm+~k|*&g|i3NgGm17_V4d zJ73yb^!XL6wDh_r$>b*Ztpoyb@Aq13B{tnTo0hriOb8bCz<1fLX7=zTp0QPHZm6-u zrSDNPnQmJ0K}54;{7RuM(Zq#cpRC)&AY3{pbD0(UQ2#|sD)U&S7GNISTeFf*%=c;} z*3VzGgm5=6ve+m;_R_}piYu8PzaH{t!;v@H``?RAUQ>1Wm1bq`RZ`ZXa`qi3N3dO7 z$8kkNAX+Xubv5(Bnxzp7NHRB=-&Xpq7x-+KJ4uTOR*ZEz zdl$UDPlBGs?^yp>P)yE5Q^BBo&KqS{`)u&39Y3#d=OthbO!tdhNjgJfx z7>!(OJg=NxJSRd`VUpYOtL{z$p-Lt~re+n(<}`{{SUbB{6im5wchkg+1b>dol5!r- zAwF84uV~DeY4rYz>&FFzs%aYvCB^BYILArYEab$VCukdZ*-r7g5}B@|wL(AkYoZ(f z@q)s)DouWSmn@G9Uoz^g(}`ozZc%g1P0eIi$qk?3B^VI3`Sph|?+v#;jHb<5>3G6BZn}*(-IBSd z`EEZU9$_|Wwk-aLT@KqjGG^&a-1NpKp=BCbdGTsG8f(^yiv(=Hip8xr7CoOXFyEUj zNPp|2=8}(1>eDyDsP#p<+Bv!+T1LK}HOJ9!E|=`Fi~b5c^SwRB49m<&W(k=~aFF=& zS;*W)($iC{*o>J^>#r|fBaEgvrtX2S|&sJt=DA~q7bjqn1W7SAvd^8lhnVKIp zPis4u>Jp_jEN`Q~=(`vTFFI7iWH?eQ*Dv119^1=vyJ(N^2z{J+!?nlfW{f#;wt-Ve zBjkeY$CPk_eTq8A%V?u|$rJOMWWH=F*g$7yK>xaWtdv{bRl|!uf-;L@WEQHeYM8l` z&CJhou2saAs6{&4xnu52U9Z$n^O9Q0ds%&z&cUqDyRTd4+$c0@cwV|;g_Cs#w|gCS zA@+@dhb&ZZX676}72he9bTubFkQ}ZZ&i4t8nlxMN&hd!EnF-wLcZ1AHCRaE|^UxZu zlN3~uj~@ScDx=C3H==}Nprw*2en$K32bb3q-gA7mx7h2loL$o_7lt1GH(Mj;;K!WaS*@vt)d@c6nHdo!|`mIo^u z8k-&8-ig@1q?9yG{J@#(RrG1OvMlQ=>5m(UT~uJx^KRfCw%PjezORiF9zK$DA2(a} zG@rM)+jJj>s$eC0u()3~&6UHI7b-9Mw+nQ+hz1-6m8W6P( ze^%pvsOC@ri>PIXVPrk}>77H39)|4~^Hx@9V$?J`e&W>!g1?4#GFk9YQrguIvK1<) zliy_A;yAGWvFwLrm8r7i&oMr1U$<-Sd@_vJTm2X_F9o zYD~+jJ3f9UpUaSKz+RU7+oIfzM_ybMlRJqCb?X z7xN)PC98aQ^jUcpUA^fU`VUyWvxw4b%g^SE1ez1^=mc(>f(6T*KBNnZ3d1^{ga1K( zUa}l%;f~4;NpEj9U<;20Zyk!3z^2!$i`L0p@LQ+nag>ed$jn=Kc(R1cwzRJoW20?o z-mBOLZ)Mo<%90$Oy4Qbg>Nq)FtE=>N-lyNhrZvK1(5WOY(eY|8V5R-;(Ex`)bBV_v zax$|EHr7o}Uj$AL{_9h1tA^K{qUAMSk}7npRY{-DFbptY_CwN5)T6uT&2{fatA9wViSnygF-Y2ShF7B3N1N3RCyo&_L)`Y3! zqNAG(N~R=vE|vo(C|64x4tse!Un_W0)@nxRJ(QZ@J)>K?(xQ%qN>LQOOo>VI) z!PTLUrcXUEGU=WKi)+xF$G+4;ni3QEEV*kPuvF3d)>DuUO zo|hw8@l~6$$}YVTsTf(cObFc}xmuzV<@`utdfWBw>Q z=g_(_nTlkk`(&nw)Op$bXCy(CS6wcNpTc6FWZ>KemxYJ!YZ^x;yazUO`r3WJtLkOigXHMdD zq6cFcZyFTVd8wI8l8yl>I2(tLCi!#XOs{Sm@HG(l!mk9RbE)N?WIDh*KkslvqJ`#x z(@n`H8Fj}bgJjO=N)%e`TShRI-o>0zTP*CFO3);av-0xMGCZjDO8l$e(qq1n+Lld% zJkF&DlX4V-4{xZOwx`gEkz{u1llgE6!nv`S{lmoRsxi?7GE03btMI9Z3~BF9hL1{A ze!_h)?Xfj~m4sc?v^_7gY_kLc)}3#B@^ExEv-a2B^p*bcrAo^Mqw`<+Mr&T%F-mRN z#z_HBwO8;-$xJyHK$dvp1eRu15G|J#5BXUXSW*1)NGQixjAE*k&d@=~3 ztr01agB1h51r7y?c@PmbL};SK9U0#j^x;b!{G-*YBGUp@k{~>Wa76AltGTW9-Xa^T z`Gyk4z6?%hKd{6;CxisPuwIZoI{D&4n>DPj2|iKkOjd#f!@%bxGP_ge=dW98pIg72 z)68wcv{G!j`;@5-Pv_S8EfU(tneZfUWD@%;KYi`Bu1kiPj1xU+$-uy@9!0zTv@iL< zAy$qjGa){zJjcr;{8pg&_WDh+TrnGA^+!JUIkU>PZSovVvsZF4Ub~=x9fujRD&GXQ z_z#C>JI{GIcWERuK}|QIR_slP{(jz*Dr1~*_hq-OO~~@A`C=yWjw-I-k+CuKu*Eo2 zk>}Zh21`bXaH`nmU1qD5)ZAsjCmcRhRnBPE*x;(VakJj+Vxv>vwl~4`l;9?Q6{aS| z2ai3jk_E`k29lN0VKGK8^YQ~jF1Z+FT3a|pfCbYi2kVB!bjJi{36>mHUn844gjthS zl$ZE!8b_=BxK?`61ll`#39hq*>s}sh2oWlo5QB@I{O}z7Ot~wbeB|8dZ?!%D+2O0< z468S6EPJ4HLqvSHh8b&}atw<@5iAo0Us89#<}NzLO(>po;ksba+k&}7T3Vr;qgfAj zxR{?EQcp~<3d)G9WyL@4U9tO7>VwNEd!=I6%X(L@+{rI_Y}EF%>Eb*Kd_GQ`PI{S} zeTVR6pEHkek!a?GLwg-IvdPI_$kJC54p=h8BYOMQ`NP6y#h+H;6fjDS31k*b)>u4i z$I>-?hZvPuZKspU6h&*X#@lnw-TpWyZ=Bt2A$MZB!l4RFabfEeS{MHl)$ECKw6Wn5 zZ-ko+4(0kDgU~g*D9sV^m*$sE3_2`5Z2`7AP@K(m}i1m}mFI}4huF4!%~8vDHTak}6f!p)m$SUqaYAt{YXQJKqeFUeTg0$*X*qFk(?;{zPw~?%=klFvUdB*9@{FGw>FE( zS;$#UQ^W9JfbH6I&N<}A4)H-c=jG!4H5p#U4Ba~X3%{9=wn0 zL03w>@cW-4*k6te@R`CJd;wffVZ`D9j5gm56D@GZv)nd2UcI`fi*#DhUYlCqCC0}&r6|PCX{~y?}Zn-V;)e(0@9o!H*8GqIgAd!MUgK8 zz82by9+Zc^6d}}y-vgh65x=320r8kxc@?Z-|4vjBp zytoB$_Bav#V-+GgBK?{SV{g6(HWqk%sQfJUrqqkl4=H^3O+W4lUU#+*BnRZuvlzK$ zjBy0GWRScf_=91L`j4@$Tj(aEaTREm=Y}zZZa0Sh9S=OG&=~02k^b&1&w8sI8RV1< z;}98S^$EbcF8?gXO2G-_xLbtz$6rR{D5bBvV>~d<9)j_^pbY5v7x272St27{1$dNz zZa5C|JesP{{&7}z2|bDp5B)tC=mY$AgT7OVY^}eT?``FQq7y(C>R^2E$v=aMQRkIi zBGf-t7}?6mP68XA3uto$Xj6%FC-A*3{r;Ie*o{ah)Wg`|0zL;`%A5i0gnx{+9ikHh zI3r&R%&)fq-wRs$`#;0yj$|0gIpAFic<(Luz!;IO+ab~Zfda@D#*;Au&}RztgXhRj z`iJy|u)EwIdz*UwaNdgl3>mHqc24`8fXtUn1)BD1m%i0B*H| zeZE867L5r_pbM=3cH0o?v3yUA75IMnKR(X4)%P9dfnLqfXYPJ=gY|{K&^AQ#Tj=XT zpzB|Qtvjgi|6opw=8E7C$;@-dB+v4svhKhw|P&M4P+D4gI%}^_Z_%0faDW+z7k+<803AA@&3CE zAfFM~1RGJD%Rp26NG^frYY>csyzg<|Q)K`L`r_a_-Z_xs3z9uB8i;)`9^`%R@g4fq zPci_s-Z&7(0;G%bJTM(JJ`MK!A3SQ!uip6G($`k?r%ed`o>1t9O#*#XHOTwE<9&-f zp|}EM6VB|9xgqjNK-+>4`<6Gz`#$GAbu2)0!&2}Qj79N9ePt6y1MeYbo&|J%+92=y zjrZSW0AhZK{^I4Iwu{zO!RJPL4|`L3YaBphKJb1V^!*xubCCZ7pzpVq7tjGsV3SQl z>uxj%Ih6KeC z^`s7HS<6MSJIJr!XLikCTYpAtv=<3ts@0Ir?(R5%VvrzCnFe^D0Q?vn^ZyR{N8>K;qgsXlmt8-4fa>^20idg9(=Fnz9`?y38r18QJ>R-mggfcOvZ9`5zNkMQ?E{9g-{>1qC7=o$V$JJ-Yf z$NP-`NC&`t(5)-{N4$sg7C6A>EA92ZKgj<+(E(t`33S#cfcOu5-`6L7e~|yZ&VQr> zV13|NXXb)vzF+K$(Sz>))F*v^kpI2Tf5b=V%VlUU4mvmMck@9cBXGWwK8zW?Yx5(% zQ`6x1|AQ7(n)L7$`ZF2UhBkCG27vA-LQF|SpY?r&=OF)ko&SiRz}Kf9zljq{M)7Gg;`X`QLXP3;m4Z!}Y*q+KU};vHNx* z-(lu)GF0Al!T(Rtae=YcJD|81lr{!I3N z!Pm~}kwO0V8UKN|&9G-9skJ{C`2@<~3^L>+803F9wna@K?gMCd1AwbdE|EHW=4stM;ssqqBGa$dC&;0#u$Av-u_bLCu$Aj8)MDu-Q z1EB9&K;I96dxQPIt!#EF|99wr;Bzy4!{PyTuL%0C4a^HZ4)VV{V?TQLui-yh4=VZM z0pGF#-CyE{ae_{01pfD_9{S!MMgMmc|3jw4U{PY{{`&cU-^KrYr*RwJqOl&%6&r*6 zK2S!n-)uhwS105DkYBaX6MSsF95>e<%{smhG0bi(cvETS@8bm_&aonH6X4PN@n7x1 z41V5bi0huy!v7V0y58GH7AY`xD*hLIzQ1~RK;0w2_r%ycj2A8deESoZ7F*u}>3{J1 z+QQmEzrs`C-kJFS-i?>-Ies8GJK8S*wn9J3Et&&B@<4My@CW$!CoF?)_ee-!hB_Irc>|IQ%) z|8rvi^8Y_U>;Etg_&_W`Kihw>PtSt^654C^tAw6G`WyNvTHEgkmu~M%>^8s1un*t{ ziv0wdTBCg-{YP7fnegJoi_TAgH2yb98u*Xm1iFoTFV;cCi~J;igTpuc3cX0kbL?)*1&cHUt8XV2(9(EZK8e{Hny4|G2} z$Ur~G|8{)-+rPvAzB~V|J$(f>A34_z6GibK$uI^$|9=Z*`^N?t-2cEU0HAMp!kKSV`fU%uApiS>@4$0PJLPEa2eSQO+^6>c!qXT%^#3Bb-}g4aApiT6 z|Iq*IV9y5!b^kAt0dxic*npvf{O^tp@K=og%@yacc;xp*e5d{)SpeRzLFYumwNK@7 z@cf6qqc`&V0Dt$jJqH%e0SnH+*^i$6;0Ne}{->P7=8pExb+o?;8jVEcva#NNDdvQvhYQ)AGiDG zKbD5h@35`!@Fdva&2{DNAN<(zq(9DoM0^F??@gvJMr?EZA4LSv7yxSm=6!w!Txa>; zAyt1aP?L56_}|@qw($LrzxewPt;ce-#s_|0yJ+zFQ~P}DD;fjfI{_nr|8=e3>-FD* z{O=Qc3;B0||B}>sUu)h|f1_~$`~ZDB4;bWsU+^ED|NRj4aVoEWb*0#W?%1q8^#u*` zzt{N>-|<3rzj5+!&VNVpfa1X_;9MZ!{|6}FH*>*3{`WTj(Rxn-*#1M&djGHbed~K@ zd;s3}ogFyH|6b)kn)8G0cd)g;uQk8h{-&G-?TWF2y-?66I$)6hy~=;+_f;^j_fB&&_?RNNm5;DYp#rMtkAB!N)1NL_~ zb%pmx4v?z8$kxTNyiS}cY~O3S2*9zm96Izs6;%20Pxdt9_r!e`G7d{%~fHp{(B50SF%y+uf6?V;Xf{u6q(L zR98>J_RG4E-Y);V$XT=j|-tspXI!Nk59w z0RIyPb-;kt0m#prUg{2hUKq2fyz8keWgPIpL_og!=Q~k@{r`9UAC397FxQ{hlX}0c z>`-FG-7%v+@e2;}`*-~Q=^5e&jL#NmoNmjrp3WmZ06M@GjWvIfP5cwR{w27<$J-2g zKN$7<9x(Si6c;qMl$^&H;9J6jwm|>uDAey?K|DWeZ|eQFLP3cW@xXXN4`dG7gZ*X? zqL`k1puZ5($!&Sm+j%5!FwYzdFcc2TK%dJ18Twu|#PiAhE}pN~W#C)P=rmYo81xPG z-B^Hhek17oIhlQ6?{y?Y2nLvU%!2s`I!APHouGH+fQ;7kf!-@&45sObH+}US#-BkM z=v}^}`3r^ja9xA@_WnGttFl9tfx)q$S8M^~+iS@8z>EhX@2Rqa#sZMfXZrDI{QSs%rX^h$s04?h2@O*F^Lh4VQl4Fp@S zEw9_lBOejS>j;P;O#oYU&`*N4)5-=SUAAIRO1-1bS?6-LPZ+lVPt`4UC^#D75Q^ zb=>}t1$53Z_zFc}%_y-&7yN3h`%m8kx}bHORM>+(E*k9UzF5oYOIZNhmGJ%)Mh7_V zADkopWV52R`+A_sVfY>!cXb0u>PXT!_2b=mbtU0~~-$El?5r3LtUIE`?qv!{; z289xZe{gM2XQ1cb%fcEAj^qpKYleE8;P(fpHw4P;fEb)<1+Ew)@@Jqi3!R_ZUEBuW z?-~UtV+7D2UD0<;kX!&?IDkJ2@J)loaJ2>=`oQ-t?x63S!nl!%bO!LU7Ubr;u0VN^ zl@fTK1>Z(`j=qTrd4G7{7Rs%F=hF(jz-~u62->0gvD%)a+%@P2M(J;-rey#Bp{x|Zjd%D3lP z)O-twG1PoZh16_Ig%sew-J`t!z5130zE_WZYoG;M^o9U>A?w?_=s%^wm>+ox%A_{= zA6W_jt(vFMuvPOE09rLq0iad$6acbX)rSCRn~!Pz94J6)od*Eh=374o0Dl4x0BoE8 z30wfUZT=_l0fDyppU?q>+UB!fH2iUAG31GNO=v6rkwq zm>+q{fRXhhPtotK01`m;wE{o|b{duprtsq0_y865K)l-R)m7$_u?%me0wAT)KG;)f<(Xs;XnMT zVi*VWw?xVJ@;|VvFpw)kz8B@}QGT$y)ZzQoE5RPy0k+p6$UA}^<^ZQuMUtObmnUY(AW&tmYIIm*?mir7!rJ6&;uI< zxcdR#P3^(lTlaz9*+2)AO4q*MF9Z4vota_|cvtimex0eeMIIgkEK=Z0>-9e*Z?L{O z3TPjV+U^XDeNhJZPz!Qsh6nVXjzl^K@K%HVhxX?FkuK}a_Ygk-zRP(qcJ{O&d%SPsafbt2%09pg%`Cv8&?(%s+<0 zd+7rmx6Z%^JVfJyS!eA7kb45~-mNor|1D*ZeE@w~sv~`fd=AiORQ@Ji-&r024IWlF z|9&m2_zXq|vXa`_I=_{J?NXsW#NV$)J=oe=OlGl7iz06>n7CIwQpepZ?j=cWcU^S zgaR8F{W4ZEG1oYww`1@`?X@ukQWzZ#tn>&-hdMM=*n|U#0pJk(~?l*pKf2N%|H4 ztCH-YE+$9}ZBl3S75cVE+xJ*-a$Q9$?Ek#~x8Pp`dTgo)xoovsIp-1sYK2?|>8X){pTm{H}RUq8Ib+NuHyXv<&myyoq7^?s*Y@3 zKlL~D*`Hm3_lD5_(Rn5S|9>u_Ge|Z;Kj_yrjQ*rM_%^Me{lCVq+tajyzJH{r>-@{= za|9an?RU`!ke&hD55YKqz6JPS)PFeWe-xkbs(bjOu?~InuXRG>Q%}>hb^Yjf*L@#t zU?QVf9Kb)k&HXOHUUXgwQA!GUJ<*wTWx^sBRti? z@8R4X{7Wt)`}gO+zrp@R_8-{4{IKs~72y9zz7IsVzj*$W2m3tGxrUNp2mBZD4?}A` zd1o*p;Q#ec`@mnyf8+z)fqed%u)Ys{!KY{OKM1-7>1gUag?jCbPNbG?b*1=!dT#y; zHa`x2pYQ8oK#RGc5C5nS{EGigb?#%yz->=h;{D>8TGY#p1CVv#y^DF#+0<=|TAgq5N`UAiBw~nDq`?mIV^!L2^ zHQ)X={6W{%ga30R@_n}c1Kb5c2D%)-`M2Q@vhSY>dcQU9=r`HA2&VEyycgHF{|_u(p(M>_J?a`~(Kz~3go@w?t@O9Rk>LQtmmSMRoe z4`2ZO+^N(Vn;m`Iyi@gc{Tt}u>+<^*@2PZvy{;(!!LEH=J5TF@RtNAE`ME|>ac%Dk zWte~l?*fR>L32yVaak0A3+ z(C0Uzxb=>B+m+|A2aOrz;QBz;i2z$AirN01jnfsJ+mf9}WAb1R^g!TuX9$Vn3d_!YTVDWrtO9yC11{l^UO_@KLS1)m27Xq6 z4$Fdj34rSbc)lO<+OR&ukqkBrnwR(1ALY;hijNWw6A(Z@Vp@&>LM=j;a!i7C%jpIJ zEvFv9i3d;&!{F!w61u{f1nBbP9GdTE7qpzZpwe=so*N^OMJfONoEZ9;Z+YsKdOkDF>eg-Xlm6xJ>3u7&Q< z9b!;LK>sXs1%6N}0{&1cP-!_60{Dj*MLBr_3Q|s-fSTbkIwwK~(n?6*&xsK2`Ew#} ztc5xCDU1NJ&JD7y0W!WB=}VA#Z|K{Ba7A+O2K~eq?i<5zS@2sh;r1Yfj{vxS`YS$1 zSs#)Hcx(XnWJt(={979w>2bgZrBZkgopWjmzquat;W!QFnh}APx&UtswB7AJj8IPn z;Nl5&O5iTN#|-$k5L%B@f^j3EGjv9@?n(k$ptChR!6(9lC-*EK#qN}SgQua5UiX~= zKk@;OCAmE?$3?aT)FlRWrgVjt-7O3JMK+BGjB`W&loQD209ir)%6^Mug7%|;=j>g@ z0jXqoPYvkU?=hG_Kh)p4gag<$XpeA7cjcg`-bZ|Zb9Xu=OQ6TN0q2iB)pk$SgZe{m z2fmvkh+6?%ul7`%JzNj!(~H~Ft;kRW+AjrJ>++nShv95@+yI%*2if5HRey&2EReo* z1WVERQFv+SjCNCzzi_+lmt2|J?t7HI1s*82(ewU>AHe`T z@OrcN8wT&dM*#R3cLw%>0zc5Y0`|#qAq>jlEH=bzz_Yn6cQ8Q(WUsJ0R%tVD<%u@-})WB+deD3J_E0PbN+iO z^5tzu-aD3`vYYe1*Hio27ccZeduuy>k6H%Jr-27=srk-bQLJLC7{o5L_y6^GuP*4r zwxD}T|G(bO)1W`!1=&I8sdRe|-d{L?>|B7h2dur;3A!NvQgtWFb*W$VRehj;yg~l6 zyVf4+b7+qUHFc-2bgwSt=Yu{F*A@6n!*p7mgAjrj`SSfSZ^~{h_)*vUt9apA<}TF* zuy2Os*%kN)%=iU*8}z3J*q-bDM)*PYQ49~V-Nc~}cY3epK%qatos9h6u+M@9e!uQ4 z4}O9l_Sd6)+3f}2Q}IQ~c4U}99xXh6V= zgJggC&bNA|!uety`%hrJP0abld1+`Z7G&x~XL!(GWq`hD-CT)E^R`#OjTL08%V&M{ z6+QsFOI0hmZwo*EisD05>TF-`E4WcRK-U!b7UA0KTzz(Yrv(`^9L$# z;63yWxqAS!G29#4RsGTv9HGSA!u}P&Lmc?B4z6C1;sCa6zzO*^kp69gJo2@^g=e=Q z9fh*<;mTcT50O70o89?C{GudE*bw}NI3recF9t;)!Igx#20eG5Zs zxeCCU+6V|%49h}SdJKzceWm&Ky&AMrhlK7Av?wothYA_MR8h!kW?XkkJDoN^Ej=~ zB+8f}0rIg9WX26-=O)Nd9O%VZ_#Fc2I6PYl{goHaitMpJs1Kd3Z3bhjQEVV>^Nf-eHG#Lw{B0AKXLq zu!oqLPSFDJ9R;bIXWabY2Nhm`Ap~Nue|eTLl^$@m2p6>7#dU}OZ;RSy+ber4wzjEb~E83L%AuB)w%6X>HE)(G1?phJGeR4xJ-dLPYN!8Dt+tf?I>p#b}Jbwc* zwBP(FziS`bj6!-6>;(Pxa7Xv4?KgaR0BzDiYVRy3bRQ*poZM7Lp+yJnHzQpQw0G@X z`>{|r^6USg;je$wcB*~!F7RL}(BZfH3~6 zxF3i1JBR~BI8#$cxKp2Zt~|7l_RIEq?B}of1pZDKyWv@vZQSO-`o zt}9dN+tHO;9=+RsS)l(-X#ck{td)-~@rJx4yym4xiyX9H-?z5lO!_YmDesis)cI}u z&^EH8&i@X^AN@bJlkIn@|Dm}7I?t$E{_(+OkH(+tb_}KsPT`BG zepsJ5$63BNy;Og4{xAL4pAUI3!uc^Zn1E}yGxq)t&x4k~V$|5+pWaty*(*;uyf0hc z_Lt}2FmkQt!S4nJJs)$ngIy_F_U0G4P9j628~UAap}oX-f5c;&xIu<9|3e07E|YSd z>k!&u&)Nc;FA(!H-vuVr&AbiYIp~>8^@~n+wsrW_2D%hDw=Z?hpUFI|FmWw>6Zxm0 zl{-F%oqvKe#(L+t=C|EmS}(9y`zX3xf$lx%zZVbL2Dx^~uTlP*bcYy@=935V@(n6x zFP`?_omB`yVVW8tg$m(?VmrxKQvHSUPM7wyDQOSe{u(qzTRg6+Adz=DW^rQC(`Y)odp4AodWy%WF9fMrzMO`m2dIym?=1|uJW{5Sjr#I`QhU5(>!f0+#$YFcb zux8O*$?+F{nfp%m_Tb~VVSa_*#5_4|4kDg*9un~fcNO`)_XOKt=Yqz3avh8OuZDxx z$C4)xxQpmeipwSYZGCzWG@e~@u+10OIFIaUn*B!b&C}q!_g|S D!X$-f literal 0 HcmV?d00001 diff --git a/ton-http-api/openapi/openapi.html b/ton-http-api/static/index.html similarity index 88% rename from ton-http-api/openapi/openapi.html rename to ton-http-api/static/index.html index e0c9877..e38d918 100644 --- a/ton-http-api/openapi/openapi.html +++ b/ton-http-api/static/index.html @@ -3,8 +3,9 @@ - - SwaggerUI + + TON Center API v2 + diff --git a/ton-http-api/static/openapi.json b/ton-http-api/static/openapi.json new file mode 100644 index 0000000..d6681b6 --- /dev/null +++ b/ton-http-api/static/openapi.json @@ -0,0 +1,283 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "TON HTTP API C++", + "description": "\nThis API enables HTTP access to TON blockchain - getting accounts and wallets information, looking up blocks and transactions, sending messages to the blockchain, calling get methods of smart contracts, and more.\n\nIn addition to REST API, all methods are available through [JSON-RPC endpoint](#json%20rpc) with `method` equal to method name and `params` passed as a dictionary.\n\nThe response contains a JSON object, which always has a boolean field `ok` and either `error` or `result`. If `ok` equals true, the request was successful and the result of the query can be found in the `result` field. In case of an unsuccessful request, `ok` equals false and the error is explained in the `error`.\n\nAPI Key should be sent either as `api_key` query parameter or `X-API-Key` header.\n", + "version": "2.1.0" + }, + "servers": [ + { + "url": "/", + "description": "Current" + }, + { + "url": "https://toncenter.com", + "description": "TON Center API v2 - mainnet" + }, + { + "url": "https://testnet.toncenter.com", + "description": "TON Center API v2 - testnet" + } + ], + "paths": { + "/api/v2/getMasterchainInfo": { + "get": { + "tags": [ + "blocks" + ], + "summary": "Get Masterchain Info", + "description": "Get up-to-date masterchain state.", + "operationId": "get_masterchain_info_getMasterchainInfo_get", + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetMasterchainInfoResponse" + }, + "examples": { + "sample1": { + "summary": "Example 1", + "value": { + "ok": true, + "result": { + "@type": "blocks.masterchainInfo", + "last": { + "@type": "ton.blockIdExt", + "workchain": -1, + "shard": "-9223372036854775808", + "seqno": 51148696, + "root_hash": "pdEYB4jzhoEFdOMdCgfXJ0z4vylDW27ETqVaSJEDyqs=", + "file_hash": "l3sF5XbGapYGFnma+6dIk0fuZYdJYO4yAkNsjDkyxcc=" + }, + "state_root_hash": "qJ2FQ7fySAnOvgIKI9laL5Mgk8rQWT+Tc/O2xUFzwWs=", + "init": { + "@type": "ton.blockIdExt", + "workchain": -1, + "shard": "0", + "seqno": 0, + "root_hash": "F6OpKZKqvqeFp6CQmFomXNMfMj2EnaUSOXN+Mh+wVWk=", + "file_hash": "XplPz01CXAps5qeSWUtxcyBfdAo5zVb1N979KLSKD24=" + }, + "@extra": "1755812855.1928415:3:0.47373957740114636" + } + } + }, + "sample2": { + "summary": "Example 2", + "value": { + "ok": true, + "result": { + "@type": "blocks.masterchainInfo", + "last": { + "@type": "ton.blockIdExt", + "workchain": -1, + "shard": "-9223372036854775808", + "seqno": 34539805, + "root_hash": "z1gmtb/KbcNwHDVLOHphfDcYMfDtRyW5sTDLuNbPd2E=", + "file_hash": "/3zsB+Lr0mONcRGZ+tx2jNC1VkOHCXfmjJ9Wai2iUlQ=" + }, + "state_root_hash": "/WR0k35BrgggvPUVglES3I4wt3SrHvU39T5YQQ0Dd2w=", + "init": { + "@type": "ton.blockIdExt", + "workchain": -1, + "shard": "0", + "seqno": 0, + "root_hash": "gj+B8wb/AmlPk1z1AhVI484rhrUpgSr2oSFIh56VoSg=", + "file_hash": "Z+IKwYS54DmmJmesw/nAD5DzWadnOCMzee+kdgSYDOg=" + } + }, + "@extra": "1755812953:0:0.712" + } + } + } + } + } + }, + "422": { + "description": "Validation Error" + }, + "504": { + "description": "Lite Server Timeout" + } + }, + "security": [ + { + "APIKeyHeader": [] + }, + { + "APIKeyQuery": [] + } + ] + } + } + }, + "components": { + "schemas": { + "TonResponse": { + "properties": { + "ok": { + "type": "boolean", + "title": "Ok" + }, + "result": { + "oneOf": [ + { + "type": "string" + }, + { + "items": {"type": "object", "additionalProperties": true}, + "type": "array" + }, + { + "type": "object", + "additionalProperties": true + } + ], + "title": "Result" + }, + "error": { + "type": "string", + "title": "Error" + }, + "code": { + "type": "integer", + "title": "Code" + } + }, + "type": "object", + "required": [ + "ok" + ], + "additionalProperties": false, + "title": "TonResponse" + }, + "TonBlockIdExt": { + "type": "object", + "additionalProperties": false, + "properties": { + "@type": { + "type": "string", + "example": "ton.blockIdExt" + }, + "workchain": { + "type": "integer" + }, + "shard": { + "type": "string", + "description": "64-bit signed integer as string" + }, + "seqno": { + "type": "integer" + }, + "root_hash": { + "type": "string" + }, + "file_hash": { + "type": "string" + } + }, + "required": [ + "workchain", + "shard", + "seqno", + "root_hash", + "file_hash" + ], + "description": "Extended block identifier." + }, + "BlocksMasterchainInfo": { + "type": "object", + "additionalProperties": false, + "description": "Information about the latest masterchain block.", + "properties": { + "@type": { + "type": "string", + "example": "blocks.masterchainInfo" + }, + "last": { + "$ref": "#/components/schemas/TonBlockIdExt" + }, + "state_root_hash": { + "type": "string" + }, + "init": { + "$ref": "#/components/schemas/TonBlockIdExt" + }, + "@extra": { + "type": "string" + } + }, + "required": [ + "last", + "state_root_hash", + "init" + ] + }, + "GetMasterchainInfoResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/TonResponse" + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "result": { + "$ref": "#/components/schemas/BlocksMasterchainInfo", + "description": "Information about the latest masterchain block." + } + } + } + ] + }, + "securitySchemes": { + "APIKeyHeader": { + "type": "apiKey", + "in": "header", + "name": "X-API-Key" + }, + "APIKeyQuery": { + "type": "apiKey", + "in": "query", + "name": "api_key" + } + } + } + }, + "tags": [ + { + "name": "utils", + "description": "Some useful methods for conversion" + }, + { + "name": "accounts", + "description": "Information about accounts." + }, + { + "name": "blocks", + "description": "Information about blocks." + }, + { + "name": "transactions", + "description": "Fetching and locating transactions." + }, + { + "name": "get config", + "description": "Get blockchain config" + }, + { + "name": "run method", + "description": "Run get method of smart contract." + }, + { + "name": "send", + "description": "Send data to blockchain." + }, + { + "name": "json rpc", + "description": "JSON-RPC endpoint." + } + ] +} diff --git a/ton-http-api/tonlib_postprocessor.cpp b/ton-http-api/tonlib_postprocessor.cpp deleted file mode 100644 index dd2c713..0000000 --- a/ton-http-api/tonlib_postprocessor.cpp +++ /dev/null @@ -1,493 +0,0 @@ -#include "tonlib_postprocessor.h" - -#include "crypto/common/bitstring.h" -#include "td/utils/overloaded.h" -#include "userver/formats/json.hpp" -#include "utils.hpp" - -namespace ton_http::core { - -static const std::unordered_set suspended_accounts{ -"-1:e69571e7b9f58edfebefa297e547f36920532289dbe9ff1b76d107fcbac30104", -"-1:19bd614293ae2e6dd4fb93d7c00e50000d95b6a14784d05fff84d031e6f990db", -"-1:660ecab3220da2f1f770d016fb50669f03719cd6a5f92188e9e80399c0695fbe", -"-1:ce5f3fe4b464c70a56fc6abccbb775c48e5253c3d2c46318c6bd224d7dfefd96", -"-1:fc3d252d2b2fd4f8964348d50da8de5c56c9fd39126a4bddcbe8344cf476eca1", -"-1:d0d9b5213a7e0c03a3873c58bfe9b9a60f2ab17cd3ded31675373b958378999d", -"-1:9635d332838598e3bed341b7115d74586894f14dcb0c5c21426aa36c24ec766d", -"-1:8ca766a670559cfd65192e9eeed29c7ec5a1544c8bd9db7e5b6e4c5e663ff42f", -"-1:dae40ee38de9a0f542319bca8a0c90cee84c75cb4a8860a1efd72e89576a5fd0", -"-1:8e9735c300c1a005649a19b0a1dde75d38c2904351714a695ced416fca0d052e", -"-1:3eb1651efaaf65221a9b43cb849fdcead2c8b6758c2654d93bb80825988cefe8", -"-1:a83d524ce9f18ff4e0be3dcccc51d88a3cd7f0914aede1eb258335d7118d2a08", -"-1:8ea7ce472073d6dfc6d11be7084d384db4dec32cc3cd5ee39cb6194bc16210e0", -"-1:02a28d6b20a24a05477cfcea76c7d3e7eaa2a9ccaf21897477ea990039bb25b2", -"-1:8a49896dd0a389eaf292a3573cdfb37ff4b89c4c9965d8c83b1db8b1edbb2f20", -"-1:66d44782557077d989b3883aa7499be3933cde99d73d1bca42aed3d529fb173f", -"-1:6680f4d15366a1c672ad2f0b3eea20770260630f70582ed008a6a27275a8b3b2", -"-1:35f14297cde39e6f3e927f4feb76aed94a084f57e8abe21c5455f34da008f7b9", -"-1:d28d64b320b0a0530ab88a00c3104defdd27f4034cf03b9e5a584f8b6332c6a4", -"-1:01b573bd6dc4cc5e383d6e08af2a1e258499995903cfebfadbf6f7e39533f914", -"-1:3dc61faecbceb4fa609cbd2f3370052cf1b0299b12c6ca00cb10a8d493944bfb", -"-1:ef03ac917e6b763f85079f196b4146457019cabb1f262f678ca8182978c14fa2", -"-1:28e8033db1467cacea8b158f0f61e682de06e8a5947504c904f1f703d2be4d9e", -"-1:dfbeb774841a15254c688bbc07d7bdd993c34f8b256fc61e48a184a311865b3a", -"-1:67ce3e9105ce2643aa779e0ee6189eeda7b31bcc44617bba1b90cf40d309c208", -"-1:6b53efc00270641c1ef54c80b742f51fe4b700b2f8f40782286330172e910577", -"-1:4bca71c72a007163afa5f96fdd58df82b464f6fe38b9acddc4cce23ea7dcd611", -"-1:6131defc8334a256c2b4cf3d001ed1236bcc7552807f34364c8e7fa5f3a3502b", -"-1:3414d2793493b8fb44309550167245195dd93e3df6037b10d9d7e8eef52c6117", -"-1:df7486d3868a0fb38febd8313f67a66c5b27097472e7b2e2802474dc6da65a8a", -"-1:e5bdad2a1226615abad9265f88271c82713426993a3bd5f216c90df51f127c36", -"-1:2c3062b2a70d34e8079162a8a62e3998d947e9f921e4f02d19241360541973c3", -"-1:b17045f9f82db60c4f3a4bb1206e108def01a2e2b400df969771a7e3392555ad", -"0:9a4821d56a4fa321cf4036eb5301f1e964d33761d1a4cbbc9a0f3b13ae0d1684", -"0:52f54dc07c3d797c698eb51317400c5c3d507036e22d7cb7039e2f5f91b4f2c8", -"0:6230d2fda8d58c024247b8cd0116779872e1cbd7b9334b8a6cc296843be3465a", -"0:f1921990bcf0ed81c36cb7be49c97adee85d5df4703946b4247c09bee8461b79", -"0:57d433af4a8c768e78cde34645b5449085224c0b211684145d4444514a5b626c", -"0:08082a325d5e0d291eb4487c38182d0db474853a9846c36b5171b545f2f41eab", -"0:a3ced23f38b77551326d498de8fdbf2a6710f9b131687891c803f09f43716b8a", -"0:759b6cf34cb71967300ec403107761b1d01f960512c45f05f2537314a6bb9944", -"0:ccb433303a8b52528c2967cdcd7e9609602fd762f408a8161cb83509a0571e7a", -"0:34de8fb422016bb981681e8b7de82ff01fda402ab5591900443561d561f37c77", -"0:eccf124f399017d33b6695bb3b78380f970af7b6b9bcfa7cc57c07666ca86e81", -"0:1a242b8250d00dc0b76fa953688af6b553d1478465c55030c5835c17ee8192f6", -"0:78873be25710f5ef480865fb163c614a7db381e8b08fe58847ec8edf5b3ef077", -"0:77fb08067d071ba69a3e5e75ecbf3c2bef21e08501f4ee9e9f302fc045d2228f", -"0:973696d592e2b14f13db7381969e04abac18e1443d134125eac695bf83e5a10a", -"0:5d7e73f319b6cadfc7941d46f530764276b8ad58331b123f9f8cf7518af76bb8", -"0:ce811136b1b98f66997d940e98de2c523c50fc085feba4b97a37d9fa8b42a12f", -"0:0927afd84711fea63794c619ded2288c7479b3ec16c927f0360ed76603f6df06", -"0:b42664f2a6ac921d531524c1d6b296f7c6bb362eb772e1e27e33b431a5b4b870", -"0:6d4acd125383c243c1f8abc42aa0ad0b3f024b91c272c0bcfd5a09195e5fd3eb", -"-1:50ceebab9d128691d06488571531a858d0d783cbd44848b2e62ca6099e9d03f5", -"-1:5ec36a53dc55d2fa6f304479de7f54a9877f03bf637af7f492583ab52fb73df1", -"0:e8ce75fa386a1daf00a489851eb7441084aa83e6fb3f5d5a16930f4f588adce2", -"0:cb3503b1117458e8908ba71424a078ec648be57c1706c6685da71731c3b85dd3", -"0:22e69f616aecab212a3aa133f596fb4345ca51fbc0d755fc05a0bb525c2cd42b", -"0:495256f32bb4932ba478d8b7061712ebb9d2b132e5b9829ac6001726483843a1", -"0:9257d26e1aa4c5bf1840f1b6777ecf4ba0ef9be81ddf8e89b4906c0dbeb543e2", -"0:3cfd6e07318cac5199f32b2440ba05b1d3090f96357a82dc7fb3e7dd60670d00", -"0:00ed1c8d25c4774e0ef3fc1c176fcd5e3c3beb2f2b506a73bad9303aea648313", -"0:59ffca801ca64d630735fd09534e1b2f31f525a9e6da07083554cbc738b8f486", -"0:d8e4683041eb92670047ef67b439008f41eaea02c6513d1c7a0954f139bd8dfb", -"0:23b513f5915f0d4b6a28e8debb1b5c0638e58c309772caedf55a838a70a625dc", -"0:1c7c0347ecf1b679e4dd5f956bd9951e6f109fc09cb3042138a2b8945515378c", -"0:24bd5413b4f996618eb848b23e0ca4baa016d043426b18ec8b87ddcd9ab60f41", -"0:5f3fa1e81dbff3a9ce54dcb87cfe934cb7447b230b31bbce7c77476a99e01187", -"0:0ccb694f7476543e6ebde59f9b87467575cb5ae315d7edf97a7657364973a588", -"0:eb662dfa2a319c3bee59fba009f40a76be064a7fb27370c47811d8c4e5feea95", -"0:d3df81835a2722628eb6b846e84bcb23de194a51701661c33752b73436308c83", -"0:81797aadec88b02287d9fab623cfa8127912e31632dd1507ffb91ad79d96ae2b", -"-1:ed2cba0b988bdaa12c4a5f5b177e51d93b54c7cd2f91515214bb1fa04faef290", -"0:2d94745933217ef0f1d1c92bb95627b40b657f4616794756f90b8b6f9d3b62ea", -"0:d6b6ff8b69fcd0adbd4e22959c0ca1e8ed8bedd96a508ad94cdb7fb6924b0cae", -"0:567ccaef29948438793cbfffa4b1eac1a62276adecca6ee12160b7d91aa897e9", -"0:2ffff28b9b9d19cfd88dea7d81176786b41ecac237ded40832de592377d15226", -"0:9ef583316539952b7d1b689c24338c3485ceb46fe25ffde1316cf688be450ea4", -"0:baa3c50ddb54cbbedea3ec6e2e892d4f0772c1f0efcc77bd199a4f6e89c4633e", -"0:820891e001cb3ec10ce07fff483ca7649f0fde8f467e43e9f706d4842a2d2122", -"0:0000000000000000000000000000000000000000000000000000000000000000", -"0:42d8cdc3975887f2907a920edde6f761da733fd7468583e45e32cb4010fc4d28", -"0:eb0635b137f6667b96ae4459f9a8a359b687faae59307920867fd8b3eb42661a", -"0:f1daf90b511a49638c5ea18e2304d23ecb9e73232640e1ea66016a1bf74a0b9f", -"0:6ffb4cec37d8fe2f1b3512f6c61b47ccc1b79ea9b5a5c53cf28d5e0b13ed2e25", -"0:14cc4f8d79ff343bd74b672f751df3e239be84110f18ab258ac8853e29e6982c", -"0:fe9e1ae29e3bf40782d382bd1d4474c7c07d4c3ac80684a05725977bbc448c65", -"0:150f71678bd23a8fc5de48897ec00181121aa16a67ba3ad018d0649c293d03f5", -"0:ba002ab75403598ea7d1072ec93079292f0a90f6ac9826c0881b1d6661b420c5", -"0:8824b345224a390afa4a9fda0092b0e02e87033a80f8bf0987c4dc7f7ec1bf2e", -"0:9ee0060805c7b5a40936a8924f4acd4ecf265194a8e47eaf33b82f03edeaefe8", -"0:adaed4d7100a12a681119a2a8e9c809ef4b1f19f637cf4de011fda9d1e5ac6f9", -"0:4196b680a6cd0e65a07d43c78f427db054068bd46e35d40f9d369a7259edd7dc", -"0:62012a94a9a562ceba332d16ecce4582da41136e48693b6aa78835433cf836ff", -"0:6ed90d443bc808a0d035aa81969c752e74a7e6aa52840d3404f83c4dfbfe2c76", -"0:396efc56779faadaf25456a47d0256c421f745cac2d1d0f5c68159417fcc7985", -"0:60b8c4878c5bf96dfa0e76c86bdebb92f7299267385128ca2fa0daf11b1657be", -"0:312f4a05d7eccd82298f2ad85b0e7612e318fde2b1ed7cd44deff3ddd6bd8b34", -"0:0d5f5b9128665fc8f23011a217ad1d193aa69d72de6ad7476f2b1588c71ed242", -"0:62b5d143a14e435928df2aaec0b0edbd448c009c1cf3bdc5554a7e5e910a01f4", -"0:606eec7b5528ea2473fb07244ad6ae10b9565ba5209eb0d82fcf9a9a77795f5d", -"0:e2b0177c53b337084399f2071609d7ad766262dc0237d73213e6a07039d9946e", -"0:19a67fdeca75657fb222d9dea33ffa755113eb745f45dd2ec38ae750c9e9648f", -"0:c4d070607e43a2a877b32ed1310464ef3acf1e8adb611d0a2c0635b70660f2d7", -"0:f24f7eb392d04df4f556bd9d63a11c6121f1148023ede05da2b1af9e9d403f77", -"0:d23141b0b76e4841ddffc878c8d3717bd46f0aa7618c68c12fd93896a1329bb3", -"0:202b511caef12e2fdb02b688f770d85534eb9fde5a391883c4da09f57f065960", -"0:832aa2f9c3fe8c0fe67b00e06eb6efae47e6494ec80d5357eee3ae219fd82b63", -"0:756953321418679585e6423b266b44bade4bf1294edc719285342153c17ec048", -"0:5b8eb5c7a310f2875658181741a1080b6927315baa594758448490bc06a17ee4", -"0:be41e675dd03f496ccf134ab77f347c25ae695f78bf00bf6dfbaa9ab960d7f7c", -"0:22530a45dbbbd70a782a3617ff4d0e44ff4e9a8741b8cee4ab9df53b08b2da86", -"0:6a8958e685eda25469a03920ced451a34a2cff00cb5bd70ee52c488fe17205fd", -"0:e6c2f68ad9dfd26da3dda4e33ad1e7df3d678ab24b200d5c053c4cb1b9fb4cdf", -"0:d6b4f659805ef0bc83141d94288ee0f7bad8ae8afb16ed6b25449df7760bfee7", -"0:63f102c5d902d4d0a0cc09576ee7af3342c85ba6d5a5357dbca0785305b985fd", -"0:186ed0c264419100e5da07a5b056a173613775cd9832a75e4122ecbd9f4dbd93", -"0:9376f0c27f46c0e5d38f235fb8e2d07665f35c3068a4973be0dbb4e8be00c4a8", -"0:6c0a12df8596da476de025a47c49ebc85e8c1edae52d2100b38ee72e03d8aedf", -"0:4304a139586288967a22dce3b3c3bbe428a217e797968cfbe0c495b07a4f00c8", -"0:2f092c8b0a8db51aba8b0227dda2fe1690ec6e1900a3311c6017571749a3732c", -"0:eceb82522275740372bf32a3da6fba83d8c68990d04aab9b71c774507b9126c9", -"0:6a035ca23b47c3e1a5ccb24e214013b8ad67f3c7674da63dd4d6c763db51b2e8", -"0:dc07e998d553b4563b020dee62d3e9d38298b2c22bb852e980cc7e687354a293", -"0:c705422111d502509d7df7af92123d168ab69a13827a60b24eb8b28ba4af2e81", -"0:85dd813ece0b0250a34338ef881dc2a068db836e16d3da63c3a7a084a00fe51b", -"0:68ee815e7df6641338dc9b6a3dc9db1f6a773a1616c0e6e75dc0665cbecb4598", -"0:8670de1bd64dbe4ceadf00c3a46b7471be5c1c7150d22b470f7b39476607cbc7", -"-1:062bb40f112ffaac45f54209c9a187dc95f9a6c4b07b264664832323398e2299", -"-1:4e2b4087aa806275c114247c789da5774ed82652fd681211a9b770c52c69e772", -"-1:707cf9eff139c9e7f83df22fc4869047ff497031de94521ff2dfdd40c2eb3c46", -"-1:daec5b9b51f23c7d43e700866f21129a742f461bace98cb2c4e8f5d58fe75ee6", -"-1:9dd3bfb670c27f144544555c803057b8f5a06e467871cc50b1afbd7cf65f82db", -"0:3457022d52a7209684ac3a8e633819f4926b59dfc0d889d350e12151f63354f6", -"0:1b98c2fddf1bd44fe8810c9ace7e1891192b37bce733132f432406ee09beda53", -"0:200144a57fdce64376e61deb7995bea7f61d490b42121793cc1fba2b67cbfb95", -"0:0769ffdea3d8261cb8844691f963979baffcf8a57e0dcac0263cc7076bd4976a", -"0:0fec8cf9cefce0e363a6ae3be7d8a0060a46f91fab5806d8faa7e1ac6c8a4c29", -"0:3227ae037fb55f6fcfe39a51a7b19072180742b04580fc57d65f254453977a0a", -"0:78e7b2f646eede090f0d8604ada07c6f7b0552b0a08386ac9370be3bc509d669", -"0:7bd6ace07a1217a0c463e7cbc059a1e73408ba517114e427bde36749a9fe076b", -"0:7bb000be851906824db0dd13019427cd930e954c2e836be191995b17287e0859", -"0:5adbdef467512619ffb747e061eeddd699130716b601f89771679162a1352b7c", -"0:5d0af141e1b03b3c03f45579d3b3bf384ceff80a858b6f542a45dcabd28acb02", -"0:5fe31152cbe3045dcc14b6ad5b0ff14a0d6cd22c9e2de601e160abac3352d5c1", -"0:6677fa11f3c4eb7c019c2ab327e384f7c019db8774d65505abf2b56ad1b6139d", -"0:676963a7c0dfe6a9c0c41776910cbbcb3cb855dffbadb99ad7dc88cb74761e0b", -"0:6c9cce64fec3b39d0af559d13de077c258349e2cae9c0588b9c51c40a74917a0", -"0:52cdc190ddbeeb86ccec2d25a4759900a1f46d45ef45b78962d0e506928ea39e", -"0:7077dd1dd31dbab37c0e74e602570fb3da06d1ee140998243c53bcfc569e632c", -"0:5938393f375da0a562274e94542c69350b8b3f7309032fddad7255d0caf022cf", -"0:b50e6fc3bee08644516aad9d1190f09a4c90c06872967293f768dddffd3189d5", -"0:b9416647545b2735cdd83d161a7d412b160fe2d2c970a128b24e88c177ad536a", -"0:bb6c62ea2365cf74a189ccd9643e73a7077624c34410f6520c642656e465afa6", -"0:853a00de1b6b5bff13112794d00d8aba04f9484a6f4a4b13a3bc6c0ddf6989fb", -"0:871d8551bd6ec4aad0598ed786aefceb6ecda5899880254c9ebd1399676855df", -"0:873879b429a6462ea0cf51944774b6103be9ec1c7acb6849ab7d0f7985df0c53", -"0:8fa7da857b09b99185819ceed2e20978ff2f8d3ee19973be59849d93f1cae42b", -"0:a94e11bd39f607a7bef279a512ffde668473d582abdeac83b9d1138dcacc1602", -"0:ac2e90de1c1daaa516e6b026ffd319ac615371d4d81e62bbc7193d530eb1e40e", -"0:9343c90fc325fddabe3c80220bfe92cdfd17104fd8216728279834d890e92e5b", -"0:93ac54521edfad7e4ed6c4af591d09aa2dc8315f14caef019f0846ea818d96f4", -"0:afdbccb8f4675a2e7728725bf421274394c518fdcc433c63561423d3f2de06ba", -"0:952fe93a75e0d1e7a67ca5c6f406d8349467da8af3867dd0c20f5befc91b322f", -"0:fab767570e36711750eaba7285fbc7445a2bc9765898ff41588825e7b61baa9c", -"0:c4f7c5cdcd788fabb5676c9276338f87b77b57fce591d315134e70c2f0d39b2e", -"0:df7910c4d530e1c2de3bf020d1d10ecc0f0a9c4d485f8eac934f9f6682801a17", -"0:e28dc13250a6be42009b786960810935b81b6dd99447c96e18e2007847a30de9", -"0:ceb453ade35b246e3064645f3da185e9a031028e5c48cc3f9285600e632ceec6", -"0:f01aee2f16fd5edf09fc9a29ff8b2ece3c95de80e613150e5b6456796b964f88", -"0:b81b6a61e804bf983ffe708bf8688626d73e63020096fd34c312bef6ca05ce3f"}; - -// utils -std::string get_address_state(tonlib_api::object_ptr& state) { - if (state->code_.empty()) { - if (state->frozen_hash_.empty()) { - return "uninitialized"; - } else { - return "frozen"; - } - } - return "active"; -} - -// utils -template -auto tl_to_json(const T& value) { - return userver::formats::json::FromString(td::json_encode(td::ToJson(value))); -} - -inline td::Result get_hash(const std::string& data) { - if (data.empty()) { - return td::Status::Error("Empty data"); - } - auto res = vm::std_boc_deserialize(data); - if (res.is_error()) { return res.move_as_error(); } - return td::base64_encode(res.move_as_ok()->get_hash().as_slice()); -} - -inline std::string get_hash_no_error(const std::string& data) { - return get_hash(data).move_as_ok(); -} - - -// wallet data parsers -namespace wallets { -const std::string wallet_v1_r1 = "te6cckEBAQEARAAAhP8AIN2k8mCBAgDXGCDXCx/tRNDTH9P/0VESuvKhIvkBVBBE+RDyovgAAdMfMSDXSpbTB9QC+wDe0aTIyx/L/8ntVEH98Ik="; -const std::string wallet_v1_r2 = "te6cckEBAQEAUwAAov8AIN0gggFMl7qXMO1E0NcLH+Ck8mCBAgDXGCDXCx/tRNDTH9P/0VESuvKhIvkBVBBE+RDyovgAAdMfMSDXSpbTB9QC+wDe0aTIyx/L/8ntVNDieG8="; -const std::string wallet_v1_r3 = "te6cckEBAQEAXwAAuv8AIN0gggFMl7ohggEznLqxnHGw7UTQ0x/XC//jBOCk8mCBAgDXGCDXCx/tRNDTH9P/0VESuvKhIvkBVBBE+RDyovgAAdMfMSDXSpbTB9QC+wDe0aTIyx/L/8ntVLW4bkI="; -const std::string wallet_v2_r1 = "te6cckEBAQEAVwAAqv8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x8B+CO78mPtRNDTH9P/0VExuvKhA/kBVBBC+RDyovgAApMg10qW0wfUAvsA6NGkyMsfy//J7VShNwu2"; -const std::string wallet_v2_r2 = "te6cckEBAQEAYwAAwv8AIN0gggFMl7ohggEznLqxnHGw7UTQ0x/XC//jBOCk8mCDCNcYINMf0x8B+CO78mPtRNDTH9P/0VExuvKhA/kBVBBC+RDyovgAApMg10qW0wfUAvsA6NGkyMsfy//J7VQETNeh"; -const std::string wallet_v3_r1 = "te6cckEBAQEAYgAAwP8AIN0gggFMl7qXMO1E0NcLH+Ck8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVD++buA="; -const std::string wallet_v3_r2 = "te6cckEBAQEAcQAA3v8AIN0gggFMl7ohggEznLqxn3Gw7UTQ0x/THzHXC//jBOCk8mCDCNcYINMf0x/TH/gjE7vyY+1E0NMf0x/T/9FRMrryoVFEuvKiBPkBVBBV+RDyo/gAkyDXSpbTB9QC+wDo0QGkyMsfyx/L/8ntVBC9ba0="; -const std::string wallet_v4_r1 = "te6cckECFQEAAvUAART/APSkE/S88sgLAQIBIAIDAgFIBAUE+PKDCNcYINMf0x/THwL4I7vyY+1E0NMf0x/T//QE0VFDuvKhUVG68qIF+QFUEGT5EPKj+AAkpMjLH1JAyx9SMMv/UhD0AMntVPgPAdMHIcAAn2xRkyDXSpbTB9QC+wDoMOAhwAHjACHAAuMAAcADkTDjDQOkyMsfEssfy/8REhMUA+7QAdDTAwFxsJFb4CHXScEgkVvgAdMfIYIQcGx1Z70ighBibG5jvbAighBkc3RyvbCSXwPgAvpAMCD6RAHIygfL/8nQ7UTQgQFA1yH0BDBcgQEI9ApvoTGzkl8F4ATTP8glghBwbHVnupEx4w0kghBibG5juuMABAYHCAIBIAkKAFAB+gD0BDCCEHBsdWeDHrFwgBhQBcsFJ88WUAP6AvQAEstpyx9SEMs/AFL4J28ighBibG5jgx6xcIAYUAXLBSfPFiT6AhTLahPLH1Iwyz8B+gL0AACSghBkc3Ryuo41BIEBCPRZMO1E0IEBQNcgyAHPFvQAye1UghBkc3Rygx6xcIAYUATLBVjPFiL6AhLLassfyz+UEDRfBOLJgED7AAIBIAsMAFm9JCtvaiaECAoGuQ+gIYRw1AgIR6STfSmRDOaQPp/5g3gSgBt4EBSJhxWfMYQCAVgNDgARuMl+1E0NcLH4AD2ynftRNCBAUDXIfQEMALIygfL/8nQAYEBCPQKb6ExgAgEgDxAAGa3OdqJoQCBrkOuF/8AAGa8d9qJoQBBrkOuFj8AAbtIH+gDU1CL5AAXIygcVy//J0Hd0gBjIywXLAiLPFlAF+gIUy2sSzMzJcfsAyEAUgQEI9FHypwIAbIEBCNcYyFQgJYEBCPRR8qeCEG5vdGVwdIAYyMsFywJQBM8WghAF9eEA+gITy2oSyx/JcfsAAgBygQEI1xgwUgKBAQj0WfKn+CWCEGRzdHJwdIAYyMsFywJQBc8WghAF9eEA+gIUy2oTyx8Syz/Jc/sAAAr0AMntVEap808="; -const std::string wallet_v4_r2 = "te6cckECFAEAAtQAART/APSkE/S88sgLAQIBIAIDAgFIBAUE+PKDCNcYINMf0x/THwL4I7vyZO1E0NMf0x/T//QE0VFDuvKhUVG68qIF+QFUEGT5EPKj+AAkpMjLH1JAyx9SMMv/UhD0AMntVPgPAdMHIcAAn2xRkyDXSpbTB9QC+wDoMOAhwAHjACHAAuMAAcADkTDjDQOkyMsfEssfy/8QERITAubQAdDTAyFxsJJfBOAi10nBIJJfBOAC0x8hghBwbHVnvSKCEGRzdHK9sJJfBeAD+kAwIPpEAcjKB8v/ydDtRNCBAUDXIfQEMFyBAQj0Cm+hMbOSXwfgBdM/yCWCEHBsdWe6kjgw4w0DghBkc3RyupJfBuMNBgcCASAICQB4AfoA9AQw+CdvIjBQCqEhvvLgUIIQcGx1Z4MesXCAGFAEywUmzxZY+gIZ9ADLaRfLH1Jgyz8gyYBA+wAGAIpQBIEBCPRZMO1E0IEBQNcgyAHPFvQAye1UAXKwjiOCEGRzdHKDHrFwgBhQBcsFUAPPFiP6AhPLassfyz/JgED7AJJfA+ICASAKCwBZvSQrb2omhAgKBrkPoCGEcNQICEekk30pkQzmkD6f+YN4EoAbeBAUiYcVnzGEAgFYDA0AEbjJftRNDXCx+AA9sp37UTQgQFA1yH0BDACyMoHy//J0AGBAQj0Cm+hMYAIBIA4PABmtznaiaEAga5Drhf/AABmvHfaiaEAQa5DrhY/AAG7SB/oA1NQi+QAFyMoHFcv/ydB3dIAYyMsFywIizxZQBfoCFMtrEszMyXP7AMhAFIEBCPRR8qcCAHCBAQjXGPoA0z/IVCBHgQEI9FHyp4IQbm90ZXB0gBjIywXLAlAGzxZQBPoCFMtqEssfyz/Jc/sAAgBsgQEI1xj6ANM/MFIkgQEI9Fnyp4IQZHN0cnB0gBjIywXLAlAFzxZQA/oCE8tqyx8Syz/Jc/sAAAr0AMntVGliJeU="; -const std::string wallet_v5_r1 = "te6cckECFAEAAoEAART/APSkE/S88sgLAQIBIAIDAgFIBAUBAvIOAtzQINdJwSCRW49jINcLHyCCEGV4dG69IYIQc2ludL2wkl8D4IIQZXh0brqOtIAg1yEB0HTXIfpAMPpE+Cj6RDBYvZFb4O1E0IEBQdch9AWDB/QOb6ExkTDhgEDXIXB/2zzgMSDXSYECgLmRMOBw4hAPAgEgBgcCASAICQAZvl8PaiaECAoOuQ+gLAIBbgoLAgFIDA0AGa3OdqJoQCDrkOuF/8AAGa8d9qJoQBDrkOuFj8AAF7Ml+1E0HHXIdcLH4AARsmL7UTQ1woAgAR4g1wsfghBzaWduuvLgin8PAeaO8O2i7fshgwjXIgKDCNcjIIAg1yHTH9Mf0x/tRNDSANMfINMf0//XCgAK+QFAzPkQmiiUXwrbMeHywIffArNQB7Dy0IRRJbry4IVQNrry4Ib4I7vy0IgikvgA3gGkf8jKAMsfAc8Wye1UIJL4D95w2zzYEAP27aLt+wL0BCFukmwhjkwCIdc5MHCUIccAs44tAdcoIHYeQ2wg10nACPLgkyDXSsAC8uCTINcdBscSwgBSMLDy0InXTNc5MAGk6GwShAe78uCT10rAAPLgk+1V4tIAAcAAkVvg69csCBQgkXCWAdcsCBwS4lIQseMPINdKERITAJYB+kAB+kT4KPpEMFi68uCR7UTQgQFB1xj0BQSdf8jKAEAEgwf0U/Lgi44UA4MH9Fvy4Iwi1woAIW4Bs7Dy0JDiyFADzxYS9ADJ7VQAcjDXLAgkji0h8uCS0gDtRNDSAFETuvLQj1RQMJExnAGBAUDXIdcKAPLgjuLIygBYzxbJ7VST8sCN4gAQk1vbMeHXTNCon9ZI"; -const std::string nominator_pool_v1 = "te6cckECOgEACcIAART/APSkE/S88sgLAQIBYgIDAgLOBAUCASATFAIBIAYHAGVCHXSasCcFIDqgCOI6oDA/ABFKACpFMBuo4TI9dKwAGcWwHUMNAg10mrAhJw3t4C5GwhgEfz4J28QAtDTA/pAMCD6RANxsI8iMTMzINdJwj+PFIAg1yHTHzCCEE5zdEu6Ats8sOMAkl8D4uAD0x/bPFYSwACAhCB8JAE80wcBptAgwv/y4UkgwQrcpvkgwv/y4UkgwRDcpuAgwv8hwRCw8uFJgAzDbPFYQwAGTcFcR3hBMEDtKmNs8CFUz2zwfDBIELOMPVUDbPBBcEEsQOkl4EFYQRRA0QDMKCwwNA6JXEhEQ0wchwHkiwG6xIsBkI8B3sSGx8uBAILOeIdFWFsAA8r1WFS698r7eIsBk4wAiwHeSVxfjDREWjhMwBBEVBAMRFAMCERMCVxFXEV8D4w0ODxADNBER0z9WFlYW2zzjDwsREAsQvxC+EL0QvBCrISIjACjIgQEAECbPARPLD8sPAfoCAfoCyQEE2zwSAtiBAQBWFlKi9A5voSCzlRESpBES3lYSLrvy4EGCEDuaygABERsBoSDCAPLgQhEajoLbPJMwcCDiVhPAAJQBVhqglFYaoAHiUwGgLL7y4EMq12V1VhS2A6oAtgm58uBEAds8gQEAElYXQLv0QwgvJQOkVhHAAI8hVhUEEDkQKAERGAEREds8AVYYoYISVAvkAL6OhFYT2zzejqNXF4EBAFYVUpL0Dm+hMfLgRciBAQASVhZAmfRDVhPbPE8HAuJPH1B3BikwMAL+VhTA/1YULbqws46dERTAAPLgeYEBAFYTUnL0Dm+h8uB62zwwwgDy4HuSVxTiERSAIPACAdERE8B5VhNWEYMH9A5voSCzjhmCEDuaygBWE9dllYAPeqmE5AERGAG+8uB7klcX4lYWlfQE0x8wlDBt+CPiVhQigwf0Dm+hMfLQfC8RAWz4IwPIygATyx8CERQBgwf0Q8j0AAEREgHLHwIBERIBD4MH9EMREo6DDds8kT3iDBEQDBC/ELwwAEoMyMsHG8sPUAn6AlAH+gIVzBP0APQAyx/L/8sHyx/LH/QAye1UAgEgFRYCASAZGgEJu/Gds8gfAgFiFxgBda877Z4riC+HtqzBg/oHN9D5cEL6Ahg/xw/AgIApEHo+N9KQT4FpAGmPmBEst4GoAjeBAciZcQDZ8y3AHwEJrIttnkAzAgFuGxwBXbvQXbPFcQXw9tf44fIoMH9HxvpSCOEAL0BDHTHzBSEG8CUANvAgKRMuIBs+YwMYHwIBIB0eAReuPu2eCDevh5i3WcAfAnaqOds8XwZQml8JbX+OqYEBAFIw9HxvpSCOmALbPIEBAFRjgPQOb6ExI1UgbwRQA28CApEy4gGz5hNfAx8vAkSrWds8XwZQml8JgQEAI1n0Dm+h8uBW2zyBAQBEMPQOb6ExHy8BVO1E0NMH0w/6APoA1AHQ2zwF9AT0BNMf0//TB9Mf0x/0BDAQvBCrEJoQiSAAHIEBANcB0w/TD/oA+gAwAB4BwP9x+DPQgQEA1wNYurAB6FtXElcSVxJXEvgAghD5b3MkUuC6jrk7ERFwCaFTgMEBmlCIoCDBAJI3J96OFjBTBaiBJxCpBFMBvJIwIN5RiKAIoQfiUHfbPCcKEREKCAqSVxLiKsABjhmCEO5vRUxS0LqScDveghDzdEhMHbqScjrekTziJAS4VhPCAFYUwQiwghBHZXQkVhUBurGCEE5zdEtWFQG6sfLgRlYTwAEwVhPAAo8k0wcQORAoVhgCARESAds8VhmhghJUC+QAvo6EVhTbPN4REEhw3lYTwAPjAFYTwAYmMCcoA7pwf46YgQEAUjD0fG+lII6HAts8MBOgApEy4gGz5jBtf483gQEAUkD0fG+lII8mAts8JcIAn1R3FamEEqAgwQCSMHDeAd6gcNs8gQEAVBIBUFX0QwKRMuIBs+YUXwQvLyUADshY+gIB+gIBcnB/IY6wgQEAVCJw9HxvpTIhjpwyVEETSHBSZts8Uhe6BaRTBL6SfzbeEDhHY0VQ3gGzIrES5l8EASkCaIEBANcBgQEAVGKg9A5voTHy4EdJMBhWGAEREts8AVYZoYISVAvkAL6OhFYU2zzeERBIcBIpMATWjyAkwQPy4HHbPGwh+QBTYL2ZNDUDpEQT+CMDkTDiVhTbPN5WE8AHjrf4I3+OLFYUgwf0fG+lII4cAvQEMdMfMFIwoYIIJ40AvJogERaDB/RbMBEV3pEy4gGz5ltWFNs83oIQR2V0JFYUAbo0MDAqA7KBAQBUZVD0Dm+h8rzbPKCCElQL5ABSMKFSELyTMGwU4IEBAFRGZvRbMIEBAFRGVfRbMAGlUSShghA7msoAUlC+jxFwUAbbPG2AEBAjECZw2zwQI5I0NOJDMC85OATgjzAkwgHy4G8kwgL4IyWhJKY8vLHy4HCCEEdldCTIyx9SIMs/yds8cIAYgEAQNBAj2zzeVhPABI4jVhbA/1YWL7qw8uBJghA7msoAAREZAaEgwgDy4EpR7qAOERjeVhPABZJXFOMNghBOc3RLVhMBujc4KywEqFYRwADy4EpWFsD/VhYvurDy4Ev6ACHCAPLgTinbPIISVAvkAFYaAaEBoVIgu/LgTFHxoSDBAJIwcN5/L9s8bYAQJFlw2zxWGFihVhmhghJUC+QAvi05OC4BTo4XMAURFgUEERUEAxEUAwIREwJXEVcRXwTjDQ8REA8Q7xDeEM0QvDEBPnB/jpiBAQBSMPR8b6UgjocC2zygE6ACkTLiAbPmMDEvARyOhBEU2zySVxTiDRETDTAACvoA+gAwARRwbYAQgEByoNs8OATWPl8FD8D/Uea6HrDy4E4IwADy4E8l8uBQghA7msoAH77y4FYJ+gAg2zyCEDuaygBSMKGCGHRqUogAUkC+8uBRghJUC+QAAREQAaFSMLvy4FJTX77y4FMu2zxSYL7y4FQtbvLgVXHbPDH5AHAyMzQ1ABzT/zHTH9MfMdP/MdQx0QCEgCj4MyBumFuCGBeEEbIA4NDTBzH6ANMf0w/TD9MPMdMPMdMP0w8wUFOoqwdQM6irB1AjqKsHWairB1IgqbQfoLYIACaAIvgzINDTBwHAEvKJ0x/THzBYA1zbPNs8ERDIyx8cyz9QBs8WyYAYcQQREAQQONs8DhEQDh8QPhAtELwQe1CZB0MTNjc4ACKAD/gz0NMfMdMfMdMfMdcLHwEacfgz0IEBANcDfwHbPDkASCJusyCRcZFw4gPIywVQBs8WUAT6AstqA5NYzAGRMOIByQH7AAAcdMjLAhLKB4EBAM8BydDKWCmU"; - -td::Result<> parse_wallet_seqno(userver::formats::json::ValueBuilder& builder, td::Ref& data) { - vm::CellSlice cs{vm::NoVm(), data}; - builder["seqno"] = cs.fetch_long(32); - return td::Status::OK(); -} - -td::Result<> parse_wallet_v3(userver::formats::json::ValueBuilder& builder, td::Ref& data) { - vm::CellSlice cs{vm::NoVm(), data}; - builder["seqno"] = cs.fetch_long(32); - builder["wallet_id"] = cs.fetch_long(32); - return td::Status::OK(); -} - -td::Result<> parse_wallet_v5(userver::formats::json::ValueBuilder& builder, td::Ref& data) { - vm::CellSlice cs{vm::NoVm(), data}; - bool is_signature_allowed = cs.fetch_long(1); - builder["seqno"] = cs.fetch_long(32); - builder["wallet_id"] = cs.fetch_long(32); - builder["is_signature_allowed"] = is_signature_allowed; - return td::Status::OK(); -} - -static const std::map(userver::formats::json::ValueBuilder&, td::Ref&)>>> wallet_data_parsers{ -{"oM/CxIruFqJx8s/AtzgtgXVs7LEBfQd/qqs7tgL2how=", {"wallet v1 r1", parse_wallet_seqno}}, -{"1JAvzJ+tdGmPqONTIgpo2g3PcuMryy657gQhfBfTBiw=", {"wallet v1 r2", parse_wallet_seqno}}, -{"WHzHie/xyE9G7DeX5F/ICaFP9a4k8eDHpqmcydyQYf8=", {"wallet v1 r3", parse_wallet_seqno}}, -{"XJpeaMEI4YchoHxC+ZVr+zmtd+xtYktgxXbsiO7mUyk=", {"wallet v2 r1", parse_wallet_seqno}}, -{"/pUw0yQ4Uwg+8u8LTCkIwKv2+hwx6iQ6rKpb+MfXU/E=", {"wallet v2 r2", parse_wallet_seqno}}, -{"thBBpYp5gLlG6PueGY48kE0keZ/6NldOpCUcQaVm9YE=", {"wallet v3 r1", parse_wallet_v3}}, -{"hNr6RJ+Ypph3ibojI1gHK8D3bcRSQAKl0JGLmnXS1Zk=", {"wallet v3 r2", parse_wallet_v3}}, -{"ZN1UgFUixb6KnbWc6gEFzPDQh4bKeb64y3nogKjXMi0=", {"wallet v4 r1", parse_wallet_v3}}, -{"/rX/aCDi/w2Ug+fg1iyBfYRniftK5YDIeIZtlZ2r1cA=", {"wallet v4 r2", parse_wallet_v3}}, -{"89fKU0k97trCizgZhqhJQDy6w9LFhHea8IEGWvCsS5M=", {"wallet v5 beta", parse_wallet_v5}}, -{"IINLe3KxEhR+Gy+0V7hOdNGjDwT3N9T2KmaOlVLSty8=", {"wallet v5 v1", parse_wallet_v5}}, -}; -} - - -TonlibWorkerResponse TonlibPostProcessor::process_getAddressInformation( - const std::string& address, - td::Result&& res, - multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - auto result = res.move_as_ok(); - ValueBuilder builder(FromString(td::json_encode(td::ToJson(result)))); - builder["state"] = get_address_state(result); - if (result->balance_ < 0) { - builder["balance"] = "0"; - } - { - auto r_std_address = block::StdAddress::parse(address); - if (r_std_address.is_error()) { - return TonlibWorkerResponse::from_error_string(r_std_address.move_as_error().to_string(), 503, std::move(session)); - } - auto std_address = r_std_address.move_as_ok(); - DetectAddressResult address_detect{std_address, "unknown"}; - std::string raw_address = address_detect.to_raw_form(true); - if (result->sync_utime_ < 1803189600 && suspended_accounts.contains(raw_address)) { - builder["suspended"] = true; - } - } - return TonlibWorkerResponse{true, nullptr, ToString(builder.ExtractValue()), std::nullopt, std::move(session)}; -} -TonlibWorkerResponse TonlibPostProcessor::process_getWalletInformation( - const std::string& address, - td::Result&& res, - multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - auto result = res.move_as_ok(); - ValueBuilder builder; - builder["wallet"] = false; - builder["balance"] = std::to_string(result->balance_ < 0 ? 0 : result->balance_); - builder["account_state"] = get_address_state(result); - if (result->last_transaction_id_) { - builder["last_transaction_id"] = tl_to_json(result->last_transaction_id_); - } - if (!result->code_.empty()) { - auto code_hash_res = get_hash(result->code_); - if (code_hash_res.is_ok()) { - auto code_hash = code_hash_res.move_as_ok(); - auto parser_ = wallets::wallet_data_parsers.find(code_hash); - if (parser_ != wallets::wallet_data_parsers.end()) { - builder["wallet"] = true; - auto data_cell = vm::std_boc_deserialize(result->data_); - if (data_cell.is_error()) { - return TonlibWorkerResponse::from_error_string(data_cell.move_as_error().to_string(), 503, std::move(session)); - } - auto data = data_cell.move_as_ok(); - builder["wallet_type"] = parser_->second.first; - auto parse_result = parser_->second.second(builder, data); - if (parse_result.is_error()) { - return TonlibWorkerResponse::from_error_string(parse_result.move_as_error().to_string(), 503, std::move(session)); - } - } - } - } - return TonlibWorkerResponse{true, nullptr, ToString(builder.ExtractValue()), std::nullopt, std::move(session)}; -} -TonlibWorkerResponse TonlibPostProcessor::process_getAddressBalance( - const std::string& address, - td::Result&& res, - multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - auto result = res.move_as_ok(); - auto balance = std::to_string(result->balance_ < 0 ? 0 : result->balance_); - return TonlibWorkerResponse{true, nullptr, "\"" +balance + "\"", std::nullopt, std::move(session)}; -} -TonlibWorkerResponse TonlibPostProcessor::process_getAddressState( - const std::string& address, - td::Result&& res, - multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - auto result = res.move_as_ok(); - auto state = get_address_state(result); - return TonlibWorkerResponse{true, nullptr, "\"" + state + "\"", std::nullopt, std::move(session)}; -} -TonlibWorkerResponse TonlibPostProcessor::process_getBlockTransactions( - td::Result&& res, multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - auto result = res.move_as_ok(); - auto workchain_str = std::to_string(result->id_->workchain_); - - ValueBuilder builder(FromString(td::json_encode(td::ToJson(result)))); - for (size_t i = 0; i < result->transactions_.size(); ++i) { - builder["transactions"][i]["account"] = workchain_str + ":" + td::hex_encode(result->transactions_[i]->account_); - } - return TonlibWorkerResponse{true, nullptr, ToString(builder.ExtractValue()), std::nullopt, std::move(session)}; -} -TonlibWorkerResponse TonlibPostProcessor::process_getBlockTransactionsExt( - td::Result&& res, multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - - auto result = res.move_as_ok(); - auto workchain_str = std::to_string(result->id_->workchain_); - - ValueBuilder builder(FromString(td::json_encode(td::ToJson(result)))); - for (size_t i = 0; i < result->transactions_.size(); ++i) { - auto r_std_address = block::StdAddress::parse(result->transactions_[i]->address_->account_address_); - if (r_std_address.is_ok()) { - const auto std_address = r_std_address.move_as_ok(); - builder["transactions"][i]["account"] = - std::to_string(std_address.workchain) + ":" + td::hex_encode(std_address.addr.as_slice().str()); - } - } - return TonlibWorkerResponse{true, nullptr, ToString(builder.ExtractValue()), std::nullopt, std::move(session)}; -} - -TonlibWorkerResponse TonlibPostProcessor::process_getTransactions( - td::Result&& res, - bool v2_schema, - bool unwrap_single_transaction, - multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_tonlib_result(std::move(res), std::move(session)); - } - auto result = res.move_as_ok(); - - ValueBuilder builder(FromString(td::json_encode(td::ToJson(result)))); - - for (size_t i = 0; i < result->transactions_.size(); ++i) { - auto& tx = result->transactions_[i]; - auto& in_msg = tx->in_msg_; - if (in_msg) { - auto local_builder = builder["transactions"][i]["in_msg"]; - process_rawMessage(in_msg, local_builder); - } - for (size_t j = 0; j < tx->out_msgs_.size(); ++j) { - auto local_builder = builder["transactions"][i]["out_msgs"][j]; - process_rawMessage(tx->out_msgs_[j], local_builder); - } - } - - if (v2_schema) { - return TonlibWorkerResponse{true, nullptr, ToString(builder.ExtractValue()), std::nullopt, std::move(session)}; - } - if (unwrap_single_transaction && result->transactions_.size() == 1) { - return TonlibWorkerResponse{ - true, nullptr, ToString(builder.ExtractValue()["transactions"][0]), std::nullopt, std::move(session) - }; - } - return TonlibWorkerResponse{ - true, nullptr, ToString(builder.ExtractValue()["transactions"]), std::nullopt, std::move(session) - }; -} -TonlibWorkerResponse TonlibPostProcessor::process_runGetMethod( - td::Result&& res, multiclient::SessionPtr&& session -) const { - using namespace userver::formats::json; - if (res.is_error()) { - return TonlibWorkerResponse::from_error_string(res.move_as_error().to_string(), 503, std::move(session)); - } - auto result = res.move_as_ok(); - - ValueBuilder builder(FromString(result.to_json_string())); - builder["stack"] = utils::serialize_tvm_stack(result.result->stack_); - auto ress = ToString(builder.ExtractValue()); - return TonlibWorkerResponse{true, nullptr, ress, std::nullopt, std::move(session)}; -} -void TonlibPostProcessor::process_rawMessage( - const tonlib_api::object_ptr& msg, userver::formats::json::ValueBuilder& builder -) const { - builder["source"] = msg->source_->account_address_; - builder["destination"] = msg->destination_->account_address_; - - auto success = tonlib_api::downcast_call( - *msg->msg_data_, - td::overloaded( - [&](tonlib_api::msg_dataRaw& data) { - auto r_body = vm::std_boc_deserialize(data.body_); - if (r_body.is_ok()) { - auto body = r_body.move_as_ok(); - vm::CellSlice cs = vm::load_cell_slice(body); - auto r_body = td::hex_decode(cs.as_bitslice().to_hex()); - if (r_body.is_ok()) { - builder["message"] = td::base64_encode(r_body.move_as_ok()); - } else { - builder["message_decode_error"] = r_body.move_as_error_suffix("failed to decode msg body hex: ").to_string(); - } - } else { - builder["message_decode_error"] = "Failed to load cell or get body slice. But why?"; - LOG(ERROR) << "Failed to load cell or get body slice. But why? msg_hash: " << msg->hash_; - } - }, - [&](tonlib_api::msg_dataText& data) { builder["message"] = data.text_; }, - [&](tonlib_api::msg_dataDecryptedText& data) { builder["message"] = data.text_; }, - [&](tonlib_api::msg_dataEncryptedText& data) { builder["message"] = data.text_; }, - [&](auto& x) { LOG(DEBUG) << "failed to decode type " << x.get_id(); } - ) - ); - if (!success) { - LOG(ERROR) << "error in downcast_call"; - } -} -} // namespace ton_http::core diff --git a/ton-http-api/tonlib_postprocessor.h b/ton-http-api/tonlib_postprocessor.h deleted file mode 100644 index a1a9c38..0000000 --- a/ton-http-api/tonlib_postprocessor.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include "tonlib_worker.h" -#include "userver/formats/json.hpp" - -namespace ton_http::core { -class TonlibPostProcessor { -public: - TonlibWorkerResponse process_getAddressInformation(const std::string& address, td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_getWalletInformation(const std::string& address, td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_getAddressBalance(const std::string& address, td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_getAddressState(const std::string& address, td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_getBlockTransactions(td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_getBlockTransactionsExt(td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_getTransactions(td::Result&& res, bool v2_schema = true, bool unwrap_single_transaction = false, multiclient::SessionPtr&& session = nullptr) const; - TonlibWorkerResponse process_runGetMethod(td::Result&& res, multiclient::SessionPtr&& session = nullptr) const; -private: - void process_rawMessage(const tonlib_api::object_ptr& msg, userver::formats::json::ValueBuilder& builder) const; -}; -} diff --git a/ton-http-api/tonlib_worker.h b/ton-http-api/tonlib_worker.h deleted file mode 100644 index 33e8930..0000000 --- a/ton-http-api/tonlib_worker.h +++ /dev/null @@ -1,370 +0,0 @@ -#pragma once -#include "auto/tl/tonlib_api.h" -#include "auto/tl/tonlib_api_json.h" -#include "td/utils/JsonBuilder.h" -#include "tl/tl_json.h" -#include "tonlib-multiclient/multi_client.h" -#include "tonlib-multiclient/request.h" -#include "userver/engine/future.hpp" -#include "utils.hpp" - -namespace ton_http::core { -// new schemas -struct DetectAddressResult { - block::StdAddress address; - std::string given_type; - - [[nodiscard]] std::string to_json_string() const; - [[nodiscard]] std::string to_raw_form(bool lower=false) const; -}; - -struct DetectHashResult { - std::string hash; - [[nodiscard]] std::string to_json_string() const; -}; - -struct ConsensusBlockResult { - std::int32_t seqno; - std::time_t timestamp; - [[nodiscard]] std::string to_json_string() const; -}; - -struct RunGetMethodResult { - tonlib_api::smc_runGetMethod::ReturnType result; - tonlib_api::smc_getRawFullAccountState::ReturnType state; - - [[nodiscard]] std::string to_json_string() const; -}; - -struct TokenDataResult { - explicit TokenDataResult(const std::string& address) : address_(address) {} - virtual ~TokenDataResult() = default; - std::string address_; - [[nodiscard]] virtual std::string to_json_string() const; -}; -using TokenDataResultPtr = std::unique_ptr; - -struct JettonMasterDataResult: public TokenDataResult { - std::string total_supply_; - bool mintable_; - std::string admin_address_; - bool jetton_content_onchain_; - std::map jetton_content_; - std::string jetton_wallet_code_; - explicit JettonMasterDataResult(const std::string& address) : TokenDataResult(address) {} - [[nodiscard]] std::string to_json_string() const override; -}; - -struct JettonWalletDataResult: public TokenDataResult { - std::string balance_; - std::string owner_address_; - std::string jetton_master_address_; - std::optional mintless_is_claimed_; - std::string jetton_wallet_code_; - bool is_validated_; - - explicit JettonWalletDataResult(const std::string& address) : TokenDataResult(address) {} - [[nodiscard]] std::string to_json_string() const override; -}; - -struct NFTCollectionDataResult : public TokenDataResult { - std::string next_item_index_; - std::string owner_address_; - bool collection_content_onchain_; - std::map collection_content_; - - explicit NFTCollectionDataResult(const std::string& address) : TokenDataResult(address) {} - [[nodiscard]] std::string to_json_string() const override; -}; - -struct NFTItemDataResult : public TokenDataResult { - bool init_; - std::string index_; - std::string collection_address_; - std::string owner_address_; - bool content_onchain_; - std::map content_; - bool is_validated_; - std::map dns_content_; - std::string domain_; - bool is_dns_{false}; - - explicit NFTItemDataResult(const std::string& address) : TokenDataResult(address) {} - [[nodiscard]] std::string to_json_string() const override; -}; - -// TonlibWorker -struct TonlibWorkerResponse { - bool is_ok{false}; - tonlib_api::object_ptr result{nullptr}; - std::optional result_str{std::nullopt}; - std::optional error{std::nullopt}; - multiclient::SessionPtr session{nullptr}; - int cache_ttl{0}; - - template - static TonlibWorkerResponse from_tonlib_result(td::Result&& result, multiclient::SessionPtr&& session = nullptr) { - if (result.is_error()) { - return {false, nullptr, std::nullopt, result.move_as_error(), std::move(session)}; - } - if constexpr(std::is_same::value) { - return {true, nullptr, result.move_as_ok(), std::nullopt, std::move(session)}; - } else { - return {true, result.move_as_ok(), std::nullopt, std::nullopt, std::move(session)}; - } - } - static TonlibWorkerResponse from_result_string(const std::string& result, multiclient::SessionPtr&& session = nullptr) { - return {true, nullptr, result, std::nullopt, std::move(session)}; - } - static TonlibWorkerResponse from_error_string(const std::string& error, const int code = 0, multiclient::SessionPtr&& session = nullptr) { - return {false, nullptr, std::nullopt, td::Status::Error(code, error), std::move(session)}; - } - TonlibWorkerResponse Cachable(int ttl = 1) { - cache_ttl = ttl; - return std::move(*this); - } -}; - -class TonlibWorker { -public: - explicit TonlibWorker(const multiclient::MultiClientConfig& config) : tonlib_(config) {}; - ~TonlibWorker() = default; - - template - using Result = std::pair, multiclient::SessionPtr>; - - Result getConsensusBlock(multiclient::SessionPtr session = nullptr) const; - Result detectAddress(const std::string& address, multiclient::SessionPtr session = nullptr) const; - Result packAddress(const std::string& address, multiclient::SessionPtr session = nullptr) const; - Result unpackAddress(const std::string& address, multiclient::SessionPtr session = nullptr) const; - Result detectHash(const std::string& hash, multiclient::SessionPtr session = nullptr) const; - Result getTokenData( - const std::string& address, - bool skip_verification = false, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - Result - getMasterchainInfo(multiclient::SessionPtr session = nullptr) const; - Result - getMasterchainBlockSignatures(ton::BlockSeqno seqno, multiclient::SessionPtr session = nullptr) const; - Result - getAddressInformation(std::string address, std::optional seqno = std::nullopt, multiclient::SessionPtr session = nullptr) const; - Result - getExtendedAddressInformation(std::string address, std::optional seqno = std::nullopt, multiclient::SessionPtr session = nullptr) const; - Result lookupBlock(const ton::WorkchainId& workchain, - const ton::ShardId& shard, const std::optional& seqno = std::nullopt, - const std::optional& lt = std::nullopt, - const std::optional& unixtime = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result getShardBlockProof(const ton::WorkchainId& workchain, - const ton::ShardId& shard, - const ton::BlockSeqno& seqno, - const std::optional& from_seqno = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result getShards(std::optional mc_seqno = std::nullopt, - std::optional lt = std::nullopt, - std::optional unixtime = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result getBlockHeader( - const ton::WorkchainId& workchain, - const ton::ShardId& shard, - const ton::BlockSeqno& seqno, - const std::string& root_hash = "", - const std::string& file_hash = "", - multiclient::SessionPtr session = nullptr - ) const; - Result getOutMsgQueueSizes(multiclient::SessionPtr session = nullptr) const; - - Result getConfigParam(const std::int32_t& param, - std::optional seqno = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result getConfigAll(std::optional seqno = std::nullopt, multiclient::SessionPtr session = nullptr) const; - Result getLibraries( - std::vector libs, - multiclient::SessionPtr session = nullptr) const; - - Result raw_getBlockTransactions(const tonlib_api::object_ptr& blk_id, - size_t count, - tonlib_api::object_ptr&& after = nullptr, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result raw_getBlockTransactionsExt(const tonlib_api::object_ptr& blk_id, - size_t count, - tonlib_api::object_ptr&& after = nullptr, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result raw_getTransactions( - const std::string& account_address, - const ton::LogicalTime& from_transaction_lt, - const std::string& from_transaction_hash, - const std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - Result raw_getTransactionsV2( - const std::string& account_address, - const ton::LogicalTime& from_transaction_lt, - const std::string& from_transaction_hash, - const size_t count, - const bool try_decode_messages, - const std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr) const; - - Result getBlockTransactions( - const ton::WorkchainId& workchain, - const ton::ShardId& shard, - const ton::BlockSeqno& seqno, - const size_t count = 40, - const std::string& root_hash = "", - const std::string& file_hash = "", - const std::optional& after_lt = std::nullopt, - const std::string& after_hash = "", - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - Result getBlockTransactionsExt( - const ton::WorkchainId& workchain, - const ton::ShardId& shard, - const ton::BlockSeqno& seqno, - const size_t count = 40, - const std::string& root_hash = "", - const std::string& file_hash = "", - const std::optional& after_lt = std::nullopt, - const std::string& after_hash = "", - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - Result getTransactions( - const std::string& account_address, - std::optional from_transaction_lt, - std::string from_transaction_hash, - ton::LogicalTime to_transaction_lt = 0, - size_t count = 10, - size_t chunk_size = 30, - bool try_decode_messages = true, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - Result tryLocateTransactionByIncomingMessage( - const std::string& source, - const std::string& destination, - ton::LogicalTime created_lt, - multiclient::SessionPtr session = nullptr) const; - Result tryLocateTransactionByOutgoingMessage( - const std::string& source, - const std::string& destination, - ton::LogicalTime created_lt, - multiclient::SessionPtr session = nullptr) const; - - Result raw_sendMessage( - const std::string& boc, - multiclient::SessionPtr session = nullptr) const; - Result raw_sendMessageReturnHash( - const std::string& boc, - multiclient::SessionPtr session = nullptr) const; - - Result loadContract( - const std::string& address, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - Result forgetContract( - std::int64_t id, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - Result runGetMethod( - const std::string& address, - const std::string& method_name, - const std::vector& stack, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - Result queryEstimateFees( - const std::string& account_address, - const std::string& body, - const std::string& init_code = "", - const std::string& init_data = "", - bool ignore_chksig = true, - multiclient::SessionPtr session = nullptr - ) const; - -private: - multiclient::MultiClient tonlib_; - - Result checkJettonMaster( - const std::string& address, - bool skip_verification = false, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - Result checkJettonWallet( - const std::string& address, - bool skip_verification = false, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - Result checkNFTCollection( - const std::string& address, - bool skip_verification = false, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - Result checkNFTItem( - const std::string& address, - bool skip_verification = false, - std::optional seqno = std::nullopt, - std::optional archival = std::nullopt, - multiclient::SessionPtr session = nullptr - ) const; - - template - Result send_request_function(multiclient::RequestFunction&& request, bool retry_archival = false) const { - if (!request.session) { - auto r_session = tonlib_.get_session(request.parameters, std::move(request.session)); - if (r_session.is_error()) { - return std::make_pair(r_session.move_as_error(), request.session); - } - request.session = r_session.move_as_ok(); - } - - auto result = tonlib_.send_request_function(request); - if (!retry_archival || result.is_ok()) { - return std::make_pair(std::move(result), request.session); - } - auto error = result.move_as_error(); - - // retry request with archival - { - request.parameters.archival = true; - auto r_session = tonlib_.get_session(request.parameters, std::move(request.session)); - if (r_session.is_error()) { - return std::make_pair(r_session.move_as_error(), request.session); - } - request.session = r_session.move_as_ok(); - } - - result = tonlib_.send_request_function(request); - if (result.is_error()) { - auto error_archival = result.move_as_error(); - LOG(WARNING) << error_archival.code() << " " << error_archival.message(); - if (error_archival.code() == -3) { - return std::make_pair(std::move(error), request.session); - } - return std::make_pair(std::move(error_archival), request.session); - } - return std::make_pair(std::move(result), request.session); - } -}; -} diff --git a/tonlib-multiclient/session.h b/tonlib-multiclient/session.h index 23fb8b6..6e362f9 100644 --- a/tonlib-multiclient/session.h +++ b/tonlib-multiclient/session.h @@ -4,7 +4,9 @@ namespace multiclient { class Session { public: - Session() = default; + explicit Session() : active_workers_(0), start_time_(0) { + start_time_ = std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); + } explicit Session(std::vector&& active_workers) : active_workers_(std::move(active_workers)), start_time_(0) { start_time_ = std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); From 43b82456df2567fac81d740ea4c712be2422548c Mon Sep 17 00:00:00 2001 From: K-Dimentional Tree Date: Sun, 14 Sep 2025 23:01:04 +0300 Subject: [PATCH 02/10] Fixed dns structs --- ton-http-api/src/utils/common.cpp | 14 +++++++------- ton-http-api/src/utils/common.hpp | 30 ++---------------------------- 2 files changed, 9 insertions(+), 35 deletions(-) diff --git a/ton-http-api/src/utils/common.cpp b/ton-http-api/src/utils/common.cpp index 437f8f8..def6483 100644 --- a/ton-http-api/src/utils/common.cpp +++ b/ton-http-api/src/utils/common.cpp @@ -487,7 +487,7 @@ td::Result>> ton_http::utils } } -td::Result parse_dns_record(td::Ref cs) { +td::Result parse_dns_record(td::Ref cs) { auto tag = tokens::gen::t_DNSRecord.check_tag(*cs); switch (tag) { case tokens::gen::DNSRecord::dns_storage_address: { @@ -495,7 +495,7 @@ td::Result parse_dns_record(td::Ref c if (!tlb::csr_unpack(cs, record)) { return td::Status::Error("Failed to unpack dns_storage_address"); } - ton_http::utils::DnsRecordStorageAddress result; + ton_http::core::DnsRecordStorageAddress result; result.bag_id = record.bag_id.to_hex(); return result; } @@ -504,7 +504,7 @@ td::Result parse_dns_record(td::Ref c if (!tlb::csr_unpack(cs, record)) { return td::Status::Error("Failed to unpack dns_adnl_address"); } - ton_http::utils::DnsRecordAdnlAddress result; + ton_http::core::DnsRecordAdnlAddress result; result.adnl_addr = record.adnl_addr.to_hex(); return result; } @@ -513,7 +513,7 @@ td::Result parse_dns_record(td::Ref c if (!tlb::csr_unpack(cs, record)) { return td::Status::Error("Failed to unpack dns_next_resolver"); } - ton_http::utils::DnsRecordNextResolver result; + ton_http::core::DnsRecordNextResolver result; switch (tokens::gen::t_MsgAddressInt.check_tag(*record.resolver)) { case tokens::gen::MsgAddressInt::addr_std: { tokens::gen::MsgAddressInt::Record_addr_std addr_std; @@ -541,7 +541,7 @@ td::Result parse_dns_record(td::Ref c } block::StdAddress addr{addr_std.workchain_id, addr_std.address}; - ton_http::utils::DnsRecordSmcAddress result; + ton_http::core::DnsRecordSmcAddress result; result.smc_addr = std::move(addr); return result; } @@ -554,12 +554,12 @@ td::Result parse_dns_record(td::Ref c } } -td::Result> ton_http::utils::parse_dns_content(td::Ref cell) { +td::Result> ton_http::utils::parse_dns_content(td::Ref cell) { static std::string attributes[] = {"wallet", "site", "storage", "dns_next_resolver"}; try { vm::Dictionary dict(cell, 256); auto it = dict.init_iterator(false); - std::map dns_content; + std::map dns_content; for ( ; !it.eof(); it.next()) { auto attr_hash = it.cur_pos(); std::string attr; diff --git a/ton-http-api/src/utils/common.hpp b/ton-http-api/src/utils/common.hpp index 09064b4..95100bb 100644 --- a/ton-http-api/src/utils/common.hpp +++ b/ton-http-api/src/utils/common.hpp @@ -5,6 +5,7 @@ #include #include "block.h" +#include "core/types.hpp" #include "td/utils/Status.h" #include "td/utils/base64.h" #include "td/utils/misc.h" @@ -16,33 +17,6 @@ namespace ton_http::utils { using namespace ton; -const std::map TonDnsRoots { - {"EQC3dNlesgVD8YbAazcauIrXBPfiVhMMr5YYk2in0Mtsz0Bz", ".ton"} -};; - -struct DnsRecordStorageAddress { - constexpr static std::string_view kType = "dns_storage_address"; - std::string bag_id; -}; - -struct DnsRecordSmcAddress { - constexpr static std::string_view kType = "dns_smc_address"; - block::StdAddress smc_addr; -}; - -struct DnsRecordAdnlAddress { - constexpr static std::string_view kType = "dns_adnl_address"; - std::string adnl_addr; -}; - -struct DnsRecordNextResolver { - constexpr static std::string_view kType = "dns_next_resolver"; - block::StdAddress resolver; -}; - -using DnsRecord = std::variant; - - // common inline std::optional stringToHash(const std::string& str) { if (str.empty()) { @@ -90,5 +64,5 @@ td::Result parse_snake_data(td::Ref data); td::Result parse_chunks_data(td::Ref data); td::Result parse_content_data(td::Ref cs); td::Result>> parse_token_data(td::Ref cell); -td::Result> parse_dns_content(td::Ref cell); +td::Result> parse_dns_content(td::Ref cell); } \ No newline at end of file From d0d1be356e77e7a41fc21f1a962fe59fb49a9669 Mon Sep 17 00:00:00 2001 From: K-Dimentional Tree Date: Sun, 21 Sep 2025 03:26:10 +0300 Subject: [PATCH 03/10] Added openapi with codegen, PoC of method, POST-versions of methods --- ton-http-api/CMakeLists.txt | 36 +- ton-http-api/schemas/v2.json | 222 - ton-http-api/schemas/v2.yaml | 1226 +++++ ton-http-api/src/converters/convert.hpp | 35 +- ton-http-api/src/converters/utils.hpp | 9 + .../src/handlers/HandlerDetectAddress.cpp | 31 + .../src/handlers/HandlerDetectAddress.h | 24 + .../handlers/HandlerGetMasterchainInfo.cpp | 17 +- .../src/handlers/HandlerGetMasterchainInfo.h | 27 +- .../src/handlers/JsonRpcMiddleware.hpp | 23 - .../src/handlers/TonlibRequestHandler.cpp | 34 - .../src/handlers/TonlibRequestHandler.h | 66 +- ton-http-api/src/main.cpp | 2 + ton-http-api/src/schemas/v2.cpp | 4126 ++++++++++++++++- ton-http-api/src/schemas/v2.hpp | 3183 ++++++++++++- ton-http-api/src/schemas/v2_fwd.hpp | 115 +- ton-http-api/src/schemas/v2_parsers.ipp | 2540 +++++++++- .../src/userver/chaotic/io/std/int64_t.cpp | 8 + .../src/userver/chaotic/io/std/int64_t.hpp | 15 + .../src/userver/chaotic/io/std/uint64_t.cpp | 8 + .../src/userver/chaotic/io/std/uint64_t.hpp | 15 + .../chaotic/io/ton_http/types/bytes.cpp | 22 + .../chaotic/io/ton_http/types/bytes.hpp | 20 + .../chaotic/io/ton_http/types/int256.cpp | 19 + .../chaotic/io/ton_http/types/int256.hpp | 17 + .../chaotic/io/ton_http/types/shard_id.cpp | 15 - .../chaotic/io/ton_http/types/shard_id.hpp | 21 - .../chaotic/io/ton_http/types/ton_addr.cpp | 24 + .../chaotic/io/ton_http/types/ton_addr.hpp | 21 + .../chaotic/io/ton_http/types/ton_hash.cpp | 2 +- ton-http-api/src/utils/common.hpp | 1 - ton-http-api/static/index.html | 6 +- ton-http-api/static/openapi.json | 1823 +++++++- 33 files changed, 12877 insertions(+), 876 deletions(-) delete mode 100644 ton-http-api/schemas/v2.json create mode 100644 ton-http-api/schemas/v2.yaml create mode 100644 ton-http-api/src/converters/utils.hpp create mode 100644 ton-http-api/src/handlers/HandlerDetectAddress.cpp create mode 100644 ton-http-api/src/handlers/HandlerDetectAddress.h delete mode 100644 ton-http-api/src/handlers/JsonRpcMiddleware.hpp delete mode 100644 ton-http-api/src/handlers/TonlibRequestHandler.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/std/int64_t.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/std/int64_t.hpp create mode 100644 ton-http-api/src/userver/chaotic/io/std/uint64_t.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/std/uint64_t.hpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.hpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/int256.cpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/int256.hpp delete mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp delete mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp create mode 100644 ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.cpp diff --git a/ton-http-api/CMakeLists.txt b/ton-http-api/CMakeLists.txt index 007f24c..1927fca 100644 --- a/ton-http-api/CMakeLists.txt +++ b/ton-http-api/CMakeLists.txt @@ -6,10 +6,8 @@ userver_setup_environment() set(TON_HTTP_API_CPP_SOURCE src/main.cpp - src/userver/chaotic/io/ton_http/types/ton_hash.cpp - src/userver/chaotic/io/ton_http/types/shard_id.cpp src/handlers/HandlerGetMasterchainInfo.cpp - src/handlers/TonlibRequestHandler.cpp + src/handlers/HandlerDetectAddress.cpp src/components/tonlib_component.cpp src/schemas/v2.cpp src/converters/convert.hpp @@ -17,6 +15,12 @@ set(TON_HTTP_API_CPP_SOURCE src/core/tonlib_worker.cpp src/core/tlb/tokens-tlb.cpp src/utils/common.cpp + src/userver/chaotic/io/ton_http/types/ton_hash.cpp + src/userver/chaotic/io/ton_http/types/ton_addr.cpp + src/userver/chaotic/io/ton_http/types/int256.cpp + src/userver/chaotic/io/ton_http/types/bytes.cpp + src/userver/chaotic/io/std/int64_t.cpp + src/userver/chaotic/io/std/uint64_t.cpp ) set(TLB_TOKENS ${CMAKE_CURRENT_SOURCE_DIR}/src/core/tlb/tokens-tlb.cpp @@ -32,14 +36,32 @@ add_custom_command( ) add_custom_target(${PROJECT_NAME}-tlbgen DEPENDS ${TLB_TOKENS}) -file(GLOB_RECURSE API_SCHEMAS ${CMAKE_CURRENT_SOURCE_DIR}/schemas/v2.json) +set(OPENAPI_YAML + ${CMAKE_CURRENT_SOURCE_DIR}/schemas/v2.yaml +) +set(OPENAPI_JSON + ${CMAKE_CURRENT_SOURCE_DIR}/static/openapi.json +) +add_custom_command( + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND yq -Poj ${OPENAPI_YAML} > ${OPENAPI_JSON} + COMMENT "Generate OpenAPI json file" + OUTPUT ${OPENAPI_JSON} + DEPENDS ${OPENAPI_YAML} +) +add_custom_target(${PROJECT_NAME}-openapi-gen DEPENDS ${OPENAPI_JSON}) + +file(GLOB_RECURSE + API_SCHEMAS + ${CMAKE_CURRENT_SOURCE_DIR}/schemas/v2.yaml +) userver_target_generate_chaotic( ${PROJECT_NAME}-chgen GENERATE_SERIALIZERS - LAYOUT "/components/schemas/([^/]*)/=ton_http::schemas::{stem}::{0}" + LAYOUT "/components/schemas/([^/]*)/=ton_http::schemas::v2::{0}" OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/ SCHEMAS ${API_SCHEMAS} - INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src + INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/../external/ton RELATIVE_TO ${CMAKE_CURRENT_SOURCE_DIR}/ ) @@ -51,7 +73,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../external/ton ) -add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-tlbgen ${PROJECT_NAME}-chgen) +add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-tlbgen ${PROJECT_NAME}-chgen ${PROJECT_NAME}-openapi-gen) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20) target_link_libraries(${PROJECT_NAME} userver::core tonlib::multiclient) target_link_options(${PROJECT_NAME} PUBLIC -rdynamic) diff --git a/ton-http-api/schemas/v2.json b/ton-http-api/schemas/v2.json deleted file mode 100644 index ab772bd..0000000 --- a/ton-http-api/schemas/v2.json +++ /dev/null @@ -1,222 +0,0 @@ -{ - "components": { - "schemas": { - "TonObject": { - "oneOf": [ - {"$ref": "#/components/schemas/TonBlockIdExt"}, - {"$ref": "#/components/schemas/MasterchainInfo"} - ], - "discriminator": { - "propertyName": "@type", - "mapping": { - "ton.blockIdExt": "#/components/schemas/TonBlockIdExt", - "blocks.masterchainInfo": "#/components/schemas/MasterchainInfo" - } - } - }, - "TonResponse": { - "properties": { - "ok": { - "type": "boolean", - "title": "Ok" - }, - "result": { - "oneOf": [ - {"type": "string"}, - {"$ref": "#/components/schemas/TonObject"}, - {"type": "array", "items": {"$ref": "#/components/schemas/TonObject"}} - ] - }, - "error": { - "type": "string", - "title": "Error desciption" - }, - "code": { - "type": "integer", - "title": "Error code" - }, - "@extra": { - "type": "string", - "title": "Extra information" - } - }, - "type": "object", - "required": [ - "ok", - "@extra" - ], - "additionalProperties": false, - "title": "TonResponse" - }, - "TonAddr": { - "type": "string", - "x-usrv-cpp-type": "ton_http::types::ton_addr" - }, - "TonHash": { - "type": "string", - "x-usrv-cpp-type": "ton_http::types::ton_hash" - }, - "TonShardId": { - "type": "string", - "x-usrv-cpp-type": "ton_http::types::shard_id" - }, - "TonBlockIdExt": { - "type": "object", - "additionalProperties": false, - "properties": { - "@type": { - "type": "string", - "default": "ton.blockIdExt" - }, - "workchain": { - "type": "integer" - }, - "shard": { - "$ref": "#/components/schemas/TonShardId" - }, - "seqno": { - "type": "integer" - }, - "root_hash": { - "$ref": "#/components/schemas/TonHash" - }, - "file_hash": { - "$ref": "#/components/schemas/TonHash" - } - }, - "required": [ - "@type", - "workchain", - "shard", - "seqno", - "root_hash", - "file_hash" - ], - "description": "Extended block identifier." - }, - "MasterchainInfo": { - "type": "object", - "additionalProperties": false, - "description": "Information about the latest masterchain block.", - "properties": { - "@type": { - "type": "string", - "default": "blocks.masterchainInfo" - }, - "last": { - "$ref": "#/components/schemas/TonBlockIdExt" - }, - "state_root_hash": { - "$ref": "#/components/schemas/TonHash" - }, - "init": { - "$ref": "#/components/schemas/TonBlockIdExt" - } - }, - "required": [ - "@type", - "last", - "state_root_hash", - "init" - ] - }, - "DetectAddressBase64Variant": { - "type": "object", - "additionalProperties": false, - "description": "Base64 form of address variant", - "properties": { - "b64": { - "type": "string" - }, - "b64url": { - "type": "string" - } - }, - "required": [ - "b64", - "b64url" - ] - }, - "DetectedAddress": { - "type": "object", - "additionalProperties": false, - "description": "Information about the address.", - "properties": { - "@type": { - "type": "string", - "default": "utils.detectedAddress" - }, - "raw_form": { - "type": "string" - }, - "bounceable": { - "$ref": "#/components/schemas/DetectAddressBase64Variant" - }, - "non_bounceable": { - "$ref": "#/components/schemas/DetectAddressBase64Variant" - }, - "given_type": { - "type": "string", - "enum": ["raw_form", "friendly_bounceable", "friendly_non_bounceable"] - }, - "test_only": { - "type": "boolean" - } - }, - "required": [ - "@type", - "raw_form", - "bounceable", - "non_bounceable", - "given_type", - "test_only" - ] - }, - "DetectedHash": { - "type": "object", - "additionalProperties": false, - "properties": { - "@type": { - "type": "string", - "default": "utils.detectedHash" - }, - "b64": { - "type": "string", - "title": "base64 form" - }, - "b64url": { - "type": "string", - "title": "base64 url-safe form" - }, - "hex": { - "type": "string", - "title": "hex form" - } - } - }, - "PackedAddress": { - "type": "string", - "title": "Address packed in base64" - }, - "UnpackedAddress": { - "type": "string", - "title": "Address unpacked to raw form" - }, - "FullAccountStateRaw": { - "type": "object", - "additionalProperties": false, - "properties": { - "@type": { - "type": "string", - "default": "raw.fullAccountState" - }, - "balance": { - "type": "string", - "x-usrv-cpp-type": "ton_http::types::int256" - } - } - - } - } - } -} diff --git a/ton-http-api/schemas/v2.yaml b/ton-http-api/schemas/v2.yaml new file mode 100644 index 0000000..2b8071c --- /dev/null +++ b/ton-http-api/schemas/v2.yaml @@ -0,0 +1,1226 @@ +openapi: '3.1.1' +info: + title: TON HTTP API C++ + description: | + This API enables HTTP access to TON blockchain - getting accounts and wallets information, looking up blocks and transactions, sending messages to the blockchain, calling get methods of smart contracts, and more. + In addition to REST API, all methods are available through [JSON-RPC endpoint](#json%20rpc) with `method` equal to method name and `params` passed as a dictionary. + The response contains a JSON object, which always has a boolean field `ok` and either `error` or `result`. If `ok` equals true, the request was successful and the result of the query can be found in the `result` field. In case of an unsuccessful request, `ok` equals false and the error is explained in the `error`. + API Key should be sent either as `api_key` query parameter or `X-API-Key` header + version: '2.1.0' +paths: + /api/v2/detectAddress: + get: + tags: + - utils + summary: Detect address + description: Get all possible address forms + operationId: detectAddress_get + parameters: + - $ref: '#/components/parameters/address' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/TonlibResponse' + default: + $ref: '#/components/responses/default' + security: + - APIKeyHeader: [] + - APIKeyQuery: [] + post: + tags: + - rpc + summary: Detect address + description: Get all possible address forms + operationId: detectAddress_post + requestBody: + $ref: '#/components/requestBodies/DetectAddressRequest' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/TonlibResponse' + default: + $ref: '#/components/responses/default' + security: + - APIKeyHeader: [] + - APIKeyQuery: [] + /api/v2/getMasterchainInfo: + get: + tags: + - blocks + summary: Get Masterchain Info + description: Get up-to-date masterchain state + operationId: getMasterchainInfo_get + parameters: [] + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/TonlibResponse' + default: + $ref: '#/components/responses/default' + security: + - APIKeyHeader: [ ] + - APIKeyQuery: [ ] + post: + tags: + - rpc + summary: Get Masterchain Info + description: Get up-to-date masterchain state + operationId: getMasterchainInfo_post + requestBody: + $ref: '#/components/requestBodies/MasterchainInfoRequest' + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/TonlibResponse' + default: + $ref: '#/components/responses/default' + security: + - APIKeyHeader: [ ] + - APIKeyQuery: [ ] +tags: + - name: utils + description: Some useful methods for conversion + - name: accounts + description: Information about accounts + - name: blocks + description: Information about blocks + - name: transactions + description: Fetching and locating transactions + - name: configuration + description: Information about blockchain config + - name: run method + description: Run get-method of smart contracts + - name: send + description: Send data to blockchain + - name: rpc + description: JSON-RPC and POST endpoints +components: + parameters: + seqnoOptional: + name: seqno + in: query + description: Seqno of a block + required: false + schema: + type: integer + format: int32 + seqno: + name: seqno + in: query + description: Seqno of a block + required: true + schema: + type: integer + format: int32 + address: + name: address + in: query + description: Identifier of target TON account in any form + required: true + schema: + $ref: '#/components/schemas/TonAddr' + requestBodies: + DetectAddressRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/DetectAddressRequest' + description: Address to detect + required: true + MasterchainInfoRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/MasterchainInfoRequest' + description: Get last masterchain block + required: true + responses: + default: + description: Tonlib error + content: + application/json: + schema: + $ref: '#/components/schemas/TonlibErrorResponse' + examples: + 422: + summary: Request validation error + value: + ok: false + code: 422 + error: ... + '@extra': ... + 504: + summary: Tonlib timeout + value: + ok: false + code: 504 + error: ... + '@extra': ... + 429: + summary: Ratelimit exceeded + value: + ok: false + code: 429 + error: ... + '@extra': ... + 409: + summary: Not a token + value: + ok: false + code: 409 + error: Smart contract is not a Jetton or NFT + '@extra': ... + securitySchemes: + APIKeyHeader: + type: apiKey + in: header + name: X-API-Key + APIKeyQuery: + type: apiKey + in: query + name: api_key + schemas: +# request schemas + EmptyRequest: + type: object + additionalProperties: false + required: [] + properties: {} + DetectAddressRequest: + type: object + additionalProperties: false + required: + - address + properties: + address: + $ref: '#/components/schemas/TonAddr' + MasterchainInfoRequest: + $ref: '#/components/schemas/EmptyRequest' +# base types + TonAddr: + type: string + x-usrv-cpp-type: 'ton_http::types::ton_addr' + TonHash: + type: string + x-usrv-cpp-type: 'ton_http::types::ton_hash' + Int256: + type: string + x-usrv-cpp-type: 'ton_http::types::int256' + Bytes: + type: string + x-usrv-cpp-type: 'ton_http::types::bytes' +# tonlib types + AccountAddress: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - accountAddress + default: accountAddress + account_address: + type: string + x-usrv-cpp-type: 'ton_http::types::bytes' + TonBlockIdExt: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - ton.blockIdExt + default: ton.blockIdExt + workchain: + type: integer + shard: + type: string + x-usrv-cpp-type: 'std::int64_t' + seqno: + type: integer + root_hash: + $ref: '#/components/schemas/TonHash' + file_hash: + $ref: '#/components/schemas/TonHash' + required: + - '@type' + - workchain + - shard + - seqno + - root_hash + - file_hash + description: Extended block identifier. + DetectAddressBase64Variant: + type: object + additionalProperties: false + description: Base64 form of address variant + properties: + b64: + type: string + b64url: + type: string + required: + - b64 + - b64url + ExtraCurrencyBalance: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - extraCurrency + default: extraCurrency + id: + type: integer + format: int32 + amount: + $ref: '#/components/schemas/Int256' + required: + - '@type' + - id + - amount + InternalTransactionId: + type: object + additionalProperties: false + description: Internal transaction identifier. + properties: + '@type': + type: string + enum: + - internal.transactionId + default: internal.transactionId + lt: + type: string + description: Logical time + x-usrv-cpp-type: 'std::uint64_t' + hash: + $ref: '#/components/schemas/TonHash' + required: + - '@type' + - lt + - hash + AccountStateRaw: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - raw.accountState + default: raw.accountState + code: + $ref: '#/components/schemas/Bytes' + data: + $ref: '#/components/schemas/Bytes' + frozen_hash: + $ref: '#/components/schemas/TonHash' + required: + - '@type' + - code + - data + - frozen_hash + AccountStateEnum: + type: string + enum: + - uninitialized + - active + - frozen + description: Computed from code/frozen_hash by the API server. + BlockSignature: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.signature + default: blocks.signature + node_id_short: + $ref: '#/components/schemas/TonHash' + signature: + $ref: '#/components/schemas/Bytes' + required: + - '@type' + - node_id_short + - signature + ShardBlockLink: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.shardBlockLink + default: blocks.shardBlockLink + id: + $ref: '#/components/schemas/TonBlockIdExt' + proof: + $ref: '#/components/schemas/Bytes' + required: + - '@type' + - id + - proof + BlockLinkBack: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.blockLinkBack + default: blocks.blockLinkBack + to_key_block: + type: boolean + from: + $ref: '#/components/schemas/TonBlockIdExt' + to: + $ref: '#/components/schemas/TonBlockIdExt' + dest_proof: + $ref: '#/components/schemas/Bytes' + proof: + $ref: '#/components/schemas/Bytes' + state_proof: + $ref: '#/components/schemas/Bytes' + required: + - '@type' + - to_key_block + - from + - to + - dest_proof + - proof + - state_proof + OutMsgQueueSize: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.outMsgQueueSize + default: blocks.outMsgQueueSize + id: + $ref: '#/components/schemas/TonBlockIdExt' + description: Block identifier for the shard. + size: + type: integer + description: Queue size for the shard. + required: + - '@type' + - id + - size + TvmCell: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - tvm.cell + default: tvm.cell + bytes: + $ref: '#/components/schemas/Bytes' + required: + - '@type' + - bytes + LibraryEntry: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - smc.libraryEntry + default: smc.libraryEntry + hash: + $ref: '#/components/schemas/TonHash' + data: + $ref: '#/components/schemas/Bytes' + required: + - '@type' + - hash + - data + ShortTxId: + type: object + additionalProperties: false + description: Short transaction identifier + properties: + '@type': + type: string + enum: + - blocks.shortTxId + default: blocks.shortTxId + mode: + type: integer + description: Transaction mode flags + account: + $ref: '#/components/schemas/TonAddr' + lt: + type: string + description: Logical time of the transaction + x-usrv-cpp-type: 'std::uint64_t' + hash: + $ref: '#/components/schemas/TonHash' + description: Base64 hash of the transaction + required: + - '@type' + - mode + - account + - lt + - hash + MsgDataRaw: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - msg.dataRaw + default: msg.dataRaw + body: + $ref: '#/components/schemas/Bytes' + init_state: + $ref: '#/components/schemas/Bytes' + MsgDataText: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - msg.dataText + default: msg.dataText + text: + type: string + MsgDataDecryptedText: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - msg.dataDecryptedText + default: msg.dataDecryptedText + text: + type: string + MsgDataEncryptedText: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - msg.dataEncryptedText + default: msg.dataEncryptedText + text: + type: string + Message: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - raw.message + default: raw.message + hash: + $ref: '#/components/schemas/TonHash' + source: + $ref: '#/components/schemas/AccountAddress' + destination: + $ref: '#/components/schemas/AccountAddress' + value: + $ref: '#/components/schemas/Int256' + extra_currencies: + type: array + items: + $ref: '#/components/schemas/ExtraCurrencyBalance' + fwd_fee: + $ref: '#/components/schemas/Int256' + ihr_fee: + $ref: '#/components/schemas/Int256' + created_lt: + type: string + description: Logical time of the transaction + x-usrv-cpp-type: 'std::uint64_t' + body_hash: + $ref: '#/components/schemas/TonHash' + msg_data: + oneOf: + - $ref: '#/components/schemas/MsgDataRaw' + - $ref: '#/components/schemas/MsgDataText' + - $ref: '#/components/schemas/MsgDataDecryptedText' + - $ref: '#/components/schemas/MsgDataEncryptedText' + required: + - '@type' + - hash + - source + - destination + - value + - extra_currencies + - fwd_fee + - ihr_fee + - created_lt + - body_hash + - msg_data + Transaction: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - raw.transaction + default: raw.transaction + address: + $ref: '#/components/schemas/AccountAddress' + account: + $ref: '#/components/schemas/TonAddr' + description: Account address in a raw form + utime: + type: integer + description: UNIX timestamp of transaction + data: + $ref: '#/components/schemas/Bytes' + transaction_id: + $ref: '#/components/schemas/InternalTransactionId' + fee: + $ref: '#/components/schemas/Int256' + storage_fee: + $ref: '#/components/schemas/Int256' + other_fee: + $ref: '#/components/schemas/Int256' + in_msg: + $ref: '#/components/schemas/Message' + out_msgs: + type: array + items: + $ref: '#/components/schemas/Message' + required: + - '@type' + - address + - account + - utime + - data + - transaction_id + - fee + - storage_fee + - other_fee + - in_msg + - out_msgs + ExtMessage: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - ext.message + default: ext.message + hash: + $ref: '#/components/schemas/TonHash' + source: + $ref: '#/components/schemas/TonAddr' + destination: + $ref: '#/components/schemas/TonAddr' + value: + $ref: '#/components/schemas/Int256' + extra_currencies: + type: array + items: + $ref: '#/components/schemas/ExtraCurrencyBalance' + fwd_fee: + $ref: '#/components/schemas/Int256' + ihr_fee: + $ref: '#/components/schemas/Int256' + created_lt: + type: string + description: Logical time of the transaction + x-usrv-cpp-type: 'std::uint64_t' + body_hash: + $ref: '#/components/schemas/TonHash' + msg_data: + oneOf: + - $ref: '#/components/schemas/MsgDataRaw' + - $ref: '#/components/schemas/MsgDataText' + - $ref: '#/components/schemas/MsgDataDecryptedText' + - $ref: '#/components/schemas/MsgDataEncryptedText' + message: + type: string + message_decode_error: + type: string + required: + - '@type' + - hash + - source + - destination + - value + - extra_currencies + - fwd_fee + - ihr_fee + - created_lt + - body_hash + - msg_data + ExtTransaction: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - ext.transaction + default: ext.transaction + address: + $ref: '#/components/schemas/AccountAddress' + utime: + type: integer + description: UNIX timestamp of transaction + data: + $ref: '#/components/schemas/Bytes' + transaction_id: + $ref: '#/components/schemas/InternalTransactionId' + fee: + $ref: '#/components/schemas/Int256' + storage_fee: + $ref: '#/components/schemas/Int256' + other_fee: + $ref: '#/components/schemas/Int256' + in_msg: + $ref: '#/components/schemas/ExtMessage' + out_msgs: + type: array + items: + $ref: '#/components/schemas/ExtMessage' + required: + - '@type' + - address + - utime + - data + - transaction_id + - fee + - storage_fee + - other_fee + - in_msg + - out_msgs + +# method responses + TonlibObject: + oneOf: + - $ref: '#/components/schemas/DetectAddress' + - $ref: '#/components/schemas/MasterchainInfo' + - $ref: '#/components/schemas/DetectHash' + discriminator: + propertyName: '@type' + mapping: + 'utils.detectAddress': '#/components/schemas/DetectAddress' + 'utils.detectedHash': '#/components/schemas/DetectHash' + 'blocks.masterchainInfo': '#/components/schemas/MasterchainInfo' + TonlibResponse: + properties: + ok: + type: boolean + title: Ok + default: true + result: + oneOf: + - type: string + - $ref: '#/components/schemas/TonlibObject' + '@extra': + type: string + title: Extra information + type: object + required: + - ok + - result + - '@extra' + additionalProperties: false + title: TonlibResponse + TonlibErrorResponse: + type: object + additionalProperties: false + title: TonlibErrorResponse + properties: + ok: + type: boolean + title: Ok + default: false + error: + type: string + title: Error description + code: + type: integer + title: Error code + minimum: 100 + maximum: 600 + '@extra': + type: string + title: Extra information + DetectAddress: + type: object + additionalProperties: false + description: Information about the address. + properties: + '@type': + type: string + enum: + - utils.detectedAddress + default: utils.detectedAddress + raw_form: + type: string + bounceable: + $ref: '#/components/schemas/DetectAddressBase64Variant' + non_bounceable: + $ref: '#/components/schemas/DetectAddressBase64Variant' + given_type: + type: string + enum: + - raw_form + - friendly_bounceable + - friendly_non_bounceable + test_only: + type: boolean + required: + - '@type' + - raw_form + - bounceable + - non_bounceable + - given_type + - test_only + DetectHash: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - utils.detectedHash + default: utils.detectedHash + b64: + type: string + title: base64 form + b64url: + type: string + title: base64 url-safe form + hex: + type: string + title: hex form + required: + - '@type' + - b64 + - b64url + - hex + PackAddress: + type: string + title: Address packed in base64 + x-usrv-cpp-type: 'ton_http::types::bytes' + UnpackAddress: + type: string + title: Address unpacked to raw form + AddressInformation: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - raw.fullAccountState + default: raw.fullAccountState + balance: + $ref: '#/components/schemas/Int256' + extra_currencies: + type: array + items: + $ref: '#/components/schemas/ExtraCurrencyBalance' + last_transaction_id: + $ref: '#/components/schemas/InternalTransactionId' + block_id: + $ref: '#/components/schemas/TonBlockIdExt' + code: + $ref: '#/components/schemas/Bytes' + data: + $ref: '#/components/schemas/Bytes' + frozen_hash: + $ref: '#/components/schemas/TonHash' + sync_utime: + type: integer + state: + $ref: '#/components/schemas/AccountStateEnum' + suspended: + type: boolean + required: + - '@type' + - balance + - extra_currencies + - code + - data + - last_transaction_id + - block_id + - frozen_hash + - sync_utime + - state + ExtendedAddressInformation: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - fullAccountState + default: fullAccountState + address: + $ref: '#/components/schemas/AccountAddress' + balance: + $ref: '#/components/schemas/Int256' + extra_currencies: + type: array + items: + $ref: '#/components/schemas/ExtraCurrencyBalance' + last_transaction_id: + $ref: '#/components/schemas/InternalTransactionId' + block_id: + $ref: '#/components/schemas/TonBlockIdExt' + sync_utime: + type: integer + account_state: + $ref: '#/components/schemas/AccountStateRaw' + revision: + type: integer + required: + - '@type' + - address + - balance + - extra_currencies + - last_transaction_id + - block_id + - sync_utime + - account_state + - revision + WalletInformation: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - walletInformation + default: walletInformation + wallet: + type: boolean + balance: + type: string + x-usrv-cpp-type: 'ton_http::types::int256' + account_state: + $ref: '#/components/schemas/AccountStateEnum' + last_transaction_id: + $ref: '#/components/schemas/InternalTransactionId' + wallet_type: + type: string + enum: + - wallet v1 r1 + - wallet v1 r2 + - wallet v1 r3 + - wallet v2 r1 + - wallet v2 r2 + - wallet v3 r1 + - wallet v3 r2 + - wallet v4 r1 + - wallet v4 r2 + - wallet v5 beta + - wallet v5 r1 + seqno: + type: integer + wallet_id: + type: integer + is_signature_allowed: + type: boolean + required: + - '@type' + - wallet + - balance + - account_state + - last_transaction_id + AddressBalance: + $ref: '#/components/schemas/Int256' + AddressState: + $ref: '#/components/schemas/AccountStateEnum' + MasterchainInfo: + type: object + additionalProperties: false + description: Information about the latest masterchain block. + properties: + '@type': + type: string + enum: + - blocks.masterchainInfo + default: blocks.masterchainInfo + last: + $ref: '#/components/schemas/TonBlockIdExt' + state_root_hash: + $ref: '#/components/schemas/TonHash' + init: + $ref: '#/components/schemas/TonBlockIdExt' + required: + - '@type' + - last + - state_root_hash + - init + MasterchainBlockSignatures: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.blockSignatures + default: blocks.blockSignatures + id: + $ref: '#/components/schemas/TonBlockIdExt' + signatures: + type: array + items: + $ref: '#/components/schemas/BlockSignature' + required: + - '@type' + - id + - signatures + ShardBlockProof: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.shardBlockProof + default: blocks.shardBlockProof + from: + $ref: '#/components/schemas/TonBlockIdExt' + mc_id: + $ref: '#/components/schemas/TonBlockIdExt' + links: + type: array + items: + $ref: '#/components/schemas/ShardBlockLink' + mc_proof: + type: array + items: + $ref: '#/components/schemas/BlockLinkBack' + required: + - '@type' + - from + - mc_id + - links + - mc_proof + ConsensusBlock: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - ext.consensusBlock + default: ext.consensusBlock + consensus_block: + type: integer + format: int32 + timestamp: + type: integer + format: int32 + required: + - '@type' + - consensus_block + - timestamp + LookupBlock: + $ref: '#/components/schemas/TonBlockIdExt' + Shards: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.shards + default: blocks.shards + shards: + type: array + items: + $ref: '#/components/schemas/TonBlockIdExt' + required: + - '@type' + - shards + BlockHeader: + type: object + additionalProperties: true + description: Block header information. + properties: + '@type': + type: string + enum: + - blocks.header + default: blocks.header + id: + $ref: '#/components/schemas/TonBlockIdExt' + description: Extended identifier of the block. + global_id: + type: integer + description: Global network identifier. + version: + type: integer + description: Block format version. + after_merge: + type: boolean + description: True if block was created after a merge. + after_split: + type: boolean + description: True if block was created after a split. + before_split: + type: boolean + description: True if block was created before a split. + want_merge: + type: boolean + description: Indicates if validators wanted a merge. + want_split: + type: boolean + description: Indicates if validators wanted a split. + validator_list_hash_short: + type: integer + description: Short hash of validator list. + catchain_seqno: + type: integer + description: Catchain sequence number. + min_ref_mc_seqno: + type: integer + description: Minimum referenced masterchain seqno. + is_key_block: + type: boolean + description: True if this block is a key block. + prev_key_block_seqno: + type: integer + description: Previous key block sequence number. + start_lt: + type: string + description: Starting logical time. + x-usrv-cpp-type: 'std::uint64_t' + end_lt: + type: string + description: Ending logical time. + x-usrv-cpp-type: 'std::uint64_t' + gen_utime: + type: integer + description: Block generation UNIX timestamp. + prev_blocks: + type: array + description: List of previous block identifiers. + items: + $ref: '#/components/schemas/TonBlockIdExt' + required: + - '@type' + - id + - global_id + - version + - after_merge + - after_split + - before_split + - want_merge + - want_split + - validator_list_hash_short + - catchain_seqno + - min_ref_mc_seqno + - is_key_block + - prev_key_block_seqno + - start_lt + - end_lt + - gen_utime + - prev_blocks + OutMsgQueueSizes: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - blocks.outMsgQueueSizes + default: blocks.outMsgQueueSizes + shards: + type: array + description: List of outgoing message queue sizes per shard. + items: + $ref: '#/components/schemas/OutMsgQueueSize' + ext_msg_queue_size_limit: + type: integer + description: Limit for the external message queue size. + required: + - '@type' + - shards + - ext_msg_queue_size_limit + ConfigInfo: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - configInfo + default: configInfo + config: + $ref: '#/components/schemas/TvmCell' + required: + - '@type' + - config + LibraryResult: + type: object + additionalProperties: false + properties: + '@type': + type: string + enum: + - smc.libraryResult + default: smc.libraryResult + result: + type: array + items: + $ref: '#/components/schemas/LibraryEntry' + required: + - '@type' + - result + BlockTransactions: + type: object + additionalProperties: false + description: Block transactions information + properties: + '@type': + type: string + enum: + - blocks.transactions + default: blocks.transactions + id: + description: Identifier of the block containing the transactions + $ref: '#/components/schemas/TonBlockIdExt' + req_count: + type: integer + description: Number of requested transactions + incomplete: + type: boolean + description: Indicates if the transaction list is incomplete + transactions: + type: array + description: List of short transaction identifiers + items: + $ref: '#/components/schemas/ShortTxId' + required: + - '@type' + - id + - req_count + - incomplete + - transactions diff --git a/ton-http-api/src/converters/convert.hpp b/ton-http-api/src/converters/convert.hpp index a98ccc3..93d02f9 100644 --- a/ton-http-api/src/converters/convert.hpp +++ b/ton-http-api/src/converters/convert.hpp @@ -2,26 +2,51 @@ #include "auto/tl/tonlib_api.h" #include "schemas/v2.hpp" -namespace ton_http { -namespace converters { + +namespace ton_http::converters { + +using namespace ton; inline schemas::v2::TonBlockIdExt Convert(tonlib_api::object_ptr& value) { schemas::v2::TonBlockIdExt result; result.workchain = value->workchain_; - result.shard = types::shard_id{value->shard_}; + result.shard = value->shard_; result.seqno = value->seqno_; result.root_hash = types::ton_hash{value->root_hash_}; result.file_hash = types::ton_hash{value->file_hash_}; return result; } -inline schemas::v2::MasterchainInfoResult Convert(tonlib_api::blocks_getMasterchainInfo::ReturnType& value) { - schemas::v2::MasterchainInfoResult result; +inline schemas::v2::MasterchainInfo Convert(tonlib_api::blocks_getMasterchainInfo::ReturnType& value) { + schemas::v2::MasterchainInfo result; result.init = Convert(value->init_); result.last = Convert(value->last_); result.state_root_hash = types::ton_hash{value->state_root_hash_}; return result; } +inline schemas::v2::DetectAddress Convert(core::DetectAddressResult& value) { + schemas::v2::DetectAddress result; + result.raw_form = value.to_raw_form(true); + + block::StdAddress b_addr(value.address); + b_addr.bounceable = false; + result.bounceable = schemas::v2::DetectAddressBase64Variant{b_addr.rserialize(false), b_addr.rserialize(true)}; + + b_addr.bounceable = true; + result.non_bounceable = schemas::v2::DetectAddressBase64Variant{b_addr.rserialize(false), b_addr.rserialize(true)}; + if (value.given_type == "raw_form") { + result.given_type = schemas::v2::DetectAddress::Given_Type::kRawForm; + } else if (value.given_type == "friendly_bounceable") { + result.given_type = schemas::v2::DetectAddress::Given_Type::kFriendlyBounceable; + } else if (value.given_type == "friendly_non_bounceable") { + result.given_type = schemas::v2::DetectAddress::Given_Type::kFriendlyNonBounceable; + } else { + throw std::runtime_error("Unknown given type, this should not happen"); + } + result.test_only = value.address.testnet; + return result; } + } + diff --git a/ton-http-api/src/converters/utils.hpp b/ton-http-api/src/converters/utils.hpp new file mode 100644 index 0000000..c573e00 --- /dev/null +++ b/ton-http-api/src/converters/utils.hpp @@ -0,0 +1,9 @@ +#include "auto/tl/tonlib_api.h" +#include "schemas/v2.hpp" + +namespace ton_http::converters { + +using namespace ton; + + +} diff --git a/ton-http-api/src/handlers/HandlerDetectAddress.cpp b/ton-http-api/src/handlers/HandlerDetectAddress.cpp new file mode 100644 index 0000000..90538e1 --- /dev/null +++ b/ton-http-api/src/handlers/HandlerDetectAddress.cpp @@ -0,0 +1,31 @@ +#include "HandlerDetectAddress.h" + +#include "converters/convert.hpp" + +ton_http::handlers::HandlerDetectAddress::HandlerDetectAddress( + const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context +) : TonlibRequestHandler(config, context) { +} +ton_http::schemas::v2::DetectAddressRequest ton_http::handlers::HandlerDetectAddress::ParseTonlibGetRequest( + const HttpRequest& request, const Value& request_json, RequestContext& context +) const { + schemas::v2::DetectAddressRequest req; + + req.address = userver::chaotic::convert::Convert(request.GetArg("address"), userver::chaotic::convert::To{}); + return req; +} +ton_http::schemas::v2::DetectAddressRequest ton_http::handlers::HandlerDetectAddress::ParseTonlibPostRequest( + const HttpRequest& request, const Value& request_json, RequestContext& context +) const { + return request_json.As(); +} +td::Result ton_http::handlers::HandlerDetectAddress::HandleRequestTonlibThrow( + schemas::v2::DetectAddressRequest& request, multiclient::SessionPtr& session +) const { + auto result = tonlib_component_.DoRequest(&core::TonlibWorker::detectAddress, request.address.GetUnderlying(), session); + if (result.is_error()) { + return result.move_as_error(); + } + auto result_ok = result.move_as_ok(); + return converters::Convert(result_ok); +} diff --git a/ton-http-api/src/handlers/HandlerDetectAddress.h b/ton-http-api/src/handlers/HandlerDetectAddress.h new file mode 100644 index 0000000..47f856f --- /dev/null +++ b/ton-http-api/src/handlers/HandlerDetectAddress.h @@ -0,0 +1,24 @@ +#pragma once +#include "TonlibRequestHandler.h" +#include "schemas/v2.hpp" + + +namespace ton_http::handlers { + +class HandlerDetectAddress : public TonlibRequestHandler { +public: + static constexpr std::string_view kName = "handler-detectAddress"; + + HandlerDetectAddress(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); + + schemas::v2::DetectAddressRequest ParseTonlibGetRequest(const HttpRequest& request, const Value& request_json, RequestContext& context) const override; + schemas::v2::DetectAddressRequest ParseTonlibPostRequest(const HttpRequest& request, const Value& request_json, RequestContext& context) const override; + + td::Result HandleRequestTonlibThrow( + schemas::v2::DetectAddressRequest& request, multiclient::SessionPtr& session + ) const override; +}; + +} // namespace ton_http::handlers + + diff --git a/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp index fdb78b2..7ad87a9 100644 --- a/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp +++ b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.cpp @@ -1,15 +1,26 @@ #include "HandlerGetMasterchainInfo.h" #include "converters/convert.hpp" -#include "userver/chaotic/io/userver/utils/datetime/time_point_tz_fraction.hpp" ton_http::handlers::HandlerGetMasterchainInfo::HandlerGetMasterchainInfo( const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context ) : TonlibRequestHandler(config, context) { } -td::Result +ton_http::schemas::v2::MasterchainInfoRequest ton_http::handlers::HandlerGetMasterchainInfo::ParseTonlibGetRequest( + const HttpRequest&, const Value&, RequestContext& +) const { + return schemas::v2::MasterchainInfoRequest{}; +} + +ton_http::schemas::v2::MasterchainInfoRequest ton_http::handlers::HandlerGetMasterchainInfo::ParseTonlibPostRequest( + const HttpRequest&, const Value&, RequestContext& +) const { + return schemas::v2::MasterchainInfoRequest{}; +} + +td::Result ton_http::handlers::HandlerGetMasterchainInfo::HandleRequestTonlibThrow( - const HttpRequest& request, const Value& request_json, RequestContext& context, multiclient::SessionPtr& session + schemas::v2::EmptyRequest&, multiclient::SessionPtr& session ) const { auto result = tonlib_component_.DoRequest(&core::TonlibWorker::getMasterchainInfo, session); if (result.is_error()) { diff --git a/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h index af17d54..4f02136 100644 --- a/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h +++ b/ton-http-api/src/handlers/HandlerGetMasterchainInfo.h @@ -1,16 +1,27 @@ #pragma once #include "TonlibRequestHandler.h" -namespace ton_http { -namespace handlers { +namespace ton_http::handlers { -class HandlerGetMasterchainInfo : public TonlibRequestHandler { +class HandlerGetMasterchainInfo + : public TonlibRequestHandler { public: - static constexpr std::string_view kName = "handler-get-masterchain-info"; + static constexpr std::string_view kName = "handler-getMasterchainInfo"; - HandlerGetMasterchainInfo(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); - td::Result HandleRequestTonlibThrow(const HttpRequest& request, const Value& request_json, RequestContext& context, multiclient::SessionPtr& session) const override; + HandlerGetMasterchainInfo( + const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context + ); + + schemas::v2::EmptyRequest ParseTonlibGetRequest( + const HttpRequest& request, const Value& request_json, RequestContext& context + ) const override; + schemas::v2::EmptyRequest ParseTonlibPostRequest( + const HttpRequest& request, const Value& request_json, RequestContext& context + ) const override; + + td::Result HandleRequestTonlibThrow( + schemas::v2::EmptyRequest& request, multiclient::SessionPtr& session + ) const override; }; -} // namespace handlers -} // namespace ton_http +} // namespace ton_http::handlers diff --git a/ton-http-api/src/handlers/JsonRpcMiddleware.hpp b/ton-http-api/src/handlers/JsonRpcMiddleware.hpp deleted file mode 100644 index 7d73569..0000000 --- a/ton-http-api/src/handlers/JsonRpcMiddleware.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include -#include "userver/server/middlewares/http_middleware_base.hpp" -#include "userver/logging/log.hpp" - -namespace ton_http::middlewares { -class JsonRpcMiddleware final : public userver::server::middlewares::HttpMiddlewareBase { -public: - // This will be used as a kName for the SimpleHttpMiddlewareFactory - static constexpr std::string_view kName{"jsonrpc-middleware"}; - - explicit JsonRpcMiddleware(const userver::server::handlers::HttpHandlerBase&) {} - -private: - void HandleRequest(userver::server::http::HttpRequest& request, userver::server::request::RequestContext& context) const override { - Next(request, context); - } - - static constexpr userver::http::headers::PredefinedHeader kCustomServerHeader{"X-Some-Server-Header"}; -}; - -using JsonRpcMiddlewareFactory = userver::server::middlewares::SimpleHttpMiddlewareFactory; -} \ No newline at end of file diff --git a/ton-http-api/src/handlers/TonlibRequestHandler.cpp b/ton-http-api/src/handlers/TonlibRequestHandler.cpp deleted file mode 100644 index edcdbf2..0000000 --- a/ton-http-api/src/handlers/TonlibRequestHandler.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "TonlibRequestHandler.h" - -#include "userver/components/component_context.hpp" -#include "userver/logging/component.hpp" -#include "schemas/v2.hpp" - - -userver::formats::json::Value ton_http::handlers::TonlibRequestHandler::HandleRequestJsonThrow( - const HttpRequest& request, const Value& request_json, RequestContext& context -) const { - auto session = tonlib_component_.GetNewSession(); - - auto result = HandleRequestTonlibThrow(request, request_json, context, session); - - schemas::v2::TonResponse response; - if (result.is_error()) { - auto tonlib_error = result.move_as_error(); - response.ok = false; - response.error = tonlib_error.message().str(); - response.code = tonlib_error.code(); - } else { - response.ok = true; - response.result = result.move_as_ok(); - } - response._extra = session->to_string(); - return userver::formats::json::ValueBuilder{response}.ExtractValue(); -} -ton_http::handlers::TonlibRequestHandler::TonlibRequestHandler( - const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context -) : - HttpHandlerJsonBase(config, context), - tonlib_component_(context.FindComponent()), - logger_(context.FindComponent().GetLogger("api-v2")) { -} diff --git a/ton-http-api/src/handlers/TonlibRequestHandler.h b/ton-http-api/src/handlers/TonlibRequestHandler.h index f7279c3..917162c 100644 --- a/ton-http-api/src/handlers/TonlibRequestHandler.h +++ b/ton-http-api/src/handlers/TonlibRequestHandler.h @@ -1,21 +1,71 @@ #pragma once -#include "userver/server/handlers/http_handler_json_base.hpp" #include "components/tonlib_component.h" #include "schemas/v2.hpp" +#include "userver/logging/component.hpp" +#include "userver/components/component_context.hpp" +#include "userver/components/component_config.hpp" +#include "userver/server/handlers/http_handler_json_base.hpp" +#include "userver/yaml_config/merge_schemas.hpp" -namespace ton_http { -namespace handlers { +namespace ton_http::handlers { +template class TonlibRequestHandler : public userver::server::handlers::HttpHandlerJsonBase { public: using HttpHandlerJsonBase::HttpHandlerJsonBase; - virtual td::Result HandleRequestTonlibThrow(const HttpRequest& request, const Value& request_json, RequestContext& context, multiclient::SessionPtr& session) const = 0; - userver::formats::json::Value HandleRequestJsonThrow(const HttpRequest& request, const Value& request_json, RequestContext& context) const override; - TonlibRequestHandler(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context); + + virtual Request ParseTonlibGetRequest(const HttpRequest& request, const Value& request_json, RequestContext& context) const = 0; + virtual Request ParseTonlibPostRequest(const HttpRequest& request, const Value& request_json, RequestContext& context) const = 0; + virtual td::Result HandleRequestTonlibThrow(Request& request, multiclient::SessionPtr& session) const = 0; + + userver::formats::json::Value HandleRequestJsonThrow(const HttpRequest& request, const Value& request_json, RequestContext& context) const override { + auto session = tonlib_component_.GetNewSession(); + + Request tonlib_request; + if (request.GetMethod() == userver::server::http::HttpMethod::kGet) { + tonlib_request = ParseTonlibGetRequest(request, request_json, context); + } else if (request.GetMethod() == userver::server::http::HttpMethod::kPost) { + tonlib_request = ParseTonlibPostRequest(request, request_json, context); + } + + auto result = HandleRequestTonlibThrow(tonlib_request, session); + + if (result.is_error()) { + schemas::v2::TonlibErrorResponse response; + auto tonlib_error = result.move_as_error(); + response.ok = false; + response.error = tonlib_error.message().str(); + response.code = tonlib_error.code(); + response._extra = session->to_string(); + return userver::formats::json::ValueBuilder{response}.ExtractValue(); + } + schemas::v2::TonlibResponse response; + response.ok = true; + response.result = result.move_as_ok(); + response._extra = session->to_string(); + response._extra = session->to_string(); + return userver::formats::json::ValueBuilder{response}.ExtractValue(); + } + TonlibRequestHandler(const userver::components::ComponentConfig& config, const userver::components::ComponentContext& context) : + HttpHandlerJsonBase(config, context), + tonlib_component_(context.FindComponent()), + logger_(context.FindComponent().GetLogger(config["logger"].As("api-v2"))) { + } + + static userver::yaml_config::Schema GetStaticConfigSchema() { + return userver::yaml_config::MergeSchemas(R"( +type: object +description: TonlibRequest base config +additionalProperties: false +properties: + logger: + type: string + description: logger name +)"); + } protected: core::TonlibComponent& tonlib_component_; userver::logging::LoggerPtr logger_; }; -} // namespace handlers -} // namespace ton_http +} // namespace ton_http::handlers diff --git a/ton-http-api/src/main.cpp b/ton-http-api/src/main.cpp index d5b2bfa..9c50810 100644 --- a/ton-http-api/src/main.cpp +++ b/ton-http-api/src/main.cpp @@ -11,6 +11,7 @@ #include "tonlib/Logging.h" #include "components/tonlib_component.h" +#include "handlers/HandlerDetectAddress.h" #include "handlers/HandlerGetMasterchainInfo.h" @@ -30,6 +31,7 @@ int main(int argc, char* argv[]) { component_list.Append(); // api handlers component_list.Append(); + component_list.Append(); return userver::utils::DaemonMain(argc, argv, component_list); } diff --git a/ton-http-api/src/schemas/v2.cpp b/ton-http-api/src/schemas/v2.cpp index 64e6886..018e1f1 100644 --- a/ton-http-api/src/schemas/v2.cpp +++ b/ton-http-api/src/schemas/v2.cpp @@ -11,106 +11,207 @@ namespace v2 { bool operator==( - const ::ton_http::schemas::v2::DetectAddressBase64Variant& lhs, - const ::ton_http::schemas::v2::DetectAddressBase64Variant& rhs + const ::ton_http::schemas::v2::AccountAddress& lhs, const ::ton_http::schemas::v2::AccountAddress& rhs ) { - return lhs.b64 == rhs.b64 && lhs.b64url == rhs.b64url && true; + return lhs._type == rhs._type && lhs.account_address == rhs.account_address && true; } USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressBase64Variant& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountAddress::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountAddress& value ) { return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); } -DetectAddressBase64Variant Parse( +AccountAddress::_Type Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> to + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> to +) { + return Parse(json, to); +} + + +AccountAddress Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress> to ) { return Parse(json, to); } +::ton_http::schemas::v2::AccountAddress::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> +) { + const auto result = k__ton_http__schemas__v2__AccountAddress___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AccountAddress::_Type", value) + ); +} + +::ton_http::schemas::v2::AccountAddress::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> to +) { + return FromString(value, to); +} + + USERVER_NAMESPACE::formats::json::Value Serialize( - [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddressBase64Variant& value, + const ::ton_http::schemas::v2::AccountAddress::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::AccountAddress& value, USERVER_NAMESPACE::formats::serialize::To ) { USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; - vb["b64"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64}; + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountAddress::_Type>{value._type}; - vb["b64url"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64url}; + if (value.account_address) { + vb["account_address"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::bytes>{*value.account_address}; + } return vb.ExtractValue(); } +std::string ToString(::ton_http::schemas::v2::AccountAddress::_Type value) { + const auto result = k__ton_http__schemas__v2__AccountAddress___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountStateEnum& value +) { + return lh << ToString(value); +} + + +AccountStateEnum Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::AccountStateEnum FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> +) { + const auto result = k__ton_http__schemas__v2__AccountStateEnum_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AccountStateEnum", value) + ); +} + +::ton_http::schemas::v2::AccountStateEnum Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AccountStateEnum& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::AccountStateEnum value) { + const auto result = k__ton_http__schemas__v2__AccountStateEnum_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + bool operator==( - const ::ton_http::schemas::v2::DetectAddressResult& lhs, const ::ton_http::schemas::v2::DetectAddressResult& rhs + const ::ton_http::schemas::v2::AccountStateRaw& lhs, const ::ton_http::schemas::v2::AccountStateRaw& rhs ) { - return lhs._type == rhs._type && lhs.raw_form == rhs.raw_form && lhs.bounceable == rhs.bounceable && - lhs.non_bounceable == rhs.non_bounceable && lhs.given_type == rhs.given_type && lhs.test_only == rhs.test_only && + return lhs._type == rhs._type && lhs.code == rhs.code && lhs.data == rhs.data && lhs.frozen_hash == rhs.frozen_hash && true; } USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountStateRaw::_Type& value ) { return lh << ToString(value); } USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountStateRaw& value ) { return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); } -DetectAddressResult::Given_Type Parse( +AccountStateRaw::_Type Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> to + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> to ) { return Parse(json, to); } -DetectAddressResult Parse( +AccountStateRaw Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult> to + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw> to ) { return Parse(json, to); } -::ton_http::schemas::v2::DetectAddressResult::Given_Type FromString( - std::string_view value, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +::ton_http::schemas::v2::AccountStateRaw::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> ) { - const auto result = k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping.TryFindBySecond(value); + const auto result = k__ton_http__schemas__v2__AccountStateRaw___Type_Mapping.TryFindBySecond(value); if (result.has_value()) { return *result; } throw std::runtime_error( - fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddressResult::Given_Type", value) + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AccountStateRaw::_Type", value) ); } -::ton_http::schemas::v2::DetectAddressResult::Given_Type Parse( - std::string_view value, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> to +::ton_http::schemas::v2::AccountStateRaw::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> to ) { return FromString(value, to); } USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value, + const ::ton_http::schemas::v2::AccountStateRaw::_Type& value, USERVER_NAMESPACE::formats::serialize::To ) { return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); @@ -118,34 +219,34 @@ USERVER_NAMESPACE::formats::json::Value Serialize( USERVER_NAMESPACE::formats::json::Value Serialize( - [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddressResult& value, + [[maybe_unused]] const ::ton_http::schemas::v2::AccountStateRaw& value, USERVER_NAMESPACE::formats::serialize::To ) { USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; - vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; - - vb["raw_form"] = USERVER_NAMESPACE::chaotic::Primitive{value.raw_form}; - - vb["bounceable"] = - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressBase64Variant>{value.bounceable}; + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountStateRaw::_Type>{value._type}; - vb["non_bounceable"] = - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressBase64Variant>{value.non_bounceable}; + vb["code"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.code + }; - vb["given_type"] = - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressResult::Given_Type>{value.given_type}; + vb["data"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.data + }; - vb["test_only"] = USERVER_NAMESPACE::chaotic::Primitive{value.test_only}; + vb["frozen_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.frozen_hash}; return vb.ExtractValue(); } -std::string ToString(::ton_http::schemas::v2::DetectAddressResult::Given_Type value) { - const auto result = k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping.TryFindByFirst(value); +std::string ToString(::ton_http::schemas::v2::AccountStateRaw::_Type value) { + const auto result = k__ton_http__schemas__v2__AccountStateRaw___Type_Mapping.TryFindByFirst(value); if (result.has_value()) { return std::string{*result}; } @@ -154,212 +255,3955 @@ std::string ToString(::ton_http::schemas::v2::DetectAddressResult::Given_Type va bool operator==( - const ::ton_http::schemas::v2::DetectHashResult& lhs, const ::ton_http::schemas::v2::DetectHashResult& rhs + const ::ton_http::schemas::v2::ExtraCurrencyBalance& lhs, const ::ton_http::schemas::v2::ExtraCurrencyBalance& rhs ) { - return lhs._type == rhs._type && lhs.b64 == rhs.b64 && lhs.b64url == rhs.b64url && lhs.hex == rhs.hex && true; + return lhs._type == rhs._type && lhs.id == rhs.id && lhs.amount == rhs.amount && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type& value +) { + return lh << ToString(value); } USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHashResult& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtraCurrencyBalance& value ) { return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); } -DetectHashResult Parse( +ExtraCurrencyBalance::_Type Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHashResult> to + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> to ) { return Parse(json, to); } -USERVER_NAMESPACE::formats::json::Value Serialize( - [[maybe_unused]] const ::ton_http::schemas::v2::DetectHashResult& value, - USERVER_NAMESPACE::formats::serialize::To +ExtraCurrencyBalance Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance> to ) { - USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; - - - vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; - - if (value.b64) { - vb["b64"] = USERVER_NAMESPACE::chaotic::Primitive{*value.b64}; - } - - if (value.b64url) { - vb["b64url"] = USERVER_NAMESPACE::chaotic::Primitive{*value.b64url}; - } - - if (value.hex) { - vb["hex"] = USERVER_NAMESPACE::chaotic::Primitive{*value.hex}; - } - - - return vb.ExtractValue(); + return Parse(json, to); } -bool operator==(const ::ton_http::schemas::v2::TonBlockIdExt& lhs, const ::ton_http::schemas::v2::TonBlockIdExt& rhs) { - return lhs._type == rhs._type && lhs.workchain == rhs.workchain && lhs.shard == rhs.shard && lhs.seqno == rhs.seqno && - lhs.root_hash == rhs.root_hash && lhs.file_hash == rhs.file_hash && true; +::ton_http::schemas::v2::ExtraCurrencyBalance::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> +) { + const auto result = k__ton_http__schemas__v2__ExtraCurrencyBalance___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type", value) + ); } - -USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt& value +::ton_http::schemas::v2::ExtraCurrencyBalance::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> to ) { - return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); + return FromString(value, to); } -TonBlockIdExt Parse( - USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> to +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type& value, + USERVER_NAMESPACE::formats::serialize::To ) { - return Parse(json, to); + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); } USERVER_NAMESPACE::formats::json::Value Serialize( - [[maybe_unused]] const ::ton_http::schemas::v2::TonBlockIdExt& value, + [[maybe_unused]] const ::ton_http::schemas::v2::ExtraCurrencyBalance& value, USERVER_NAMESPACE::formats::serialize::To ) { USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; - vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; - - vb["workchain"] = USERVER_NAMESPACE::chaotic::Primitive{value.workchain}; + vb["@type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type>{value._type}; - vb["shard"] = USERVER_NAMESPACE::chaotic:: - WithType, ton_http::types::shard_id>{value.shard}; + vb["id"] = USERVER_NAMESPACE::chaotic::Primitive{value.id}; - vb["seqno"] = USERVER_NAMESPACE::chaotic::Primitive{value.seqno}; + vb["amount"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.amount + }; - vb["root_hash"] = USERVER_NAMESPACE::chaotic:: - WithType, ton_http::types::ton_hash>{value.root_hash}; - vb["file_hash"] = USERVER_NAMESPACE::chaotic:: - WithType, ton_http::types::ton_hash>{value.file_hash}; + return vb.ExtractValue(); +} - return vb.ExtractValue(); +std::string ToString(::ton_http::schemas::v2::ExtraCurrencyBalance::_Type value) { + const auto result = k__ton_http__schemas__v2__ExtraCurrencyBalance___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); } bool operator==( - const ::ton_http::schemas::v2::MasterchainInfoResult& lhs, const ::ton_http::schemas::v2::MasterchainInfoResult& rhs + const ::ton_http::schemas::v2::InternalTransactionId& lhs, const ::ton_http::schemas::v2::InternalTransactionId& rhs ) { - return lhs._type == rhs._type && lhs.last == rhs.last && lhs.state_root_hash == rhs.state_root_hash && - lhs.init == rhs.init && true; + return lhs._type == rhs._type && lhs.lt == rhs.lt && lhs.hash == rhs.hash && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::InternalTransactionId::_Type& value +) { + return lh << ToString(value); } USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfoResult& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::InternalTransactionId& value ) { return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); } -MasterchainInfoResult Parse( +InternalTransactionId::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> to +) { + return Parse(json, to); +} + + +InternalTransactionId Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfoResult> to + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId> to ) { return Parse(json, to); } +::ton_http::schemas::v2::InternalTransactionId::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> +) { + const auto result = k__ton_http__schemas__v2__InternalTransactionId___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::InternalTransactionId::_Type", value) + ); +} + +::ton_http::schemas::v2::InternalTransactionId::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> to +) { + return FromString(value, to); +} + + USERVER_NAMESPACE::formats::json::Value Serialize( - [[maybe_unused]] const ::ton_http::schemas::v2::MasterchainInfoResult& value, + const ::ton_http::schemas::v2::InternalTransactionId::_Type& value, USERVER_NAMESPACE::formats::serialize::To ) { - USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} - vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive{value._type}; +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::InternalTransactionId& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; - vb["last"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.last}; - vb["state_root_hash"] = USERVER_NAMESPACE::chaotic:: - WithType, ton_http::types::ton_hash>{value.state_root_hash}; + vb["@type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::InternalTransactionId::_Type>{value._type}; - vb["init"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.init}; + vb["lt"] = + USERVER_NAMESPACE::chaotic::WithType, std::uint64_t>{value.lt}; + + vb["hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.hash}; return vb.ExtractValue(); } -bool operator==(const ::ton_http::schemas::v2::TonResponse& lhs, const ::ton_http::schemas::v2::TonResponse& rhs) { - return lhs.ok == rhs.ok && lhs.result == rhs.result && lhs.error == rhs.error && lhs.code == rhs.code && - lhs._extra == rhs._extra && true; +std::string ToString(::ton_http::schemas::v2::InternalTransactionId::_Type value) { + const auto result = k__ton_http__schemas__v2__InternalTransactionId___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::TonBlockIdExt& lhs, const ::ton_http::schemas::v2::TonBlockIdExt& rhs) { + return lhs._type == rhs._type && lhs.workchain == rhs.workchain && lhs.shard == rhs.shard && lhs.seqno == rhs.seqno && + lhs.root_hash == rhs.root_hash && lhs.file_hash == rhs.file_hash && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt::_Type& value +) { + return lh << ToString(value); } USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonResponse& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt& value ) { return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); } -TonResponse Parse( +TonBlockIdExt::_Type Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonResponse> to + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> to ) { return Parse(json, to); } -USERVER_NAMESPACE::formats::json::Value Serialize( - [[maybe_unused]] const ::ton_http::schemas::v2::TonResponse& value, - USERVER_NAMESPACE::formats::serialize::To +TonBlockIdExt Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> to ) { - USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; - + return Parse(json, to); +} - vb["ok"] = USERVER_NAMESPACE::chaotic::Primitive{value.ok}; - if (value.result) { - vb["result"] = USERVER_NAMESPACE::chaotic::Variant< - USERVER_NAMESPACE::chaotic::Primitive, - USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< - &::ton_http::schemas::v2::kTonObject_Settings, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, - USERVER_NAMESPACE::chaotic::Array< - USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< - &::ton_http::schemas::v2::kTonObject_Settings, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, - std::vector<::ton_http::schemas::v2::TonObject>>>{*value.result}; +::ton_http::schemas::v2::TonBlockIdExt::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> +) { + const auto result = k__ton_http__schemas__v2__TonBlockIdExt___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::TonBlockIdExt::_Type", value) + ); +} - if (value.error) { - vb["error"] = USERVER_NAMESPACE::chaotic::Primitive{*value.error}; - } +::ton_http::schemas::v2::TonBlockIdExt::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> to +) { + return FromString(value, to); +} - if (value.code) { - vb["code"] = USERVER_NAMESPACE::chaotic::Primitive{*value.code}; - } - vb["@extra"] = USERVER_NAMESPACE::chaotic::Primitive{value._extra}; +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TonBlockIdExt::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} - return vb.ExtractValue(); -} +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::TonBlockIdExt& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; -} // namespace v2 + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt::_Type>{value._type}; + + vb["workchain"] = USERVER_NAMESPACE::chaotic::Primitive{value.workchain}; + + vb["shard"] = USERVER_NAMESPACE::chaotic::WithType, std::int64_t>{ + value.shard + }; + + vb["seqno"] = USERVER_NAMESPACE::chaotic::Primitive{value.seqno}; + + vb["root_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.root_hash}; + + vb["file_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.file_hash}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::TonBlockIdExt::_Type value) { + const auto result = k__ton_http__schemas__v2__TonBlockIdExt___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::AddressInformation& lhs, const ::ton_http::schemas::v2::AddressInformation& rhs +) { + return lhs._type == rhs._type && lhs.balance == rhs.balance && lhs.extra_currencies == rhs.extra_currencies && + lhs.last_transaction_id == rhs.last_transaction_id && lhs.block_id == rhs.block_id && lhs.code == rhs.code && + lhs.data == rhs.data && lhs.frozen_hash == rhs.frozen_hash && lhs.sync_utime == rhs.sync_utime && + lhs.state == rhs.state && lhs.suspended == rhs.suspended && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AddressInformation::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AddressInformation& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +AddressInformation::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> to +) { + return Parse(json, to); +} + + +AddressInformation Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::AddressInformation::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> +) { + const auto result = k__ton_http__schemas__v2__AddressInformation___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AddressInformation::_Type", value) + ); +} + +::ton_http::schemas::v2::AddressInformation::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AddressInformation::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::AddressInformation& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AddressInformation::_Type>{value._type}; + + vb["balance"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.balance + }; + + vb["extra_currencies"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtraCurrencyBalance>, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>{value.extra_currencies}; + + vb["last_transaction_id"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::InternalTransactionId>{value.last_transaction_id}; + + vb["block_id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.block_id}; + + vb["code"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.code + }; + + vb["data"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.data + }; + + vb["frozen_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.frozen_hash}; + + vb["sync_utime"] = USERVER_NAMESPACE::chaotic::Primitive{value.sync_utime}; + + vb["state"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountStateEnum>{value.state}; + + if (value.suspended) { + vb["suspended"] = USERVER_NAMESPACE::chaotic::Primitive{*value.suspended}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::AddressInformation::_Type value) { + const auto result = k__ton_http__schemas__v2__AddressInformation___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::BlockHeader& lhs, const ::ton_http::schemas::v2::BlockHeader& rhs) { + return lhs._type == rhs._type && lhs.id == rhs.id && lhs.global_id == rhs.global_id && lhs.version == rhs.version && + lhs.after_merge == rhs.after_merge && lhs.after_split == rhs.after_split && + lhs.before_split == rhs.before_split && lhs.want_merge == rhs.want_merge && lhs.want_split == rhs.want_split && + lhs.validator_list_hash_short == rhs.validator_list_hash_short && lhs.catchain_seqno == rhs.catchain_seqno && + lhs.min_ref_mc_seqno == rhs.min_ref_mc_seqno && lhs.is_key_block == rhs.is_key_block && + lhs.prev_key_block_seqno == rhs.prev_key_block_seqno && lhs.start_lt == rhs.start_lt && + lhs.end_lt == rhs.end_lt && lhs.gen_utime == rhs.gen_utime && lhs.prev_blocks == rhs.prev_blocks && + lhs.extra == rhs.extra && + + true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockHeader::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockHeader& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +BlockHeader::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> to +) { + return Parse(json, to); +} + + +BlockHeader Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::BlockHeader::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> +) { + const auto result = k__ton_http__schemas__v2__BlockHeader___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockHeader::_Type", value) + ); +} + +::ton_http::schemas::v2::BlockHeader::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockHeader::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::BlockHeader& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = value.extra; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::BlockHeader::_Type>{value._type}; + + vb["id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.id}; + + vb["global_id"] = USERVER_NAMESPACE::chaotic::Primitive{value.global_id}; + + vb["version"] = USERVER_NAMESPACE::chaotic::Primitive{value.version}; + + vb["after_merge"] = USERVER_NAMESPACE::chaotic::Primitive{value.after_merge}; + + vb["after_split"] = USERVER_NAMESPACE::chaotic::Primitive{value.after_split}; + + vb["before_split"] = USERVER_NAMESPACE::chaotic::Primitive{value.before_split}; + + vb["want_merge"] = USERVER_NAMESPACE::chaotic::Primitive{value.want_merge}; + + vb["want_split"] = USERVER_NAMESPACE::chaotic::Primitive{value.want_split}; + + vb["validator_list_hash_short"] = USERVER_NAMESPACE::chaotic::Primitive{value.validator_list_hash_short}; + + vb["catchain_seqno"] = USERVER_NAMESPACE::chaotic::Primitive{value.catchain_seqno}; + + vb["min_ref_mc_seqno"] = USERVER_NAMESPACE::chaotic::Primitive{value.min_ref_mc_seqno}; + + vb["is_key_block"] = USERVER_NAMESPACE::chaotic::Primitive{value.is_key_block}; + + vb["prev_key_block_seqno"] = USERVER_NAMESPACE::chaotic::Primitive{value.prev_key_block_seqno}; + + vb["start_lt"] = + USERVER_NAMESPACE::chaotic::WithType, std::uint64_t>{ + value.start_lt + }; + + vb["end_lt"] = + USERVER_NAMESPACE::chaotic::WithType, std::uint64_t>{ + value.end_lt + }; + + vb["gen_utime"] = USERVER_NAMESPACE::chaotic::Primitive{value.gen_utime}; + + vb["prev_blocks"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, + std::vector<::ton_http::schemas::v2::TonBlockIdExt>>{value.prev_blocks}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::BlockHeader::_Type value) { + const auto result = k__ton_http__schemas__v2__BlockHeader___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::BlockLinkBack& lhs, const ::ton_http::schemas::v2::BlockLinkBack& rhs) { + return lhs._type == rhs._type && lhs.to_key_block == rhs.to_key_block && lhs.from == rhs.from && lhs.to == rhs.to && + lhs.dest_proof == rhs.dest_proof && lhs.proof == rhs.proof && lhs.state_proof == rhs.state_proof && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockLinkBack::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockLinkBack& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +BlockLinkBack::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> to +) { + return Parse(json, to); +} + + +BlockLinkBack Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::BlockLinkBack::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> +) { + const auto result = k__ton_http__schemas__v2__BlockLinkBack___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockLinkBack::_Type", value) + ); +} + +::ton_http::schemas::v2::BlockLinkBack::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockLinkBack::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::BlockLinkBack& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::BlockLinkBack::_Type>{value._type}; + + vb["to_key_block"] = USERVER_NAMESPACE::chaotic::Primitive{value.to_key_block}; + + vb["from"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.from}; + + vb["to"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.to}; + + vb["dest_proof"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.dest_proof + }; + + vb["proof"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.proof + }; + + vb["state_proof"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.state_proof + }; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::BlockLinkBack::_Type value) { + const auto result = k__ton_http__schemas__v2__BlockLinkBack___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::BlockSignature& lhs, const ::ton_http::schemas::v2::BlockSignature& rhs +) { + return lhs._type == rhs._type && lhs.node_id_short == rhs.node_id_short && lhs.signature == rhs.signature && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockSignature::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockSignature& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +BlockSignature::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> to +) { + return Parse(json, to); +} + + +BlockSignature Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::BlockSignature::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> +) { + const auto result = k__ton_http__schemas__v2__BlockSignature___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockSignature::_Type", value) + ); +} + +::ton_http::schemas::v2::BlockSignature::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockSignature::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::BlockSignature& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::BlockSignature::_Type>{value._type}; + + vb["node_id_short"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.node_id_short}; + + vb["signature"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.signature + }; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::BlockSignature::_Type value) { + const auto result = k__ton_http__schemas__v2__BlockSignature___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::ShortTxId& lhs, const ::ton_http::schemas::v2::ShortTxId& rhs) { + return lhs._type == rhs._type && lhs.mode == rhs.mode && lhs.account == rhs.account && lhs.lt == rhs.lt && + lhs.hash == rhs.hash && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShortTxId::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShortTxId& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ShortTxId::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> to +) { + return Parse(json, to); +} + + +ShortTxId Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ShortTxId::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> +) { + const auto result = k__ton_http__schemas__v2__ShortTxId___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ShortTxId::_Type", value) + ); +} + +::ton_http::schemas::v2::ShortTxId::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShortTxId::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ShortTxId& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ShortTxId::_Type>{value._type}; + + vb["mode"] = USERVER_NAMESPACE::chaotic::Primitive{value.mode}; + + vb["account"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_addr>{value.account}; + + vb["lt"] = + USERVER_NAMESPACE::chaotic::WithType, std::uint64_t>{value.lt}; + + vb["hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.hash}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ShortTxId::_Type value) { + const auto result = k__ton_http__schemas__v2__ShortTxId___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::BlockTransactions& lhs, const ::ton_http::schemas::v2::BlockTransactions& rhs +) { + return lhs._type == rhs._type && lhs.id == rhs.id && lhs.req_count == rhs.req_count && + lhs.incomplete == rhs.incomplete && lhs.transactions == rhs.transactions && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockTransactions::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockTransactions& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +BlockTransactions::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> to +) { + return Parse(json, to); +} + + +BlockTransactions Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::BlockTransactions::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> +) { + const auto result = k__ton_http__schemas__v2__BlockTransactions___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockTransactions::_Type", value) + ); +} + +::ton_http::schemas::v2::BlockTransactions::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockTransactions::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::BlockTransactions& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::BlockTransactions::_Type>{value._type}; + + vb["id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.id}; + + vb["req_count"] = USERVER_NAMESPACE::chaotic::Primitive{value.req_count}; + + vb["incomplete"] = USERVER_NAMESPACE::chaotic::Primitive{value.incomplete}; + + vb["transactions"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ShortTxId>, + std::vector<::ton_http::schemas::v2::ShortTxId>>{value.transactions}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::BlockTransactions::_Type value) { + const auto result = k__ton_http__schemas__v2__BlockTransactions___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::TvmCell& lhs, const ::ton_http::schemas::v2::TvmCell& rhs) { + return lhs._type == rhs._type && lhs.bytes == rhs.bytes && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TvmCell::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TvmCell& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +TvmCell::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> to +) { + return Parse(json, to); +} + + +TvmCell Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::TvmCell::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> +) { + const auto result = k__ton_http__schemas__v2__TvmCell___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::TvmCell::_Type", value) + ); +} + +::ton_http::schemas::v2::TvmCell::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TvmCell::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::TvmCell& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TvmCell::_Type>{value._type}; + + vb["bytes"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.bytes + }; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::TvmCell::_Type value) { + const auto result = k__ton_http__schemas__v2__TvmCell___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::ConfigInfo& lhs, const ::ton_http::schemas::v2::ConfigInfo& rhs) { + return lhs._type == rhs._type && lhs.config == rhs.config && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConfigInfo::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConfigInfo& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ConfigInfo::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> to +) { + return Parse(json, to); +} + + +ConfigInfo Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ConfigInfo::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> +) { + const auto result = k__ton_http__schemas__v2__ConfigInfo___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ConfigInfo::_Type", value) + ); +} + +::ton_http::schemas::v2::ConfigInfo::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ConfigInfo::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ConfigInfo& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ConfigInfo::_Type>{value._type}; + + vb["config"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TvmCell>{value.config}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ConfigInfo::_Type value) { + const auto result = k__ton_http__schemas__v2__ConfigInfo___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::ConsensusBlock& lhs, const ::ton_http::schemas::v2::ConsensusBlock& rhs +) { + return lhs._type == rhs._type && lhs.consensus_block == rhs.consensus_block && lhs.timestamp == rhs.timestamp && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConsensusBlock::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConsensusBlock& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ConsensusBlock::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> to +) { + return Parse(json, to); +} + + +ConsensusBlock Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ConsensusBlock::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> +) { + const auto result = k__ton_http__schemas__v2__ConsensusBlock___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ConsensusBlock::_Type", value) + ); +} + +::ton_http::schemas::v2::ConsensusBlock::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ConsensusBlock::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ConsensusBlock& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ConsensusBlock::_Type>{value._type}; + + vb["consensus_block"] = USERVER_NAMESPACE::chaotic::Primitive{value.consensus_block}; + + vb["timestamp"] = USERVER_NAMESPACE::chaotic::Primitive{value.timestamp}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ConsensusBlock::_Type value) { + const auto result = k__ton_http__schemas__v2__ConsensusBlock___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressBase64Variant& lhs, + const ::ton_http::schemas::v2::DetectAddressBase64Variant& rhs +) { + return lhs.b64 == rhs.b64 && lhs.b64url == rhs.b64url && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressBase64Variant& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectAddressBase64Variant Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddressBase64Variant& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["b64"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64}; + + vb["b64url"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64url}; + + + return vb.ExtractValue(); +} + + +bool operator==(const ::ton_http::schemas::v2::DetectAddress& lhs, const ::ton_http::schemas::v2::DetectAddress& rhs) { + return lhs._type == rhs._type && lhs.raw_form == rhs.raw_form && lhs.bounceable == rhs.bounceable && + lhs.non_bounceable == rhs.non_bounceable && lhs.given_type == rhs.given_type && lhs.test_only == rhs.test_only && + true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddress::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddress::Given_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddress& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectAddress::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> to +) { + return Parse(json, to); +} + + +DetectAddress::Given_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> to +) { + return Parse(json, to); +} + + +DetectAddress Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::DetectAddress::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> +) { + const auto result = k__ton_http__schemas__v2__DetectAddress___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddress::_Type", value) + ); +} + +::ton_http::schemas::v2::DetectAddress::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> to +) { + return FromString(value, to); +} + + +::ton_http::schemas::v2::DetectAddress::Given_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> +) { + const auto result = k__ton_http__schemas__v2__DetectAddress__Given_Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddress::Given_Type", value) + ); +} + +::ton_http::schemas::v2::DetectAddress::Given_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddress::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddress::Given_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddress& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddress::_Type>{value._type}; + + vb["raw_form"] = USERVER_NAMESPACE::chaotic::Primitive{value.raw_form}; + + vb["bounceable"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressBase64Variant>{value.bounceable}; + + vb["non_bounceable"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressBase64Variant>{value.non_bounceable}; + + vb["given_type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddress::Given_Type>{value.given_type}; + + vb["test_only"] = USERVER_NAMESPACE::chaotic::Primitive{value.test_only}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::DetectAddress::_Type value) { + const auto result = k__ton_http__schemas__v2__DetectAddress___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +std::string ToString(::ton_http::schemas::v2::DetectAddress::Given_Type value) { + const auto result = k__ton_http__schemas__v2__DetectAddress__Given_Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressRequest& lhs, const ::ton_http::schemas::v2::DetectAddressRequest& rhs +) { + return lhs.address == rhs.address && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressRequest& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectAddressRequest Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressRequest> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectAddressRequest& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["address"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_addr>{value.address}; + + + return vb.ExtractValue(); +} + + +bool operator==(const ::ton_http::schemas::v2::DetectHash& lhs, const ::ton_http::schemas::v2::DetectHash& rhs) { + return lhs._type == rhs._type && lhs.b64 == rhs.b64 && lhs.b64url == rhs.b64url && lhs.hex == rhs.hex && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHash::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHash& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +DetectHash::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> to +) { + return Parse(json, to); +} + + +DetectHash Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::DetectHash::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> +) { + const auto result = k__ton_http__schemas__v2__DetectHash___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectHash::_Type", value) + ); +} + +::ton_http::schemas::v2::DetectHash::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectHash::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::DetectHash& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectHash::_Type>{value._type}; + + vb["b64"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64}; + + vb["b64url"] = USERVER_NAMESPACE::chaotic::Primitive{value.b64url}; + + vb["hex"] = USERVER_NAMESPACE::chaotic::Primitive{value.hex}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::DetectHash::_Type value) { + const auto result = k__ton_http__schemas__v2__DetectHash___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::EmptyRequest& lhs, const ::ton_http::schemas::v2::EmptyRequest& rhs) { + (void)lhs; + (void)rhs; + + return + + true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::EmptyRequest& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +EmptyRequest Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::EmptyRequest> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::EmptyRequest& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + return vb.ExtractValue(); +} + + +bool operator==(const ::ton_http::schemas::v2::MsgDataRaw& lhs, const ::ton_http::schemas::v2::MsgDataRaw& rhs) { + return lhs._type == rhs._type && lhs.body == rhs.body && lhs.init_state == rhs.init_state && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataRaw::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataRaw& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MsgDataRaw::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> to +) { + return Parse(json, to); +} + + +MsgDataRaw Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::MsgDataRaw::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> +) { + const auto result = k__ton_http__schemas__v2__MsgDataRaw___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataRaw::_Type", value) + ); +} + +::ton_http::schemas::v2::MsgDataRaw::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataRaw::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MsgDataRaw& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataRaw::_Type>{value._type}; + + if (value.body) { + vb["body"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::bytes>{*value.body}; + } + + if (value.init_state) { + vb["init_state"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::bytes>{*value.init_state}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::MsgDataRaw::_Type value) { + const auto result = k__ton_http__schemas__v2__MsgDataRaw___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::MsgDataText& lhs, const ::ton_http::schemas::v2::MsgDataText& rhs) { + return lhs._type == rhs._type && lhs.text == rhs.text && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataText::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataText& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MsgDataText::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> to +) { + return Parse(json, to); +} + + +MsgDataText Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::MsgDataText::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> +) { + const auto result = k__ton_http__schemas__v2__MsgDataText___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataText::_Type", value) + ); +} + +::ton_http::schemas::v2::MsgDataText::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataText::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MsgDataText& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataText::_Type>{value._type}; + + if (value.text) { + vb["text"] = USERVER_NAMESPACE::chaotic::Primitive{*value.text}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::MsgDataText::_Type value) { + const auto result = k__ton_http__schemas__v2__MsgDataText___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::MsgDataDecryptedText& lhs, const ::ton_http::schemas::v2::MsgDataDecryptedText& rhs +) { + return lhs._type == rhs._type && lhs.text == rhs.text && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataDecryptedText::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataDecryptedText& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MsgDataDecryptedText::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> to +) { + return Parse(json, to); +} + + +MsgDataDecryptedText Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::MsgDataDecryptedText::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> +) { + const auto result = k__ton_http__schemas__v2__MsgDataDecryptedText___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataDecryptedText::_Type", value) + ); +} + +::ton_http::schemas::v2::MsgDataDecryptedText::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataDecryptedText::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MsgDataDecryptedText& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataDecryptedText::_Type>{value._type}; + + if (value.text) { + vb["text"] = USERVER_NAMESPACE::chaotic::Primitive{*value.text}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::MsgDataDecryptedText::_Type value) { + const auto result = k__ton_http__schemas__v2__MsgDataDecryptedText___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::MsgDataEncryptedText& lhs, const ::ton_http::schemas::v2::MsgDataEncryptedText& rhs +) { + return lhs._type == rhs._type && lhs.text == rhs.text && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataEncryptedText::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataEncryptedText& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MsgDataEncryptedText::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> to +) { + return Parse(json, to); +} + + +MsgDataEncryptedText Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::MsgDataEncryptedText::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> +) { + const auto result = k__ton_http__schemas__v2__MsgDataEncryptedText___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataEncryptedText::_Type", value) + ); +} + +::ton_http::schemas::v2::MsgDataEncryptedText::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataEncryptedText::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MsgDataEncryptedText& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataEncryptedText::_Type>{value._type}; + + if (value.text) { + vb["text"] = USERVER_NAMESPACE::chaotic::Primitive{*value.text}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::MsgDataEncryptedText::_Type value) { + const auto result = k__ton_http__schemas__v2__MsgDataEncryptedText___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::ExtMessage& lhs, const ::ton_http::schemas::v2::ExtMessage& rhs) { + return lhs._type == rhs._type && lhs.hash == rhs.hash && lhs.source == rhs.source && + lhs.destination == rhs.destination && lhs.value == rhs.value && lhs.extra_currencies == rhs.extra_currencies && + lhs.fwd_fee == rhs.fwd_fee && lhs.ihr_fee == rhs.ihr_fee && lhs.created_lt == rhs.created_lt && + lhs.body_hash == rhs.body_hash && lhs.msg_data == rhs.msg_data && lhs.message == rhs.message && + lhs.message_decode_error == rhs.message_decode_error && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtMessage::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtMessage& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ExtMessage::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> to +) { + return Parse(json, to); +} + + +ExtMessage Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ExtMessage::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> +) { + const auto result = k__ton_http__schemas__v2__ExtMessage___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtMessage::_Type", value) + ); +} + +::ton_http::schemas::v2::ExtMessage::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtMessage::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ExtMessage& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtMessage::_Type>{value._type}; + + vb["hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.hash}; + + vb["source"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_addr>{value.source}; + + vb["destination"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_addr>{value.destination}; + + vb["value"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.value + }; + + vb["extra_currencies"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtraCurrencyBalance>, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>{value.extra_currencies}; + + vb["fwd_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.fwd_fee + }; + + vb["ihr_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.ihr_fee + }; + + vb["created_lt"] = + USERVER_NAMESPACE::chaotic::WithType, std::uint64_t>{ + value.created_lt + }; + + vb["body_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.body_hash}; + + vb["msg_data"] = USERVER_NAMESPACE::chaotic::Variant< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataRaw>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataDecryptedText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataEncryptedText>>{value.msg_data}; + + if (value.message) { + vb["message"] = USERVER_NAMESPACE::chaotic::Primitive{*value.message}; + } + + if (value.message_decode_error) { + vb["message_decode_error"] = USERVER_NAMESPACE::chaotic::Primitive{*value.message_decode_error}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ExtMessage::_Type value) { + const auto result = k__ton_http__schemas__v2__ExtMessage___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::ExtTransaction& lhs, const ::ton_http::schemas::v2::ExtTransaction& rhs +) { + return lhs._type == rhs._type && lhs.address == rhs.address && lhs.utime == rhs.utime && lhs.data == rhs.data && + lhs.transaction_id == rhs.transaction_id && lhs.fee == rhs.fee && lhs.storage_fee == rhs.storage_fee && + lhs.other_fee == rhs.other_fee && lhs.in_msg == rhs.in_msg && lhs.out_msgs == rhs.out_msgs && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtTransaction::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtTransaction& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ExtTransaction::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> to +) { + return Parse(json, to); +} + + +ExtTransaction Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ExtTransaction::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> +) { + const auto result = k__ton_http__schemas__v2__ExtTransaction___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtTransaction::_Type", value) + ); +} + +::ton_http::schemas::v2::ExtTransaction::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtTransaction::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ExtTransaction& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtTransaction::_Type>{value._type}; + + vb["address"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountAddress>{value.address}; + + vb["utime"] = USERVER_NAMESPACE::chaotic::Primitive{value.utime}; + + vb["data"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.data + }; + + vb["transaction_id"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::InternalTransactionId>{value.transaction_id}; + + vb["fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.fee + }; + + vb["storage_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.storage_fee + }; + + vb["other_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.other_fee + }; + + vb["in_msg"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtMessage>{value.in_msg}; + + vb["out_msgs"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtMessage>, + std::vector<::ton_http::schemas::v2::ExtMessage>>{value.out_msgs}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ExtTransaction::_Type value) { + const auto result = k__ton_http__schemas__v2__ExtTransaction___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::ExtendedAddressInformation& lhs, + const ::ton_http::schemas::v2::ExtendedAddressInformation& rhs +) { + return lhs._type == rhs._type && lhs.address == rhs.address && lhs.balance == rhs.balance && + lhs.extra_currencies == rhs.extra_currencies && lhs.last_transaction_id == rhs.last_transaction_id && + lhs.block_id == rhs.block_id && lhs.sync_utime == rhs.sync_utime && lhs.account_state == rhs.account_state && + lhs.revision == rhs.revision && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtendedAddressInformation::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtendedAddressInformation& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ExtendedAddressInformation::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> to +) { + return Parse(json, to); +} + + +ExtendedAddressInformation Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ExtendedAddressInformation::_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> +) { + const auto result = k__ton_http__schemas__v2__ExtendedAddressInformation___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtendedAddressInformation::_Type", value) + ); +} + +::ton_http::schemas::v2::ExtendedAddressInformation::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtendedAddressInformation::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ExtendedAddressInformation& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtendedAddressInformation::_Type>{value._type}; + + vb["address"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountAddress>{value.address}; + + vb["balance"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.balance + }; + + vb["extra_currencies"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtraCurrencyBalance>, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>{value.extra_currencies}; + + vb["last_transaction_id"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::InternalTransactionId>{value.last_transaction_id}; + + vb["block_id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.block_id}; + + vb["sync_utime"] = USERVER_NAMESPACE::chaotic::Primitive{value.sync_utime}; + + vb["account_state"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountStateRaw>{value.account_state}; + + vb["revision"] = USERVER_NAMESPACE::chaotic::Primitive{value.revision}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ExtendedAddressInformation::_Type value) { + const auto result = k__ton_http__schemas__v2__ExtendedAddressInformation___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::LibraryEntry& lhs, const ::ton_http::schemas::v2::LibraryEntry& rhs) { + return lhs._type == rhs._type && lhs.hash == rhs.hash && lhs.data == rhs.data && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryEntry::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryEntry& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +LibraryEntry::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> to +) { + return Parse(json, to); +} + + +LibraryEntry Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::LibraryEntry::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> +) { + const auto result = k__ton_http__schemas__v2__LibraryEntry___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::LibraryEntry::_Type", value) + ); +} + +::ton_http::schemas::v2::LibraryEntry::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::LibraryEntry::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::LibraryEntry& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::LibraryEntry::_Type>{value._type}; + + vb["hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.hash}; + + vb["data"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.data + }; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::LibraryEntry::_Type value) { + const auto result = k__ton_http__schemas__v2__LibraryEntry___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::LibraryResult& lhs, const ::ton_http::schemas::v2::LibraryResult& rhs) { + return lhs._type == rhs._type && lhs.result == rhs.result && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryResult::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryResult& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +LibraryResult::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> to +) { + return Parse(json, to); +} + + +LibraryResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::LibraryResult::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> +) { + const auto result = k__ton_http__schemas__v2__LibraryResult___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::LibraryResult::_Type", value) + ); +} + +::ton_http::schemas::v2::LibraryResult::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::LibraryResult::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::LibraryResult& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::LibraryResult::_Type>{value._type}; + + vb["result"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::LibraryEntry>, + std::vector<::ton_http::schemas::v2::LibraryEntry>>{value.result}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::LibraryResult::_Type value) { + const auto result = k__ton_http__schemas__v2__LibraryResult___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::MasterchainBlockSignatures& lhs, + const ::ton_http::schemas::v2::MasterchainBlockSignatures& rhs +) { + return lhs._type == rhs._type && lhs.id == rhs.id && lhs.signatures == rhs.signatures && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainBlockSignatures& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MasterchainBlockSignatures::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> to +) { + return Parse(json, to); +} + + +MasterchainBlockSignatures Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::MasterchainBlockSignatures::_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> +) { + const auto result = k__ton_http__schemas__v2__MasterchainBlockSignatures___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type", value) + ); +} + +::ton_http::schemas::v2::MasterchainBlockSignatures::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MasterchainBlockSignatures& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type>{value._type}; + + vb["id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.id}; + + vb["signatures"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::BlockSignature>, + std::vector<::ton_http::schemas::v2::BlockSignature>>{value.signatures}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::MasterchainBlockSignatures::_Type value) { + const auto result = k__ton_http__schemas__v2__MasterchainBlockSignatures___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::MasterchainInfo& lhs, const ::ton_http::schemas::v2::MasterchainInfo& rhs +) { + return lhs._type == rhs._type && lhs.last == rhs.last && lhs.state_root_hash == rhs.state_root_hash && + lhs.init == rhs.init && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfo::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfo& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +MasterchainInfo::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> to +) { + return Parse(json, to); +} + + +MasterchainInfo Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::MasterchainInfo::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> +) { + const auto result = k__ton_http__schemas__v2__MasterchainInfo___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MasterchainInfo::_Type", value) + ); +} + +::ton_http::schemas::v2::MasterchainInfo::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainInfo::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::MasterchainInfo& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfo::_Type>{value._type}; + + vb["last"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.last}; + + vb["state_root_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.state_root_hash}; + + vb["init"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.init}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::MasterchainInfo::_Type value) { + const auto result = k__ton_http__schemas__v2__MasterchainInfo___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::Message& lhs, const ::ton_http::schemas::v2::Message& rhs) { + return lhs._type == rhs._type && lhs.hash == rhs.hash && lhs.source == rhs.source && + lhs.destination == rhs.destination && lhs.value == rhs.value && lhs.extra_currencies == rhs.extra_currencies && + lhs.fwd_fee == rhs.fwd_fee && lhs.ihr_fee == rhs.ihr_fee && lhs.created_lt == rhs.created_lt && + lhs.body_hash == rhs.body_hash && lhs.msg_data == rhs.msg_data && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Message::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Message& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +Message::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> to +) { + return Parse(json, to); +} + + +Message Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::Message::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> +) { + const auto result = k__ton_http__schemas__v2__Message___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::Message::_Type", value) + ); +} + +::ton_http::schemas::v2::Message::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Message::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::Message& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::Message::_Type>{value._type}; + + vb["hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.hash}; + + vb["source"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountAddress>{value.source}; + + vb["destination"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountAddress>{value.destination}; + + vb["value"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.value + }; + + vb["extra_currencies"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtraCurrencyBalance>, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>{value.extra_currencies}; + + vb["fwd_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.fwd_fee + }; + + vb["ihr_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.ihr_fee + }; + + vb["created_lt"] = + USERVER_NAMESPACE::chaotic::WithType, std::uint64_t>{ + value.created_lt + }; + + vb["body_hash"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_hash>{value.body_hash}; + + vb["msg_data"] = USERVER_NAMESPACE::chaotic::Variant< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataRaw>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataDecryptedText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataEncryptedText>>{value.msg_data}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::Message::_Type value) { + const auto result = k__ton_http__schemas__v2__Message___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::OutMsgQueueSize& lhs, const ::ton_http::schemas::v2::OutMsgQueueSize& rhs +) { + return lhs._type == rhs._type && lhs.id == rhs.id && lhs.size == rhs.size && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSize::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSize& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +OutMsgQueueSize::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> to +) { + return Parse(json, to); +} + + +OutMsgQueueSize Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::OutMsgQueueSize::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> +) { + const auto result = k__ton_http__schemas__v2__OutMsgQueueSize___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::OutMsgQueueSize::_Type", value) + ); +} + +::ton_http::schemas::v2::OutMsgQueueSize::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::OutMsgQueueSize::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::OutMsgQueueSize& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::OutMsgQueueSize::_Type>{value._type}; + + vb["id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.id}; + + vb["size"] = USERVER_NAMESPACE::chaotic::Primitive{value.size}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::OutMsgQueueSize::_Type value) { + const auto result = k__ton_http__schemas__v2__OutMsgQueueSize___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::OutMsgQueueSizes& lhs, const ::ton_http::schemas::v2::OutMsgQueueSizes& rhs +) { + return lhs._type == rhs._type && lhs.shards == rhs.shards && + lhs.ext_msg_queue_size_limit == rhs.ext_msg_queue_size_limit && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSizes::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSizes& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +OutMsgQueueSizes::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> to +) { + return Parse(json, to); +} + + +OutMsgQueueSizes Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::OutMsgQueueSizes::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> +) { + const auto result = k__ton_http__schemas__v2__OutMsgQueueSizes___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::OutMsgQueueSizes::_Type", value) + ); +} + +::ton_http::schemas::v2::OutMsgQueueSizes::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::OutMsgQueueSizes::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::OutMsgQueueSizes& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::OutMsgQueueSizes::_Type>{value._type}; + + vb["shards"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::OutMsgQueueSize>, + std::vector<::ton_http::schemas::v2::OutMsgQueueSize>>{value.shards}; + + vb["ext_msg_queue_size_limit"] = USERVER_NAMESPACE::chaotic::Primitive{value.ext_msg_queue_size_limit}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::OutMsgQueueSizes::_Type value) { + const auto result = k__ton_http__schemas__v2__OutMsgQueueSizes___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::ShardBlockLink& lhs, const ::ton_http::schemas::v2::ShardBlockLink& rhs +) { + return lhs._type == rhs._type && lhs.id == rhs.id && lhs.proof == rhs.proof && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockLink::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockLink& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ShardBlockLink::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> to +) { + return Parse(json, to); +} + + +ShardBlockLink Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ShardBlockLink::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> +) { + const auto result = k__ton_http__schemas__v2__ShardBlockLink___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ShardBlockLink::_Type", value) + ); +} + +::ton_http::schemas::v2::ShardBlockLink::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShardBlockLink::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ShardBlockLink& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ShardBlockLink::_Type>{value._type}; + + vb["id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.id}; + + vb["proof"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.proof + }; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ShardBlockLink::_Type value) { + const auto result = k__ton_http__schemas__v2__ShardBlockLink___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::ShardBlockProof& lhs, const ::ton_http::schemas::v2::ShardBlockProof& rhs +) { + return lhs._type == rhs._type && lhs.from == rhs.from && lhs.mc_id == rhs.mc_id && lhs.links == rhs.links && + lhs.mc_proof == rhs.mc_proof && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockProof::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockProof& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +ShardBlockProof::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> to +) { + return Parse(json, to); +} + + +ShardBlockProof Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::ShardBlockProof::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> +) { + const auto result = k__ton_http__schemas__v2__ShardBlockProof___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ShardBlockProof::_Type", value) + ); +} + +::ton_http::schemas::v2::ShardBlockProof::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShardBlockProof::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::ShardBlockProof& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ShardBlockProof::_Type>{value._type}; + + vb["from"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.from}; + + vb["mc_id"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>{value.mc_id}; + + vb["links"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ShardBlockLink>, + std::vector<::ton_http::schemas::v2::ShardBlockLink>>{value.links}; + + vb["mc_proof"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::BlockLinkBack>, + std::vector<::ton_http::schemas::v2::BlockLinkBack>>{value.mc_proof}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::ShardBlockProof::_Type value) { + const auto result = k__ton_http__schemas__v2__ShardBlockProof___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==(const ::ton_http::schemas::v2::Shards& lhs, const ::ton_http::schemas::v2::Shards& rhs) { + return lhs._type == rhs._type && lhs.shards == rhs.shards && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Shards::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Shards& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +Shards::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> to +) { + return Parse(json, to); +} + + +Shards Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::Shards::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> +) { + const auto result = k__ton_http__schemas__v2__Shards___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::Shards::_Type", value) + ); +} + +::ton_http::schemas::v2::Shards::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Shards::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::Shards& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::Shards::_Type>{value._type}; + + vb["shards"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, + std::vector<::ton_http::schemas::v2::TonBlockIdExt>>{value.shards}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::Shards::_Type value) { + const auto result = k__ton_http__schemas__v2__Shards___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::TonlibErrorResponse& lhs, const ::ton_http::schemas::v2::TonlibErrorResponse& rhs +) { + return lhs.ok == rhs.ok && lhs.error == rhs.error && lhs.code == rhs.code && lhs._extra == rhs._extra && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonlibErrorResponse& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +TonlibErrorResponse Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonlibErrorResponse> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::TonlibErrorResponse& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["ok"] = USERVER_NAMESPACE::chaotic::Primitive{value.ok}; + + if (value.error) { + vb["error"] = USERVER_NAMESPACE::chaotic::Primitive{*value.error}; + } + + if (value.code) { + vb["code"] = USERVER_NAMESPACE::chaotic::Primitive< + int, + USERVER_NAMESPACE::chaotic::Minimum<::ton_http::schemas::v2::TonlibErrorResponse::kCodeMinimum>, + USERVER_NAMESPACE::chaotic::Maximum<::ton_http::schemas::v2::TonlibErrorResponse::kCodeMaximum>>{*value.code}; + } + + if (value._extra) { + vb["@extra"] = USERVER_NAMESPACE::chaotic::Primitive{*value._extra}; + } + + + return vb.ExtractValue(); +} + + +bool operator==( + const ::ton_http::schemas::v2::TonlibResponse& lhs, const ::ton_http::schemas::v2::TonlibResponse& rhs +) { + return lhs.ok == rhs.ok && lhs.result == rhs.result && lhs._extra == rhs._extra && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonlibResponse& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +TonlibResponse Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonlibResponse> to +) { + return Parse(json, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::TonlibResponse& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["ok"] = USERVER_NAMESPACE::chaotic::Primitive{value.ok}; + + vb["result"] = USERVER_NAMESPACE::chaotic::Variant< + USERVER_NAMESPACE::chaotic::Primitive, + USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< + &::ton_http::schemas::v2::kTonlibObject_Settings, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddress>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfo>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectHash>>>{value.result}; + + vb["@extra"] = USERVER_NAMESPACE::chaotic::Primitive{value._extra}; + + + return vb.ExtractValue(); +} + + +bool operator==(const ::ton_http::schemas::v2::Transaction& lhs, const ::ton_http::schemas::v2::Transaction& rhs) { + return lhs._type == rhs._type && lhs.address == rhs.address && lhs.account == rhs.account && lhs.utime == rhs.utime && + lhs.data == rhs.data && lhs.transaction_id == rhs.transaction_id && lhs.fee == rhs.fee && + lhs.storage_fee == rhs.storage_fee && lhs.other_fee == rhs.other_fee && lhs.in_msg == rhs.in_msg && + lhs.out_msgs == rhs.out_msgs && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Transaction::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Transaction& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +Transaction::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> to +) { + return Parse(json, to); +} + + +Transaction Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::Transaction::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> +) { + const auto result = k__ton_http__schemas__v2__Transaction___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::Transaction::_Type", value) + ); +} + +::ton_http::schemas::v2::Transaction::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Transaction::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::Transaction& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::Transaction::_Type>{value._type}; + + vb["address"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountAddress>{value.address}; + + vb["account"] = USERVER_NAMESPACE::chaotic:: + WithType, ton_http::types::ton_addr>{value.account}; + + vb["utime"] = USERVER_NAMESPACE::chaotic::Primitive{value.utime}; + + vb["data"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::bytes>{ + value.data + }; + + vb["transaction_id"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::InternalTransactionId>{value.transaction_id}; + + vb["fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.fee + }; + + vb["storage_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.storage_fee + }; + + vb["other_fee"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.other_fee + }; + + vb["in_msg"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::Message>{value.in_msg}; + + vb["out_msgs"] = USERVER_NAMESPACE::chaotic::Array< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::Message>, + std::vector<::ton_http::schemas::v2::Message>>{value.out_msgs}; + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::Transaction::_Type value) { + const auto result = k__ton_http__schemas__v2__Transaction___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +bool operator==( + const ::ton_http::schemas::v2::WalletInformation& lhs, const ::ton_http::schemas::v2::WalletInformation& rhs +) { + return lhs._type == rhs._type && lhs.wallet == rhs.wallet && lhs.balance == rhs.balance && + lhs.account_state == rhs.account_state && lhs.last_transaction_id == rhs.last_transaction_id && + lhs.wallet_type == rhs.wallet_type && lhs.seqno == rhs.seqno && lhs.wallet_id == rhs.wallet_id && + lhs.is_signature_allowed == rhs.is_signature_allowed && true; +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::WalletInformation::_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::WalletInformation::Wallet_Type& value +) { + return lh << ToString(value); +} + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::WalletInformation& value +) { + return lh << ToString(USERVER_NAMESPACE::formats::json::ValueBuilder(value).ExtractValue()); +} + + +WalletInformation::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> to +) { + return Parse(json, to); +} + + +WalletInformation::Wallet_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> to +) { + return Parse(json, to); +} + + +WalletInformation Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation> to +) { + return Parse(json, to); +} + + +::ton_http::schemas::v2::WalletInformation::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> +) { + const auto result = k__ton_http__schemas__v2__WalletInformation___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::WalletInformation::_Type", value) + ); +} + +::ton_http::schemas::v2::WalletInformation::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> to +) { + return FromString(value, to); +} + + +::ton_http::schemas::v2::WalletInformation::Wallet_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> +) { + const auto result = k__ton_http__schemas__v2__WalletInformation__Wallet_Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + throw std::runtime_error( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::WalletInformation::Wallet_Type", value) + ); +} + +::ton_http::schemas::v2::WalletInformation::Wallet_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> to +) { + return FromString(value, to); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::WalletInformation::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::WalletInformation::Wallet_Type& value, + USERVER_NAMESPACE::formats::serialize::To +) { + return USERVER_NAMESPACE::formats::json::ValueBuilder(ToString(value)).ExtractValue(); +} + + +USERVER_NAMESPACE::formats::json::Value Serialize( + [[maybe_unused]] const ::ton_http::schemas::v2::WalletInformation& value, + USERVER_NAMESPACE::formats::serialize::To +) { + USERVER_NAMESPACE::formats::json::ValueBuilder vb = USERVER_NAMESPACE::formats::common::Type::kObject; + + + vb["@type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::WalletInformation::_Type>{value._type}; + + vb["wallet"] = USERVER_NAMESPACE::chaotic::Primitive{value.wallet}; + + vb["balance"] = + USERVER_NAMESPACE::chaotic::WithType, ton_http::types::int256>{ + value.balance + }; + + vb["account_state"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::AccountStateEnum>{value.account_state}; + + vb["last_transaction_id"] = + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::InternalTransactionId>{value.last_transaction_id}; + + if (value.wallet_type) { + vb["wallet_type"] = USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::WalletInformation::Wallet_Type>{ + *value.wallet_type + }; + } + + if (value.seqno) { + vb["seqno"] = USERVER_NAMESPACE::chaotic::Primitive{*value.seqno}; + } + + if (value.wallet_id) { + vb["wallet_id"] = USERVER_NAMESPACE::chaotic::Primitive{*value.wallet_id}; + } + + if (value.is_signature_allowed) { + vb["is_signature_allowed"] = USERVER_NAMESPACE::chaotic::Primitive{*value.is_signature_allowed}; + } + + + return vb.ExtractValue(); +} + + +std::string ToString(::ton_http::schemas::v2::WalletInformation::_Type value) { + const auto result = k__ton_http__schemas__v2__WalletInformation___Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +std::string ToString(::ton_http::schemas::v2::WalletInformation::Wallet_Type value) { + const auto result = k__ton_http__schemas__v2__WalletInformation__Wallet_Type_Mapping.TryFindByFirst(value); + if (result.has_value()) { + return std::string{*result}; + } + throw std::runtime_error(fmt::format("Invalid enum value: {}", static_cast(value))); +} + + +} // namespace v2 } // namespace schemas } // namespace ton_http -fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::DetectAddressResult::Given_Type>::format( - const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value, fmt::format_context& ctx +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::AccountAddress::_Type>::format( + const ::ton_http::schemas::v2::AccountAddress::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::AccountStateEnum>::format( + const ::ton_http::schemas::v2::AccountStateEnum& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::AccountStateRaw::_Type>::format( + const ::ton_http::schemas::v2::AccountStateRaw::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type>::format( + const ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::InternalTransactionId::_Type>::format( + const ::ton_http::schemas::v2::InternalTransactionId::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::TonBlockIdExt::_Type>::format( + const ::ton_http::schemas::v2::TonBlockIdExt::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::AddressInformation::_Type>::format( + const ::ton_http::schemas::v2::AddressInformation::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::BlockHeader::_Type>::format( + const ::ton_http::schemas::v2::BlockHeader::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::BlockLinkBack::_Type>::format( + const ::ton_http::schemas::v2::BlockLinkBack::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::BlockSignature::_Type>::format( + const ::ton_http::schemas::v2::BlockSignature::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ShortTxId::_Type>::format( + const ::ton_http::schemas::v2::ShortTxId::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::BlockTransactions::_Type>::format( + const ::ton_http::schemas::v2::BlockTransactions::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::TvmCell::_Type>::format( + const ::ton_http::schemas::v2::TvmCell::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ConfigInfo::_Type>::format( + const ::ton_http::schemas::v2::ConfigInfo::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ConsensusBlock::_Type>::format( + const ::ton_http::schemas::v2::ConsensusBlock::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::DetectAddress::_Type>::format( + const ::ton_http::schemas::v2::DetectAddress::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::DetectAddress::Given_Type>::format( + const ::ton_http::schemas::v2::DetectAddress::Given_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::DetectHash::_Type>::format( + const ::ton_http::schemas::v2::DetectHash::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::MsgDataRaw::_Type>::format( + const ::ton_http::schemas::v2::MsgDataRaw::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::MsgDataText::_Type>::format( + const ::ton_http::schemas::v2::MsgDataText::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::MsgDataDecryptedText::_Type>::format( + const ::ton_http::schemas::v2::MsgDataDecryptedText::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::MsgDataEncryptedText::_Type>::format( + const ::ton_http::schemas::v2::MsgDataEncryptedText::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ExtMessage::_Type>::format( + const ::ton_http::schemas::v2::ExtMessage::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ExtTransaction::_Type>::format( + const ::ton_http::schemas::v2::ExtTransaction::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ExtendedAddressInformation::_Type>::format( + const ::ton_http::schemas::v2::ExtendedAddressInformation::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::LibraryEntry::_Type>::format( + const ::ton_http::schemas::v2::LibraryEntry::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::LibraryResult::_Type>::format( + const ::ton_http::schemas::v2::LibraryResult::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type>::format( + const ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::MasterchainInfo::_Type>::format( + const ::ton_http::schemas::v2::MasterchainInfo::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::Message::_Type>::format( + const ::ton_http::schemas::v2::Message::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::OutMsgQueueSize::_Type>::format( + const ::ton_http::schemas::v2::OutMsgQueueSize::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::OutMsgQueueSizes::_Type>::format( + const ::ton_http::schemas::v2::OutMsgQueueSizes::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ShardBlockLink::_Type>::format( + const ::ton_http::schemas::v2::ShardBlockLink::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::ShardBlockProof::_Type>::format( + const ::ton_http::schemas::v2::ShardBlockProof::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::Shards::_Type>::format( + const ::ton_http::schemas::v2::Shards::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::Transaction::_Type>::format( + const ::ton_http::schemas::v2::Transaction::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::WalletInformation::_Type>::format( + const ::ton_http::schemas::v2::WalletInformation::_Type& value, fmt::format_context& ctx +) const { + return fmt::format_to(ctx.out(), "{}", ToString(value)); +} + + +fmt::format_context::iterator fmt::formatter<::ton_http::schemas::v2::WalletInformation::Wallet_Type>::format( + const ::ton_http::schemas::v2::WalletInformation::Wallet_Type& value, fmt::format_context& ctx ) const { return fmt::format_to(ctx.out(), "{}", ToString(value)); } diff --git a/ton-http-api/src/schemas/v2.hpp b/ton-http-api/src/schemas/v2.hpp index 28604da..8dca5f2 100644 --- a/ton-http-api/src/schemas/v2.hpp +++ b/ton-http-api/src/schemas/v2.hpp @@ -7,12 +7,16 @@ #include #include #include +#include +#include #include -#include +#include +#include #include #include #include #include +#include #include #include @@ -25,155 +29,352 @@ namespace schemas { namespace v2 { -// Base64 form of address variant -struct DetectAddressBase64Variant { - std::string b64{}; - std::string b64url{}; +struct AccountAddress { + enum class _Type { + kAccountaddress, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kAccountaddress, + }; + + + ::ton_http::schemas::v2::AccountAddress::_Type _type{::ton_http::schemas::v2::AccountAddress::_Type::kAccountaddress}; + std::optional account_address{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::AccountAddress& lhs, const ::ton_http::schemas::v2::AccountAddress& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountAddress::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountAddress& value +); + + +AccountAddress::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> +); + + +AccountAddress Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress> +); + + +AccountAddress::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> +); + + +AccountAddress::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AccountAddress::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AccountAddress& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::AccountAddress::_Type value); + + +enum class AccountStateEnum { + kUninitialized, + kActive, + kFrozen, +}; + +static constexpr AccountStateEnum kAccountStateEnumValues[] = { + AccountStateEnum::kUninitialized, + AccountStateEnum::kActive, + AccountStateEnum::kFrozen, +}; + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountStateEnum& value +); + + +AccountStateEnum Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> +); + + +AccountStateEnum FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> +); + + +AccountStateEnum Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AccountStateEnum& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::AccountStateEnum value); + + +using Bytes = std::string; + + +using TonHash = std::string; + + +struct AccountStateRaw { + enum class _Type { + kRawAccountstate, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kRawAccountstate, + }; + + + ::ton_http::schemas::v2::AccountStateRaw::_Type _type{ + ::ton_http::schemas::v2::AccountStateRaw::_Type::kRawAccountstate + }; + ton_http::types::bytes code{}; + ton_http::types::bytes data{}; + ton_http::types::ton_hash frozen_hash{}; }; bool operator==( - const ::ton_http::schemas::v2::DetectAddressBase64Variant& lhs, - const ::ton_http::schemas::v2::DetectAddressBase64Variant& rhs + const ::ton_http::schemas::v2::AccountStateRaw& lhs, const ::ton_http::schemas::v2::AccountStateRaw& rhs ); USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressBase64Variant& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountStateRaw::_Type& value ); -DetectAddressBase64Variant Parse( +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AccountStateRaw& value +); + + +AccountStateRaw::_Type Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> +); + + +AccountStateRaw Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw> +); + + +AccountStateRaw::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> +); + + +AccountStateRaw::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> ); USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::DetectAddressBase64Variant& value, + const ::ton_http::schemas::v2::AccountStateRaw::_Type& value, USERVER_NAMESPACE::formats::serialize::To ); -// Information about the address. -struct DetectAddressResult { - enum class Given_Type { - kRawForm, - kFriendlyBounceable, - kFriendlyNonBounceable, +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AccountStateRaw& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::AccountStateRaw::_Type value); + + +using Int256 = std::string; + + +using AddressBalance = std::string; + + +struct ExtraCurrencyBalance { + enum class _Type { + kExtracurrency, }; - static constexpr Given_Type kGiven_TypeValues[] = { - Given_Type::kRawForm, - Given_Type::kFriendlyBounceable, - Given_Type::kFriendlyNonBounceable, + static constexpr _Type k_TypeValues[] = { + _Type::kExtracurrency, }; - std::string _type{"utils.detectAddress"}; - std::string raw_form{}; - ::ton_http::schemas::v2::DetectAddressBase64Variant bounceable{}; - ::ton_http::schemas::v2::DetectAddressBase64Variant non_bounceable{}; - ::ton_http::schemas::v2::DetectAddressResult::Given_Type given_type{}; - bool test_only{}; + ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type _type{ + ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type::kExtracurrency + }; + std::int32_t id{}; + ton_http::types::int256 amount{}; }; bool operator==( - const ::ton_http::schemas::v2::DetectAddressResult& lhs, const ::ton_http::schemas::v2::DetectAddressResult& rhs + const ::ton_http::schemas::v2::ExtraCurrencyBalance& lhs, const ::ton_http::schemas::v2::ExtraCurrencyBalance& rhs ); USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type& value ); USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressResult& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtraCurrencyBalance& value ); -DetectAddressResult::Given_Type Parse( +ExtraCurrencyBalance::_Type Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> ); -DetectAddressResult Parse( +ExtraCurrencyBalance Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult> + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance> ); -DetectAddressResult::Given_Type FromString( - std::string_view value, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +ExtraCurrencyBalance::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> ); -DetectAddressResult::Given_Type Parse( - std::string_view value, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +ExtraCurrencyBalance::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> ); USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::DetectAddressResult::Given_Type& value, + const ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type& value, USERVER_NAMESPACE::formats::serialize::To ); USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::DetectAddressResult& value, + const ::ton_http::schemas::v2::ExtraCurrencyBalance& value, USERVER_NAMESPACE::formats::serialize::To ); -std::string ToString(::ton_http::schemas::v2::DetectAddressResult::Given_Type value); +std::string ToString(::ton_http::schemas::v2::ExtraCurrencyBalance::_Type value); + + +// Internal transaction identifier. +struct InternalTransactionId { + enum class _Type { + kInternalTransactionid, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kInternalTransactionid, + }; -struct DetectHashResult { - std::string _type{"utils.detectHash"}; - std::optional b64{}; - std::optional b64url{}; - std::optional hex{}; + ::ton_http::schemas::v2::InternalTransactionId::_Type _type{ + ::ton_http::schemas::v2::InternalTransactionId::_Type::kInternalTransactionid + }; + std::uint64_t lt{}; + ton_http::types::ton_hash hash{}; }; bool operator==( - const ::ton_http::schemas::v2::DetectHashResult& lhs, const ::ton_http::schemas::v2::DetectHashResult& rhs + const ::ton_http::schemas::v2::InternalTransactionId& lhs, const ::ton_http::schemas::v2::InternalTransactionId& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::InternalTransactionId::_Type& value ); USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHashResult& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::InternalTransactionId& value +); + + +InternalTransactionId::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> ); -DetectHashResult Parse( +InternalTransactionId Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHashResult> + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId> +); + + +InternalTransactionId::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> +); + + +InternalTransactionId::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> ); USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::DetectHashResult& value, + const ::ton_http::schemas::v2::InternalTransactionId::_Type& value, USERVER_NAMESPACE::formats::serialize::To ); -using TonShardId = std::string; +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::InternalTransactionId& value, + USERVER_NAMESPACE::formats::serialize::To +); -using TonHash = std::string; +std::string ToString(::ton_http::schemas::v2::InternalTransactionId::_Type value); // Extended block identifier. struct TonBlockIdExt { - std::string _type{"ton.blockIdExt"}; + enum class _Type { + kTonBlockidext, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kTonBlockidext, + }; + + + ::ton_http::schemas::v2::TonBlockIdExt::_Type _type{::ton_http::schemas::v2::TonBlockIdExt::_Type::kTonBlockidext}; int workchain{}; - ton_http::types::shard_id shard{}; + std::int64_t shard{}; int seqno{}; ton_http::types::ton_hash root_hash{}; ton_http::types::ton_hash file_hash{}; @@ -183,110 +384,2904 @@ struct TonBlockIdExt { bool operator==(const ::ton_http::schemas::v2::TonBlockIdExt& lhs, const ::ton_http::schemas::v2::TonBlockIdExt& rhs); +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt::_Type& value +); + + USERVER_NAMESPACE::logging::LogHelper& operator<<( USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonBlockIdExt& value ); +TonBlockIdExt::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> +); + + TonBlockIdExt Parse( USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> ); +TonBlockIdExt::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> +); + + +TonBlockIdExt::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TonBlockIdExt::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + USERVER_NAMESPACE::formats::json::Value Serialize( const ::ton_http::schemas::v2::TonBlockIdExt& value, USERVER_NAMESPACE::formats::serialize::To ); -// Information about the latest masterchain block. -struct MasterchainInfoResult { - std::string _type{"blocks.masterchainInfo"}; - ::ton_http::schemas::v2::TonBlockIdExt last{}; - ton_http::types::ton_hash state_root_hash{}; - ::ton_http::schemas::v2::TonBlockIdExt init{}; +std::string ToString(::ton_http::schemas::v2::TonBlockIdExt::_Type value); + + +struct AddressInformation { + enum class _Type { + kRawFullaccountstate, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kRawFullaccountstate, + }; + + + ::ton_http::schemas::v2::AddressInformation::_Type _type{ + ::ton_http::schemas::v2::AddressInformation::_Type::kRawFullaccountstate + }; + ton_http::types::int256 balance{}; + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance> extra_currencies{}; + ::ton_http::schemas::v2::InternalTransactionId last_transaction_id{}; + ::ton_http::schemas::v2::TonBlockIdExt block_id{}; + ton_http::types::bytes code{}; + ton_http::types::bytes data{}; + ton_http::types::ton_hash frozen_hash{}; + int sync_utime{}; + ::ton_http::schemas::v2::AccountStateEnum state{}; + std::optional suspended{}; }; bool operator==( - const ::ton_http::schemas::v2::MasterchainInfoResult& lhs, const ::ton_http::schemas::v2::MasterchainInfoResult& rhs + const ::ton_http::schemas::v2::AddressInformation& lhs, const ::ton_http::schemas::v2::AddressInformation& rhs ); USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfoResult& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AddressInformation::_Type& value ); -MasterchainInfoResult Parse( +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::AddressInformation& value +); + + +AddressInformation::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> +); + + +AddressInformation Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfoResult> + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation> +); + + +AddressInformation::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> +); + + +AddressInformation::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> ); USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::MasterchainInfoResult& value, + const ::ton_http::schemas::v2::AddressInformation::_Type& value, USERVER_NAMESPACE::formats::serialize::To ); -using TonAddr = std::string; +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::AddressInformation& value, + USERVER_NAMESPACE::formats::serialize::To +); -[[maybe_unused]] static constexpr USERVER_NAMESPACE::chaotic::OneOfStringSettings kTonObject_Settings = { - "@type", USERVER_NAMESPACE::utils::TrivialSet([](auto selector) { - return selector().template Type().Case("ton.blockIdExt").Case("blocks.masterchainInfo"); - }) -}; +std::string ToString(::ton_http::schemas::v2::AddressInformation::_Type value); -using TonObject = std::variant<::ton_http::schemas::v2::TonBlockIdExt, ::ton_http::schemas::v2::MasterchainInfoResult>; +using AddressState = ::ton_http::schemas::v2::AccountStateEnum; -// TonResponse -struct TonResponse { - using Result = - std::variant>; +// Block header information. +struct BlockHeader { + enum class _Type { + kBlocksHeader, + }; + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksHeader, + }; - bool ok{}; - std::optional<::ton_http::schemas::v2::TonResponse::Result> result{}; - std::optional error{}; - std::optional code{}; - std::string _extra{}; + + ::ton_http::schemas::v2::BlockHeader::_Type _type{::ton_http::schemas::v2::BlockHeader::_Type::kBlocksHeader}; + ::ton_http::schemas::v2::TonBlockIdExt id{}; + int global_id{}; + int version{}; + bool after_merge{}; + bool after_split{}; + bool before_split{}; + bool want_merge{}; + bool want_split{}; + int validator_list_hash_short{}; + int catchain_seqno{}; + int min_ref_mc_seqno{}; + bool is_key_block{}; + int prev_key_block_seqno{}; + std::uint64_t start_lt{}; + std::uint64_t end_lt{}; + int gen_utime{}; + std::vector<::ton_http::schemas::v2::TonBlockIdExt> prev_blocks{}; + + + USERVER_NAMESPACE::formats::json::Value extra; }; -bool operator==(const ::ton_http::schemas::v2::TonResponse& lhs, const ::ton_http::schemas::v2::TonResponse& rhs); +bool operator==(const ::ton_http::schemas::v2::BlockHeader& lhs, const ::ton_http::schemas::v2::BlockHeader& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockHeader::_Type& value +); USERVER_NAMESPACE::logging::LogHelper& operator<<( - USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonResponse& value + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockHeader& value +); + + +BlockHeader::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> ); -TonResponse Parse( +BlockHeader Parse( USERVER_NAMESPACE::formats::json::Value json, - USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonResponse> + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader> +); + + +BlockHeader::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> +); + + +BlockHeader::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> ); USERVER_NAMESPACE::formats::json::Value Serialize( - const ::ton_http::schemas::v2::TonResponse& value, + const ::ton_http::schemas::v2::BlockHeader::_Type& value, USERVER_NAMESPACE::formats::serialize::To ); -} // namespace v2 -} // namespace schemas -} // namespace ton_http +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockHeader& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::BlockHeader::_Type value); + + +struct BlockLinkBack { + enum class _Type { + kBlocksBlocklinkback, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksBlocklinkback, + }; + + + ::ton_http::schemas::v2::BlockLinkBack::_Type _type{ + ::ton_http::schemas::v2::BlockLinkBack::_Type::kBlocksBlocklinkback + }; + bool to_key_block{}; + ::ton_http::schemas::v2::TonBlockIdExt from{}; + ::ton_http::schemas::v2::TonBlockIdExt to{}; + ton_http::types::bytes dest_proof{}; + ton_http::types::bytes proof{}; + ton_http::types::bytes state_proof{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::BlockLinkBack& lhs, const ::ton_http::schemas::v2::BlockLinkBack& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockLinkBack::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockLinkBack& value +); + + +BlockLinkBack::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> +); + + +BlockLinkBack Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack> +); + + +BlockLinkBack::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> +); + + +BlockLinkBack::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockLinkBack::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockLinkBack& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::BlockLinkBack::_Type value); + + +struct BlockSignature { + enum class _Type { + kBlocksSignature, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksSignature, + }; + + + ::ton_http::schemas::v2::BlockSignature::_Type _type{ + ::ton_http::schemas::v2::BlockSignature::_Type::kBlocksSignature + }; + ton_http::types::ton_hash node_id_short{}; + ton_http::types::bytes signature{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::BlockSignature& lhs, const ::ton_http::schemas::v2::BlockSignature& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockSignature::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockSignature& value +); + + +BlockSignature::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> +); + + +BlockSignature Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature> +); + + +BlockSignature::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> +); + + +BlockSignature::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockSignature::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockSignature& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::BlockSignature::_Type value); + + +using TonAddr = std::string; + + +// Short transaction identifier +struct ShortTxId { + enum class _Type { + kBlocksShorttxid, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksShorttxid, + }; + + + ::ton_http::schemas::v2::ShortTxId::_Type _type{::ton_http::schemas::v2::ShortTxId::_Type::kBlocksShorttxid}; + int mode{}; + ton_http::types::ton_addr account{}; + std::uint64_t lt{}; + ton_http::types::ton_hash hash{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::ShortTxId& lhs, const ::ton_http::schemas::v2::ShortTxId& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShortTxId::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShortTxId& value +); + + +ShortTxId::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> +); + + +ShortTxId Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId> +); + + +ShortTxId::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> +); + + +ShortTxId::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShortTxId::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShortTxId& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ShortTxId::_Type value); + + +// Block transactions information +struct BlockTransactions { + enum class _Type { + kBlocksTransactions, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksTransactions, + }; + + + ::ton_http::schemas::v2::BlockTransactions::_Type _type{ + ::ton_http::schemas::v2::BlockTransactions::_Type::kBlocksTransactions + }; + ::ton_http::schemas::v2::TonBlockIdExt id{}; + int req_count{}; + bool incomplete{}; + std::vector<::ton_http::schemas::v2::ShortTxId> transactions{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::BlockTransactions& lhs, const ::ton_http::schemas::v2::BlockTransactions& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockTransactions::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::BlockTransactions& value +); + + +BlockTransactions::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> +); + + +BlockTransactions Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions> +); + + +BlockTransactions::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> +); + + +BlockTransactions::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockTransactions::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::BlockTransactions& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::BlockTransactions::_Type value); + + +struct TvmCell { + enum class _Type { + kTvmCell, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kTvmCell, + }; + + + ::ton_http::schemas::v2::TvmCell::_Type _type{::ton_http::schemas::v2::TvmCell::_Type::kTvmCell}; + ton_http::types::bytes bytes{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::TvmCell& lhs, const ::ton_http::schemas::v2::TvmCell& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TvmCell::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TvmCell& value +); + + +TvmCell::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> +); + + +TvmCell Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell> +); + + +TvmCell::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> +); + + +TvmCell::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TvmCell::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TvmCell& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::TvmCell::_Type value); + + +struct ConfigInfo { + enum class _Type { + kConfiginfo, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kConfiginfo, + }; + + + ::ton_http::schemas::v2::ConfigInfo::_Type _type{::ton_http::schemas::v2::ConfigInfo::_Type::kConfiginfo}; + ::ton_http::schemas::v2::TvmCell config{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::ConfigInfo& lhs, const ::ton_http::schemas::v2::ConfigInfo& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConfigInfo::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConfigInfo& value +); + + +ConfigInfo::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> +); + + +ConfigInfo Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo> +); + + +ConfigInfo::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> +); + + +ConfigInfo::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ConfigInfo::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ConfigInfo& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ConfigInfo::_Type value); + + +struct ConsensusBlock { + enum class _Type { + kExtConsensusblock, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kExtConsensusblock, + }; + + + ::ton_http::schemas::v2::ConsensusBlock::_Type _type{ + ::ton_http::schemas::v2::ConsensusBlock::_Type::kExtConsensusblock + }; + std::int32_t consensus_block{}; + std::int32_t timestamp{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::ConsensusBlock& lhs, const ::ton_http::schemas::v2::ConsensusBlock& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConsensusBlock::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ConsensusBlock& value +); + + +ConsensusBlock::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> +); + + +ConsensusBlock Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock> +); + + +ConsensusBlock::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> +); + + +ConsensusBlock::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ConsensusBlock::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ConsensusBlock& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ConsensusBlock::_Type value); + + +// Base64 form of address variant +struct DetectAddressBase64Variant { + std::string b64{}; + std::string b64url{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressBase64Variant& lhs, + const ::ton_http::schemas::v2::DetectAddressBase64Variant& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressBase64Variant& value +); + + +DetectAddressBase64Variant Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddressBase64Variant& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +// Information about the address. +struct DetectAddress { + enum class _Type { + kUtilsDetectedaddress, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kUtilsDetectedaddress, + }; + + + enum class Given_Type { + kRawForm, + kFriendlyBounceable, + kFriendlyNonBounceable, + }; + + static constexpr Given_Type kGiven_TypeValues[] = { + Given_Type::kRawForm, + Given_Type::kFriendlyBounceable, + Given_Type::kFriendlyNonBounceable, + }; + + + ::ton_http::schemas::v2::DetectAddress::_Type _type{ + ::ton_http::schemas::v2::DetectAddress::_Type::kUtilsDetectedaddress + }; + std::string raw_form{}; + ::ton_http::schemas::v2::DetectAddressBase64Variant bounceable{}; + ::ton_http::schemas::v2::DetectAddressBase64Variant non_bounceable{}; + ::ton_http::schemas::v2::DetectAddress::Given_Type given_type{}; + bool test_only{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::DetectAddress& lhs, const ::ton_http::schemas::v2::DetectAddress& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddress::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddress::Given_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddress& value +); + + +DetectAddress::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> +); + + +DetectAddress::Given_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> +); + + +DetectAddress Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress> +); + + +DetectAddress::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> +); + + +DetectAddress::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> +); + + +DetectAddress::Given_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> +); + + +DetectAddress::Given_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddress::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddress::Given_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddress& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::DetectAddress::_Type value); + + +std::string ToString(::ton_http::schemas::v2::DetectAddress::Given_Type value); + + +struct DetectAddressRequest { + ton_http::types::ton_addr address{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::DetectAddressRequest& lhs, const ::ton_http::schemas::v2::DetectAddressRequest& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectAddressRequest& value +); + + +DetectAddressRequest Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressRequest> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectAddressRequest& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +struct DetectHash { + enum class _Type { + kUtilsDetectedhash, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kUtilsDetectedhash, + }; + + + ::ton_http::schemas::v2::DetectHash::_Type _type{::ton_http::schemas::v2::DetectHash::_Type::kUtilsDetectedhash}; + std::string b64{}; + std::string b64url{}; + std::string hex{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::DetectHash& lhs, const ::ton_http::schemas::v2::DetectHash& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHash::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::DetectHash& value +); + + +DetectHash::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> +); + + +DetectHash Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash> +); + + +DetectHash::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> +); + + +DetectHash::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectHash::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::DetectHash& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::DetectHash::_Type value); + + +struct EmptyRequest {}; + + +bool operator==(const ::ton_http::schemas::v2::EmptyRequest& lhs, const ::ton_http::schemas::v2::EmptyRequest& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::EmptyRequest& value +); + + +EmptyRequest Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::EmptyRequest> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::EmptyRequest& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +struct MsgDataRaw { + enum class _Type { + kMsgDataraw, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kMsgDataraw, + }; + + + ::ton_http::schemas::v2::MsgDataRaw::_Type _type{::ton_http::schemas::v2::MsgDataRaw::_Type::kMsgDataraw}; + std::optional body{}; + std::optional init_state{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::MsgDataRaw& lhs, const ::ton_http::schemas::v2::MsgDataRaw& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataRaw::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataRaw& value +); + + +MsgDataRaw::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> +); + + +MsgDataRaw Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw> +); + + +MsgDataRaw::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> +); + + +MsgDataRaw::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataRaw::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataRaw& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::MsgDataRaw::_Type value); + + +struct MsgDataText { + enum class _Type { + kMsgDatatext, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kMsgDatatext, + }; + + + ::ton_http::schemas::v2::MsgDataText::_Type _type{::ton_http::schemas::v2::MsgDataText::_Type::kMsgDatatext}; + std::optional text{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::MsgDataText& lhs, const ::ton_http::schemas::v2::MsgDataText& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataText::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataText& value +); + + +MsgDataText::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> +); + + +MsgDataText Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText> +); + + +MsgDataText::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> +); + + +MsgDataText::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataText::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataText& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::MsgDataText::_Type value); + + +struct MsgDataDecryptedText { + enum class _Type { + kMsgDatadecryptedtext, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kMsgDatadecryptedtext, + }; + + + ::ton_http::schemas::v2::MsgDataDecryptedText::_Type _type{ + ::ton_http::schemas::v2::MsgDataDecryptedText::_Type::kMsgDatadecryptedtext + }; + std::optional text{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::MsgDataDecryptedText& lhs, const ::ton_http::schemas::v2::MsgDataDecryptedText& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataDecryptedText::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataDecryptedText& value +); + + +MsgDataDecryptedText::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> +); + + +MsgDataDecryptedText Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText> +); + + +MsgDataDecryptedText::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> +); + + +MsgDataDecryptedText::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataDecryptedText::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataDecryptedText& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::MsgDataDecryptedText::_Type value); + + +struct MsgDataEncryptedText { + enum class _Type { + kMsgDataencryptedtext, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kMsgDataencryptedtext, + }; + + + ::ton_http::schemas::v2::MsgDataEncryptedText::_Type _type{ + ::ton_http::schemas::v2::MsgDataEncryptedText::_Type::kMsgDataencryptedtext + }; + std::optional text{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::MsgDataEncryptedText& lhs, const ::ton_http::schemas::v2::MsgDataEncryptedText& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataEncryptedText::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MsgDataEncryptedText& value +); + + +MsgDataEncryptedText::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> +); + + +MsgDataEncryptedText Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText> +); + + +MsgDataEncryptedText::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> +); + + +MsgDataEncryptedText::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataEncryptedText::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MsgDataEncryptedText& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::MsgDataEncryptedText::_Type value); + + +struct ExtMessage { + enum class _Type { + kExtMessage, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kExtMessage, + }; + + + using Msg_Data = std::variant< + ::ton_http::schemas::v2::MsgDataRaw, + ::ton_http::schemas::v2::MsgDataText, + ::ton_http::schemas::v2::MsgDataDecryptedText, + ::ton_http::schemas::v2::MsgDataEncryptedText>; + + + ::ton_http::schemas::v2::ExtMessage::_Type _type{::ton_http::schemas::v2::ExtMessage::_Type::kExtMessage}; + ton_http::types::ton_hash hash{}; + ton_http::types::ton_addr source{}; + ton_http::types::ton_addr destination{}; + ton_http::types::int256 value{}; + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance> extra_currencies{}; + ton_http::types::int256 fwd_fee{}; + ton_http::types::int256 ihr_fee{}; + std::uint64_t created_lt{}; + ton_http::types::ton_hash body_hash{}; + ::ton_http::schemas::v2::ExtMessage::Msg_Data msg_data{}; + std::optional message{}; + std::optional message_decode_error{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::ExtMessage& lhs, const ::ton_http::schemas::v2::ExtMessage& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtMessage::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtMessage& value +); + + +ExtMessage::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> +); + + +ExtMessage Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage> +); + + +ExtMessage::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> +); + + +ExtMessage::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtMessage::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtMessage& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ExtMessage::_Type value); + + +struct ExtTransaction { + enum class _Type { + kExtTransaction, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kExtTransaction, + }; + + + ::ton_http::schemas::v2::ExtTransaction::_Type _type{::ton_http::schemas::v2::ExtTransaction::_Type::kExtTransaction}; + ::ton_http::schemas::v2::AccountAddress address{}; + int utime{}; + ton_http::types::bytes data{}; + ::ton_http::schemas::v2::InternalTransactionId transaction_id{}; + ton_http::types::int256 fee{}; + ton_http::types::int256 storage_fee{}; + ton_http::types::int256 other_fee{}; + ::ton_http::schemas::v2::ExtMessage in_msg{}; + std::vector<::ton_http::schemas::v2::ExtMessage> out_msgs{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::ExtTransaction& lhs, const ::ton_http::schemas::v2::ExtTransaction& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtTransaction::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtTransaction& value +); + + +ExtTransaction::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> +); + + +ExtTransaction Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction> +); + + +ExtTransaction::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> +); + + +ExtTransaction::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtTransaction::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtTransaction& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ExtTransaction::_Type value); + + +struct ExtendedAddressInformation { + enum class _Type { + kFullaccountstate, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kFullaccountstate, + }; + + + ::ton_http::schemas::v2::ExtendedAddressInformation::_Type _type{ + ::ton_http::schemas::v2::ExtendedAddressInformation::_Type::kFullaccountstate + }; + ::ton_http::schemas::v2::AccountAddress address{}; + ton_http::types::int256 balance{}; + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance> extra_currencies{}; + ::ton_http::schemas::v2::InternalTransactionId last_transaction_id{}; + ::ton_http::schemas::v2::TonBlockIdExt block_id{}; + int sync_utime{}; + ::ton_http::schemas::v2::AccountStateRaw account_state{}; + int revision{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::ExtendedAddressInformation& lhs, + const ::ton_http::schemas::v2::ExtendedAddressInformation& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtendedAddressInformation::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ExtendedAddressInformation& value +); + + +ExtendedAddressInformation::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> +); + + +ExtendedAddressInformation Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation> +); + + +ExtendedAddressInformation::_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> +); + + +ExtendedAddressInformation::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtendedAddressInformation::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ExtendedAddressInformation& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ExtendedAddressInformation::_Type value); + + +struct LibraryEntry { + enum class _Type { + kSmcLibraryentry, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kSmcLibraryentry, + }; + + + ::ton_http::schemas::v2::LibraryEntry::_Type _type{::ton_http::schemas::v2::LibraryEntry::_Type::kSmcLibraryentry}; + ton_http::types::ton_hash hash{}; + ton_http::types::bytes data{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::LibraryEntry& lhs, const ::ton_http::schemas::v2::LibraryEntry& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryEntry::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryEntry& value +); + + +LibraryEntry::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> +); + + +LibraryEntry Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry> +); + + +LibraryEntry::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> +); + + +LibraryEntry::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::LibraryEntry::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::LibraryEntry& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::LibraryEntry::_Type value); + + +struct LibraryResult { + enum class _Type { + kSmcLibraryresult, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kSmcLibraryresult, + }; + + + ::ton_http::schemas::v2::LibraryResult::_Type _type{::ton_http::schemas::v2::LibraryResult::_Type::kSmcLibraryresult}; + std::vector<::ton_http::schemas::v2::LibraryEntry> result{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::LibraryResult& lhs, const ::ton_http::schemas::v2::LibraryResult& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryResult::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::LibraryResult& value +); + + +LibraryResult::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> +); + + +LibraryResult Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult> +); + + +LibraryResult::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> +); + + +LibraryResult::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::LibraryResult::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::LibraryResult& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::LibraryResult::_Type value); + + +using LookupBlock = ::ton_http::schemas::v2::TonBlockIdExt; + + +struct MasterchainBlockSignatures { + enum class _Type { + kBlocksBlocksignatures, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksBlocksignatures, + }; + + + ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type _type{ + ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type::kBlocksBlocksignatures + }; + ::ton_http::schemas::v2::TonBlockIdExt id{}; + std::vector<::ton_http::schemas::v2::BlockSignature> signatures{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::MasterchainBlockSignatures& lhs, + const ::ton_http::schemas::v2::MasterchainBlockSignatures& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainBlockSignatures& value +); + + +MasterchainBlockSignatures::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> +); + + +MasterchainBlockSignatures Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures> +); + + +MasterchainBlockSignatures::_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> +); + + +MasterchainBlockSignatures::_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainBlockSignatures& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::MasterchainBlockSignatures::_Type value); + + +// Information about the latest masterchain block. +struct MasterchainInfo { + enum class _Type { + kBlocksMasterchaininfo, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksMasterchaininfo, + }; + + + ::ton_http::schemas::v2::MasterchainInfo::_Type _type{ + ::ton_http::schemas::v2::MasterchainInfo::_Type::kBlocksMasterchaininfo + }; + ::ton_http::schemas::v2::TonBlockIdExt last{}; + ton_http::types::ton_hash state_root_hash{}; + ::ton_http::schemas::v2::TonBlockIdExt init{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::MasterchainInfo& lhs, const ::ton_http::schemas::v2::MasterchainInfo& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfo::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::MasterchainInfo& value +); + + +MasterchainInfo::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> +); + + +MasterchainInfo Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo> +); + + +MasterchainInfo::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> +); + + +MasterchainInfo::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainInfo::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::MasterchainInfo& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::MasterchainInfo::_Type value); + + +using MasterchainInfoRequest = ::ton_http::schemas::v2::EmptyRequest; + + +struct Message { + enum class _Type { + kRawMessage, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kRawMessage, + }; + + + using Msg_Data = std::variant< + ::ton_http::schemas::v2::MsgDataRaw, + ::ton_http::schemas::v2::MsgDataText, + ::ton_http::schemas::v2::MsgDataDecryptedText, + ::ton_http::schemas::v2::MsgDataEncryptedText>; + + + ::ton_http::schemas::v2::Message::_Type _type{::ton_http::schemas::v2::Message::_Type::kRawMessage}; + ton_http::types::ton_hash hash{}; + ::ton_http::schemas::v2::AccountAddress source{}; + ::ton_http::schemas::v2::AccountAddress destination{}; + ton_http::types::int256 value{}; + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance> extra_currencies{}; + ton_http::types::int256 fwd_fee{}; + ton_http::types::int256 ihr_fee{}; + std::uint64_t created_lt{}; + ton_http::types::ton_hash body_hash{}; + ::ton_http::schemas::v2::Message::Msg_Data msg_data{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::Message& lhs, const ::ton_http::schemas::v2::Message& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Message::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Message& value +); + + +Message::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> +); + + +Message Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message> +); + + +Message::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> +); + + +Message::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Message::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Message& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::Message::_Type value); + + +struct OutMsgQueueSize { + enum class _Type { + kBlocksOutmsgqueuesize, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksOutmsgqueuesize, + }; + + + ::ton_http::schemas::v2::OutMsgQueueSize::_Type _type{ + ::ton_http::schemas::v2::OutMsgQueueSize::_Type::kBlocksOutmsgqueuesize + }; + ::ton_http::schemas::v2::TonBlockIdExt id{}; + int size{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::OutMsgQueueSize& lhs, const ::ton_http::schemas::v2::OutMsgQueueSize& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSize::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSize& value +); + + +OutMsgQueueSize::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> +); + + +OutMsgQueueSize Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize> +); + + +OutMsgQueueSize::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> +); + + +OutMsgQueueSize::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::OutMsgQueueSize::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::OutMsgQueueSize& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::OutMsgQueueSize::_Type value); + + +struct OutMsgQueueSizes { + enum class _Type { + kBlocksOutmsgqueuesizes, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksOutmsgqueuesizes, + }; + + + ::ton_http::schemas::v2::OutMsgQueueSizes::_Type _type{ + ::ton_http::schemas::v2::OutMsgQueueSizes::_Type::kBlocksOutmsgqueuesizes + }; + std::vector<::ton_http::schemas::v2::OutMsgQueueSize> shards{}; + int ext_msg_queue_size_limit{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::OutMsgQueueSizes& lhs, const ::ton_http::schemas::v2::OutMsgQueueSizes& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSizes::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::OutMsgQueueSizes& value +); + + +OutMsgQueueSizes::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> +); + + +OutMsgQueueSizes Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes> +); + + +OutMsgQueueSizes::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> +); + + +OutMsgQueueSizes::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::OutMsgQueueSizes::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::OutMsgQueueSizes& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::OutMsgQueueSizes::_Type value); + + +using PackAddress = std::string; + + +struct ShardBlockLink { + enum class _Type { + kBlocksShardblocklink, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksShardblocklink, + }; + + + ::ton_http::schemas::v2::ShardBlockLink::_Type _type{ + ::ton_http::schemas::v2::ShardBlockLink::_Type::kBlocksShardblocklink + }; + ::ton_http::schemas::v2::TonBlockIdExt id{}; + ton_http::types::bytes proof{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::ShardBlockLink& lhs, const ::ton_http::schemas::v2::ShardBlockLink& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockLink::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockLink& value +); + + +ShardBlockLink::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> +); + + +ShardBlockLink Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink> +); + + +ShardBlockLink::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> +); + + +ShardBlockLink::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShardBlockLink::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShardBlockLink& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ShardBlockLink::_Type value); + + +struct ShardBlockProof { + enum class _Type { + kBlocksShardblockproof, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksShardblockproof, + }; + + + ::ton_http::schemas::v2::ShardBlockProof::_Type _type{ + ::ton_http::schemas::v2::ShardBlockProof::_Type::kBlocksShardblockproof + }; + ::ton_http::schemas::v2::TonBlockIdExt from{}; + ::ton_http::schemas::v2::TonBlockIdExt mc_id{}; + std::vector<::ton_http::schemas::v2::ShardBlockLink> links{}; + std::vector<::ton_http::schemas::v2::BlockLinkBack> mc_proof{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::ShardBlockProof& lhs, const ::ton_http::schemas::v2::ShardBlockProof& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockProof::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::ShardBlockProof& value +); + + +ShardBlockProof::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> +); + + +ShardBlockProof Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof> +); + + +ShardBlockProof::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> +); + + +ShardBlockProof::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShardBlockProof::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::ShardBlockProof& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::ShardBlockProof::_Type value); + + +struct Shards { + enum class _Type { + kBlocksShards, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kBlocksShards, + }; + + + ::ton_http::schemas::v2::Shards::_Type _type{::ton_http::schemas::v2::Shards::_Type::kBlocksShards}; + std::vector<::ton_http::schemas::v2::TonBlockIdExt> shards{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::Shards& lhs, const ::ton_http::schemas::v2::Shards& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Shards::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Shards& value +); + + +Shards::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> +); + + +Shards Parse( + USERVER_NAMESPACE::formats::json::Value json, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards> +); + + +Shards::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> +); + + +Shards::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Shards::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Shards& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::Shards::_Type value); + + +// TonlibErrorResponse +struct TonlibErrorResponse { + static constexpr auto kCodeMinimum = 100; + + + static constexpr auto kCodeMaximum = 600; + + + bool ok{false}; + std::optional error{}; + std::optional code{}; + std::optional _extra{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::TonlibErrorResponse& lhs, const ::ton_http::schemas::v2::TonlibErrorResponse& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonlibErrorResponse& value +); + + +TonlibErrorResponse Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonlibErrorResponse> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TonlibErrorResponse& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +[[maybe_unused]] static constexpr USERVER_NAMESPACE::chaotic::OneOfStringSettings kTonlibObject_Settings = { + "@type", USERVER_NAMESPACE::utils::TrivialSet([](auto selector) { + return selector() + .template Type() + .Case("utils.detectAddress") + .Case("blocks.masterchainInfo") + .Case("utils.detectedHash"); + }) +}; + + +using TonlibObject = std::variant< + ::ton_http::schemas::v2::DetectAddress, + ::ton_http::schemas::v2::MasterchainInfo, + ::ton_http::schemas::v2::DetectHash>; + + +// TonlibResponse +struct TonlibResponse { + using Result = std::variant; + + + bool ok{true}; + ::ton_http::schemas::v2::TonlibResponse::Result result{}; + std::string _extra{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::TonlibResponse& lhs, const ::ton_http::schemas::v2::TonlibResponse& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::TonlibResponse& value +); + + +TonlibResponse Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonlibResponse> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::TonlibResponse& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +struct Transaction { + enum class _Type { + kRawTransaction, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kRawTransaction, + }; + + + ::ton_http::schemas::v2::Transaction::_Type _type{::ton_http::schemas::v2::Transaction::_Type::kRawTransaction}; + ::ton_http::schemas::v2::AccountAddress address{}; + ton_http::types::ton_addr account{}; + int utime{}; + ton_http::types::bytes data{}; + ::ton_http::schemas::v2::InternalTransactionId transaction_id{}; + ton_http::types::int256 fee{}; + ton_http::types::int256 storage_fee{}; + ton_http::types::int256 other_fee{}; + ::ton_http::schemas::v2::Message in_msg{}; + std::vector<::ton_http::schemas::v2::Message> out_msgs{}; +}; + + +bool operator==(const ::ton_http::schemas::v2::Transaction& lhs, const ::ton_http::schemas::v2::Transaction& rhs); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Transaction::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::Transaction& value +); + + +Transaction::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> +); + + +Transaction Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction> +); + + +Transaction::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> +); + + +Transaction::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Transaction::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::Transaction& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::Transaction::_Type value); + + +using UnpackAddress = std::string; + + +struct WalletInformation { + enum class _Type { + kWalletinformation, + }; + + static constexpr _Type k_TypeValues[] = { + _Type::kWalletinformation, + }; + + + enum class Wallet_Type { + kWalletV1R1, + kWalletV1R2, + kWalletV1R3, + kWalletV2R1, + kWalletV2R2, + kWalletV3R1, + kWalletV3R2, + kWalletV4R1, + kWalletV4R2, + kWalletV5Beta, + kWalletV5R1, + }; + + static constexpr Wallet_Type kWallet_TypeValues[] = { + Wallet_Type::kWalletV1R1, + Wallet_Type::kWalletV1R2, + Wallet_Type::kWalletV1R3, + Wallet_Type::kWalletV2R1, + Wallet_Type::kWalletV2R2, + Wallet_Type::kWalletV3R1, + Wallet_Type::kWalletV3R2, + Wallet_Type::kWalletV4R1, + Wallet_Type::kWalletV4R2, + Wallet_Type::kWalletV5Beta, + Wallet_Type::kWalletV5R1, + }; + + + ::ton_http::schemas::v2::WalletInformation::_Type _type{ + ::ton_http::schemas::v2::WalletInformation::_Type::kWalletinformation + }; + bool wallet{}; + ton_http::types::int256 balance{}; + ::ton_http::schemas::v2::AccountStateEnum account_state{}; + ::ton_http::schemas::v2::InternalTransactionId last_transaction_id{}; + std::optional<::ton_http::schemas::v2::WalletInformation::Wallet_Type> wallet_type{}; + std::optional seqno{}; + std::optional wallet_id{}; + std::optional is_signature_allowed{}; +}; + + +bool operator==( + const ::ton_http::schemas::v2::WalletInformation& lhs, const ::ton_http::schemas::v2::WalletInformation& rhs +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::WalletInformation::_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::WalletInformation::Wallet_Type& value +); + + +USERVER_NAMESPACE::logging::LogHelper& operator<<( + USERVER_NAMESPACE::logging::LogHelper& lh, const ::ton_http::schemas::v2::WalletInformation& value +); + + +WalletInformation::_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> +); + + +WalletInformation::Wallet_Type Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> +); + + +WalletInformation Parse( + USERVER_NAMESPACE::formats::json::Value json, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation> +); + + +WalletInformation::_Type FromString( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> +); + + +WalletInformation::_Type Parse( + std::string_view value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> +); + + +WalletInformation::Wallet_Type FromString( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> +); + + +WalletInformation::Wallet_Type Parse( + std::string_view value, + USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::WalletInformation::_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::WalletInformation::Wallet_Type& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +USERVER_NAMESPACE::formats::json::Value Serialize( + const ::ton_http::schemas::v2::WalletInformation& value, + USERVER_NAMESPACE::formats::serialize::To +); + + +std::string ToString(::ton_http::schemas::v2::WalletInformation::_Type value); + + +std::string ToString(::ton_http::schemas::v2::WalletInformation::Wallet_Type value); + + +} // namespace v2 +} // namespace schemas +} // namespace ton_http + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::AccountAddress::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::AccountAddress::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::AccountStateEnum> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::AccountStateEnum&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::AccountStateRaw::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::AccountStateRaw::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::InternalTransactionId::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::InternalTransactionId::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::TonBlockIdExt::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::TonBlockIdExt::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::AddressInformation::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::AddressInformation::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::BlockHeader::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::BlockHeader::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::BlockLinkBack::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::BlockLinkBack::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::BlockSignature::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::BlockSignature::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ShortTxId::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::ShortTxId::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::BlockTransactions::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::BlockTransactions::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::TvmCell::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::TvmCell::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ConfigInfo::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::ConfigInfo::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ConsensusBlock::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::ConsensusBlock::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::DetectAddress::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::DetectAddress::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::DetectAddress::Given_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::DetectAddress::Given_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::DetectHash::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::DetectHash::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::MsgDataRaw::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::MsgDataRaw::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::MsgDataText::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::MsgDataText::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::MsgDataDecryptedText::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::MsgDataEncryptedText::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ExtMessage::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::ExtMessage::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ExtTransaction::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::ExtTransaction::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::ExtendedAddressInformation::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::LibraryEntry::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::LibraryEntry::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::LibraryResult::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::LibraryResult::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::MasterchainInfo::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::MasterchainInfo::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::Message::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::Message::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::OutMsgQueueSize::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::OutMsgQueueSize::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::OutMsgQueueSizes::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ShardBlockLink::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::ShardBlockLink::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::ShardBlockProof::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::ShardBlockProof::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::Shards::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::Shards::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::Transaction::_Type> { + fmt::format_context::iterator format(const ::ton_http::schemas::v2::Transaction::_Type&, fmt::format_context&) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; + + +template <> +struct fmt::formatter<::ton_http::schemas::v2::WalletInformation::_Type> { + fmt::format_context::iterator format( + const ::ton_http::schemas::v2::WalletInformation::_Type&, fmt::format_context& + ) const; + + constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { + return ctx.begin(); + } +}; template <> -struct fmt::formatter<::ton_http::schemas::v2::DetectAddressResult::Given_Type> { +struct fmt::formatter<::ton_http::schemas::v2::WalletInformation::Wallet_Type> { fmt::format_context::iterator format( - const ::ton_http::schemas::v2::DetectAddressResult::Given_Type&, fmt::format_context& + const ::ton_http::schemas::v2::WalletInformation::Wallet_Type&, fmt::format_context& ) const; constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context& ctx) { diff --git a/ton-http-api/src/schemas/v2_fwd.hpp b/ton-http-api/src/schemas/v2_fwd.hpp index 448bb0a..30e81f7 100644 --- a/ton-http-api/src/schemas/v2_fwd.hpp +++ b/ton-http-api/src/schemas/v2_fwd.hpp @@ -6,22 +6,127 @@ namespace schemas { namespace v2 { -struct DetectAddressBase64Variant; +struct AccountAddress; + + +enum class AccountStateEnum; + + +struct AccountStateRaw; -struct DetectAddressResult; +struct ExtraCurrencyBalance; -struct DetectHashResult; +struct InternalTransactionId; struct TonBlockIdExt; -struct MasterchainInfoResult; +struct AddressInformation; + + +struct BlockHeader; + + +struct BlockLinkBack; + + +struct BlockSignature; + + +struct ShortTxId; + + +struct BlockTransactions; + + +struct TvmCell; + + +struct ConfigInfo; + + +struct ConsensusBlock; + + +struct DetectAddressBase64Variant; + + +struct DetectAddress; + + +struct DetectAddressRequest; + + +struct DetectHash; + + +struct EmptyRequest; + + +struct MsgDataRaw; + + +struct MsgDataText; + + +struct MsgDataDecryptedText; + + +struct MsgDataEncryptedText; + + +struct ExtMessage; + + +struct ExtTransaction; + + +struct ExtendedAddressInformation; + + +struct LibraryEntry; + + +struct LibraryResult; + + +struct MasterchainBlockSignatures; + + +struct MasterchainInfo; + + +struct Message; + + +struct OutMsgQueueSize; + + +struct OutMsgQueueSizes; + + +struct ShardBlockLink; + + +struct ShardBlockProof; + + +struct Shards; + + +struct TonlibErrorResponse; + + +struct TonlibResponse; + + +struct Transaction; -struct TonResponse; +struct WalletInformation; } // namespace v2 diff --git a/ton-http-api/src/schemas/v2_parsers.ipp b/ton-http-api/src/schemas/v2_parsers.ipp index 71ceda0..b86203d 100644 --- a/ton-http-api/src/schemas/v2_parsers.ipp +++ b/ton-http-api/src/schemas/v2_parsers.ipp @@ -20,136 +20,277 @@ namespace schemas { namespace v2 { -static constexpr USERVER_NAMESPACE::utils::TrivialSet - k__ton_http__schemas__v2__DetectAddressBase64Variant_PropertiesNames = [](auto selector) { - return selector().template Type().Case("b64").Case("b64url"); +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__AccountAddress___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::AccountAddress::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::AccountAddress::_Type::kAccountaddress, "accountAddress" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__AccountAddress_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("account_address"); }; template -::ton_http::schemas::v2::DetectAddressBase64Variant Parse( - Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> +::ton_http::schemas::v2::AccountAddress::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__AccountAddress___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AccountAddress::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::AccountAddress Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountAddress> ) { value.CheckNotMissing(); value.CheckObjectOrNull(); - ::ton_http::schemas::v2::DetectAddressBase64Variant res; + ::ton_http::schemas::v2::AccountAddress res; - res.b64 = value["b64"].template As>(); - res.b64url = value["b64url"].template As>(); + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::AccountAddress::_Type::kAccountaddress + ); + res.account_address = value["account_address"] + .template As, + ton_http::types::bytes>>>(); USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( - value, k__ton_http__schemas__v2__DetectAddressBase64Variant_PropertiesNames + value, k__ton_http__schemas__v2__AccountAddress_PropertiesNames ); return res; } -static constexpr USERVER_NAMESPACE::utils::TrivialBiMap - k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping = [](auto selector) { +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__AccountStateEnum_Mapping = + [](auto selector) { return selector() - .template Type<::ton_http::schemas::v2::DetectAddressResult::Given_Type, std::string_view>() - .Case(::ton_http::schemas::v2::DetectAddressResult::Given_Type::kRawForm, "raw_form") - .Case(::ton_http::schemas::v2::DetectAddressResult::Given_Type::kFriendlyBounceable, "friendly_bounceable") - .Case( - ::ton_http::schemas::v2::DetectAddressResult::Given_Type::kFriendlyNonBounceable, - "friendly_non_bounceable" - ); + .template Type<::ton_http::schemas::v2::AccountStateEnum, std::string_view>() + .Case(::ton_http::schemas::v2::AccountStateEnum::kUninitialized, "uninitialized") + .Case(::ton_http::schemas::v2::AccountStateEnum::kActive, "active") + .Case(::ton_http::schemas::v2::AccountStateEnum::kFrozen, "frozen"); + }; + + +template +::ton_http::schemas::v2::AccountStateEnum Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateEnum> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__AccountStateEnum_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AccountStateEnum", value), val + ); +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__AccountStateRaw___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::AccountStateRaw::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::AccountStateRaw::_Type::kRawAccountstate, "raw.accountState" + ); }; -static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectAddressResult_PropertiesNames = +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__AccountStateRaw_PropertiesNames = [](auto selector) { - return selector() - .template Type() - .Case("@type") - .Case("raw_form") - .Case("bounceable") - .Case("non_bounceable") - .Case("given_type") - .Case("test_only"); + return selector().template Type().Case("@type").Case("code").Case("data").Case("frozen_hash"); }; template -::ton_http::schemas::v2::DetectAddressResult::Given_Type Parse( - Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult::Given_Type> +::ton_http::schemas::v2::AccountStateRaw::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw::_Type> ) { const auto value = val.template As(); - const auto result = k__ton_http__schemas__v2__DetectAddressResult__Given_Type_Mapping.TryFindBySecond(value); + const auto result = k__ton_http__schemas__v2__AccountStateRaw___Type_Mapping.TryFindBySecond(value); if (result.has_value()) { return *result; } USERVER_NAMESPACE::chaotic::ThrowForValue( - fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddressResult::Given_Type", value), - val + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AccountStateRaw::_Type", value), val ); } template -::ton_http::schemas::v2::DetectAddressResult Parse( - Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressResult> +::ton_http::schemas::v2::AccountStateRaw Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AccountStateRaw> ) { value.CheckNotMissing(); value.CheckObjectOrNull(); - ::ton_http::schemas::v2::DetectAddressResult res; + ::ton_http::schemas::v2::AccountStateRaw res; - res._type = value["@type"].template As>("utils.detectAddress"); - res.raw_form = value["raw_form"].template As>(); - res.bounceable = - value["bounceable"] - .template As>(); - res.non_bounceable = - value["non_bounceable"] - .template As>(); - res.given_type = - value["given_type"] - .template As< - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddressResult::Given_Type>>(); - res.test_only = value["test_only"].template As>(); + res._type = value["@type"] + .template As>( + ::ton_http::schemas::v2::AccountStateRaw::_Type::kRawAccountstate + ); + res.code = + value["code"] + .template As, ton_http::types::bytes>>(); + res.data = + value["data"] + .template As, ton_http::types::bytes>>(); + res.frozen_hash = + value["frozen_hash"] + .template As, ton_http::types::ton_hash>>(); USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( - value, k__ton_http__schemas__v2__DetectAddressResult_PropertiesNames + value, k__ton_http__schemas__v2__AccountStateRaw_PropertiesNames ); return res; } -static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectHashResult_PropertiesNames = +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ExtraCurrencyBalance___Type_Mapping = [](auto selector) { - return selector().template Type().Case("@type").Case("b64").Case("b64url").Case("hex"); + return selector().template Type<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type::kExtracurrency, "extraCurrency" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ExtraCurrencyBalance_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("id").Case("amount"); + }; + + +template +::ton_http::schemas::v2::ExtraCurrencyBalance::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ExtraCurrencyBalance___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ExtraCurrencyBalance Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtraCurrencyBalance> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ExtraCurrencyBalance res; + + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::ExtraCurrencyBalance::_Type::kExtracurrency + ); + res.id = value["id"].template As>(); + res.amount = + value["amount"] + .template As, ton_http::types::int256>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ExtraCurrencyBalance_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__InternalTransactionId___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::InternalTransactionId::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::InternalTransactionId::_Type::kInternalTransactionid, "internal.transactionId" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__InternalTransactionId_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("lt").Case("hash"); }; template -::ton_http::schemas::v2::DetectHashResult Parse( - Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHashResult> +::ton_http::schemas::v2::InternalTransactionId::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__InternalTransactionId___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::InternalTransactionId::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::InternalTransactionId Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::InternalTransactionId> ) { value.CheckNotMissing(); value.CheckObjectOrNull(); - ::ton_http::schemas::v2::DetectHashResult res; + ::ton_http::schemas::v2::InternalTransactionId res; - res._type = value["@type"].template As>("utils.detectHash"); - res.b64 = value["b64"].template As>>(); - res.b64url = value["b64url"].template As>>(); - res.hex = value["hex"].template As>>(); + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::InternalTransactionId::_Type::kInternalTransactionid + ); + res.lt = value["lt"] + .template As, std::uint64_t>>(); + res.hash = + value["hash"] + .template As, ton_http::types::ton_hash>>(); USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( - value, k__ton_http__schemas__v2__DetectHashResult_PropertiesNames + value, k__ton_http__schemas__v2__InternalTransactionId_PropertiesNames ); return res; } +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__TonBlockIdExt___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::TonBlockIdExt::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::TonBlockIdExt::_Type::kTonBlockidext, "ton.blockIdExt" + ); + }; + + static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TonBlockIdExt_PropertiesNames = [](auto selector) { return selector() @@ -163,6 +304,21 @@ static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ }; +template +::ton_http::schemas::v2::TonBlockIdExt::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__TonBlockIdExt___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::TonBlockIdExt::_Type", value), val + ); +} + + template ::ton_http::schemas::v2::TonBlockIdExt Parse( Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonBlockIdExt> @@ -172,12 +328,15 @@ template ::ton_http::schemas::v2::TonBlockIdExt res; - res._type = value["@type"].template As>("ton.blockIdExt"); + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::TonBlockIdExt::_Type::kTonBlockidext + ); res.workchain = value["workchain"].template As>(); res.shard = value["shard"] - .template As, ton_http::types::shard_id>>(); + .template As< + USERVER_NAMESPACE::chaotic::WithType, std::int64_t>>(); res.seqno = value["seqno"].template As>(); res.root_hash = value["root_hash"] @@ -197,81 +356,2264 @@ template } -static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MasterchainInfoResult_PropertiesNames = +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__AddressInformation___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::AddressInformation::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::AddressInformation::_Type::kRawFullaccountstate, "raw.fullAccountState" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__AddressInformation_PropertiesNames = [](auto selector) { return selector() .template Type() .Case("@type") - .Case("last") - .Case("state_root_hash") - .Case("init"); + .Case("balance") + .Case("extra_currencies") + .Case("last_transaction_id") + .Case("block_id") + .Case("code") + .Case("data") + .Case("frozen_hash") + .Case("sync_utime") + .Case("state") + .Case("suspended"); }; template -::ton_http::schemas::v2::MasterchainInfoResult Parse( - Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfoResult> +::ton_http::schemas::v2::AddressInformation::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__AddressInformation___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::AddressInformation::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::AddressInformation Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::AddressInformation> ) { value.CheckNotMissing(); value.CheckObjectOrNull(); - ::ton_http::schemas::v2::MasterchainInfoResult res; + ::ton_http::schemas::v2::AddressInformation res; - res._type = value["@type"].template As>("blocks.masterchainInfo"); - res.last = value["last"].template As>(); - res.state_root_hash = - value["state_root_hash"] + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::AddressInformation::_Type::kRawFullaccountstate + ); + res.balance = + value["balance"] + .template As, ton_http::types::int256>>(); + res.extra_currencies = value["extra_currencies"] + .template As, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>>(); + res.last_transaction_id = + value["last_transaction_id"] + .template As>(); + res.block_id = + value["block_id"].template As>(); + res.code = + value["code"] + .template As, ton_http::types::bytes>>(); + res.data = + value["data"] + .template As, ton_http::types::bytes>>(); + res.frozen_hash = + value["frozen_hash"] .template As, ton_http::types::ton_hash>>(); - res.init = value["init"].template As>(); + res.sync_utime = value["sync_utime"].template As>(); + res.state = + value["state"].template As>(); + res.suspended = value["suspended"].template As>>(); USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( - value, k__ton_http__schemas__v2__MasterchainInfoResult_PropertiesNames + value, k__ton_http__schemas__v2__AddressInformation_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__BlockHeader___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::BlockHeader::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::BlockHeader::_Type::kBlocksHeader, "blocks.header" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__BlockHeader_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("id") + .Case("global_id") + .Case("version") + .Case("after_merge") + .Case("after_split") + .Case("before_split") + .Case("want_merge") + .Case("want_split") + .Case("validator_list_hash_short") + .Case("catchain_seqno") + .Case("min_ref_mc_seqno") + .Case("is_key_block") + .Case("prev_key_block_seqno") + .Case("start_lt") + .Case("end_lt") + .Case("gen_utime") + .Case("prev_blocks"); + }; + + +template +::ton_http::schemas::v2::BlockHeader::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__BlockHeader___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockHeader::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::BlockHeader Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockHeader> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::BlockHeader res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::BlockHeader::_Type::kBlocksHeader + ); + res.id = value["id"].template As>(); + res.global_id = value["global_id"].template As>(); + res.version = value["version"].template As>(); + res.after_merge = value["after_merge"].template As>(); + res.after_split = value["after_split"].template As>(); + res.before_split = value["before_split"].template As>(); + res.want_merge = value["want_merge"].template As>(); + res.want_split = value["want_split"].template As>(); + res.validator_list_hash_short = + value["validator_list_hash_short"].template As>(); + res.catchain_seqno = value["catchain_seqno"].template As>(); + res.min_ref_mc_seqno = value["min_ref_mc_seqno"].template As>(); + res.is_key_block = value["is_key_block"].template As>(); + res.prev_key_block_seqno = value["prev_key_block_seqno"].template As>(); + res.start_lt = value["start_lt"] + .template As, std::uint64_t>>(); + res.end_lt = value["end_lt"] + .template As, std::uint64_t>>(); + res.gen_utime = value["gen_utime"].template As>(); + res.prev_blocks = value["prev_blocks"] + .template As, + std::vector<::ton_http::schemas::v2::TonBlockIdExt>>>(); + + + res.extra = USERVER_NAMESPACE::chaotic::ExtractAdditionalPropertiesTrue( + value, k__ton_http__schemas__v2__BlockHeader_PropertiesNames ); + return res; } -static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TonResponse_PropertiesNames = +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__BlockLinkBack___Type_Mapping = [](auto selector) { - return selector().template Type().Case("ok").Case("result").Case("error").Case("code").Case( - "@extra" + return selector().template Type<::ton_http::schemas::v2::BlockLinkBack::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::BlockLinkBack::_Type::kBlocksBlocklinkback, "blocks.blockLinkBack" ); }; +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__BlockLinkBack_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("to_key_block") + .Case("from") + .Case("to") + .Case("dest_proof") + .Case("proof") + .Case("state_proof"); + }; + + +template +::ton_http::schemas::v2::BlockLinkBack::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__BlockLinkBack___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockLinkBack::_Type", value), val + ); +} + + template -::ton_http::schemas::v2::TonResponse Parse( - Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonResponse> +::ton_http::schemas::v2::BlockLinkBack Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockLinkBack> ) { value.CheckNotMissing(); value.CheckObjectOrNull(); - ::ton_http::schemas::v2::TonResponse res; + ::ton_http::schemas::v2::BlockLinkBack res; - res.ok = value["ok"].template As>(); - res.result = value["result"] - .template As, - USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< - &::ton_http::schemas::v2::kTonObject_Settings, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, - USERVER_NAMESPACE::chaotic::Array< - USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< - &::ton_http::schemas::v2::kTonObject_Settings, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::TonBlockIdExt>, - USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfoResult>>, - std::vector<::ton_http::schemas::v2::TonObject>>>>>(); - res.error = value["error"].template As>>(); - res.code = value["code"].template As>>(); - res._extra = value["@extra"].template As>(); + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::BlockLinkBack::_Type::kBlocksBlocklinkback + ); + res.to_key_block = value["to_key_block"].template As>(); + res.from = value["from"].template As>(); + res.to = value["to"].template As>(); + res.dest_proof = + value["dest_proof"] + .template As, ton_http::types::bytes>>(); + res.proof = + value["proof"] + .template As, ton_http::types::bytes>>(); + res.state_proof = + value["state_proof"] + .template As, ton_http::types::bytes>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__BlockLinkBack_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__BlockSignature___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::BlockSignature::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::BlockSignature::_Type::kBlocksSignature, "blocks.signature" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__BlockSignature_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("node_id_short").Case("signature"); + }; + + +template +::ton_http::schemas::v2::BlockSignature::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__BlockSignature___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockSignature::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::BlockSignature Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockSignature> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::BlockSignature res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::BlockSignature::_Type::kBlocksSignature + ); + res.node_id_short = + value["node_id_short"] + .template As, ton_http::types::ton_hash>>(); + res.signature = + value["signature"] + .template As, ton_http::types::bytes>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__BlockSignature_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ShortTxId___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ShortTxId::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ShortTxId::_Type::kBlocksShorttxid, "blocks.shortTxId" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ShortTxId_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("mode").Case("account").Case("lt").Case( + "hash" + ); + }; + + +template +::ton_http::schemas::v2::ShortTxId::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ShortTxId___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ShortTxId::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ShortTxId Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShortTxId> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ShortTxId res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::ShortTxId::_Type::kBlocksShorttxid + ); + res.mode = value["mode"].template As>(); + res.account = + value["account"] + .template As, ton_http::types::ton_addr>>(); + res.lt = value["lt"] + .template As, std::uint64_t>>(); + res.hash = + value["hash"] + .template As, ton_http::types::ton_hash>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ShortTxId_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__BlockTransactions___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::BlockTransactions::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::BlockTransactions::_Type::kBlocksTransactions, "blocks.transactions" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__BlockTransactions_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("id") + .Case("req_count") + .Case("incomplete") + .Case("transactions"); + }; + + +template +::ton_http::schemas::v2::BlockTransactions::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__BlockTransactions___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::BlockTransactions::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::BlockTransactions Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::BlockTransactions> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::BlockTransactions res; + + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::BlockTransactions::_Type::kBlocksTransactions + ); + res.id = value["id"].template As>(); + res.req_count = value["req_count"].template As>(); + res.incomplete = value["incomplete"].template As>(); + res.transactions = value["transactions"] + .template As, + std::vector<::ton_http::schemas::v2::ShortTxId>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__BlockTransactions_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__TvmCell___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::TvmCell::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::TvmCell::_Type::kTvmCell, "tvm.cell" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TvmCell_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("bytes"); + }; + + +template +::ton_http::schemas::v2::TvmCell::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__TvmCell___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::TvmCell::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::TvmCell Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TvmCell> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::TvmCell res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::TvmCell::_Type::kTvmCell + ); + res.bytes = + value["bytes"] + .template As, ton_http::types::bytes>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, k__ton_http__schemas__v2__TvmCell_PropertiesNames); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ConfigInfo___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ConfigInfo::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ConfigInfo::_Type::kConfiginfo, "configInfo" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ConfigInfo_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("config"); + }; + + +template +::ton_http::schemas::v2::ConfigInfo::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ConfigInfo___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ConfigInfo::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ConfigInfo Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConfigInfo> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ConfigInfo res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::ConfigInfo::_Type::kConfiginfo + ); + res.config = value["config"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ConfigInfo_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ConsensusBlock___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ConsensusBlock::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ConsensusBlock::_Type::kExtConsensusblock, "ext.consensusBlock" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ConsensusBlock_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("consensus_block").Case("timestamp"); + }; + + +template +::ton_http::schemas::v2::ConsensusBlock::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ConsensusBlock___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ConsensusBlock::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ConsensusBlock Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ConsensusBlock> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ConsensusBlock res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::ConsensusBlock::_Type::kExtConsensusblock + ); + res.consensus_block = value["consensus_block"].template As>(); + res.timestamp = value["timestamp"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ConsensusBlock_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet + k__ton_http__schemas__v2__DetectAddressBase64Variant_PropertiesNames = [](auto selector) { + return selector().template Type().Case("b64").Case("b64url"); + }; + + +template +::ton_http::schemas::v2::DetectAddressBase64Variant Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressBase64Variant> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectAddressBase64Variant res; + + res.b64 = value["b64"].template As>(); + res.b64url = value["b64url"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectAddressBase64Variant_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__DetectAddress___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::DetectAddress::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::DetectAddress::_Type::kUtilsDetectedaddress, "utils.detectedAddress" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__DetectAddress__Given_Type_Mapping = + [](auto selector) { + return selector() + .template Type<::ton_http::schemas::v2::DetectAddress::Given_Type, std::string_view>() + .Case(::ton_http::schemas::v2::DetectAddress::Given_Type::kRawForm, "raw_form") + .Case(::ton_http::schemas::v2::DetectAddress::Given_Type::kFriendlyBounceable, "friendly_bounceable") + .Case(::ton_http::schemas::v2::DetectAddress::Given_Type::kFriendlyNonBounceable, "friendly_non_bounceable"); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectAddress_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("raw_form") + .Case("bounceable") + .Case("non_bounceable") + .Case("given_type") + .Case("test_only"); + }; + + +template +::ton_http::schemas::v2::DetectAddress::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__DetectAddress___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddress::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::DetectAddress::Given_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress::Given_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__DetectAddress__Given_Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectAddress::Given_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::DetectAddress Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddress> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectAddress res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::DetectAddress::_Type::kUtilsDetectedaddress + ); + res.raw_form = value["raw_form"].template As>(); + res.bounceable = + value["bounceable"] + .template As>(); + res.non_bounceable = + value["non_bounceable"] + .template As>(); + res.given_type = + value["given_type"] + .template As>(); + res.test_only = value["test_only"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectAddress_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectAddressRequest_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("address"); + }; + + +template +::ton_http::schemas::v2::DetectAddressRequest Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectAddressRequest> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectAddressRequest res; + + res.address = + value["address"] + .template As, ton_http::types::ton_addr>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectAddressRequest_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__DetectHash___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::DetectHash::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::DetectHash::_Type::kUtilsDetectedhash, "utils.detectedHash" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__DetectHash_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("b64").Case("b64url").Case("hex"); + }; + + +template +::ton_http::schemas::v2::DetectHash::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__DetectHash___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::DetectHash::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::DetectHash Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::DetectHash> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::DetectHash res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::DetectHash::_Type::kUtilsDetectedhash + ); + res.b64 = value["b64"].template As>(); + res.b64url = value["b64url"].template As>(); + res.hex = value["hex"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__DetectHash_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__EmptyRequest_PropertiesNames = + [](auto selector) { + return selector().template Type(); + }; + + +template +::ton_http::schemas::v2::EmptyRequest Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::EmptyRequest> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::EmptyRequest res; + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__EmptyRequest_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__MsgDataRaw___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::MsgDataRaw::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::MsgDataRaw::_Type::kMsgDataraw, "msg.dataRaw" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MsgDataRaw_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("body").Case("init_state"); + }; + + +template +::ton_http::schemas::v2::MsgDataRaw::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__MsgDataRaw___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataRaw::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::MsgDataRaw Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataRaw> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MsgDataRaw res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::MsgDataRaw::_Type::kMsgDataraw + ); + res.body = value["body"] + .template As, + ton_http::types::bytes>>>(); + res.init_state = value["init_state"] + .template As, + ton_http::types::bytes>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MsgDataRaw_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__MsgDataText___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::MsgDataText::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::MsgDataText::_Type::kMsgDatatext, "msg.dataText" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MsgDataText_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("text"); + }; + + +template +::ton_http::schemas::v2::MsgDataText::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__MsgDataText___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataText::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::MsgDataText Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataText> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MsgDataText res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::MsgDataText::_Type::kMsgDatatext + ); + res.text = value["text"].template As>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MsgDataText_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__MsgDataDecryptedText___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::MsgDataDecryptedText::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::MsgDataDecryptedText::_Type::kMsgDatadecryptedtext, "msg.dataDecryptedText" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MsgDataDecryptedText_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("text"); + }; + + +template +::ton_http::schemas::v2::MsgDataDecryptedText::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__MsgDataDecryptedText___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataDecryptedText::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::MsgDataDecryptedText Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataDecryptedText> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MsgDataDecryptedText res; + + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::MsgDataDecryptedText::_Type::kMsgDatadecryptedtext + ); + res.text = value["text"].template As>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MsgDataDecryptedText_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__MsgDataEncryptedText___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::MsgDataEncryptedText::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::MsgDataEncryptedText::_Type::kMsgDataencryptedtext, "msg.dataEncryptedText" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MsgDataEncryptedText_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("text"); + }; + + +template +::ton_http::schemas::v2::MsgDataEncryptedText::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__MsgDataEncryptedText___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MsgDataEncryptedText::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::MsgDataEncryptedText Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MsgDataEncryptedText> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MsgDataEncryptedText res; + + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::MsgDataEncryptedText::_Type::kMsgDataencryptedtext + ); + res.text = value["text"].template As>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MsgDataEncryptedText_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ExtMessage___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ExtMessage::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ExtMessage::_Type::kExtMessage, "ext.message" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ExtMessage_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("hash") + .Case("source") + .Case("destination") + .Case("value") + .Case("extra_currencies") + .Case("fwd_fee") + .Case("ihr_fee") + .Case("created_lt") + .Case("body_hash") + .Case("msg_data") + .Case("message") + .Case("message_decode_error"); + }; + + +template +::ton_http::schemas::v2::ExtMessage::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ExtMessage___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtMessage::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ExtMessage Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtMessage> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ExtMessage res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::ExtMessage::_Type::kExtMessage + ); + res.hash = + value["hash"] + .template As, ton_http::types::ton_hash>>(); + res.source = + value["source"] + .template As, ton_http::types::ton_addr>>(); + res.destination = + value["destination"] + .template As, ton_http::types::ton_addr>>(); + res.value = + value["value"] + .template As, ton_http::types::int256>>(); + res.extra_currencies = value["extra_currencies"] + .template As, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>>(); + res.fwd_fee = + value["fwd_fee"] + .template As, ton_http::types::int256>>(); + res.ihr_fee = + value["ihr_fee"] + .template As, ton_http::types::int256>>(); + res.created_lt = value["created_lt"] + .template As, std::uint64_t>>(); + res.body_hash = + value["body_hash"] + .template As, ton_http::types::ton_hash>>(); + res.msg_data = value["msg_data"] + .template As, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataDecryptedText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataEncryptedText>>>(); + res.message = value["message"].template As>>(); + res.message_decode_error = + value["message_decode_error"].template As>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ExtMessage_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ExtTransaction___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ExtTransaction::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ExtTransaction::_Type::kExtTransaction, "ext.transaction" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ExtTransaction_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("address") + .Case("utime") + .Case("data") + .Case("transaction_id") + .Case("fee") + .Case("storage_fee") + .Case("other_fee") + .Case("in_msg") + .Case("out_msgs"); + }; + + +template +::ton_http::schemas::v2::ExtTransaction::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ExtTransaction___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtTransaction::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ExtTransaction Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtTransaction> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ExtTransaction res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::ExtTransaction::_Type::kExtTransaction + ); + res.address = + value["address"].template As>(); + res.utime = value["utime"].template As>(); + res.data = + value["data"] + .template As, ton_http::types::bytes>>(); + res.transaction_id = + value["transaction_id"] + .template As>(); + res.fee = + value["fee"] + .template As, ton_http::types::int256>>(); + res.storage_fee = + value["storage_fee"] + .template As, ton_http::types::int256>>(); + res.other_fee = + value["other_fee"] + .template As, ton_http::types::int256>>(); + res.in_msg = + value["in_msg"].template As>(); + res.out_msgs = value["out_msgs"] + .template As, + std::vector<::ton_http::schemas::v2::ExtMessage>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ExtTransaction_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap + k__ton_http__schemas__v2__ExtendedAddressInformation___Type_Mapping = [](auto selector) { + return selector() + .template Type<::ton_http::schemas::v2::ExtendedAddressInformation::_Type, std::string_view>() + .Case(::ton_http::schemas::v2::ExtendedAddressInformation::_Type::kFullaccountstate, "fullAccountState"); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet + k__ton_http__schemas__v2__ExtendedAddressInformation_PropertiesNames = [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("address") + .Case("balance") + .Case("extra_currencies") + .Case("last_transaction_id") + .Case("block_id") + .Case("sync_utime") + .Case("account_state") + .Case("revision"); + }; + + +template +::ton_http::schemas::v2::ExtendedAddressInformation::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ExtendedAddressInformation___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ExtendedAddressInformation::_Type", value), + val + ); +} + + +template +::ton_http::schemas::v2::ExtendedAddressInformation Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ExtendedAddressInformation> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ExtendedAddressInformation res; + + res._type = + value["@type"] + .template As< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::ExtendedAddressInformation::_Type>>( + ::ton_http::schemas::v2::ExtendedAddressInformation::_Type::kFullaccountstate + ); + res.address = + value["address"].template As>(); + res.balance = + value["balance"] + .template As, ton_http::types::int256>>(); + res.extra_currencies = value["extra_currencies"] + .template As, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>>(); + res.last_transaction_id = + value["last_transaction_id"] + .template As>(); + res.block_id = + value["block_id"].template As>(); + res.sync_utime = value["sync_utime"].template As>(); + res.account_state = + value["account_state"] + .template As>(); + res.revision = value["revision"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ExtendedAddressInformation_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__LibraryEntry___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::LibraryEntry::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::LibraryEntry::_Type::kSmcLibraryentry, "smc.libraryEntry" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__LibraryEntry_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("hash").Case("data"); + }; + + +template +::ton_http::schemas::v2::LibraryEntry::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__LibraryEntry___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::LibraryEntry::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::LibraryEntry Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryEntry> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::LibraryEntry res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::LibraryEntry::_Type::kSmcLibraryentry + ); + res.hash = + value["hash"] + .template As, ton_http::types::ton_hash>>(); + res.data = + value["data"] + .template As, ton_http::types::bytes>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__LibraryEntry_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__LibraryResult___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::LibraryResult::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::LibraryResult::_Type::kSmcLibraryresult, "smc.libraryResult" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__LibraryResult_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("result"); + }; + + +template +::ton_http::schemas::v2::LibraryResult::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__LibraryResult___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::LibraryResult::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::LibraryResult Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::LibraryResult> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::LibraryResult res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::LibraryResult::_Type::kSmcLibraryresult + ); + res.result = value["result"] + .template As, + std::vector<::ton_http::schemas::v2::LibraryEntry>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__LibraryResult_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap + k__ton_http__schemas__v2__MasterchainBlockSignatures___Type_Mapping = [](auto selector) { + return selector() + .template Type<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type, std::string_view>() + .Case( + ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type::kBlocksBlocksignatures, + "blocks.blockSignatures" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet + k__ton_http__schemas__v2__MasterchainBlockSignatures_PropertiesNames = [](auto selector) { + return selector().template Type().Case("@type").Case("id").Case("signatures"); + }; + + +template +::ton_http::schemas::v2::MasterchainBlockSignatures::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__MasterchainBlockSignatures___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type", value), + val + ); +} + + +template +::ton_http::schemas::v2::MasterchainBlockSignatures Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainBlockSignatures> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MasterchainBlockSignatures res; + + res._type = + value["@type"] + .template As< + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainBlockSignatures::_Type>>( + ::ton_http::schemas::v2::MasterchainBlockSignatures::_Type::kBlocksBlocksignatures + ); + res.id = value["id"].template As>(); + res.signatures = value["signatures"] + .template As, + std::vector<::ton_http::schemas::v2::BlockSignature>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MasterchainBlockSignatures_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__MasterchainInfo___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::MasterchainInfo::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::MasterchainInfo::_Type::kBlocksMasterchaininfo, "blocks.masterchainInfo" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__MasterchainInfo_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("last") + .Case("state_root_hash") + .Case("init"); + }; + + +template +::ton_http::schemas::v2::MasterchainInfo::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__MasterchainInfo___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::MasterchainInfo::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::MasterchainInfo Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::MasterchainInfo> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::MasterchainInfo res; + + res._type = value["@type"] + .template As>( + ::ton_http::schemas::v2::MasterchainInfo::_Type::kBlocksMasterchaininfo + ); + res.last = value["last"].template As>(); + res.state_root_hash = + value["state_root_hash"] + .template As, ton_http::types::ton_hash>>(); + res.init = value["init"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__MasterchainInfo_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__Message___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::Message::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::Message::_Type::kRawMessage, "raw.message" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__Message_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("hash") + .Case("source") + .Case("destination") + .Case("value") + .Case("extra_currencies") + .Case("fwd_fee") + .Case("ihr_fee") + .Case("created_lt") + .Case("body_hash") + .Case("msg_data"); + }; + + +template +::ton_http::schemas::v2::Message::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__Message___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::Message::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::Message Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Message> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::Message res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::Message::_Type::kRawMessage + ); + res.hash = + value["hash"] + .template As, ton_http::types::ton_hash>>(); + res.source = + value["source"].template As>(); + res.destination = value["destination"] + .template As>(); + res.value = + value["value"] + .template As, ton_http::types::int256>>(); + res.extra_currencies = value["extra_currencies"] + .template As, + std::vector<::ton_http::schemas::v2::ExtraCurrencyBalance>>>(); + res.fwd_fee = + value["fwd_fee"] + .template As, ton_http::types::int256>>(); + res.ihr_fee = + value["ihr_fee"] + .template As, ton_http::types::int256>>(); + res.created_lt = value["created_lt"] + .template As, std::uint64_t>>(); + res.body_hash = + value["body_hash"] + .template As, ton_http::types::ton_hash>>(); + res.msg_data = value["msg_data"] + .template As, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataDecryptedText>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MsgDataEncryptedText>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, k__ton_http__schemas__v2__Message_PropertiesNames); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__OutMsgQueueSize___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::OutMsgQueueSize::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::OutMsgQueueSize::_Type::kBlocksOutmsgqueuesize, "blocks.outMsgQueueSize" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__OutMsgQueueSize_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("id").Case("size"); + }; + + +template +::ton_http::schemas::v2::OutMsgQueueSize::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__OutMsgQueueSize___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::OutMsgQueueSize::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::OutMsgQueueSize Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSize> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::OutMsgQueueSize res; + + res._type = value["@type"] + .template As>( + ::ton_http::schemas::v2::OutMsgQueueSize::_Type::kBlocksOutmsgqueuesize + ); + res.id = value["id"].template As>(); + res.size = value["size"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__OutMsgQueueSize_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__OutMsgQueueSizes___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::OutMsgQueueSizes::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::OutMsgQueueSizes::_Type::kBlocksOutmsgqueuesizes, "blocks.outMsgQueueSizes" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__OutMsgQueueSizes_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("shards").Case("ext_msg_queue_size_limit"); + }; + + +template +::ton_http::schemas::v2::OutMsgQueueSizes::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__OutMsgQueueSizes___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::OutMsgQueueSizes::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::OutMsgQueueSizes Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::OutMsgQueueSizes> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::OutMsgQueueSizes res; + + res._type = value["@type"] + .template As>( + ::ton_http::schemas::v2::OutMsgQueueSizes::_Type::kBlocksOutmsgqueuesizes + ); + res.shards = value["shards"] + .template As, + std::vector<::ton_http::schemas::v2::OutMsgQueueSize>>>(); + res.ext_msg_queue_size_limit = + value["ext_msg_queue_size_limit"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__OutMsgQueueSizes_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ShardBlockLink___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ShardBlockLink::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ShardBlockLink::_Type::kBlocksShardblocklink, "blocks.shardBlockLink" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ShardBlockLink_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("id").Case("proof"); + }; + + +template +::ton_http::schemas::v2::ShardBlockLink::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ShardBlockLink___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ShardBlockLink::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ShardBlockLink Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockLink> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ShardBlockLink res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::ShardBlockLink::_Type::kBlocksShardblocklink + ); + res.id = value["id"].template As>(); + res.proof = + value["proof"] + .template As, ton_http::types::bytes>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ShardBlockLink_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__ShardBlockProof___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::ShardBlockProof::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::ShardBlockProof::_Type::kBlocksShardblockproof, "blocks.shardBlockProof" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__ShardBlockProof_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("from").Case("mc_id").Case("links").Case( + "mc_proof" + ); + }; + + +template +::ton_http::schemas::v2::ShardBlockProof::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__ShardBlockProof___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::ShardBlockProof::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::ShardBlockProof Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::ShardBlockProof> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::ShardBlockProof res; + + res._type = value["@type"] + .template As>( + ::ton_http::schemas::v2::ShardBlockProof::_Type::kBlocksShardblockproof + ); + res.from = value["from"].template As>(); + res.mc_id = + value["mc_id"].template As>(); + res.links = value["links"] + .template As, + std::vector<::ton_http::schemas::v2::ShardBlockLink>>>(); + res.mc_proof = value["mc_proof"] + .template As, + std::vector<::ton_http::schemas::v2::BlockLinkBack>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__ShardBlockProof_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__Shards___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::Shards::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::Shards::_Type::kBlocksShards, "blocks.shards" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__Shards_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("@type").Case("shards"); + }; + + +template +::ton_http::schemas::v2::Shards::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__Shards___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::Shards::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::Shards Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Shards> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::Shards res; + + res._type = value["@type"].template As>( + ::ton_http::schemas::v2::Shards::_Type::kBlocksShards + ); + res.shards = value["shards"] + .template As, + std::vector<::ton_http::schemas::v2::TonBlockIdExt>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties(value, k__ton_http__schemas__v2__Shards_PropertiesNames); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TonlibErrorResponse_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("ok").Case("error").Case("code").Case("@extra"); + }; + + +template +::ton_http::schemas::v2::TonlibErrorResponse Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonlibErrorResponse> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::TonlibErrorResponse res; + + res.ok = value["ok"].template As>(false); + res.error = value["error"].template As>>(); + res.code = + value["code"] + .template As, + USERVER_NAMESPACE::chaotic::Maximum<::ton_http::schemas::v2::TonlibErrorResponse::kCodeMaximum>>>>(); + res._extra = value["@extra"].template As>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__TonlibErrorResponse_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__TonlibResponse_PropertiesNames = + [](auto selector) { + return selector().template Type().Case("ok").Case("result").Case("@extra"); + }; + + +template +::ton_http::schemas::v2::TonlibResponse Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::TonlibResponse> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::TonlibResponse res; + + res.ok = value["ok"].template As>(true); + res.result = value["result"] + .template As, + USERVER_NAMESPACE::chaotic::OneOfWithDiscriminator< + &::ton_http::schemas::v2::kTonlibObject_Settings, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectAddress>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::MasterchainInfo>, + USERVER_NAMESPACE::chaotic::Primitive<::ton_http::schemas::v2::DetectHash>>>>(); + res._extra = value["@extra"].template As>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__TonlibResponse_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__Transaction___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::Transaction::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::Transaction::_Type::kRawTransaction, "raw.transaction" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__Transaction_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("address") + .Case("account") + .Case("utime") + .Case("data") + .Case("transaction_id") + .Case("fee") + .Case("storage_fee") + .Case("other_fee") + .Case("in_msg") + .Case("out_msgs"); + }; + + +template +::ton_http::schemas::v2::Transaction::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__Transaction___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::Transaction::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::Transaction Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::Transaction> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::Transaction res; + + res._type = + value["@type"].template As>( + ::ton_http::schemas::v2::Transaction::_Type::kRawTransaction + ); + res.address = + value["address"].template As>(); + res.account = + value["account"] + .template As, ton_http::types::ton_addr>>(); + res.utime = value["utime"].template As>(); + res.data = + value["data"] + .template As, ton_http::types::bytes>>(); + res.transaction_id = + value["transaction_id"] + .template As>(); + res.fee = + value["fee"] + .template As, ton_http::types::int256>>(); + res.storage_fee = + value["storage_fee"] + .template As, ton_http::types::int256>>(); + res.other_fee = + value["other_fee"] + .template As, ton_http::types::int256>>(); + res.in_msg = value["in_msg"].template As>(); + res.out_msgs = value["out_msgs"] + .template As, + std::vector<::ton_http::schemas::v2::Message>>>(); + + + USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( + value, k__ton_http__schemas__v2__Transaction_PropertiesNames + ); + + return res; +} + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap k__ton_http__schemas__v2__WalletInformation___Type_Mapping = + [](auto selector) { + return selector().template Type<::ton_http::schemas::v2::WalletInformation::_Type, std::string_view>().Case( + ::ton_http::schemas::v2::WalletInformation::_Type::kWalletinformation, "walletInformation" + ); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialBiMap + k__ton_http__schemas__v2__WalletInformation__Wallet_Type_Mapping = [](auto selector) { + return selector() + .template Type<::ton_http::schemas::v2::WalletInformation::Wallet_Type, std::string_view>() + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV1R1, "wallet v1 r1") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV1R2, "wallet v1 r2") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV1R3, "wallet v1 r3") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV2R1, "wallet v2 r1") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV2R2, "wallet v2 r2") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV3R1, "wallet v3 r1") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV3R2, "wallet v3 r2") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV4R1, "wallet v4 r1") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV4R2, "wallet v4 r2") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV5Beta, "wallet v5 beta") + .Case(::ton_http::schemas::v2::WalletInformation::Wallet_Type::kWalletV5R1, "wallet v5 r1"); + }; + + +static constexpr USERVER_NAMESPACE::utils::TrivialSet k__ton_http__schemas__v2__WalletInformation_PropertiesNames = + [](auto selector) { + return selector() + .template Type() + .Case("@type") + .Case("wallet") + .Case("balance") + .Case("account_state") + .Case("last_transaction_id") + .Case("wallet_type") + .Case("seqno") + .Case("wallet_id") + .Case("is_signature_allowed"); + }; + + +template +::ton_http::schemas::v2::WalletInformation::_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__WalletInformation___Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::WalletInformation::_Type", value), val + ); +} + + +template +::ton_http::schemas::v2::WalletInformation::Wallet_Type Parse( + Value val, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation::Wallet_Type> +) { + const auto value = val.template As(); + const auto result = k__ton_http__schemas__v2__WalletInformation__Wallet_Type_Mapping.TryFindBySecond(value); + if (result.has_value()) { + return *result; + } + USERVER_NAMESPACE::chaotic::ThrowForValue( + fmt::format("Invalid enum value ({}) for type ::ton_http::schemas::v2::WalletInformation::Wallet_Type", value), + val + ); +} + + +template +::ton_http::schemas::v2::WalletInformation Parse( + Value value, USERVER_NAMESPACE::formats::parse::To<::ton_http::schemas::v2::WalletInformation> +) { + value.CheckNotMissing(); + value.CheckObjectOrNull(); + + ::ton_http::schemas::v2::WalletInformation res; + + res._type = + value["@type"] + .template As>( + ::ton_http::schemas::v2::WalletInformation::_Type::kWalletinformation + ); + res.wallet = value["wallet"].template As>(); + res.balance = + value["balance"] + .template As, ton_http::types::int256>>(); + res.account_state = + value["account_state"] + .template As>(); + res.last_transaction_id = + value["last_transaction_id"] + .template As>(); + res.wallet_type = + value["wallet_type"] + .template As>>(); + res.seqno = value["seqno"].template As>>(); + res.wallet_id = value["wallet_id"].template As>>(); + res.is_signature_allowed = + value["is_signature_allowed"].template As>>(); USERVER_NAMESPACE::chaotic::ValidateNoAdditionalProperties( - value, k__ton_http__schemas__v2__TonResponse_PropertiesNames + value, k__ton_http__schemas__v2__WalletInformation_PropertiesNames ); return res; diff --git a/ton-http-api/src/userver/chaotic/io/std/int64_t.cpp b/ton-http-api/src/userver/chaotic/io/std/int64_t.cpp new file mode 100644 index 0000000..b96d996 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/std/int64_t.cpp @@ -0,0 +1,8 @@ +#include "int64_t.hpp" + +std::int64_t userver::chaotic::convert::Convert(const std::string& value, chaotic::convert::To) { + return std::int64_t{std::stoll(value)}; +} +std::string userver::v2_13_rc::Convert(const std::int64_t& value, chaotic::convert::To) { + return std::to_string(value); +} diff --git a/ton-http-api/src/userver/chaotic/io/std/int64_t.hpp b/ton-http-api/src/userver/chaotic/io/std/int64_t.hpp new file mode 100644 index 0000000..78ccc96 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/std/int64_t.hpp @@ -0,0 +1,15 @@ +#pragma once +#include +#include + +#include "userver/chaotic/convert/to.hpp" + +USERVER_NAMESPACE_BEGIN + +namespace chaotic::convert { + +std::int64_t Convert(const std::string& value, chaotic::convert::To); +} +std::string Convert(const std::int64_t& value, chaotic::convert::To); + +USERVER_NAMESPACE_END diff --git a/ton-http-api/src/userver/chaotic/io/std/uint64_t.cpp b/ton-http-api/src/userver/chaotic/io/std/uint64_t.cpp new file mode 100644 index 0000000..5152bb1 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/std/uint64_t.cpp @@ -0,0 +1,8 @@ +#include "uint64_t.hpp" + +std::uint64_t userver::chaotic::convert::Convert(const std::string& value, chaotic::convert::To) { + return std::uint64_t{std::stoull(value)}; +} +std::string userver::v2_13_rc::Convert(const std::uint64_t& value, chaotic::convert::To) { + return std::to_string(value); +} diff --git a/ton-http-api/src/userver/chaotic/io/std/uint64_t.hpp b/ton-http-api/src/userver/chaotic/io/std/uint64_t.hpp new file mode 100644 index 0000000..ef4ea0c --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/std/uint64_t.hpp @@ -0,0 +1,15 @@ +#pragma once +#include +#include + +#include "userver/chaotic/convert/to.hpp" + +USERVER_NAMESPACE_BEGIN + +namespace chaotic::convert { + +std::uint64_t Convert(const std::string& value, chaotic::convert::To); +} +std::string Convert(const std::uint64_t& value, chaotic::convert::To); + +USERVER_NAMESPACE_END diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.cpp new file mode 100644 index 0000000..9afa422 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.cpp @@ -0,0 +1,22 @@ +#include "bytes.hpp" + +#include "td/utils/base64.h" +#include "utils/exceptions.hpp" + + +ton_http::types::bytes userver::chaotic::convert::Convert(const std::string& value, chaotic::convert::To) { + if (value.empty()) { + return ton_http::types::bytes{}; + } + auto res = td::base64_decode(value); + if (res.is_error()) { + throw ton_http::utils::ParsingException("invalid base64 encoded bytes: " + res.move_as_error().message().str()); + } + return ton_http::types::bytes{res.move_as_ok()}; +} +std::string userver::chaotic::convert::Convert(const ton_http::types::bytes& value, chaotic::convert::To) { + if (value.GetUnderlying().empty()) { + return ""; + } + return td::base64_encode(value.GetUnderlying()); +} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.hpp new file mode 100644 index 0000000..5dceb69 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/bytes.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +namespace ton_http::types { +class bytes : public USERVER_NAMESPACE::utils::StrongTypedef { + using StrongTypedef::StrongTypedef; +}; +} + +USERVER_NAMESPACE_BEGIN + +namespace chaotic::convert { +ton_http::types::bytes Convert(const std::string& value, chaotic::convert::To); +std::string Convert(const ton_http::types::bytes& value, chaotic::convert::To); + +} + +USERVER_NAMESPACE_END diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/int256.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/int256.cpp new file mode 100644 index 0000000..5324655 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/int256.cpp @@ -0,0 +1,19 @@ +#include "int256.hpp" + +#include "common/refint.h" +#include "utils/exceptions.hpp" + + +ton_http::types::int256 +chaotic::convert::Convert(const std::string& value, userver::chaotic::convert::To) { + auto integer = td::string_to_int256(value); + if (integer.is_null()) { + throw ton_http::utils::ParsingException{"Failed to parse int256: '" + value + "'"}; + } + return ton_http::types::int256{integer->to_dec_string()}; +} + +std::string +chaotic::convert::Convert(const ton_http::types::int256& value, userver::chaotic::convert::To) { + return value.GetUnderlying(); +} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/int256.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/int256.hpp new file mode 100644 index 0000000..e26521a --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/int256.hpp @@ -0,0 +1,17 @@ +#pragma once +#include +#include "userver/chaotic/io/userver/utils/strong_typedef.hpp" + +namespace ton_http::types { + +class int256 : public USERVER_NAMESPACE::utils::StrongTypedef { + using StrongTypedef::StrongTypedef; +}; +} + +namespace chaotic::convert { + +ton_http::types::int256 Convert(const std::string& value, USERVER_NAMESPACE::chaotic::convert::To); +std::string Convert(const ton_http::types::int256& value, USERVER_NAMESPACE::chaotic::convert::To); + +} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp deleted file mode 100644 index 075da71..0000000 --- a/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "shard_id.hpp" -#include "utils/exceptions.hpp" - -ton_http::types::shard_id -userver::chaotic::convert::Convert(const std::string& value, chaotic::convert::To) { - try { - return ton_http::types::shard_id{std::stoll(value)}; - } catch (...) { - throw ton_http::utils::ParsingException{"Failed to parse shard_id: '" + value + "'"}; - } -} -std::string -userver::chaotic::convert::Convert(const ton_http::types::shard_id& value, chaotic::convert::To) { - return std::to_string(value.GetUnderlying()); -} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp deleted file mode 100644 index eaabd58..0000000 --- a/ton-http-api/src/userver/chaotic/io/ton_http/types/shard_id.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include - -namespace ton_http::types { -class shard_id : public USERVER_NAMESPACE::utils::StrongTypedef { - using StrongTypedef::StrongTypedef; -}; -} - -USERVER_NAMESPACE_BEGIN - -namespace chaotic::convert { - -ton_http::types::shard_id Convert(const std::string& value, chaotic::convert::To); -std::string Convert(const ton_http::types::shard_id& value, chaotic::convert::To); - -} - -USERVER_NAMESPACE_END diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.cpp new file mode 100644 index 0000000..bb218b3 --- /dev/null +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.cpp @@ -0,0 +1,24 @@ +#include "ton_addr.hpp" + +#include "block.h" +#include "utils/exceptions.hpp" + + +ton_http::types::ton_addr +userver::chaotic::convert::Convert(const std::string& value, chaotic::convert::To) { + auto r_addr = block::StdAddress::parse(value); + if (r_addr.is_error()) { + throw ton_http::utils::ParsingException{"Failed to parse ton_addr: '" + value + "': " + r_addr.error().message().str()}; + } + auto addr = r_addr.move_as_ok(); + if (value.find(':') != std::string::npos) { + auto raw_addr = fmt::format("{}:{}", addr.workchain, td::hex_encode(addr.addr.as_slice())); + return ton_http::types::ton_addr{raw_addr}; + } + + return ton_http::types::ton_addr{addr.rserialize()}; +} +std::string +userver::chaotic::convert::Convert(const ton_http::types::ton_addr& hash, chaotic::convert::To) { + return hash.GetUnderlying(); +} diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp index 3f59c93..56f35c3 100644 --- a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_addr.hpp @@ -1,2 +1,23 @@ #pragma once +#include +#include + +#include + +namespace ton_http::types { +class ton_addr : public USERVER_NAMESPACE::utils::StrongTypedef { + using StrongTypedef::StrongTypedef; +}; +} + +USERVER_NAMESPACE_BEGIN + +namespace chaotic::convert { + +ton_http::types::ton_addr Convert(const std::string& str, chaotic::convert::To); +std::string Convert(const ton_http::types::ton_addr& hash, chaotic::convert::To); + +} + +USERVER_NAMESPACE_END diff --git a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp index 3fc9309..ffabf4c 100644 --- a/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp +++ b/ton-http-api/src/userver/chaotic/io/ton_http/types/ton_hash.cpp @@ -8,7 +8,7 @@ ton_http::types::ton_hash userver::chaotic::convert::Convert(const std::string& str, chaotic::convert::To) { if (str.empty()) { - return ton_http::types::ton_hash{str}; + return ton_http::types::ton_hash{""}; } if (str.length() == 44) { diff --git a/ton-http-api/src/utils/common.hpp b/ton-http-api/src/utils/common.hpp index 95100bb..ddd4f2d 100644 --- a/ton-http-api/src/utils/common.hpp +++ b/ton-http-api/src/utils/common.hpp @@ -9,7 +9,6 @@ #include "td/utils/Status.h" #include "td/utils/base64.h" #include "td/utils/misc.h" -#include "tokens-tlb.h" #include "vm/cells/Cell.h" #include "vm/cells/CellSlice.h" diff --git a/ton-http-api/static/index.html b/ton-http-api/static/index.html index e38d918..0e963a2 100644 --- a/ton-http-api/static/index.html +++ b/ton-http-api/static/index.html @@ -6,12 +6,12 @@ TON Center API v2 - +
- - + +