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

add tecMPT_ISSUANCE_NOT_FOUND code #33

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions include/xrpl/protocol/TER.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ enum TECcodes : TERUnderlyingType {
tecMPT_MAX_AMOUNT_EXCEEDED = 193,
tecMPT_LOCKED = 194,
tecMPT_NOT_SUPPORTED = 195,
tecMPT_ISSUANCE_NOT_FOUND = 196
};

//------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/libxrpl/protocol/TER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ transResults()
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(tefALREADY, "The exact transaction was already in this ledger."),
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),
Expand Down
18 changes: 18 additions & 0 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,24 @@ class MPToken_test : public beast::unit_test::suite
jrr[jss::result][jss::error_message] ==
"Field 'build_path' not allowed in this context.");
}

// Issuer fails trying to send fund after issuance was destroyed
{
Env env{*this, features};

MPTTester mptAlice(env, alice, {.holders = {&bob}});

mptAlice.create({.ownerCount = 1, .holderCount = 0});

mptAlice.authorize({.account = &bob});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to authorize.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the test as it is, I added another test case where the holder didn't authorize


// alice destroys issuance
mptAlice.destroy({.ownerCount = 0});

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

void
Expand Down
4 changes: 2 additions & 2 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ rippleCredit(
view.update(sle);
}
else
return tecINTERNAL;
return tecMPT_ISSUANCE_NOT_FOUND;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a sender is not the issuer, need to check if mpt issuance doesn't exist. I.e., if it doesn't exist then the error is tecMPT_ISSUANCE_NOT_FOUND and if mpt token doesn't exist then the error is tecNO_AUTH.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify? The code currently does what you have described.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a sender is not the issuer then we are getting MPToken object. If this object doesn't exist then tecNO_AUTH is returned. This is not correct error if MPTokenIssuance object doesn't exist. I think we should check at the start of the function if MPTokenIssuance doesn't exist and return tecMPT_ISSUANCE_NOT_FOUND.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i moved the check to the start of function

}
else
{
Expand Down Expand Up @@ -1914,7 +1914,7 @@ rippleCredit(
return tecINSUFFICIENT_FUNDS;
}
else
return tecINTERNAL;
return tecMPT_ISSUANCE_NOT_FOUND;
}
else
{
Expand Down
Loading