// This file is auto-generated. Do not edit. #pragma once #include #include #include #include #include #include #include #include namespace xrpl::transactions { class OracleSetBuilder; /** * @brief Transaction: OracleSet * * Type: ttORACLE_SET (51) * Delegable: Delegation::delegable * Amendment: featurePriceOracle * Privileges: noPriv * * Immutable wrapper around STTx providing type-safe field access. * Use OracleSetBuilder to construct new transactions. */ class OracleSet : public TransactionBase { public: static constexpr xrpl::TxType txType = ttORACLE_SET; /** * @brief Construct a OracleSet transaction wrapper from an existing STTx object. * @throws std::runtime_error if the transaction type doesn't match. */ explicit OracleSet(std::shared_ptr tx) : TransactionBase(std::move(tx)) { // Verify transaction type if (tx_->getTxnType() != txType) { throw std::runtime_error("Invalid transaction type for OracleSet"); } } // Transaction-specific field getters /** * @brief Get sfOracleDocumentID (soeREQUIRED) * @return The field value. */ [[nodiscard]] SF_UINT32::type::value_type getOracleDocumentID() const { return this->tx_->at(sfOracleDocumentID); } /** * @brief Get sfProvider (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getProvider() const { if (hasProvider()) { return this->tx_->at(sfProvider); } return std::nullopt; } /** * @brief Check if sfProvider is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasProvider() const { return this->tx_->isFieldPresent(sfProvider); } /** * @brief Get sfURI (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getURI() const { if (hasURI()) { return this->tx_->at(sfURI); } return std::nullopt; } /** * @brief Check if sfURI is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasURI() const { return this->tx_->isFieldPresent(sfURI); } /** * @brief Get sfAssetClass (soeOPTIONAL) * @return The field value, or std::nullopt if not present. */ [[nodiscard]] protocol_autogen::Optional getAssetClass() const { if (hasAssetClass()) { return this->tx_->at(sfAssetClass); } return std::nullopt; } /** * @brief Check if sfAssetClass is present. * @return True if the field is present, false otherwise. */ [[nodiscard]] bool hasAssetClass() const { return this->tx_->isFieldPresent(sfAssetClass); } /** * @brief Get sfLastUpdateTime (soeREQUIRED) * @return The field value. */ [[nodiscard]] SF_UINT32::type::value_type getLastUpdateTime() const { return this->tx_->at(sfLastUpdateTime); } /** * @brief Get sfPriceDataSeries (soeREQUIRED) * @note This is an untyped field. * @return The field value. */ [[nodiscard]] STArray const& getPriceDataSeries() const { return this->tx_->getFieldArray(sfPriceDataSeries); } }; /** * @brief Builder for OracleSet transactions. * * Provides a fluent interface for constructing transactions with method chaining. * Uses Json::Value internally for flexible transaction construction. * Inherits common field setters from TransactionBuilderBase. */ class OracleSetBuilder : public TransactionBuilderBase { public: /** * @brief Construct a new OracleSetBuilder with required fields. * @param account The account initiating the transaction. * @param oracleDocumentID The sfOracleDocumentID field value. * @param lastUpdateTime The sfLastUpdateTime field value. * @param priceDataSeries The sfPriceDataSeries field value. * @param sequence Optional sequence number for the transaction. * @param fee Optional fee for the transaction. */ OracleSetBuilder(SF_ACCOUNT::type::value_type account, std::decay_t const& oracleDocumentID, std::decay_t const& lastUpdateTime, STArray const& priceDataSeries, std::optional sequence = std::nullopt, std::optional fee = std::nullopt ) : TransactionBuilderBase(ttORACLE_SET, account, sequence, fee) { setOracleDocumentID(oracleDocumentID); setLastUpdateTime(lastUpdateTime); setPriceDataSeries(priceDataSeries); } /** * @brief Construct a OracleSetBuilder from an existing STTx object. * @param tx The existing transaction to copy from. * @throws std::runtime_error if the transaction type doesn't match. */ OracleSetBuilder(std::shared_ptr tx) { if (tx->getTxnType() != ttORACLE_SET) { throw std::runtime_error("Invalid transaction type for OracleSetBuilder"); } object_ = *tx; } /** @brief Transaction-specific field setters */ /** * @brief Set sfOracleDocumentID (soeREQUIRED) * @return Reference to this builder for method chaining. */ OracleSetBuilder& setOracleDocumentID(std::decay_t const& value) { object_[sfOracleDocumentID] = value; return *this; } /** * @brief Set sfProvider (soeOPTIONAL) * @return Reference to this builder for method chaining. */ OracleSetBuilder& setProvider(std::decay_t const& value) { object_[sfProvider] = value; return *this; } /** * @brief Set sfURI (soeOPTIONAL) * @return Reference to this builder for method chaining. */ OracleSetBuilder& setURI(std::decay_t const& value) { object_[sfURI] = value; return *this; } /** * @brief Set sfAssetClass (soeOPTIONAL) * @return Reference to this builder for method chaining. */ OracleSetBuilder& setAssetClass(std::decay_t const& value) { object_[sfAssetClass] = value; return *this; } /** * @brief Set sfLastUpdateTime (soeREQUIRED) * @return Reference to this builder for method chaining. */ OracleSetBuilder& setLastUpdateTime(std::decay_t const& value) { object_[sfLastUpdateTime] = value; return *this; } /** * @brief Set sfPriceDataSeries (soeREQUIRED) * @return Reference to this builder for method chaining. */ OracleSetBuilder& setPriceDataSeries(STArray const& value) { object_.setFieldArray(sfPriceDataSeries, value); return *this; } /** * @brief Build and return the OracleSet wrapper. * @param publicKey The public key for signing. * @param secretKey The secret key for signing. * @return The constructed transaction wrapper. */ OracleSet build(PublicKey const& publicKey, SecretKey const& secretKey) { sign(publicKey, secretKey); return OracleSet{std::make_shared(std::move(object_))}; } }; } // namespace xrpl::transactions