xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/AMMDeposit.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 = ttAMM_DEPOSIT;
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 AMMDeposit");
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
79 [[nodiscard]]
81 getAmount() const
82 {
83 if (hasAmount())
84 {
85 return this->tx_->at(sfAmount);
86 }
87 return std::nullopt;
88 }
89
94 [[nodiscard]]
95 bool
96 hasAmount() const
97 {
98 return this->tx_->isFieldPresent(sfAmount);
99 }
100
106 [[nodiscard]]
109 {
110 if (hasAmount2())
111 {
112 return this->tx_->at(sfAmount2);
113 }
114 return std::nullopt;
115 }
116
121 [[nodiscard]]
122 bool
124 {
125 return this->tx_->isFieldPresent(sfAmount2);
126 }
127
132 [[nodiscard]]
134 getEPrice() const
135 {
136 if (hasEPrice())
137 {
138 return this->tx_->at(sfEPrice);
139 }
140 return std::nullopt;
141 }
142
147 [[nodiscard]]
148 bool
149 hasEPrice() const
150 {
151 return this->tx_->isFieldPresent(sfEPrice);
152 }
153
158 [[nodiscard]]
161 {
162 if (hasLPTokenOut())
163 {
164 return this->tx_->at(sfLPTokenOut);
165 }
166 return std::nullopt;
167 }
168
173 [[nodiscard]]
174 bool
176 {
177 return this->tx_->isFieldPresent(sfLPTokenOut);
178 }
179
184 [[nodiscard]]
187 {
188 if (hasTradingFee())
189 {
190 return this->tx_->at(sfTradingFee);
191 }
192 return std::nullopt;
193 }
194
199 [[nodiscard]]
200 bool
202 {
203 return this->tx_->isFieldPresent(sfTradingFee);
204 }
205};
206
214class AMMDepositBuilder : public TransactionBuilderBase<AMMDepositBuilder>
215{
216public:
225 AMMDepositBuilder(SF_ACCOUNT::type::value_type account,
228)
229 : TransactionBuilderBase<AMMDepositBuilder>(ttAMM_DEPOSIT, account, sequence, fee)
230 {
231 setAsset(asset);
232 setAsset2(asset2);
233 }
234
241 {
242 if (tx->getTxnType() != ttAMM_DEPOSIT)
243 {
244 throw std::runtime_error("Invalid transaction type for AMMDepositBuilder");
245 }
246 object_ = *tx;
247 }
248
250
258 {
259 object_[sfAsset] = STIssue(sfAsset, value);
260 return *this;
261 }
262
270 {
271 object_[sfAsset2] = STIssue(sfAsset2, value);
272 return *this;
273 }
274
282 {
283 object_[sfAmount] = value;
284 return *this;
285 }
286
294 {
295 object_[sfAmount2] = value;
296 return *this;
297 }
298
305 {
306 object_[sfEPrice] = value;
307 return *this;
308 }
309
316 {
317 object_[sfLPTokenOut] = value;
318 return *this;
319 }
320
327 {
328 object_[sfTradingFee] = value;
329 return *this;
330 }
331
339 build(PublicKey const& publicKey, SecretKey const& secretKey)
340 {
341 sign(publicKey, secretKey);
342 return AMMDeposit{std::make_shared<STTx>(std::move(object_))};
343 }
344};
345
346} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
AMMDepositBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (SoeOptional).
AMMDeposit build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AMMDeposit wrapper.
AMMDepositBuilder & setTradingFee(std::decay_t< typename SF_UINT16::type::value_type > const &value)
Set sfTradingFee (SoeOptional).
AMMDepositBuilder(std::shared_ptr< STTx const > tx)
Construct a AMMDepositBuilder from an existing STTx object.
AMMDepositBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Transaction-specific field setters.
AMMDepositBuilder & setAsset2(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset2 (SoeRequired).
AMMDepositBuilder(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 AMMDepositBuilder with required fields.
AMMDepositBuilder & setLPTokenOut(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfLPTokenOut (SoeOptional).
AMMDepositBuilder & setAmount2(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount2 (SoeOptional).
AMMDepositBuilder & setEPrice(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfEPrice (SoeOptional).
bool hasLPTokenOut() const
Check if sfLPTokenOut is present.
bool hasEPrice() const
Check if sfEPrice is present.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getAmount2() const
Get sfAmount2 (SoeOptional).
bool hasAmount() const
Check if sfAmount is present.
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (SoeRequired).
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getEPrice() const
Get sfEPrice (SoeOptional).
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getAmount() const
Get sfAmount (SoeOptional).
bool hasAmount2() const
Check if sfAmount2 is present.
SF_ISSUE::type::value_type getAsset2() const
Get sfAsset2 (SoeRequired).
AMMDeposit(std::shared_ptr< STTx const > tx)
Construct a AMMDeposit transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getLPTokenOut() const
Get sfLPTokenOut (SoeOptional).
bool hasTradingFee() const
Check if sfTradingFee is present.
protocol_autogen::Optional< SF_UINT16::type::value_type > getTradingFee() const
Get sfTradingFee (SoeOptional).
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.
AMMDepositBuilder & 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