6#ifndef OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_UTIL_H_
7#define OPENCBDC_TX_SRC_PARSEC_AGENT_RUNNERS_EVM_UTIL_H_
16#include <evmc/evmc.hpp>
17#include <evmc/hex.hpp>
20#include <secp256k1_extrakeys.h>
21#include <secp256k1_recovery.h>
27 auto to_uint64(
const evmc::uint256be& v) -> uint64_t;
34 auto to_hex(
const T& v) -> std::string {
35 return evmc::hex(evmc::bytes(v.bytes,
sizeof(v.bytes)));
39 const std::string& prefix =
"0x") -> std::string;
55 typename std::enable_if_t<std::is_same<T, evmc::bytes32>::value
56 || std::is_same<T, evmc::address>::value,
59 if(!maybe_bytes.has_value()) {
62 if(maybe_bytes.value().size() !=
sizeof(T)) {
67 std::memcpy(val.bytes,
68 maybe_bytes.value().data(),
69 maybe_bytes.value().size());
78 -> std::optional<evmc::uint256be>;
84 const std::shared_ptr<logging::log>& log,
85 const std::shared_ptr<parsec::broker::interface>& broker) -> bool;
Buffer to store and retrieve byte data.
static auto from_hex_prefixed(const std::string &hex, const std::string &prefix="0x") -> std::optional< buffer >
Creates a new buffer from the provided hex string optionally prefixed with a prefix sequence.
auto mint_initial_accounts(const std::shared_ptr< logging::log > &log, const std::shared_ptr< parsec::broker::interface > &broker) -> bool
Mints a set of initial accounts with funds, bypassing the agent.
auto to_hex_trimmed(const evmc::bytes32 &b, const std::string &prefix) -> std::string
auto to_hex(const evmc::address &addr) -> std::string
auto uint256be_from_hex(const std::string &hex) -> std::optional< evmc::uint256be >
Generates a uint256be from a hex string.
auto from_hex(const std::string &hex) -> typename std::enable_if_t< std::is_same< T, evmc::bytes32 >::value||std::is_same< T, evmc::address >::value, std::optional< T > >
Parses hexadecimal representation in string format to T.
void add_to_bloom(cbdc::buffer &bloom, const cbdc::buffer &entry)
Adds an entry to a bloom value.
auto to_uint64(const evmc::uint256be &v) -> uint64_t
Converts an uint256be to a uint64_t, ignoring higher order bits.