fix all the build issues

This commit is contained in:
Mayukha Vadari
2026-03-16 21:48:12 -04:00
parent 4157e3684c
commit a8987cf271
49 changed files with 466 additions and 329 deletions

View File

@@ -157,7 +157,7 @@ canWithdraw(
ReadView const& view,
AccountID const& from,
AccountID const& to,
SLE::const_ref toSle,
WrappedAccountRoot const& toWrapped,
STAmount const& amount,
bool hasDestinationTag);

View File

@@ -4,7 +4,7 @@
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/ledger/entries/WrappedSLEBase.h>
#include <xrpl/ledger/helpers/WrappedSLEBase.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/Rate.h>
#include <xrpl/protocol/STLedgerEntry.h>
@@ -22,20 +22,34 @@ protected:
AccountID const id_;
public:
WrappedAccountRoot() = default;
WrappedAccountRoot(AccountID const& id, ReadView const* view)
: WrappedSLEBase(view->read(keylet::account(id)), view), id_(sle_ ? (*sle_)[sfAccount] : id)
{
}
WrappedAccountRoot(AccountID const& id, ApplyView* view)
: WrappedSLEBase(view->peek(keylet::account(id)), view), id_(sle_ ? (*sle_)[sfAccount] : id)
{
}
AccountID const&
id() const
{
return id_;
}
/** Check if the issuer has the global freeze flag set.
@return true if the account has global freeze set
*/
[[nodiscard]] bool
isGlobalFrozen();
isGlobalFrozen() const;
/** Returns IOU issuer transfer fee as Rate. Rate specifies
* the fee as fractions of 1 billion. For example, 1% transfer rate
* is represented as 1,010,000,000.
*/
[[nodiscard]] Rate
transferRate();
transferRate() const;
// Calculate liquid XRP balance for an account.
// This function may be used to calculate the amount of XRP that
@@ -59,7 +73,7 @@ public:
- If the SLE requires a destination tag, checks that there is a tag.
*/
[[nodiscard]] TER
checkDestinationAndTag(SLE::const_ref toSle, bool hasDestinationTag);
checkDestinationAndTag(bool hasDestinationTag) const;
};
/** Generate a pseudo-account address from a pseudo owner key.

View File

@@ -3,6 +3,7 @@
#include <xrpl/beast/utility/Journal.h>
#include <xrpl/ledger/ApplyView.h>
#include <xrpl/ledger/ReadView.h>
#include <xrpl/ledger/helpers/AccountRootHelpers.h>
#include <xrpl/ledger/helpers/TokenHelpers.h>
#include <xrpl/protocol/IOUAmount.h>
#include <xrpl/protocol/Issue.h>
@@ -137,16 +138,16 @@ trustCreate(
bool const bSrcHigh,
AccountID const& uSrcAccountID,
AccountID const& uDstAccountID,
uint256 const& uIndex, // --> ripple state entry
SLE::ref sleAccount, // --> the account being set.
bool const bAuth, // --> authorize account.
bool const bNoRipple, // --> others cannot ripple through
bool const bFreeze, // --> funds cannot leave
bool bDeepFreeze, // --> can neither receive nor send funds
STAmount const& saBalance, // --> balance of account being set.
// Issuer should be noAccount()
STAmount const& saLimit, // --> limit for account being set.
// Issuer should be the account being set.
uint256 const& uIndex, // --> ripple state entry
WrappedAccountRoot const& wrappedAcct, // --> the account being set.
bool const bAuth, // --> authorize account.
bool const bNoRipple, // --> others cannot ripple through
bool const bFreeze, // --> funds cannot leave
bool bDeepFreeze, // --> can neither receive nor send funds
STAmount const& saBalance, // --> balance of account being set.
// Issuer should be noAccount()
STAmount const& saLimit, // --> limit for account being set.
// Issuer should be the account being set.
std::uint32_t uQualityIn,
std::uint32_t uQualityOut,
beast::Journal j);

View File

@@ -24,6 +24,14 @@ class WrappedSLEBase
public:
virtual ~WrappedSLEBase() = default;
// Explicitly default copy/move operations
WrappedSLEBase(WrappedSLEBase const&) = default;
WrappedSLEBase(WrappedSLEBase&&) = default;
WrappedSLEBase&
operator=(WrappedSLEBase const&) = default;
WrappedSLEBase&
operator=(WrappedSLEBase&&) = default;
/** Returns true if the ledger entry exists */
bool
exists() const
@@ -38,13 +46,27 @@ public:
return exists();
}
/** Returns the underlying SLE for raw access when needed */
/** Returns the underlying SLE for read access (always available) */
std::shared_ptr<SLE const> const&
sle() const
{
return sle_;
}
/** Returns a mutable SLE for write operations
*
* @throws std::logic_error if called in a read-only context
*/
std::shared_ptr<SLE> const&
mutableSle() const
{
if (!mutableSle_)
{
throw std::logic_error("Cannot modify SLE in read-only context");
}
return mutableSle_;
}
/** Returns the read view (always available) */
ReadView const*
readView() const
@@ -73,12 +95,24 @@ public:
return applyView_;
}
STLedgerEntry*
operator->()
{
return mutableSle_.get();
}
STLedgerEntry const*
operator->() const
{
return sle_.get();
}
STLedgerEntry&
operator*()
{
return *mutableSle_;
}
STLedgerEntry const&
operator*() const
{
@@ -95,15 +129,16 @@ protected:
}
/** Constructor for read-write context (ApplyView) */
explicit WrappedSLEBase(std::shared_ptr<SLE const> sle, ApplyView* view)
: sle_(std::move(sle)), readView_(view), applyView_(view)
explicit WrappedSLEBase(std::shared_ptr<SLE> sle, ApplyView* view)
: sle_(sle), mutableSle_(std::move(sle)), readView_(view), applyView_(view)
{
// ApplyView inherits from ReadView, so we can use it for both
}
std::shared_ptr<SLE const> sle_;
ReadView const* readView_;
ApplyView* applyView_; // nullptr for read-only contexts
std::shared_ptr<SLE const> sle_; // Always valid (const view)
std::shared_ptr<SLE> mutableSle_; // nullptr for read-only contexts
ReadView const* readView_; // Always valid
ApplyView* applyView_; // nullptr for read-only contexts
};
} // namespace xrpl

View File

@@ -475,4 +475,15 @@ loanMakePayment(
LoanPaymentType const paymentType,
beast::Journal j);
// LoanBroker-specific `adjustOwnerCount` function (temporary, while the Wrapped classes are WIP)
// Assert will check the type, so that we ensure it's not used by anything else
// Order of parameters is different from the old `adjustOwnerCount` function to avoid anything
// accidentally calling this with the wrong type.
void
adjustOwnerCount(
std::shared_ptr<SLE> const& sle,
ApplyView& view,
std::int32_t amount,
beast::Journal j);
} // namespace xrpl