rippled
LedgerFormats.cpp
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #include <ripple/protocol/LedgerFormats.h>
21 #include <ripple/protocol/jss.h>
22 #include <utility>
23 
24 namespace ripple {
25 
27 {
28  // clang-format off
29  // Fields shared by all ledger formats:
30  static const std::initializer_list<SOElement> commonFields{
34  };
35 
36  add(jss::AccountRoot,
38  {
58  },
59  commonFields);
60 
61  add(jss::DirectoryNode,
62  ltDIR_NODE,
63  {
64  {sfOwner, soeOPTIONAL}, // for owner directories
65  {sfTakerPaysCurrency, soeOPTIONAL}, // order book directories
66  {sfTakerPaysIssuer, soeOPTIONAL}, // order book directories
67  {sfTakerGetsCurrency, soeOPTIONAL}, // order book directories
68  {sfTakerGetsIssuer, soeOPTIONAL}, // order book directories
69  {sfExchangeRate, soeOPTIONAL}, // order book directories
75  },
76  commonFields);
77 
78  add(jss::Offer,
79  ltOFFER,
80  {
91  },
92  commonFields);
93 
94  add(jss::RippleState,
96  {
108  },
109  commonFields);
110 
111  add(jss::Escrow,
112  ltESCROW,
113  {
126  },
127  commonFields);
128 
129  add(jss::LedgerHashes,
131  {
135  },
136  commonFields);
137 
138  add(jss::Amendments,
139  ltAMENDMENTS,
140  {
141  {sfAmendments, soeOPTIONAL}, // Enabled
143  },
144  commonFields);
145 
146  add(jss::FeeSettings,
148  {
149  // Old version uses raw numbers
154  // New version uses Amounts
158  },
159  commonFields);
160 
161  add(jss::Ticket,
162  ltTICKET,
163  {
169  },
170  commonFields);
171 
172  // All fields are soeREQUIRED because there is always a
173  // SignerEntries. If there are no SignerEntries the node is deleted.
174  add(jss::SignerList,
176  {
183  },
184  commonFields);
185 
186  add(jss::PayChannel,
187  ltPAYCHAN,
188  {
203  },
204  commonFields);
205 
206  add(jss::Check,
207  ltCHECK,
208  {
221  },
222  commonFields);
223 
224  add(jss::DepositPreauth,
226  {
232  },
233  commonFields);
234 
235  add(jss::NegativeUNL,
237  {
241  },
242  commonFields);
243 
244  add(jss::NFTokenPage,
246  {
252  },
253  commonFields);
254 
255  add(jss::NFTokenOffer,
257  {
258  {sfOwner, soeREQUIRED},
267  },
268  commonFields);
269  // clang-format on
270 }
271 
272 LedgerFormats const&
274 {
275  static LedgerFormats instance;
276  return instance;
277 }
278 
279 } // namespace ripple
ripple::sfIndexNext
const SF_UINT64 sfIndexNext
ripple::sfSignerListID
const SF_UINT32 sfSignerListID
ripple::sfHighQualityIn
const SF_UINT32 sfHighQualityIn
ripple::sfPreviousTxnLgrSeq
const SF_UINT32 sfPreviousTxnLgrSeq
ripple::sfOwnerCount
const SF_UINT32 sfOwnerCount
ripple::sfSourceTag
const SF_UINT32 sfSourceTag
ripple::sfRootIndex
const SF_UINT256 sfRootIndex
ripple::ltTICKET
@ ltTICKET
A ledger object which describes a ticket.
Definition: LedgerFormats.h:80
ripple::sfBaseFeeDrops
const SF_AMOUNT sfBaseFeeDrops
ripple::sfReserveBase
const SF_UINT32 sfReserveBase
ripple::sfSendMax
const SF_AMOUNT sfSendMax
utility
ripple::sfOwnerNode
const SF_UINT64 sfOwnerNode
ripple::sfDestination
const SF_ACCOUNT sfDestination
ripple::sfAmount
const SF_AMOUNT sfAmount
ripple::sfNFTokenID
const SF_UINT256 sfNFTokenID
ripple::ltLEDGER_HASHES
@ ltLEDGER_HASHES
A ledger object that contains a list of ledger hashes.
Definition: LedgerFormats.h:102
ripple::sfWalletSize
const SF_UINT32 sfWalletSize
ripple::sfFirstLedgerSequence
const SF_UINT32 sfFirstLedgerSequence
ripple::sfOwner
const SF_ACCOUNT sfOwner
ripple::sfSequence
const SF_UINT32 sfSequence
ripple::sfRegularKey
const SF_ACCOUNT sfRegularKey
ripple::sfBookDirectory
const SF_UINT256 sfBookDirectory
ripple::sfTakerPaysCurrency
const SF_UINT160 sfTakerPaysCurrency
ripple::sfLedgerIndex
const SF_UINT256 sfLedgerIndex
ripple::ltSIGNER_LIST
@ ltSIGNER_LIST
A ledger object which contains a signer list for an account.
Definition: LedgerFormats.h:86
ripple::sfMintedNFTokens
const SF_UINT32 sfMintedNFTokens
ripple::soeREQUIRED
@ soeREQUIRED
Definition: SOTemplate.h:35
ripple::sfTicketSequence
const SF_UINT32 sfTicketSequence
ripple::ltCHECK
@ ltCHECK
A ledger object which describes a check.
Definition: LedgerFormats.h:136
ripple::ltFEE_SETTINGS
@ ltFEE_SETTINGS
The ledger object which lists the network's fee settings.
Definition: LedgerFormats.h:118
ripple::sfTakerGetsCurrency
const SF_UINT160 sfTakerGetsCurrency
ripple::sfNFTokenOfferNode
const SF_UINT64 sfNFTokenOfferNode
ripple::ltDIR_NODE
@ ltDIR_NODE
A ledger object which contains a list of object identifiers.
Definition: LedgerFormats.h:66
ripple::sfExpiration
const SF_UINT32 sfExpiration
ripple::sfSignerQuorum
const SF_UINT32 sfSignerQuorum
ripple::sfIndexes
const SF_VECTOR256 sfIndexes
ripple::sfTakerGetsIssuer
const SF_UINT160 sfTakerGetsIssuer
ripple::sfLowNode
const SF_UINT64 sfLowNode
ripple::sfTakerPays
const SF_AMOUNT sfTakerPays
ripple::ltAMENDMENTS
@ ltAMENDMENTS
The ledger object which lists details about amendments on the network.
Definition: LedgerFormats.h:110
ripple::sfLowQualityOut
const SF_UINT32 sfLowQualityOut
ripple::sfLowLimit
const SF_AMOUNT sfLowLimit
ripple::ltOFFER
@ ltOFFER
A ledger object which describes an offer on the DEX.
Definition: LedgerFormats.h:92
ripple::sfSettleDelay
const SF_UINT32 sfSettleDelay
ripple::sfNFTokenMinter
const SF_ACCOUNT sfNFTokenMinter
ripple::ltESCROW
@ ltESCROW
A ledger object describing a single escrow.
Definition: LedgerFormats.h:124
ripple::sfReserveIncrement
const SF_UINT32 sfReserveIncrement
ripple::sfIndexPrevious
const SF_UINT64 sfIndexPrevious
ripple::ltNFTOKEN_OFFER
@ ltNFTOKEN_OFFER
A ledger object which identifies an offer to buy or sell an NFT.
Definition: LedgerFormats.h:162
ripple::soeOPTIONAL
@ soeOPTIONAL
Definition: SOTemplate.h:36
ripple::sfBookNode
const SF_UINT64 sfBookNode
ripple::LedgerFormats::LedgerFormats
LedgerFormats()
Create the object.
Definition: LedgerFormats.cpp:26
ripple::sfLowQualityIn
const SF_UINT32 sfLowQualityIn
ripple::sfValidatorToDisable
const SF_VL sfValidatorToDisable
ripple::sfTicketCount
const SF_UINT32 sfTicketCount
ripple::sfAccountTxnID
const SF_UINT256 sfAccountTxnID
ripple::ltDEPOSIT_PREAUTH
@ ltDEPOSIT_PREAUTH
A ledger object which describes a deposit preauthorization.
Definition: LedgerFormats.h:142
ripple::sfDestinationNode
const SF_UINT64 sfDestinationNode
ripple::sfTakerGets
const SF_AMOUNT sfTakerGets
ripple::sfTransferRate
const SF_UINT32 sfTransferRate
ripple::sfTickSize
const SF_UINT8 sfTickSize
ripple::sfPreviousTxnID
const SF_UINT256 sfPreviousTxnID
ripple::sfAuthorize
const SF_ACCOUNT sfAuthorize
ripple::sfHighLimit
const SF_AMOUNT sfHighLimit
ripple::sfExchangeRate
const SF_UINT64 sfExchangeRate
ripple::sfReserveIncrementDrops
const SF_AMOUNT sfReserveIncrementDrops
ripple::sfReserveBaseDrops
const SF_AMOUNT sfReserveBaseDrops
ripple::LedgerFormats::getInstance
static LedgerFormats const & getInstance()
Definition: LedgerFormats.cpp:273
ripple::sfEmailHash
const SF_UINT128 sfEmailHash
ripple::sfNFTokens
const SField sfNFTokens
ripple::sfSignerEntries
const SField sfSignerEntries
ripple::sfBaseFee
const SF_UINT64 sfBaseFee
ripple::sfHashes
const SF_VECTOR256 sfHashes
ripple::ltNFTOKEN_PAGE
@ ltNFTOKEN_PAGE
A ledger object which contains a list of NFTs.
Definition: LedgerFormats.h:156
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::sfWalletLocator
const SF_UINT256 sfWalletLocator
ripple::sfLedgerEntryType
const SF_UINT16 sfLedgerEntryType
ripple::ltNEGATIVE_UNL
@ ltNEGATIVE_UNL
The ledger object which tracks the current negative UNL state.
Definition: LedgerFormats.h:150
ripple::sfCondition
const SF_VL sfCondition
ripple::sfTakerPaysIssuer
const SF_UINT160 sfTakerPaysIssuer
ripple::sfInvoiceID
const SF_UINT256 sfInvoiceID
ripple::sfFlags
const SF_UINT32 sfFlags
ripple::ltACCOUNT_ROOT
@ ltACCOUNT_ROOT
A ledger object which describes an account.
Definition: LedgerFormats.h:59
ripple::sfDestinationTag
const SF_UINT32 sfDestinationTag
ripple::sfBalance
const SF_AMOUNT sfBalance
ripple::sfReferenceFeeUnits
const SF_UINT32 sfReferenceFeeUnits
ripple::sfNextPageMin
const SF_UINT256 sfNextPageMin
ripple::sfCancelAfter
const SF_UINT32 sfCancelAfter
ripple::sfMessageKey
const SF_VL sfMessageKey
ripple::sfHighQualityOut
const SF_UINT32 sfHighQualityOut
ripple::sfPreviousPageMin
const SF_UINT256 sfPreviousPageMin
ripple::LedgerFormats
Holds the list of known ledger entry formats.
Definition: LedgerFormats.h:276
ripple::sfFinishAfter
const SF_UINT32 sfFinishAfter
ripple::sfAccount
const SF_ACCOUNT sfAccount
ripple::ltRIPPLE_STATE
@ ltRIPPLE_STATE
A ledger object which describes a bidirectional trust line.
Definition: LedgerFormats.h:74
ripple::sfDomain
const SF_VL sfDomain
ripple::sfLastLedgerSequence
const SF_UINT32 sfLastLedgerSequence
ripple::sfBurnedNFTokens
const SF_UINT32 sfBurnedNFTokens
ripple::sfMajorities
const SField sfMajorities
ripple::sfDisabledValidators
const SField sfDisabledValidators
ripple::sfPublicKey
const SF_VL sfPublicKey
ripple::sfHighNode
const SF_UINT64 sfHighNode
ripple::soeDEFAULT
@ soeDEFAULT
Definition: SOTemplate.h:37
ripple::KnownFormats< LedgerEntryType, LedgerFormats >::add
Item const & add(char const *name, LedgerEntryType type, std::initializer_list< SOElement > uniqueFields, std::initializer_list< SOElement > commonFields={})
Add a new format.
Definition: KnownFormats.h:170
ripple::sfAmendments
const SF_VECTOR256 sfAmendments
ripple::ltPAYCHAN
@ ltPAYCHAN
A ledger object describing a single unidirectional XRP payment channel.
Definition: LedgerFormats.h:130
ripple::sfValidatorToReEnable
const SF_VL sfValidatorToReEnable
std::initializer_list