xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/AMMWithdraw.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_WITHDRAW;
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 AMMWithdraw");
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 (hasLPTokenIn())
163 {
164 return this->tx_->at(sfLPTokenIn);
165 }
166 return std::nullopt;
167 }
168
173 [[nodiscard]]
174 bool
176 {
177 return this->tx_->isFieldPresent(sfLPTokenIn);
178 }
179};
180
188class AMMWithdrawBuilder : public TransactionBuilderBase<AMMWithdrawBuilder>
189{
190public:
199 AMMWithdrawBuilder(SF_ACCOUNT::type::value_type account,
202)
203 : TransactionBuilderBase<AMMWithdrawBuilder>(ttAMM_WITHDRAW, account, sequence, fee)
204 {
205 setAsset(asset);
206 setAsset2(asset2);
207 }
208
215 {
216 if (tx->getTxnType() != ttAMM_WITHDRAW)
217 {
218 throw std::runtime_error("Invalid transaction type for AMMWithdrawBuilder");
219 }
220 object_ = *tx;
221 }
222
224
232 {
233 object_[sfAsset] = STIssue(sfAsset, value);
234 return *this;
235 }
236
244 {
245 object_[sfAsset2] = STIssue(sfAsset2, value);
246 return *this;
247 }
248
256 {
257 object_[sfAmount] = value;
258 return *this;
259 }
260
268 {
269 object_[sfAmount2] = value;
270 return *this;
271 }
272
279 {
280 object_[sfEPrice] = value;
281 return *this;
282 }
283
290 {
291 object_[sfLPTokenIn] = value;
292 return *this;
293 }
294
302 build(PublicKey const& publicKey, SecretKey const& secretKey)
303 {
304 sign(publicKey, secretKey);
305 return AMMWithdraw{std::make_shared<STTx>(std::move(object_))};
306 }
307};
308
309} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
AMMWithdrawBuilder & setLPTokenIn(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfLPTokenIn (SoeOptional).
AMMWithdrawBuilder & setAsset2(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset2 (SoeRequired).
AMMWithdrawBuilder & setAmount2(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount2 (SoeOptional).
AMMWithdrawBuilder & setEPrice(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfEPrice (SoeOptional).
AMMWithdrawBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Transaction-specific field setters.
AMMWithdrawBuilder & setAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfAmount (SoeOptional).
AMMWithdrawBuilder(std::shared_ptr< STTx const > tx)
Construct a AMMWithdrawBuilder from an existing STTx object.
AMMWithdrawBuilder(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 AMMWithdrawBuilder with required fields.
AMMWithdraw build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the AMMWithdraw wrapper.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getAmount2() const
Get sfAmount2 (SoeOptional).
bool hasEPrice() const
Check if sfEPrice is present.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getAmount() const
Get sfAmount (SoeOptional).
bool hasAmount2() const
Check if sfAmount2 is present.
bool hasAmount() const
Check if sfAmount is present.
SF_ISSUE::type::value_type getAsset2() const
Get sfAsset2 (SoeRequired).
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (SoeRequired).
AMMWithdraw(std::shared_ptr< STTx const > tx)
Construct a AMMWithdraw transaction wrapper from an existing STTx object.
bool hasLPTokenIn() const
Check if sfLPTokenIn is present.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getEPrice() const
Get sfEPrice (SoeOptional).
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getLPTokenIn() const
Get sfLPTokenIn (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.
AMMWithdrawBuilder & 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