rippled
Loading...
Searching...
No Matches
protocol_autogen/transactions/OracleSet.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 OracleSetBuilder;
17
30{
31public:
32 static constexpr xrpl::TxType txType = ttORACLE_SET;
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 OracleSet");
45 }
46 }
47
48 // Transaction-specific field getters
49
54 [[nodiscard]]
55 SF_UINT32::type::value_type
57 {
58 return this->tx_->at(sfOracleDocumentID);
59 }
60
65 [[nodiscard]]
68 {
69 if (hasProvider())
70 {
71 return this->tx_->at(sfProvider);
72 }
73 return std::nullopt;
74 }
75
80 [[nodiscard]]
81 bool
83 {
84 return this->tx_->isFieldPresent(sfProvider);
85 }
86
91 [[nodiscard]]
93 getURI() const
94 {
95 if (hasURI())
96 {
97 return this->tx_->at(sfURI);
98 }
99 return std::nullopt;
100 }
101
106 [[nodiscard]]
107 bool
108 hasURI() const
109 {
110 return this->tx_->isFieldPresent(sfURI);
111 }
112
117 [[nodiscard]]
120 {
121 if (hasAssetClass())
122 {
123 return this->tx_->at(sfAssetClass);
124 }
125 return std::nullopt;
126 }
127
132 [[nodiscard]]
133 bool
135 {
136 return this->tx_->isFieldPresent(sfAssetClass);
137 }
138
143 [[nodiscard]]
144 SF_UINT32::type::value_type
146 {
147 return this->tx_->at(sfLastUpdateTime);
148 }
154 [[nodiscard]]
155 STArray const&
157 {
158 return this->tx_->getFieldArray(sfPriceDataSeries);
159 }
160};
161
169class OracleSetBuilder : public TransactionBuilderBase<OracleSetBuilder>
170{
171public:
181 OracleSetBuilder(SF_ACCOUNT::type::value_type account,
184)
185 : TransactionBuilderBase<OracleSetBuilder>(ttORACLE_SET, account, sequence, fee)
186 {
187 setOracleDocumentID(oracleDocumentID);
188 setLastUpdateTime(lastUpdateTime);
189 setPriceDataSeries(priceDataSeries);
190 }
191
198 {
199 if (tx->getTxnType() != ttORACLE_SET)
200 {
201 throw std::runtime_error("Invalid transaction type for OracleSetBuilder");
202 }
203 object_ = *tx;
204 }
205
214 {
215 object_[sfOracleDocumentID] = value;
216 return *this;
217 }
218
225 {
226 object_[sfProvider] = value;
227 return *this;
228 }
229
236 {
237 object_[sfURI] = value;
238 return *this;
239 }
240
247 {
248 object_[sfAssetClass] = value;
249 return *this;
250 }
251
258 {
259 object_[sfLastUpdateTime] = value;
260 return *this;
261 }
262
269 {
270 object_.setFieldArray(sfPriceDataSeries, value);
271 return *this;
272 }
273
281 build(PublicKey const& publicKey, SecretKey const& secretKey)
282 {
283 sign(publicKey, secretKey);
284 return OracleSet{std::make_shared<STTx>(std::move(object_))};
285 }
286};
287
288} // namespace xrpl::transactions
A public key.
Definition PublicKey.h:42
void setFieldArray(SField const &field, STArray const &v)
Definition STObject.cpp:819
A secret key.
Definition SecretKey.h:18
OracleSetBuilder & setAssetClass(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfAssetClass (soeOPTIONAL)
OracleSet build(PublicKey const &publicKey, SecretKey const &secretKey)
Build and return the OracleSet wrapper.
OracleSetBuilder(SF_ACCOUNT::type::value_type account, std::decay_t< typename SF_UINT32::type::value_type > const &oracleDocumentID, std::decay_t< typename SF_UINT32::type::value_type > const &lastUpdateTime, STArray const &priceDataSeries, std::optional< SF_UINT32::type::value_type > sequence=std::nullopt, std::optional< SF_AMOUNT::type::value_type > fee=std::nullopt)
Construct a new OracleSetBuilder with required fields.
OracleSetBuilder & setProvider(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfProvider (soeOPTIONAL)
OracleSetBuilder & setLastUpdateTime(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Set sfLastUpdateTime (soeREQUIRED)
OracleSetBuilder & setURI(std::decay_t< typename SF_VL::type::value_type > const &value)
Set sfURI (soeOPTIONAL)
OracleSetBuilder & setOracleDocumentID(std::decay_t< typename SF_UINT32::type::value_type > const &value)
Transaction-specific field setters.
OracleSetBuilder & setPriceDataSeries(STArray const &value)
Set sfPriceDataSeries (soeREQUIRED)
OracleSetBuilder(std::shared_ptr< STTx const > tx)
Construct a OracleSetBuilder from an existing STTx object.
bool hasProvider() const
Check if sfProvider is present.
STArray const & getPriceDataSeries() const
Get sfPriceDataSeries (soeREQUIRED)
OracleSet(std::shared_ptr< STTx const > tx)
Construct a OracleSet transaction wrapper from an existing STTx object.
SF_UINT32::type::value_type getLastUpdateTime() const
Get sfLastUpdateTime (soeREQUIRED)
SF_UINT32::type::value_type getOracleDocumentID() const
Get sfOracleDocumentID (soeREQUIRED)
bool hasAssetClass() const
Check if sfAssetClass is present.
protocol_autogen::Optional< SF_VL::type::value_type > getProvider() const
Get sfProvider (soeOPTIONAL)
bool hasURI() const
Check if sfURI is present.
protocol_autogen::Optional< SF_VL::type::value_type > getAssetClass() const
Get sfAssetClass (soeOPTIONAL)
protocol_autogen::Optional< SF_VL::type::value_type > getURI() const
Get sfURI (soeOPTIONAL)
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.
OracleSetBuilder & sign(PublicKey const &publicKey, SecretKey const &secretKey)
Sign the transaction with the given keys.
T is_same_v
STL namespace.
TxType
Transaction type identifiers.
Definition TxFormats.h:39