diff --git a/include/xrpl/ledger/helpers/MPTokenHelpers.h b/include/xrpl/ledger/helpers/MPTokenHelpers.h index 19ab93ac9c..538ff618ac 100644 --- a/include/xrpl/ledger/helpers/MPTokenHelpers.h +++ b/include/xrpl/ledger/helpers/MPTokenHelpers.h @@ -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 { diff --git a/include/xrpl/ledger/helpers/RippleStateHelpers.h b/include/xrpl/ledger/helpers/RippleStateHelpers.h index 5090684cb0..e3072bade0 100644 --- a/include/xrpl/ledger/helpers/RippleStateHelpers.h +++ b/include/xrpl/ledger/helpers/RippleStateHelpers.h @@ -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 { diff --git a/include/xrpl/ledger/helpers/TokenHelpers.h b/include/xrpl/ledger/helpers/TokenHelpers.h index bb9e2919c2..c286214255 100644 --- a/include/xrpl/ledger/helpers/TokenHelpers.h +++ b/include/xrpl/ledger/helpers/TokenHelpers.h @@ -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; diff --git a/include/xrpl/protocol/detail/features.macro b/include/xrpl/protocol/detail/features.macro index a40d524c70..6c034ffc6e 100644 --- a/include/xrpl/protocol/detail/features.macro +++ b/include/xrpl/protocol/detail/features.macro @@ -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) diff --git a/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp b/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp index e324e0abaf..014ae73784 100644 --- a/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp +++ b/src/libxrpl/tx/transactors/escrow/EscrowCancel.cpp @@ -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( [&](T const&) { return escrowCancelPreclaimHelper(ctx, account, amount); }, amount.asset().value()); !isTesSuccess(ret)) + { return ret; + } } } return tesSUCCESS;