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  {
59  },
60  commonFields);
61 
62  add(jss::DirectoryNode,
63  ltDIR_NODE,
64  {
65  {sfOwner, soeOPTIONAL}, // for owner directories
66  {sfTakerPaysCurrency, soeOPTIONAL}, // order book directories
67  {sfTakerPaysIssuer, soeOPTIONAL}, // order book directories
68  {sfTakerGetsCurrency, soeOPTIONAL}, // order book directories
69  {sfTakerGetsIssuer, soeOPTIONAL}, // order book directories
70  {sfExchangeRate, soeOPTIONAL}, // order book directories
76  },
77  commonFields);
78 
79  add(jss::Offer,
80  ltOFFER,
81  {
92  },
93  commonFields);
94 
95  add(jss::RippleState,
97  {
109  },
110  commonFields);
111 
112  add(jss::Escrow,
113  ltESCROW,
114  {
127  },
128  commonFields);
129 
130  add(jss::LedgerHashes,
132  {
136  },
137  commonFields);
138 
139  add(jss::Amendments,
140  ltAMENDMENTS,
141  {
142  {sfAmendments, soeOPTIONAL}, // Enabled
144  },
145  commonFields);
146 
147  add(jss::FeeSettings,
149  {
150  // Old version uses raw numbers
155  // New version uses Amounts
159  },
160  commonFields);
161 
162  add(jss::Ticket,
163  ltTICKET,
164  {
170  },
171  commonFields);
172 
173  // All fields are soeREQUIRED because there is always a
174  // SignerEntries. If there are no SignerEntries the node is deleted.
175  add(jss::SignerList,
177  {
184  },
185  commonFields);
186 
187  add(jss::PayChannel,
188  ltPAYCHAN,
189  {
204  },
205  commonFields);
206 
207  add(jss::Check,
208  ltCHECK,
209  {
222  },
223  commonFields);
224 
225  add(jss::DepositPreauth,
227  {
233  },
234  commonFields);
235 
236  add(jss::NegativeUNL,
238  {
242  },
243  commonFields);
244 
245  add(jss::NFTokenPage,
247  {
253  },
254  commonFields);
255 
256  add(jss::NFTokenOffer,
258  {
259  {sfOwner, soeREQUIRED},
268  },
269  commonFields);
270  // clang-format on
271 }
272 
273 LedgerFormats const&
275 {
276  static LedgerFormats instance;
277  return instance;
278 }
279 
280 } // 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::sfFirstNFTokenSequence
const SF_UINT32 sfFirstNFTokenSequence
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:274
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