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

Commit

Permalink
Merge pull request #10100 from EOSIO/keke_epe151
Browse files Browse the repository at this point in the history
Standardize JSON formatting of action data (epe 151)
  • Loading branch information
brianjohnson5972 authored Mar 8, 2021
2 parents 7e2063e + e080f35 commit 24f4b8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
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
8 changes: 4 additions & 4 deletions unittests/abi_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2698,10 +2698,10 @@ BOOST_AUTO_TEST_CASE(abi_large_signature)
auto stop = fc::time_point::now();
// Give it a leaway of 50ms
BOOST_CHECK_LE( (stop - start).count(), 51*1000 );
// only contains hex_data if it didn't hit the deadline
// contains only 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" ) );
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

0 comments on commit 24f4b8f

Please sign in to comment.