xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/TrustSet.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 TrustSetBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttTRUST_SET;
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 TrustSet");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
57 {
58 if (hasLimitAmount())
59 {
60 return this->tx_->at(sfLimitAmount);
61 }
62 return std::nullopt;
63 }
64
69 [[nodiscard]]
70 bool
72 {
73 return this->tx_->isFieldPresent(sfLimitAmount);
74 }
75
80 [[nodiscard]]
83 {
84 if (hasQualityIn())
85 {
86 return this->tx_->at(sfQualityIn);
87 }
88 return std::nullopt;
89 }
90
95 [[nodiscard]]
96 bool
98 {
99 return this->tx_->isFieldPresent(sfQualityIn);
100 }
101
106 [[nodiscard]]
109 {
110 if (hasQualityOut())
111 {
112 return this->tx_->at(sfQualityOut);
113 }
114 return std::nullopt;
115 }
116
121 [[nodiscard]]
122 bool
124 {
125 return this->tx_->isFieldPresent(sfQualityOut);
126 }
127};
128
136class TrustSetBuilder : public TransactionBuilderBase<TrustSetBuilder>
137{
138public:
145 TrustSetBuilder(SF_ACCOUNT::type::value_type account,
146 std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
148)
149 : TransactionBuilderBase<TrustSetBuilder>(ttTRUST_SET, account, sequence, fee)
150 {
151 }
152
159 {
160 if (tx->getTxnType() != ttTRUST_SET)
161 {
162 throw std::runtime_error("Invalid transaction type for TrustSetBuilder");
163 }
164 object_ = *tx;
165 }
166
170
177 {
178 object_[sfLimitAmount] = value;
179 return *this;
180 }
181
188 {
189 object_[sfQualityIn] = value;
190 return *this;
191 }
192
199 {
200 object_[sfQualityOut] = value;
201 return *this;
202 }
203
211 build(PublicKey const& publicKey, SecretKey const& secretKey)
212 {
213 sign(publicKey, secretKey);
214 return TrustSet{std::make_shared<STTx>(std::move(object_))};
215 }
216};
217
218} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:53
A secret key.
Definition SecretKey.h:24
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.
TrustSetBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
TrustSetBuilder & setQualityOut(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfQualityOut (SoeOptional).
TrustSetBuilder(SF_ACCOUNT::type::value_type account, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new TrustSetBuilder with required fields.
TrustSetBuilder & setQualityIn(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfQualityIn (SoeOptional).
TrustSetBuilder(std::shared_ptr< STTx const > tx)
Construct a TrustSetBuilder from an existing STTx object.
TrustSetBuilder & setLimitAmount(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Transaction-specific field setters.
TrustSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the TrustSet wrapper.
protocol_autogen::Optional< SF_UINT32::type::value_type > getQualityOut() const
Get sfQualityOut (SoeOptional).
bool hasQualityIn() const
Check if sfQualityIn is present.
bool hasLimitAmount() const
Check if sfLimitAmount is present.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getLimitAmount() const
Get sfLimitAmount (SoeOptional).
TrustSet(std::shared_ptr< STTx const > tx)
Construct a TrustSet transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_UINT32::type::value_type > getQualityIn() const
Get sfQualityIn (SoeOptional).
bool hasQualityOut() const
Check if sfQualityOut is present.
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:45