rippled
Loading...
Searching...
No Matches
Indexes.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/protocol/Book.h>
5#include <xrpl/protocol/Keylet.h>
6#include <xrpl/protocol/LedgerFormats.h>
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/STXChainBridge.h>
10#include <xrpl/protocol/Serializer.h>
11#include <xrpl/protocol/UintTypes.h>
12#include <xrpl/protocol/jss.h>
13
14#include <cstdint>
15#include <set>
16
17namespace xrpl {
18
19class SeqProxy;
34namespace keylet {
35
38account(AccountID const& id) noexcept;
39
41Keylet const&
42amendments() noexcept;
43
46child(uint256 const& key) noexcept;
47
53Keylet const&
54skip() noexcept;
55
67skip(LedgerIndex ledger) noexcept;
68
70Keylet const&
71fees() noexcept;
72
74Keylet const&
75negativeUNL() noexcept;
76
78struct book_t
79{
80 explicit book_t() = default;
81
82 Keylet
83 operator()(Book const& b) const;
84};
85static book_t const book{};
86
96line(AccountID const& id0, AccountID const& id1, Currency const& currency) noexcept;
97
98inline Keylet
99line(AccountID const& id, Issue const& issue) noexcept
100{
101 return line(id, issue.account, issue.currency);
102}
107Keylet
108offer(AccountID const& id, std::uint32_t seq) noexcept;
109
110inline Keylet
111offer(uint256 const& key) noexcept
112{
113 return {ltOFFER, key};
114}
118Keylet
119quality(Keylet const& k, std::uint64_t q) noexcept;
120
122struct next_t
123{
124 explicit next_t() = default;
125
126 Keylet
127 operator()(Keylet const& k) const;
128};
129static next_t const next{};
130
133{
134 explicit ticket_t() = default;
135
136 Keylet
137 operator()(AccountID const& id, std::uint32_t ticketSeq) const;
138
139 Keylet
140 operator()(AccountID const& id, SeqProxy ticketSeq) const;
141
142 Keylet
143 operator()(uint256 const& key) const
144 {
145 return {ltTICKET, key};
146 }
147};
148static ticket_t const ticket{};
149
151Keylet
152signers(AccountID const& account) noexcept;
153
156Keylet
157check(AccountID const& id, std::uint32_t seq) noexcept;
158
159inline Keylet
160check(uint256 const& key) noexcept
161{
162 return {ltCHECK, key};
163}
168Keylet
169depositPreauth(AccountID const& owner, AccountID const& preauthorized) noexcept;
170
171Keylet
173 AccountID const& owner,
174 std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
175
176inline Keylet
177depositPreauth(uint256 const& key) noexcept
178{
179 return {ltDEPOSIT_PREAUTH, key};
180}
183//------------------------------------------------------------------------------
184
186Keylet
187unchecked(uint256 const& key) noexcept;
188
190Keylet
191ownerDir(AccountID const& id) noexcept;
192
195Keylet
196page(uint256 const& root, std::uint64_t index = 0) noexcept;
197
198inline Keylet
199page(Keylet const& root, std::uint64_t index = 0) noexcept
200{
201 XRPL_ASSERT(root.type == ltDIR_NODE, "xrpl::keylet::page : valid root type");
202 return page(root.key, index);
203}
207Keylet
208escrow(AccountID const& src, std::uint32_t seq) noexcept;
209
211Keylet
212payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
213
223Keylet
224nftpage_min(AccountID const& owner);
225
227Keylet
228nftpage_max(AccountID const& owner);
229
230Keylet
231nftpage(Keylet const& k, uint256 const& token);
235Keylet
236nftoffer(AccountID const& owner, std::uint32_t seq);
237
238inline Keylet
240{
241 return {ltNFTOKEN_OFFER, offer};
242}
243
245Keylet
246nft_buys(uint256 const& id) noexcept;
247
249Keylet
250nft_sells(uint256 const& id) noexcept;
251
253Keylet
254amm(Asset const& issue1, Asset const& issue2) noexcept;
255
256Keylet
257amm(uint256 const& amm) noexcept;
258
260Keylet
261delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
262
263Keylet
265
266// `seq` is stored as `sfXChainClaimID` in the object
267Keylet
269
270// `seq` is stored as `sfXChainAccountCreateCount` in the object
271Keylet
273
274Keylet
275did(AccountID const& account) noexcept;
276
277Keylet
278oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
279
280Keylet
281credential(AccountID const& subject, AccountID const& issuer, Slice const& credType) noexcept;
282
283inline Keylet
284credential(uint256 const& key) noexcept
285{
286 return {ltCREDENTIAL, key};
287}
288
289Keylet
290mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
291
292Keylet
293mptIssuance(MPTID const& issuanceID) noexcept;
294
295inline Keylet
296mptIssuance(uint256 const& issuanceKey)
297{
298 return {ltMPTOKEN_ISSUANCE, issuanceKey};
299}
300
301Keylet
302mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
303
304inline Keylet
305mptoken(uint256 const& mptokenKey)
306{
307 return {ltMPTOKEN, mptokenKey};
308}
309
310Keylet
311mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
312
313Keylet
314vault(AccountID const& owner, std::uint32_t seq) noexcept;
315
316inline Keylet
317vault(uint256 const& vaultKey)
318{
319 return {ltVAULT, vaultKey};
320}
321
322Keylet
323loanbroker(AccountID const& owner, std::uint32_t seq) noexcept;
324
325inline Keylet
327{
328 return {ltLOAN_BROKER, key};
329}
330
331Keylet
332loan(uint256 const& loanBrokerID, std::uint32_t loanSeq) noexcept;
333
334inline Keylet
335loan(uint256 const& key)
336{
337 return {ltLOAN, key};
338}
339
340Keylet
341permissionedDomain(AccountID const& account, std::uint32_t seq) noexcept;
342
343Keylet
344permissionedDomain(uint256 const& domainID) noexcept;
345} // namespace keylet
346
347// Everything below is deprecated and should be removed in favor of keylets:
348
350getBookBase(Book const& book);
351
353getQualityNext(uint256 const& uBase);
354
355// VFALCO This name could be better
357getQuality(uint256 const& uBase);
358
360getTicketIndex(AccountID const& account, std::uint32_t uSequence);
361
363getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
364
365template <class... keyletParams>
366// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
373
374// This list should include all of the keylet functions that take a single
375// AccountID parameter.
377 {{&keylet::account, jss::AccountRoot, false},
378 {&keylet::ownerDir, jss::DirectoryNode, true},
379 {&keylet::signers, jss::SignerList, true},
380 // It's normally impossible to create an item at nftpage_min, but
381 // test it anyway, since the invariant checks for it.
382 {&keylet::nftpage_min, jss::NFTokenPage, true},
383 {&keylet::nftpage_max, jss::NFTokenPage, true},
384 {&keylet::did, jss::DID, true}}};
385
386MPTID
387makeMptID(std::uint32_t sequence, AccountID const& account);
388
389} // namespace xrpl
Lightweight wrapper to tag static string.
Definition json_value.h:44
Specifies an order book.
Definition Book.h:16
A currency issued by an account.
Definition Issue.h:13
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:36
An immutable linear range of bytes.
Definition Slice.h:26
STL namespace.
Keylet const & skip() noexcept
The index of the "short" skip list.
Definition Indexes.cpp:177
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Definition Indexes.cpp:249
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:295
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition Indexes.cpp:468
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition Indexes.cpp:207
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:462
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition Indexes.cpp:371
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:386
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:330
static ticket_t const ticket
Definition Indexes.h:148
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:307
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition Indexes.cpp:379
static next_t const next
Definition Indexes.h:129
Keylet loanbroker(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:510
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition Indexes.cpp:351
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition Indexes.cpp:424
static book_t const book
Definition Indexes.h:85
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:193
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:336
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition Indexes.cpp:392
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:357
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:474
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:301
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:404
Keylet loan(uint256 const &loanBrokerID, std::uint32_t loanSeq) noexcept
Definition Indexes.cpp:516
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition Indexes.cpp:243
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition Indexes.cpp:171
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:504
Keylet line(AccountID const &id0, AccountID const &id1, Currency const &currency) noexcept
The index of a trust line for a given currency.
Definition Indexes.cpp:220
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition Indexes.cpp:363
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:448
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:486
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition Indexes.cpp:398
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:418
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition Indexes.cpp:200
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition Indexes.cpp:522
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition Indexes.cpp:342
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:498
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:434
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
uint256 getTicketIndex(AccountID const &account, std::uint32_t uSequence)
Definition Indexes.cpp:138
std::uint64_t getQuality(uint256 const &uBase)
Definition Indexes.cpp:131
Number root(Number f, unsigned d)
Definition Number.cpp:958
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
base_uint< 256 > uint256
Definition base_uint.h:531
base_uint< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
Definition UintTypes.h:44
uint256 getQualityNext(uint256 const &uBase)
Definition Indexes.cpp:123
uint256 getBookBase(Book const &book)
Definition Indexes.cpp:98
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:151
std::array< keyletDesc< AccountID const & >, 6 > const directAccountKeylets
Definition Indexes.h:376
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
Json::StaticString expectedLEName
Definition Indexes.h:370
std::function< Keylet(keyletParams...)> function
Definition Indexes.h:369
bool includeInTests
Definition Indexes.h:371
The beginning of an order book.
Definition Indexes.h:79
Keylet operator()(Book const &b) const
Definition Indexes.cpp:214
The directory for the next lower quality.
Definition Indexes.h:123
Keylet operator()(Keylet const &k) const
Definition Indexes.cpp:267
A ticket belonging to an account.
Definition Indexes.h:133
Keylet operator()(uint256 const &key) const
Definition Indexes.h:143
Keylet operator()(AccountID const &id, std::uint32_t ticketSeq) const
Definition Indexes.cpp:274