refactor EscrowCancel

This commit is contained in:
Mayukha Vadari
2026-03-22 11:30:47 -07:00
parent 458dce37b6
commit 1a822da112
5 changed files with 39 additions and 1 deletions

View File

@@ -130,6 +130,14 @@ public:
[[nodiscard]] bool
requiresAuth() const override;
[[nodiscard]] TER
checkExists() const override
{
if (!exists())
return tecOBJECT_NOT_FOUND;
return tesSUCCESS;
}
[[nodiscard]] bool
hasHolder(AccountID const& holder) const override
{

View File

@@ -132,6 +132,14 @@ public:
[[nodiscard]] bool
requiresAuth() const override;
[[nodiscard]] TER
checkExists() const override
{
if (!exists())
return tecNO_ISSUER;
return tesSUCCESS;
}
[[nodiscard]] bool
hasHolder(AccountID const& holder) const override
{

View File

@@ -160,6 +160,9 @@ public:
[[nodiscard]] virtual bool
requiresAuth() const = 0;
[[nodiscard]] virtual TER
checkExists() const = 0;
[[nodiscard]] virtual bool
hasHolder(AccountID const& holder) const = 0;

View File

@@ -16,6 +16,7 @@
// Add new amendments to the top of this list.
// Keep it sorted in reverse chronological order.
XRPL_FIX (TypeSafetyRefactor, Supported::no, VoteBehavior::DefaultNo)
XRPL_FIX (PermissionedDomainInvariant, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (ExpiredNFTokenOfferRemoval, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (BatchInnerSigs, Supported::no, VoteBehavior::DefaultNo)

View File

@@ -82,13 +82,31 @@ EscrowCancel::preclaim(PreclaimContext const& ctx)
if (!isXRP(amount))
{
if (auto const ret = std::visit(
if (ctx.view.rules().enabled(fixTypeSafetyRefactor))
{
AccountID issuer = amount.getIssuer();
// If the issuer is the same as the account, return tecINTERNAL
if (issuer == account)
return tecINTERNAL; // LCOV_EXCL_LINE
auto const token = makeTokenBase(ctx.view, amount.issue());
if (auto const ter = token->checkExists(); !isTesSuccess(ter))
return ter;
if (auto const ter = token->requireAuth(account, AuthType::WeakAuth);
!isTesSuccess(ter))
return ter;
}
else if (
auto const ret = std::visit(
[&]<typename T>(T const&) {
return escrowCancelPreclaimHelper<T>(ctx, account, amount);
},
amount.asset().value());
!isTesSuccess(ret))
{
return ret;
}
}
}
return tesSUCCESS;