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
172depositPreauth(AccountID const& owner, std::set<std::pair<AccountID, Slice>> const& authCreds) noexcept;
173
174inline Keylet
175depositPreauth(uint256 const& key) noexcept
176{
177 return {ltDEPOSIT_PREAUTH, key};
178}
181//------------------------------------------------------------------------------
182
184Keylet
185unchecked(uint256 const& key) noexcept;
186
188Keylet
189ownerDir(AccountID const& id) noexcept;
190
193Keylet
194page(uint256 const& root, std::uint64_t index = 0) noexcept;
195
196inline Keylet
197page(Keylet const& root, std::uint64_t index = 0) noexcept
198{
199 XRPL_ASSERT(root.type == ltDIR_NODE, "xrpl::keylet::page : valid root type");
200 return page(root.key, index);
201}
205Keylet
206escrow(AccountID const& src, std::uint32_t seq) noexcept;
207
209Keylet
210payChan(AccountID const& src, AccountID const& dst, std::uint32_t seq) noexcept;
211
221Keylet
222nftpage_min(AccountID const& owner);
223
225Keylet
226nftpage_max(AccountID const& owner);
227
228Keylet
229nftpage(Keylet const& k, uint256 const& token);
233Keylet
234nftoffer(AccountID const& owner, std::uint32_t seq);
235
236inline Keylet
238{
239 return {ltNFTOKEN_OFFER, offer};
240}
241
243Keylet
244nft_buys(uint256 const& id) noexcept;
245
247Keylet
248nft_sells(uint256 const& id) noexcept;
249
251Keylet
252amm(Asset const& issue1, Asset const& issue2) noexcept;
253
254Keylet
255amm(uint256 const& amm) noexcept;
256
258Keylet
259delegate(AccountID const& account, AccountID const& authorizedAccount) noexcept;
260
261Keylet
263
264// `seq` is stored as `sfXChainClaimID` in the object
265Keylet
267
268// `seq` is stored as `sfXChainAccountCreateCount` in the object
269Keylet
271
272Keylet
273did(AccountID const& account) noexcept;
274
275Keylet
276oracle(AccountID const& account, std::uint32_t const& documentID) noexcept;
277
278Keylet
279credential(AccountID const& subject, AccountID const& issuer, Slice const& credType) noexcept;
280
281inline Keylet
282credential(uint256 const& key) noexcept
283{
284 return {ltCREDENTIAL, key};
285}
286
287Keylet
288mptIssuance(std::uint32_t seq, AccountID const& issuer) noexcept;
289
290Keylet
291mptIssuance(MPTID const& issuanceID) noexcept;
292
293inline Keylet
294mptIssuance(uint256 const& issuanceKey)
295{
296 return {ltMPTOKEN_ISSUANCE, issuanceKey};
297}
298
299Keylet
300mptoken(MPTID const& issuanceID, AccountID const& holder) noexcept;
301
302inline Keylet
303mptoken(uint256 const& mptokenKey)
304{
305 return {ltMPTOKEN, mptokenKey};
306}
307
308Keylet
309mptoken(uint256 const& issuanceKey, AccountID const& holder) noexcept;
310
311Keylet
312vault(AccountID const& owner, std::uint32_t seq) noexcept;
313
314inline Keylet
315vault(uint256 const& vaultKey)
316{
317 return {ltVAULT, vaultKey};
318}
319
320Keylet
321loanbroker(AccountID const& owner, std::uint32_t seq) noexcept;
322
323inline Keylet
325{
326 return {ltLOAN_BROKER, key};
327}
328
329Keylet
330loan(uint256 const& loanBrokerID, std::uint32_t loanSeq) noexcept;
331
332inline Keylet
333loan(uint256 const& key)
334{
335 return {ltLOAN, key};
336}
337
338Keylet
340
341Keylet
342permissionedDomain(uint256 const& domainID) noexcept;
343} // namespace keylet
344
345// Everything below is deprecated and should be removed in favor of keylets:
346
348getBookBase(Book const& book);
349
351getQualityNext(uint256 const& uBase);
352
353// VFALCO This name could be better
355getQuality(uint256 const& uBase);
356
358getTicketIndex(AccountID const& account, std::uint32_t uSequence);
359
361getTicketIndex(AccountID const& account, SeqProxy ticketSeq);
362
363template <class... keyletParams>
370
371// This list should include all of the keylet functions that take a single
372// AccountID parameter.
374 {{&keylet::account, jss::AccountRoot, false},
375 {&keylet::ownerDir, jss::DirectoryNode, true},
376 {&keylet::signers, jss::SignerList, true},
377 // It's normally impossible to create an item at nftpage_min, but
378 // test it anyway, since the invariant checks for it.
379 {&keylet::nftpage_min, jss::NFTokenPage, true},
380 {&keylet::nftpage_max, jss::NFTokenPage, true},
381 {&keylet::did, jss::DID, true}}};
382
383MPTID
384makeMptID(std::uint32_t sequence, AccountID const& account);
385
386} // 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:172
Keylet quality(Keylet const &k, std::uint64_t q) noexcept
The initial directory page for a specific quality.
Definition Indexes.cpp:241
Keylet signers(AccountID const &account) noexcept
A SignerList.
Definition Indexes.cpp:287
Keylet oracle(AccountID const &account, std::uint32_t const &documentID) noexcept
Definition Indexes.cpp:456
Keylet const & negativeUNL() noexcept
The (fixed) index of the object containing the ledger negativeUNL.
Definition Indexes.cpp:201
Keylet did(AccountID const &account) noexcept
Definition Indexes.cpp:450
Keylet nftpage_max(AccountID const &owner)
A keylet for the owner's last possible NFT page.
Definition Indexes.cpp:360
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
Definition Indexes.cpp:375
Keylet unchecked(uint256 const &key) noexcept
Any ledger entry.
Definition Indexes.cpp:319
static ticket_t const ticket
Definition Indexes.h:148
Keylet depositPreauth(AccountID const &owner, AccountID const &preauthorized) noexcept
A DepositPreauth.
Definition Indexes.cpp:299
Keylet nftpage(Keylet const &k, uint256 const &token)
Definition Indexes.cpp:368
static next_t const next
Definition Indexes.h:129
Keylet loanbroker(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:498
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Definition Indexes.cpp:340
Keylet bridge(STXChainBridge const &bridge, STXChainBridge::ChainType chainType)
Definition Indexes.cpp:412
static book_t const book
Definition Indexes.h:85
Keylet const & amendments() noexcept
The index of the amendment table.
Definition Indexes.cpp:187
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:325
Keylet nft_buys(uint256 const &id) noexcept
The directory of buy offers for the specified NFT.
Definition Indexes.cpp:381
Keylet payChan(AccountID const &src, AccountID const &dst, std::uint32_t seq) noexcept
A PaymentChannel.
Definition Indexes.cpp:346
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:462
Keylet check(AccountID const &id, std::uint32_t seq) noexcept
A Check.
Definition Indexes.cpp:293
Keylet amm(Asset const &issue1, Asset const &issue2) noexcept
AMM entry.
Definition Indexes.cpp:393
Keylet loan(uint256 const &loanBrokerID, std::uint32_t loanSeq) noexcept
Definition Indexes.cpp:504
Keylet offer(AccountID const &id, std::uint32_t seq) noexcept
An offer from an account.
Definition Indexes.cpp:235
Keylet child(uint256 const &key) noexcept
Any item that can be in an owner dir.
Definition Indexes.cpp:166
Keylet vault(AccountID const &owner, std::uint32_t seq) noexcept
Definition Indexes.cpp:492
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:214
Keylet nftpage_min(AccountID const &owner)
NFT page keylets.
Definition Indexes.cpp:352
Keylet xChainCreateAccountClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:436
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:474
Keylet nft_sells(uint256 const &id) noexcept
The directory of sell offers for the specified NFT.
Definition Indexes.cpp:387
Keylet delegate(AccountID const &account, AccountID const &authorizedAccount) noexcept
A keylet for Delegate object.
Definition Indexes.cpp:406
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:160
Keylet const & fees() noexcept
The (fixed) index of the object containing the ledger fees.
Definition Indexes.cpp:194
Keylet permissionedDomain(AccountID const &account, std::uint32_t seq) noexcept
Definition Indexes.cpp:510
Keylet page(uint256 const &root, std::uint64_t index=0) noexcept
A page in a directory.
Definition Indexes.cpp:331
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:486
Keylet xChainClaimID(STXChainBridge const &bridge, std::uint64_t seq)
Definition Indexes.cpp:422
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:133
std::uint64_t getQuality(uint256 const &uBase)
Definition Indexes.cpp:126
Number root(Number f, unsigned d)
Definition Number.cpp:938
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:526
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:119
uint256 getBookBase(Book const &book)
Definition Indexes.cpp:98
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:146
std::array< keyletDesc< AccountID const & >, 6 > const directAccountKeylets
Definition Indexes.h:373
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
Json::StaticString expectedLEName
Definition Indexes.h:367
std::function< Keylet(keyletParams...)> function
Definition Indexes.h:366
bool includeInTests
Definition Indexes.h:368
The beginning of an order book.
Definition Indexes.h:79
Keylet operator()(Book const &b) const
Definition Indexes.cpp:208
The directory for the next lower quality.
Definition Indexes.h:123
Keylet operator()(Keylet const &k) const
Definition Indexes.cpp:259
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:266