xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/SponsorshipSet.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 = ttSPONSORSHIP_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 SponsorshipSet");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
57 {
59 {
60 return this->tx_->at(sfCounterpartySponsor);
61 }
62 return std::nullopt;
63 }
64
69 [[nodiscard]]
70 bool
72 {
73 return this->tx_->isFieldPresent(sfCounterpartySponsor);
74 }
75
80 [[nodiscard]]
82 getSponsee() const
83 {
84 if (hasSponsee())
85 {
86 return this->tx_->at(sfSponsee);
87 }
88 return std::nullopt;
89 }
90
95 [[nodiscard]]
96 bool
97 hasSponsee() const
98 {
99 return this->tx_->isFieldPresent(sfSponsee);
100 }
101
106 [[nodiscard]]
109 {
110 if (hasFeeAmountDelta())
111 {
112 return this->tx_->at(sfFeeAmountDelta);
113 }
114 return std::nullopt;
115 }
116
121 [[nodiscard]]
122 bool
124 {
125 return this->tx_->isFieldPresent(sfFeeAmountDelta);
126 }
127
132 [[nodiscard]]
134 getMaxFee() const
135 {
136 if (hasMaxFee())
137 {
138 return this->tx_->at(sfMaxFee);
139 }
140 return std::nullopt;
141 }
142
147 [[nodiscard]]
148 bool
149 hasMaxFee() const
150 {
151 return this->tx_->isFieldPresent(sfMaxFee);
152 }
153
158 [[nodiscard]]
161 {
163 {
164 return this->tx_->at(sfRemainingOwnerCountDelta);
165 }
166 return std::nullopt;
167 }
168
173 [[nodiscard]]
174 bool
176 {
177 return this->tx_->isFieldPresent(sfRemainingOwnerCountDelta);
178 }
179};
180
188class SponsorshipSetBuilder : public TransactionBuilderBase<SponsorshipSetBuilder>
189{
190public:
197 SponsorshipSetBuilder(SF_ACCOUNT::type::value_type account,
198 std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
200)
201 : TransactionBuilderBase<SponsorshipSetBuilder>(ttSPONSORSHIP_SET, account, sequence, fee)
202 {
203 }
204
211 {
212 if (tx->getTxnType() != ttSPONSORSHIP_SET)
213 {
214 throw std::runtime_error("Invalid transaction type for SponsorshipSetBuilder");
215 }
216 object_ = *tx;
217 }
218
222
229 {
230 object_[sfCounterpartySponsor] = value;
231 return *this;
232 }
233
240 {
241 object_[sfSponsee] = value;
242 return *this;
243 }
244
251 {
252 object_[sfFeeAmountDelta] = value;
253 return *this;
254 }
255
262 {
263 object_[sfMaxFee] = value;
264 return *this;
265 }
266
273 {
274 object_[sfRemainingOwnerCountDelta] = value;
275 return *this;
276 }
277
285 build(PublicKey const& publicKey, SecretKey const& secretKey)
286 {
287 sign(publicKey, secretKey);
289 }
290};
291
292} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:53
A secret key.
Definition SecretKey.h:24
SponsorshipSetBuilder(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 SponsorshipSetBuilder with required fields.
SponsorshipSetBuilder & setRemainingOwnerCountDelta(std::decay_t< typename SF_INT32::type::value_type > const &value)
Set sfRemainingOwnerCountDelta (SoeOptional).
SponsorshipSetBuilder(std::shared_ptr< STTx const > tx)
Construct a SponsorshipSetBuilder from an existing STTx object.
SponsorshipSetBuilder & setSponsee(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfSponsee (SoeOptional).
SponsorshipSetBuilder & setMaxFee(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfMaxFee (SoeOptional).
SponsorshipSetBuilder & setCounterpartySponsor(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Transaction-specific field setters.
SponsorshipSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the SponsorshipSet wrapper.
SponsorshipSetBuilder & setFeeAmountDelta(std::decay_t< typename SF_AMOUNT::type::value_type > const &value)
Set sfFeeAmountDelta (SoeOptional).
bool hasFeeAmountDelta() const
Check if sfFeeAmountDelta is present.
bool hasSponsee() const
Check if sfSponsee is present.
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getCounterpartySponsor() const
Get sfCounterpartySponsor (SoeOptional).
bool hasCounterpartySponsor() const
Check if sfCounterpartySponsor is present.
bool hasRemainingOwnerCountDelta() const
Check if sfRemainingOwnerCountDelta is present.
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getFeeAmountDelta() const
Get sfFeeAmountDelta (SoeOptional).
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getSponsee() const
Get sfSponsee (SoeOptional).
SponsorshipSet(std::shared_ptr< STTx const > tx)
Construct a SponsorshipSet transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_INT32::type::value_type > getRemainingOwnerCountDelta() const
Get sfRemainingOwnerCountDelta (SoeOptional).
protocol_autogen::Optional< SF_AMOUNT::type::value_type > getMaxFee() const
Get sfMaxFee (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.
SponsorshipSetBuilder & 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:45