From 7e90e8c2000013a2c0ce161f974567519b5b7fd5 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 22 Nov 2024 16:10:01 -0500 Subject: [PATCH 1/3] add `rpcName` to `LEDGER_ENTRY` macro --- include/xrpl/protocol/LedgerFormats.h | 2 +- .../xrpl/protocol/detail/ledger_entries.macro | 50 +++++++++---------- include/xrpl/protocol/jss.h | 35 ++++--------- src/libxrpl/protocol/LedgerFormats.cpp | 2 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 40 +++++---------- 5 files changed, 49 insertions(+), 80 deletions(-) diff --git a/include/xrpl/protocol/LedgerFormats.h b/include/xrpl/protocol/LedgerFormats.h index 4f3eef4919d..502d66bde6e 100644 --- a/include/xrpl/protocol/LedgerFormats.h +++ b/include/xrpl/protocol/LedgerFormats.h @@ -56,7 +56,7 @@ enum LedgerEntryType : std::uint16_t #pragma push_macro("LEDGER_ENTRY") #undef LEDGER_ENTRY -#define LEDGER_ENTRY(tag, value, name, fields) tag = value, +#define LEDGER_ENTRY(tag, value, name, rpcName, fields) tag = value, #include diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 0cb1ec3416a..783ada829e6 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -31,7 +31,7 @@ \sa keylet::nftoffer */ -LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, ({ +LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, nft_offer, ({ {sfOwner, soeREQUIRED}, {sfNFTokenID, soeREQUIRED}, {sfAmount, soeREQUIRED}, @@ -47,7 +47,7 @@ LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, ({ \sa keylet::check */ -LEDGER_ENTRY(ltCHECK, 0x0043, Check, ({ +LEDGER_ENTRY(ltCHECK, 0x0043, Check, check, ({ {sfAccount, soeREQUIRED}, {sfDestination, soeREQUIRED}, {sfSendMax, soeREQUIRED}, @@ -66,7 +66,7 @@ LEDGER_ENTRY(ltCHECK, 0x0043, Check, ({ \sa keylet::did */ -LEDGER_ENTRY(ltDID, 0x0049, DID, ({ +LEDGER_ENTRY(ltDID, 0x0049, DID, did, ({ {sfAccount, soeREQUIRED}, {sfDIDDocument, soeOPTIONAL}, {sfURI, soeOPTIONAL}, @@ -82,7 +82,7 @@ LEDGER_ENTRY(ltDID, 0x0049, DID, ({ \sa keylet::negativeUNL */ -LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, ({ +LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, nunl, ({ {sfDisabledValidators, soeOPTIONAL}, {sfValidatorToDisable, soeOPTIONAL}, {sfValidatorToReEnable, soeOPTIONAL}, @@ -94,7 +94,7 @@ LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, ({ \sa keylet::nftpage_min, keylet::nftpage_max, keylet::nftpage */ -LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, ({ +LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, nft_page, ({ {sfPreviousPageMin, soeOPTIONAL}, {sfNextPageMin, soeOPTIONAL}, {sfNFTokens, soeREQUIRED}, @@ -108,7 +108,7 @@ LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, ({ */ // All fields are soeREQUIRED because there is always a SignerEntries. // If there are no SignerEntries the node is deleted. -LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, ({ +LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, signer_list, ({ {sfOwnerNode, soeREQUIRED}, {sfSignerQuorum, soeREQUIRED}, {sfSignerEntries, soeREQUIRED}, @@ -121,7 +121,7 @@ LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, ({ \sa keylet::ticket */ -LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ({ +LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ticket, ({ {sfAccount, soeREQUIRED}, {sfOwnerNode, soeREQUIRED}, {sfTicketSequence, soeREQUIRED}, @@ -133,7 +133,7 @@ LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ({ \sa keylet::account */ -LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, ({ +LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({ {sfAccount, soeREQUIRED}, {sfSequence, soeREQUIRED}, {sfBalance, soeREQUIRED}, @@ -162,7 +162,7 @@ LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, ({ \sa keylet::page, keylet::quality, keylet::book, keylet::next and keylet::ownerDir */ -LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, ({ +LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, directory, ({ {sfOwner, soeOPTIONAL}, // for owner directories {sfTakerPaysCurrency, soeOPTIONAL}, // order book directories {sfTakerPaysIssuer, soeOPTIONAL}, // order book directories @@ -184,7 +184,7 @@ LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, ({ \sa keylet::amendments */ -LEDGER_ENTRY(ltAMENDMENTS, 0x0066, Amendments, ({ +LEDGER_ENTRY(ltAMENDMENTS, 0x0066, Amendments, amendments, ({ {sfAmendments, soeOPTIONAL}, // Enabled {sfMajorities, soeOPTIONAL}, {sfPreviousTxnID, soeOPTIONAL}, @@ -199,7 +199,7 @@ LEDGER_ENTRY(ltAMENDMENTS, 0x0066, Amendments, ({ \sa keylet::skip */ -LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, ({ +LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, hashes, ({ {sfFirstLedgerSequence, soeOPTIONAL}, {sfLastLedgerSequence, soeOPTIONAL}, {sfHashes, soeREQUIRED}, @@ -209,7 +209,7 @@ LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, ({ \sa keylet::bridge */ -LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, ({ +LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, bridge, ({ {sfAccount, soeREQUIRED}, {sfSignatureReward, soeREQUIRED}, {sfMinAccountCreateAmount, soeOPTIONAL}, @@ -226,7 +226,7 @@ LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, ({ \sa keylet::offer */ -LEDGER_ENTRY(ltOFFER, 0x006f, Offer, ({ +LEDGER_ENTRY(ltOFFER, 0x006f, Offer, offer, ({ {sfAccount, soeREQUIRED}, {sfSequence, soeREQUIRED}, {sfTakerPays, soeREQUIRED}, @@ -243,7 +243,7 @@ LEDGER_ENTRY(ltOFFER, 0x006f, Offer, ({ \sa keylet::depositPreauth */ -LEDGER_ENTRY(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, ({ +LEDGER_ENTRY(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, deposit_preauth, ({ {sfAccount, soeREQUIRED}, {sfAuthorize, soeOPTIONAL}, {sfOwnerNode, soeREQUIRED}, @@ -256,7 +256,7 @@ LEDGER_ENTRY(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, ({ \sa keylet::xChainClaimID */ -LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, ({ +LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, xchain_owned_claim_id, ({ {sfAccount, soeREQUIRED}, {sfXChainBridge, soeREQUIRED}, {sfXChainClaimID, soeREQUIRED}, @@ -274,7 +274,7 @@ LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, ({ \sa keylet::line */ -LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, ({ +LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, state, ({ {sfBalance, soeREQUIRED}, {sfLowLimit, soeREQUIRED}, {sfHighLimit, soeREQUIRED}, @@ -294,7 +294,7 @@ LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, ({ \sa keylet::fees */ -LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, ({ +LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, fee, ({ // Old version uses raw numbers {sfBaseFee, soeOPTIONAL}, {sfReferenceFeeUnits, soeOPTIONAL}, @@ -312,7 +312,7 @@ LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, ({ \sa keylet::xChainCreateAccountClaimID */ -LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAccountClaimID, ({ +LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAccountClaimID, xchain_owned_create_account_claim_id, ({ {sfAccount, soeREQUIRED}, {sfXChainBridge, soeREQUIRED}, {sfXChainAccountCreateCount, soeREQUIRED}, @@ -326,7 +326,7 @@ LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAc \sa keylet::escrow */ -LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, ({ +LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({ {sfAccount, soeREQUIRED}, {sfDestination, soeREQUIRED}, {sfAmount, soeREQUIRED}, @@ -345,7 +345,7 @@ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, ({ \sa keylet::payChan */ -LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, ({ +LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, payment_channel, ({ {sfAccount, soeREQUIRED}, {sfDestination, soeREQUIRED}, {sfAmount, soeREQUIRED}, @@ -366,7 +366,7 @@ LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, ({ \sa keylet::amm */ -LEDGER_ENTRY(ltAMM, 0x0079, AMM, ({ +LEDGER_ENTRY(ltAMM, 0x0079, AMM, amm, ({ {sfAccount, soeREQUIRED}, {sfTradingFee, soeDEFAULT}, {sfVoteSlots, soeOPTIONAL}, @@ -382,7 +382,7 @@ LEDGER_ENTRY(ltAMM, 0x0079, AMM, ({ /** A ledger object which tracks Oracle \sa keylet::oracle */ -LEDGER_ENTRY(ltORACLE, 0x0080, Oracle, ({ +LEDGER_ENTRY(ltORACLE, 0x0080, Oracle, oracle, ({ {sfOwner, soeREQUIRED}, {sfProvider, soeREQUIRED}, {sfPriceDataSeries, soeREQUIRED}, @@ -397,7 +397,7 @@ LEDGER_ENTRY(ltORACLE, 0x0080, Oracle, ({ /** A ledger object which tracks MPTokenIssuance \sa keylet::mptIssuance */ -LEDGER_ENTRY(ltMPTOKEN_ISSUANCE, 0x007e, MPTokenIssuance, ({ +LEDGER_ENTRY(ltMPTOKEN_ISSUANCE, 0x007e, MPTokenIssuance, mpt_issuance, ({ {sfIssuer, soeREQUIRED}, {sfSequence, soeREQUIRED}, {sfTransferFee, soeDEFAULT}, @@ -413,7 +413,7 @@ LEDGER_ENTRY(ltMPTOKEN_ISSUANCE, 0x007e, MPTokenIssuance, ({ /** A ledger object which tracks MPToken \sa keylet::mptoken */ -LEDGER_ENTRY(ltMPTOKEN, 0x007f, MPToken, ({ +LEDGER_ENTRY(ltMPTOKEN, 0x007f, MPToken, mptoken, ({ {sfAccount, soeREQUIRED}, {sfMPTokenIssuanceID, soeREQUIRED}, {sfMPTAmount, soeDEFAULT}, @@ -425,7 +425,7 @@ LEDGER_ENTRY(ltMPTOKEN, 0x007f, MPToken, ({ /** A ledger object which tracks Credential \sa keylet::credential */ -LEDGER_ENTRY(ltCREDENTIAL, 0x0081, Credential, ({ +LEDGER_ENTRY(ltCREDENTIAL, 0x0081, Credential, credential, ({ {sfSubject, soeREQUIRED}, {sfIssuer, soeREQUIRED}, {sfCredentialType, soeREQUIRED}, diff --git a/include/xrpl/protocol/jss.h b/include/xrpl/protocol/jss.h index f9e0db24949..c4a2a895849 100644 --- a/include/xrpl/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -123,7 +123,6 @@ JSS(XChainOwnedClaimID); // ledger type. JSS(XChainOwnedCreateAccountClaimID); // ledger type. JSS(aborted); // out: InboundLedger JSS(accepted); // out: LedgerToJson, OwnerInfo, SubmitTransaction -JSS(account); // in/out: many JSS(accountState); // out: LedgerToJson JSS(accountTreeHash); // out: ledger/Ledger.cpp JSS(account_data); // out: AccountInfo @@ -150,8 +149,6 @@ JSS(affected); // out: AcceptedLedgerTx JSS(age); // out: NetworkOPs, Peers JSS(alternatives); // out: PathRequest, RipplePathFind JSS(amendment_blocked); // out: NetworkOPs -JSS(amendments); // in: AccountObjects, out: NetworkOPs -JSS(amm); // out: amm_info JSS(amm_account); // in: amm_info JSS(amount); // out: AccountChannels, amm_info JSS(amount2); // out: amm_info @@ -191,21 +188,17 @@ JSS(books); // in: Subscribe, Unsubscribe JSS(both); // in: Subscribe, Unsubscribe JSS(both_sides); // in: Subscribe, Unsubscribe JSS(broadcast); // out: SubmitTransaction -JSS(bridge); // in: LedgerEntry JSS(bridge_account); // in: LedgerEntry JSS(build_path); // in: TransactionSign JSS(build_version); // out: NetworkOPs JSS(cancel_after); // out: AccountChannels JSS(can_delete); // out: CanDelete JSS(mpt_amount); // out: mpt_holders -JSS(mpt_issuance); // in: LedgerEntry, AccountObjects JSS(mpt_issuance_id); // in: Payment, mpt_holders -JSS(mptoken); // in: LedgerEntry, AccountObjects JSS(mptoken_index); // out: mpt_holders JSS(changes); // out: BookChanges JSS(channel_id); // out: AccountChannels JSS(channels); // out: AccountChannels -JSS(check); // in: AccountObjects JSS(check_nodes); // in: LedgerCleaner JSS(clear); // in/out: FetchInfo JSS(close); // out: BookChanges @@ -232,7 +225,6 @@ JSS(converge_time_s); // out: NetworkOPs JSS(cookie); // out: NetworkOPs JSS(count); // in: AccountTx*, ValidatorList JSS(counters); // in/out: retrieve counters -JSS(credential); // in: LedgerEntry Credential JSS(credentials); // in: deposit_authorized JSS(credential_type); // in: LedgerEntry DepositPreauth JSS(ctid); // in/out: Tx RPC @@ -254,7 +246,6 @@ JSS(debug_signing); // in: TransactionSign JSS(deletion_blockers_only); // in: AccountObjects JSS(delivered_amount); // out: insertDeliveredAmount JSS(deposit_authorized); // out: deposit_authorized -JSS(deposit_preauth); // in: AccountObjects, LedgerData JSS(deprecated); // out JSS(descending); // in: AccountTx* JSS(description); // in/out: Reservations @@ -266,11 +257,9 @@ JSS(destination_currencies); // in: PathRequest, RipplePathFind JSS(destination_tag); // in: PathRequest // out: AccountChannels JSS(details); // out: Manifest, server_info -JSS(did); // in: LedgerEntry JSS(dir_entry); // out: DirectoryEntryIterator JSS(dir_index); // out: DirectoryEntryIterator JSS(dir_root); // out: DirectoryEntryIterator -JSS(directory); // in: LedgerEntry JSS(discounted_fee); // out: amm_info JSS(domain); // out: ValidatorInfo, Manifest JSS(drops); // out: TxQ @@ -289,7 +278,6 @@ JSS(errored); JSS(error_code); // out: error JSS(error_exception); // out: Submit JSS(error_message); // out: error -JSS(escrow); // in: LedgerEntry JSS(expand); // in: handler/Ledger JSS(expected_date); // out: any (warnings) JSS(expected_date_UTC); // out: any (warnings) @@ -300,7 +288,6 @@ JSS(fail_hard); // in: Sign, Submit JSS(failed); // out: InboundLedger JSS(feature); // in: Feature JSS(features); // out: Feature -JSS(fee); // out: NetworkOPs, Peers JSS(fee_base); // out: NetworkOPs JSS(fee_div_max); // in: TransactionSign JSS(fee_level); // out: AccountInfo @@ -324,7 +311,6 @@ JSS(fullbelow_size); // out: GetCounts JSS(good); // out: RPCVersion JSS(hash); // out: NetworkOPs, InboundLedger, // LedgerToJson, STTx; field -JSS(hashes); // in: AccountObjects JSS(have_header); // out: InboundLedger JSS(have_state); // out: InboundLedger JSS(have_transactions); // out: InboundLedger @@ -462,9 +448,7 @@ JSS(network_id); // out: NetworkOPs JSS(network_ledger); // out: NetworkOPs JSS(next_refresh_time); // out: ValidatorSite JSS(nft_id); // in: nft_sell_offers, nft_buy_offers -JSS(nft_offer); // in: LedgerEntry JSS(nft_offer_index); // out nft_buy_offers, nft_sell_offers -JSS(nft_page); // in: LedgerEntry JSS(nft_serial); // out: account_nfts JSS(nft_taxon); // out: nft_info (clio) JSS(nftoken_id); // out: insertNFTokenID @@ -487,9 +471,7 @@ JSS(node_writes_duration_us); // out: GetCounts JSS(node_write_retries); // out: GetCounts JSS(node_writes_delayed); // out::GetCounts JSS(nth); // out: RPC server_definitions -JSS(nunl); // in: AccountObjects JSS(obligations); // out: GatewayBalances -JSS(offer); // in: LedgerEntry JSS(offers); // out: NetworkOPs, AccountOffers, Subscribe JSS(offer_id); // out: insertNFTokenOfferID JSS(offline); // in: TransactionSign @@ -498,7 +480,6 @@ JSS(open); // out: handlers/Ledger JSS(open_ledger_cost); // out: SubmitTransaction JSS(open_ledger_fee); // out: TxQ JSS(open_ledger_level); // out: TxQ -JSS(oracle); // in: LedgerEntry JSS(oracles); // in: get_aggregate_price JSS(oracle_document_id); // in: get_aggregate_price JSS(owner); // in: LedgerEntry, out: NetworkOPs @@ -513,7 +494,6 @@ JSS(password); // in: Subscribe JSS(paths); // in: RipplePathFind JSS(paths_canonical); // out: RipplePathFind JSS(paths_computed); // out: PathRequest, RipplePathFind -JSS(payment_channel); // in: LedgerEntry JSS(peer); // in: AccountLines JSS(peer_authorized); // out: AccountLines JSS(peer_id); // out: RCLCxPeerPos @@ -599,7 +579,6 @@ JSS(signature_verified); // out: ChannelVerify JSS(signing_key); // out: NetworkOPs JSS(signing_keys); // out: ValidatorList JSS(signing_time); // out: NetworkOPs -JSS(signer_list); // in: AccountObjects JSS(signer_lists); // in/out: AccountInfo JSS(size); // out: get_aggregate_price JSS(snapshot); // in: Subscribe @@ -611,7 +590,6 @@ JSS(stand_alone); // out: NetworkOPs JSS(standard_deviation); // out: get_aggregate_price JSS(start); // in: TxHistory JSS(started); -JSS(state); // out: Logic.h, ServerState, LedgerData JSS(state_accounting); // out: NetworkOPs JSS(state_now); // in: Subscribe JSS(status); // error @@ -633,7 +611,6 @@ JSS(taker_gets_funded); // out: NetworkOPs JSS(taker_pays); // in: Subscribe, Unsubscribe, BookOffers JSS(taker_pays_funded); // out: NetworkOPs JSS(threshold); // in: Blacklist -JSS(ticket); // in: AccountObjects JSS(ticket_count); // out: AccountInfo JSS(ticket_seq); // in: LedgerEntry JSS(time); @@ -732,8 +709,6 @@ JSS(warning); // rpc: JSS(warnings); // out: server_info, server_state JSS(workers); JSS(write_load); // out: GetCounts -JSS(xchain_owned_claim_id); // in: LedgerEntry, AccountObjects -JSS(xchain_owned_create_account_claim_id); // in: LedgerEntry JSS(NegativeUNL); // out: ValidatorList; ledger type // clang-format on @@ -747,6 +722,16 @@ JSS(NegativeUNL); // out: ValidatorList; ledger type #undef TRANSACTION #pragma pop_macro("TRANSACTION") +#pragma push_macro("LEDGER_ENTRY") +#undef LEDGER_ENTRY + +#define LEDGER_ENTRY(tag, value, name, rpcName, fields) JSS(rpcName); + +#include + +#undef LEDGER_ENTRY +#pragma pop_macro("LEDGER_ENTRY") + #undef JSS } // namespace jss diff --git a/src/libxrpl/protocol/LedgerFormats.cpp b/src/libxrpl/protocol/LedgerFormats.cpp index d66b085e0d0..518c3771d62 100644 --- a/src/libxrpl/protocol/LedgerFormats.cpp +++ b/src/libxrpl/protocol/LedgerFormats.cpp @@ -38,7 +38,7 @@ LedgerFormats::LedgerFormats() #undef LEDGER_ENTRY #define UNWRAP(...) __VA_ARGS__ -#define LEDGER_ENTRY(tag, value, name, fields) \ +#define LEDGER_ENTRY(tag, value, name, rpcName, fields) \ add(jss::name, tag, UNWRAP fields, commonFields); #include diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index af204eaedf7..41f844f974a 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -931,34 +931,18 @@ chooseLedgerEntryType(Json::Value const& params) std::pair result{RPC::Status::OK, ltANY}; if (params.isMember(jss::type)) { - static constexpr std::array, 25> - types{ - {{jss::account, ltACCOUNT_ROOT}, - {jss::amendments, ltAMENDMENTS}, - {jss::amm, ltAMM}, - {jss::bridge, ltBRIDGE}, - {jss::check, ltCHECK}, - {jss::credential, ltCREDENTIAL}, - {jss::deposit_preauth, ltDEPOSIT_PREAUTH}, - {jss::did, ltDID}, - {jss::directory, ltDIR_NODE}, - {jss::escrow, ltESCROW}, - {jss::fee, ltFEE_SETTINGS}, - {jss::hashes, ltLEDGER_HASHES}, - {jss::nunl, ltNEGATIVE_UNL}, - {jss::oracle, ltORACLE}, - {jss::nft_offer, ltNFTOKEN_OFFER}, - {jss::nft_page, ltNFTOKEN_PAGE}, - {jss::offer, ltOFFER}, - {jss::payment_channel, ltPAYCHAN}, - {jss::signer_list, ltSIGNER_LIST}, - {jss::state, ltRIPPLE_STATE}, - {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}, - {jss::mpt_issuance, ltMPTOKEN_ISSUANCE}, - {jss::mptoken, ltMPTOKEN}}}; + static constexpr auto types = + std::to_array>({ +#pragma push_macro("LEDGER_ENTRY") +#undef LEDGER_ENTRY + +#define LEDGER_ENTRY(tag, value, name, rpcName, fields) {jss::rpcName, tag}, + +#include + +#undef LEDGER_ENTRY +#pragma pop_macro("LEDGER_ENTRY") + }); auto const& p = params[jss::type]; if (!p.isString()) From 4468db12370e6f871ad2696a257961d895ebdea3 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 22 Nov 2024 16:27:30 -0500 Subject: [PATCH 2/3] add ledger objects to JSS --- .../xrpl/protocol/detail/ledger_entries.macro | 8 ++++- include/xrpl/protocol/jss.h | 34 +++++-------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 783ada829e6..210de92dbfe 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -21,6 +21,10 @@ #error "undefined macro: LEDGER_ENTRY" #endif +#ifndef LEDGER_ENTRY_DUPLICATE +#define LEDGER_ENTRY_DUPLICATE(tag, value, name, rpcName, fields) LEDGER_ENTRY(tag, value, name, rpcName, fields) +#endif + /** * These objects are listed in order of increasing ledger type ID. * There are many gaps between these IDs. @@ -243,7 +247,7 @@ LEDGER_ENTRY(ltOFFER, 0x006f, Offer, offer, ({ \sa keylet::depositPreauth */ -LEDGER_ENTRY(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, deposit_preauth, ({ +LEDGER_ENTRY_DUPLICATE(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, deposit_preauth, ({ {sfAccount, soeREQUIRED}, {sfAuthorize, soeOPTIONAL}, {sfOwnerNode, soeREQUIRED}, @@ -436,3 +440,5 @@ LEDGER_ENTRY(ltCREDENTIAL, 0x0081, Credential, credential, ({ {sfPreviousTxnID, soeREQUIRED}, {sfPreviousTxnLgrSeq, soeREQUIRED}, })) + +#undef LEDGER_ENTRY_DUPLICATE diff --git a/include/xrpl/protocol/jss.h b/include/xrpl/protocol/jss.h index c4a2a895849..f46f7a5563c 100644 --- a/include/xrpl/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -45,10 +45,7 @@ namespace jss { JSS(AL_size); // out: GetCounts JSS(AL_hit_rate); // out: GetCounts JSS(Account); // in: TransactionSign; field. -JSS(AccountRoot); // ledger type. -JSS(AMM); // ledger type JSS(AMMID); // field -JSS(Amendments); // ledger type. JSS(Amount); // in: TransactionSign; field. JSS(Amount2); // in/out: AMM IOU/XRP pool, deposit, withdraw amount JSS(Asset); // in: AMM Asset1 @@ -60,67 +57,47 @@ JSS(AuthAccounts); // in: AMM Auction Slot JSS(BaseAsset); // in: Oracle JSS(BidMax); // in: AMM Bid JSS(BidMin); // in: AMM Bid -JSS(Bridge); // ledger type. -JSS(Check); // ledger type. JSS(ClearFlag); // field. -JSS(Credential); // ledger type. -JSS(DID); // ledger type. JSS(DeliverMax); // out: alias to Amount JSS(DeliverMin); // in: TransactionSign JSS(Destination); // in: TransactionSign; field. -JSS(DirectoryNode); // ledger type. JSS(EPrice); // in: AMM Deposit option -JSS(Escrow); // ledger type. JSS(Fee); // in/out: TransactionSign; field. -JSS(FeeSettings); // ledger type. JSS(Flags); // in/out: TransactionSign; field. JSS(Holder); // field. JSS(Invalid); // JSS(Issuer); // in: Credential transactions JSS(LastLedgerSequence); // in: TransactionSign; field JSS(LastUpdateTime); // field. -JSS(LedgerHashes); // ledger type. JSS(LimitAmount); // field. -JSS(MPToken); // ledger type. -JSS(MPTokenIssuance); // ledger type. JSS(NetworkID); // field. -JSS(NFTokenOffer); // ledger type. -JSS(NFTokenPage); // ledger type. JSS(LPTokenOut); // in: AMM Liquidity Provider deposit tokens JSS(LPTokenIn); // in: AMM Liquidity Provider withdraw tokens JSS(LPToken); // out: AMM Liquidity Provider tokens info -JSS(Offer); // ledger type. JSS(OfferSequence); // field. -JSS(Oracle); // ledger type. JSS(OracleDocumentID); // field JSS(Owner); // field JSS(Paths); // in/out: TransactionSign -JSS(PayChannel); // ledger type. JSS(PriceDataSeries); // field. JSS(PriceData); // field. JSS(Provider); // field. JSS(QuoteAsset); // in: Oracle. -JSS(RippleState); // ledger type. JSS(SLE_hit_rate); // out: GetCounts. JSS(Scale); // field. JSS(SettleDelay); // in: TransactionSign JSS(SendMax); // in: TransactionSign JSS(Sequence); // in/out: TransactionSign; field. JSS(SetFlag); // field. -JSS(SignerList); // ledger type. JSS(SigningPubKey); // field. JSS(Subject); // in: Credential transactions JSS(TakerGets); // field. JSS(TakerPays); // field. -JSS(Ticket); // ledger type. JSS(TxnSignature); // field. JSS(TradingFee); // in/out: AMM trading fee JSS(TransactionType); // in: TransactionSign. JSS(TransferRate); // in: TransferRate. JSS(URI); // field. JSS(VoteSlots); // out: AMM Vote -JSS(XChainOwnedClaimID); // ledger type. -JSS(XChainOwnedCreateAccountClaimID); // ledger type. JSS(aborted); // out: InboundLedger JSS(accepted); // out: LedgerToJson, OwnerInfo, SubmitTransaction JSS(accountState); // out: LedgerToJson @@ -709,7 +686,6 @@ JSS(warning); // rpc: JSS(warnings); // out: server_info, server_state JSS(workers); JSS(write_load); // out: GetCounts -JSS(NegativeUNL); // out: ValidatorList; ledger type // clang-format on #pragma push_macro("TRANSACTION") @@ -723,14 +699,22 @@ JSS(NegativeUNL); // out: ValidatorList; ledger type #pragma pop_macro("TRANSACTION") #pragma push_macro("LEDGER_ENTRY") +#pragma push_macro("LEDGER_ENTRY_DUPLICATE") #undef LEDGER_ENTRY +#undef LEDGER_ENTRY_DUPLICATE -#define LEDGER_ENTRY(tag, value, name, rpcName, fields) JSS(rpcName); +#define LEDGER_ENTRY(tag, value, name, rpcName, fields) \ + JSS(name); \ + JSS(rpcName); + +#define LEDGER_ENTRY_DUPLICATE(tag, value, name, rpcName, fields) JSS(rpcName); #include #undef LEDGER_ENTRY +#undef LEDGER_ENTRY_DUPLICATE #pragma pop_macro("LEDGER_ENTRY") +#pragma pop_macro("LEDGER_ENTRY_DUPLICATE") #undef JSS From 5826d6f26d5bb37ef71bdeeaf089440c86afff92 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 22 Nov 2024 17:42:32 -0500 Subject: [PATCH 3/3] use __VA_ARGS__ --- include/xrpl/protocol/detail/ledger_entries.macro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro index 210de92dbfe..75c54fe573c 100644 --- a/include/xrpl/protocol/detail/ledger_entries.macro +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -22,7 +22,7 @@ #endif #ifndef LEDGER_ENTRY_DUPLICATE -#define LEDGER_ENTRY_DUPLICATE(tag, value, name, rpcName, fields) LEDGER_ENTRY(tag, value, name, rpcName, fields) +#define LEDGER_ENTRY_DUPLICATE(...) LEDGER_ENTRY(__VA_ARGS__) #endif /**