xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/AMMBid.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 AMMBidBuilder;
17
29class AMMBid : public TransactionBase
30{
31public:
32 static constexpr xrpl::TxType txType = ttAMM_BID;
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 AMMBid");
45 }
46 }
47
48 // Transaction-specific field getters
49
55 [[nodiscard]]
56 SF_ISSUE::type::value_type
57 getAsset() const
58 {
59 return this->tx_->at(sfAsset);
60 }
61
67 [[nodiscard]]
68 SF_ISSUE::type::value_type
69 getAsset2() const
70 {
71 return this->tx_->at(sfAsset2);
72 }
73
78 [[nodiscard]]
80 getBidMin() const
81 {
82 if (hasBidMin())
83 {
84 return this->tx_->at(sfBidMin);
85 }
86 return std::nullopt;
87 }
88
93 [[nodiscard]]
94 bool
95 hasBidMin() const
96 {
97 return this->tx_->isFieldPresent(sfBidMin);
98 }
99
104 [[nodiscard]]
106 getBidMax() const
107 {
108 if (hasBidMax())
109 {
110 return this->tx_->at(sfBidMax);
111 }
112 return std::nullopt;
113 }
114
119 [[nodiscard]]
120 bool
121 hasBidMax() const
122 {
123 return this->tx_->isFieldPresent(sfBidMax);
124 }
125
130 [[nodiscard]]
133 {
134 if (this->tx_->isFieldPresent(sfAuthAccounts))
135 return this->tx_->getFieldArray(sfAuthAccounts);
136 return std::nullopt;
137 }
138
143 [[nodiscard]]
144 bool
146 {
147 return this->tx_->isFieldPresent(sfAuthAccounts);
148 }
149};
150
158class AMMBidBuilder : public TransactionBuilderBase<AMMBidBuilder>
159{
160public:
169 AMMBidBuilder(SF_ACCOUNT::type::value_type account,
172)
173 : TransactionBuilderBase<AMMBidBuilder>(ttAMM_BID, account, sequence, fee)
174 {
175 setAsset(asset);
176 setAsset2(asset2);
177 }
178
185 {
186 if (tx->getTxnType() != ttAMM_BID)
187 {
188 throw std::runtime_error("Invalid transaction type for AMMBidBuilder");
189 }
190 object_ = *tx;
191 }
192
194
202 {
203 object_[sfAsset] = STIssue(sfAsset, value);
204 return *this;
205 }
206
214 {
215 object_[sfAsset2] = STIssue(sfAsset2, value);
216 return *this;
217 }
218
225 {
226 object_[sfBidMin] = value;
227 return *this;
228 }
229
236 {
237 object_[sfBidMax] = value;
238 return *this;
239 }
240
247 {
248 object_.setFieldArray(sfAuthAccounts, value);
249 return *this;
250 }
251
258 AMMBid
259 build(PublicKey const& publicKey, SecretKey const& secretKey)
260 {
261 sign(publicKey, secretKey);
262 return AMMBid{std::make_shared<STTx>(std::move(object_))};
263 }
264};
265
266} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
AMMBidBuilder & setBidMax(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfBidMax (SoeOptional).
AMMBidBuilder & setAuthAccounts(STArray const &value)
Set sfAuthAccounts (SoeOptional).
AMMBidBuilder & setBidMin(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfBidMin (SoeOptional).
AMMBidBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_ISSUE::type::value_type > const &asset, std::decay_t< typename SF_ISSUE::type::value_type > const &asset2, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new AMMBidBuilder with required fields.
AMMBidBuilder & setAsset2(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset2 (SoeRequired).
AMMBidBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Transaction-specific field setters.
AMMBidBuilder(std::shared_ptr< STTx const > tx)
Construct a AMMBidBuilder from an existing STTx object.
AMMBid build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AMMBid wrapper.
bool hasBidMin() const
Check if sfBidMin is present.
bool hasBidMax() const
Check if sfBidMax is present.
std::optional< std::reference_wrapper< STArray const > > getAuthAccounts() const
Get sfAuthAccounts (SoeOptional).
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getBidMin() const
Get sfBidMin (SoeOptional).
bool hasAuthAccounts() const
Check if sfAuthAccounts is present.
AMMBid(std::shared_ptr< STTx const > tx)
Construct a AMMBid transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getBidMax() const
Get sfBidMax (SoeOptional).
SF_ISSUE::type::value_type getAsset2() const
Get sfAsset2 (SoeRequired).
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (SoeRequired).
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.
AMMBidBuilder & 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