@@ -1644,16 +1644,18 @@ read_only::get_account_results read_only::get_account( const get_account_params&
1644
1644
1645
1645
const auto token_code = N (eosio.token );
1646
1646
1647
+ auto core_symbol = extract_core_symbol ();
1648
+
1647
1649
const auto * t_id = d.find <chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple ( token_code, params.account_name , N (accounts) ));
1648
1650
if ( t_id != nullptr ) {
1649
1651
const auto &idx = d.get_index <key_value_index, by_scope_primary>();
1650
- auto it = idx.find (boost::make_tuple ( t_id->id , symbol () .to_symbol_code () ));
1652
+ auto it = idx.find (boost::make_tuple ( t_id->id , core_symbol .to_symbol_code () ));
1651
1653
if ( it != idx.end () && it->value .size () >= sizeof (asset) ) {
1652
1654
asset bal;
1653
1655
fc::datastream<const char *> ds (it->value .data (), it->value .size ());
1654
1656
fc::raw::unpack (ds, bal);
1655
1657
1656
- if ( bal.get_symbol ().valid () && bal.get_symbol () == symbol () ) {
1658
+ if ( bal.get_symbol ().valid () && bal.get_symbol () == core_symbol ) {
1657
1659
result.core_liquid_balance = bal;
1658
1660
}
1659
1661
}
@@ -1766,6 +1768,46 @@ read_only::get_transaction_id_result read_only::get_transaction_id( const read_o
1766
1768
return params.id ();
1767
1769
}
1768
1770
1771
+ namespace detail {
1772
+ struct ram_market_exchange_state_t {
1773
+ asset ignore1;
1774
+ asset ignore2;
1775
+ double ignore3;
1776
+ asset core_symbol;
1777
+ double ignore4;
1778
+ };
1779
+ }
1780
+
1781
+ chain::symbol read_only::extract_core_symbol ()const {
1782
+ symbol core_symbol; // Default to CORE_SYMBOL if the appropriate data structure cannot be found in the system contract table data
1783
+
1784
+ // The following code makes assumptions about the contract deployed on eosio account (i.e. the system contract) and how it stores its data.
1785
+ const auto & d = db.db ();
1786
+ const auto * t_id = d.find <chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple ( N (eosio), N (eosio), N (rammarket) ));
1787
+ if ( t_id != nullptr ) {
1788
+ const auto &idx = d.get_index <key_value_index, by_scope_primary>();
1789
+ auto it = idx.find (boost::make_tuple ( t_id->id , eosio::chain::string_to_symbol_c (4 ," RAMCORE" ) ));
1790
+ if ( it != idx.end () ) {
1791
+ detail::ram_market_exchange_state_t ram_market_exchange_state;
1792
+
1793
+ fc::datastream<const char *> ds ( it->value .data (), it->value .size () );
1794
+
1795
+ try {
1796
+ fc::raw::unpack (ds, ram_market_exchange_state);
1797
+ } catch ( ... ) {
1798
+ return core_symbol;
1799
+ }
1800
+
1801
+ if ( ram_market_exchange_state.core_symbol .get_symbol ().valid () ) {
1802
+ core_symbol = ram_market_exchange_state.core_symbol .get_symbol ();
1803
+ }
1804
+ }
1805
+ }
1806
+
1807
+ return core_symbol;
1808
+ }
1769
1809
1770
1810
} // namespace chain_apis
1771
1811
} // namespace eosio
1812
+
1813
+ FC_REFLECT ( eosio::chain_apis::detail::ram_market_exchange_state_t , (ignore1)(ignore2)(ignore3)(core_symbol)(ignore4) )
0 commit comments