From 640b231f5fba9d00b3faff44c08d7a4e10ac312c Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Sat, 21 Mar 2026 22:02:08 -0700 Subject: [PATCH] add some more helper functions --- include/xrpl/ledger/helpers/MPTokenHelpers.h | 12 +++++++++++ .../xrpl/ledger/helpers/RippleStateHelpers.h | 12 +++++++++++ include/xrpl/ledger/helpers/TokenHelpers.h | 20 +++++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/xrpl/ledger/helpers/MPTokenHelpers.h b/include/xrpl/ledger/helpers/MPTokenHelpers.h index f51e71a495..d2ed0faef6 100644 --- a/include/xrpl/ledger/helpers/MPTokenHelpers.h +++ b/include/xrpl/ledger/helpers/MPTokenHelpers.h @@ -118,6 +118,18 @@ public: [[nodiscard]] TER canTransfer(AccountID const& from, AccountID const& to) const override; + //------------------------------------------------------------------------------ + // + // Token capability checks (MPT-specific) + // + //------------------------------------------------------------------------------ + + [[nodiscard]] bool + canClawback() const override; + + [[nodiscard]] bool + requiresAuth() const override; + STAmount accountHolds( AccountID const& account, diff --git a/include/xrpl/ledger/helpers/RippleStateHelpers.h b/include/xrpl/ledger/helpers/RippleStateHelpers.h index 83a9f8abc2..d20401efbe 100644 --- a/include/xrpl/ledger/helpers/RippleStateHelpers.h +++ b/include/xrpl/ledger/helpers/RippleStateHelpers.h @@ -95,6 +95,18 @@ public: [[nodiscard]] TER canTransfer(AccountID const& from, AccountID const& to) const override; + //------------------------------------------------------------------------------ + // + // Token capability checks (IOU-specific) + // + //------------------------------------------------------------------------------ + + [[nodiscard]] bool + canClawback() const override; + + [[nodiscard]] bool + requiresAuth() const override; + protected: Issue const issue_; AccountID const issuer_; diff --git a/include/xrpl/ledger/helpers/TokenHelpers.h b/include/xrpl/ledger/helpers/TokenHelpers.h index e880ecb299..388bb8e96a 100644 --- a/include/xrpl/ledger/helpers/TokenHelpers.h +++ b/include/xrpl/ledger/helpers/TokenHelpers.h @@ -140,6 +140,26 @@ public: [[nodiscard]] virtual TER canTransfer(AccountID const& from, AccountID const& to) const = 0; + //------------------------------------------------------------------------------ + // + // Token capability checks (Asset-based dispatchers) + // + //------------------------------------------------------------------------------ + + /** Check if the token issuer has enabled clawback capability. + * For IOUs, checks lsfAllowTrustLineClawback on issuer's AccountRoot. + * For MPTs, checks lsfMPTCanClawback on the issuance. + */ + [[nodiscard]] virtual bool + canClawback() const = 0; + + /** Check if the token requires authorization for holders. + * For IOUs, checks lsfRequireAuth on issuer's AccountRoot. + * For MPTs, checks lsfMPTRequireAuth on the issuance. + */ + [[nodiscard]] virtual bool + requiresAuth() const = 0; + protected: TokenBase(ReadView const& view, std::shared_ptr sle) : ReadOnlySLE(sle, view) {