rippled
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
16class AMMWithdrawBuilder;
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
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 (hasLPTokenIn())
159 {
160 return this->tx_->at(sfLPTokenIn);
161 }
162 return std::nullopt;
163 }
164
169 [[nodiscard]]
170 bool
172 {
173 return this->tx_->isFieldPresent(sfLPTokenIn);
174 }
175};
176
184class AMMWithdrawBuilder : public TransactionBuilderBase<AMMWithdrawBuilder>
185{
186public:
195 AMMWithdrawBuilder(SF_ACCOUNT::type::value_type account,
198)
199 : TransactionBuilderBase<AMMWithdrawBuilder>(ttAMM_WITHDRAW, account, sequence, fee)
200 {
201 setAsset(asset);
202 setAsset2(asset2);
203 }
204
211 {
212 if (tx->getTxnType() != ttAMM_WITHDRAW)
213 {
214 throw std::runtime_error("Invalid transaction type for AMMWithdrawBuilder");
215 }
216 object_ = *tx;
217 }
218
227 {
228 object_[sfAsset] = STIssue(sfAsset, value);
229 return *this;
230 }
231
238 {
239 object_[sfAsset2] = STIssue(sfAsset2, value);
240 return *this;
241 }
242
249 {
250 object_[sfAmount] = value;
251 return *this;
252 }
253
260 {
261 object_[sfAmount2] = value;
262 return *this;
263 }
264
271 {
272 object_[sfEPrice] = value;
273 return *this;
274 }
275
282 {
283 object_[sfLPTokenIn] = value;
284 return *this;
285 }
286
294 build(PublicKey const& publicKey, SecretKey const& secretKey)
295 {
296 sign(publicKey, secretKey);
297 return AMMWithdraw{std::make_shared<STTx>(std::move(object_))};
298 }
299};
300
301} // 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)
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.
AMMWithdrawBuilder & 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