Skip to content

Commit

Permalink
rename fixUnburnableNFToken to NonFungibleTokensV1_2
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyzlei committed Feb 13, 2023
1 parent 40c55e9 commit 820fcfa
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 53 deletions.
8 changes: 4 additions & 4 deletions src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx)

// The two offers may not form a loop. A broker may not sell the
// token to the current owner of the token.
if (ctx.view.rules().enabled(fixUnburnableNFToken) &&
if (ctx.view.rules().enabled(NonFungibleTokensV1_2) &&
((*bo)[sfOwner] == (*so)[sfOwner]))
return tecCANT_ACCEPT_OWN_NFTOKEN_OFFER;

Expand Down Expand Up @@ -180,7 +180,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx)
// After this amendment, we allow an IOU issuer to buy an NFT with their
// own currency
auto const needed = bo->at(sfAmount);
if (ctx.view.rules().enabled(fixUnburnableNFToken))
if (ctx.view.rules().enabled(NonFungibleTokensV1_2))
{
if (accountFunds(
ctx.view, (*bo)[sfOwner], needed, fhZERO_IF_FROZEN, ctx.j) <
Expand Down Expand Up @@ -223,7 +223,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx)

// The account offering to buy must have funds:
auto const needed = so->at(sfAmount);
if (!ctx.view.rules().enabled(fixUnburnableNFToken))
if (!ctx.view.rules().enabled(NonFungibleTokensV1_2))
{
if (accountHolds(
ctx.view,
Expand Down Expand Up @@ -278,7 +278,7 @@ NFTokenAcceptOffer::pay(
// their own currency, we know that something went wrong. This was
// originally found in the context of IOU transfer fees. Since there are
// several payouts in this tx, just confirm that the end state is OK.
if (!view().rules().enabled(fixUnburnableNFToken))
if (!view().rules().enabled(NonFungibleTokensV1_2))
return result;
if (result != tesSUCCESS)
return result;
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/tx/impl/NFTokenBurn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ NFTokenBurn::preclaim(PreclaimContext const& ctx)
}
}

if (!ctx.view.rules().enabled(fixUnburnableNFToken))
if (!ctx.view.rules().enabled(NonFungibleTokensV1_2))
{
// If there are too many offers, then burning the token would produce
// too much metadata. Disallow burning a token with too many offers.
Expand Down Expand Up @@ -109,7 +109,7 @@ NFTokenBurn::doApply()
view().update(issuer);
}

if (ctx_.view().rules().enabled(fixUnburnableNFToken))
if (ctx_.view().rules().enabled(NonFungibleTokensV1_2))
{
// Delete up to 500 offers in total.
// Because the number of sell offers is likely to be less than
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/tx/impl/NFTokenCreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ NFTokenCreateOffer::preclaim(PreclaimContext const& ctx)
{
// After this amendment, we allow an IOU issuer to make a buy offer
// using their own currency.
if (ctx.view.rules().enabled(fixUnburnableNFToken))
if (ctx.view.rules().enabled(NonFungibleTokensV1_2))
{
if (accountFunds(
ctx.view,
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ extern uint256 const fixTrustLinesToSelf;
extern uint256 const fixRemoveNFTokenAutoTrustLine;
extern uint256 const featureImmediateOfferKilled;
extern uint256 const featureDisallowIncoming;
extern uint256 const fixUnburnableNFToken;
extern uint256 const NonFungibleTokensV1_2;

} // namespace ripple

Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/Feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ REGISTER_FIX (fixTrustLinesToSelf, Supported::yes, DefaultVote::no)
REGISTER_FIX (fixRemoveNFTokenAutoTrustLine, Supported::yes, DefaultVote::yes);
REGISTER_FEATURE(ImmediateOfferKilled, Supported::yes, DefaultVote::no);
REGISTER_FEATURE(DisallowIncoming, Supported::yes, DefaultVote::no);
REGISTER_FIX (fixUnburnableNFToken, Supported::yes, DefaultVote::no);
REGISTER_FEATURE(NonFungibleTokensV1_2, Supported::yes, DefaultVote::no);

// The following amendments have been active for at least two years. Their
// pre-amendment code has been removed and the identifiers are deprecated.
Expand Down
22 changes: 11 additions & 11 deletions src/test/app/NFTokenBurn_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ class NFTokenBurn_test : public beast::unit_test::suite
using namespace test::jtx;

// Test what happens if a NFT is unburnable when there are
// more than 500 offers, before fixUnburnableNFToken goes live
if (!features[fixUnburnableNFToken])
// more than 500 offers, before NonFungibleTokensV1_2 goes live
if (!features[NonFungibleTokensV1_2])
{
Env env{*this, features};

Expand Down Expand Up @@ -620,10 +620,10 @@ class NFTokenBurn_test : public beast::unit_test::suite
}

// Test that up to 499 buy/sell offers will be removed when NFT is
// burned after fixUnburnableNFToken is enabled. This is to test that we
// can successfully remove all offers if the number of offers is less
// burned after NonFungibleTokensV1_2 is enabled. This is to test that
// we can successfully remove all offers if the number of offers is less
// than 500.
if (features[fixUnburnableNFToken])
if (features[NonFungibleTokensV1_2])
{
Env env{*this, features};

Expand Down Expand Up @@ -673,8 +673,8 @@ class NFTokenBurn_test : public beast::unit_test::suite
}

// Test that up to 500 buy offers are removed when NFT is burned
// after fixUnburnableNFToken is enabled
if (features[fixUnburnableNFToken])
// after NonFungibleTokensV1_2 is enabled
if (features[NonFungibleTokensV1_2])
{
Env env{*this, features};

Expand Down Expand Up @@ -718,8 +718,8 @@ class NFTokenBurn_test : public beast::unit_test::suite
}

// Test that up to 500 buy/sell offers are removed when NFT is burned
// after fixUnburnableNFToken is enabled
if (features[fixUnburnableNFToken])
// after NonFungibleTokensV1_2 is enabled
if (features[NonFungibleTokensV1_2])
{
Env env{*this, features};

Expand Down Expand Up @@ -786,8 +786,8 @@ class NFTokenBurn_test : public beast::unit_test::suite
FeatureBitset const all{supported_amendments()};
FeatureBitset const fixNFTDir{fixNFTokenDirV1};

testWithFeats(all - fixUnburnableNFToken - fixNFTDir);
testWithFeats(all - fixUnburnableNFToken);
testWithFeats(all - NonFungibleTokensV1_2 - fixNFTDir);
testWithFeats(all - NonFungibleTokensV1_2);
testWithFeats(all);
}
};
Expand Down
68 changes: 35 additions & 33 deletions src/test/app/NFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3822,7 +3822,8 @@ class NFToken_test : public beast::unit_test::suite
using namespace test::jtx;

for (auto const& tweakedFeatures :
{features - fixUnburnableNFToken, features | fixUnburnableNFToken})
{features - NonFungibleTokensV1_2,
features | NonFungibleTokensV1_2})
{
Env env{*this, tweakedFeatures};

Expand Down Expand Up @@ -4361,7 +4362,7 @@ class NFToken_test : public beast::unit_test::suite
token::owner(minter));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
{
env(token::brokerOffers(
broker, buyOfferIndex, minterOfferIndex),
Expand Down Expand Up @@ -4907,12 +4908,12 @@ class NFToken_test : public beast::unit_test::suite
IOU const gwXAU(gw["XAU"]);

// Test both with and without fixNFTokenNegOffer and
// fixUnburnableNFToken. Need to turn off fixUnburnableNFToken as well
// NonFungibleTokensV1_2. Need to turn off NonFungibleTokensV1_2 as well
// because that amendment came later and addressed the acceptance
// side of this issue.
for (auto const& tweakedFeatures :
{features - fixNFTokenNegOffer - featureNonFungibleTokensV1_1 -
fixUnburnableNFToken,
NonFungibleTokensV1_2,
features - fixNFTokenNegOffer - featureNonFungibleTokensV1_1,
features | fixNFTokenNegOffer})
{
Expand Down Expand Up @@ -5003,7 +5004,7 @@ class NFToken_test : public beast::unit_test::suite
}
{
// 1. If fixNFTokenNegOffer is enabled get tecOBJECT_NOT_FOUND
// 2. If it is not enabled, but fixUnburnableNFToken is
// 2. If it is not enabled, but NonFungibleTokensV1_2 is
// enabled, get tecOBJECT_NOT_FOUND.
// 3. If neither are enabled, get tesSUCCESS.
TER const offerAcceptTER = tweakedFeatures[fixNFTokenNegOffer]
Expand Down Expand Up @@ -5145,7 +5146,8 @@ class NFToken_test : public beast::unit_test::suite
testcase("Payments with IOU transfer fees");

for (auto const& tweakedFeatures :
{features - fixUnburnableNFToken, features | fixUnburnableNFToken})
{features - NonFungibleTokensV1_2,
features | NonFungibleTokensV1_2})
{
Env env{*this, tweakedFeatures};

Expand Down Expand Up @@ -5297,13 +5299,13 @@ class NFToken_test : public beast::unit_test::suite
auto const nftID = mintNFT(minter);
auto const offerID =
createSellOffer(minter, nftID, gwXAU(1000));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tecINSUFFICIENT_FUNDS)
: static_cast<TER>(tesSUCCESS);
env(token::acceptSellOffer(buyer, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
expectInitialState();
else
{
Expand All @@ -5321,13 +5323,13 @@ class NFToken_test : public beast::unit_test::suite
auto const nftID = mintNFT(minter);
auto const offerID =
createBuyOffer(buyer, minter, nftID, gwXAU(1000));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tecINSUFFICIENT_FUNDS)
: static_cast<TER>(tesSUCCESS);
env(token::acceptBuyOffer(minter, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
expectInitialState();
else
{
Expand All @@ -5345,13 +5347,13 @@ class NFToken_test : public beast::unit_test::suite
reinitializeTrustLineBalances();
auto const nftID = mintNFT(minter);
auto const offerID = createSellOffer(minter, nftID, gwXAU(995));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tecINSUFFICIENT_FUNDS)
: static_cast<TER>(tesSUCCESS);
env(token::acceptSellOffer(buyer, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
expectInitialState();
else
{
Expand All @@ -5369,13 +5371,13 @@ class NFToken_test : public beast::unit_test::suite
auto const nftID = mintNFT(minter);
auto const offerID =
createBuyOffer(buyer, minter, nftID, gwXAU(995));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tecINSUFFICIENT_FUNDS)
: static_cast<TER>(tesSUCCESS);
env(token::acceptBuyOffer(minter, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
expectInitialState();
else
{
Expand Down Expand Up @@ -5470,13 +5472,13 @@ class NFToken_test : public beast::unit_test::suite
auto const nftID = mintNFT(minter);
auto const offerID =
createSellOffer(minter, nftID, gwXAU(1000));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tesSUCCESS)
: static_cast<TER>(tecINSUFFICIENT_FUNDS);
env(token::acceptSellOffer(gw, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
{
BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(1000));
BEAST_EXPECT(
Expand All @@ -5491,18 +5493,18 @@ class NFToken_test : public beast::unit_test::suite
reinitializeTrustLineBalances();

auto const nftID = mintNFT(minter);
auto const offerTER = tweakedFeatures[fixUnburnableNFToken]
auto const offerTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tesSUCCESS)
: static_cast<TER>(tecUNFUNDED_OFFER);
auto const offerID =
createBuyOffer(gw, minter, nftID, gwXAU(1000), {offerTER});
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tesSUCCESS)
: static_cast<TER>(tecOBJECT_NOT_FOUND);
env(token::acceptBuyOffer(minter, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
{
BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(1000));
BEAST_EXPECT(
Expand All @@ -5518,13 +5520,13 @@ class NFToken_test : public beast::unit_test::suite
auto const nftID = mintNFT(minter);
auto const offerID =
createSellOffer(minter, nftID, gwXAU(5000));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tesSUCCESS)
: static_cast<TER>(tecINSUFFICIENT_FUNDS);
env(token::acceptSellOffer(gw, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
{
BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(5000));
BEAST_EXPECT(
Expand All @@ -5539,18 +5541,18 @@ class NFToken_test : public beast::unit_test::suite
reinitializeTrustLineBalances();

auto const nftID = mintNFT(minter);
auto const offerTER = tweakedFeatures[fixUnburnableNFToken]
auto const offerTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tesSUCCESS)
: static_cast<TER>(tecUNFUNDED_OFFER);
auto const offerID =
createBuyOffer(gw, minter, nftID, gwXAU(5000), {offerTER});
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tesSUCCESS)
: static_cast<TER>(tecOBJECT_NOT_FOUND);
env(token::acceptBuyOffer(minter, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
{
BEAST_EXPECT(env.balance(minter, gwXAU) == gwXAU(5000));
BEAST_EXPECT(
Expand Down Expand Up @@ -5692,13 +5694,13 @@ class NFToken_test : public beast::unit_test::suite
// now we can do a secondary sale
auto const offerID =
createSellOffer(secondarySeller, nftID, gwXAU(1000));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tecINSUFFICIENT_FUNDS)
: static_cast<TER>(tesSUCCESS);
env(token::acceptSellOffer(buyer, offerID), ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
expectInitialState();
else
{
Expand Down Expand Up @@ -5728,14 +5730,14 @@ class NFToken_test : public beast::unit_test::suite
// now we can do a secondary sale
auto const offerID =
createBuyOffer(buyer, secondarySeller, nftID, gwXAU(1000));
auto const sellTER = tweakedFeatures[fixUnburnableNFToken]
auto const sellTER = tweakedFeatures[NonFungibleTokensV1_2]
? static_cast<TER>(tecINSUFFICIENT_FUNDS)
: static_cast<TER>(tesSUCCESS);
env(token::acceptBuyOffer(secondarySeller, offerID),
ter(sellTER));
env.close();

if (tweakedFeatures[fixUnburnableNFToken])
if (tweakedFeatures[NonFungibleTokensV1_2])
expectInitialState();
else
{
Expand Down Expand Up @@ -5901,7 +5903,7 @@ class NFToken_test : public beast::unit_test::suite
// the NFToken being bought and returned to the original owner and
// the broker pocketing the profit.
//
// This unit test verifies that the fixUnburnableNFToken amendment
// This unit test verifies that the NonFungibleTokensV1_2 amendment
// fixes that bug.
testcase("Brokered sale to self");

Expand Down Expand Up @@ -5967,7 +5969,7 @@ class NFToken_test : public beast::unit_test::suite
BEAST_EXPECT(nftCount(env, bob) == 1);
auto const bobsPriorBalance = env.balance(bob);
auto const brokersPriorBalance = env.balance(broker);
TER expectTer = features[fixUnburnableNFToken]
TER expectTer = features[NonFungibleTokensV1_2]
? TER(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)
: TER(tesSUCCESS);
env(token::brokerOffers(broker, bobBuyOfferIndex, bobSellOfferIndex),
Expand Down Expand Up @@ -6038,9 +6040,9 @@ class NFToken_test : public beast::unit_test::suite
FeatureBitset const all{supported_amendments()};
FeatureBitset const fixNFTDir{fixNFTokenDirV1};

testWithFeats(all - fixNFTDir - fixUnburnableNFToken);
testWithFeats(all - disallowIncoming - fixUnburnableNFToken);
testWithFeats(all - fixUnburnableNFToken);
testWithFeats(all - fixNFTDir - NonFungibleTokensV1_2);
testWithFeats(all - disallowIncoming - NonFungibleTokensV1_2);
testWithFeats(all - NonFungibleTokensV1_2);
testWithFeats(all);
}
};
Expand Down

0 comments on commit 820fcfa

Please sign in to comment.