14 #include "scale/scale.hpp" 20 std::shared_ptr<const crypto::Hasher> hasher,
21 std::shared_ptr<const runtime::MemoryProvider> memory_provider,
22 std::shared_ptr<const runtime::CoreApiFactory> core_factory)
23 : hasher_{std::move(hasher)},
37 auto code = memory.loadN(ptr, len);
42 static const auto kErrorRes =
43 scale::encode<std::optional<primitives::Version>>(std::nullopt).value();
45 if (uncompress_res.has_error()) {
47 "Error uncompressing code: {}",
48 uncompress_res.error().message());
49 return memory.storeBuffer(kErrorRes);
53 auto version_res = core_api->version();
56 if (version_res.has_value()) {
57 auto enc_version_res = scale::encode(
58 std::make_optional(scale::encode(version_res.value()).value()));
59 if (enc_version_res.has_error()) {
61 "Error encoding ext_misc_runtime_version_version_1 result: {}",
62 enc_version_res.error().message());
63 return memory.storeBuffer(kErrorRes);
65 auto res_span = memory.storeBuffer(enc_version_res.value());
68 logger_->error(
"Error inside Core_version: {}",
69 version_res.error().message());
70 return memory.storeBuffer(kErrorRes);
77 logger_->info(
"hex: {}", buf.toHex());
81 logger_->info(
"num: {}", value);
88 logger_->info(
"utf8: {}", buf.toString());
runtime::WasmSpan ext_misc_runtime_version_version_1(runtime::WasmSpan data) const
Class represents arbitrary (including empty) byte buffer.
static constexpr std::pair< WasmPointer, WasmSize > splitSpan(WasmSpan span)
const std::vector< uint8_t > & asVector() const
getter for vector of bytes
#define SL_TRACE_FUNC_CALL(logger, ret,...)
std::shared_ptr< const runtime::CoreApiFactory > core_factory_
std::shared_ptr< const crypto::Hasher > hasher_
void ext_misc_print_utf8_version_1(runtime::WasmSpan data) const
uint64_t WasmSpan
combination of pointer and size, where less significant part represents wasm pointer, and most significant represents size
MiscExtension(uint64_t chain_id, std::shared_ptr< const crypto::Hasher > hasher, std::shared_ptr< const runtime::MemoryProvider > memory_provider, std::shared_ptr< const runtime::CoreApiFactory > core_provider)
std::shared_ptr< const runtime::MemoryProvider > memory_provider_
void ext_misc_print_num_version_1(uint64_t value) const
Logger createLogger(const std::string &tag)
void ext_misc_print_hex_version_1(runtime::WasmSpan data) const
outcome::result< void > uncompressCodeIfNeeded(common::BufferView buf, common::Buffer &res)