27class LedgerTypeAttribute {
28 enum class LedgerCategory {
35 xrpl::LedgerEntryType type_ = xrpl::ltANY;
36 char const* name_ =
nullptr;
37 char const* rpcName_ =
nullptr;
38 LedgerCategory category_ = LedgerCategory::Invalid;
40 constexpr LedgerTypeAttribute(
43 xrpl::LedgerEntryType type,
44 LedgerCategory category
46 : type_{type}, name_{name}, rpcName_{rpcName}, category_{category}
51 static constexpr LedgerTypeAttribute
52 chainLedgerType(
char const* name,
char const* rpcName, xrpl::LedgerEntryType type)
54 return LedgerTypeAttribute(name, rpcName, type, LedgerCategory::Chain);
57 static constexpr LedgerTypeAttribute
58 accountOwnedLedgerType(
char const* name,
char const* rpcName, xrpl::LedgerEntryType type)
60 return LedgerTypeAttribute(name, rpcName, type, LedgerCategory::AccountOwned);
63 static constexpr LedgerTypeAttribute
64 deletionBlockerLedgerType(
char const* name,
char const* rpcName, xrpl::LedgerEntryType type)
66 return LedgerTypeAttribute(name, rpcName, type, LedgerCategory::DeletionBlocker);
79 using LedgerTypeAttributeList = LedgerTypeAttribute[];
81 static constexpr LedgerTypeAttributeList
const kLedgerTypes{
82 LedgerTypeAttribute::accountOwnedLedgerType(
87 LedgerTypeAttribute::chainLedgerType(JS(Amendments), JS(amendments), xrpl::ltAMENDMENTS),
88 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Check), JS(check), xrpl::ltCHECK),
89 LedgerTypeAttribute::accountOwnedLedgerType(
92 xrpl::ltDEPOSIT_PREAUTH
95 LedgerTypeAttribute::chainLedgerType(JS(DirectoryNode), JS(directory), xrpl::ltDIR_NODE),
96 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Escrow), JS(escrow), xrpl::ltESCROW),
97 LedgerTypeAttribute::chainLedgerType(JS(FeeSettings), JS(fee), xrpl::ltFEE_SETTINGS),
98 LedgerTypeAttribute::chainLedgerType(JS(LedgerHashes), JS(hashes), xrpl::ltLEDGER_HASHES),
99 LedgerTypeAttribute::accountOwnedLedgerType(JS(Offer), JS(offer), xrpl::ltOFFER),
100 LedgerTypeAttribute::deletionBlockerLedgerType(
105 LedgerTypeAttribute::accountOwnedLedgerType(
110 LedgerTypeAttribute::deletionBlockerLedgerType(
115 LedgerTypeAttribute::accountOwnedLedgerType(JS(Ticket), JS(ticket), xrpl::ltTICKET),
116 LedgerTypeAttribute::accountOwnedLedgerType(
119 xrpl::ltNFTOKEN_OFFER
121 LedgerTypeAttribute::deletionBlockerLedgerType(
126 LedgerTypeAttribute::accountOwnedLedgerType(JS(AMM), JS(amm), xrpl::ltAMM),
127 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Bridge), JS(bridge), xrpl::ltBRIDGE),
128 LedgerTypeAttribute::deletionBlockerLedgerType(
129 JS(XChainOwnedClaimID),
130 JS(xchain_owned_claim_id),
131 xrpl::ltXCHAIN_OWNED_CLAIM_ID
133 LedgerTypeAttribute::deletionBlockerLedgerType(
134 JS(XChainOwnedCreateAccountClaimID),
135 JS(xchain_owned_create_account_claim_id),
136 xrpl::ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID
138 LedgerTypeAttribute::accountOwnedLedgerType(JS(DID), JS(did), xrpl::ltDID),
139 LedgerTypeAttribute::accountOwnedLedgerType(JS(Oracle), JS(oracle), xrpl::ltORACLE),
140 LedgerTypeAttribute::accountOwnedLedgerType(
145 LedgerTypeAttribute::accountOwnedLedgerType(JS(Vault), JS(vault), xrpl::ltVAULT),
147 LedgerTypeAttribute::accountOwnedLedgerType(
152 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Loan), JS(loan), xrpl::ltLOAN),
153 LedgerTypeAttribute::chainLedgerType(JS(NegativeUNL), JS(nunl), xrpl::ltNEGATIVE_UNL),
154 LedgerTypeAttribute::deletionBlockerLedgerType(
157 xrpl::ltMPTOKEN_ISSUANCE
159 LedgerTypeAttribute::deletionBlockerLedgerType(JS(MPToken), JS(mptoken), xrpl::ltMPTOKEN),
160 LedgerTypeAttribute::deletionBlockerLedgerType(
161 JS(PermissionedDomain),
162 JS(permissioned_domain),
163 xrpl::ltPERMISSIONED_DOMAIN
165 LedgerTypeAttribute::accountOwnedLedgerType(JS(Delegate), JS(delegate), xrpl::ltDELEGATE),
173 static constexpr auto
176 std::array<
char const*, std::size(kLedgerTypes)> res{};
177 std::ranges::transform(kLedgerTypes, std::begin(res), [](
auto const& item) {
178 return item.rpcName_;
188 static constexpr auto
191 constexpr auto kFilter = [](
auto const& item) {
192 return item.category_ == LedgerTypeAttribute::LedgerCategory::DeletionBlocker;
195 constexpr auto kDeletionBlockersCount =
196 std::count_if(std::begin(kLedgerTypes), std::end(kLedgerTypes), kFilter);
197 std::array<xrpl::LedgerEntryType, kDeletionBlockersCount> res{};
198 auto it = std::begin(res);
199 std::ranges::for_each(kLedgerTypes, [&](
auto const& item) {
215 static xrpl::LedgerEntryType
225 static xrpl::LedgerEntryType
229 static std::optional<std::reference_wrapper<impl::LedgerTypeAttribute const>>
230 getLedgerTypeAttributeFromStr(std::string
const& entryName);