rippled
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
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
213 {
214 object_[sfAccount] = value;
215 return *this;
216 }
217
224 {
225 object_[sfDIDDocument] = value;
226 return *this;
227 }
228
235 {
236 object_[sfURI] = value;
237 return *this;
238 }
239
246 {
247 object_[sfData] = value;
248 return *this;
249 }
250
257 {
258 object_[sfOwnerNode] = value;
259 return *this;
260 }
261
268 {
269 object_[sfPreviousTxnID] = value;
270 return *this;
271 }
272
279 {
280 object_[sfPreviousTxnLgrSeq] = value;
281 return *this;
282 }
283
289 DID
290 build(uint256 const& index)
291 {
292 return DID{std::make_shared<SLE>(std::move(object_), index)};
293 }
294};
295
296} // namespace xrpl::ledger_entries
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:234
DIDBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (soeREQUIRED)
Definition DID.h:256
DIDBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (soeREQUIRED)
Definition DID.h:278
DIDBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfPreviousTxnID (soeREQUIRED)
Definition DID.h:267
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:245
DIDBuilder & setDIDDocument(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfDIDDocument (soeOPTIONAL)
Definition DID.h:223
DID build(uint256 const &index)
Build and return the completed DID wrapper.
Definition DID.h:290
DIDBuilder(std::shared_ptr< SLE const > sle)
Construct a DIDBuilder from an existing SLE object.
Definition DID.h:196
DIDBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Ledger entry-specific field setters.
Definition DID.h:212
Ledger Entry: DID.
Definition DID.h:28
DID(std::shared_ptr< SLE const > sle)
Construct a DID ledger entry wrapper from an existing SLE object.
Definition DID.h:36
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
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
Base class for type-safe ledger entry wrappers.
std::shared_ptr< SLE const > sle_
The underlying serialized ledger entry being wrapped.
Base class for all ledger entry builders.
T is_same_v
STL namespace.
LedgerEntryType
Identifiers for on-ledger objects.