rippled
Loading...
Searching...
No Matches
include/xrpl/protocol_autogen/ledger_entries/AMM.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 AMMBuilder;
17
27class AMM : public LedgerEntryBase
28{
29public:
30 static constexpr LedgerEntryType entryType = ltAMM;
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 AMM");
43 }
44 }
45
46 // Ledger entry-specific field getters
47
52 [[nodiscard]]
53 SF_ACCOUNT::type::value_type
54 getAccount() const
55 {
56 return this->sle_->at(sfAccount);
57 }
58
63 [[nodiscard]]
66 {
67 if (hasTradingFee())
68 return this->sle_->at(sfTradingFee);
69 return std::nullopt;
70 }
71
76 [[nodiscard]]
77 bool
79 {
80 return this->sle_->isFieldPresent(sfTradingFee);
81 }
82
88 [[nodiscard]]
91 {
92 if (this->sle_->isFieldPresent(sfVoteSlots))
93 return this->sle_->getFieldArray(sfVoteSlots);
94 return std::nullopt;
95 }
96
101 [[nodiscard]]
102 bool
104 {
105 return this->sle_->isFieldPresent(sfVoteSlots);
106 }
107
113 [[nodiscard]]
116 {
117 if (this->sle_->isFieldPresent(sfAuctionSlot))
118 return this->sle_->getFieldObject(sfAuctionSlot);
119 return std::nullopt;
120 }
121
126 [[nodiscard]]
127 bool
129 {
130 return this->sle_->isFieldPresent(sfAuctionSlot);
131 }
132
137 [[nodiscard]]
138 SF_AMOUNT::type::value_type
140 {
141 return this->sle_->at(sfLPTokenBalance);
142 }
143
148 [[nodiscard]]
149 SF_ISSUE::type::value_type
150 getAsset() const
151 {
152 return this->sle_->at(sfAsset);
153 }
154
159 [[nodiscard]]
160 SF_ISSUE::type::value_type
161 getAsset2() const
162 {
163 return this->sle_->at(sfAsset2);
164 }
165
170 [[nodiscard]]
171 SF_UINT64::type::value_type
173 {
174 return this->sle_->at(sfOwnerNode);
175 }
176
181 [[nodiscard]]
184 {
185 if (hasPreviousTxnID())
186 return this->sle_->at(sfPreviousTxnID);
187 return std::nullopt;
188 }
189
194 [[nodiscard]]
195 bool
197 {
198 return this->sle_->isFieldPresent(sfPreviousTxnID);
199 }
200
205 [[nodiscard]]
208 {
210 return this->sle_->at(sfPreviousTxnLgrSeq);
211 return std::nullopt;
212 }
213
218 [[nodiscard]]
219 bool
221 {
222 return this->sle_->isFieldPresent(sfPreviousTxnLgrSeq);
223 }
224};
225
233class AMMBuilder : public LedgerEntryBuilderBase<AMMBuilder>
234{
235public:
253
260 {
261 if (sle->at(sfLedgerEntryType) != ltAMM)
262 {
263 throw std::runtime_error("Invalid ledger entry type for AMM");
264 }
265 object_ = *sle;
266 }
267
276 {
277 object_[sfAccount] = value;
278 return *this;
279 }
280
287 {
288 object_[sfTradingFee] = value;
289 return *this;
290 }
291
297 setVoteSlots(STArray const& value)
298 {
299 object_.setFieldArray(sfVoteSlots, value);
300 return *this;
301 }
302
309 {
310 object_.setFieldObject(sfAuctionSlot, value);
311 return *this;
312 }
313
320 {
321 object_[sfLPTokenBalance] = value;
322 return *this;
323 }
324
331 {
332 object_[sfAsset] = STIssue(sfAsset, value);
333 return *this;
334 }
335
342 {
343 object_[sfAsset2] = STIssue(sfAsset2, value);
344 return *this;
345 }
346
353 {
354 object_[sfOwnerNode] = value;
355 return *this;
356 }
357
364 {
365 object_[sfPreviousTxnID] = value;
366 return *this;
367 }
368
375 {
376 object_[sfPreviousTxnLgrSeq] = value;
377 return *this;
378 }
379
385 AMM
386 build(uint256 const& index)
387 {
388 return AMM{std::make_shared<SLE>(std::move(object_), index)};
389 }
390};
391
392} // namespace xrpl::ledger_entries
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:819
void setFieldObject(SField const &field, STObject const &v)
Definition STObject.cpp:825
AMMBuilder & setTradingFee(std::decay_t< typename SF_UINT16::type::value_type > const &value)
Set sfTradingFee (soeDEFAULT)
AMMBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (soeOPTIONAL)
AMMBuilder & setAuctionSlot(STObject const &value)
Set sfAuctionSlot (soeOPTIONAL)
AMMBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (soeREQUIRED)
AMMBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfPreviousTxnID (soeOPTIONAL)
AMMBuilder & setVoteSlots(STArray const &value)
Set sfVoteSlots (soeOPTIONAL)
AMMBuilder & setAsset2(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset2 (soeREQUIRED)
AMMBuilder & setLPTokenBalance(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfLPTokenBalance (soeREQUIRED)
AMMBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset (soeREQUIRED)
AMMBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Ledger entry-specific field setters.
AMMBuilder(std::decay_t< typename SF_ACCOUNT::type::value_type > const &account, std::decay_t< typename SF_AMOUNT::type::value_type > const &lPTokenBalance, std::decay_t< typename SF_ISSUE::type::value_type > const &asset, std::decay_t< typename SF_ISSUE::type::value_type > const &asset2, std::decay_t< typename SF_UINT64::type::value_type > const &ownerNode)
Construct a new AMMBuilder with required fields.
AMM build(uint256 const &index)
Build and return the completed AMM wrapper.
AMMBuilder(std::shared_ptr< SLE const > sle)
Construct a AMMBuilder from an existing SLE object.
SF_ISSUE::type::value_type getAsset2() const
Get sfAsset2 (soeREQUIRED)
bool hasPreviousTxnLgrSeq() const
Check if sfPreviousTxnLgrSeq is present.
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (soeREQUIRED)
std::optional< STObject > getAuctionSlot() const
Get sfAuctionSlot (soeOPTIONAL)
protocol_autogen::Optional< SF_UINT32::type::value_type > getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (soeOPTIONAL)
bool hasPreviousTxnID() const
Check if sfPreviousTxnID is present.
bool hasTradingFee() const
Check if sfTradingFee is present.
SF_AMOUNT::type::value_type getLPTokenBalance() const
Get sfLPTokenBalance (soeREQUIRED)
std::optional< std::reference_wrapper< STArray const > > getVoteSlots() const
Get sfVoteSlots (soeOPTIONAL)
bool hasAuctionSlot() const
Check if sfAuctionSlot is present.
AMM(std::shared_ptr< SLE const > sle)
Construct a AMM ledger entry wrapper from an existing SLE object.
SF_ACCOUNT::type::value_type getAccount() const
Get sfAccount (soeREQUIRED)
protocol_autogen::Optional< SF_UINT256::type::value_type > getPreviousTxnID() const
Get sfPreviousTxnID (soeOPTIONAL)
protocol_autogen::Optional< SF_UINT16::type::value_type > getTradingFee() const
Get sfTradingFee (soeDEFAULT)
bool hasVoteSlots() const
Check if sfVoteSlots is present.
SF_UINT64::type::value_type getOwnerNode() const
Get sfOwnerNode (soeREQUIRED)
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.
T is_same_v
STL namespace.
LedgerEntryType
Identifiers for on-ledger objects.