feat: export ledger name spaces via server_definitions

This commit is contained in:
Denis Angell
2026-07-16 20:01:49 -04:00
parent 5ce0b1c2c7
commit c7bfd6a7e1
6 changed files with 141 additions and 59 deletions

View File

@@ -17,11 +17,46 @@
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <utility>
namespace xrpl {
/**
* Type-specific prefix for calculating ledger indices.
*
* The identifier for a given object within the ledger is calculated based
* on some object-specific parameters. To ensure that different types of
* objects have different indices, even if they happen to use the same set
* of parameters, we use "tagged hashing" by adding a type-specific prefix.
*
* The name spaces are listed in detail/ledger_name_spaces.macro.
*/
#pragma push_macro("LEDGER_NAME_SPACE")
#undef LEDGER_NAME_SPACE
#pragma push_macro("LEDGER_NAME_SPACE_DEPRECATED")
#undef LEDGER_NAME_SPACE_DEPRECATED
#define LEDGER_NAME_SPACE(name, value) name = (value),
#define LEDGER_NAME_SPACE_DEPRECATED(name, value) name [[deprecated]] = (value),
enum class LedgerNameSpace : std::uint16_t {
#include <xrpl/protocol/detail/ledger_name_spaces.macro>
};
#undef LEDGER_NAME_SPACE_DEPRECATED
#pragma pop_macro("LEDGER_NAME_SPACE_DEPRECATED")
#undef LEDGER_NAME_SPACE
#pragma pop_macro("LEDGER_NAME_SPACE")
/**
* The name->value map of active (non-deprecated) ledger name spaces.
*/
std::map<std::string, std::uint16_t> const&
ledgerNameSpaceMap();
class SeqProxy;
/**
* Keylet computation functions.

View File

@@ -0,0 +1,59 @@
#if !defined(LEDGER_NAME_SPACE)
#error "undefined macro: LEDGER_NAME_SPACE"
#endif
#if !defined(LEDGER_NAME_SPACE_DEPRECATED)
#error "undefined macro: LEDGER_NAME_SPACE_DEPRECATED"
#endif
// Active ledger name spaces.
//
// @note These values are part of the protocol and *CANNOT* be arbitrarily
// changed. If they were, on-ledger objects may no longer be able to
// be located or addressed.
//
// Additions to this list are OK, but changing existing entries to
// assign them a different values should never be needed.
//
// Entries that are removed should be moved to the deprecated list
// below to prevent accidental reuse.
LEDGER_NAME_SPACE(Account, 'a')
LEDGER_NAME_SPACE(DirNode, 'd')
LEDGER_NAME_SPACE(TrustLine, 'r')
LEDGER_NAME_SPACE(Offer, 'o')
LEDGER_NAME_SPACE(OwnerDir, 'O')
LEDGER_NAME_SPACE(BookDir, 'B')
LEDGER_NAME_SPACE(SkipList, 's')
LEDGER_NAME_SPACE(Escrow, 'u')
LEDGER_NAME_SPACE(Amendments, 'f')
LEDGER_NAME_SPACE(FeeSettings, 'e')
LEDGER_NAME_SPACE(Ticket, 'T')
LEDGER_NAME_SPACE(SignerList, 'S')
LEDGER_NAME_SPACE(XRPPaymentChannel, 'x')
LEDGER_NAME_SPACE(Check, 'C')
LEDGER_NAME_SPACE(DepositPreauth, 'p')
LEDGER_NAME_SPACE(DepositPreauthCredentials, 'P')
LEDGER_NAME_SPACE(NegativeUnl, 'N')
LEDGER_NAME_SPACE(NftokenOffer, 'q')
LEDGER_NAME_SPACE(NftokenBuyOffers, 'h')
LEDGER_NAME_SPACE(NftokenSellOffers, 'i')
LEDGER_NAME_SPACE(Amm, 'A')
LEDGER_NAME_SPACE(Bridge, 'H')
LEDGER_NAME_SPACE(XchainClaimId, 'Q')
LEDGER_NAME_SPACE(XchainCreateAccountClaimId, 'K')
LEDGER_NAME_SPACE(Did, 'I')
LEDGER_NAME_SPACE(Oracle, 'R')
LEDGER_NAME_SPACE(MPTokenIssuance, '~')
LEDGER_NAME_SPACE(MPToken, 't')
LEDGER_NAME_SPACE(Credential, 'D')
LEDGER_NAME_SPACE(PermissionedDomain, 'm')
LEDGER_NAME_SPACE(Delegate, 'E')
LEDGER_NAME_SPACE(Vault, 'V')
LEDGER_NAME_SPACE(LoanBroker, 'l') // lower-case L
LEDGER_NAME_SPACE(Loan, 'L')
LEDGER_NAME_SPACE(Sponsorship, '>')
// No longer used or supported. Left here to reserve the space to avoid
// accidental reuse, and intentionally not exported to clients.
LEDGER_NAME_SPACE_DEPRECATED(Contract, 'c')
LEDGER_NAME_SPACE_DEPRECATED(Generator, 'g')
LEDGER_NAME_SPACE_DEPRECATED(Nickname, 'n')

View File

@@ -350,6 +350,7 @@ JSS(LEDGER_ENTRY_TYPES); // out: RPC server_definitions
// matches definitions.json format
JSS(LEDGER_ENTRY_FLAGS); // out: RPC server_definitions
JSS(LEDGER_ENTRY_FORMATS); // out: RPC server_definitions
JSS(LEDGER_NAME_SPACES); // out: RPC server_definitions
JSS(levels); // LogLevels
JSS(limit); // in/out: AccountTx*, AccountOffers, AccountLines, AccountObjects
// in: LedgerData, BookOffers