refactor: SField and TER code renames (#7797)

This commit is contained in:
Rithvik Reddygari
2026-07-20 12:29:39 -04:00
committed by GitHub
parent d3550fac60
commit a41889df31
27 changed files with 316 additions and 322 deletions

View File

@@ -61,9 +61,9 @@ public:
}
void
setWasmReturnCode(std::int32_t const wasmReturnCode)
setVMReturnCode(std::int32_t const vmReturnCode)
{
wasmReturnCode_ = wasmReturnCode;
vmReturnCode_ = vmReturnCode;
}
/** Get the number of modified entries
@@ -85,7 +85,7 @@ public:
private:
std::optional<STAmount> deliver_;
std::optional<std::uint32_t> gasUsed_;
std::optional<std::int32_t> wasmReturnCode_;
std::optional<std::int32_t> vmReturnCode_;
};
} // namespace xrpl

View File

@@ -52,7 +52,7 @@ public:
std::optional<STAmount> const& deliver,
std::optional<uint256 const> const& parentBatchId,
std::optional<std::uint32_t> const& gasUsed,
std::optional<std::int32_t> const& wasmReturnCode,
std::optional<std::int32_t> const& vmReturnCode,
bool isDryRun,
beast::Journal j);

View File

@@ -129,7 +129,7 @@ enum TEMcodes : TERUnderlyingType {
temINVALID_INNER_BATCH,
temBAD_MPT,
temBAD_WASM,
temINVALID_BYTECODE,
temTEMP_DISABLED,
};
@@ -177,8 +177,8 @@ enum TEFcodes : TERUnderlyingType {
tefNO_TICKET,
tefNFTOKEN_IS_NOT_TRANSFERABLE,
tefINVALID_LEDGER_FIX_TYPE,
tefNO_WASM,
tefWASM_FIELD_NOT_INCLUDED,
tefNO_BYTECODE,
tefBYTECODE_NOT_INCLUDED,
};
//------------------------------------------------------------------------------
@@ -363,7 +363,7 @@ enum TECcodes : TERUnderlyingType {
tecLIMIT_EXCEEDED = 195,
tecPSEUDO_ACCOUNT = 196,
tecPRECISION_LOSS = 197,
tecWASM_REJECTED = 198,
tecBYTECODE_REJECTED = 198,
};
//------------------------------------------------------------------------------

View File

@@ -88,8 +88,8 @@ public:
if (obj.isFieldPresent(sfGasUsed))
gasUsed_ = obj.getFieldU32(sfGasUsed);
if (obj.isFieldPresent(sfWasmReturnCode))
wasmReturnCode_ = obj.getFieldI32(sfWasmReturnCode);
if (obj.isFieldPresent(sfVMReturnCode))
vmReturnCode_ = obj.getFieldI32(sfVMReturnCode);
}
[[nodiscard]] std::optional<STAmount> const&
@@ -123,15 +123,15 @@ public:
}
void
setWasmReturnCode(std::optional<std::int32_t> const wasmReturnCode)
setVMReturnCode(std::optional<std::int32_t> const vmReturnCode)
{
wasmReturnCode_ = wasmReturnCode;
vmReturnCode_ = vmReturnCode;
}
[[nodiscard]] std::optional<std::int32_t> const&
getWasmReturnCode() const
getVMReturnCode() const
{
return wasmReturnCode_;
return vmReturnCode_;
}
private:
@@ -143,7 +143,7 @@ private:
std::optional<STAmount> deliveredAmount_;
std::optional<uint256> parentBatchID_;
std::optional<std::uint32_t> gasUsed_;
std::optional<std::int32_t> wasmReturnCode_;
std::optional<std::int32_t> vmReturnCode_;
STArray nodes_;
};

View File

@@ -339,7 +339,7 @@ LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, escrow, ({
{sfCondition, SoeOptional},
{sfCancelAfter, SoeOptional},
{sfFinishAfter, SoeOptional},
{sfFinishFunction, SoeOptional},
{sfBytecode, SoeOptional},
{sfData, SoeOptional},
{sfSourceTag, SoeOptional},
{sfDestinationTag, SoeOptional},

View File

@@ -116,7 +116,7 @@ TYPED_SFIELD(sfOverpaymentInterestRate, UINT32, 68) // 1/10 basis points (bi
TYPED_SFIELD(sfExtensionComputeLimit, UINT32, 69)
TYPED_SFIELD(sfExtensionSizeLimit, UINT32, 70)
TYPED_SFIELD(sfGasPrice, UINT32, 71)
TYPED_SFIELD(sfComputationAllowance, UINT32, 72)
TYPED_SFIELD(sfGas, UINT32, 72)
TYPED_SFIELD(sfGasUsed, UINT32, 73)
// 64-bit integers (common)
@@ -232,7 +232,7 @@ TYPED_SFIELD(sfManagementFeeOutstanding, NUMBER, 17, SField::kSmdNeedsAsset
// 32-bit signed (common)
TYPED_SFIELD(sfLoanScale, INT32, 1)
TYPED_SFIELD(sfWasmReturnCode, INT32, 2)
TYPED_SFIELD(sfVMReturnCode, INT32, 2)
// currency amount (common)
TYPED_SFIELD(sfAmount, AMOUNT, 1)
@@ -304,7 +304,7 @@ TYPED_SFIELD(sfAssetClass, VL, 28)
TYPED_SFIELD(sfProvider, VL, 29)
TYPED_SFIELD(sfMPTokenMetadata, VL, 30)
TYPED_SFIELD(sfCredentialType, VL, 31)
TYPED_SFIELD(sfFinishFunction, VL, 32)
TYPED_SFIELD(sfBytecode, VL, 32)
// account (common)
TYPED_SFIELD(sfAccount, ACCOUNT, 1)

View File

@@ -55,7 +55,7 @@ TRANSACTION(ttESCROW_CREATE, 1, EscrowCreate,
{sfCondition, SoeOptional},
{sfCancelAfter, SoeOptional},
{sfFinishAfter, SoeOptional},
{sfFinishFunction, SoeOptional},
{sfBytecode, SoeOptional},
{sfData, SoeOptional},
}))
@@ -73,7 +73,7 @@ TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish,
{sfFulfillment, SoeOptional},
{sfCondition, SoeOptional},
{sfCredentialIDs, SoeOptional},
{sfComputationAllowance, SoeOptional},
{sfGas, SoeOptional},
}))

View File

@@ -175,27 +175,27 @@ public:
}
/**
* @brief Get sfFinishFunction (SoeOptional)
* @brief Get sfBytecode (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getFinishFunction() const
getBytecode() const
{
if (hasFinishFunction())
return this->sle_->at(sfFinishFunction);
if (hasBytecode())
return this->sle_->at(sfBytecode);
return std::nullopt;
}
/**
* @brief Check if sfFinishFunction is present.
* @brief Check if sfBytecode is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasFinishFunction() const
hasBytecode() const
{
return this->sle_->isFieldPresent(sfFinishFunction);
return this->sle_->isFieldPresent(sfBytecode);
}
/**
@@ -500,13 +500,13 @@ public:
}
/**
* @brief Set sfFinishFunction (SoeOptional)
* @brief Set sfBytecode (SoeOptional)
* @return Reference to this builder for method chaining.
*/
EscrowBuilder&
setFinishFunction(std::decay_t<typename SF_VL::type::value_type> const& value)
setBytecode(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfFinishFunction] = value;
object_[sfBytecode] = value;
return *this;
}

View File

@@ -175,29 +175,29 @@ public:
}
/**
* @brief Get sfFinishFunction (SoeOptional)
* @brief Get sfBytecode (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_VL::type::value_type>
getFinishFunction() const
getBytecode() const
{
if (hasFinishFunction())
if (hasBytecode())
{
return this->tx_->at(sfFinishFunction);
return this->tx_->at(sfBytecode);
}
return std::nullopt;
}
/**
* @brief Check if sfFinishFunction is present.
* @brief Check if sfBytecode is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasFinishFunction() const
hasBytecode() const
{
return this->tx_->isFieldPresent(sfFinishFunction);
return this->tx_->isFieldPresent(sfBytecode);
}
/**
@@ -339,13 +339,13 @@ public:
}
/**
* @brief Set sfFinishFunction (SoeOptional)
* @brief Set sfBytecode (SoeOptional)
* @return Reference to this builder for method chaining.
*/
EscrowCreateBuilder&
setFinishFunction(std::decay_t<typename SF_VL::type::value_type> const& value)
setBytecode(std::decay_t<typename SF_VL::type::value_type> const& value)
{
object_[sfFinishFunction] = value;
object_[sfBytecode] = value;
return *this;
}

View File

@@ -148,29 +148,29 @@ public:
}
/**
* @brief Get sfComputationAllowance (SoeOptional)
* @brief Get sfGas (SoeOptional)
* @return The field value, or std::nullopt if not present.
*/
[[nodiscard]]
protocol_autogen::Optional<SF_UINT32::type::value_type>
getComputationAllowance() const
getGas() const
{
if (hasComputationAllowance())
if (hasGas())
{
return this->tx_->at(sfComputationAllowance);
return this->tx_->at(sfGas);
}
return std::nullopt;
}
/**
* @brief Check if sfComputationAllowance is present.
* @brief Check if sfGas is present.
* @return True if the field is present, false otherwise.
*/
[[nodiscard]]
bool
hasComputationAllowance() const
hasGas() const
{
return this->tx_->isFieldPresent(sfComputationAllowance);
return this->tx_->isFieldPresent(sfGas);
}
};
@@ -274,13 +274,13 @@ public:
}
/**
* @brief Set sfComputationAllowance (SoeOptional)
* @brief Set sfGas (SoeOptional)
* @return Reference to this builder for method chaining.
*/
EscrowFinishBuilder&
setComputationAllowance(std::decay_t<typename SF_UINT32::type::value_type> const& value)
setGas(std::decay_t<typename SF_UINT32::type::value_type> const& value)
{
object_[sfComputationAllowance] = value;
object_[sfGas] = value;
return *this;
}

View File

@@ -85,9 +85,9 @@ public:
/** Sets the gas used in the metadata */
void
setWasmReturnCode(std::int32_t const wasmReturnCode)
setVMReturnCode(std::int32_t const vmReturnCode)
{
wasmReturnCode_ = wasmReturnCode;
vmReturnCode_ = vmReturnCode;
}
/** Discard changes and start fresh. */
@@ -141,7 +141,7 @@ private:
// The ID of the batch transaction we are executing under, if seated.
std::optional<uint256 const> parentBatchId_;
std::optional<std::uint32_t> gasUsed_;
std::optional<std::int32_t> wasmReturnCode_;
std::optional<std::int32_t> vmReturnCode_;
};
} // namespace xrpl