Skip to content

Commit

Permalink
account_objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrippled committed Oct 15, 2024
1 parent edd696b commit 1f2af22
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/test/app/PermissionedDomains_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class PermissionedDomains_test : public beast::unit_test::suite
BEAST_EXPECT(pd::ownerInfo(alice, env)["OwnerCount"].asUInt() == 1);
auto objects = pd::getObjects(alice, env);
BEAST_EXPECT(objects.size() == 1);
// Test that account_objects is correct without passing it the type
BEAST_EXPECT(objects == pd::getObjects(alice, env, false));
auto const domain = objects.begin()->first;
env(pd::deleteTx(alice, domain));
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/jtx/PermissionedDomains.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ deleteTx(AccountID const& account, uint256 const& domain);

// Get PermissionedDomain objects from account_objects rpc call
std::map<uint256, Json::Value>
getObjects(Account const& account, Env& env);
getObjects(Account const& account, Env& env, bool withType = true);

// Check if ledger object is there
bool
Expand Down
6 changes: 4 additions & 2 deletions src/test/jtx/impl/PermissionedDomains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ deleteTx(AccountID const& account, uint256 const& domain)
return jv;
}

// Get PermissionedDomain objects from account_objects rpc call
// Get PermissionedDomain objects by type from account_objects rpc call
std::map<uint256, Json::Value>
getObjects(Account const& account, Env& env)
getObjects(Account const& account, Env& env, bool withType)
{
std::map<uint256, Json::Value> ret;
Json::Value params;
params[jss::account] = account.human();
if (withType)
params[jss::type] = jss::permissioned_domain;
auto const& resp = env.rpc("json", "account_objects", to_string(params));
Json::Value a(Json::arrayValue);
a = resp[jss::result][jss::account_objects];
Expand Down
1 change: 1 addition & 0 deletions src/test/rpc/AccountObjects_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ class AccountObjects_test : public beast::unit_test::suite
BEAST_EXPECT(acctObjsIsSize(acctObjs(gw, jss::ticket), 0));
BEAST_EXPECT(acctObjsIsSize(acctObjs(gw, jss::amm), 0));
BEAST_EXPECT(acctObjsIsSize(acctObjs(gw, jss::did), 0));
BEAST_EXPECT(acctObjsIsSize(acctObjs(gw, jss::permissioned_domain), 0));

// we expect invalid field type reported for the following types
BEAST_EXPECT(acctObjsTypeIsInvalid(acctObjs(gw, jss::amendments)));
Expand Down
5 changes: 3 additions & 2 deletions src/xrpld/rpc/detail/RPCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ chooseLedgerEntryType(Json::Value const& params)
std::pair<RPC::Status, LedgerEntryType> result{RPC::Status::OK, ltANY};
if (params.isMember(jss::type))
{
static constexpr std::array<std::pair<char const*, LedgerEntryType>, 22>
static constexpr std::array<std::pair<char const*, LedgerEntryType>, 23>
types{
{{jss::account, ltACCOUNT_ROOT},
{jss::amendments, ltAMENDMENTS},
Expand All @@ -939,7 +939,8 @@ chooseLedgerEntryType(Json::Value const& params)
{jss::ticket, ltTICKET},
{jss::xchain_owned_claim_id, ltXCHAIN_OWNED_CLAIM_ID},
{jss::xchain_owned_create_account_claim_id,
ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID}}};
ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID},
{jss::permissioned_domain, ltPERMISSIONED_DOMAIN}}};

auto const& p = params[jss::type];
if (!p.isString())
Expand Down

0 comments on commit 1f2af22

Please sign in to comment.