Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Jul 15, 2024
1 parent 407eadd commit 85af04c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/test/app/MPToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ class MPToken_test : public beast::unit_test::suite
// env(mpt::authorize(alice, id.key, std::nullopt));
// env.close();

mptAlice.pay(alice, bob, 100, tecOBJECT_NOT_FOUND);

mptAlice.authorize({.account = &bob});
mptAlice.authorize({.account = &carol});

Expand Down
27 changes: 19 additions & 8 deletions src/xrpld/ledger/detail/View.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1696,15 +1696,19 @@ TER
requireAuth(ReadView const& view, MPTIssue const& mpt, AccountID const& account)
{
auto const mptID = keylet::mptIssuance(mpt.mpt());
if (auto const sle = view.read(mptID);
sle && sle->getFieldU32(sfFlags) & lsfMPTRequireAuth)
auto const sle = view.read(mptID);
if (!sle)
return tecOBJECT_NOT_FOUND;

if (sle->getFieldU32(sfFlags) & lsfMPTRequireAuth)
{
auto const mptokenID = keylet::mptoken(mptID.key, account);
if (auto const tokSle = view.read(mptokenID); tokSle &&
//(sle->getFlags() & lsfMPTRequireAuth) &&
!(tokSle->getFlags() & lsfMPTAuthorized))
return TER{tecNO_AUTH};
}

return tesSUCCESS;
}

Expand All @@ -1716,12 +1720,17 @@ canTransfer(
AccountID const& to)
{
auto const mptID = keylet::mptIssuance(mpt.mpt());
if (auto const sle = view.read(mptID);
sle && !(sle->getFieldU32(sfFlags) & lsfMPTCanTransfer))
{
if (from != (*sle)[sfIssuer] && to != (*sle)[sfIssuer])
return TER{tecNO_AUTH};
}
auto const sle = view.read(mptID);
if (!sle)
return tecOBJECT_NOT_FOUND;

if (from != (*sle)[sfIssuer] && to != (*sle)[sfIssuer] && !(sle->getFieldU32(sfFlags) & lsfMPTCanTransfer))
return TER{tecNO_AUTH};

if (from != (*sle)[sfIssuer]){
auto const sle = view.read(keylet::mptoken());
}

return tesSUCCESS;
}

Expand Down Expand Up @@ -1924,6 +1933,8 @@ rippleMPTCredit(
sle->getFieldU64(sfMPTAmount) + saAmount.mpt().mpt());
view.update(sle);
}
else
return tecINTERNAL;
}
return tesSUCCESS;
}
Expand Down

0 comments on commit 85af04c

Please sign in to comment.