rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/DIDSet.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 DIDSetBuilder;
17
29class DIDSet : public TransactionBase
30{
31public:
32 static constexpr xrpl::TxType txType = ttDID_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 DIDSet");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
57 {
58 if (hasDIDDocument())
59 {
60 return this->tx_->at(sfDIDDocument);
61 }
62 return std::nullopt;
63 }
64
69 [[nodiscard]]
70 bool
72 {
73 return this->tx_->isFieldPresent(sfDIDDocument);
74 }
75
80 [[nodiscard]]
82 getURI() const
83 {
84 if (hasURI())
85 {
86 return this->tx_->at(sfURI);
87 }
88 return std::nullopt;
89 }
90
95 [[nodiscard]]
96 bool
97 hasURI() const
98 {
99 return this->tx_->isFieldPresent(sfURI);
100 }
101
106 [[nodiscard]]
108 getData() const
109 {
110 if (hasData())
111 {
112 return this->tx_->at(sfData);
113 }
114 return std::nullopt;
115 }
116
121 [[nodiscard]]
122 bool
123 hasData() const
124 {
125 return this->tx_->isFieldPresent(sfData);
126 }
127};
128
136class DIDSetBuilder : public TransactionBuilderBase<DIDSetBuilder>
137{
138public:
145 DIDSetBuilder(SF_ACCOUNT::type::value_type account,
148)
149 : TransactionBuilderBase<DIDSetBuilder>(ttDID_SET, account, sequence, fee)
150 {
151 }
152
159 {
160 if (tx->getTxnType() != ttDID_SET)
161 {
162 throw std::runtime_error("Invalid transaction type for DIDSetBuilder");
163 }
164 object_ = *tx;
165 }
166
175 {
176 object_[sfDIDDocument] = value;
177 return *this;
178 }
179
186 {
187 object_[sfURI] = value;
188 return *this;
189 }
190
197 {
198 object_[sfData] = value;
199 return *this;
200 }
201
208 DIDSet
209 build(PublicKey const& publicKey, SecretKey const& secretKey)
210 {
211 sign(publicKey, secretKey);
212 return DIDSet{std::make_shared<STTx>(std::move(object_))};
213 }
214};
215
216} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
DIDSetBuilder & setDIDDocument(std::decay_t< typename SF_VL::type::value_type > const &value)
Transaction-specific field setters.
DIDSetBuilder(std::shared_ptr< STTx const > tx)
Construct a DIDSetBuilder from an existing STTx object.
DIDSetBuilder(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 DIDSetBuilder with required fields.
DIDSetBuilder & setData(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfData (soeOPTIONAL)
DIDSetBuilder & setURI(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfURI (soeOPTIONAL)
DIDSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the DIDSet wrapper.
DIDSet(std::shared_ptr< STTx const > tx)
Construct a DIDSet transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_VL::type::value_type > getData() const
Get sfData (soeOPTIONAL)
protocol_autogen::Optional< SF_VL::type::value_type > getDIDDocument() const
Get sfDIDDocument (soeOPTIONAL)
protocol_autogen::Optional< SF_VL::type::value_type > getURI() const
Get sfURI (soeOPTIONAL)
bool hasDIDDocument() const
Check if sfDIDDocument is present.
bool hasData() const
Check if sfData is present.
bool hasURI() const
Check if sfURI is present.
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.
DIDSetBuilder & 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