Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::impl::abi_from_variant Struct Reference

#include <abi_serializer.hpp>

Static Public Member Functions

template<typename M , typename Resolver , not_require_abi_t< M > = 1>
static void extract (const fc::variant &v, M &o, Resolver, abi_traverse_context &ctx)
 
template<typename M , typename Resolver , require_abi_t< M > = 1>
static void extract (const fc::variant &v, M &o, Resolver resolver, abi_traverse_context &ctx)
 
template<typename M , typename Resolver , require_abi_t< M > = 1>
static void extract (const fc::variant &v, vector< M > &o, Resolver resolver, abi_traverse_context &ctx)
 
template<typename M , typename Resolver , require_abi_t< M > = 1>
static void extract (const fc::variant &v, std::shared_ptr< M > &o, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void extract (const fc::variant &v, action &act, Resolver resolver, abi_traverse_context &ctx)
 
template<typename Resolver >
static void extract (const fc::variant &v, packed_transaction &ptrx, Resolver resolver, abi_traverse_context &ctx)
 

Detailed Description

Definition at line 696 of file abi_serializer.hpp.

Member Function Documentation

◆ extract() [1/6]

template<typename Resolver >
static void sysio::chain::impl::abi_from_variant::extract ( const fc::variant & v,
action & act,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

Non templated overload that has priority for the action structure this type has members which must be directly translated by the ABI so it is exploded and processed explicitly

Definition at line 753 of file abi_serializer.hpp.

754 {
755 auto h = ctx.enter_scope();
756 const variant_object& vo = v.get_object();
757 SYS_ASSERT(vo.contains("account"), packed_transaction_type_exception, "Missing account");
758 SYS_ASSERT(vo.contains("name"), packed_transaction_type_exception, "Missing name");
759 from_variant(vo["account"], act.account);
760 from_variant(vo["name"], act.name);
761
762 if (vo.contains("authorization")) {
763 from_variant(vo["authorization"], act.authorization);
764 }
765
766 bool valid_empty_data = false;
767 if( vo.contains( "data" ) ) {
768 const auto& data = vo["data"];
769 if( data.is_string() ) {
770 from_variant(data, act.data);
771 valid_empty_data = act.data.empty();
772 } else if ( data.is_object() ) {
773 auto abi = resolver(act.account);
774 if (abi) {
775 auto type = abi->get_action_type(act.name);
776 if (!type.empty()) {
777 variant_to_binary_context _ctx(*abi, ctx, type);
778 _ctx.short_path = true; // Just to be safe while avoiding the complexity of threading an override boolean all over the place
779 act.data = std::move( abi->_variant_to_binary( type, data, _ctx ));
780 valid_empty_data = act.data.empty();
781 }
782 }
783 }
784 }
785
786 if( !valid_empty_data && act.data.empty() ) {
787 if( vo.contains( "hex_data" ) ) {
788 const auto& data = vo["hex_data"];
789 if( data.is_string() ) {
790 from_variant(data, act.data);
791 }
792 }
793 }
794
795 SYS_ASSERT(valid_empty_data || !act.data.empty(), packed_transaction_type_exception,
796 "Failed to deserialize data for ${account}:${name}", ("account", act.account)("name", act.name));
797 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
variant_object & get_object()
Definition variant.cpp:554
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
Here is the call graph for this function:

◆ extract() [2/6]

template<typename M , typename Resolver , require_abi_t< M > = 1>
static void sysio::chain::impl::abi_from_variant::extract ( const fc::variant & v,
M & o,
Resolver resolver,
abi_traverse_context & ctx )
static

template which overloads extract for types which contain ABI information in their trees for these types we create new ABI aware visitors

◆ extract() [3/6]

template<typename M , typename Resolver , require_abi_t< M > >
void sysio::chain::impl::abi_from_variant::extract ( const fc::variant & v,
M & o,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

template which overloads extract for types which are not relvant to ABI information and can be degraded to the normal ::from_variant(...) processing

Definition at line 702 of file abi_serializer.hpp.

703 {
704 auto h = ctx.enter_scope();
705 from_variant(v, o);
706 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ extract() [4/6]

template<typename Resolver >
static void sysio::chain::impl::abi_from_variant::extract ( const fc::variant & v,
packed_transaction & ptrx,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

Definition at line 800 of file abi_serializer.hpp.

801 {
802 auto h = ctx.enter_scope();
803 const variant_object& vo = v.get_object();
804 SYS_ASSERT(vo.contains("signatures"), packed_transaction_type_exception, "Missing signatures");
805 SYS_ASSERT(vo.contains("compression"), packed_transaction_type_exception, "Missing compression");
806 std::vector<signature_type> signatures;
808 from_variant(vo["signatures"], signatures);
809 from_variant(vo["compression"], compression);
810
811 bytes packed_cfd;
812 std::vector<bytes> cfd;
813 bool use_packed_cfd = false;
814 if( vo.contains("packed_context_free_data") && vo["packed_context_free_data"].is_string() && !vo["packed_context_free_data"].as_string().empty() ) {
815 from_variant(vo["packed_context_free_data"], packed_cfd );
816 use_packed_cfd = true;
817 } else if( vo.contains("context_free_data") ) {
818 from_variant(vo["context_free_data"], cfd);
819 }
820
821 if( vo.contains("packed_trx") && vo["packed_trx"].is_string() && !vo["packed_trx"].as_string().empty() ) {
822 bytes packed_trx;
823 from_variant(vo["packed_trx"], packed_trx);
824 if( use_packed_cfd ) {
825 ptrx = packed_transaction( std::move( packed_trx ), std::move( signatures ), std::move( packed_cfd ), compression );
826 } else {
827 ptrx = packed_transaction( std::move( packed_trx ), std::move( signatures ), std::move( cfd ), compression );
828 }
829 } else {
830 SYS_ASSERT(vo.contains("transaction"), packed_transaction_type_exception, "Missing transaction");
831 if( use_packed_cfd ) {
832 transaction trx;
833 extract( vo["transaction"], trx, resolver, ctx );
834 ptrx = packed_transaction( std::move(trx), std::move(signatures), std::move(packed_cfd), compression );
835 } else {
836 signed_transaction trx;
837 extract( vo["transaction"], trx, resolver, ctx );
838 trx.signatures = std::move( signatures );
839 trx.context_free_data = std::move(cfd);
840 ptrx = packed_transaction( std::move( trx ), compression );
841 }
842 }
843 }
vector< char > bytes
Definition types.hpp:243
#define extract(n)
Here is the call graph for this function:

◆ extract() [5/6]

template<typename M , typename Resolver , require_abi_t< M > = 1>
static void sysio::chain::impl::abi_from_variant::extract ( const fc::variant & v,
std::shared_ptr< M > & o,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

template which overloads extract for shared_ptr of types which contain ABI information in their trees for these members we call extract in order to trigger further processing

Definition at line 738 of file abi_serializer.hpp.

739 {
740 auto h = ctx.enter_scope();
741 const variant_object& vo = v.get_object();
742 M obj;
743 extract(vo, obj, resolver, ctx);
744 o = std::make_shared<M>(obj);
745 }
Here is the call graph for this function:

◆ extract() [6/6]

template<typename M , typename Resolver , require_abi_t< M > = 1>
static void sysio::chain::impl::abi_from_variant::extract ( const fc::variant & v,
vector< M > & o,
Resolver resolver,
abi_traverse_context & ctx )
inlinestatic

template which overloads extract for vectors of types which contain ABI information in their trees for these members we call extract in order to trigger further processing

Definition at line 720 of file abi_serializer.hpp.

721 {
722 auto h = ctx.enter_scope();
723 const variants& array = v.get_array();
724 o.clear();
725 o.reserve( array.size() );
726 for( auto itr = array.begin(); itr != array.end(); ++itr ) {
727 M o_iter;
728 extract(*itr, o_iter, resolver, ctx);
729 o.emplace_back(std::move(o_iter));
730 }
731 }
variants & get_array()
Definition variant.cpp:496
std::vector< fc::variant > variants
Definition variant.hpp:173
value::array array
Here is the call graph for this function:

The documentation for this struct was generated from the following file: