mirror of
https://github.com/XRPLF/rippled.git
synced 2026-09-29 16:28:08 +00:00
Upstream rewrote the wasm VM and host-function system (Rust `crates/` bridged via cxx), collapsed `transactions.macro` onto `TxSettings`, and moved invariant running from `ApplyContext` to `Transactor`. This merge resolves those conflicts and the breaks that carried no conflict marker. Conflict resolutions of note: - transactions.macro: took upstream's 5-argument `TxSettings` form and re-expressed our `emitable` column as `TxSettings::emittance`, a new scoped `Emittance` enum in TxSettings.h. `Emitable.cpp` and the transaction code generator read the new member. - sfields.macro: upstream claimed UINT32 75-80, so `sfParameterFlag` moves from 80 to 86. The amendment is not live, so no wire break. - HostFunc.h: took upstream's version, which drops `floatRoot`, and re-added the 15 contract virtuals. `setDataNestedObjectField`'s parameters are renamed to `(account, key, nestedKey, value)` to match the implementation; the wire order is unchanged. - WasmCommon.h: `SubmitTxnFailure` (-21) and `InvalidState` (-22) join upstream's enum and the Rust `host_errors!` table. `Success` is gone; the helpers that compared against it now return `expected<void, ...>`. - Transactor.cpp: kept the emitted-transaction pass, now using `checkInvariants(result, fee, InvariantScope::ProtocolOnly)`. Breaks with no conflict marker: - `Emitable.cpp` used the 8-argument TRANSACTION macro. - `STTx::getSeqValue` is gone; use `getSeqProxy().value()`. - `NetworkOPsImp::subLock_` is now `streamLock_`, held with `scoped_lock`. - The `LedgerEntryHelpers` namespace is now `ledger_entry_helpers`. - `keylet::vault` takes a `SeqProxy`. The three contract `ledger_entry` parsers were copy-pasted from the vault one and returned vault keylets; they now build contract, contract source and contract data keylets from their own fields. `contract_hash` is added to jss. The 15 contract host functions still register through the deleted C++ wrapper layer, so contract bytecode does not run yet. Porting them to the Rust-declared ABI is the next commit.
398 lines
11 KiB
C++
398 lines
11 KiB
C++
// This file is auto-generated. Do not edit.
|
|
#pragma once
|
|
|
|
#include <xrpl/protocol/STTx.h>
|
|
#include <xrpl/protocol/STParsedJSON.h>
|
|
#include <xrpl/protocol/jss.h>
|
|
#include <xrpl/protocol_autogen/TransactionBase.h>
|
|
#include <xrpl/protocol_autogen/TransactionBuilderBase.h>
|
|
#include <xrpl/json/json_value.h>
|
|
|
|
#include <stdexcept>
|
|
#include <optional>
|
|
|
|
namespace xrpl::transactions {
|
|
|
|
class ContractModifyBuilder;
|
|
|
|
/**
|
|
* @brief Transaction: ContractModify
|
|
*
|
|
* Type: ttCONTRACT_MODIFY (93)
|
|
* Delegable: Delegation::Delegable
|
|
* Amendment: featureSmartContract
|
|
* Privileges: Privilege::NoPriv
|
|
*
|
|
* Immutable wrapper around STTx providing type-safe field access.
|
|
* Use ContractModifyBuilder to construct new transactions.
|
|
*/
|
|
class ContractModify : public TransactionBase
|
|
{
|
|
public:
|
|
static constexpr xrpl::TxType txType = ttCONTRACT_MODIFY;
|
|
|
|
/**
|
|
* @brief Construct a ContractModify transaction wrapper from an existing STTx object.
|
|
* @throws std::runtime_error if the transaction type doesn't match.
|
|
*/
|
|
explicit ContractModify(std::shared_ptr<STTx const> tx)
|
|
: TransactionBase(std::move(tx))
|
|
{
|
|
// Verify transaction type
|
|
if (tx_->getTxnType() != txType)
|
|
{
|
|
throw std::runtime_error("Invalid transaction type for ContractModify");
|
|
}
|
|
}
|
|
|
|
// Transaction-specific field getters
|
|
|
|
/**
|
|
* @brief Get sfContractAccount (SoeOptional)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
|
getContractAccount() const
|
|
{
|
|
if (hasContractAccount())
|
|
{
|
|
return this->tx_->at(sfContractAccount);
|
|
}
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfContractAccount is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasContractAccount() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfContractAccount);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfOwner (SoeOptional)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_ACCOUNT::type::value_type>
|
|
getOwner() const
|
|
{
|
|
if (hasOwner())
|
|
{
|
|
return this->tx_->at(sfOwner);
|
|
}
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfOwner is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasOwner() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfOwner);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfContractCode (SoeOptional)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_VL::type::value_type>
|
|
getContractCode() const
|
|
{
|
|
if (hasContractCode())
|
|
{
|
|
return this->tx_->at(sfContractCode);
|
|
}
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfContractCode is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasContractCode() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfContractCode);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfContractHash (SoeOptional)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_UINT256::type::value_type>
|
|
getContractHash() const
|
|
{
|
|
if (hasContractHash())
|
|
{
|
|
return this->tx_->at(sfContractHash);
|
|
}
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfContractHash is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasContractHash() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfContractHash);
|
|
}
|
|
/**
|
|
* @brief Get sfFunctions (SoeOptional)
|
|
* @note This is an untyped field.
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
std::optional<std::reference_wrapper<STArray const>>
|
|
getFunctions() const
|
|
{
|
|
if (this->tx_->isFieldPresent(sfFunctions))
|
|
return this->tx_->getFieldArray(sfFunctions);
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfFunctions is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasFunctions() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfFunctions);
|
|
}
|
|
/**
|
|
* @brief Get sfInstanceParameters (SoeOptional)
|
|
* @note This is an untyped field.
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
std::optional<std::reference_wrapper<STArray const>>
|
|
getInstanceParameters() const
|
|
{
|
|
if (this->tx_->isFieldPresent(sfInstanceParameters))
|
|
return this->tx_->getFieldArray(sfInstanceParameters);
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfInstanceParameters is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasInstanceParameters() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfInstanceParameters);
|
|
}
|
|
/**
|
|
* @brief Get sfInstanceParameterValues (SoeOptional)
|
|
* @note This is an untyped field.
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
std::optional<std::reference_wrapper<STArray const>>
|
|
getInstanceParameterValues() const
|
|
{
|
|
if (this->tx_->isFieldPresent(sfInstanceParameterValues))
|
|
return this->tx_->getFieldArray(sfInstanceParameterValues);
|
|
return std::nullopt;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if sfInstanceParameterValues is present.
|
|
* @return True if the field is present, false otherwise.
|
|
*/
|
|
[[nodiscard]]
|
|
bool
|
|
hasInstanceParameterValues() const
|
|
{
|
|
return this->tx_->isFieldPresent(sfInstanceParameterValues);
|
|
}
|
|
|
|
/**
|
|
* @brief Get sfURI (SoeOptional)
|
|
* @return The field value, or std::nullopt if not present.
|
|
*/
|
|
[[nodiscard]]
|
|
protocol_autogen::Optional<SF_VL::type::value_type>
|
|
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 Builder for ContractModify transactions.
|
|
*
|
|
* Provides a fluent interface for constructing transactions with method chaining.
|
|
* Uses STObject internally for flexible transaction construction.
|
|
* Inherits common field setters from TransactionBuilderBase.
|
|
*/
|
|
class ContractModifyBuilder : public TransactionBuilderBase<ContractModifyBuilder>
|
|
{
|
|
public:
|
|
/**
|
|
* @brief Construct a new ContractModifyBuilder with required fields.
|
|
* @param account The account initiating the transaction.
|
|
* @param sequence Optional sequence number for the transaction.
|
|
* @param fee Optional fee for the transaction.
|
|
*/
|
|
ContractModifyBuilder(SF_ACCOUNT::type::value_type account,
|
|
std::optional<SF_UINT32::type::value_type> sequence = std::nullopt,
|
|
std::optional<SF_AMOUNT::type::value_type> fee = std::nullopt
|
|
)
|
|
: TransactionBuilderBase<ContractModifyBuilder>(ttCONTRACT_MODIFY, account, sequence, fee)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @brief Construct a ContractModifyBuilder from an existing STTx object.
|
|
* @param tx The existing transaction to copy from.
|
|
* @throws std::runtime_error if the transaction type doesn't match.
|
|
*/
|
|
ContractModifyBuilder(std::shared_ptr<STTx const> tx)
|
|
{
|
|
if (tx->getTxnType() != ttCONTRACT_MODIFY)
|
|
{
|
|
throw std::runtime_error("Invalid transaction type for ContractModifyBuilder");
|
|
}
|
|
object_ = *tx;
|
|
}
|
|
|
|
/**
|
|
* @brief Transaction-specific field setters
|
|
*/
|
|
|
|
/**
|
|
* @brief Set sfContractAccount (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setContractAccount(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
|
{
|
|
object_[sfContractAccount] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfOwner (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setOwner(std::decay_t<typename SF_ACCOUNT::type::value_type> const& value)
|
|
{
|
|
object_[sfOwner] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfContractCode (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setContractCode(std::decay_t<typename SF_VL::type::value_type> const& value)
|
|
{
|
|
object_[sfContractCode] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfContractHash (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setContractHash(std::decay_t<typename SF_UINT256::type::value_type> const& value)
|
|
{
|
|
object_[sfContractHash] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfFunctions (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setFunctions(STArray const& value)
|
|
{
|
|
object_.setFieldArray(sfFunctions, value);
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfInstanceParameters (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setInstanceParameters(STArray const& value)
|
|
{
|
|
object_.setFieldArray(sfInstanceParameters, value);
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfInstanceParameterValues (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setInstanceParameterValues(STArray const& value)
|
|
{
|
|
object_.setFieldArray(sfInstanceParameterValues, value);
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Set sfURI (SoeOptional)
|
|
* @return Reference to this builder for method chaining.
|
|
*/
|
|
ContractModifyBuilder&
|
|
setURI(std::decay_t<typename SF_VL::type::value_type> const& value)
|
|
{
|
|
object_[sfURI] = value;
|
|
return *this;
|
|
}
|
|
|
|
/**
|
|
* @brief Build and return the ContractModify wrapper.
|
|
* @param publicKey The public key for signing.
|
|
* @param secretKey The secret key for signing.
|
|
* @return The constructed transaction wrapper.
|
|
*/
|
|
ContractModify
|
|
build(PublicKey const& publicKey, SecretKey const& secretKey)
|
|
{
|
|
sign(publicKey, secretKey);
|
|
return ContractModify{std::make_shared<STTx>(std::move(object_))};
|
|
}
|
|
};
|
|
|
|
} // namespace xrpl::transactions
|