Skip to content

Commit

Permalink
Add available call to check account existence
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Jan 31, 2025
1 parent bad63a8 commit d9d36b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 10 additions & 3 deletions contracts/api/include/api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ struct get_account_response
eosiosystem::voter_info vote;
};

struct get_available_response
{
name account;
bool available;
};

struct token_definition
{
name contract;
Expand Down Expand Up @@ -67,12 +73,13 @@ class [[eosio::contract("api")]] api : public contract
const name system_contract_msig,
const name system_token_contract,
const symbol system_token_symbol);
/**
* account readonly action
*/

[[eosio::action, eosio::read_only]] get_account_response account(const name account);
using account_action = action_wrapper<"account"_n, &api::account>;

[[eosio::action, eosio::read_only]] get_available_response available(const name account);
using available_action = action_wrapper<"available"_n, &api::available>;

[[eosio::action, eosio::read_only]] std::vector<asset>
balances(const name account, const std::vector<token_definition> tokens, const bool zerobalances);
using balances_action = action_wrapper<"balances"_n, &api::balances>;
Expand Down
5 changes: 5 additions & 0 deletions contracts/api/src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ namespace api {
.vote = vote};
}

[[eosio::action, eosio::read_only]] get_available_response api::available(const name account)
{
return get_available_response{.account = account, .available = is_account(account)};
}

[[eosio::action, eosio::read_only]] get_network_response api::network()
{
config_table _config(get_self(), get_self().value);
Expand Down

0 comments on commit d9d36b3

Please sign in to comment.