Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename MPT codes #37

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions include/xrpl/protocol/TER.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,7 @@ enum TECcodes : TERUnderlyingType {
tecTOKEN_PAIR_NOT_FOUND = 189,
tecARRAY_EMPTY = 190,
tecARRAY_TOO_LARGE = 191,
tecMPTOKEN_EXISTS = 192,
tecMPT_MAX_AMOUNT_EXCEEDED = 193,
tecMPT_LOCKED = 194,
tecMPT_NOT_SUPPORTED = 195,
tecMPT_ISSUANCE_NOT_FOUND = 196
tecLOCKED = 192,
};

//------------------------------------------------------------------------------
Expand Down
6 changes: 1 addition & 5 deletions src/libxrpl/protocol/TER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ transResults()
MAKE_ERROR(tecHAS_OBLIGATIONS, "The account cannot be deleted since it has obligations."),
MAKE_ERROR(tecTOO_SOON, "It is too early to attempt the requested operation. Please wait."),
MAKE_ERROR(tecMAX_SEQUENCE_REACHED, "The maximum sequence number was reached."),
MAKE_ERROR(tecMPT_NOT_SUPPORTED, "MPT is not supported."),
MAKE_ERROR(tecNO_SUITABLE_NFTOKEN_PAGE, "A suitable NFToken page could not be located."),
MAKE_ERROR(tecNFTOKEN_BUY_SELL_MISMATCH, "The 'Buy' and 'Sell' NFToken offers are mismatched."),
MAKE_ERROR(tecNFTOKEN_OFFER_TYPE_MISMATCH, "The type of NFToken offer is incorrect."),
Expand Down Expand Up @@ -116,10 +115,7 @@ transResults()
MAKE_ERROR(tecTOKEN_PAIR_NOT_FOUND, "Token pair is not found in Oracle object."),
MAKE_ERROR(tecARRAY_EMPTY, "Array is empty."),
MAKE_ERROR(tecARRAY_TOO_LARGE, "Array is too large."),
MAKE_ERROR(tecMPTOKEN_EXISTS, "The account already owns the MPToken object."),
MAKE_ERROR(tecMPT_MAX_AMOUNT_EXCEEDED, "The MPT's maximum amount is exceeded."),
MAKE_ERROR(tecMPT_LOCKED, "MPT is locked by the issuer."),
MAKE_ERROR(tecMPT_ISSUANCE_NOT_FOUND, "The MPTokenIssuance object is not found"),
MAKE_ERROR(tecLOCKED, "Fund is locked."),

MAKE_ERROR(tefALREADY, "The exact transaction was already in this ledger."),
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),
Expand Down
14 changes: 7 additions & 7 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class MPToken_test : public beast::unit_test::suite
mptAlice.authorize({.account = &bob, .holderCount = 1});

// bob cannot create the mptoken the second time
mptAlice.authorize({.account = &bob, .err = tecMPTOKEN_EXISTS});
mptAlice.authorize({.account = &bob, .err = tecDUPLICATE});

// Check that bob cannot delete MPToken when his balance is
// non-zero
Expand Down Expand Up @@ -766,8 +766,8 @@ class MPToken_test : public beast::unit_test::suite
// Global lock
mptAlice.set({.account = &alice, .flags = tfMPTLock});
// Can't send between holders
mptAlice.pay(bob, carol, 1, tecMPT_LOCKED);
mptAlice.pay(carol, bob, 2, tecMPT_LOCKED);
mptAlice.pay(bob, carol, 1, tecLOCKED);
mptAlice.pay(carol, bob, 2, tecLOCKED);
// Issuer can send
mptAlice.pay(alice, bob, 3);
// Holder can send back to issuer
Expand All @@ -779,8 +779,8 @@ class MPToken_test : public beast::unit_test::suite
mptAlice.set(
{.account = &alice, .holder = &bob, .flags = tfMPTLock});
// Can't send between holders
mptAlice.pay(bob, carol, 5, tecMPT_LOCKED);
mptAlice.pay(carol, bob, 6, tecMPT_LOCKED);
mptAlice.pay(bob, carol, 5, tecLOCKED);
mptAlice.pay(carol, bob, 6, tecLOCKED);
// Issuer can send
mptAlice.pay(alice, bob, 7);
// Holder can send back to issuer
Expand Down Expand Up @@ -1030,7 +1030,7 @@ class MPToken_test : public beast::unit_test::suite

// alice tries to send bob fund after issuance is destroy, should
// fail.
mptAlice.pay(alice, bob, 100, tecMPT_ISSUANCE_NOT_FOUND);
mptAlice.pay(alice, bob, 100, tecOBJECT_NOT_FOUND);
}

// Issuer fails trying to send to some who doesn't own MPT for a
Expand All @@ -1047,7 +1047,7 @@ class MPToken_test : public beast::unit_test::suite

// alice tries to send bob who doesn't own the MPT after issuance is
// destroyed, it should fail
mptAlice.pay(alice, bob, 100, tecMPT_ISSUANCE_NOT_FOUND);
mptAlice.pay(alice, bob, 100, tecOBJECT_NOT_FOUND);
}

// Issuers issues maximum amount of MPT to a holder, the holder should
Expand Down
2 changes: 1 addition & 1 deletion src/test/jtx/impl/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ MPTTester::authorize(MPTAuthorize const& arg)
arg.account != nullptr && *arg.account != issuer_ &&
arg.flags.value_or(0) == 0 && issuanceKey_)
{
if (result == tecMPTOKEN_EXISTS)
if (result == tecDUPLICATE)
{
// Verify that MPToken already exists
env_.require(requireAny([&]() -> bool {
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/MPTokenAuthorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ MPTokenAuthorize::preclaim(PreclaimContext const& ctx)

// if holder wants to use and create a mpt
if (sleMpt)
return tecMPTOKEN_EXISTS;
return tecDUPLICATE;

return tesSUCCESS;
}
Expand Down
4 changes: 2 additions & 2 deletions src/xrpld/app/tx/detail/Payment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ applyHelper<MPTIssue>(ApplyContext& ctx, XRPAmount const&, XRPAmount const&)
// - issuer can send to holder
if (isFrozen(ctx.view(), account, mpt) ||
isFrozen(ctx.view(), uDstAccountID, mpt))
return tecMPT_LOCKED;
return tecLOCKED;

auto const sendMax(ctx.tx[~sfSendMax]);
// If the transfer fee is included then SendMax has to be included
Expand All @@ -698,7 +698,7 @@ applyHelper<MPTIssue>(ApplyContext& ctx, XRPAmount const&, XRPAmount const&)
accountSendMPT(pv, account, uDstAccountID, saDstAmount, ctx.journal);
if (res == tesSUCCESS)
pv.apply(ctx.rawView());
else if (res == tecINSUFFICIENT_FUNDS || res == tecMPT_MAX_AMOUNT_EXCEEDED)
else if (res == tecINSUFFICIENT_FUNDS || res == tecPATH_DRY)
res = tecPATH_PARTIAL;

return res;
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 @@ -1363,15 +1363,15 @@ rippleSendMPT(
keylet::mptIssuance(saAmount.get<MPTIssue>().getMptID());
auto const sle = view.peek(mptID);
if (!sle)
return tecMPT_ISSUANCE_NOT_FOUND;
return tecOBJECT_NOT_FOUND;

auto const sendAmount = saAmount.mpt().value();
auto const maximumAmount =
sle->at(~sfMaximumAmount).value_or(maxMPTokenAmount);
if (sendAmount > maximumAmount ||
sle->getFieldU64(sfOutstandingAmount) >
maximumAmount - sendAmount)
return tecMPT_MAX_AMOUNT_EXCEEDED;
return tecPATH_DRY;
}

// Direct send: redeeming IOUs and/or sending own IOUs.
Expand Down Expand Up @@ -1885,7 +1885,7 @@ rippleMPTCredit(
auto const mptID = keylet::mptIssuance(saAmount.get<MPTIssue>().getMptID());
auto const issuer = saAmount.getIssuer();
if (!view.exists(mptID))
return tecMPT_ISSUANCE_NOT_FOUND;
return tecOBJECT_NOT_FOUND;
if (uSenderID == issuer)
{
if (auto sle = view.peek(mptID))
Expand Down
Loading