Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Nov 8, 2023
1 parent bd72823 commit 5376bed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/ripple/app/tx/impl/CFTokenIssuanceDestroy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <ripple/ledger/View.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/st.h>
#include <ripple/protocol/TxFlags.h>

namespace ripple {

Expand All @@ -30,9 +31,13 @@ CFTokenIssuanceDestroy::preflight(PreflightContext const& ctx)
if (!ctx.rules.enabled(featureCFTokensV1))
return temDISABLED;

//check flags
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;

if (ctx.tx.getFlags() & tfCFTokenIssuanceDestroyMask)
return temINVALID_FLAG;

return preflight2(ctx);
}

Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/applySteps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <ripple/app/tx/impl/AMMWithdraw.h>
#include <ripple/app/tx/impl/ApplyContext.h>
#include <ripple/app/tx/impl/CFTokenIssuanceCreate.h>
#include <ripple/app/tx/impl/CFTokenIssuanceDestroy.h>
#include <ripple/app/tx/impl/CancelCheck.h>
#include <ripple/app/tx/impl/CancelOffer.h>
#include <ripple/app/tx/impl/CashCheck.h>
Expand Down Expand Up @@ -162,7 +163,7 @@ with_txn_type(TxType txnType, F&& f)
return f.template operator()<DIDDelete>();
case ttCFTOKEN_ISSUANCE_CREATE:
return f.template operator()<CFTokenIssuanceCreate>();
case ttCFTOKEN_ISSUANCE_DESTORY:
case ttCFTOKEN_ISSUANCE_DESTROY:
return f.template operator()<CFTokenIssuanceDestroy>();
default:
throw UnknownTxnType(txnType);
Expand Down
2 changes: 2 additions & 0 deletions src/ripple/protocol/TxFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ constexpr std::uint32_t tfBridgeModifyMask = ~(tfUniversal | tfClearAccountCreat
constexpr std::uint32_t const tfCFTokenIssuanceCreateMask =
~(tfCFTCanLock | tfCFTRequireAuth | tfCFTCanEscrow | tfCFTCanTrade | tfCFTCanTransfer | tfCFTCanClawback | tfUniversal);

// CFTokenIssuanceDestroy flags:
constexpr std::uint32_t const tfCFTokenIssuanceDestroyMask = ~tfUniversal;
// clang-format on

} // namespace ripple
Expand Down
3 changes: 1 addition & 2 deletions src/test/app/CFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,11 @@ class CFToken_test : public beast::unit_test::suite

BEAST_EXPECT(env.ownerCount(master) == 0);

auto const id = keylet::cftIssuance(master.id(), env.seq(master));
env(cft::create(master));
env.close();
BEAST_EXPECT(env.ownerCount(master) == 1);

auto const id = keylet::cftIssuance(master.id(), env.seq(master));

env(cft::destroy(master, ripple::to_string(id.key)));
env.close();
BEAST_EXPECT(env.ownerCount(master) == 0);
Expand Down

0 comments on commit 5376bed

Please sign in to comment.