From fc4e239c82aed70e732aa5b3e15da6aa6ef9b0e2 Mon Sep 17 00:00:00 2001 From: Jeeyong Um Date: Wed, 12 Jun 2019 00:01:44 +0900 Subject: [PATCH] Enable extended_asset to be encoded from array --- libraries/chain/include/eosio/chain/asset.hpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libraries/chain/include/eosio/chain/asset.hpp b/libraries/chain/include/eosio/chain/asset.hpp index 85222652a02..f75420cbb52 100644 --- a/libraries/chain/include/eosio/chain/asset.hpp +++ b/libraries/chain/include/eosio/chain/asset.hpp @@ -114,5 +114,19 @@ inline void from_variant(const fc::variant& var, eosio::chain::asset& vo) { } } +namespace fc { +inline void from_variant(const fc::variant& var, eosio::chain::extended_asset& vo) { + if( var.is_array() ) { + const auto& va = var.get_array(); + from_variant(va.at(0), vo.quantity); + from_variant(va.at(1), vo.contract); + } else { + const auto& vars = var.get_object(); + from_variant(vars["quantity"], vo.quantity); + from_variant(vars["contract"], vo.contract); + } +} +} + FC_REFLECT(eosio::chain::asset, (amount)(sym)) FC_REFLECT(eosio::chain::extended_asset, (quantity)(contract) )