rippled
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
16class AMMDepositBuilder;
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
54 [[nodiscard]]
55 SF_ISSUE::type::value_type
56 getAsset() const
57 {
58 return this->tx_->at(sfAsset);
59 }
60
65 [[nodiscard]]
66 SF_ISSUE::type::value_type
67 getAsset2() const
68 {
69 return this->tx_->at(sfAsset2);
70 }
71
76 [[nodiscard]]
78 getAmount() const
79 {
80 if (hasAmount())
81 {
82 return this->tx_->at(sfAmount);
83 }
84 return std::nullopt;
85 }
86
91 [[nodiscard]]
92 bool
93 hasAmount() const
94 {
95 return this->tx_->isFieldPresent(sfAmount);
96 }
97
102 [[nodiscard]]
105 {
106 if (hasAmount2())
107 {
108 return this->tx_->at(sfAmount2);
109 }
110 return std::nullopt;
111 }
112
117 [[nodiscard]]
118 bool
120 {
121 return this->tx_->isFieldPresent(sfAmount2);
122 }
123
128 [[nodiscard]]
130 getEPrice() const
131 {
132 if (hasEPrice())
133 {
134 return this->tx_->at(sfEPrice);
135 }
136 return std::nullopt;
137 }
138
143 [[nodiscard]]
144 bool
145 hasEPrice() const
146 {
147 return this->tx_->isFieldPresent(sfEPrice);
148 }
149
154 [[nodiscard]]
157 {
158 if (hasLPTokenOut())
159 {
160 return this->tx_->at(sfLPTokenOut);
161 }
162 return std::nullopt;
163 }
164
169 [[nodiscard]]
170 bool
172 {
173 return this->tx_->isFieldPresent(sfLPTokenOut);
174 }
175
180 [[nodiscard]]
183 {
184 if (hasTradingFee())
185 {
186 return this->tx_->at(sfTradingFee);
187 }
188 return std::nullopt;
189 }
190
195 [[nodiscard]]
196 bool
198 {
199 return this->tx_->isFieldPresent(sfTradingFee);
200 }
201};
202
210class AMMDepositBuilder : public TransactionBuilderBase<AMMDepositBuilder>
211{
212public:
221 AMMDepositBuilder(SF_ACCOUNT::type::value_type account,
224)
225 : TransactionBuilderBase<AMMDepositBuilder>(ttAMM_DEPOSIT, account, sequence, fee)
226 {
227 setAsset(asset);
228 setAsset2(asset2);
229 }
230
237 {
238 if (tx->getTxnType() != ttAMM_DEPOSIT)
239 {
240 throw std::runtime_error("Invalid transaction type for AMMDepositBuilder");
241 }
242 object_ = *tx;
243 }
244
253 {
254 object_[sfAsset] = STIssue(sfAsset, value);
255 return *this;
256 }
257
264 {
265 object_[sfAsset2] = STIssue(sfAsset2, value);
266 return *this;
267 }
268
275 {
276 object_[sfAmount] = value;
277 return *this;
278 }
279
286 {
287 object_[sfAmount2] = value;
288 return *this;
289 }
290
297 {
298 object_[sfEPrice] = value;
299 return *this;
300 }
301
308 {
309 object_[sfLPTokenOut] = value;
310 return *this;
311 }
312
319 {
320 object_[sfTradingFee] = value;
321 return *this;
322 }
323
331 build(PublicKey const& publicKey, SecretKey const& secretKey)
332 {
333 sign(publicKey, secretKey);
334 return AMMDeposit{std::make_shared<STTx>(std::move(object_))};
335 }
336};
337
338} // 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)
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.
AMMDepositBuilder & 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