mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Signed-off-by: JCW <a1q123456@users.noreply.github.com> Co-authored-by: Bart <bthomee@users.noreply.github.com>
286 lines
7.8 KiB
C++
286 lines
7.8 KiB
C++
// This file is auto-generated. Do not edit.
|
|
#pragma once
|
|
|
|
#include <xrpl/protocol/STLedgerEntry.h>
|
|
#include <xrpl/protocol/STParsedJSON.h>
|
|
#include <xrpl/protocol/jss.h>
|
|
#include <xrpl/protocol_autogen/LedgerEntryBase.h>
|
|
#include <xrpl/protocol_autogen/LedgerEntryBuilderBase.h>
|
|
#include <xrpl/json/json_value.h>
|
|
|
|
#include <stdexcept>
|
|
#include <optional>
|
|
|
|
namespace xrpl::ledger_entries {
|
|
|
|
class MPTokenBuilder;
|
|
|
|
/**
|
|
* @brief Ledger Entry: MPToken
|
|
*
|
|
* Type: ltMPTOKEN (0x007f)
|
|
* RPC Name: mptoken
|
|
*
|
|
* Immutable wrapper around SLE providing type-safe field access.
|
|
* Use MPTokenBuilder to construct new ledger entries.
|
|
*/
|
|
class MPToken : public LedgerEntryBase
|
|
{
|
|
public:
|
|
static constexpr LedgerEntryType entryType = ltMPTOKEN;
|
|
|
|
/**
|
|
* @brief Construct a MPToken ledger entry wrapper from an existing SLE object.
|
|
* @throws std::runtime_error if the ledger entry type doesn't match.
|
|
*/
|
|
explicit MPToken(std::shared_ptr<SLE const> sle)
|
|
: LedgerEntryBase(std::move(sle))
|
|
{
|
|
// Verify ledger entry type
|
|
if (sle_->getType() != entryType)
|
|
{
|
|
throw std::runtime_error("Invalid ledger entry type for MPToken");
|
|
}
|
|
}
|
|
|
|
// Ledger entry-specific field getters
|
|
|
|
/**
|
|
* @brief Get sfAccount (soeREQUIRED)
|
|
* @return The field value.
|
|
*/
|
|
[[nodiscard]]
|
|
SF_ACCOUNT::type::value_type
|
|
getAccount() const
|
|
{
|
|
return this->sle_->at(sfAccount);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfMPTokenIssuanceID (soeREQUIRED)
|
|
* @return The field value.
|
|
*/
|
|
[[nodiscard]]
|
|
SF_UINT192::type::value_type
|
|
getMPTokenIssuanceID() const
|
|
{
|
|
return this->sle_->at(sfMPTokenIssuanceID);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfMPTAmount (soeDEFAULT)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_UINT64::type::value_type>
|
|
getMPTAmount() const
|
|
{
|
|
if (hasMPTAmount())
|
|
return this->sle_->at(sfMPTAmount);
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfMPTAmount is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasMPTAmount() const
|
|
{
|
|
return this->sle_->isFieldPresent(sfMPTAmount);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfLockedAmount (soeOPTIONAL)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_UINT64::type::value_type>
|
|
getLockedAmount() const
|
|
{
|
|
if (hasLockedAmount())
|
|
return this->sle_->at(sfLockedAmount);
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfLockedAmount is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasLockedAmount() const
|
|
{
|
|
return this->sle_->isFieldPresent(sfLockedAmount);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfOwnerNode (soeREQUIRED)
|
|
* @return The field value.
|
|
*/
|
|
[[nodiscard]]
|
|
SF_UINT64::type::value_type
|
|
getOwnerNode() const
|
|
{
|
|
return this->sle_->at(sfOwnerNode);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfPreviousTxnID (soeREQUIRED)
|
|
* @return The field value.
|
|
*/
|
|
[[nodiscard]]
|
|
SF_UINT256::type::value_type
|
|
getPreviousTxnID() const
|
|
{
|
|
return this->sle_->at(sfPreviousTxnID);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfPreviousTxnLgrSeq (soeREQUIRED)
|
|
* @return The field value.
|
|
*/
|
|
[[nodiscard]]
|
|
SF_UINT32::type::value_type
|
|
getPreviousTxnLgrSeq() const
|
|
{
|
|
return this->sle_->at(sfPreviousTxnLgrSeq);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* @brief Builder for MPToken ledger entries.
|
|
*
|
|
* Provides a fluent interface for constructing ledger entries with method chaining.
|
|
* Uses Json::Value internally for flexible ledger entry construction.
|
|
* Inherits common field setters from LedgerEntryBuilderBase.
|
|
*/
|
|
class MPTokenBuilder : public LedgerEntryBuilderBase<MPTokenBuilder>
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Construct a new MPTokenBuilder with required fields.
|
|
* @param account The sfAccount field value.
|
|
* @param mPTokenIssuanceID The sfMPTokenIssuanceID field value.
|
|
* @param ownerNode The sfOwnerNode field value.
|
|
* @param previousTxnID The sfPreviousTxnID field value.
|
|
* @param previousTxnLgrSeq The sfPreviousTxnLgrSeq field value.
|
|
*/
|
|
MPTokenBuilder(std::decay_t<typename SF_ACCOUNT::type::value_type> const& account,std::decay_t<typename SF_UINT192::type::value_type> const& mPTokenIssuanceID,std::decay_t<typename SF_UINT64::type::value_type> const& ownerNode,std::decay_t<typename SF_UINT256::type::value_type> const& previousTxnID,std::decay_t<typename SF_UINT32::type::value_type> const& previousTxnLgrSeq)
|
|
: LedgerEntryBuilderBase<MPTokenBuilder>(ltMPTOKEN)
|
|
{
|
|
setAccount(account);
|
|
setMPTokenIssuanceID(mPTokenIssuanceID);
|
|
setOwnerNode(ownerNode);
|
|
setPreviousTxnID(previousTxnID);
|
|
setPreviousTxnLgrSeq(previousTxnLgrSeq);
|
|
}
|
|
|
|
/**
|
|
* @brief Construct a MPTokenBuilder from an existing SLE object.
|
|
* @param sle The existing ledger entry to copy from.
|
|
* @throws std::runtime_error if the ledger entry type doesn't match.
|
|
*/
|
|
MPTokenBuilder(std::shared_ptr<SLE const> sle)
|
|
{
|
|
if (sle->at(sfLedgerEntryType) != ltMPTOKEN)
|
|
{
|
|
throw std::runtime_error("Invalid ledger entry type for MPToken");
|
|
}
|
|
object_ = *sle;
|
|
}
|
|
|
|
/** @brief Ledger entry-specific field setters */
|
|
|
|
/**
|
|
* @brief Set sfAccount (soeREQUIRED)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
|
{
|
|
object_[sfAccount] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfMPTokenIssuanceID (soeREQUIRED)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setMPTokenIssuanceID(std::decay_t<typename SF_UINT192::type::value_type> const& value)
|
|
{
|
|
object_[sfMPTokenIssuanceID] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfMPTAmount (soeDEFAULT)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setMPTAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
|
{
|
|
object_[sfMPTAmount] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfLockedAmount (soeOPTIONAL)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setLockedAmount(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
|
{
|
|
object_[sfLockedAmount] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfOwnerNode (soeREQUIRED)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setOwnerNode(std::decay_t<typename SF_UINT64::type::value_type> const& value)
|
|
{
|
|
object_[sfOwnerNode] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfPreviousTxnID (soeREQUIRED)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setPreviousTxnID(std::decay_t<typename SF_UINT256::type::value_type> const& value)
|
|
{
|
|
object_[sfPreviousTxnID] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfPreviousTxnLgrSeq (soeREQUIRED)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
MPTokenBuilder&
|
|
setPreviousTxnLgrSeq(std::decay_t<typename SF_UINT32::type::value_type> const& value)
|
|
{
|
|
object_[sfPreviousTxnLgrSeq] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Build and return the completed MPToken wrapper.
|
|
* @param index The ledger entry index.
|
|
* @return The constructed ledger entry wrapper.
|
|
*/
|
|
MPToken
|
|
build(uint256 const& index)
|
|
{
|
|
return MPToken{std::make_shared<SLE>(std::move(object_), index)};
|
|
}
|
|
};
|
|
|
|
} // namespace xrpl::ledger_entries
|