xrpld
Loading...
Searching...
No Matches
DID.h
1// This file is auto-generated. Do not edit.
2#pragma once
3
4#include <xrpl/protocol/STLedgerEntry.h>
5#include <xrpl/protocol/STParsedJSON.h>
6#include <xrpl/protocol/jss.h>
7#include <xrpl/protocol_autogen/LedgerEntryBase.h>
8#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
9#include <xrpl/json/json_value.h>
10
11#include <stdexcept>
12#include <optional>
13
14namespace xrpl::ledger_entries {
15
16class DIDBuilder;
17
27class DID : public LedgerEntryBase
28{
29public:
30 static constexpr LedgerEntryType entryType = ltDID;
31
36 explicit DID(SLE::const_pointer sle)
37 : LedgerEntryBase(std::move(sle))
38 {
39 // Verify ledger entry type
40 if (sle_->getType() != entryType)
41 {
42 throw std::runtime_error("Invalid ledger entry type for DID");
43 }
44 }
45
46 // Ledger entry-specific field getters
47
52 [[nodiscard]]
53 SF_ACCOUNT::type::value_type
54 getAccount() const
55 {
56 return this->sle_->at(sfAccount);
57 }
58
63 [[nodiscard]]
66 {
67 if (hasDIDDocument())
68 return this->sle_->at(sfDIDDocument);
69 return std::nullopt;
70 }
71
76 [[nodiscard]]
77 bool
79 {
80 return this->sle_->isFieldPresent(sfDIDDocument);
81 }
82
87 [[nodiscard]]
89 getURI() const
90 {
91 if (hasURI())
92 return this->sle_->at(sfURI);
93 return std::nullopt;
94 }
95
100 [[nodiscard]]
101 bool
102 hasURI() const
103 {
104 return this->sle_->isFieldPresent(sfURI);
105 }
106
111 [[nodiscard]]
113 getData() const
114 {
115 if (hasData())
116 return this->sle_->at(sfData);
117 return std::nullopt;
118 }
119
124 [[nodiscard]]
125 bool
126 hasData() const
127 {
128 return this->sle_->isFieldPresent(sfData);
129 }
130
135 [[nodiscard]]
136 SF_UINT64::type::value_type
138 {
139 return this->sle_->at(sfOwnerNode);
140 }
141
146 [[nodiscard]]
147 SF_UINT256::type::value_type
149 {
150 return this->sle_->at(sfPreviousTxnID);
151 }
152
157 [[nodiscard]]
158 SF_UINT32::type::value_type
160 {
161 return this->sle_->at(sfPreviousTxnLgrSeq);
162 }
163};
164
172class DIDBuilder : public LedgerEntryBuilderBase<DIDBuilder>
173{
174public:
190
197 {
198 if (sle->at(sfLedgerEntryType) != ltDID)
199 {
200 throw std::runtime_error("Invalid ledger entry type for DID");
201 }
202 object_ = *sle;
203 }
204
208
215 {
216 object_[sfAccount] = value;
217 return *this;
218 }
219
226 {
227 object_[sfDIDDocument] = value;
228 return *this;
229 }
230
237 {
238 object_[sfURI] = value;
239 return *this;
240 }
241
248 {
249 object_[sfData] = value;
250 return *this;
251 }
252
259 {
260 object_[sfOwnerNode] = value;
261 return *this;
262 }
263
270 {
271 object_[sfPreviousTxnID] = value;
272 return *this;
273 }
274
281 {
282 object_[sfPreviousTxnLgrSeq] = value;
283 return *this;
284 }
285
291 DID
292 build(uint256 const& index)
293 {
294 return DID{std::make_shared<SLE>(std::move(object_), index)};
295 }
296};
297
298} // namespace xrpl::ledger_entries
std::shared_ptr< STLedgerEntry const > const_pointer
Builder for DID ledger entries.
Definition DID.h:173
DIDBuilder & setURI(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfURI (SoeOptional).
Definition DID.h:236
DIDBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (SoeRequired).
Definition DID.h:258
DIDBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (SoeRequired).
Definition DID.h:280
DIDBuilder(SLE::const_pointer sle)
Construct a DIDBuilder from an existing SLE object.
Definition DID.h:196
DIDBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfPreviousTxnID (SoeRequired).
Definition DID.h:269
DIDBuilder(std::decay_t< typename SF_ACCOUNT::type::value_type > const &account, std::decay_t< typename SF_UINT64::type::value_type > const &ownerNode, std::decay_t< typename SF_UINT256::type::value_type > const &previousTxnID, std::decay_t< typename SF_UINT32::type::value_type > const &previousTxnLgrSeq)
Construct a new DIDBuilder with required fields.
Definition DID.h:182
DIDBuilder & setData(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfData (SoeOptional).
Definition DID.h:247
DIDBuilder & setDIDDocument(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfDIDDocument (SoeOptional).
Definition DID.h:225
DID build(uint256 const &index)
Build and return the completed DID wrapper.
Definition DID.h:292
DIDBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Ledger entry-specific field setters.
Definition DID.h:214
Ledger Entry: DID.
Definition DID.h:28
SF_ACCOUNT::type::value_type getAccount() const
Get sfAccount (SoeRequired).
Definition DID.h:54
static constexpr LedgerEntryType entryType
Definition DID.h:30
protocol_autogen::Optional< SF_VL::type::value_type > getURI() const
Get sfURI (SoeOptional).
Definition DID.h:89
bool hasData() const
Check if sfData is present.
Definition DID.h:126
protocol_autogen::Optional< SF_VL::type::value_type > getDIDDocument() const
Get sfDIDDocument (SoeOptional).
Definition DID.h:65
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (SoeRequired).
Definition DID.h:148
bool hasDIDDocument() const
Check if sfDIDDocument is present.
Definition DID.h:78
DID(SLE::const_pointer sle)
Construct a DID ledger entry wrapper from an existing SLE object.
Definition DID.h:36
SF_UINT32::type::value_type getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (SoeRequired).
Definition DID.h:159
bool hasURI() const
Check if sfURI is present.
Definition DID.h:102
SF_UINT64::type::value_type getOwnerNode() const
Get sfOwnerNode (SoeRequired).
Definition DID.h:137
protocol_autogen::Optional< SF_VL::type::value_type > getData() const
Get sfData (SoeOptional).
Definition DID.h:113
LedgerEntryBase(SLE::const_pointer sle)
Construct a ledger entry wrapper from an existing SLE object.
SLE::const_pointer sle_
The underlying serialized ledger entry being wrapped.
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
LedgerEntryType
Identifiers for on-ledger objects.
BaseUInt< 256 > uint256
Definition base_uint.h:580