mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'ximinez/lending-XLS-66' into ximinez/lending-enabled
This commit is contained in:
@@ -62,15 +62,9 @@ public:
|
||||
explicit constexpr
|
||||
operator bool() const noexcept;
|
||||
|
||||
operator Number() const
|
||||
operator Number() const noexcept
|
||||
{
|
||||
return {value(), Number::strong};
|
||||
}
|
||||
|
||||
Number
|
||||
toNumber(Number::EnforceInteger enforce) const
|
||||
{
|
||||
return {value(), enforce};
|
||||
return value();
|
||||
}
|
||||
|
||||
/** Return the sign of the amount */
|
||||
|
||||
@@ -40,12 +40,6 @@ private:
|
||||
exponent_type mOffset;
|
||||
bool mIsNegative;
|
||||
|
||||
// The Enforce integer setting is not stored or serialized. If set, it is
|
||||
// used during automatic conversions to Number. If not set, the default
|
||||
// behavior is used. It can also be overridden when coverting by using
|
||||
// toNumber().
|
||||
std::optional<Number::EnforceInteger> enforceConversion_;
|
||||
|
||||
public:
|
||||
using value_type = STAmount;
|
||||
|
||||
@@ -143,28 +137,9 @@ public:
|
||||
STAmount(A const& asset, int mantissa, int exponent = 0);
|
||||
|
||||
template <AssetType A>
|
||||
STAmount(
|
||||
A const& asset,
|
||||
Number const& number,
|
||||
std::optional<Number::EnforceInteger> enforce = std::nullopt)
|
||||
STAmount(A const& asset, Number const& number)
|
||||
: STAmount(asset, number.mantissa(), number.exponent())
|
||||
{
|
||||
enforceConversion_ = enforce;
|
||||
if (!enforce)
|
||||
{
|
||||
// Use the default conversion behavior
|
||||
[[maybe_unused]]
|
||||
Number const n = *this;
|
||||
}
|
||||
else if (enforce == Number::strong)
|
||||
{
|
||||
// Throw if it's not valid
|
||||
if (!validNumber())
|
||||
{
|
||||
Throw<std::overflow_error>(
|
||||
"STAmount::STAmount integer Number lost precision");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy support for new-style amounts
|
||||
@@ -172,17 +147,6 @@ public:
|
||||
STAmount(XRPAmount const& amount);
|
||||
STAmount(MPTAmount const& amount, MPTIssue const& mptIssue);
|
||||
operator Number() const;
|
||||
Number
|
||||
toNumber(Number::EnforceInteger enforce) const;
|
||||
|
||||
void
|
||||
setIntegerEnforcement(std::optional<Number::EnforceInteger> enforce);
|
||||
|
||||
std::optional<Number::EnforceInteger>
|
||||
integerEnforcement() const noexcept;
|
||||
|
||||
bool
|
||||
validNumber() const noexcept;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//
|
||||
@@ -557,8 +521,6 @@ inline STAmount::operator bool() const noexcept
|
||||
|
||||
inline STAmount::operator Number() const
|
||||
{
|
||||
if (enforceConversion_)
|
||||
return toNumber(*enforceConversion_);
|
||||
if (native())
|
||||
return xrp();
|
||||
if (mAsset.holds<MPTIssue>())
|
||||
@@ -566,17 +528,6 @@ inline STAmount::operator Number() const
|
||||
return iou();
|
||||
}
|
||||
|
||||
inline Number
|
||||
STAmount::toNumber(Number::EnforceInteger enforce) const
|
||||
{
|
||||
if (native())
|
||||
return xrp().toNumber(enforce);
|
||||
if (mAsset.holds<MPTIssue>())
|
||||
return mpt().toNumber(enforce);
|
||||
// It doesn't make sense to enforce limits on IOUs
|
||||
return iou();
|
||||
}
|
||||
|
||||
inline STAmount&
|
||||
STAmount::operator=(beast::Zero)
|
||||
{
|
||||
@@ -598,11 +549,6 @@ STAmount::operator=(Number const& number)
|
||||
mValue = mIsNegative ? -number.mantissa() : number.mantissa();
|
||||
mOffset = number.exponent();
|
||||
canonicalize();
|
||||
|
||||
// Convert it back to a Number to check that it's valid
|
||||
[[maybe_unused]]
|
||||
Number n = *this;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -618,7 +564,7 @@ STAmount::clear()
|
||||
{
|
||||
// The -100 is used to allow 0 to sort less than a small positive values
|
||||
// which have a negative exponent.
|
||||
mOffset = integral() ? 0 : -100;
|
||||
mOffset = native() ? 0 : -100;
|
||||
mValue = 0;
|
||||
mIsNegative = false;
|
||||
}
|
||||
|
||||
@@ -56,18 +56,6 @@ public:
|
||||
bool
|
||||
isDefault() const override;
|
||||
|
||||
/// Sets the flag on the underlying number
|
||||
void
|
||||
setIntegerEnforcement(Number::EnforceInteger enforce);
|
||||
|
||||
/// Gets the flag value on the underlying number
|
||||
Number::EnforceInteger
|
||||
integerEnforcement() const noexcept;
|
||||
|
||||
/// Checks the underlying number
|
||||
bool
|
||||
valid() const noexcept;
|
||||
|
||||
operator Number() const
|
||||
{
|
||||
return value_;
|
||||
|
||||
@@ -23,7 +23,6 @@ systemName()
|
||||
|
||||
/** Number of drops in the genesis account. */
|
||||
constexpr XRPAmount INITIAL_XRP{100'000'000'000 * DROPS_PER_XRP};
|
||||
static_assert(INITIAL_XRP.drops() == 100'000'000'000'000'000);
|
||||
|
||||
/** Returns true if the amount does not exceed the initial XRP in existence. */
|
||||
inline bool
|
||||
|
||||
@@ -143,13 +143,7 @@ public:
|
||||
|
||||
operator Number() const noexcept
|
||||
{
|
||||
return {drops(), Number::compatible};
|
||||
}
|
||||
|
||||
Number
|
||||
toNumber(Number::EnforceInteger enforce) const
|
||||
{
|
||||
return {value(), enforce};
|
||||
return drops();
|
||||
}
|
||||
|
||||
/** Return the sign of the amount */
|
||||
|
||||
@@ -480,10 +480,10 @@ LEDGER_ENTRY(ltVAULT, 0x0084, Vault, vault, ({
|
||||
{sfAccount, soeREQUIRED},
|
||||
{sfData, soeOPTIONAL},
|
||||
{sfAsset, soeREQUIRED},
|
||||
{sfAssetsTotal, soeDEFAULT},
|
||||
{sfAssetsAvailable, soeDEFAULT},
|
||||
{sfAssetsTotal, soeREQUIRED},
|
||||
{sfAssetsAvailable, soeREQUIRED},
|
||||
{sfAssetsMaximum, soeDEFAULT},
|
||||
{sfLossUnrealized, soeDEFAULT},
|
||||
{sfLossUnrealized, soeREQUIRED},
|
||||
{sfShareMPTID, soeREQUIRED},
|
||||
{sfWithdrawalPolicy, soeREQUIRED},
|
||||
{sfScale, soeDEFAULT},
|
||||
|
||||
Reference in New Issue
Block a user