xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/OfferCreate.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
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttOFFER_CREATE;
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 OfferCreate");
45 }
46 }
47
48 // Transaction-specific field getters
49
55 [[nodiscard]]
56 SF_AMOUNT::type::value_type
58 {
59 return this->tx_->at(sfTakerPays);
60 }
61
67 [[nodiscard]]
68 SF_AMOUNT::type::value_type
70 {
71 return this->tx_->at(sfTakerGets);
72 }
73
78 [[nodiscard]]
81 {
82 if (hasExpiration())
83 {
84 return this->tx_->at(sfExpiration);
85 }
86 return std::nullopt;
87 }
88
93 [[nodiscard]]
94 bool
96 {
97 return this->tx_->isFieldPresent(sfExpiration);
98 }
99
104 [[nodiscard]]
107 {
108 if (hasOfferSequence())
109 {
110 return this->tx_->at(sfOfferSequence);
111 }
112 return std::nullopt;
113 }
114
119 [[nodiscard]]
120 bool
122 {
123 return this->tx_->isFieldPresent(sfOfferSequence);
124 }
125
130 [[nodiscard]]
133 {
134 if (hasDomainID())
135 {
136 return this->tx_->at(sfDomainID);
137 }
138 return std::nullopt;
139 }
140
145 [[nodiscard]]
146 bool
148 {
149 return this->tx_->isFieldPresent(sfDomainID);
150 }
151};
152
160class OfferCreateBuilder : public TransactionBuilderBase<OfferCreateBuilder>
161{
162public:
171 OfferCreateBuilder(SF_ACCOUNT::type::value_type account,
174)
175 : TransactionBuilderBase<OfferCreateBuilder>(ttOFFER_CREATE, account, sequence, fee)
176 {
177 setTakerPays(takerPays);
178 setTakerGets(takerGets);
179 }
180
187 {
188 if (tx->getTxnType() != ttOFFER_CREATE)
189 {
190 throw std::runtime_error("Invalid transaction type for OfferCreateBuilder");
191 }
192 object_ = *tx;
193 }
194
196
204 {
205 object_[sfTakerPays] = value;
206 return *this;
207 }
208
216 {
217 object_[sfTakerGets] = value;
218 return *this;
219 }
220
227 {
228 object_[sfExpiration] = value;
229 return *this;
230 }
231
238 {
239 object_[sfOfferSequence] = value;
240 return *this;
241 }
242
249 {
250 object_[sfDomainID] = value;
251 return *this;
252 }
253
261 build(PublicKey const& publicKey, SecretKey const& secretKey)
262 {
263 sign(publicKey, secretKey);
264 return OfferCreate{std::make_shared<STTx>(std::move(object_))};
265 }
266};
267
268} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
OfferCreateBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_AMOUNT::type::value_type > const &takerPays, std::decay_t< typename SF_AMOUNT::type::value_type > const &takerGets, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new OfferCreateBuilder with required fields.
OfferCreateBuilder & setExpiration(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfExpiration (SoeOptional).
OfferCreateBuilder & setTakerPays(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Transaction-specific field setters.
OfferCreate build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the OfferCreate wrapper.
OfferCreateBuilder & setDomainID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfDomainID (SoeOptional).
OfferCreateBuilder & setOfferSequence(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfOfferSequence (SoeOptional).
OfferCreateBuilder & setTakerGets(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfTakerGets (SoeRequired).
OfferCreateBuilder(std::shared_ptr< STTx const > tx)
Construct a OfferCreateBuilder from an existing STTx object.
protocol_autogen::Optional< SF_UINT32::type::value_type > getOfferSequence() const
Get sfOfferSequence (SoeOptional).
protocol_autogen::Optional< SF_UINT32::type::value_type > getExpiration() const
Get sfExpiration (SoeOptional).
SF_AMOUNT::type::value_type getTakerPays() const
Get sfTakerPays (SoeRequired).
bool hasOfferSequence() const
Check if sfOfferSequence is present.
bool hasDomainID() const
Check if sfDomainID is present.
SF_AMOUNT::type::value_type getTakerGets() const
Get sfTakerGets (SoeRequired).
bool hasExpiration() const
Check if sfExpiration is present.
protocol_autogen::Optional< SF_UINT256::type::value_type > getDomainID() const
Get sfDomainID (SoeOptional).
OfferCreate(std::shared_ptr< STTx const > tx)
Construct a OfferCreate transaction wrapper from an existing STTx object.
std::shared_ptr< STTx const > tx_
The underlying transaction object being wrapped.
TransactionBase(std::shared_ptr< STTx const > tx)
Construct a transaction wrapper from an existing STTx object.
OfferCreateBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
T make_shared(T... args)
STL namespace.
std::conditional_t< std::is_reference_v< ValueType >, std::optional< std::reference_wrapper< std::remove_reference_t< ValueType > > >, std::optional< ValueType > > Optional
Definition Utils.h:9
TxType
Transaction type identifiers.
Definition TxFormats.h:41