Merge branch 'ximinez/lending-refactoring-3' into ximinez/lending-refactoring-4

This commit is contained in:
Ed Hennis
2025-09-20 17:12:26 -04:00
committed by GitHub
50 changed files with 45 additions and 157 deletions

View File

@@ -137,7 +137,7 @@ Permission::getTxFeature(TxType txType) const
auto const txFeaturesIt = txFeatureMap_.find(txType);
XRPL_ASSERT(
txFeaturesIt != txFeatureMap_.end(),
"ripple::Permissions::isDelegatable : tx exists in txFeatureMap_");
"ripple::Permissions::getTxFeature : tx exists in txFeatureMap_");
if (txFeaturesIt->second == uint256{})
return std::nullopt;

View File

@@ -31,7 +31,7 @@
namespace ripple {
bool
AMMBid::isEnabled(PreflightContext const& ctx)
AMMBid::checkExtraFeatures(PreflightContext const& ctx)
{
return ammEnabled(ctx.rules);
}

View File

@@ -72,7 +72,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -32,7 +32,7 @@
namespace ripple {
bool
AMMCreate::isEnabled(PreflightContext const& ctx)
AMMCreate::checkExtraFeatures(PreflightContext const& ctx)
{
return ammEnabled(ctx.rules);
}

View File

@@ -64,7 +64,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -28,7 +28,7 @@
namespace ripple {
bool
AMMDelete::isEnabled(PreflightContext const& ctx)
AMMDelete::checkExtraFeatures(PreflightContext const& ctx)
{
return ammEnabled(ctx.rules);
}

View File

@@ -40,7 +40,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -30,7 +30,7 @@
namespace ripple {
bool
AMMDeposit::isEnabled(PreflightContext const& ctx)
AMMDeposit::checkExtraFeatures(PreflightContext const& ctx)
{
return ammEnabled(ctx.rules);
}

View File

@@ -69,7 +69,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -28,7 +28,7 @@
namespace ripple {
bool
AMMVote::isEnabled(PreflightContext const& ctx)
AMMVote::checkExtraFeatures(PreflightContext const& ctx)
{
return ammEnabled(ctx.rules);
}

View File

@@ -57,7 +57,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -29,7 +29,7 @@
namespace ripple {
bool
AMMWithdraw::isEnabled(PreflightContext const& ctx)
AMMWithdraw::checkExtraFeatures(PreflightContext const& ctx)
{
return ammEnabled(ctx.rules);
}

View File

@@ -77,7 +77,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -44,7 +44,7 @@ CreateOffer::makeTxConsequences(PreflightContext const& ctx)
}
bool
CreateOffer::isEnabled(PreflightContext const& ctx)
CreateOffer::checkExtraFeatures(PreflightContext const& ctx)
{
if (ctx.tx.isFieldPresent(sfDomainID) &&
!ctx.rules.enabled(featurePermissionedDEX))

View File

@@ -44,7 +44,7 @@ public:
makeTxConsequences(PreflightContext const& ctx);
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -39,7 +39,7 @@
namespace ripple {
bool
DeleteAccount::isEnabled(PreflightContext const& ctx)
DeleteAccount::checkExtraFeatures(PreflightContext const& ctx)
{
if (!ctx.rules.enabled(featureDeletableAccounts))
return false;

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -31,7 +31,7 @@
namespace ripple {
bool
DepositPreauth::isEnabled(PreflightContext const& ctx)
DepositPreauth::checkExtraFeatures(PreflightContext const& ctx)
{
bool const authArrPresent = ctx.tx.isFieldPresent(sfAuthorizeCredentials);
bool const unauthArrPresent =

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -631,7 +631,7 @@ checkCondition(Slice f, Slice c)
}
bool
EscrowFinish::isEnabled(PreflightContext const& ctx)
EscrowFinish::checkExtraFeatures(PreflightContext const& ctx)
{
return !ctx.tx.isFieldPresent(sfCredentialIDs) ||
ctx.rules.enabled(featureCredentials);

View File

@@ -61,7 +61,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -26,7 +26,7 @@
namespace ripple {
bool
MPTokenIssuanceCreate::isEnabled(PreflightContext const& ctx)
MPTokenIssuanceCreate::checkExtraFeatures(PreflightContext const& ctx)
{
if (ctx.tx.isFieldPresent(sfDomainID) &&
!(ctx.rules.enabled(featurePermissionedDomains) &&

View File

@@ -51,7 +51,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -27,7 +27,7 @@
namespace ripple {
bool
MPTokenIssuanceSet::isEnabled(PreflightContext const& ctx)
MPTokenIssuanceSet::checkExtraFeatures(PreflightContext const& ctx)
{
return !ctx.tx.isFieldPresent(sfDomainID) ||
(ctx.rules.enabled(featurePermissionedDomains) &&

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -47,7 +47,7 @@ hasOfferFields(PreflightContext const& ctx)
}
bool
NFTokenMint::isEnabled(PreflightContext const& ctx)
NFTokenMint::checkExtraFeatures(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureNFTokenMintOffer) || !hasOfferFields(ctx);
}

View File

@@ -37,7 +37,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -26,7 +26,7 @@
namespace ripple {
bool
NFTokenModify::isEnabled(PreflightContext const& ctx)
NFTokenModify::checkExtraFeatures(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureNonFungibleTokensV1_1);
}

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -423,7 +423,7 @@ PayChanFund::doApply()
//------------------------------------------------------------------------------
bool
PayChanClaim::isEnabled(PreflightContext const& ctx)
PayChanClaim::checkExtraFeatures(PreflightContext const& ctx)
{
return !ctx.tx.isFieldPresent(sfCredentialIDs) ||
ctx.rules.enabled(featureCredentials);

View File

@@ -89,7 +89,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -66,7 +66,7 @@ getMaxSourceAmount(
}
bool
Payment::isEnabled(PreflightContext const& ctx)
Payment::checkExtraFeatures(PreflightContext const& ctx)
{
if (ctx.tx.isFieldPresent(sfCredentialIDs) &&
!ctx.rules.enabled(featureCredentials))

View File

@@ -43,7 +43,7 @@ public:
makeTxConsequences(PreflightContext const& ctx);
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -29,7 +29,7 @@
namespace ripple {
bool
PermissionedDomainSet::isEnabled(PreflightContext const& ctx)
PermissionedDomainSet::checkExtraFeatures(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureCredentials);
}

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -206,7 +206,7 @@ public:
// Optional if the transaction is gated on an amendment that
// isn't specified in transactions.macro
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
// Optional if the transaction uses any flags other than tfUniversal
static std::uint32_t
@@ -222,7 +222,7 @@ public:
* Do not try to call preflight1 or preflight2 directly.
* Do not check whether relevant amendments are enabled in preflight.
Instead, define isEnabled.
Instead, define checkExtraFeatures.
* Do not check flags in preflight. Instead, define getFlagsMask.
*/
template <class T>
@@ -289,7 +289,7 @@ protected:
// Base class always returns true
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
// Base class always returns tfUniversalMask
static std::uint32_t
@@ -355,7 +355,7 @@ private:
};
inline bool
Transactor::isEnabled(PreflightContext const& ctx)
Transactor::checkExtraFeatures(PreflightContext const& ctx)
{
return true;
}
@@ -401,7 +401,7 @@ Transactor::invokePreflight(PreflightContext const& ctx)
if (feature && !ctx.rules.enabled(*feature))
return temDISABLED;
if (!T::isEnabled(ctx))
if (!T::checkExtraFeatures(ctx))
return temDISABLED;
if (auto const ret = preflight1(ctx, T::getFlagsMask(ctx)))

View File

@@ -32,12 +32,6 @@
namespace ripple {
bool
VaultClawback::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureSingleAssetVault);
}
NotTEC
VaultClawback::preflight(PreflightContext const& ctx)
{

View File

@@ -33,9 +33,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -36,10 +36,9 @@
namespace ripple {
bool
VaultCreate::isEnabled(PreflightContext const& ctx)
VaultCreate::checkExtraFeatures(PreflightContext const& ctx)
{
if (!ctx.rules.enabled(featureSingleAssetVault) ||
!ctx.rules.enabled(featureMPTokensV1))
if (!ctx.rules.enabled(featureMPTokensV1))
return false;
return !ctx.tx.isFieldPresent(sfDomainID) ||

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);

View File

@@ -28,12 +28,6 @@
namespace ripple {
bool
VaultDelete::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureSingleAssetVault);
}
NotTEC
VaultDelete::preflight(PreflightContext const& ctx)
{

View File

@@ -33,9 +33,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -33,12 +33,6 @@
namespace ripple {
bool
VaultDeposit::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureSingleAssetVault);
}
NotTEC
VaultDeposit::preflight(PreflightContext const& ctx)
{

View File

@@ -33,9 +33,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -31,11 +31,8 @@
namespace ripple {
bool
VaultSet::isEnabled(PreflightContext const& ctx)
VaultSet::checkExtraFeatures(PreflightContext const& ctx)
{
if (!ctx.rules.enabled(featureSingleAssetVault))
return false;
return !ctx.tx.isFieldPresent(sfDomainID) ||
ctx.rules.enabled(featurePermissionedDomains);
}

View File

@@ -34,7 +34,7 @@ public:
}
static bool
isEnabled(PreflightContext const& ctx);
checkExtraFeatures(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -30,12 +30,6 @@
namespace ripple {
bool
VaultWithdraw::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureSingleAssetVault);
}
NotTEC
VaultWithdraw::preflight(PreflightContext const& ctx)
{

View File

@@ -33,9 +33,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);

View File

@@ -1367,12 +1367,6 @@ attestationDoApply(ApplyContext& ctx)
} // namespace
//------------------------------------------------------------------------------
bool
XChainCreateBridge::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainCreateBridge::preflight(PreflightContext const& ctx)
{
@@ -1545,12 +1539,6 @@ XChainCreateBridge::doApply()
//------------------------------------------------------------------------------
bool
BridgeModify::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
std::uint32_t
BridgeModify::getFlagsMask(PreflightContext const& ctx)
{
@@ -1658,12 +1646,6 @@ BridgeModify::doApply()
//------------------------------------------------------------------------------
bool
XChainClaim::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainClaim::preflight(PreflightContext const& ctx)
{
@@ -1893,12 +1875,6 @@ XChainCommit::makeTxConsequences(PreflightContext const& ctx)
return TxConsequences{ctx.tx, maxSpend};
}
bool
XChainCommit::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainCommit::preflight(PreflightContext const& ctx)
{
@@ -2004,12 +1980,6 @@ XChainCommit::doApply()
//------------------------------------------------------------------------------
bool
XChainCreateClaimID::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainCreateClaimID::preflight(PreflightContext const& ctx)
{
@@ -2116,12 +2086,6 @@ XChainCreateClaimID::doApply()
//------------------------------------------------------------------------------
bool
XChainAddClaimAttestation::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainAddClaimAttestation::preflight(PreflightContext const& ctx)
{
@@ -2142,12 +2106,6 @@ XChainAddClaimAttestation::doApply()
//------------------------------------------------------------------------------
bool
XChainAddAccountCreateAttestation::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainAddAccountCreateAttestation::preflight(PreflightContext const& ctx)
{
@@ -2168,12 +2126,6 @@ XChainAddAccountCreateAttestation::doApply()
//------------------------------------------------------------------------------
bool
XChainCreateAccountCommit::isEnabled(PreflightContext const& ctx)
{
return ctx.rules.enabled(featureXChainBridge);
}
NotTEC
XChainCreateAccountCommit::preflight(PreflightContext const& ctx)
{

View File

@@ -39,9 +39,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);
@@ -61,9 +58,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static std::uint32_t
getFlagsMask(PreflightContext const& ctx);
@@ -100,9 +94,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);
@@ -130,9 +121,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);
@@ -162,9 +150,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);
@@ -194,9 +179,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);
@@ -218,9 +200,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);
@@ -265,9 +244,6 @@ public:
{
}
static bool
isEnabled(PreflightContext const& ctx);
static NotTEC
preflight(PreflightContext const& ctx);