xrpld
Loading...
Searching...
No Matches
protocol_autogen/transactions/SponsorshipTransfer.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_TRANSFER;
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 SponsorshipTransfer");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
57 {
58 if (hasObjectID())
59 {
60 return this->tx_->at(sfObjectID);
61 }
62 return std::nullopt;
63 }
64
69 [[nodiscard]]
70 bool
72 {
73 return this->tx_->isFieldPresent(sfObjectID);
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};
102
110class SponsorshipTransferBuilder : public TransactionBuilderBase<SponsorshipTransferBuilder>
111{
112public:
119 SponsorshipTransferBuilder(SF_ACCOUNT::type::value_type account,
120 std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
122)
123 : TransactionBuilderBase<SponsorshipTransferBuilder>(ttSPONSORSHIP_TRANSFER, account, sequence, fee)
124 {
125 }
126
133 {
134 if (tx->getTxnType() != ttSPONSORSHIP_TRANSFER)
135 {
136 throw std::runtime_error("Invalid transaction type for SponsorshipTransferBuilder");
137 }
138 object_ = *tx;
139 }
140
144
151 {
152 object_[sfObjectID] = value;
153 return *this;
154 }
155
162 {
163 object_[sfSponsee] = value;
164 return *this;
165 }
166
174 build(PublicKey const& publicKey, SecretKey const& secretKey)
175 {
176 sign(publicKey, secretKey);
178 }
179};
180
181} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:53
A secret key.
Definition SecretKey.h:24
SponsorshipTransfer build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the SponsorshipTransfer wrapper.
SponsorshipTransferBuilder(std::shared_ptr< STTx const > tx)
Construct a SponsorshipTransferBuilder from an existing STTx object.
SponsorshipTransferBuilder & setSponsee(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfSponsee (SoeOptional).
SponsorshipTransferBuilder(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 SponsorshipTransferBuilder with required fields.
SponsorshipTransferBuilder & setObjectID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Transaction-specific field setters.
protocol_autogen::Optional< SF_UINT256::type::value_type > getObjectID() const
Get sfObjectID (SoeOptional).
SponsorshipTransfer(std::shared_ptr< STTx const > tx)
Construct a SponsorshipTransfer transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_ACCOUNT::type::value_type > getSponsee() const
Get sfSponsee (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.
SponsorshipTransferBuilder & 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