Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Nov 9, 2023
1 parent 468a6e8 commit d294463
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
46 changes: 43 additions & 3 deletions src/ripple/app/tx/impl/CFTokenIssuanceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,67 @@ CFTokenIssuanceSet::preflight(PreflightContext const& ctx)
else if (!(txFlags & tfCFTLock & tfCFTUnlock))
return temINVALID_FLAG;

auto const accountID = ctx.tx[sfAccount];
auto const holderID = ctx.tx[~sfCFTokenHolder];
if (holderID && accountID == holderID)
return temMALFORMED;

return preflight2(ctx);
}

TER
CFTokenIssuanceSet::preclaim(PreclaimContext const& ctx)
{
// ensure that issuance exists
auto const sleCFT =
auto const sleCftIssuance =
ctx.view.read(keylet::cftIssuance(ctx.tx[sfCFTokenIssuanceID]));
if (!sleCFT)
if (!sleCftIssuance)
return tecOBJECT_NOT_FOUND;


auto const holderID = ctx.tx[~sfCFTokenHolder];

// issuer wants to lock/unlock a specific holder
if (holderID && !ctx.view.exists(keylet::cftoken(ctx.tx[sfCFTokenIssuanceID], holderID)))
return tecOBJECT_NOT_FOUND;

return tesSUCCESS;
}

TER
CFTokenIssuanceSet::doApply()
{
auto const cftIssuanceID = ctx_.tx[sfCFTokenIssuanceID];
// auto const sleCftIssuance =
// view().peek(keylet::cftIssuance(cftIssuanceID));
// if (!sleCftIssuance)
// return tecINTERNAL;

auto const txFlags = ctx_.tx.getFlags();
auto const holderID = ctx_.tx[~sfCFTokenHolder];

if (holderID){
auto const sleCft = view().peek(keylet::cftoken(cftIssuanceID, holderID));
if (!sleCft)
return tecINTERNAL;

std::uint32_t const flagsIn = sleCft->getFieldU32(sfFlags);
std::uint32_t flagsOut = flagsIn;

if (txFlags & tfCFTLock){
flagsOut |= lsfCFTLocked;
}
else if (txFlags & tfCFTUnlock){
flagsOut &= ~lsfCFTLocked;
}

if (flagsIn != flagsOut)
sleCft->setFieldU32(sfFlags, flagsOut);

view().update(sleCft);
return tesSUCCESS;
}


return tesSUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/LedgerFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ enum LedgerSpecificFlags {
lsfSellNFToken = 0x00000001,

// ltCFTOKEN_ISSUANCE
lsfCFTLocked = 0x00000001,
lsfCFTLocked = 0x00000001, // Also used in ltCFTOKEN
lsfCFTCanLock = 0x00000002,
lsfCFTRequireAuth = 0x00000004,
lsfCFTCanEscrow = 0x00000008,
Expand Down

0 comments on commit d294463

Please sign in to comment.