From 8c7ad76e384f729ad90595d6eb5f02808c69f9eb Mon Sep 17 00:00:00 2001 From: baris g Date: Mon, 24 Apr 2023 21:08:27 +0300 Subject: [PATCH] Fixes for clang-17 c++17 fixes for clang compiler --- libraries/db/include/graphene/db/index.hpp | 2 +- .../bitcoin/bitcoin_address.hpp | 3 +- .../include/graphene/wallet/reflect_util.hpp | 14 +- .../wallet/include/graphene/wallet/wallet.hpp | 88 ++++---- libraries/wallet/wallet.cpp | 203 +++++++++--------- tests/elasticsearch/main.cpp | 4 +- tests/tests/database_tests.cpp | 2 +- 7 files changed, 161 insertions(+), 155 deletions(-) diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp index 1bc593f4..3ef8b52d 100644 --- a/libraries/db/include/graphene/db/index.hpp +++ b/libraries/db/include/graphene/db/index.hpp @@ -277,7 +277,7 @@ namespace graphene { namespace db { { static_assert( object_id::space_id == Object::space_id, "Space ID mismatch!" ); static_assert( object_id::type_id == Object::type_id, "Type_ID mismatch!" ); - if( id.instance >= next ) return nullptr; + if( (size_t) id.instance >= next ) return nullptr; return content[id.instance.value >> chunkbits][id.instance.value & _mask]; }; diff --git a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp index b9467e2f..a2823198 100644 --- a/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp +++ b/libraries/plugins/peerplays_sidechain/include/graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp @@ -214,10 +214,11 @@ public: btc_timelocked_one_or_weighted_multisig_address(const fc::ecc::public_key &user_key_data, uint32_t latency, const std::vector> &keys_data, network network_type = network::regtest); + uint32_t latency_; + private: void create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector> &keys_data); - uint32_t latency_; }; }}} // namespace graphene::peerplays_sidechain::bitcoin diff --git a/libraries/wallet/include/graphene/wallet/reflect_util.hpp b/libraries/wallet/include/graphene/wallet/reflect_util.hpp index 44c0f412..e5af4ad0 100644 --- a/libraries/wallet/include/graphene/wallet/reflect_util.hpp +++ b/libraries/wallet/include/graphene/wallet/reflect_util.hpp @@ -27,12 +27,16 @@ // support the wallet, e.g. allow specifying operations by name // instead of ID. +#include "fc/variant.hpp" +#include +#include + namespace graphene { namespace wallet { struct static_variant_map { - flat_map< string, int > name_to_which; - vector< string > which_to_name; + flat_map< std::string, int > name_to_which; + std::vector< std::string > which_to_name; }; namespace impl { @@ -84,16 +88,16 @@ struct from_which_visitor return result; // converted from StaticVariant to Result automatically due to return type } - const variant& v; + const fc::variant& v; const uint32_t _max_depth; - from_which_visitor( const variant& _v, uint32_t max_depth ) : v(_v), _max_depth(max_depth) {} + from_which_visitor( const fc::variant& _v, uint32_t max_depth ) : v(_v), _max_depth(max_depth) {} }; } // namespace impl template< typename T > -T from_which_variant( int which, const variant& v, uint32_t max_depth ) +T from_which_variant( int which, const fc::variant& v, uint32_t max_depth ) { // Parse a variant for a known which() T dummy; diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 02790e19..855cbd47 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -47,7 +47,7 @@ typedef uint16_t transaction_handle_type; * of the given type, with the new operator. */ -object* create_object( const variant& v ); +object* create_object( const fc::variant& v ); struct plain_keys { @@ -306,13 +306,13 @@ class wallet_api fc::ecc::private_key derive_private_key(const std::string& prefix_string, int sequence_number) const; - variant info(); + fc::variant info(); /** Returns info such as client version, git version of graphene/fc, version of boost, openssl. * @returns compile time info and client and dependencies versions */ variant_object about() const; - optional get_block( uint32_t num ); - vector> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const; + fc::optional get_block( uint32_t num ); + vector> get_blocks(uint32_t block_num_from, uint32_t block_num_to)const; /** Returns the number of accounts registered on the blockchain * @returns the number of registered accounts */ @@ -460,7 +460,7 @@ class wallet_api * @param id the id of the object to return * @returns the requested object */ - variant get_object(object_id_type id) const; + fc::variant get_object(object_id_type id) const; /** Returns the current wallet filename. * @@ -1127,7 +1127,7 @@ class wallet_api * @returns the signed transaction updating the asset */ signed_transaction update_asset(string symbol, - optional new_issuer, + fc::optional new_issuer, asset_options new_options, bool broadcast = false); @@ -1465,8 +1465,8 @@ class wallet_api * @param broadcast true if you wish to broadcast the transaction. */ signed_transaction update_son_vesting_balances(string owner_account, - optional new_deposit, - optional new_pay_vb, + fc::optional new_deposit, + fc::optional new_pay_vb, bool broadcast = false); /** Modify status of the SON owned by the given account to maintenance. @@ -1519,21 +1519,21 @@ class wallet_api * @brief Get active SON wallet * @return Active SON wallet object */ - optional get_active_son_wallet(); + fc::optional get_active_son_wallet(); /** * @brief Get SON wallet that was active for a given time point * @param time_point Time point * @return SON wallet object, for the wallet that was active for a given time point */ - optional get_son_wallet_by_time_point(time_point_sec time_point); + fc::optional get_son_wallet_by_time_point(time_point_sec time_point); /** * @brief Get full list of SON wallets * @param limit Maximum number of results to return * @return A list of SON wallet objects */ - vector> get_son_wallets(uint32_t limit); + vector> get_son_wallets(uint32_t limit); /** Adds sidechain address owned by the given account for a given sidechain. * @@ -1572,14 +1572,14 @@ class wallet_api * @param account the name or id of the account who owns the address * @returns the list of all sidechain addresses owned by given account. */ - vector> get_sidechain_addresses_by_account(string account); + vector> get_sidechain_addresses_by_account(string account); /** Retrieves all sidechain addresses registered for a given sidechain. * * @param sidechain the name of the sidechain * @returns the list of all sidechain addresses registered for a given sidechain. */ - vector> get_sidechain_addresses_by_sidechain(sidechain_type sidechain); + vector> get_sidechain_addresses_by_sidechain(sidechain_type sidechain); /** Retrieves sidechain address owned by given account for a given sidechain. * @@ -1642,7 +1642,7 @@ class wallet_api share_type daily_pay, string name, string url, - variant worker_settings, + fc::variant worker_settings, bool broadcast = false ); @@ -1908,7 +1908,7 @@ class wallet_api * @return the signed transaction changing your vote proxy settings */ signed_transaction set_voting_proxy(string account_to_modify, - optional voting_account, + fc::optional voting_account, bool broadcast = false); /** Set your vote for the number of witnesses and committee_members in the system. @@ -2340,13 +2340,13 @@ class wallet_api string name, string symbol, string base_uri, - optional revenue_partner, - optional revenue_split, + fc::optional revenue_partner, + fc::optional revenue_split, bool is_transferable, bool is_sellable, - optional role_id, - optional max_supply, - optional lottery_options, + fc::optional role_id, + fc::optional max_supply, + fc::optional lottery_options, bool broadcast); /** @@ -2366,14 +2366,14 @@ class wallet_api */ signed_transaction nft_metadata_update(string owner_account_id_or_name, nft_metadata_id_type nft_metadata_id, - optional name, - optional symbol, - optional base_uri, - optional revenue_partner, - optional revenue_split, - optional is_transferable, - optional is_sellable, - optional role_id, + fc::optional name, + fc::optional symbol, + fc::optional base_uri, + fc::optional revenue_partner, + fc::optional revenue_split, + fc::optional is_transferable, + fc::optional is_sellable, + fc::optional role_id, bool broadcast); /** @@ -2405,7 +2405,7 @@ class wallet_api * @param token_id NFT ID * @return NFT owner account ID */ - optional nft_owner_of(const nft_id_type token_id) const; + fc::optional nft_owner_of(const nft_id_type token_id) const; /** * @brief Transfers NFT safely @@ -2470,7 +2470,7 @@ class wallet_api * @param token_id NFT ID * @return NFT approved account ID */ - optional nft_get_approved(const nft_id_type token_id) const; + fc::optional nft_get_approved(const nft_id_type token_id) const; /** * @brief Returns operator approved state for all NFT owned by owner @@ -2493,7 +2493,7 @@ class wallet_api asset maximum_price, bool buying_item, time_point_sec offer_expiration_date, - optional memo, + fc::optional memo, bool broadcast); signed_transaction create_bid(string bidder_account_id_or_name, asset bid_price, @@ -2502,16 +2502,16 @@ class wallet_api signed_transaction cancel_offer(string issuer_account_id_or_name, offer_id_type offer_id, bool broadcast); - vector list_offers(uint32_t limit, optional lower_id) const; - vector list_sell_offers(uint32_t limit, optional lower_id) const; - vector list_buy_offers(uint32_t limit, optional lower_id) const; - vector list_offer_history(uint32_t limit, optional lower_id) const; + vector list_offers(uint32_t limit, fc::optional lower_id) const; + vector list_sell_offers(uint32_t limit, fc::optional lower_id) const; + vector list_buy_offers(uint32_t limit, fc::optional lower_id) const; + vector list_offer_history(uint32_t limit, fc::optional lower_id) const; vector get_offers_by_issuer(string issuer_account_id_or_name, - uint32_t limit, optional lower_id) const; - vector get_offers_by_item(const nft_id_type item, uint32_t limit, optional lower_id) const; - vector get_offer_history_by_issuer(string issuer_account_id_or_name, uint32_t limit, optional lower_id) const; - vector get_offer_history_by_item(const nft_id_type item, uint32_t limit, optional lower_id) const; - vector get_offer_history_by_bidder(string bidder_account_id_or_name, uint32_t limit, optional lower_id) const; + uint32_t limit, fc::optional lower_id) const; + vector get_offers_by_item(const nft_id_type item, uint32_t limit, fc::optional lower_id) const; + vector get_offer_history_by_issuer(string issuer_account_id_or_name, uint32_t limit, fc::optional lower_id) const; + vector get_offer_history_by_item(const nft_id_type item, uint32_t limit, fc::optional lower_id) const; + vector get_offer_history_by_bidder(string bidder_account_id_or_name, uint32_t limit, fc::optional lower_id) const; signed_transaction create_account_role(string owner_account_id_or_name, string name, @@ -2522,13 +2522,13 @@ class wallet_api bool broadcast); signed_transaction update_account_role(string owner_account_id_or_name, account_role_id_type role_id, - optional name, - optional metadata, + fc::optional name, + fc::optional metadata, flat_set operations_to_add, flat_set operations_to_remove, flat_set accounts_to_add, flat_set accounts_to_remove, - optional valid_to, + fc::optional valid_to, bool broadcast); signed_transaction delete_account_role(string owner_account_id_or_name, account_role_id_type role_id, @@ -2545,7 +2545,7 @@ class wallet_api void flood_network(string prefix, uint32_t number_of_transactions); void network_add_nodes( const vector& nodes ); - vector< variant > network_get_connected_peers(); + vector< fc::variant > network_get_connected_peers(); /** * Used to transfer from one set of blinded balances to another diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index d2fac215..5106063a 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -21,6 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "fc/uint128.hpp" #include #include #include @@ -149,7 +150,7 @@ public: }; template -optional maybe_id( const string& name_or_id ) +fc::optional maybe_id( const string& name_or_id ) { if( std::isdigit( name_or_id.front() ) ) { @@ -161,7 +162,7 @@ optional maybe_id( const string& name_or_id ) { // not an ID } } - return optional(); + return fc::optional(); } string address_to_shorthash( const address& addr ) @@ -378,11 +379,11 @@ private: } fc::mutex _subscribed_object_changed_mutex; - void subscribed_object_changed(const variant& changed_objects_variant) + void subscribed_object_changed(const fc::variant& changed_objects_variant) { fc::scoped_lock lock(_resync_mutex); fc::variants changed_objects = changed_objects_variant.get_array(); - for (const variant& changed_object_variant : changed_objects) + for (const fc::variant& changed_object_variant : changed_objects) { // changed_object_variant is either the object, or just the id if the object was removed if (changed_object_variant.is_object()) @@ -555,12 +556,12 @@ public: } init_prototype_ops(); - _remote_db->set_block_applied_callback( [this](const variant& block_id ) + _remote_db->set_block_applied_callback( [this](const fc::variant& block_id ) { on_block_applied( block_id ); } ); - _remote_db->set_subscribe_callback( [this](const variant& object ) + _remote_db->set_subscribe_callback( [this](const fc::variant& object ) { on_subscribe_callback( object ); }, false ); @@ -599,12 +600,12 @@ public: } } - void on_block_applied( const variant& block_id ) + void on_block_applied( const fc::variant& block_id ) { fc::async([this]{resync();}, "Resync after block"); } - void on_subscribe_callback( const variant& object ) + void on_subscribe_callback( const fc::variant& object ) { //idump((object)); fc::async([this, object]{subscribed_object_changed(object);}, "Object changed"); @@ -668,7 +669,7 @@ public: s->set_fee(op); } - variant info() const + fc::variant info() const { auto chain_props = get_chain_properties(); auto global_props = get_global_properties(); @@ -778,14 +779,14 @@ public: "." + fc::to_string(id.instance.value); return asset_id; } - optional find_asset(asset_id_type id)const + fc::optional find_asset(asset_id_type id)const { auto rec = _remote_db->get_assets({asset_id_to_string(id)}).front(); if( rec ) _asset_cache[id] = *rec; return rec; } - optional find_asset(string asset_symbol_or_id)const + fc::optional find_asset(string asset_symbol_or_id)const { FC_ASSERT( asset_symbol_or_id.size() > 0 ); @@ -799,7 +800,7 @@ public: if( rec ) { if( rec->symbol != asset_symbol_or_id ) - return optional(); + return fc::optional(); _asset_cache[rec->get_id()] = *rec; } @@ -822,7 +823,7 @@ public: asset_id_type get_asset_id(string asset_symbol_or_id) const { FC_ASSERT( asset_symbol_or_id.size() > 0 ); - vector> opt_asset; + vector> opt_asset; if( std::isdigit( asset_symbol_or_id.front() ) ) return fc::variant(asset_symbol_or_id, 1).as( 1 ); opt_asset = _remote_db->lookup_asset_symbols( {asset_symbol_or_id} ); @@ -1063,11 +1064,11 @@ public: account_ids_to_send.push_back( account_id ); ++it; } - std::vector< optional< account_object > > accounts = _remote_db->get_accounts(account_ids_to_send); + std::vector< fc::optional< account_object > > accounts = _remote_db->get_accounts(account_ids_to_send); // server response should be same length as request FC_ASSERT( accounts.size() == account_ids_to_send.size() ); size_t i = 0; - for( const optional< account_object >& acct : accounts ) + for( const fc::optional< account_object >& acct : accounts ) { account_object& old_acct = old_accounts[i]; if( !acct.valid() ) @@ -1652,14 +1653,14 @@ public: signed_transaction update_asset(string symbol, - optional new_issuer, + fc::optional new_issuer, asset_options new_options, bool broadcast /* = false */) { try { - optional asset_to_update = find_asset(symbol); + fc::optional asset_to_update = find_asset(symbol); if (!asset_to_update) FC_THROW("No asset with that symbol exists!"); - optional new_issuer_account_id; + fc::optional new_issuer_account_id; if (new_issuer) { account_object new_issuer_account = get_account(*new_issuer); @@ -1684,7 +1685,7 @@ public: bitasset_options new_options, bool broadcast /* = false */) { try { - optional asset_to_update = find_asset(symbol); + fc::optional asset_to_update = find_asset(symbol); if (!asset_to_update) FC_THROW("No asset with that symbol exists!"); @@ -1705,7 +1706,7 @@ public: dividend_asset_options new_options, bool broadcast /* = false */) { try { - optional asset_to_update = find_asset(symbol); + fc::optional asset_to_update = find_asset(symbol); if (!asset_to_update) FC_THROW("No asset with that symbol exists!"); @@ -1726,7 +1727,7 @@ public: flat_set new_feed_producers, bool broadcast /* = false */) { try { - optional asset_to_update = find_asset(symbol); + fc::optional asset_to_update = find_asset(symbol); if (!asset_to_update) FC_THROW("No asset with that symbol exists!"); @@ -1751,7 +1752,7 @@ public: price_feed feed, bool broadcast /* = false */) { try { - optional asset_to_update = find_asset(symbol); + fc::optional asset_to_update = find_asset(symbol); if (!asset_to_update) FC_THROW("No asset with that symbol exists!"); @@ -1774,7 +1775,7 @@ public: bool broadcast /* = false */) { try { account_object from_account = get_account(from); - optional asset_to_fund = find_asset(symbol); + fc::optional asset_to_fund = find_asset(symbol); if (!asset_to_fund) FC_THROW("No asset with that symbol exists!"); asset_object core_asset = get_asset(asset_id_type()); @@ -1798,7 +1799,7 @@ public: bool broadcast /* = false */) { try { account_object from_account = get_account(from); - optional asset_to_reserve = find_asset(symbol); + fc::optional asset_to_reserve = find_asset(symbol); if (!asset_to_reserve) FC_THROW("No asset with that symbol exists!"); @@ -1818,7 +1819,7 @@ public: price settle_price, bool broadcast /* = false */) { try { - optional asset_to_settle = find_asset(symbol); + fc::optional asset_to_settle = find_asset(symbol); if (!asset_to_settle) FC_THROW("No asset with that symbol exists!"); @@ -1840,7 +1841,7 @@ public: string symbol, bool broadcast /* = false */) { try { - optional asset_to_settle = find_asset(symbol); + fc::optional asset_to_settle = find_asset(symbol); if (!asset_to_settle) FC_THROW("No asset with that symbol exists!"); @@ -2175,8 +2176,8 @@ public: } FC_CAPTURE_AND_RETHROW( (owner_account)(broadcast) ) } signed_transaction update_son_vesting_balances(string owner_account, - optional new_deposit, - optional new_pay_vb, + fc::optional new_deposit, + fc::optional new_pay_vb, bool broadcast /* = false */) { try { son_object son = get_son(owner_account); @@ -2249,7 +2250,7 @@ public: std::string acc_id = account_id_to_string(obj->son_account); owners.push_back(acc_id); } - vector< optional< account_object> > accs = _remote_db->get_accounts(owners); + vector< fc::optional< account_object> > accs = _remote_db->get_accounts(owners); std::remove_if(son_objects.begin(), son_objects.end(), [](const fc::optional& obj) -> bool { return obj.valid(); }); map result; @@ -2296,17 +2297,17 @@ public: return result; } FC_CAPTURE_AND_RETHROW() } - optional get_active_son_wallet() + fc::optional get_active_son_wallet() { try { return _remote_db->get_active_son_wallet(); } FC_CAPTURE_AND_RETHROW() } - optional get_son_wallet_by_time_point(time_point_sec time_point) + fc::optional get_son_wallet_by_time_point(time_point_sec time_point) { try { return _remote_db->get_son_wallet_by_time_point(time_point); } FC_CAPTURE_AND_RETHROW() } - vector> get_son_wallets(uint32_t limit) + vector> get_son_wallets(uint32_t limit) { try { return _remote_db->get_son_wallets(limit); } FC_CAPTURE_AND_RETHROW() } @@ -2482,7 +2483,7 @@ public: } FC_CAPTURE_AND_RETHROW( (witness_name)(url)(block_signing_key)(broadcast) ) } template - static WorkerInit _create_worker_initializer( const variant& worker_settings ) + static WorkerInit _create_worker_initializer( const fc::variant& worker_settings ) { WorkerInit result; from_variant( worker_settings, result, GRAPHENE_MAX_NESTED_OBJECTS ); @@ -2496,7 +2497,7 @@ public: share_type daily_pay, string name, string url, - variant worker_settings, + fc::variant worker_settings, bool broadcast ) { @@ -2569,7 +2570,7 @@ public: flat_set new_votes( acct.options.votes ); fc::variants objects = _remote_db->get_objects( query_ids ); - for( const variant& obj : objects ) + for( const fc::variant& obj : objects ) { worker_object wo; from_variant( obj, wo, GRAPHENE_MAX_NESTED_OBJECTS ); @@ -3069,7 +3070,7 @@ public: } FC_CAPTURE_AND_RETHROW( (voting_account)(witnesses_to_approve)(witnesses_to_reject)(desired_number_of_witnesses)(broadcast) ) } signed_transaction set_voting_proxy(string account_to_modify, - optional voting_account, + fc::optional voting_account, bool broadcast /* = false */) { try { account_object account_object_to_modify = get_account(account_to_modify); @@ -3398,17 +3399,17 @@ public: std::map> get_result_formatters() const { std::map > m; - m["help"] = [](variant result, const fc::variants& a) + m["help"] = [](fc::variant result, const fc::variants& a) { return result.get_string(); }; - m["gethelp"] = [](variant result, const fc::variants& a) + m["gethelp"] = [](fc::variant result, const fc::variants& a) { return result.get_string(); }; - m["get_account_history"] = [this](variant result, const fc::variants& a) + m["get_account_history"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3425,7 +3426,7 @@ public: return ss.str(); }; - m["get_relative_account_history"] = [this](variant result, const fc::variants& a) + m["get_relative_account_history"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3443,7 +3444,7 @@ public: return ss.str(); }; - m["list_account_balances"] = [this](variant result, const fc::variants& a) + m["list_account_balances"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); vector asset_recs; @@ -3458,7 +3459,7 @@ public: return ss.str(); }; - m["list_core_accounts"] = [this](variant result, const fc::variants& a) + m["list_core_accounts"] = [this](fc::variant result, const fc::variants& a) { std::stringstream ss; @@ -3473,7 +3474,7 @@ public: return ss.str(); }; - m["get_blind_balances"] = [this](variant result, const fc::variants& a) + m["get_blind_balances"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); vector asset_recs; @@ -3487,7 +3488,7 @@ public: return ss.str(); }; - m["transfer_to_blind"] = [this](variant result, const fc::variants& a) + m["transfer_to_blind"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3500,7 +3501,7 @@ public: } return ss.str(); }; - m["blind_transfer"] = [this](variant result, const fc::variants& a) + m["blind_transfer"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3513,7 +3514,7 @@ public: } return ss.str(); }; - m["receive_blind_transfer"] = [this](variant result, const fc::variants& a) + m["receive_blind_transfer"] = [this](fc::variant result, const fc::variants& a) { auto r = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3521,7 +3522,7 @@ public: ss << as.amount_to_pretty_string( r.amount ) << " " << r.from_label << " => " << r.to_label << " " << r.memo <<"\n"; return ss.str(); }; - m["blind_history"] = [this](variant result, const fc::variants& a) + m["blind_history"] = [this](fc::variant result, const fc::variants& a) { auto records = result.as>( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3536,7 +3537,7 @@ public: } return ss.str(); }; - m["get_upcoming_tournaments"] = m["get_tournaments"] = m["get_tournaments_by_state"] = [this](variant result, const fc::variants& a) + m["get_upcoming_tournaments"] = m["get_tournaments"] = m["get_tournaments_by_state"] = [this](fc::variant result, const fc::variants& a) { const vector tournaments = result.as >( GRAPHENE_MAX_NESTED_OBJECTS ); std::stringstream ss; @@ -3584,7 +3585,7 @@ public: } return ss.str(); }; - m["get_tournament"] = [this](variant result, const fc::variants& a) + m["get_tournament"] = [this](fc::variant result, const fc::variants& a) { std::stringstream ss; @@ -3685,7 +3686,7 @@ public: return ss.str(); }; - m["get_order_book"] = [this](variant result, const fc::variants& a) + m["get_order_book"] = [this](fc::variant result, const fc::variants& a) { auto orders = result.as( GRAPHENE_MAX_NESTED_OBJECTS ); auto bids = orders.bids; @@ -3901,7 +3902,7 @@ public: fc::from_variant_visitor( changed_values, changed_op, GRAPHENE_MAX_NESTED_OBJECTS ) ); - optional asset_to_update = find_asset(changed_op.asset_to_update); + fc::optional asset_to_update = find_asset(changed_op.asset_to_update); if (!asset_to_update) FC_THROW("No asset with that symbol exists!"); @@ -4208,15 +4209,15 @@ public: } } - vector< variant > network_get_connected_peers() + vector< fc::variant > network_get_connected_peers() { use_network_node_api(); const auto peers = (*_remote_net_node)->get_connected_peers(); - vector< variant > result; + vector< fc::variant > result; result.reserve( peers.size() ); for( const auto& peer : peers ) { - variant v; + fc::variant v; fc::to_variant( peer, v, GRAPHENE_MAX_NESTED_OBJECTS ); result.push_back( v ); } @@ -4337,9 +4338,9 @@ public: fc::api _remote_net_broadcast; fc::api _remote_hist; fc::api _remote_bookie; - optional< fc::api > _remote_net_node; - optional< fc::api > _remote_debug; - optional< fc::api > _remote_sidechain; + fc::optional< fc::api > _remote_net_node; + fc::optional< fc::api > _remote_debug; + fc::optional< fc::api > _remote_sidechain; flat_map _prototype_ops; @@ -4615,12 +4616,12 @@ bool wallet_api::copy_wallet_file(string destination_filename) return my->copy_wallet_file(destination_filename); } -optional wallet_api::get_block(uint32_t num) +fc::optional wallet_api::get_block(uint32_t num) { return my->_remote_db->get_block(num); } -vector> wallet_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const +vector> wallet_api::get_blocks(uint32_t block_num_from, uint32_t block_num_to) const { return my->_remote_db->get_blocks(block_num_from, block_num_to); } @@ -4834,7 +4835,7 @@ string wallet_api::serialize_transaction( signed_transaction tx )const return fc::to_hex(fc::raw::pack(tx)); } -variant wallet_api::get_object( object_id_type id ) const +fc::variant wallet_api::get_object( object_id_type id ) const { return my->_remote_db->get_objects({id}); } @@ -5073,7 +5074,7 @@ string wallet_api::normalize_brain_key(string s) const return detail::normalize_brain_key( s ); } -variant wallet_api::info() +fc::variant wallet_api::info() { return my->info(); } @@ -5146,7 +5147,7 @@ signed_transaction wallet_api::buy_ticket( asset_id_type lottery, account_id_typ } signed_transaction wallet_api::update_asset(string symbol, - optional new_issuer, + fc::optional new_issuer, asset_options new_options, bool broadcast /* = false */) { @@ -5333,8 +5334,8 @@ signed_transaction wallet_api::activate_deregistered_son(const string & owner_ac signed_transaction wallet_api::update_son_vesting_balances(string owner_account, - optional new_deposit, - optional new_pay_vb, + fc::optional new_deposit, + fc::optional new_pay_vb, bool broadcast /* = false */) { return my->update_son_vesting_balances(owner_account, new_deposit, new_pay_vb, broadcast); @@ -5365,17 +5366,17 @@ map wallet_api::get_son_network_status() return my->get_son_network_status(); } -optional wallet_api::get_active_son_wallet() +fc::optional wallet_api::get_active_son_wallet() { return my->get_active_son_wallet(); } -optional wallet_api::get_son_wallet_by_time_point(time_point_sec time_point) +fc::optional wallet_api::get_son_wallet_by_time_point(time_point_sec time_point) { return my->get_son_wallet_by_time_point(time_point); } -vector> wallet_api::get_son_wallets(uint32_t limit) +vector> wallet_api::get_son_wallets(uint32_t limit) { return my->get_son_wallets(limit); } @@ -5421,13 +5422,13 @@ signed_transaction wallet_api::sidechain_withdrawal_transaction(const string &so withdraw_amount); } -vector> wallet_api::get_sidechain_addresses_by_account(string account) +vector> wallet_api::get_sidechain_addresses_by_account(string account) { account_id_type account_id = get_account_id(account); return my->_remote_db->get_sidechain_addresses_by_account(account_id); } -vector> wallet_api::get_sidechain_addresses_by_sidechain(sidechain_type sidechain) +vector> wallet_api::get_sidechain_addresses_by_sidechain(sidechain_type sidechain) { return my->_remote_db->get_sidechain_addresses_by_sidechain(sidechain); } @@ -5457,7 +5458,7 @@ signed_transaction wallet_api::create_worker( share_type daily_pay, string name, string url, - variant worker_settings, + fc::variant worker_settings, bool broadcast /* = false */) { return my->create_worker( owner_account, work_begin_date, work_end_date, @@ -5570,7 +5571,7 @@ signed_transaction wallet_api::update_witness_votes(string voting_account, } signed_transaction wallet_api::set_voting_proxy(string account_to_modify, - optional voting_account, + fc::optional voting_account, bool broadcast /* = false */) { return my->set_voting_proxy(account_to_modify, voting_account, broadcast); @@ -5653,7 +5654,7 @@ void wallet_api::network_add_nodes( const vector& nodes ) my->network_add_nodes( nodes ); } -vector< variant > wallet_api::network_get_connected_peers() +vector< fc::variant > wallet_api::network_get_connected_peers() { return my->network_get_connected_peers(); } @@ -5979,7 +5980,7 @@ vector< signed_transaction > wallet_api_impl::import_balance( string name_or_id, } else { - optional< private_key_type > key = wif_to_key( wif_key ); + fc::optional< private_key_type > key = wif_to_key( wif_key ); FC_ASSERT( key.valid(), "Invalid private key" ); fc::ecc::public_key pk = key->get_public_key(); addrs.push_back( pk ); @@ -7402,13 +7403,13 @@ signed_transaction wallet_api::nft_metadata_create(string owner_account_id_or_na string name, string symbol, string base_uri, - optional revenue_partner, - optional revenue_split, + fc::optional revenue_partner, + fc::optional revenue_split, bool is_transferable, bool is_sellable, - optional role_id, - optional max_supply, - optional lottery_options, + fc::optional role_id, + fc::optional max_supply, + fc::optional lottery_options, bool broadcast) { account_object owner_account = my->get_account(owner_account_id_or_name); @@ -7445,14 +7446,14 @@ signed_transaction wallet_api::nft_metadata_create(string owner_account_id_or_na signed_transaction wallet_api::nft_metadata_update(string owner_account_id_or_name, nft_metadata_id_type nft_metadata_id, - optional name, - optional symbol, - optional base_uri, - optional revenue_partner, - optional revenue_split, - optional is_transferable, - optional is_sellable, - optional role_id, + fc::optional name, + fc::optional symbol, + fc::optional base_uri, + fc::optional revenue_partner, + fc::optional revenue_split, + fc::optional is_transferable, + fc::optional is_sellable, + fc::optional role_id, bool broadcast) { account_object owner_account = my->get_account(owner_account_id_or_name); @@ -7518,7 +7519,7 @@ uint64_t wallet_api::nft_get_balance(string owner_account_id_or_name) const return my->_remote_db->nft_get_balance(owner_account.id); } -optional wallet_api::nft_owner_of(const nft_id_type token_id) const +fc::optional wallet_api::nft_owner_of(const nft_id_type token_id) const { return my->_remote_db->nft_owner_of(token_id); } @@ -7600,7 +7601,7 @@ signed_transaction wallet_api::nft_set_approval_for_all(string owner_account_id_ return my->sign_transaction( trx, broadcast ); } -optional wallet_api::nft_get_approved(const nft_id_type token_id) const +fc::optional wallet_api::nft_get_approved(const nft_id_type token_id) const { return my->_remote_db->nft_get_approved(token_id); } @@ -7638,7 +7639,7 @@ signed_transaction wallet_api::create_offer(set item_ids, asset maximum_price, bool buying_item, time_point_sec offer_expiration_date, - optional memo, + fc::optional memo, bool broadcast) { account_object issuer_account = my->get_account(issuer_accound_id_or_name); @@ -7698,7 +7699,7 @@ signed_transaction wallet_api::cancel_offer(string issuer_account_id_or_name, return my->sign_transaction( trx, broadcast ); } -vector wallet_api::list_offers(uint32_t limit, optional lower_id) const +vector wallet_api::list_offers(uint32_t limit, fc::optional lower_id) const { offer_id_type lb_id; if(lower_id) @@ -7706,7 +7707,7 @@ vector wallet_api::list_offers(uint32_t limit, optional_remote_db->list_offers(lb_id, limit); } -vector wallet_api::list_sell_offers(uint32_t limit, optional lower_id) const +vector wallet_api::list_sell_offers(uint32_t limit, fc::optional lower_id) const { offer_id_type lb_id; if(lower_id) @@ -7714,7 +7715,7 @@ vector wallet_api::list_sell_offers(uint32_t limit, optional_remote_db->list_sell_offers(lb_id, limit); } -vector wallet_api::list_buy_offers(uint32_t limit, optional lower_id) const +vector wallet_api::list_buy_offers(uint32_t limit, fc::optional lower_id) const { offer_id_type lb_id; if(lower_id) @@ -7722,7 +7723,7 @@ vector wallet_api::list_buy_offers(uint32_t limit, optional_remote_db->list_buy_offers(lb_id, limit); } -vector wallet_api::list_offer_history(uint32_t limit, optional lower_id) const +vector wallet_api::list_offer_history(uint32_t limit, fc::optional lower_id) const { offer_history_id_type lb_id; if(lower_id) @@ -7731,7 +7732,7 @@ vector wallet_api::list_offer_history(uint32_t limit, opti } vector wallet_api::get_offers_by_issuer(string issuer_account_id_or_name, - uint32_t limit, optional lower_id) const + uint32_t limit, fc::optional lower_id) const { offer_id_type lb_id; if(lower_id) @@ -7740,7 +7741,7 @@ vector wallet_api::get_offers_by_issuer(string issuer_account_id_o return my->_remote_db->get_offers_by_issuer(lb_id, issuer_account.id, limit); } -vector wallet_api::get_offers_by_item(const nft_id_type item, uint32_t limit, optional lower_id) const +vector wallet_api::get_offers_by_item(const nft_id_type item, uint32_t limit, fc::optional lower_id) const { offer_id_type lb_id; if(lower_id) @@ -7748,7 +7749,7 @@ vector wallet_api::get_offers_by_item(const nft_id_type item, uint return my->_remote_db->get_offers_by_item(lb_id, item, limit); } -vector wallet_api::get_offer_history_by_issuer(string issuer_account_id_or_name, uint32_t limit, optional lower_id) const +vector wallet_api::get_offer_history_by_issuer(string issuer_account_id_or_name, uint32_t limit, fc::optional lower_id) const { offer_history_id_type lb_id; if(lower_id) @@ -7757,7 +7758,7 @@ vector wallet_api::get_offer_history_by_issuer(string issu return my->_remote_db->get_offer_history_by_issuer(lb_id, issuer_account.id, limit); } -vector wallet_api::get_offer_history_by_item(const nft_id_type item, uint32_t limit, optional lower_id) const +vector wallet_api::get_offer_history_by_item(const nft_id_type item, uint32_t limit, fc::optional lower_id) const { offer_history_id_type lb_id; if(lower_id) @@ -7765,7 +7766,7 @@ vector wallet_api::get_offer_history_by_item(const nft_id_ return my->_remote_db->get_offer_history_by_item(lb_id, item, limit); } -vector wallet_api::get_offer_history_by_bidder(string bidder_account_id_or_name, uint32_t limit, optional lower_id) const +vector wallet_api::get_offer_history_by_bidder(string bidder_account_id_or_name, uint32_t limit, fc::optional lower_id) const { offer_history_id_type lb_id; if(lower_id) @@ -7802,13 +7803,13 @@ signed_transaction wallet_api::create_account_role(string owner_account_id_or_na signed_transaction wallet_api::update_account_role(string owner_account_id_or_name, account_role_id_type role_id, - optional name, - optional metadata, + fc::optional name, + fc::optional metadata, flat_set operations_to_add, flat_set operations_to_remove, flat_set accounts_to_add, flat_set accounts_to_remove, - optional valid_to, + fc::optional valid_to, bool broadcast) { account_object owner_account = my->get_account(owner_account_id_or_name); diff --git a/tests/elasticsearch/main.cpp b/tests/elasticsearch/main.cpp index 7067e1e9..b3e42ce7 100644 --- a/tests/elasticsearch/main.cpp +++ b/tests/elasticsearch/main.cpp @@ -79,7 +79,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_account_history) { es.query = query; auto res = graphene::utilities::simpleQuery(es); - variant j = fc::json::from_string(res); + fc::variant j = fc::json::from_string(res); auto total = j["count"].as_string(); BOOST_CHECK_EQUAL(total, "5"); @@ -163,7 +163,7 @@ BOOST_AUTO_TEST_CASE(elasticsearch_objects) { es.query = query; auto res = graphene::utilities::simpleQuery(es); - variant j = fc::json::from_string(res); + fc::variant j = fc::json::from_string(res); auto total = j["count"].as_string(); BOOST_CHECK_EQUAL(total, "2"); diff --git a/tests/tests/database_tests.cpp b/tests/tests/database_tests.cpp index e0644b1b..eff50e1c 100644 --- a/tests/tests/database_tests.cpp +++ b/tests/tests/database_tests.cpp @@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE( flat_index_test ) price_feed current_feed; current_feed.settlement_price = bitusd.amount(100) / asset(100); publish_feed(bitusd, sam, current_feed); - FC_ASSERT( bitusd.bitasset_data_id->instance == 0 ); + FC_ASSERT( bitusd.bitasset_data_id->instance == (const unsigned int) 0 ); FC_ASSERT( !(*bitusd.bitasset_data_id)(db).current_feed.settlement_price.is_null() ); try { auto ses = db._undo_db.start_undo_session();