Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Standardize JSON formatting of action data (epe 151) #10100

Merged
merged 3 commits into from
Mar 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions libraries/chain/include/eosio/chain/abi_serializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,20 +432,11 @@ namespace impl {
binary_to_variant_context _ctx(*abi, ctx, type);
_ctx.short_path = true; // Just to be safe while avoiding the complexity of threading an override boolean all over the place
mvo( "data", abi->_binary_to_variant( type, act.data, _ctx ));
mvo("hex_data", act.data);
} catch(...) {
// any failure to serialize data, then leave as not serailzed
mvo("data", act.data);
}
} else {
mvo("data", act.data);
} catch(...) {}
}
} else {
mvo("data", act.data);
}
} catch(...) {
mvo("data", act.data);
}
}catch(...) {}
mvo("hex_data", act.data);
out(name, std::move(mvo));
}

Expand Down Expand Up @@ -829,7 +820,7 @@ namespace impl {
}
}

if( !valid_empty_data && act.data.empty() ) {
if( ( !valid_empty_data && act.data.empty() ) || !vo.contains( "data" ) ) {
if( vo.contains( "hex_data" ) ) {
const auto& data = vo["hex_data"];
if( data.is_string() ) {
Expand Down
6 changes: 3 additions & 3 deletions unittests/abi_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2700,8 +2700,8 @@ BOOST_AUTO_TEST_CASE(abi_large_signature)
BOOST_CHECK_LE( (stop - start).count(), 51*1000 );
// only contains hex_data if it didn't hit the deadline
if( check_data ) {
BOOST_CHECK( var.get_object().contains( "data" ) );
BOOST_CHECK( !var.get_object().contains( "hex_data" ) );
BOOST_CHECK( !var.get_object().contains( "data" ) );
brianjohnson5972 marked this conversation as resolved.
Show resolved Hide resolved
BOOST_CHECK( var.get_object().contains( "hex_data" ) );
}
} FC_LOG_AND_RETHROW()
}
Expand Down Expand Up @@ -3356,7 +3356,7 @@ inline std::pair<action_trace, std::string> generate_action_trace(const std::opt
<< "\"actor\":\"acctest\","
<< "\"permission\":\"active\""
<< "}],"
<< "\"data\":\"09746573745f64617461\""
<< "\"hex_data\":\"09746573745f64617461\""
<< "},"
<< "\"context_free\":false,"
<< "\"elapsed\":3,"
Expand Down