46class LedgerTypeAttribute {
47 enum class LedgerCategory {
54 ripple::LedgerEntryType type_ = ripple::ltANY;
55 char const* name_ =
nullptr;
56 char const* rpcName_ =
nullptr;
57 LedgerCategory category_ = LedgerCategory::Invalid;
59 constexpr LedgerTypeAttribute(
62 ripple::LedgerEntryType type,
63 LedgerCategory category
65 : type_{type}, name_{name}, rpcName_{rpcName}, category_{category}
70 static constexpr LedgerTypeAttribute
71 chainLedgerType(
char const* name,
char const* rpcName, ripple::LedgerEntryType type)
73 return LedgerTypeAttribute(name, rpcName, type, LedgerCategory::Chain);
76 static constexpr LedgerTypeAttribute
77 accountOwnedLedgerType(
char const* name,
char const* rpcName, ripple::LedgerEntryType type)
79 return LedgerTypeAttribute(name, rpcName, type, LedgerCategory::AccountOwned);
82 static constexpr LedgerTypeAttribute
83 deletionBlockerLedgerType(
char const* name,
char const* rpcName, ripple::LedgerEntryType type)
85 return LedgerTypeAttribute(name, rpcName, type, LedgerCategory::DeletionBlocker);
98 using LedgerTypeAttributeList = LedgerTypeAttribute[];
100 static constexpr LedgerTypeAttributeList
const kLEDGER_TYPES{
101 LedgerTypeAttribute::accountOwnedLedgerType(
104 ripple::ltACCOUNT_ROOT
106 LedgerTypeAttribute::chainLedgerType(JS(Amendments), JS(amendments), ripple::ltAMENDMENTS),
107 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Check), JS(check), ripple::ltCHECK),
108 LedgerTypeAttribute::accountOwnedLedgerType(
111 ripple::ltDEPOSIT_PREAUTH
114 LedgerTypeAttribute::chainLedgerType(JS(DirectoryNode), JS(directory), ripple::ltDIR_NODE),
115 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Escrow), JS(escrow), ripple::ltESCROW),
116 LedgerTypeAttribute::chainLedgerType(JS(FeeSettings), JS(fee), ripple::ltFEE_SETTINGS),
117 LedgerTypeAttribute::chainLedgerType(JS(LedgerHashes), JS(hashes), ripple::ltLEDGER_HASHES),
118 LedgerTypeAttribute::accountOwnedLedgerType(JS(Offer), JS(offer), ripple::ltOFFER),
119 LedgerTypeAttribute::deletionBlockerLedgerType(
124 LedgerTypeAttribute::accountOwnedLedgerType(
127 ripple::ltSIGNER_LIST
129 LedgerTypeAttribute::deletionBlockerLedgerType(
132 ripple::ltRIPPLE_STATE
134 LedgerTypeAttribute::accountOwnedLedgerType(JS(Ticket), JS(ticket), ripple::ltTICKET),
135 LedgerTypeAttribute::accountOwnedLedgerType(
138 ripple::ltNFTOKEN_OFFER
140 LedgerTypeAttribute::deletionBlockerLedgerType(
143 ripple::ltNFTOKEN_PAGE
145 LedgerTypeAttribute::accountOwnedLedgerType(JS(AMM), JS(amm), ripple::ltAMM),
146 LedgerTypeAttribute::deletionBlockerLedgerType(JS(Bridge), JS(bridge), ripple::ltBRIDGE),
147 LedgerTypeAttribute::deletionBlockerLedgerType(
148 JS(XChainOwnedClaimID),
149 JS(xchain_owned_claim_id),
150 ripple::ltXCHAIN_OWNED_CLAIM_ID
152 LedgerTypeAttribute::deletionBlockerLedgerType(
153 JS(XChainOwnedCreateAccountClaimID),
154 JS(xchain_owned_create_account_claim_id),
155 ripple::ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID
157 LedgerTypeAttribute::accountOwnedLedgerType(JS(DID), JS(did), ripple::ltDID),
158 LedgerTypeAttribute::accountOwnedLedgerType(JS(Oracle), JS(oracle), ripple::ltORACLE),
159 LedgerTypeAttribute::accountOwnedLedgerType(
164 LedgerTypeAttribute::accountOwnedLedgerType(JS(Vault), JS(vault), ripple::ltVAULT),
165 LedgerTypeAttribute::chainLedgerType(JS(NegativeUNL), JS(nunl), ripple::ltNEGATIVE_UNL),
166 LedgerTypeAttribute::deletionBlockerLedgerType(
169 ripple::ltMPTOKEN_ISSUANCE
171 LedgerTypeAttribute::deletionBlockerLedgerType(JS(MPToken), JS(mptoken), ripple::ltMPTOKEN),
172 LedgerTypeAttribute::deletionBlockerLedgerType(
173 JS(PermissionedDomain),
174 JS(permissioned_domain),
175 ripple::ltPERMISSIONED_DOMAIN
177 LedgerTypeAttribute::accountOwnedLedgerType(JS(Delegate), JS(delegate), ripple::ltDELEGATE),
185 static constexpr auto
188 std::array<
char const*, std::size(kLEDGER_TYPES)> res{};
189 std::ranges::transform(kLEDGER_TYPES, std::begin(res), [](
auto const& item) {
190 return item.rpcName_;
200 static constexpr auto
203 constexpr auto kFILTER = [](
auto const& item) {
204 return item.category_ == LedgerTypeAttribute::LedgerCategory::DeletionBlocker;
207 constexpr auto kDELETION_BLOCKERS_COUNT =
208 std::count_if(std::begin(kLEDGER_TYPES), std::end(kLEDGER_TYPES), kFILTER);
209 std::array<ripple::LedgerEntryType, kDELETION_BLOCKERS_COUNT> res{};
210 auto it = std::begin(res);
211 std::ranges::for_each(kLEDGER_TYPES, [&](
auto const& item) {
227 static ripple::LedgerEntryType
237 static ripple::LedgerEntryType
241 static std::optional<std::reference_wrapper<impl::LedgerTypeAttribute const>>
242 getLedgerTypeAttributeFromStr(std::string
const& entryName);