Skip to content

Commit

Permalink
[FOLD] Rename SFields to NFTokenMinter and NFTokenBrokerFee
Browse files Browse the repository at this point in the history
  • Loading branch information
scottschurr committed Mar 28, 2022
1 parent 8f9167f commit 7b5ecf3
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 46 deletions.
6 changes: 3 additions & 3 deletions src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ NFTokenAcceptOffer::preflight(PreflightContext const& ctx)

// The `BrokerFee` field must not be present in direct mode but may be
// present and greater than zero in brokered mode.
if (auto const bf = ctx.tx[~sfBrokerFee])
if (auto const bf = ctx.tx[~sfNFTokenBrokerFee])
{
if (!bo || !so)
return temMALFORMED;
Expand Down Expand Up @@ -118,7 +118,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx)
// have, ensure that the seller will get at least as much as they want
// to get *after* this fee is accounted for (but before the issuer's
// cut, if any).
if (auto const brokerFee = ctx.tx[~sfBrokerFee])
if (auto const brokerFee = ctx.tx[~sfNFTokenBrokerFee])
{
if (brokerFee->issue() != (*bo)[sfAmount].issue())
return tecNFTOKEN_BUY_SELL_MISMATCH;
Expand Down Expand Up @@ -311,7 +311,7 @@ NFTokenAcceptOffer::doApply()
// being paid out than the seller authorized. That would be bad!

// Send the broker the amount they requested.
if (auto const cut = ctx_.tx[~sfBrokerFee];
if (auto const cut = ctx_.tx[~sfNFTokenBrokerFee];
cut && cut.value() != beast::zero)
{
if (auto const r = pay(buyer, account_, cut.value());
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/NFTokenBurn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ NFTokenBurn::preclaim(PreclaimContext const& ctx)
{
if (auto const sle = ctx.view.read(keylet::account(issuer)); sle)
{
if (auto const minter = (*sle)[~sfMinter]; minter != account)
if (auto const minter = (*sle)[~sfNFTokenMinter];
minter != account)
return tecNO_PERMISSION;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/NFTokenCreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ NFTokenCreateOffer::preclaim(PreclaimContext const& ctx)
auto const root = ctx.view.read(keylet::account(issuer));
assert(root);

if (auto minter = (*root)[~sfMinter]; minter != ctx.tx[sfAccount])
if (auto minter = (*root)[~sfNFTokenMinter];
minter != ctx.tx[sfAccount])
return tefNFTOKEN_IS_NOT_TRANSFERABLE;
}

Expand Down
3 changes: 2 additions & 1 deletion src/ripple/app/tx/impl/NFTokenMint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ NFTokenMint::preclaim(PreclaimContext const& ctx)
if (!sle)
return tecNO_ISSUER;

if (auto const minter = (*sle)[~sfMinter]; minter != ctx.tx[sfAccount])
if (auto const minter = (*sle)[~sfNFTokenMinter];
minter != ctx.tx[sfAccount])
return tecNO_PERMISSION;
}

Expand Down
15 changes: 9 additions & 6 deletions src/ripple/app/tx/impl/SetAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ SetAccount::preflight(PreflightContext const& ctx)
if (ctx.rules.enabled(featureNonFungibleTokensV1))
{
// Configure authorized minting account:
if (uSetFlag == asfAuthorizedMinter && !tx.isFieldPresent(sfMinter))
if (uSetFlag == asfAuthorizedNFTokenMinter &&
!tx.isFieldPresent(sfNFTokenMinter))
return temMALFORMED;

if (uClearFlag == asfAuthorizedMinter && tx.isFieldPresent(sfMinter))
if (uClearFlag == asfAuthorizedNFTokenMinter &&
tx.isFieldPresent(sfNFTokenMinter))
return temMALFORMED;
}

Expand Down Expand Up @@ -528,11 +530,12 @@ SetAccount::doApply()
// Configure authorized minting account:
if (ctx_.view().rules().enabled(featureNonFungibleTokensV1))
{
if (uSetFlag == asfAuthorizedMinter)
sle->setAccountID(sfMinter, ctx_.tx[sfMinter]);
if (uSetFlag == asfAuthorizedNFTokenMinter)
sle->setAccountID(sfNFTokenMinter, ctx_.tx[sfNFTokenMinter]);

if (uClearFlag == asfAuthorizedMinter && sle->isFieldPresent(sfMinter))
sle->makeFieldAbsent(sfMinter);
if (uClearFlag == asfAuthorizedNFTokenMinter &&
sle->isFieldPresent(sfNFTokenMinter))
sle->makeFieldAbsent(sfNFTokenMinter);
}

if (uFlagsIn != uFlagsOut)
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/proto/org/xrpl/rpc/v1/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ message Balance
CurrencyAmount value = 1;
}

message BrokerFee
message NFTokenBrokerFee
{
CurrencyAmount value = 1;
}
Expand Down Expand Up @@ -536,7 +536,7 @@ message Issuer
AccountAddress value = 1;
}

message Minter
message NFTokenMinter
{
AccountAddress value = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/proto/org/xrpl/rpc/v1/ledger_objects.proto
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ message AccountRoot

MintedNFTokens minted_nftokens = 17;

Minter minter = 18;
NFTokenMinter nftoken_minter = 18;

RegularKey regular_key = 12;

Expand Down
4 changes: 2 additions & 2 deletions src/ripple/proto/org/xrpl/rpc/v1/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ message AccountSet

TickSize tick_size = 7;

Minter minter = 8;
NFTokenMinter nftoken_minter = 8;
}

// Next field: 3
Expand Down Expand Up @@ -220,7 +220,7 @@ message EscrowFinish
// Next field: 4
message NFTokenAcceptOffer
{
BrokerFee broker_fee = 1;
NFTokenBrokerFee nftoken_broker_fee = 1;

BuyOffer buy_offer = 2;

Expand Down
4 changes: 2 additions & 2 deletions src/ripple/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ extern SF_AMOUNT const sfDeliverMin;
extern SF_AMOUNT const sfMinimumOffer;
extern SF_AMOUNT const sfRippleEscrow;
extern SF_AMOUNT const sfDeliveredAmount;
extern SF_AMOUNT const sfBrokerFee;
extern SF_AMOUNT const sfNFTokenBrokerFee;

// variable length (common)
extern SF_VL const sfPublicKey;
Expand Down Expand Up @@ -492,7 +492,7 @@ extern SF_ACCOUNT const sfIssuer;
extern SF_ACCOUNT const sfAuthorize;
extern SF_ACCOUNT const sfUnauthorize;
extern SF_ACCOUNT const sfRegularKey;
extern SF_ACCOUNT const sfMinter;
extern SF_ACCOUNT const sfNFTokenMinter;

// path set
extern SField const sfPaths;
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/TxFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ constexpr std::uint32_t asfNoFreeze = 6;
constexpr std::uint32_t asfGlobalFreeze = 7;
constexpr std::uint32_t asfDefaultRipple = 8;
constexpr std::uint32_t asfDepositAuth = 9;
constexpr std::uint32_t asfAuthorizedMinter = 10;
constexpr std::uint32_t asfAuthorizedNFTokenMinter = 10;

// OfferCreate flags:
constexpr std::uint32_t tfPassive = 0x00010000;
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/protocol/impl/LedgerFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ LedgerFormats::LedgerFormats()
{sfDomain, soeOPTIONAL},
{sfTickSize, soeOPTIONAL},
{sfTicketCount, soeOPTIONAL},
{sfMinter, soeOPTIONAL},
{sfNFTokenMinter, soeOPTIONAL},
{sfMintedNFTokens, soeDEFAULT},
{sfBurnedNFTokens, soeDEFAULT},
},
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/protocol/impl/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ CONSTRUCT_TYPED_SFIELD(sfDeliverMin, "DeliverMin", AMOUNT,
CONSTRUCT_TYPED_SFIELD(sfMinimumOffer, "MinimumOffer", AMOUNT, 16);
CONSTRUCT_TYPED_SFIELD(sfRippleEscrow, "RippleEscrow", AMOUNT, 17);
CONSTRUCT_TYPED_SFIELD(sfDeliveredAmount, "DeliveredAmount", AMOUNT, 18);
CONSTRUCT_TYPED_SFIELD(sfBrokerFee, "BrokerFee", AMOUNT, 19);
CONSTRUCT_TYPED_SFIELD(sfNFTokenBrokerFee, "NFTokenBrokerFee", AMOUNT, 19);

// variable length (common)
CONSTRUCT_TYPED_SFIELD(sfPublicKey, "PublicKey", VL, 1);
Expand Down Expand Up @@ -246,7 +246,7 @@ CONSTRUCT_TYPED_SFIELD(sfAuthorize, "Authorize", ACCOUNT,
CONSTRUCT_TYPED_SFIELD(sfUnauthorize, "Unauthorize", ACCOUNT, 6);
// 7 is currently unused
CONSTRUCT_TYPED_SFIELD(sfRegularKey, "RegularKey", ACCOUNT, 8);
CONSTRUCT_TYPED_SFIELD(sfMinter, "Minter", ACCOUNT, 9);
CONSTRUCT_TYPED_SFIELD(sfNFTokenMinter, "NFTokenMinter", ACCOUNT, 9);

// vector of 256-bit
CONSTRUCT_TYPED_SFIELD(sfIndexes, "Indexes", VECTOR256, 1, SField::sMD_Never);
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/protocol/impl/TxFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TxFormats::TxFormats()
{sfClearFlag, soeOPTIONAL},
{sfTickSize, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
{sfMinter, soeOPTIONAL},
{sfNFTokenMinter, soeOPTIONAL},
},
commonFields);

Expand Down Expand Up @@ -318,7 +318,7 @@ TxFormats::TxFormats()
{
{sfBuyOffer, soeOPTIONAL},
{sfSellOffer, soeOPTIONAL},
{sfBrokerFee, soeOPTIONAL},
{sfNFTokenBrokerFee, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);
Expand Down
16 changes: 9 additions & 7 deletions src/ripple/rpc/impl/GRPCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,18 +925,20 @@ populateMintedNFTokens(T& to, STObject const& from)

template <class T>
void
populateMinter(T& to, STObject const& from)
populateNFTokenMinter(T& to, STObject const& from)
{
populateProtoAccount(
[&to]() { return to.mutable_minter(); }, from, sfMinter);
[&to]() { return to.mutable_nftoken_minter(); }, from, sfNFTokenMinter);
}

template <class T>
void
populateBrokerFee(T& to, STObject const& from)
populateNFTokenBrokerFee(T& to, STObject const& from)
{
populateProtoAmount(
[&to]() { return to.mutable_broker_fee(); }, from, sfBrokerFee);
[&to]() { return to.mutable_nftoken_broker_fee(); },
from,
sfNFTokenBrokerFee);
}

template <class T>
Expand Down Expand Up @@ -1135,7 +1137,7 @@ convert(org::xrpl::rpc::v1::AccountSet& to, STObject const& from)

populateMessageKey(to, from);

populateMinter(to, from);
populateNFTokenMinter(to, from);

populateSetFlag(to, from);

Expand Down Expand Up @@ -1245,7 +1247,7 @@ convert(org::xrpl::rpc::v1::EscrowFinish& to, STObject const& from)
void
convert(org::xrpl::rpc::v1::NFTokenAcceptOffer& to, STObject const& from)
{
populateBrokerFee(to, from);
populateNFTokenBrokerFee(to, from);

populateBuyOffer(to, from);

Expand Down Expand Up @@ -1454,7 +1456,7 @@ convert(org::xrpl::rpc::v1::AccountRoot& to, STObject const& from)

populateMintedNFTokens(to, from);

populateMinter(to, from);
populateNFTokenMinter(to, from);
}

void
Expand Down
11 changes: 6 additions & 5 deletions src/test/app/NFToken_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ class NFToken_test : public beast::unit_test::suite
// mint NFTs on alice's behalf. alice gives permission to minter.
env(token::setMinter(alice, minter));
env.close();
BEAST_EXPECT(env.le(alice)->getAccountID(sfMinter) == minter.id());
BEAST_EXPECT(
env.le(alice)->getAccountID(sfNFTokenMinter) == minter.id());

// A lambda that checks minter's and alice's ownerCount,
// mintedCount, and burnedCount all in one fell swoop.
Expand Down Expand Up @@ -1097,20 +1098,20 @@ class NFToken_test : public beast::unit_test::suite
BEAST_EXPECT(ownerCount(env, buyer) == 0);
}

// A buy offer may not contain a sfBrokerFee field.
// A buy offer may not contain a sfNFTokenBrokerFee field.
{
Json::Value jv = token::acceptBuyOffer(buyer, noXferOfferIndex);
jv[sfBrokerFee.jsonName] =
jv[sfNFTokenBrokerFee.jsonName] =
STAmount(500000).getJson(JsonOptions::none);
env(jv, ter(temMALFORMED));
env.close();
BEAST_EXPECT(ownerCount(env, buyer) == 0);
}

// A sell offer may not contain a sfBrokerFee field.
// A sell offer may not contain a sfNFTokenBrokerFee field.
{
Json::Value jv = token::acceptSellOffer(buyer, noXferOfferIndex);
jv[sfBrokerFee.jsonName] =
jv[sfNFTokenBrokerFee.jsonName] =
STAmount(500000).getJson(JsonOptions::none);
env(jv, ter(temMALFORMED));
env.close();
Expand Down
8 changes: 4 additions & 4 deletions src/test/jtx/impl/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,21 +200,21 @@ brokerOffers(
void
brokerFee::operator()(Env& env, JTx& jt) const
{
jt.jv[sfBrokerFee.jsonName] = brokerFee_.getJson(JsonOptions::none);
jt.jv[sfNFTokenBrokerFee.jsonName] = brokerFee_.getJson(JsonOptions::none);
}

Json::Value
setMinter(jtx::Account const& account, jtx::Account const& minter)
{
Json::Value jt = fset(account, asfAuthorizedMinter);
jt[sfMinter.fieldName] = minter.human();
Json::Value jt = fset(account, asfAuthorizedNFTokenMinter);
jt[sfNFTokenMinter.fieldName] = minter.human();
return jt;
}

Json::Value
clearMinter(jtx::Account const& account)
{
return fclear(account, asfAuthorizedMinter);
return fclear(account, asfAuthorizedNFTokenMinter);
}

} // namespace token
Expand Down
2 changes: 1 addition & 1 deletion src/test/jtx/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ brokerOffers(
uint256 const& buyOfferIndex,
uint256 const& sellOfferIndex);

/** Sets the optional BrokerFee field in a brokerOffer transaction. */
/** Sets the optional NFTokenBrokerFee field in a brokerOffer transaction. */
class brokerFee
{
private:
Expand Down
8 changes: 4 additions & 4 deletions src/test/rpc/AccountSet_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ class AccountSet_test : public beast::unit_test::suite
// elsewhere.
continue;
}
if (flag == asfAuthorizedMinter)
if (flag == asfAuthorizedNFTokenMinter)
{
// The asfAuthorizedMinter flag requires the presence or
// absence of the sfMinter field in the transaction. It
// is tested elsewhere.
// The asfAuthorizedNFTokenMinter flag requires the
// presence or absence of the sfNFTokenMinter field in
// the transaction. It is tested elsewhere.
continue;
}
else if (
Expand Down

0 comments on commit 7b5ecf3

Please sign in to comment.