rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/DepositPreauth.h
1// This file is auto-generated. Do not edit.
2#pragma once
3
4#include <xrpl/protocol/STTx.h>
5#include <xrpl/protocol/STParsedJSON.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/protocol_autogen/TransactionBase.h>
8#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
9#include <xrpl/json/json_value.h>
10
11#include <stdexcept>
12#include <optional>
13
14namespace xrpl::transactions {
15
16class DepositPreauthBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttDEPOSIT_PREAUTH;
33
39 : TransactionBase(std::move(tx))
40 {
41 // Verify transaction type
42 if (tx_->getTxnType() != txType)
43 {
44 throw std::runtime_error("Invalid transaction type for DepositPreauth");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
57 {
58 if (hasAuthorize())
59 {
60 return this->tx_->at(sfAuthorize);
61 }
62 return std::nullopt;
63 }
64
69 [[nodiscard]]
70 bool
72 {
73 return this->tx_->isFieldPresent(sfAuthorize);
74 }
75
80 [[nodiscard]]
83 {
84 if (hasUnauthorize())
85 {
86 return this->tx_->at(sfUnauthorize);
87 }
88 return std::nullopt;
89 }
90
95 [[nodiscard]]
96 bool
98 {
99 return this->tx_->isFieldPresent(sfUnauthorize);
100 }
106 [[nodiscard]]
109 {
110 if (this->tx_->isFieldPresent(sfAuthorizeCredentials))
111 return this->tx_->getFieldArray(sfAuthorizeCredentials);
112 return std::nullopt;
113 }
114
119 [[nodiscard]]
120 bool
122 {
123 return this->tx_->isFieldPresent(sfAuthorizeCredentials);
124 }
130 [[nodiscard]]
133 {
134 if (this->tx_->isFieldPresent(sfUnauthorizeCredentials))
135 return this->tx_->getFieldArray(sfUnauthorizeCredentials);
136 return std::nullopt;
137 }
138
143 [[nodiscard]]
144 bool
146 {
147 return this->tx_->isFieldPresent(sfUnauthorizeCredentials);
148 }
149};
150
158class DepositPreauthBuilder : public TransactionBuilderBase<DepositPreauthBuilder>
159{
160public:
167 DepositPreauthBuilder(SF_ACCOUNT::type::value_type account,
170)
171 : TransactionBuilderBase<DepositPreauthBuilder>(ttDEPOSIT_PREAUTH, account, sequence, fee)
172 {
173 }
174
181 {
182 if (tx->getTxnType() != ttDEPOSIT_PREAUTH)
183 {
184 throw std::runtime_error("Invalid transaction type for DepositPreauthBuilder");
185 }
186 object_ = *tx;
187 }
188
197 {
198 object_[sfAuthorize] = value;
199 return *this;
200 }
201
208 {
209 object_[sfUnauthorize] = value;
210 return *this;
211 }
212
219 {
220 object_.setFieldArray(sfAuthorizeCredentials, value);
221 return *this;
222 }
223
230 {
231 object_.setFieldArray(sfUnauthorizeCredentials, value);
232 return *this;
233 }
234
242 build(PublicKey const& publicKey, SecretKey const& secretKey)
243 {
244 sign(publicKey, secretKey);
246 }
247};
248
249} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:819
A secret key.
Definition SecretKey.h:18
DepositPreauthBuilder & setUnauthorize(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfUnauthorize (soeOPTIONAL)
DepositPreauthBuilder & setAuthorizeCredentials(STArray const &value)
Set sfAuthorizeCredentials (soeOPTIONAL)
DepositPreauthBuilder(std::shared_ptr< STTx const > tx)
Construct a DepositPreauthBuilder from an existing STTx object.
DepositPreauthBuilder(SF_ACCOUNT::type::value_type account, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new DepositPreauthBuilder with required fields.
DepositPreauth build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the DepositPreauth wrapper.
DepositPreauthBuilder & setUnauthorizeCredentials(STArray const &value)
Set sfUnauthorizeCredentials (soeOPTIONAL)
DepositPreauthBuilder & setAuthorize(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Transaction-specific field setters.
bool hasAuthorize() const
Check if sfAuthorize is present.
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getAuthorize() const
Get sfAuthorize (soeOPTIONAL)
bool hasUnauthorizeCredentials() const
Check if sfUnauthorizeCredentials is present.
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getUnauthorize() const
Get sfUnauthorize (soeOPTIONAL)
std::optional< std::reference_wrapper< STArray const > > getUnauthorizeCredentials() const
Get sfUnauthorizeCredentials (soeOPTIONAL)
bool hasUnauthorize() const
Check if sfUnauthorize is present.
bool hasAuthorizeCredentials() const
Check if sfAuthorizeCredentials is present.
std::optional< std::reference_wrapper< STArray const > > getAuthorizeCredentials() const
Get sfAuthorizeCredentials (soeOPTIONAL)
DepositPreauth(std::shared_ptr< STTx const > tx)
Construct a DepositPreauth transaction wrapper from an existing STTx object.
Base class for all transaction wrapper types.
std::shared_ptr< STTx const > tx_
The underlying transaction object being wrapped.
Base class for all transaction builders.
DepositPreauthBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
T is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39