Skip to content

Commit

Permalink
[fold] clang
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnxie999 committed Apr 4, 2023
1 parent 87bea96 commit 7b1fffa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/ripple/rpc/impl/NFTokenID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,22 @@ getNFTokenIDFromDeletedOffer(TxMeta const& transactionMeta)
std::vector<uint256> tokenIDResult;
for (STObject const& node : transactionMeta.getNodes())
{
if (node.getFieldU16(sfLedgerEntryType) != ltNFTOKEN_OFFER || node.getFName() != sfDeletedNode)
if (node.getFieldU16(sfLedgerEntryType) != ltNFTOKEN_OFFER ||
node.getFName() != sfDeletedNode)
continue;

auto const& toAddNFT = node.peekAtField(sfFinalFields)
.downcast<STObject>()
.getFieldH256(sfNFTokenID);
.downcast<STObject>()
.getFieldH256(sfNFTokenID);
tokenIDResult.push_back(toAddNFT);

}

// Deduplicate the NFT IDs because multiple offers could affect the same NFT
// and hence we would get duplicate NFT IDs
sort(tokenIDResult.begin(), tokenIDResult.end());
tokenIDResult.erase( unique( tokenIDResult.begin(), tokenIDResult.end() ), tokenIDResult.end() );
tokenIDResult.erase(
unique(tokenIDResult.begin(), tokenIDResult.end()),
tokenIDResult.end());
return tokenIDResult;
}

Expand Down
3 changes: 2 additions & 1 deletion src/ripple/rpc/impl/NFTokenOfferID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ getOfferIDFromCreatedOffer(TxMeta const& transactionMeta)
{
for (STObject const& node : transactionMeta.getNodes())
{
if (node.getFieldU16(sfLedgerEntryType) != ltNFTOKEN_OFFER || node.getFName() != sfCreatedNode)
if (node.getFieldU16(sfLedgerEntryType) != ltNFTOKEN_OFFER ||
node.getFName() != sfCreatedNode)
continue;

return node.getFieldH256(sfLedgerIndex);
Expand Down
9 changes: 5 additions & 4 deletions src/test/app/NFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6641,7 +6641,7 @@ class NFToken_test : public beast::unit_test::suite
BEAST_EXPECT(nftID.parseHex(id.asString()));
return nftID;
});

// Sort both array to prepare for comparison
std::sort(metaIDs.begin(), metaIDs.end());
std::sort(actualNftIDs.begin(), actualNftIDs.end());
Expand Down Expand Up @@ -6763,8 +6763,8 @@ class NFToken_test : public beast::unit_test::suite
verifyNFTokenID(nftId);
}

// Check if there are no duplicate nft id in Cancel transactions where multiple offers
// are cancelled for the same NFT
// Check if there are no duplicate nft id in Cancel transactions where
// multiple offers are cancelled for the same NFT
{
// Alice mints a NFT
uint256 const nftId{
Expand All @@ -6788,7 +6788,8 @@ class NFToken_test : public beast::unit_test::suite
env.close();
verifyNFTokenOfferID(aliceOfferIndex2);

// Make sure the metadata only has 1 nft id, since both offers are for the same nft
// Make sure the metadata only has 1 nft id, since both offers are
// for the same nft
env(token::cancelOffer(
alice, {aliceOfferIndex1, aliceOfferIndex2}));
env.close();
Expand Down

0 comments on commit 7b1fffa

Please sign in to comment.