diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 2d0412b0..0f30c6ff 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -157,7 +157,8 @@ public: // SON members vector> get_sons(const vector &son_ids) const; - fc::optional get_son_by_account(account_id_type account) const; + fc::optional get_son_by_account_id(account_id_type account) const; + fc::optional get_son_by_account(const std::string account_id_or_name) const; map lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const; uint64_t get_son_count() const; @@ -1719,11 +1720,11 @@ vector> database_api_impl::get_sons(const vector database_api::get_son_by_account(account_id_type account) const { - return my->get_son_by_account(account); +fc::optional database_api::get_son_by_account_id(account_id_type account) const { + return my->get_son_by_account_id(account); } -fc::optional database_api_impl::get_son_by_account(account_id_type account) const { +fc::optional database_api_impl::get_son_by_account_id(account_id_type account) const { const auto &idx = _db.get_index_type().indices().get(); auto itr = idx.find(account); if (itr != idx.end()) @@ -1731,6 +1732,15 @@ fc::optional database_api_impl::get_son_by_account(account_id_type a return {}; } +fc::optional database_api::get_son_by_account(const std::string account_id_or_name) const { + return my->get_son_by_account(account_id_or_name); +} + +fc::optional database_api_impl::get_son_by_account(const std::string account_id_or_name) const { + const account_id_type account = get_account_from_string(account_id_or_name)->id; + return get_son_by_account_id(account); +} + map database_api::lookup_son_accounts(const string &lower_bound_name, uint32_t limit) const { return my->lookup_son_accounts(lower_bound_name, limit); } diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index acbe2c8b..8e727d54 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -620,7 +620,14 @@ public: * @param account The ID of the account whose SON should be retrieved * @return The SON object, or null if the account does not have a SON */ - fc::optional get_son_by_account(account_id_type account) const; + fc::optional get_son_by_account_id(account_id_type account) const; + + /** + * @brief Get the SON owned by a given account + * @param account The ID of the account whose SON should be retrieved + * @return The SON object, or null if the account does not have a SON + */ + fc::optional get_son_by_account(const std::string account_id_or_name) const; /** * @brief Get names and IDs for registered SONs @@ -1086,6 +1093,7 @@ FC_API(graphene::app::database_api, // SON members (get_sons) + (get_son_by_account_id) (get_son_by_account) (lookup_son_accounts) (get_son_count)