diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt | |
index 42a6e37..01e0c25 100644 | |
--- a/tools/CMakeLists.txt | |
+++ b/tools/CMakeLists.txt | |
@@ -14,3 +14,7 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/eosiocpp DESTINATION ${CMAKE_INSTALL_ | |
add_executable( print_floats print_floats.cpp ) | |
target_include_directories( print_floats PRIVATE ${Boost_INCLUDE_DIR} ) | |
target_link_libraries( print_floats PRIVATE ${Boost_LIBRARIES} ) | |
+ | |
+add_executable( abi_from_hex abi_from_hex.cpp ) | |
+target_include_directories( abi_from_hex PRIVATE ${Boost_INCLUDE_DIR} ) | |
+target_link_libraries( abi_from_hex PRIVATE eosio_chain fc ${Boost_LIBRARIES} ) | |
\ No newline at end of file | |
diff --git a/tools/abi_from_hex.cpp b/tools/abi_from_hex.cpp | |
new file mode 100644 | |
index 0000000..383811a | |
--- /dev/null | |
+++ b/tools/abi_from_hex.cpp | |
@@ -0,0 +1,58 @@ | |
+/** | |
+ * @file | |
+ * @copyright defined in eos/LICENSE.txt | |
+ */ | |
+ | |
+#include <eosio/chain/asset.hpp> | |
+#include <eosio/chain/block_log.hpp> | |
+#include <eosio/chain/transaction.hpp> | |
+#include <eosio/chain/block_header_state.hpp> | |
+#include <eosio/chain/abi_serializer.hpp> | |
+#include <eosio/chain/authority.hpp> | |
+#include <fc/io/raw.hpp> | |
+#include <fc/io/json.hpp> | |
+#include <fc/crypto/hex.hpp> | |
+#include <fc/optional.hpp> | |
+#include <fc/reflect/reflect.hpp> | |
+#include <fc/filesystem.hpp> | |
+ | |
+using namespace eosio; | |
+using namespace eosio::chain; | |
+using namespace chainbase; | |
+using namespace fc; | |
+using namespace std; | |
+ | |
+#include <boost/program_options.hpp> | |
+ | |
+namespace po = boost::program_options; | |
+ | |
+int main(int argc, const char **argv) { | |
+ | |
+ try { | |
+ | |
+ std::istream *in; | |
+ std::ifstream ifn; | |
+ | |
+ if ( argc == 1 ) { | |
+ in=&cin; | |
+ } else { | |
+ ifn.open(argv[1]); | |
+ in=&ifn; | |
+ } | |
+ | |
+ std::stringstream buffer; | |
+ buffer << in->rdbuf(); | |
+ | |
+ auto str_hex_abi = buffer.str(); | |
+ bytes bin_abi(str_hex_abi.size()/2); | |
+ | |
+ from_hex(buffer.str(), bin_abi.data(), bin_abi.size()); | |
+ auto abi = fc::raw::unpack<abi_def>(bin_abi.data(), bin_abi.size()); | |
+ | |
+ cout << fc::json::to_string(abi) << std::endl; | |
+ | |
+ return 0; | |
+ | |
+ } FC_CAPTURE_AND_LOG(()); | |
+ return 1; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment