Skip to content

Commit

Permalink
Resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Oct 30, 2024
1 parent 6b9ff1d commit 9dd3fac
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 194 deletions.
5 changes: 0 additions & 5 deletions include/xrpl/protocol/STAmount.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@

namespace ripple {

template <typename A>
concept AssetType =
std::is_same_v<A, Asset> || std::is_convertible_v<A, Issue> ||
std::is_convertible_v<A, MPTIssue> || std::is_convertible_v<A, MPTID>;

// Internal form:
// 1: If amount is zero, then value is zero and offset is -100
// 2: Otherwise:
Expand Down
3 changes: 1 addition & 2 deletions include/xrpl/protocol/detail/features.macro
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
// If you add an amendment here, then do not forget to increment `numFeatures`
// in include/xrpl/protocol/Feature.h.

XRPL_FEATURE(MPTokensV1, Supported::yes, VoteBehavior::DefaultNo)
// InvariantsV1_1 will be changes to Supported::yes when all the
// invariants expected to be included under it are complete.
XRPL_FEATURE(MPTokensV1, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo)
XRPL_FIX (NFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (InnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo)
Expand Down Expand Up @@ -95,7 +95,6 @@ XRPL_FIX (1513, Supported::yes, VoteBehavior::DefaultYe
XRPL_FEATURE(FlowCross, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(OwnerPaysFee, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(MPTokensV1, Supported::yes, VoteBehavior::DefaultNo)

// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.
Expand Down
2 changes: 0 additions & 2 deletions include/xrpl/protocol/jss.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ JSS(LastLedgerSequence); // in: TransactionSign; field
JSS(LastUpdateTime); // field.
JSS(LedgerHashes); // ledger type.
JSS(LimitAmount); // field.
JSS(BidMax); // in: AMM Bid
JSS(BidMin); // in: AMM Bid
JSS(MPToken); // ledger type.
JSS(MPTokenIssuance); // ledger type.
JSS(NetworkID); // field.
Expand Down
2 changes: 0 additions & 2 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ class MPToken_test : public beast::unit_test::suite

Json::Value jv;
jv[jss::secret] = alice.name();
jv[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base);
jv[jss::tx_json] = pay(alice, carol, mpt);
jv[jss::tx_json][jss::Fee] = to_string(env.current()->fees().base);
auto const jrr = env.rpc("json", "submit", to_string(jv));
Expand Down Expand Up @@ -1409,7 +1408,6 @@ class MPToken_test : public beast::unit_test::suite
jv[jss::Flags] = tfSingleAsset;
test(jv, field.fieldName);
};
ammDeposit(sfAmount);
for (SField const& field :
{std::ref(sfAmount),
std::ref(sfAmount2),
Expand Down
1 change: 0 additions & 1 deletion src/test/jtx/impl/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ Account const&
MPTTester::holder(std::string const& holder_) const
{
auto const& it = holders_.find(holder_);
assert(it != holders_.cend());
if (it == holders_.cend())
Throw<std::runtime_error>("Holder is not found");
return it->second;
Expand Down
1 change: 0 additions & 1 deletion src/xrpld/app/tx/detail/MPTokenAuthorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ MPTokenAuthorize::doApply()
.account = account_,
.flags = tx.getFlags(),
.holderID = tx[~sfHolder]});
.holderID = tx[~sfMPTokenHolder]});
}

} // namespace ripple
9 changes: 0 additions & 9 deletions src/xrpld/ledger/View.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,6 @@ accountHolds(
AuthHandling zeroIfUnauthorized,
beast::Journal j);

[[nodiscard]] STAmount
accountHolds(
ReadView const& view,
AccountID const& account,
MPTIssue const& mptIssue,
FreezeHandling zeroIfFrozen,
AuthHandling zeroIfUnauthorized,
beast::Journal j);

// Returns the amount an account can spend of the currency type saDefault, or
// returns saDefault if this account is the issuer of the currency in
// question. Should be used in favor of accountHolds when questioning how much
Expand Down
172 changes: 0 additions & 172 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,6 @@ isIndividualFrozen(
return false;
}

bool
isIndividualFrozen(
ReadView const& view,
AccountID const& account,
MPTIssue const& mptIssue)
{
if (auto const sle =
view.read(keylet::mptoken(mptIssue.getMptID(), account)))
return sle->getFlags() & lsfMPTLocked;
return false;
}

// Can the specified account spend the specified currency issued by
// the specified issuer or does the freeze flag prohibit it?
bool
Expand Down Expand Up @@ -601,19 +589,6 @@ transferRate(ReadView const& view, MPTID const& issuanceID)
return parityRate;
}

Rate
transferRate(ReadView const& view, MPTID const& issuanceID)
{
// fee is 0-50,000 (0-50%), rate is 1,000,000,000-2,000,000,000
// For example, if transfer fee is 50% then 10,000 * 50,000 = 500,000
// which represents 50% of 1,000,000,000
if (auto const sle = view.read(keylet::mptIssuance(issuanceID));
sle && sle->isFieldPresent(sfTransferFee))
return Rate{1'000'000'000u + 10'000 * sle->getFieldU16(sfTransferFee)};

return parityRate;
}

bool
areCompatible(
ReadView const& validLedger,
Expand Down Expand Up @@ -1543,93 +1518,6 @@ accountSend(
saAmount.asset().value());
}

static TER
rippleSendMPT(
ApplyView& view,
AccountID const& uSenderID,
AccountID const& uReceiverID,
STAmount const& saAmount,
STAmount& saActual,
beast::Journal j,
WaiveTransferFee waiveFee)
{
assert(uSenderID != uReceiverID);

// Safe to get MPT since rippleSendMPT is only called by accountSendMPT
auto const issuer = saAmount.getIssuer();

auto const sle =
view.read(keylet::mptIssuance(saAmount.get<MPTIssue>().getMptID()));
if (!sle)
return tecOBJECT_NOT_FOUND;

if (uSenderID == issuer || uReceiverID == issuer)
{
// if sender is issuer, check that the new OutstandingAmount will not
// exceed MaximumAmount
if (uSenderID == issuer)
{
auto const sendAmount = saAmount.mpt().value();
auto const maximumAmount =
sle->at(~sfMaximumAmount).value_or(maxMPTokenAmount);
if (sendAmount > maximumAmount ||
sle->getFieldU64(sfOutstandingAmount) >
maximumAmount - sendAmount)
return tecPATH_DRY;
}

// Direct send: redeeming MPTs and/or sending own MPTs.
auto const ter =
rippleCreditMPT(view, uSenderID, uReceiverID, saAmount, j);
if (ter != tesSUCCESS)
return ter;
saActual = saAmount;
return tesSUCCESS;
}

// Sending 3rd party MPTs: transit.
saActual = (waiveFee == WaiveTransferFee::Yes)
? saAmount
: multiply(
saAmount,
transferRate(view, saAmount.get<MPTIssue>().getMptID()));

JLOG(j.debug()) << "rippleSend> " << to_string(uSenderID) << " - > "
<< to_string(uReceiverID)
<< " : deliver=" << saAmount.getFullText()
<< " cost=" << saActual.getFullText();

if (auto const terResult =
rippleCreditMPT(view, issuer, uReceiverID, saAmount, j);
terResult != tesSUCCESS)
return terResult;

return rippleCreditMPT(view, uSenderID, issuer, saActual, j);
}

TER
accountSendMPT(
ApplyView& view,
AccountID const& uSenderID,
AccountID const& uReceiverID,
STAmount const& saAmount,
beast::Journal j,
WaiveTransferFee waiveFee)
{
assert(saAmount >= beast::zero && saAmount.holds<MPTIssue>());

/* 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()};

return rippleSendMPT(
view, uSenderID, uReceiverID, saAmount, saActual, j, waiveFee);
}

static bool
updateTrustLine(
ApplyView& view,
Expand Down Expand Up @@ -2089,66 +1977,6 @@ deleteAMMTrustLine(
return tesSUCCESS;
}

TER
rippleCreditMPT(
ApplyView& view,
AccountID const& uSenderID,
AccountID const& uReceiverID,
STAmount const& saAmount,
beast::Journal j)
{
auto const mptID = keylet::mptIssuance(saAmount.get<MPTIssue>().getMptID());
auto const issuer = saAmount.getIssuer();
auto sleIssuance = view.peek(mptID);
if (!sleIssuance)
return tecOBJECT_NOT_FOUND;
if (uSenderID == issuer)
{
(*sleIssuance)[sfOutstandingAmount] += saAmount.mpt().value();
view.update(sleIssuance);
}
else
{
auto const mptokenID = keylet::mptoken(mptID.key, uSenderID);
if (auto sle = view.peek(mptokenID))
{
auto const amt = sle->getFieldU64(sfMPTAmount);
auto const pay = saAmount.mpt().value();
if (amt < pay)
return tecINSUFFICIENT_FUNDS;
(*sle)[sfMPTAmount] = amt - pay;
view.update(sle);
}
else
return tecNO_AUTH;
}

if (uReceiverID == issuer)
{
auto const outstanding = sleIssuance->getFieldU64(sfOutstandingAmount);
auto const redeem = saAmount.mpt().value();
if (outstanding >= redeem)
{
sleIssuance->setFieldU64(sfOutstandingAmount, outstanding - redeem);
view.update(sleIssuance);
}
else
return tecINTERNAL;
}
else
{
auto const mptokenID = keylet::mptoken(mptID.key, uReceiverID);
if (auto sle = view.peek(mptokenID))
{
(*sle)[sfMPTAmount] += saAmount.mpt().value();
view.update(sle);
}
else
return tecNO_AUTH;
}
return tesSUCCESS;
}

TER
rippleCredit(
ApplyView& view,
Expand Down

0 comments on commit 9dd3fac

Please sign in to comment.