Skip to content

Commit 8fd18a5

Browse files
authored
add tecMPT_ISSUANCE_NOT_FOUND code (XRPLF#33)
* add issuance not found code * add issuance check to start of func * uses `exists()`
1 parent 8ffbab0 commit 8fd18a5

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

include/xrpl/protocol/TER.h

+1
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ enum TECcodes : TERUnderlyingType {
345345
tecMPT_MAX_AMOUNT_EXCEEDED = 193,
346346
tecMPT_LOCKED = 194,
347347
tecMPT_NOT_SUPPORTED = 195,
348+
tecMPT_ISSUANCE_NOT_FOUND = 196
348349
};
349350

350351
//------------------------------------------------------------------------------

src/libxrpl/protocol/TER.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ transResults()
119119
MAKE_ERROR(tecMPTOKEN_EXISTS, "The account already owns the MPToken object."),
120120
MAKE_ERROR(tecMPT_MAX_AMOUNT_EXCEEDED, "The MPT's maximum amount is exceeded."),
121121
MAKE_ERROR(tecMPT_LOCKED, "MPT is locked by the issuer."),
122+
MAKE_ERROR(tecMPT_ISSUANCE_NOT_FOUND, "The MPTokenIssuance object is not found"),
122123

123124
MAKE_ERROR(tefALREADY, "The exact transaction was already in this ledger."),
124125
MAKE_ERROR(tefBAD_ADD_AUTH, "Not authorized to add account."),

src/test/app/MPToken_test.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,41 @@ class MPToken_test : public beast::unit_test::suite
980980
jrr[jss::result][jss::error_message] ==
981981
"Field 'build_path' not allowed in this context.");
982982
}
983+
984+
// Issuer fails trying to send fund after issuance was destroyed
985+
{
986+
Env env{*this, features};
987+
988+
MPTTester mptAlice(env, alice, {.holders = {&bob}});
989+
990+
mptAlice.create({.ownerCount = 1, .holderCount = 0});
991+
992+
mptAlice.authorize({.account = &bob});
993+
994+
// alice destroys issuance
995+
mptAlice.destroy({.ownerCount = 0});
996+
997+
// alice tries to send bob fund after issuance is destroy, should
998+
// fail.
999+
mptAlice.pay(alice, bob, 100, tecMPT_ISSUANCE_NOT_FOUND);
1000+
}
1001+
1002+
// Issuer fails trying to send to some who doesn't own MPT for a
1003+
// issuance that was destroyed
1004+
{
1005+
Env env{*this, features};
1006+
1007+
MPTTester mptAlice(env, alice, {.holders = {&bob}});
1008+
1009+
mptAlice.create({.ownerCount = 1, .holderCount = 0});
1010+
1011+
// alice destroys issuance
1012+
mptAlice.destroy({.ownerCount = 0});
1013+
1014+
// alice tries to send bob who doesn't own the MPT after issuance is
1015+
// destroyed, it should fail
1016+
mptAlice.pay(alice, bob, 100, tecMPT_ISSUANCE_NOT_FOUND);
1017+
}
9831018
}
9841019

9851020
void

src/xrpld/ledger/detail/View.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,10 @@ rippleCredit(
18601860
{
18611861
auto const mptID = keylet::mptIssuance(saAmount.issue().getMptID());
18621862
auto const issuer = saAmount.getIssuer();
1863+
1864+
if (!view.exists(mptID))
1865+
return tecMPT_ISSUANCE_NOT_FOUND;
1866+
18631867
if (uSenderID == issuer)
18641868
{
18651869
if (auto sle = view.peek(mptID))

0 commit comments

Comments
 (0)