rippled
Loading...
Searching...
No Matches
RippleState.h
1// This file is auto-generated. Do not edit.
2#pragma once
3
4#include <xrpl/protocol/STLedgerEntry.h>
5#include <xrpl/protocol/STParsedJSON.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/protocol_autogen/LedgerEntryBase.h>
8#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
9#include <xrpl/json/json_value.h>
10
11#include <stdexcept>
12#include <optional>
13
14namespace xrpl::ledger_entries {
15
16class RippleStateBuilder;
17
28{
29public:
30 static constexpr LedgerEntryType entryType = ltRIPPLE_STATE;
31
37 : LedgerEntryBase(std::move(sle))
38 {
39 // Verify ledger entry type
40 if (sle_->getType() != entryType)
41 {
42 throw std::runtime_error("Invalid ledger entry type for RippleState");
43 }
44 }
45
46 // Ledger entry-specific field getters
47
52 [[nodiscard]]
53 SF_AMOUNT::type::value_type
54 getBalance() const
55 {
56 return this->sle_->at(sfBalance);
57 }
58
63 [[nodiscard]]
64 SF_AMOUNT::type::value_type
66 {
67 return this->sle_->at(sfLowLimit);
68 }
69
74 [[nodiscard]]
75 SF_AMOUNT::type::value_type
77 {
78 return this->sle_->at(sfHighLimit);
79 }
80
85 [[nodiscard]]
86 SF_UINT256::type::value_type
88 {
89 return this->sle_->at(sfPreviousTxnID);
90 }
91
96 [[nodiscard]]
97 SF_UINT32::type::value_type
99 {
100 return this->sle_->at(sfPreviousTxnLgrSeq);
101 }
102
107 [[nodiscard]]
110 {
111 if (hasLowNode())
112 return this->sle_->at(sfLowNode);
113 return std::nullopt;
114 }
115
120 [[nodiscard]]
121 bool
123 {
124 return this->sle_->isFieldPresent(sfLowNode);
125 }
126
131 [[nodiscard]]
134 {
135 if (hasLowQualityIn())
136 return this->sle_->at(sfLowQualityIn);
137 return std::nullopt;
138 }
139
144 [[nodiscard]]
145 bool
147 {
148 return this->sle_->isFieldPresent(sfLowQualityIn);
149 }
150
155 [[nodiscard]]
158 {
159 if (hasLowQualityOut())
160 return this->sle_->at(sfLowQualityOut);
161 return std::nullopt;
162 }
163
168 [[nodiscard]]
169 bool
171 {
172 return this->sle_->isFieldPresent(sfLowQualityOut);
173 }
174
179 [[nodiscard]]
182 {
183 if (hasHighNode())
184 return this->sle_->at(sfHighNode);
185 return std::nullopt;
186 }
187
192 [[nodiscard]]
193 bool
195 {
196 return this->sle_->isFieldPresent(sfHighNode);
197 }
198
203 [[nodiscard]]
206 {
207 if (hasHighQualityIn())
208 return this->sle_->at(sfHighQualityIn);
209 return std::nullopt;
210 }
211
216 [[nodiscard]]
217 bool
219 {
220 return this->sle_->isFieldPresent(sfHighQualityIn);
221 }
222
227 [[nodiscard]]
230 {
231 if (hasHighQualityOut())
232 return this->sle_->at(sfHighQualityOut);
233 return std::nullopt;
234 }
235
240 [[nodiscard]]
241 bool
243 {
244 return this->sle_->isFieldPresent(sfHighQualityOut);
245 }
246};
247
255class RippleStateBuilder : public LedgerEntryBuilderBase<RippleStateBuilder>
256{
257public:
275
282 {
283 if (sle->at(sfLedgerEntryType) != ltRIPPLE_STATE)
284 {
285 throw std::runtime_error("Invalid ledger entry type for RippleState");
286 }
287 object_ = *sle;
288 }
289
298 {
299 object_[sfBalance] = value;
300 return *this;
301 }
302
309 {
310 object_[sfLowLimit] = value;
311 return *this;
312 }
313
320 {
321 object_[sfHighLimit] = value;
322 return *this;
323 }
324
331 {
332 object_[sfPreviousTxnID] = value;
333 return *this;
334 }
335
342 {
343 object_[sfPreviousTxnLgrSeq] = value;
344 return *this;
345 }
346
353 {
354 object_[sfLowNode] = value;
355 return *this;
356 }
357
364 {
365 object_[sfLowQualityIn] = value;
366 return *this;
367 }
368
375 {
376 object_[sfLowQualityOut] = value;
377 return *this;
378 }
379
386 {
387 object_[sfHighNode] = value;
388 return *this;
389 }
390
397 {
398 object_[sfHighQualityIn] = value;
399 return *this;
400 }
401
408 {
409 object_[sfHighQualityOut] = value;
410 return *this;
411 }
412
419 build(uint256 const& index)
420 {
421 return RippleState{std::make_shared<SLE>(std::move(object_), index)};
422 }
423};
424
425} // namespace xrpl::ledger_entries
Base class for type-safe ledger entry wrappers.
std::shared_ptr< SLE const > sle_
The underlying serialized ledger entry being wrapped.
Base class for all ledger entry builders.
Builder for RippleState ledger entries.
RippleStateBuilder & setLowQualityOut(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfLowQualityOut (soeOPTIONAL)
RippleStateBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (soeREQUIRED)
RippleStateBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfPreviousTxnID (soeREQUIRED)
RippleStateBuilder & setHighNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfHighNode (soeOPTIONAL)
RippleStateBuilder & setLowNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfLowNode (soeOPTIONAL)
RippleStateBuilder & setHighLimit(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfHighLimit (soeREQUIRED)
RippleStateBuilder & setBalance(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Ledger entry-specific field setters.
RippleState build(uint256 const &index)
Build and return the completed RippleState wrapper.
RippleStateBuilder & setLowLimit(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfLowLimit (soeREQUIRED)
RippleStateBuilder & setHighQualityOut(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfHighQualityOut (soeOPTIONAL)
RippleStateBuilder(std::decay_t< typename SF_AMOUNT::type::value_type > const &balance, std::decay_t< typename SF_AMOUNT::type::value_type > const &lowLimit, std::decay_t< typename SF_AMOUNT::type::value_type > const &highLimit, std::decay_t< typename SF_UINT256::type::value_type > const &previousTxnID, std::decay_t< typename SF_UINT32::type::value_type > const &previousTxnLgrSeq)
Construct a new RippleStateBuilder with required fields.
RippleStateBuilder & setHighQualityIn(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfHighQualityIn (soeOPTIONAL)
RippleStateBuilder & setLowQualityIn(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfLowQualityIn (soeOPTIONAL)
RippleStateBuilder(std::shared_ptr< SLE const > sle)
Construct a RippleStateBuilder from an existing SLE object.
Ledger Entry: RippleState.
Definition RippleState.h:28
protocol_autogen::Optional< SF_UINT64::type::value_type > getLowNode() const
Get sfLowNode (soeOPTIONAL)
SF_AMOUNT::type::value_type getHighLimit() const
Get sfHighLimit (soeREQUIRED)
Definition RippleState.h:76
static constexpr LedgerEntryType entryType
Definition RippleState.h:30
bool hasHighQualityIn() const
Check if sfHighQualityIn is present.
SF_AMOUNT::type::value_type getBalance() const
Get sfBalance (soeREQUIRED)
Definition RippleState.h:54
protocol_autogen::Optional< SF_UINT32::type::value_type > getLowQualityIn() const
Get sfLowQualityIn (soeOPTIONAL)
protocol_autogen::Optional< SF_UINT32::type::value_type > getHighQualityOut() const
Get sfHighQualityOut (soeOPTIONAL)
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (soeREQUIRED)
Definition RippleState.h:87
RippleState(std::shared_ptr< SLE const > sle)
Construct a RippleState ledger entry wrapper from an existing SLE object.
Definition RippleState.h:36
bool hasLowQualityIn() const
Check if sfLowQualityIn is present.
SF_UINT32::type::value_type getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (soeREQUIRED)
Definition RippleState.h:98
SF_AMOUNT::type::value_type getLowLimit() const
Get sfLowLimit (soeREQUIRED)
Definition RippleState.h:65
bool hasLowNode() const
Check if sfLowNode is present.
protocol_autogen::Optional< SF_UINT64::type::value_type > getHighNode() const
Get sfHighNode (soeOPTIONAL)
bool hasHighNode() const
Check if sfHighNode is present.
bool hasLowQualityOut() const
Check if sfLowQualityOut is present.
protocol_autogen::Optional< SF_UINT32::type::value_type > getLowQualityOut() const
Get sfLowQualityOut (soeOPTIONAL)
protocol_autogen::Optional< SF_UINT32::type::value_type > getHighQualityIn() const
Get sfHighQualityIn (soeOPTIONAL)
bool hasHighQualityOut() const
Check if sfHighQualityOut is present.
T is_same_v
STL namespace.
LedgerEntryType
Identifiers for on-ledger objects.