mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Address PR comments
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
@@ -8,8 +8,6 @@ classes for each ledger entry type, similar to the transaction wrapper classes.
|
||||
Uses pcpp to preprocess the macro file and pyparsing to parse the DSL.
|
||||
"""
|
||||
|
||||
# cspell:words sfields
|
||||
|
||||
import io
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
@@ -6,8 +6,6 @@ and generate C++ classes for each transaction type.
|
||||
Uses pcpp to preprocess the macro file and pyparsing to parse the DSL.
|
||||
"""
|
||||
|
||||
# cspell:words sfields
|
||||
|
||||
import io
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
@@ -6,8 +6,6 @@ This module provides shared functionality for parsing transactions.macro
|
||||
and ledger_entries.macro files using pcpp and pyparsing.
|
||||
"""
|
||||
|
||||
# cspell:words sfields
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
import pyparsing as pp
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#
|
||||
# These packages are required to run the code generation scripts that
|
||||
# parse macro files and generate C++ wrapper classes.
|
||||
# cspell:words pyparsing
|
||||
|
||||
# C preprocessor for Python - used to preprocess macro files
|
||||
pcpp>=1.30
|
||||
@@ -12,3 +11,9 @@ pyparsing>=3.0.0
|
||||
|
||||
# Template engine - used to generate C++ code from templates
|
||||
Mako>=1.2.0
|
||||
|
||||
# Pre-commit - used to format generated C++ code
|
||||
pre-commit>=3.0.0
|
||||
|
||||
# Code formatter - used to format generated C++ code
|
||||
clang-format>=18.1.0
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
namespace xrpl::ledger_entries {
|
||||
|
||||
// Forward declaration
|
||||
class ${name}Builder;
|
||||
|
||||
/**
|
||||
* Ledger Entry: ${name}
|
||||
* @brief Ledger Entry: ${name}
|
||||
*
|
||||
* Type: ${tag} (${value})
|
||||
* RPC Name: ${rpc_name}
|
||||
*
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
static constexpr LedgerEntryType entryType = ${tag};
|
||||
|
||||
/**
|
||||
* Construct a ${name} ledger entry wrapper from an existing SLE object.
|
||||
* @brief Construct a ${name} ledger entry wrapper from an existing SLE object.
|
||||
* @throws std::runtime_error if the ledger entry type doesn't match.
|
||||
*/
|
||||
explicit ${name}(std::shared_ptr<SLE const> sle)
|
||||
@@ -48,9 +48,14 @@ public:
|
||||
% if field['typed']:
|
||||
|
||||
/**
|
||||
* Get ${field['name']} (${field['requirement']})
|
||||
* @brief Get ${field['name']} (${field['requirement']})
|
||||
% if field.get('mpt_support'):
|
||||
* MPT Support: ${field['mpt_support']}
|
||||
% endif
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
* @return The field value.
|
||||
% else:
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
% endif
|
||||
*/
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
@@ -70,6 +75,10 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if ${field['name']} is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
has${field['name'][2:]}() const
|
||||
@@ -80,11 +89,16 @@ public:
|
||||
% else:
|
||||
|
||||
/**
|
||||
* Get ${field['name']} (${field['requirement']})
|
||||
* @brief Get ${field['name']} (${field['requirement']})
|
||||
% if field.get('mpt_support'):
|
||||
* MPT Support: ${field['mpt_support']}
|
||||
% endif
|
||||
* Note: This is an untyped field (${field.get('cppType', 'unknown')}).
|
||||
* @note This is an untyped field (${field.get('cppType', 'unknown')}).
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
* @return The field value.
|
||||
% else:
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
% endif
|
||||
*/
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
[[nodiscard]]
|
||||
@@ -103,6 +117,10 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if ${field['name']} is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
has${field['name'][2:]}() const
|
||||
@@ -118,7 +136,8 @@ public:
|
||||
required_fields = [f for f in fields if f['requirement'] == 'soeREQUIRED']
|
||||
%>\
|
||||
/**
|
||||
* Builder for ${name} ledger entries.
|
||||
* @brief Builder for ${name} 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.
|
||||
@@ -126,6 +145,12 @@ public:
|
||||
class ${name}Builder : public LedgerEntryBuilderBase<${name}Builder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new ${name}Builder with required fields.
|
||||
% for field in required_fields:
|
||||
* @param ${field['paramName']} The ${field['name']} field value.
|
||||
% endfor
|
||||
*/
|
||||
${name}Builder(\
|
||||
% for i, field in enumerate(required_fields):
|
||||
${field['typeData']['setter_type']} ${field['paramName']}${',' if i < len(required_fields) - 1 else ''}\
|
||||
@@ -138,6 +163,11 @@ ${field['typeData']['setter_type']} ${field['paramName']}${',' if i < len(requir
|
||||
% endfor
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a ${name}Builder 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.
|
||||
*/
|
||||
${name}Builder(std::shared_ptr<SLE const> sle)
|
||||
{
|
||||
if (sle->at(sfLedgerEntryType) != ${tag})
|
||||
@@ -147,11 +177,11 @@ ${field['typeData']['setter_type']} ${field['paramName']}${',' if i < len(requir
|
||||
object_ = *sle;
|
||||
}
|
||||
|
||||
// Ledger entry-specific field setters
|
||||
/** @brief Ledger entry-specific field setters */
|
||||
% for field in fields:
|
||||
|
||||
/**
|
||||
* Set ${field['name']} (${field['requirement']})
|
||||
* @brief Set ${field['name']} (${field['requirement']})
|
||||
% if field.get('mpt_support'):
|
||||
* MPT Support: ${field['mpt_support']}
|
||||
% endif
|
||||
@@ -172,7 +202,8 @@ ${field['typeData']['setter_type']} ${field['paramName']}${',' if i < len(requir
|
||||
% endfor
|
||||
|
||||
/**
|
||||
* Build and return the completed ${name} wrapper.
|
||||
* @brief Build and return the completed ${name} wrapper.
|
||||
* @param index The ledger entry index.
|
||||
* @return The constructed ledger entry wrapper.
|
||||
*/
|
||||
${name}
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
|
||||
namespace xrpl::transactions {
|
||||
|
||||
// Forward declaration
|
||||
class ${name}Builder;
|
||||
|
||||
/**
|
||||
* Transaction: ${name}
|
||||
* @brief Transaction: ${name}
|
||||
*
|
||||
* Type: ${tag} (${value})
|
||||
* Delegable: ${delegable}
|
||||
* Amendment: ${amendments}
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
static constexpr xrpl::TxType txType = ${tag};
|
||||
|
||||
/**
|
||||
* Construct a ${name} transaction wrapper from an existing STTx object.
|
||||
* @brief Construct a ${name} transaction wrapper from an existing STTx object.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
explicit ${name}(std::shared_ptr<STTx const> tx)
|
||||
@@ -50,9 +50,14 @@ public:
|
||||
% if field['typed']:
|
||||
|
||||
/**
|
||||
* Get ${field['name']} (${field['requirement']})
|
||||
* @brief Get ${field['name']} (${field['requirement']})
|
||||
% if field.get('supports_mpt'):
|
||||
* Note: This field supports MPT (Multi-Purpose Token) amounts.
|
||||
* @note This field supports MPT (Multi-Purpose Token) amounts.
|
||||
% endif
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
* @return The field value.
|
||||
% else:
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
% endif
|
||||
*/
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
@@ -74,6 +79,10 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if ${field['name']} is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
has${field['name'][2:]}() const
|
||||
@@ -83,11 +92,16 @@ public:
|
||||
% endif
|
||||
% else:
|
||||
/**
|
||||
* Get ${field['name']} (${field['requirement']})
|
||||
* @brief Get ${field['name']} (${field['requirement']})
|
||||
% if field.get('supports_mpt'):
|
||||
* Note: This field supports MPT (Multi-Purpose Token) amounts.
|
||||
* @note This field supports MPT (Multi-Purpose Token) amounts.
|
||||
% endif
|
||||
* @note This is an untyped field.
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
* @return The field value.
|
||||
% else:
|
||||
* @return The field value, or std::nullopt if not present.
|
||||
% endif
|
||||
* Note: This is an untyped field
|
||||
*/
|
||||
% if field['requirement'] == 'soeREQUIRED':
|
||||
[[nodiscard]]
|
||||
@@ -106,6 +120,10 @@ public:
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if ${field['name']} is present.
|
||||
* @return True if the field is present, false otherwise.
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool
|
||||
has${field['name'][2:]}() const
|
||||
@@ -121,7 +139,8 @@ public:
|
||||
required_fields = [f for f in fields if f['requirement'] == 'soeREQUIRED']
|
||||
%>\
|
||||
/**
|
||||
* Builder for ${name} transactions.
|
||||
* @brief Builder for ${name} 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.
|
||||
@@ -129,6 +148,15 @@ public:
|
||||
class ${name}Builder : public TransactionBuilderBase<${name}Builder>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new ${name}Builder with required fields.
|
||||
* @param account The account initiating the transaction.
|
||||
% for field in required_fields:
|
||||
* @param ${field['paramName']} The ${field['name']} field value.
|
||||
% endfor
|
||||
* @param sequence Optional sequence number for the transaction.
|
||||
* @param fee Optional fee for the transaction.
|
||||
*/
|
||||
${name}Builder(SF_ACCOUNT::type::value_type account,
|
||||
% for i, field in enumerate(required_fields):
|
||||
${field['typeData']['setter_type']} ${field['paramName']},\
|
||||
@@ -143,6 +171,11 @@ public:
|
||||
% endfor
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct a ${name}Builder from an existing STTx object.
|
||||
* @param tx The existing transaction to copy from.
|
||||
* @throws std::runtime_error if the transaction type doesn't match.
|
||||
*/
|
||||
${name}Builder(std::shared_ptr<STTx const> tx)
|
||||
{
|
||||
if (tx->getTxnType() != ${tag})
|
||||
@@ -152,13 +185,13 @@ public:
|
||||
object_ = *tx;
|
||||
}
|
||||
|
||||
// Transaction-specific field setters
|
||||
/** @brief Transaction-specific field setters */
|
||||
% for field in fields:
|
||||
|
||||
/**
|
||||
* Set ${field['name']} (${field['requirement']})
|
||||
* @brief Set ${field['name']} (${field['requirement']})
|
||||
% if field.get('supports_mpt'):
|
||||
* Note: This field supports MPT (Multi-Purpose Token) amounts.
|
||||
* @note This field supports MPT (Multi-Purpose Token) amounts.
|
||||
% endif
|
||||
* @return Reference to this builder for method chaining.
|
||||
*/
|
||||
@@ -177,9 +210,9 @@ public:
|
||||
% endfor
|
||||
|
||||
/**
|
||||
* Build and return the ${name} wrapper.
|
||||
* @param publicKey The public key for signing
|
||||
* @param secretKey The secret key for signing
|
||||
* @brief Build and return the ${name} wrapper.
|
||||
* @param publicKey The public key for signing.
|
||||
* @param secretKey The secret key for signing.
|
||||
* @return The constructed transaction wrapper.
|
||||
*/
|
||||
${name}
|
||||
|
||||
Reference in New Issue
Block a user