rippled
Loading...
Searching...
No Matches
Vault.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 VaultBuilder;
17
27class Vault : public LedgerEntryBase
28{
29public:
30 static constexpr LedgerEntryType entryType = ltVAULT;
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 Vault");
43 }
44 }
45
46 // Ledger entry-specific field getters
47
52 [[nodiscard]]
53 SF_UINT256::type::value_type
55 {
56 return this->sle_->at(sfPreviousTxnID);
57 }
58
63 [[nodiscard]]
64 SF_UINT32::type::value_type
66 {
67 return this->sle_->at(sfPreviousTxnLgrSeq);
68 }
69
74 [[nodiscard]]
75 SF_UINT32::type::value_type
77 {
78 return this->sle_->at(sfSequence);
79 }
80
85 [[nodiscard]]
86 SF_UINT64::type::value_type
88 {
89 return this->sle_->at(sfOwnerNode);
90 }
91
96 [[nodiscard]]
97 SF_ACCOUNT::type::value_type
98 getOwner() const
99 {
100 return this->sle_->at(sfOwner);
101 }
102
107 [[nodiscard]]
108 SF_ACCOUNT::type::value_type
110 {
111 return this->sle_->at(sfAccount);
112 }
113
118 [[nodiscard]]
120 getData() const
121 {
122 if (hasData())
123 return this->sle_->at(sfData);
124 return std::nullopt;
125 }
126
131 [[nodiscard]]
132 bool
133 hasData() const
134 {
135 return this->sle_->isFieldPresent(sfData);
136 }
137
142 [[nodiscard]]
143 SF_ISSUE::type::value_type
144 getAsset() const
145 {
146 return this->sle_->at(sfAsset);
147 }
148
153 [[nodiscard]]
156 {
157 if (hasAssetsTotal())
158 return this->sle_->at(sfAssetsTotal);
159 return std::nullopt;
160 }
161
166 [[nodiscard]]
167 bool
169 {
170 return this->sle_->isFieldPresent(sfAssetsTotal);
171 }
172
177 [[nodiscard]]
180 {
181 if (hasAssetsAvailable())
182 return this->sle_->at(sfAssetsAvailable);
183 return std::nullopt;
184 }
185
190 [[nodiscard]]
191 bool
193 {
194 return this->sle_->isFieldPresent(sfAssetsAvailable);
195 }
196
201 [[nodiscard]]
204 {
205 if (hasAssetsMaximum())
206 return this->sle_->at(sfAssetsMaximum);
207 return std::nullopt;
208 }
209
214 [[nodiscard]]
215 bool
217 {
218 return this->sle_->isFieldPresent(sfAssetsMaximum);
219 }
220
225 [[nodiscard]]
228 {
229 if (hasLossUnrealized())
230 return this->sle_->at(sfLossUnrealized);
231 return std::nullopt;
232 }
233
238 [[nodiscard]]
239 bool
241 {
242 return this->sle_->isFieldPresent(sfLossUnrealized);
243 }
244
249 [[nodiscard]]
250 SF_UINT192::type::value_type
252 {
253 return this->sle_->at(sfShareMPTID);
254 }
255
260 [[nodiscard]]
261 SF_UINT8::type::value_type
263 {
264 return this->sle_->at(sfWithdrawalPolicy);
265 }
266
271 [[nodiscard]]
273 getScale() const
274 {
275 if (hasScale())
276 return this->sle_->at(sfScale);
277 return std::nullopt;
278 }
279
284 [[nodiscard]]
285 bool
286 hasScale() const
287 {
288 return this->sle_->isFieldPresent(sfScale);
289 }
290};
291
299class VaultBuilder : public LedgerEntryBuilderBase<VaultBuilder>
300{
301public:
327
334 {
335 if (sle->at(sfLedgerEntryType) != ltVAULT)
336 {
337 throw std::runtime_error("Invalid ledger entry type for Vault");
338 }
339 object_ = *sle;
340 }
341
350 {
351 object_[sfPreviousTxnID] = value;
352 return *this;
353 }
354
361 {
362 object_[sfPreviousTxnLgrSeq] = value;
363 return *this;
364 }
365
372 {
373 object_[sfSequence] = value;
374 return *this;
375 }
376
383 {
384 object_[sfOwnerNode] = value;
385 return *this;
386 }
387
394 {
395 object_[sfOwner] = value;
396 return *this;
397 }
398
405 {
406 object_[sfAccount] = value;
407 return *this;
408 }
409
416 {
417 object_[sfData] = value;
418 return *this;
419 }
420
427 {
428 object_[sfAsset] = STIssue(sfAsset, value);
429 return *this;
430 }
431
438 {
439 object_[sfAssetsTotal] = value;
440 return *this;
441 }
442
449 {
450 object_[sfAssetsAvailable] = value;
451 return *this;
452 }
453
460 {
461 object_[sfAssetsMaximum] = value;
462 return *this;
463 }
464
471 {
472 object_[sfLossUnrealized] = value;
473 return *this;
474 }
475
482 {
483 object_[sfShareMPTID] = value;
484 return *this;
485 }
486
493 {
494 object_[sfWithdrawalPolicy] = value;
495 return *this;
496 }
497
504 {
505 object_[sfScale] = value;
506 return *this;
507 }
508
514 Vault
515 build(uint256 const& index)
516 {
517 return Vault{std::make_shared<SLE>(std::move(object_), index)};
518 }
519};
520
521} // namespace xrpl::ledger_entries
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.
Builder for Vault ledger entries.
Definition Vault.h:300
VaultBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (soeREQUIRED)
Definition Vault.h:360
VaultBuilder(std::decay_t< typename SF_UINT256::type::value_type > const &previousTxnID, std::decay_t< typename SF_UINT32::type::value_type > const &previousTxnLgrSeq, std::decay_t< typename SF_UINT32::type::value_type > const &sequence, std::decay_t< typename SF_UINT64::type::value_type > const &ownerNode, std::decay_t< typename SF_ACCOUNT::type::value_type > const &owner, std::decay_t< typename SF_ACCOUNT::type::value_type > const &account, std::decay_t< typename SF_ISSUE::type::value_type > const &asset, std::decay_t< typename SF_UINT192::type::value_type > const &shareMPTID, std::decay_t< typename SF_UINT8::type::value_type > const &withdrawalPolicy)
Construct a new VaultBuilder with required fields.
Definition Vault.h:314
VaultBuilder(std::shared_ptr< SLE const > sle)
Construct a VaultBuilder from an existing SLE object.
Definition Vault.h:333
VaultBuilder & setOwner(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfOwner (soeREQUIRED)
Definition Vault.h:393
VaultBuilder & setSequence(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSequence (soeREQUIRED)
Definition Vault.h:371
VaultBuilder & setAssetsAvailable(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsAvailable (soeDEFAULT)
Definition Vault.h:448
VaultBuilder & setWithdrawalPolicy(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfWithdrawalPolicy (soeREQUIRED)
Definition Vault.h:492
VaultBuilder & setScale(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfScale (soeDEFAULT)
Definition Vault.h:503
VaultBuilder & setAssetsTotal(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsTotal (soeDEFAULT)
Definition Vault.h:437
VaultBuilder & setShareMPTID(std::decay_t< typename SF_UINT192::type::value_type > const &value)
Set sfShareMPTID (soeREQUIRED)
Definition Vault.h:481
VaultBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (soeREQUIRED)
Definition Vault.h:382
VaultBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset (soeREQUIRED)
Definition Vault.h:426
Vault build(uint256 const &index)
Build and return the completed Vault wrapper.
Definition Vault.h:515
VaultBuilder & setLossUnrealized(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfLossUnrealized (soeDEFAULT)
Definition Vault.h:470
VaultBuilder & setData(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfData (soeOPTIONAL)
Definition Vault.h:415
VaultBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Ledger entry-specific field setters.
Definition Vault.h:349
VaultBuilder & setAssetsMaximum(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsMaximum (soeDEFAULT)
Definition Vault.h:459
VaultBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfAccount (soeREQUIRED)
Definition Vault.h:404
Ledger Entry: Vault.
Definition Vault.h:28
bool hasAssetsTotal() const
Check if sfAssetsTotal is present.
Definition Vault.h:168
protocol_autogen::Optional< SF_NUMBER::type::value_type > getAssetsMaximum() const
Get sfAssetsMaximum (soeDEFAULT)
Definition Vault.h:203
bool hasAssetsAvailable() const
Check if sfAssetsAvailable is present.
Definition Vault.h:192
bool hasScale() const
Check if sfScale is present.
Definition Vault.h:286
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (soeREQUIRED)
Definition Vault.h:144
protocol_autogen::Optional< SF_VL::type::value_type > getData() const
Get sfData (soeOPTIONAL)
Definition Vault.h:120
SF_UINT32::type::value_type getPreviousTxnLgrSeq() const
Get sfPreviousTxnLgrSeq (soeREQUIRED)
Definition Vault.h:65
SF_ACCOUNT::type::value_type getOwner() const
Get sfOwner (soeREQUIRED)
Definition Vault.h:98
protocol_autogen::Optional< SF_NUMBER::type::value_type > getLossUnrealized() const
Get sfLossUnrealized (soeDEFAULT)
Definition Vault.h:227
static constexpr LedgerEntryType entryType
Definition Vault.h:30
protocol_autogen::Optional< SF_NUMBER::type::value_type > getAssetsAvailable() const
Get sfAssetsAvailable (soeDEFAULT)
Definition Vault.h:179
bool hasData() const
Check if sfData is present.
Definition Vault.h:133
protocol_autogen::Optional< SF_UINT8::type::value_type > getScale() const
Get sfScale (soeDEFAULT)
Definition Vault.h:273
SF_UINT192::type::value_type getShareMPTID() const
Get sfShareMPTID (soeREQUIRED)
Definition Vault.h:251
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (soeREQUIRED)
Definition Vault.h:54
bool hasAssetsMaximum() const
Check if sfAssetsMaximum is present.
Definition Vault.h:216
SF_UINT8::type::value_type getWithdrawalPolicy() const
Get sfWithdrawalPolicy (soeREQUIRED)
Definition Vault.h:262
protocol_autogen::Optional< SF_NUMBER::type::value_type > getAssetsTotal() const
Get sfAssetsTotal (soeDEFAULT)
Definition Vault.h:155
Vault(std::shared_ptr< SLE const > sle)
Construct a Vault ledger entry wrapper from an existing SLE object.
Definition Vault.h:36
SF_UINT64::type::value_type getOwnerNode() const
Get sfOwnerNode (soeREQUIRED)
Definition Vault.h:87
SF_UINT32::type::value_type getSequence() const
Get sfSequence (soeREQUIRED)
Definition Vault.h:76
bool hasLossUnrealized() const
Check if sfLossUnrealized is present.
Definition Vault.h:240
SF_ACCOUNT::type::value_type getAccount() const
Get sfAccount (soeREQUIRED)
Definition Vault.h:109
T is_same_v
STL namespace.
LedgerEntryType
Identifiers for on-ledger objects.