From 8bcebdea4262dac468646acb2ece683082d450d2 Mon Sep 17 00:00:00 2001 From: tequ Date: Thu, 6 Nov 2025 14:19:15 +0900 Subject: [PATCH] Support 'cron' type for `account_objects` (#624) --- src/ripple/rpc/impl/RPCHelpers.cpp | 50 +++++++++++++++------------- src/test/rpc/AccountObjects_test.cpp | 16 +++++++++ 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/ripple/rpc/impl/RPCHelpers.cpp b/src/ripple/rpc/impl/RPCHelpers.cpp index a573425b7..32e7e5611 100644 --- a/src/ripple/rpc/impl/RPCHelpers.cpp +++ b/src/ripple/rpc/impl/RPCHelpers.cpp @@ -1106,30 +1106,32 @@ chooseLedgerEntryType(Json::Value const& params) std::pair result{RPC::Status::OK, ltANY}; if (params.isMember(jss::type)) { - static constexpr std::array, 22> - types{ - {{jss::account, ltACCOUNT_ROOT}, - {jss::amendments, ltAMENDMENTS}, - {jss::check, ltCHECK}, - {jss::deposit_preauth, ltDEPOSIT_PREAUTH}, - {jss::directory, ltDIR_NODE}, - {jss::escrow, ltESCROW}, - {jss::emitted_txn, ltEMITTED_TXN}, - {jss::hook, ltHOOK}, - {jss::hook_definition, ltHOOK_DEFINITION}, - {jss::hook_state, ltHOOK_STATE}, - {jss::fee, ltFEE_SETTINGS}, - {jss::hashes, ltLEDGER_HASHES}, - {jss::import_vlseq, ltIMPORT_VLSEQ}, - {jss::offer, ltOFFER}, - {jss::payment_channel, ltPAYCHAN}, - {jss::uri_token, ltURI_TOKEN}, - {jss::signer_list, ltSIGNER_LIST}, - {jss::state, ltRIPPLE_STATE}, - {jss::ticket, ltTICKET}, - {jss::nft_offer, ltNFTOKEN_OFFER}, - {jss::nft_page, ltNFTOKEN_PAGE}, - {jss::unl_report, ltUNL_REPORT}}}; + static constexpr std::array, 23> + types{{ + {jss::account, ltACCOUNT_ROOT}, + {jss::amendments, ltAMENDMENTS}, + {jss::check, ltCHECK}, + {jss::deposit_preauth, ltDEPOSIT_PREAUTH}, + {jss::directory, ltDIR_NODE}, + {jss::escrow, ltESCROW}, + {jss::emitted_txn, ltEMITTED_TXN}, + {jss::hook, ltHOOK}, + {jss::hook_definition, ltHOOK_DEFINITION}, + {jss::hook_state, ltHOOK_STATE}, + {jss::fee, ltFEE_SETTINGS}, + {jss::hashes, ltLEDGER_HASHES}, + {jss::import_vlseq, ltIMPORT_VLSEQ}, + {jss::offer, ltOFFER}, + {jss::payment_channel, ltPAYCHAN}, + {jss::uri_token, ltURI_TOKEN}, + {jss::signer_list, ltSIGNER_LIST}, + {jss::state, ltRIPPLE_STATE}, + {jss::ticket, ltTICKET}, + {jss::nft_offer, ltNFTOKEN_OFFER}, + {jss::nft_page, ltNFTOKEN_PAGE}, + {jss::unl_report, ltUNL_REPORT}, + {jss::cron, ltCRON}, + }}; auto const& p = params[jss::type]; if (!p.isString()) diff --git a/src/test/rpc/AccountObjects_test.cpp b/src/test/rpc/AccountObjects_test.cpp index e20720ca7..63ac15d41 100644 --- a/src/test/rpc/AccountObjects_test.cpp +++ b/src/test/rpc/AccountObjects_test.cpp @@ -781,6 +781,22 @@ public: auto const& hook = resp[jss::result][jss::account_objects][0u]; BEAST_EXPECT(hook[sfAccount.jsonName] == gw.human()); } + { + // Create a Cron + env(cron::set(gw), + cron::startTime(env.now().time_since_epoch().count() + 100), + cron::delay(100), + cron::repeat(200), + fee(XRP(1))); + env.close(); + } + { + // Find the cron. + Json::Value const resp = acct_objs(gw, jss::cron); + BEAST_EXPECT(acct_objs_is_size(resp, 1)); + auto const& cron = resp[jss::result][jss::account_objects][0u]; + BEAST_EXPECT(cron[sfOwner.jsonName] == gw.human()); + } { // See how "deletion_blockers_only" handles gw's directory. Json::Value params;