rippled
Loading...
Searching...
No Matches
protocol_autogen/ledger_entries/DepositPreauth.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 DepositPreauthBuilder;
17
28{
29public:
30 static constexpr LedgerEntryType entryType = ltDEPOSIT_PREAUTH;
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 DepositPreauth");
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 (hasAuthorize())
68 return this->sle_->at(sfAuthorize);
69 return std::nullopt;
70 }
71
76 [[nodiscard]]
77 bool
79 {
80 return this->sle_->isFieldPresent(sfAuthorize);
81 }
82
87 [[nodiscard]]
88 SF_UINT64::type::value_type
90 {
91 return this->sle_->at(sfOwnerNode);
92 }
93
98 [[nodiscard]]
99 SF_UINT256::type::value_type
101 {
102 return this->sle_->at(sfPreviousTxnID);
103 }
104
109 [[nodiscard]]
110 SF_UINT32::type::value_type
112 {
113 return this->sle_->at(sfPreviousTxnLgrSeq);
114 }
115
121 [[nodiscard]]
124 {
125 if (this->sle_->isFieldPresent(sfAuthorizeCredentials))
126 return this->sle_->getFieldArray(sfAuthorizeCredentials);
127 return std::nullopt;
128 }
129
134 [[nodiscard]]
135 bool
137 {
138 return this->sle_->isFieldPresent(sfAuthorizeCredentials);
139 }
140};
141
149class DepositPreauthBuilder : public LedgerEntryBuilderBase<DepositPreauthBuilder>
150{
151public:
167
174 {
175 if (sle->at(sfLedgerEntryType) != ltDEPOSIT_PREAUTH)
176 {
177 throw std::runtime_error("Invalid ledger entry type for DepositPreauth");
178 }
179 object_ = *sle;
180 }
181
190 {
191 object_[sfAccount] = value;
192 return *this;
193 }
194
201 {
202 object_[sfAuthorize] = value;
203 return *this;
204 }
205
212 {
213 object_[sfOwnerNode] = value;
214 return *this;
215 }
216
223 {
224 object_[sfPreviousTxnID] = value;
225 return *this;
226 }
227
234 {
235 object_[sfPreviousTxnLgrSeq] = value;
236 return *this;
237 }
238
245 {
246 object_.setFieldArray(sfAuthorizeCredentials, value);
247 return *this;
248 }
249
256 build(uint256 const& index)
257 {
258 return DepositPreauth{std::make_shared<SLE>(std::move(object_), index)};
259 }
260};
261
262} // namespace xrpl::ledger_entries
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:819
DepositPreauthBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (soeREQUIRED)
DepositPreauthBuilder & setAuthorizeCredentials(STArray const &value)
Set sfAuthorizeCredentials (soeOPTIONAL)
DepositPreauthBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (soeREQUIRED)
DepositPreauth build(uint256 const &index)
Build and return the completed DepositPreauth wrapper.
DepositPreauthBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfPreviousTxnID (soeREQUIRED)
DepositPreauthBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Ledger entry-specific field setters.
DepositPreauthBuilder(std::shared_ptr< SLE const > sle)
Construct a DepositPreauthBuilder from an existing SLE object.
DepositPreauthBuilder(std::decay_t< typename SF_ACCOUNT::type::value_type > const &account, std::decay_t< typename SF_UINT64::type::value_type > const &ownerNode, 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 DepositPreauthBuilder with required fields.
DepositPreauthBuilder & setAuthorize(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfAuthorize (soeOPTIONAL)
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (soeREQUIRED)
bool hasAuthorizeCredentials() const
Check if sfAuthorizeCredentials is present.
bool hasAuthorize() const
Check if sfAuthorize is present.
DepositPreauth(std::shared_ptr< SLE const > sle)
Construct a DepositPreauth ledger entry wrapper from an existing SLE object.
SF_ACCOUNT::type::value_type getAccount() const
Get sfAccount (soeREQUIRED)
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getAuthorize() const
Get sfAuthorize (soeOPTIONAL)
SF_UINT32::type::value_type getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (soeREQUIRED)
std::optional< std::reference_wrapper< STArray const > > getAuthorizeCredentials() const
Get sfAuthorizeCredentials (soeOPTIONAL)
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.