xrpld
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]]
252 {
253 if (hasYieldUnrealized())
254 return this->sle_->at(sfYieldUnrealized);
255 return std::nullopt;
256 }
257
262 [[nodiscard]]
263 bool
265 {
266 return this->sle_->isFieldPresent(sfYieldUnrealized);
267 }
268
273 [[nodiscard]]
276 {
277 if (hasAssetsDeployed())
278 return this->sle_->at(sfAssetsDeployed);
279 return std::nullopt;
280 }
281
286 [[nodiscard]]
287 bool
289 {
290 return this->sle_->isFieldPresent(sfAssetsDeployed);
291 }
292
297 [[nodiscard]]
298 SF_UINT192::type::value_type
300 {
301 return this->sle_->at(sfShareMPTID);
302 }
303
308 [[nodiscard]]
309 SF_UINT8::type::value_type
311 {
312 return this->sle_->at(sfWithdrawalPolicy);
313 }
314
319 [[nodiscard]]
321 getScale() const
322 {
323 if (hasScale())
324 return this->sle_->at(sfScale);
325 return std::nullopt;
326 }
327
332 [[nodiscard]]
333 bool
334 hasScale() const
335 {
336 return this->sle_->isFieldPresent(sfScale);
337 }
338
343 [[nodiscard]]
346 {
347 if (hasLEVersion())
348 return this->sle_->at(sfLEVersion);
349 return std::nullopt;
350 }
351
356 [[nodiscard]]
357 bool
359 {
360 return this->sle_->isFieldPresent(sfLEVersion);
361 }
362
367 [[nodiscard]]
370 {
371 if (hasVaultKind())
372 return this->sle_->at(sfVaultKind);
373 return std::nullopt;
374 }
375
380 [[nodiscard]]
381 bool
383 {
384 return this->sle_->isFieldPresent(sfVaultKind);
385 }
386
391 [[nodiscard]]
394 {
396 return this->sle_->at(sfSubscriptionDate);
397 return std::nullopt;
398 }
399
404 [[nodiscard]]
405 bool
407 {
408 return this->sle_->isFieldPresent(sfSubscriptionDate);
409 }
410
415 [[nodiscard]]
418 {
419 if (hasRedemptionDate())
420 return this->sle_->at(sfRedemptionDate);
421 return std::nullopt;
422 }
423
428 [[nodiscard]]
429 bool
431 {
432 return this->sle_->isFieldPresent(sfRedemptionDate);
433 }
434};
435
443class VaultBuilder : public LedgerEntryBuilderBase<VaultBuilder>
444{
445public:
471
478 {
479 if (sle->at(sfLedgerEntryType) != ltVAULT)
480 {
481 throw std::runtime_error("Invalid ledger entry type for Vault");
482 }
483 object_ = *sle;
484 }
485
489
496 {
497 object_[sfPreviousTxnID] = value;
498 return *this;
499 }
500
507 {
508 object_[sfPreviousTxnLgrSeq] = value;
509 return *this;
510 }
511
518 {
519 object_[sfSequence] = value;
520 return *this;
521 }
522
529 {
530 object_[sfOwnerNode] = value;
531 return *this;
532 }
533
540 {
541 object_[sfOwner] = value;
542 return *this;
543 }
544
551 {
552 object_[sfAccount] = value;
553 return *this;
554 }
555
562 {
563 object_[sfData] = value;
564 return *this;
565 }
566
573 {
574 object_[sfAsset] = STIssue(sfAsset, value);
575 return *this;
576 }
577
584 {
585 object_[sfAssetsTotal] = value;
586 return *this;
587 }
588
595 {
596 object_[sfAssetsAvailable] = value;
597 return *this;
598 }
599
606 {
607 object_[sfAssetsMaximum] = value;
608 return *this;
609 }
610
617 {
618 object_[sfLossUnrealized] = value;
619 return *this;
620 }
621
628 {
629 object_[sfYieldUnrealized] = value;
630 return *this;
631 }
632
639 {
640 object_[sfAssetsDeployed] = value;
641 return *this;
642 }
643
650 {
651 object_[sfShareMPTID] = value;
652 return *this;
653 }
654
661 {
662 object_[sfWithdrawalPolicy] = value;
663 return *this;
664 }
665
672 {
673 object_[sfScale] = value;
674 return *this;
675 }
676
683 {
684 object_[sfLEVersion] = value;
685 return *this;
686 }
687
694 {
695 object_[sfVaultKind] = value;
696 return *this;
697 }
698
705 {
706 object_[sfSubscriptionDate] = value;
707 return *this;
708 }
709
716 {
717 object_[sfRedemptionDate] = value;
718 return *this;
719 }
720
726 Vault
727 build(UInt256 const& index)
728 {
729 return Vault{std::make_shared<SLE>(std::move(object_), index)};
730 }
731};
732
733} // namespace xrpl::ledger_entries
std::shared_ptr< STLedgerEntry const > const_pointer
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.
Builder for Vault ledger entries.
Definition Vault.h:444
VaultBuilder & setPreviousTxnLgrSeq(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfPreviousTxnLgrSeq (SoeRequired).
Definition Vault.h:506
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:458
VaultBuilder & setVaultKind(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfVaultKind (SoeDefault).
Definition Vault.h:693
VaultBuilder & setOwner(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfOwner (SoeRequired).
Definition Vault.h:539
VaultBuilder & setSequence(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSequence (SoeRequired).
Definition Vault.h:517
VaultBuilder & setAssetsAvailable(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsAvailable (SoeDefault).
Definition Vault.h:594
VaultBuilder & setWithdrawalPolicy(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfWithdrawalPolicy (SoeRequired).
Definition Vault.h:660
VaultBuilder & setRedemptionDate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfRedemptionDate (SoeOptional).
Definition Vault.h:715
VaultBuilder & setAssetsDeployed(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsDeployed (SoeDefault).
Definition Vault.h:638
VaultBuilder & setScale(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfScale (SoeDefault).
Definition Vault.h:671
VaultBuilder & setAssetsTotal(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsTotal (SoeDefault).
Definition Vault.h:583
VaultBuilder & setShareMPTID(std::decay_t< typename SF_UINT192::type::value_type > const &value)
Set sfShareMPTID (SoeRequired).
Definition Vault.h:649
VaultBuilder & setOwnerNode(std::decay_t< typename SF_UINT64::type::value_type > const &value)
Set sfOwnerNode (SoeRequired).
Definition Vault.h:528
VaultBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Set sfAsset (SoeRequired).
Definition Vault.h:572
Vault build(UInt256 const &index)
Build and return the completed Vault wrapper.
Definition Vault.h:727
VaultBuilder & setSubscriptionDate(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfSubscriptionDate (SoeOptional).
Definition Vault.h:704
VaultBuilder(SLE::const_pointer sle)
Construct a VaultBuilder from an existing SLE object.
Definition Vault.h:477
VaultBuilder & setLossUnrealized(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfLossUnrealized (SoeDefault).
Definition Vault.h:616
VaultBuilder & setData(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfData (SoeOptional).
Definition Vault.h:561
VaultBuilder & setPreviousTxnID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Ledger entry-specific field setters.
Definition Vault.h:495
VaultBuilder & setLEVersion(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfLEVersion (SoeDefault).
Definition Vault.h:682
VaultBuilder & setAssetsMaximum(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsMaximum (SoeDefault).
Definition Vault.h:605
VaultBuilder & setYieldUnrealized(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfYieldUnrealized (SoeDefault).
Definition Vault.h:627
VaultBuilder & setAccount(std::decay_t< typename SF_ACCOUNT::type::value_type > const &value)
Set sfAccount (SoeRequired).
Definition Vault.h:550
Ledger Entry: Vault.
Definition Vault.h:28
bool hasAssetsDeployed() const
Check if sfAssetsDeployed is present.
Definition Vault.h:288
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 hasVaultKind() const
Check if sfVaultKind is present.
Definition Vault.h:382
bool hasAssetsAvailable() const
Check if sfAssetsAvailable is present.
Definition Vault.h:192
bool hasScale() const
Check if sfScale is present.
Definition Vault.h:334
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (SoeRequired).
Definition Vault.h:144
Vault(SLE::const_pointer sle)
Construct a Vault ledger entry wrapper from an existing SLE object.
Definition Vault.h:36
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
protocol_autogen::Optional< SF_UINT8::type::value_type > getLEVersion() const
Get sfLEVersion (SoeDefault).
Definition Vault.h:345
protocol_autogen::Optional< SF_NUMBER::type::value_type > getYieldUnrealized() const
Get sfYieldUnrealized (SoeDefault).
Definition Vault.h:251
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:321
SF_UINT192::type::value_type getShareMPTID() const
Get sfShareMPTID (SoeRequired).
Definition Vault.h:299
bool hasRedemptionDate() const
Check if sfRedemptionDate is present.
Definition Vault.h:430
SF_UINT256::type::value_type getPreviousTxnID() const
Get sfPreviousTxnID (SoeRequired).
Definition Vault.h:54
protocol_autogen::Optional< SF_NUMBER::type::value_type > getAssetsDeployed() const
Get sfAssetsDeployed (SoeDefault).
Definition Vault.h:275
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:310
protocol_autogen::Optional< SF_NUMBER::type::value_type > getAssetsTotal() const
Get sfAssetsTotal (SoeDefault).
Definition Vault.h:155
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
protocol_autogen::Optional< SF_UINT32::type::value_type > getRedemptionDate() const
Get sfRedemptionDate (SoeOptional).
Definition Vault.h:417
SF_ACCOUNT::type::value_type getAccount() const
Get sfAccount (SoeRequired).
Definition Vault.h:109
protocol_autogen::Optional< SF_UINT32::type::value_type > getSubscriptionDate() const
Get sfSubscriptionDate (SoeOptional).
Definition Vault.h:393
protocol_autogen::Optional< SF_UINT8::type::value_type > getVaultKind() const
Get sfVaultKind (SoeDefault).
Definition Vault.h:369
bool hasSubscriptionDate() const
Check if sfSubscriptionDate is present.
Definition Vault.h:406
bool hasYieldUnrealized() const
Check if sfYieldUnrealized is present.
Definition Vault.h:264
bool hasLEVersion() const
Check if sfLEVersion is present.
Definition Vault.h:358
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
BaseUInt< 256 > UInt256
Definition base_uint.h:581
LedgerEntryType
Identifiers for on-ledger objects.