rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/VaultCreate.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 VaultCreateBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttVAULT_CREATE;
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 VaultCreate");
45 }
46 }
47
48 // Transaction-specific field getters
49
55 [[nodiscard]]
56 SF_ISSUE::type::value_type
57 getAsset() const
58 {
59 return this->tx_->at(sfAsset);
60 }
61
66 [[nodiscard]]
69 {
70 if (hasAssetsMaximum())
71 {
72 return this->tx_->at(sfAssetsMaximum);
73 }
74 return std::nullopt;
75 }
76
81 [[nodiscard]]
82 bool
84 {
85 return this->tx_->isFieldPresent(sfAssetsMaximum);
86 }
87
92 [[nodiscard]]
95 {
97 {
98 return this->tx_->at(sfMPTokenMetadata);
99 }
100 return std::nullopt;
101 }
102
107 [[nodiscard]]
108 bool
110 {
111 return this->tx_->isFieldPresent(sfMPTokenMetadata);
112 }
113
118 [[nodiscard]]
121 {
122 if (hasDomainID())
123 {
124 return this->tx_->at(sfDomainID);
125 }
126 return std::nullopt;
127 }
128
133 [[nodiscard]]
134 bool
136 {
137 return this->tx_->isFieldPresent(sfDomainID);
138 }
139
144 [[nodiscard]]
147 {
149 {
150 return this->tx_->at(sfWithdrawalPolicy);
151 }
152 return std::nullopt;
153 }
154
159 [[nodiscard]]
160 bool
162 {
163 return this->tx_->isFieldPresent(sfWithdrawalPolicy);
164 }
165
170 [[nodiscard]]
172 getData() const
173 {
174 if (hasData())
175 {
176 return this->tx_->at(sfData);
177 }
178 return std::nullopt;
179 }
180
185 [[nodiscard]]
186 bool
187 hasData() const
188 {
189 return this->tx_->isFieldPresent(sfData);
190 }
191
196 [[nodiscard]]
198 getScale() const
199 {
200 if (hasScale())
201 {
202 return this->tx_->at(sfScale);
203 }
204 return std::nullopt;
205 }
206
211 [[nodiscard]]
212 bool
213 hasScale() const
214 {
215 return this->tx_->isFieldPresent(sfScale);
216 }
217};
218
226class VaultCreateBuilder : public TransactionBuilderBase<VaultCreateBuilder>
227{
228public:
236 VaultCreateBuilder(SF_ACCOUNT::type::value_type account,
239)
240 : TransactionBuilderBase<VaultCreateBuilder>(ttVAULT_CREATE, account, sequence, fee)
241 {
242 setAsset(asset);
243 }
244
251 {
252 if (tx->getTxnType() != ttVAULT_CREATE)
253 {
254 throw std::runtime_error("Invalid transaction type for VaultCreateBuilder");
255 }
256 object_ = *tx;
257 }
258
268 {
269 object_[sfAsset] = STIssue(sfAsset, value);
270 return *this;
271 }
272
279 {
280 object_[sfAssetsMaximum] = value;
281 return *this;
282 }
283
290 {
291 object_[sfMPTokenMetadata] = value;
292 return *this;
293 }
294
301 {
302 object_[sfDomainID] = value;
303 return *this;
304 }
305
312 {
313 object_[sfWithdrawalPolicy] = value;
314 return *this;
315 }
316
323 {
324 object_[sfData] = value;
325 return *this;
326 }
327
334 {
335 object_[sfScale] = value;
336 return *this;
337 }
338
346 build(PublicKey const& publicKey, SecretKey const& secretKey)
347 {
348 sign(publicKey, secretKey);
349 return VaultCreate{std::make_shared<STTx>(std::move(object_))};
350 }
351};
352
353} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
A secret key.
Definition SecretKey.h:18
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.
VaultCreateBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
VaultCreateBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_ISSUE::type::value_type > const &asset, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new VaultCreateBuilder with required fields.
VaultCreateBuilder & setWithdrawalPolicy(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfWithdrawalPolicy (soeOPTIONAL)
VaultCreateBuilder & setDomainID(std::decay_t< typename SF_UINT256::type::value_type > const &value)
Set sfDomainID (soeOPTIONAL)
VaultCreateBuilder & setMPTokenMetadata(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfMPTokenMetadata (soeOPTIONAL)
VaultCreateBuilder(std::shared_ptr< STTx const > tx)
Construct a VaultCreateBuilder from an existing STTx object.
VaultCreateBuilder & setData(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfData (soeOPTIONAL)
VaultCreate build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the VaultCreate wrapper.
VaultCreateBuilder & setScale(std::decay_t< typename SF_UINT8::type::value_type > const &value)
Set sfScale (soeOPTIONAL)
VaultCreateBuilder & setAssetsMaximum(std::decay_t< typename SF_NUMBER::type::value_type > const &value)
Set sfAssetsMaximum (soeOPTIONAL)
VaultCreateBuilder & setAsset(std::decay_t< typename SF_ISSUE::type::value_type > const &value)
Transaction-specific field setters.
bool hasAssetsMaximum() const
Check if sfAssetsMaximum is present.
protocol_autogen::Optional< SF_UINT256::type::value_type > getDomainID() const
Get sfDomainID (soeOPTIONAL)
bool hasMPTokenMetadata() const
Check if sfMPTokenMetadata is present.
bool hasData() const
Check if sfData is present.
bool hasScale() const
Check if sfScale is present.
protocol_autogen::Optional< SF_VL::type::value_type > getMPTokenMetadata() const
Get sfMPTokenMetadata (soeOPTIONAL)
bool hasDomainID() const
Check if sfDomainID is present.
protocol_autogen::Optional< SF_VL::type::value_type > getData() const
Get sfData (soeOPTIONAL)
protocol_autogen::Optional< SF_UINT8::type::value_type > getWithdrawalPolicy() const
Get sfWithdrawalPolicy (soeOPTIONAL)
SF_ISSUE::type::value_type getAsset() const
Get sfAsset (soeREQUIRED)
bool hasWithdrawalPolicy() const
Check if sfWithdrawalPolicy is present.
protocol_autogen::Optional< SF_UINT8::type::value_type > getScale() const
Get sfScale (soeOPTIONAL)
VaultCreate(std::shared_ptr< STTx const > tx)
Construct a VaultCreate transaction wrapper from an existing STTx object.
protocol_autogen::Optional< SF_NUMBER::type::value_type > getAssetsMaximum() const
Get sfAssetsMaximum (soeOPTIONAL)
T is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39