Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Dec 8, 2024
1 parent 5771e20 commit 64b6d7a
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 91 deletions.
27 changes: 0 additions & 27 deletions include/xrpl/protocol/Asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ class Asset
friend constexpr bool
operator==(Asset const& lhs, Asset const& rhs);

friend constexpr bool
operator!=(Asset const& lhs, Asset const& rhs);

friend constexpr bool
operator<(Asset const& lhs, Asset const& rhs);

friend constexpr std::weak_ordering
operator<=>(Asset const& lhs, Asset const& rhs);

Expand Down Expand Up @@ -160,27 +154,6 @@ operator==(Asset const& lhs, Asset const& rhs)
rhs.issue_);
}

constexpr bool
operator!=(Asset const& lhs, Asset const& rhs)
{
return !(lhs == rhs);
}

constexpr bool
operator<(Asset const& lhs, Asset const& rhs)
{
return std::visit(
[&]<typename TLhs, typename TRhs>(
TLhs const& issLhs, TRhs const& issRhs) {
if constexpr (std::is_same_v<TLhs, TRhs>)
return issLhs < issRhs;
else
return false;
},
lhs.issue_,
rhs.issue_);
}

constexpr bool
operator==(Currency const& lhs, Asset const& rhs)
{
Expand Down
25 changes: 1 addition & 24 deletions include/xrpl/protocol/MPTIssue.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,39 +53,16 @@ class MPTIssue
void
setJson(Json::Value& jv) const;

auto
constexpr std::weak_ordering
operator<=>(MPTIssue const&) const = default;

bool
native() const
{
return false;
}

friend constexpr std::weak_ordering
operator<=>(MPTIssue const& lhs, MPTIssue const& rhs);
};

constexpr bool
operator==(MPTIssue const& lhs, MPTIssue const& rhs)
{
return lhs.mptID_ == rhs.mptID_;
}

constexpr bool
operator!=(MPTIssue const& lhs, MPTIssue const& rhs)
{
return !(lhs == rhs);
}

constexpr std::weak_ordering
operator<=>(MPTIssue const& lhs, MPTIssue const& rhs)
{
if (auto const c{lhs.mptID_ <=> rhs.mptID_}; c != 0)
return c;
return lhs.mptID_ <=> rhs.mptID_;
}

/** MPT is a non-native token.
*/
inline bool
Expand Down
24 changes: 12 additions & 12 deletions include/xrpl/protocol/detail/transactions.macro
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ TRANSACTION(ttCLAWBACK, 30, Clawback, ({
/** This transaction claws back tokens from an AMM pool. */
TRANSACTION(ttAMM_CLAWBACK, 31, AMMClawback, ({
{sfHolder, soeREQUIRED},
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfAsset, soeREQUIRED, soeMPTSupported},
{sfAsset2, soeREQUIRED, soeMPTSupported},
{sfAmount, soeOPTIONAL, soeMPTSupported},
}))

Expand All @@ -250,8 +250,8 @@ TRANSACTION(ttAMM_CREATE, 35, AMMCreate, ({

/** This transaction type deposits into an AMM instance */
TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, ({
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfAsset, soeREQUIRED, soeMPTSupported},
{sfAsset2, soeREQUIRED, soeMPTSupported},
{sfAmount, soeOPTIONAL, soeMPTSupported},
{sfAmount2, soeOPTIONAL, soeMPTSupported},
{sfEPrice, soeOPTIONAL},
Expand All @@ -261,8 +261,8 @@ TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, ({

/** This transaction type withdraws from an AMM instance */
TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, ({
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfAsset, soeREQUIRED, soeMPTSupported},
{sfAsset2, soeREQUIRED, soeMPTSupported},
{sfAmount, soeOPTIONAL, soeMPTSupported},
{sfAmount2, soeOPTIONAL, soeMPTSupported},
{sfEPrice, soeOPTIONAL},
Expand All @@ -271,24 +271,24 @@ TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, ({

/** This transaction type votes for the trading fee */
TRANSACTION(ttAMM_VOTE, 38, AMMVote, ({
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfAsset, soeREQUIRED, soeMPTSupported},
{sfAsset2, soeREQUIRED, soeMPTSupported},
{sfTradingFee, soeREQUIRED},
}))

/** This transaction type bids for the auction slot */
TRANSACTION(ttAMM_BID, 39, AMMBid, ({
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfAsset, soeREQUIRED, soeMPTSupported},
{sfAsset2, soeREQUIRED, soeMPTSupported},
{sfBidMin, soeOPTIONAL},
{sfBidMax, soeOPTIONAL},
{sfAuthAccounts, soeOPTIONAL},
}))

/** This transaction type deletes AMM in the empty state */
TRANSACTION(ttAMM_DELETE, 40, AMMDelete, ({
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfAsset, soeREQUIRED, soeMPTSupported},
{sfAsset2, soeREQUIRED, soeMPTSupported},
}))

/** This transactions creates a crosschain sequence number */
Expand Down
1 change: 1 addition & 0 deletions src/libxrpl/protocol/MPTIssue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//==============================================================================

#include <xrpl/json/json_errors.h>
#include <xrpl/protocol/Indexes.h>
#include <xrpl/protocol/MPTIssue.h>
#include <xrpl/protocol/jss.h>

Expand Down
5 changes: 1 addition & 4 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1544,9 +1544,6 @@ class MPToken_test : public beast::unit_test::suite
jrr = env.rpc("json", "sign", to_string(jv1));
BEAST_EXPECT(jrr[jss::result][jss::error] == "invalidParams");
};
auto toSFieldRef = [](SField const& field) {
return std::ref(field);
};
auto setMPTFields = [&](SField const& field,
Json::Value& jv,
bool withAmount = true) {
Expand Down Expand Up @@ -3139,7 +3136,7 @@ class MPToken_test : public beast::unit_test::suite
mpt.authorize({.account = alice});
mpt.pay(gw, alice, 1'000);
AMM amm(env, gw, MPT(100), XRP(100));
amm.deposit(DepositArg{.account = alice, .tokens = 100});
amm.deposit(DepositArg{.account = alice, .tokens = 10'000});
amm::ammClawback(
gw, alice, MPTIssue(mpt.issuanceID()), xrpIssue(), MPT(10));
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/paths/detail/MPTEndpointStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include <xrpld/app/paths/detail/Steps.h>
#include <xrpld/ledger/PaymentSandbox.h>
#include <xrpl/basics/Log.h>
#include <xrpl/basics/MPTAmount.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/MPTAmount.h>
#include <xrpl/protocol/Quality.h>

#include <boost/container/flat_set.hpp>
Expand Down
3 changes: 1 addition & 2 deletions src/xrpld/app/tx/detail/AMMBid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ AMMBid::preflight(PreflightContext const& ctx)
return temINVALID_FLAG;
}

if (auto const res = invalidAMMAssetPair(
ctx.tx[sfAsset].get<Issue>(), ctx.tx[sfAsset2].get<Issue>()))
if (auto const res = invalidAMMAssetPair(ctx.tx[sfAsset], ctx.tx[sfAsset2]))
{
JLOG(ctx.j.debug()) << "AMM Bid: Invalid asset pair.";
return res;
Expand Down
10 changes: 5 additions & 5 deletions src/xrpld/app/tx/detail/AMMClawback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ AMMClawback::preflight(PreflightContext const& ctx)
return temMALFORMED;
}

auto const asset = ctx.tx[sfAsset].get<Issue>();
auto const asset2 = ctx.tx[sfAsset2].get<Issue>();
auto const asset = ctx.tx[sfAsset];
auto const asset2 = ctx.tx[sfAsset2];

if (isXRP(asset))
return temMALFORMED;
Expand All @@ -82,7 +82,7 @@ AMMClawback::preflight(PreflightContext const& ctx)
return temMALFORMED;
}

if (clawAmount && clawAmount->get<Issue>() != asset)
if (clawAmount && clawAmount->issue() != asset)
{
JLOG(ctx.j.trace()) << "AMMClawback: Amount's issuer/currency subfield "
"does not match Asset field";
Expand All @@ -98,8 +98,8 @@ AMMClawback::preflight(PreflightContext const& ctx)
TER
AMMClawback::preclaim(PreclaimContext const& ctx)
{
auto const asset = ctx.tx[sfAsset].get<Issue>();
auto const asset2 = ctx.tx[sfAsset2].get<Issue>();
auto const asset = ctx.tx[sfAsset];
auto const asset2 = ctx.tx[sfAsset2];
auto const sleIssuer = ctx.view.read(keylet::account(ctx.tx[sfAccount]));
if (!sleIssuer)
return terNO_ACCOUNT; // LCOV_EXCL_LINE
Expand Down
4 changes: 2 additions & 2 deletions src/xrpld/app/tx/detail/AMMDelete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ AMMDelete::doApply()
// as we go on processing transactions.
Sandbox sb(&ctx_.view());

auto const ter = deleteAMMAccount(
sb, ctx_.tx[sfAsset].get<Issue>(), ctx_.tx[sfAsset2].get<Issue>(), j_);
auto const ter =
deleteAMMAccount(sb, ctx_.tx[sfAsset], ctx_.tx[sfAsset2], j_);
if (ter == tesSUCCESS || ter == tecINCOMPLETE)
sb.apply(ctx_.rawView());

Expand Down
8 changes: 4 additions & 4 deletions src/xrpld/app/tx/detail/AMMDeposit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ AMMDeposit::preflight(PreflightContext const& ctx)
return temMALFORMED;
}

auto const asset = ctx.tx[sfAsset].get<Issue>();
auto const asset2 = ctx.tx[sfAsset2].get<Issue>();
auto const asset = ctx.tx[sfAsset];
auto const asset2 = ctx.tx[sfAsset2];
if (auto const res = invalidAMMAssetPair(asset, asset2))
{
JLOG(ctx.j.debug()) << "AMM Deposit: invalid asset pair.";
Expand Down Expand Up @@ -278,10 +278,10 @@ AMMDeposit::preclaim(PreclaimContext const& ctx)
return tesSUCCESS;
};

if (auto const ter = checkAsset(ctx.tx[sfAsset].get<Issue>()))
if (auto const ter = checkAsset(ctx.tx[sfAsset]))
return ter;

if (auto const ter = checkAsset(ctx.tx[sfAsset2].get<Issue>()))
if (auto const ter = checkAsset(ctx.tx[sfAsset2]))
return ter;
}

Expand Down
3 changes: 1 addition & 2 deletions src/xrpld/app/tx/detail/AMMVote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ AMMVote::preflight(PreflightContext const& ctx)
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;

if (auto const res = invalidAMMAssetPair(
ctx.tx[sfAsset].get<Issue>(), ctx.tx[sfAsset2].get<Issue>()))
if (auto const res = invalidAMMAssetPair(ctx.tx[sfAsset], ctx.tx[sfAsset2]))
{
JLOG(ctx.j.debug()) << "AMM Vote: invalid asset pair.";
return res;
Expand Down
11 changes: 3 additions & 8 deletions src/xrpld/app/tx/detail/AMMWithdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ AMMWithdraw::preflight(PreflightContext const& ctx)
return temMALFORMED;
}

auto const asset = ctx.tx[sfAsset].get<Issue>();
auto const asset2 = ctx.tx[sfAsset2].get<Issue>();
auto const asset = ctx.tx[sfAsset];
auto const asset2 = ctx.tx[sfAsset2];
if (auto const res = invalidAMMAssetPair(asset, asset2))
{
JLOG(ctx.j.debug()) << "AMM Withdraw: Invalid asset pair.";
Expand Down Expand Up @@ -438,12 +438,7 @@ AMMWithdraw::applyGuts(Sandbox& sb)
return {result, false};

auto const res = deleteAMMAccountIfEmpty(
sb,
ammSle,
newLPTokenBalance,
ctx_.tx[sfAsset].get<Issue>(),
ctx_.tx[sfAsset2].get<Issue>(),
j_);
sb, ammSle, newLPTokenBalance, ctx_.tx[sfAsset], ctx_.tx[sfAsset2], j_);
// LCOV_EXCL_START
if (!res.second)
return {res.first, false};
Expand Down

0 comments on commit 64b6d7a

Please sign in to comment.