Skip to content

Commit

Permalink
simplify sfTicketSequence TxFormats logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mvadari committed Sep 1, 2023
1 parent f31c50d commit 0474732
Showing 1 changed file with 22 additions and 34 deletions.
56 changes: 22 additions & 34 deletions src/ripple/protocol/impl/TxFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ namespace ripple {
TxFormats::TxFormats()
{
// Fields shared by all txFormats:
static const std::initializer_list<SOElement> pseudoCommonFields{
{sfTransactionType, soeREQUIRED},
{sfFlags, soeOPTIONAL},
{sfSourceTag, soeOPTIONAL},
{sfAccount, soeREQUIRED},
{sfSequence, soeREQUIRED},
{sfPreviousTxnID, soeOPTIONAL}, // emulate027
{sfLastLedgerSequence, soeOPTIONAL},
{sfAccountTxnID, soeOPTIONAL},
{sfFee, soeREQUIRED},
{sfOperationLimit, soeOPTIONAL},
{sfMemos, soeOPTIONAL},
{sfSigningPubKey, soeREQUIRED},
{sfTxnSignature, soeOPTIONAL},
{sfSigners, soeOPTIONAL}, // submit_multisigned
{sfNetworkID, soeOPTIONAL},
};

static const std::initializer_list<SOElement> commonFields{
{sfTransactionType, soeREQUIRED},
{sfFlags, soeOPTIONAL},
Expand All @@ -41,6 +59,7 @@ TxFormats::TxFormats()
{sfTxnSignature, soeOPTIONAL},
{sfSigners, soeOPTIONAL}, // submit_multisigned
{sfNetworkID, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
};

add(jss::AccountSet,
Expand All @@ -55,7 +74,6 @@ TxFormats::TxFormats()
{sfSetFlag, soeOPTIONAL},
{sfClearFlag, soeOPTIONAL},
{sfTickSize, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
{sfNFTokenMinter, soeOPTIONAL},
},
commonFields);
Expand All @@ -66,7 +84,6 @@ TxFormats::TxFormats()
{sfLimitAmount, soeOPTIONAL},
{sfQualityIn, soeOPTIONAL},
{sfQualityOut, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -77,7 +94,6 @@ TxFormats::TxFormats()
{sfTakerGets, soeREQUIRED},
{sfExpiration, soeOPTIONAL},
{sfOfferSequence, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -87,7 +103,6 @@ TxFormats::TxFormats()
{sfAmount, soeREQUIRED},
{sfAmount2, soeREQUIRED},
{sfTradingFee, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -100,7 +115,6 @@ TxFormats::TxFormats()
{sfAmount2, soeOPTIONAL},
{sfEPrice, soeOPTIONAL},
{sfLPTokenOut, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
{sfTradingFee, soeOPTIONAL},
},
commonFields);
Expand All @@ -114,7 +128,6 @@ TxFormats::TxFormats()
{sfAmount2, soeOPTIONAL},
{sfEPrice, soeOPTIONAL},
{sfLPTokenIn, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -124,7 +137,6 @@ TxFormats::TxFormats()
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfTradingFee, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -136,7 +148,6 @@ TxFormats::TxFormats()
{sfBidMin, soeOPTIONAL},
{sfBidMax, soeOPTIONAL},
{sfAuthAccounts, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -145,23 +156,20 @@ TxFormats::TxFormats()
{
{sfAsset, soeREQUIRED},
{sfAsset2, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

add(jss::OfferCancel,
ttOFFER_CANCEL,
{
{sfOfferSequence, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

add(jss::SetRegularKey,
ttREGULAR_KEY_SET,
{
{sfRegularKey, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -175,7 +183,6 @@ TxFormats::TxFormats()
{sfInvoiceID, soeOPTIONAL},
{sfDestinationTag, soeOPTIONAL},
{sfDeliverMin, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -188,7 +195,6 @@ TxFormats::TxFormats()
{sfCancelAfter, soeOPTIONAL},
{sfFinishAfter, soeOPTIONAL},
{sfDestinationTag, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -199,7 +205,6 @@ TxFormats::TxFormats()
{sfOfferSequence, soeREQUIRED},
{sfFulfillment, soeOPTIONAL},
{sfCondition, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -208,7 +213,6 @@ TxFormats::TxFormats()
{
{sfOwner, soeREQUIRED},
{sfOfferSequence, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -218,7 +222,7 @@ TxFormats::TxFormats()
{sfLedgerSequence, soeREQUIRED},
{sfAmendment, soeREQUIRED},
},
commonFields);
pseudoCommonFields);

add(jss::SetFee,
ttFEE,
Expand All @@ -234,7 +238,7 @@ TxFormats::TxFormats()
{sfReserveBaseDrops, soeOPTIONAL},
{sfReserveIncrementDrops, soeOPTIONAL},
},
commonFields);
pseudoCommonFields);

add(jss::UNLModify,
ttUNL_MODIFY,
Expand All @@ -243,13 +247,12 @@ TxFormats::TxFormats()
{sfLedgerSequence, soeREQUIRED},
{sfUNLModifyValidator, soeREQUIRED},
},
commonFields);
pseudoCommonFields);

add(jss::TicketCreate,
ttTICKET_CREATE,
{
{sfTicketCount, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -260,7 +263,6 @@ TxFormats::TxFormats()
{
{sfSignerQuorum, soeREQUIRED},
{sfSignerEntries, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -273,7 +275,6 @@ TxFormats::TxFormats()
{sfPublicKey, soeREQUIRED},
{sfCancelAfter, soeOPTIONAL},
{sfDestinationTag, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -283,7 +284,6 @@ TxFormats::TxFormats()
{sfChannel, soeREQUIRED},
{sfAmount, soeREQUIRED},
{sfExpiration, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -295,7 +295,6 @@ TxFormats::TxFormats()
{sfBalance, soeOPTIONAL},
{sfSignature, soeOPTIONAL},
{sfPublicKey, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -307,7 +306,6 @@ TxFormats::TxFormats()
{sfExpiration, soeOPTIONAL},
{sfDestinationTag, soeOPTIONAL},
{sfInvoiceID, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -317,15 +315,13 @@ TxFormats::TxFormats()
{sfCheckID, soeREQUIRED},
{sfAmount, soeOPTIONAL},
{sfDeliverMin, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

add(jss::CheckCancel,
ttCHECK_CANCEL,
{
{sfCheckID, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -334,7 +330,6 @@ TxFormats::TxFormats()
{
{sfDestination, soeREQUIRED},
{sfDestinationTag, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -343,7 +338,6 @@ TxFormats::TxFormats()
{
{sfAuthorize, soeOPTIONAL},
{sfUnauthorize, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -354,7 +348,6 @@ TxFormats::TxFormats()
{sfTransferFee, soeOPTIONAL},
{sfIssuer, soeOPTIONAL},
{sfURI, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -363,7 +356,6 @@ TxFormats::TxFormats()
{
{sfNFTokenID, soeREQUIRED},
{sfOwner, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -375,15 +367,13 @@ TxFormats::TxFormats()
{sfDestination, soeOPTIONAL},
{sfOwner, soeOPTIONAL},
{sfExpiration, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

add(jss::NFTokenCancelOffer,
ttNFTOKEN_CANCEL_OFFER,
{
{sfNFTokenOffers, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

Expand All @@ -393,15 +383,13 @@ TxFormats::TxFormats()
{sfNFTokenBuyOffer, soeOPTIONAL},
{sfNFTokenSellOffer, soeOPTIONAL},
{sfNFTokenBrokerFee, soeOPTIONAL},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);

add(jss::Clawback,
ttCLAWBACK,
{
{sfAmount, soeREQUIRED},
{sfTicketSequence, soeOPTIONAL},
},
commonFields);
}
Expand Down

0 comments on commit 0474732

Please sign in to comment.