Skip to content

Commit

Permalink
Fix clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Jul 1, 2024
1 parent d1332ec commit a1fb803
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 28 deletions.
23 changes: 17 additions & 6 deletions include/xrpl/protocol/STAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,14 @@ class STAmount final : public STBase, public CountedObject<STAmount>
operator+(STAmount const& v1, STAmount const& v2);
};

class STMPTAmount: public STBase, public CountedObject<STMPTAmount>
class STMPTAmount : public STBase, public CountedObject<STMPTAmount>
{
private:
public:
STMPTAmount() = default;
STMPTAmount(SerialIter& sit, SField const& name) {}
STMPTAmount(SerialIter& sit, SField const& name)
{
}
SerializedTypeID
getSType() const override
{
Expand Down Expand Up @@ -348,13 +350,22 @@ class STEitherAmount : public STBase, public CountedObject<STEitherAmount>
{
private:
std::variant<STAmount, STMPTAmount> amount_;

public:
using value_type = STAmount;
STEitherAmount() = default;
STEitherAmount(SerialIter& sit, SField const& name) {}
STEitherAmount(XRPAmount const& amount) : amount_{amount} {}
STEitherAmount(STAmount const& amount) : amount_{amount} {}
STEitherAmount(STMPTAmount const& amount) : amount_{amount} {}
STEitherAmount(SerialIter& sit, SField const& name)
{
}
STEitherAmount(XRPAmount const& amount) : amount_{amount}
{
}
STEitherAmount(STAmount const& amount) : amount_{amount}
{
}
STEitherAmount(STMPTAmount const& amount) : amount_{amount}
{
}
SerializedTypeID
getSType() const override
{
Expand Down
1 change: 0 additions & 1 deletion src/libxrpl/protocol/STAmount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,6 @@ amountFromJsonNoThrow(STEitherAmount& result, Json::Value const& jvSource)
return true;
}


//------------------------------------------------------------------------------
//
// Operators
Expand Down
4 changes: 2 additions & 2 deletions src/libxrpl/protocol/STParsedJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,8 @@ parseLeaf(
case STI_AMOUNT:
try
{
ret =
detail::make_stvar<STEitherAmount>(amountFromJson(field, value));
ret = detail::make_stvar<STEitherAmount>(
amountFromJson(field, value));
}
catch (std::exception const&)
{
Expand Down
6 changes: 3 additions & 3 deletions src/test/jtx/impl/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,14 @@ MPTTester::pay(
}
else
{
STAmount const saAmount = Issue{};//{*mpt_, amount};
STAmount const saAmount = Issue{}; //{*mpt_, amount};
STAmount const saActual =
multiply(saAmount, transferRateMPT(*env_.current(), *mpt_));
// Sender pays the transfer fee if any
//env_.require(mptpay(*this, src, srcAmt - saActual.mpt().mpt()));
// env_.require(mptpay(*this, src, srcAmt - saActual.mpt().mpt()));
env_.require(mptpay(*this, dest, destAmt + amount));
// Outstanding amount is reduced by the transfer fee if any
//env_.require(mptpay(
// env_.require(mptpay(
// *this, issuer_, outstnAmt - (saActual - saAmount).mpt().mpt()));
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/jtx/impl/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ paths::operator()(Env& env, JTx& jt) const
auto& jv = jt.jv;
auto const from = env.lookup(jv[jss::Account].asString());
auto const to = env.lookup(jv[jss::Destination].asString());
auto const amount = static_cast<STAmount>(amountFromJson(sfAmount, jv[jss::Amount]));
auto const amount =
static_cast<STAmount>(amountFromJson(sfAmount, jv[jss::Amount]));
Pathfinder pf(
std::make_shared<RippleLineCache>(
env.current(), env.app().journal("RippleLineCache")),
Expand Down
6 changes: 4 additions & 2 deletions src/test/protocol/STAmount_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,8 @@ class STAmount_test : public beast::unit_test::suite
for (std::uint64_t drops = 100000000000000000; drops != 1;
drops = drops / 10)
{
auto const t = static_cast<STAmount>(amountFromString(xrp, std::to_string(drops)));
auto const t = static_cast<STAmount>(
amountFromString(xrp, std::to_string(drops)));
auto const s = t.xrp();
BEAST_EXPECT(s.drops() == drops);
BEAST_EXPECT(t == STAmount(XRPAmount(drops)));
Expand All @@ -625,7 +626,8 @@ class STAmount_test : public beast::unit_test::suite

try
{
auto const t = static_cast<STAmount>(amountFromString(usd, "136500"));
auto const t =
static_cast<STAmount>(amountFromString(usd, "136500"));
fail(to_string(t.xrp()));
}
catch (std::logic_error const&)
Expand Down
21 changes: 11 additions & 10 deletions src/xrpld/app/tx/detail/Clawback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ Clawback::preflight(PreflightContext const& ctx)
if (issuer == holder)
return temMALFORMED;

//if (clawAmount.mpt() > MPTAmount{maxMPTokenAmount} ||
// clawAmount <= beast::zero)
return temBAD_AMOUNT;
// if (clawAmount.mpt() > MPTAmount{maxMPTokenAmount} ||
// clawAmount <= beast::zero)
return temBAD_AMOUNT;
}
else
{
//if (issuer == holder || isXRP(clawAmount) || clawAmount <= beast::zero)
return temBAD_AMOUNT;
// if (issuer == holder || isXRP(clawAmount) || clawAmount <=
// beast::zero)
return temBAD_AMOUNT;
}

return preflight2(ctx);
Expand Down Expand Up @@ -116,7 +117,7 @@ Clawback::preclaim(PreclaimContext const& ctx)
fhIGNORE_FREEZE,
ahIGNORE_AUTH,
ctx.j) <= beast::zero)*/
return tecINSUFFICIENT_FUNDS;
return tecINSUFFICIENT_FUNDS;
}
else
{
Expand Down Expand Up @@ -159,7 +160,7 @@ Clawback::preclaim(PreclaimContext const& ctx)
issuer,
fhIGNORE_FREEZE,
ctx.j) <= beast::zero)*/
return tecINSUFFICIENT_FUNDS;
return tecINSUFFICIENT_FUNDS;
}

return tesSUCCESS;
Expand All @@ -170,10 +171,10 @@ Clawback::doApply()
{
AccountID const& issuer = account_;
STAmount clawAmount = ctx_.tx[sfAmount];
AccountID const holder = //clawAmount.isMPT()
//? ctx_.tx[sfMPTokenHolder] :
AccountID const holder = // clawAmount.isMPT()
//? ctx_.tx[sfMPTokenHolder] :
clawAmount.getIssuer(); // cannot be reference because clawAmount is
// modified beblow
// modified beblow

/*if (clawAmount.isMPT())
{
Expand Down
6 changes: 3 additions & 3 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ accountSend(
}
else
{
//assert(saAmount >= beast::zero && !saAmount.isMPT());
// assert(saAmount >= beast::zero && !saAmount.isMPT());
}

/* If we aren't sending anything or if the sender is the same as the
Expand Down Expand Up @@ -1397,15 +1397,15 @@ accountSendMPT(
beast::Journal j,
WaiveTransferFee waiveFee)
{
//assert(saAmount >= beast::zero && saAmount.isMPT());
// assert(saAmount >= beast::zero && saAmount.isMPT());

/* If we aren't sending anything or if the sender is the same as the
* receiver then we don't need to do anything.
*/
if (!saAmount || (uSenderID == uReceiverID))
return tesSUCCESS;

//STAmount saActual{saAmount.asset()};
// STAmount saActual{saAmount.asset()};
STAmount saActual{};

return rippleSendMPT(
Expand Down

0 comments on commit a1fb803

Please sign in to comment.