diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index a00d6b85c1b..5537c543d6f 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -308,70 +308,20 @@ foreachFeature(FeatureBitset bs, F&& f) f(bitsetIndexToFeature(i)); } -extern uint256 const featureOwnerPaysFee; -extern uint256 const featureFlow; -extern uint256 const featureFlowCross; -extern uint256 const featureCryptoConditionsSuite; -extern uint256 const fix1513; -extern uint256 const featureDepositAuth; -extern uint256 const featureChecks; -extern uint256 const fix1571; -extern uint256 const fix1543; -extern uint256 const fix1623; -extern uint256 const featureDepositPreauth; -extern uint256 const fix1515; -extern uint256 const fix1578; -extern uint256 const featureMultiSignReserve; -extern uint256 const fixTakerDryOfferRemoval; -extern uint256 const fixMasterKeyAsRegularKey; -extern uint256 const fixCheckThreading; -extern uint256 const fixPayChanRecipientOwnerDir; -extern uint256 const featureDeletableAccounts; -extern uint256 const fixQualityUpperBound; -extern uint256 const featureRequireFullyCanonicalSig; -extern uint256 const fix1781; -extern uint256 const featureHardenedValidations; -extern uint256 const fixAmendmentMajorityCalc; -extern uint256 const featureNegativeUNL; -extern uint256 const featureTicketBatch; -extern uint256 const featureFlowSortStrands; -extern uint256 const fixSTAmountCanonicalize; -extern uint256 const fixRmSmallIncreasedQOffers; -extern uint256 const featureCheckCashMakesTrustLine; -extern uint256 const featureNonFungibleTokensV1; -extern uint256 const featureExpandedSignerList; -extern uint256 const fixNFTokenDirV1; -extern uint256 const fixNFTokenNegOffer; -extern uint256 const featureNonFungibleTokensV1_1; -extern uint256 const fixTrustLinesToSelf; -extern uint256 const fixRemoveNFTokenAutoTrustLine; -extern uint256 const featureImmediateOfferKilled; -extern uint256 const featureDisallowIncoming; -extern uint256 const featureXRPFees; -extern uint256 const featureAMM; -extern uint256 const fixUniversalNumber; -extern uint256 const fixNonFungibleTokensV1_2; -extern uint256 const fixNFTokenRemint; -extern uint256 const fixReducedOffersV1; -extern uint256 const featureClawback; -extern uint256 const featureXChainBridge; -extern uint256 const fixDisallowIncomingV1; -extern uint256 const featureDID; -extern uint256 const fixFillOrKill; -extern uint256 const fixNFTokenReserve; -extern uint256 const fixInnerObjTemplate; -extern uint256 const fixAMMOverflowOffer; -extern uint256 const featurePriceOracle; -extern uint256 const fixEmptyDID; -extern uint256 const fixXChainRewardRounding; -extern uint256 const fixPreviousTxnID; -extern uint256 const fixAMMv1_1; -extern uint256 const featureNFTokenMintOffer; -extern uint256 const fixReducedOffersV2; -extern uint256 const fixEnforceNFTokenTrustline; -extern uint256 const fixInnerObjTemplate2; -extern uint256 const featureInvariantsV1_1; -extern uint256 const fixNFTokenPageLinks; +#pragma push_macro("XRPL_FEATURE") +#undef XRPL_FEATURE +#pragma push_macro("XRPL_FIX") +#undef XRPL_FIX + +#define XRPL_FEATURE(name, supported, vote) extern uint256 const feature##name; +#define XRPL_FIX(name, supported, vote) extern uint256 const fix##name; + +#include + +#undef XRPL_FIX +#pragma pop_macro("XRPL_FIX") +#undef XRPL_FEATURE +#pragma pop_macro("XRPL_FEATURE") } // namespace ripple diff --git a/include/xrpl/protocol/LedgerFormats.h b/include/xrpl/protocol/LedgerFormats.h index 0ee6c992d8d..14fcaa673ab 100644 --- a/include/xrpl/protocol/LedgerFormats.h +++ b/include/xrpl/protocol/LedgerFormats.h @@ -52,150 +52,16 @@ namespace ripple { // clang-format off enum LedgerEntryType : std::uint16_t { - /** A ledger object which describes an account. - \sa keylet::account - */ - ltACCOUNT_ROOT = 0x0061, - - /** A ledger object which contains a list of object identifiers. - - \sa keylet::page, keylet::quality, keylet::book, keylet::next and - keylet::ownerDir - */ - ltDIR_NODE = 0x0064, - - /** A ledger object which describes a bidirectional trust line. - - @note Per Vinnie Falco this should be renamed to ltTRUST_LINE - - \sa keylet::line - */ - ltRIPPLE_STATE = 0x0072, - - /** A ledger object which describes a ticket. - - \sa keylet::ticket - */ - ltTICKET = 0x0054, - - /** A ledger object which contains a signer list for an account. - - \sa keylet::signers - */ - ltSIGNER_LIST = 0x0053, - - /** A ledger object which describes an offer on the DEX. - - \sa keylet::offer - */ - ltOFFER = 0x006f, - - - /** The ledger object which lists details about sidechains. - - \sa keylet::bridge - */ - ltBRIDGE = 0x0069, - - /** A ledger object that contains a list of ledger hashes. - - This type is used to store the ledger hashes which the protocol uses - to implement skip lists that allow for efficient backwards (and, in - theory, forward) forward iteration across large ledger ranges. - - \sa keylet::skip - */ - ltLEDGER_HASHES = 0x0068, - - /** The ledger object which lists details about amendments on the network. - - \note This is a singleton: only one such object exists in the ledger. - - \sa keylet::amendments - */ - ltAMENDMENTS = 0x0066, - - /** A claim id for a cross chain transaction. - - \sa keylet::xChainClaimID - */ - ltXCHAIN_OWNED_CLAIM_ID = 0x0071, - - /** A claim id for a cross chain create account transaction. +#pragma push_macro("LEDGER_ENTRY") +#undef LEDGER_ENTRY - \sa keylet::xChainCreateAccountClaimID - */ - ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID = 0x0074, - - /** The ledger object which lists the network's fee settings. - - \note This is a singleton: only one such object exists in the ledger. - - \sa keylet::fees - */ - ltFEE_SETTINGS = 0x0073, - - /** A ledger object describing a single escrow. - - \sa keylet::escrow - */ - ltESCROW = 0x0075, - - /** A ledger object describing a single unidirectional XRP payment channel. - - \sa keylet::payChan - */ - ltPAYCHAN = 0x0078, - - /** A ledger object which describes a check. - - \sa keylet::check - */ - ltCHECK = 0x0043, - - /** A ledger object which describes a deposit preauthorization. - - \sa keylet::depositPreauth - */ - ltDEPOSIT_PREAUTH = 0x0070, +#define LEDGER_ENTRY(tag, value, name, fields) tag = value, - /** The ledger object which tracks the current negative UNL state. +#include - \note This is a singleton: only one such object exists in the ledger. - - \sa keylet::negativeUNL - */ - ltNEGATIVE_UNL = 0x004e, - - /** A ledger object which contains a list of NFTs - - \sa keylet::nftpage_min, keylet::nftpage_max, keylet::nftpage - */ - ltNFTOKEN_PAGE = 0x0050, - - /** A ledger object which identifies an offer to buy or sell an NFT. - - \sa keylet::nftoffer - */ - ltNFTOKEN_OFFER = 0x0037, - - /** The ledger object which tracks the AMM. - - \sa keylet::amm - */ - ltAMM = 0x0079, - - /** The ledger object which tracks the DID. - - \sa keylet::did - */ - ltDID = 0x0049, - - /** A ledger object which tracks Oracle - \sa keylet::oracle - */ - ltORACLE = 0x0080, +#undef LEDGER_ENTRY +#pragma pop_macro("LEDGER_ENTRY") //--------------------------------------------------------------------------- /** A special type, matching any ledger entry type. diff --git a/include/xrpl/protocol/SField.h b/include/xrpl/protocol/SField.h index 7f54201a4b8..c370239ca19 100644 --- a/include/xrpl/protocol/SField.h +++ b/include/xrpl/protocol/SField.h @@ -218,6 +218,11 @@ class SField return jsonName; } + operator Json::StaticString const&() const + { + return jsonName; + } + bool isInvalid() const { @@ -355,329 +360,26 @@ using SF_XCHAIN_BRIDGE = TypedField; //------------------------------------------------------------------------------ +// Use macros for most SField construction to enforce naming conventions. +#pragma push_macro("UNTYPED_SFIELD") +#undef UNTYPED_SFIELD +#pragma push_macro("TYPED_SFIELD") +#undef TYPED_SFIELD + +#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \ + extern SField const sfName; +#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \ + extern SF_##stiSuffix const sfName; + extern SField const sfInvalid; extern SField const sfGeneric; -extern SField const sfLedgerEntry; -extern SField const sfTransaction; -extern SField const sfValidation; -extern SField const sfMetadata; - -// 8-bit integers (common) -extern SF_UINT8 const sfCloseResolution; -extern SF_UINT8 const sfMethod; -extern SF_UINT8 const sfTransactionResult; -extern SF_UINT8 const sfWasLockingChainSend; -extern SF_UINT8 const sfScale; - -// 8-bit integers (uncommon) -extern SF_UINT8 const sfTickSize; -extern SF_UINT8 const sfUNLModifyDisabling; -extern SF_UINT8 const sfHookResult; - -// 16-bit integers (common) -extern SF_UINT16 const sfLedgerEntryType; -extern SF_UINT16 const sfTransactionType; -extern SF_UINT16 const sfSignerWeight; -extern SF_UINT16 const sfTransferFee; -extern SF_UINT16 const sfTradingFee; - -// 16-bit integers (uncommon) -extern SF_UINT16 const sfVersion; -extern SF_UINT16 const sfHookStateChangeCount; -extern SF_UINT16 const sfHookEmitCount; -extern SF_UINT16 const sfHookExecutionIndex; -extern SF_UINT16 const sfHookApiVersion; -extern SF_UINT16 const sfDiscountedFee; -extern SF_UINT16 const sfLedgerFixType; - -// 32-bit integers (common) -extern SF_UINT32 const sfNetworkID; -extern SF_UINT32 const sfFlags; -extern SF_UINT32 const sfSourceTag; -extern SF_UINT32 const sfSequence; -extern SF_UINT32 const sfPreviousTxnLgrSeq; -extern SF_UINT32 const sfLedgerSequence; -extern SF_UINT32 const sfCloseTime; -extern SF_UINT32 const sfParentCloseTime; -extern SF_UINT32 const sfSigningTime; -extern SF_UINT32 const sfExpiration; -extern SF_UINT32 const sfTransferRate; -extern SF_UINT32 const sfWalletSize; -extern SF_UINT32 const sfOwnerCount; -extern SF_UINT32 const sfDestinationTag; -extern SF_UINT32 const sfLastUpdateTime; - -// 32-bit integers (uncommon) -extern SF_UINT32 const sfHighQualityIn; -extern SF_UINT32 const sfHighQualityOut; -extern SF_UINT32 const sfLowQualityIn; -extern SF_UINT32 const sfLowQualityOut; -extern SF_UINT32 const sfQualityIn; -extern SF_UINT32 const sfQualityOut; -extern SF_UINT32 const sfStampEscrow; -extern SF_UINT32 const sfBondAmount; -extern SF_UINT32 const sfLoadFee; -extern SF_UINT32 const sfOfferSequence; -extern SF_UINT32 const sfFirstLedgerSequence; -extern SF_UINT32 const sfLastLedgerSequence; -extern SF_UINT32 const sfTransactionIndex; -extern SF_UINT32 const sfOperationLimit; -extern SF_UINT32 const sfReferenceFeeUnits; -extern SF_UINT32 const sfReserveBase; -extern SF_UINT32 const sfReserveIncrement; -extern SF_UINT32 const sfSetFlag; -extern SF_UINT32 const sfClearFlag; -extern SF_UINT32 const sfSignerQuorum; -extern SF_UINT32 const sfCancelAfter; -extern SF_UINT32 const sfFinishAfter; -extern SF_UINT32 const sfSignerListID; -extern SF_UINT32 const sfSettleDelay; -extern SF_UINT32 const sfTicketCount; -extern SF_UINT32 const sfTicketSequence; -extern SF_UINT32 const sfNFTokenTaxon; -extern SF_UINT32 const sfMintedNFTokens; -extern SF_UINT32 const sfBurnedNFTokens; -extern SF_UINT32 const sfHookStateCount; -extern SF_UINT32 const sfEmitGeneration; -extern SF_UINT32 const sfVoteWeight; -extern SF_UINT32 const sfFirstNFTokenSequence; -extern SF_UINT32 const sfOracleDocumentID; - -// 64-bit integers (common) -extern SF_UINT64 const sfIndexNext; -extern SF_UINT64 const sfIndexPrevious; -extern SF_UINT64 const sfBookNode; -extern SF_UINT64 const sfOwnerNode; -extern SF_UINT64 const sfBaseFee; -extern SF_UINT64 const sfExchangeRate; -extern SF_UINT64 const sfLowNode; -extern SF_UINT64 const sfHighNode; -extern SF_UINT64 const sfDestinationNode; -extern SF_UINT64 const sfCookie; -extern SF_UINT64 const sfServerVersion; -extern SF_UINT64 const sfNFTokenOfferNode; -extern SF_UINT64 const sfEmitBurden; - -// 64-bit integers (uncommon) -extern SF_UINT64 const sfHookOn; -extern SF_UINT64 const sfHookInstructionCount; -extern SF_UINT64 const sfHookReturnCode; -extern SF_UINT64 const sfReferenceCount; -extern SF_UINT64 const sfXChainClaimID; -extern SF_UINT64 const sfXChainAccountCreateCount; -extern SF_UINT64 const sfXChainAccountClaimCount; -extern SF_UINT64 const sfAssetPrice; - -// 128-bit -extern SF_UINT128 const sfEmailHash; - -// 160-bit (common) -extern SF_UINT160 const sfTakerPaysCurrency; -extern SF_UINT160 const sfTakerPaysIssuer; -extern SF_UINT160 const sfTakerGetsCurrency; -extern SF_UINT160 const sfTakerGetsIssuer; - -// 256-bit (common) -extern SF_UINT256 const sfLedgerHash; -extern SF_UINT256 const sfParentHash; -extern SF_UINT256 const sfTransactionHash; -extern SF_UINT256 const sfAccountHash; -extern SF_UINT256 const sfPreviousTxnID; -extern SF_UINT256 const sfLedgerIndex; -extern SF_UINT256 const sfWalletLocator; -extern SF_UINT256 const sfRootIndex; -extern SF_UINT256 const sfAccountTxnID; -extern SF_UINT256 const sfNFTokenID; -extern SF_UINT256 const sfEmitParentTxnID; -extern SF_UINT256 const sfEmitNonce; -extern SF_UINT256 const sfEmitHookHash; -extern SF_UINT256 const sfAMMID; - -// 256-bit (uncommon) -extern SF_UINT256 const sfBookDirectory; -extern SF_UINT256 const sfInvoiceID; -extern SF_UINT256 const sfNickname; -extern SF_UINT256 const sfAmendment; -extern SF_UINT256 const sfDigest; -extern SF_UINT256 const sfChannel; -extern SF_UINT256 const sfConsensusHash; -extern SF_UINT256 const sfCheckID; -extern SF_UINT256 const sfValidatedHash; -extern SF_UINT256 const sfPreviousPageMin; -extern SF_UINT256 const sfNextPageMin; -extern SF_UINT256 const sfNFTokenBuyOffer; -extern SF_UINT256 const sfNFTokenSellOffer; -extern SF_UINT256 const sfHookStateKey; -extern SF_UINT256 const sfHookHash; -extern SF_UINT256 const sfHookNamespace; -extern SF_UINT256 const sfHookSetTxnID; - -// currency amount (common) -extern SF_AMOUNT const sfAmount; -extern SF_AMOUNT const sfBalance; -extern SF_AMOUNT const sfLimitAmount; -extern SF_AMOUNT const sfTakerPays; -extern SF_AMOUNT const sfTakerGets; -extern SF_AMOUNT const sfLowLimit; -extern SF_AMOUNT const sfHighLimit; -extern SF_AMOUNT const sfFee; -extern SF_AMOUNT const sfSendMax; -extern SF_AMOUNT const sfDeliverMin; -extern SF_AMOUNT const sfAmount2; -extern SF_AMOUNT const sfEPrice; -extern SF_AMOUNT const sfBidMin; -extern SF_AMOUNT const sfBidMax; -extern SF_AMOUNT const sfPrice; -extern SF_AMOUNT const sfLPTokenBalance; - -// currency amount (uncommon) -extern SF_AMOUNT const sfMinimumOffer; -extern SF_AMOUNT const sfRippleEscrow; -extern SF_AMOUNT const sfDeliveredAmount; -extern SF_AMOUNT const sfNFTokenBrokerFee; -extern SF_AMOUNT const sfLPTokenOut; -extern SF_AMOUNT const sfLPTokenIn; - -// currency amount (fees) -extern SF_AMOUNT const sfBaseFeeDrops; -extern SF_AMOUNT const sfReserveBaseDrops; -extern SF_AMOUNT const sfReserveIncrementDrops; -extern SF_AMOUNT const sfSignatureReward; -extern SF_AMOUNT const sfMinAccountCreateAmount; - -// variable length (common) -extern SF_VL const sfPublicKey; -extern SF_VL const sfMessageKey; -extern SF_VL const sfSigningPubKey; -extern SF_VL const sfTxnSignature; -extern SF_VL const sfURI; -extern SF_VL const sfSignature; -extern SF_VL const sfDomain; -extern SF_VL const sfFundCode; -extern SF_VL const sfRemoveCode; -extern SF_VL const sfExpireCode; -extern SF_VL const sfCreateCode; -extern SF_VL const sfMemoType; -extern SF_VL const sfMemoData; -extern SF_VL const sfMemoFormat; -extern SF_VL const sfDIDDocument; -extern SF_VL const sfData; -extern SF_VL const sfAssetClass; -extern SF_VL const sfProvider; - -// variable length (uncommon) -extern SF_VL const sfFulfillment; -extern SF_VL const sfCondition; -extern SF_VL const sfMasterSignature; -extern SF_VL const sfUNLModifyValidator; -extern SF_VL const sfValidatorToDisable; -extern SF_VL const sfValidatorToReEnable; -extern SF_VL const sfHookStateData; -extern SF_VL const sfHookReturnString; -extern SF_VL const sfHookParameterName; -extern SF_VL const sfHookParameterValue; - -// account -extern SF_ACCOUNT const sfAccount; -extern SF_ACCOUNT const sfOwner; -extern SF_ACCOUNT const sfDestination; -extern SF_ACCOUNT const sfIssuer; -extern SF_ACCOUNT const sfAuthorize; -extern SF_ACCOUNT const sfUnauthorize; -extern SF_ACCOUNT const sfRegularKey; -extern SF_ACCOUNT const sfNFTokenMinter; -extern SF_ACCOUNT const sfEmitCallback; - -// account (uncommon) -extern SF_ACCOUNT const sfHookAccount; -extern SF_ACCOUNT const sfOtherChainSource; -extern SF_ACCOUNT const sfOtherChainDestination; -extern SF_ACCOUNT const sfAttestationSignerAccount; -extern SF_ACCOUNT const sfAttestationRewardAccount; -extern SF_ACCOUNT const sfLockingChainDoor; -extern SF_ACCOUNT const sfIssuingChainDoor; - -// path set -extern SField const sfPaths; - -// currency -extern SF_CURRENCY const sfBaseAsset; -extern SF_CURRENCY const sfQuoteAsset; - -// issue -extern SF_ISSUE const sfAsset; -extern SF_ISSUE const sfAsset2; -extern SF_ISSUE const sfLockingChainIssue; -extern SF_ISSUE const sfIssuingChainIssue; - -// bridge -extern SF_XCHAIN_BRIDGE const sfXChainBridge; - -// vector of 256-bit -extern SF_VECTOR256 const sfIndexes; -extern SF_VECTOR256 const sfHashes; -extern SF_VECTOR256 const sfAmendments; -extern SF_VECTOR256 const sfNFTokenOffers; - -// inner object -// OBJECT/1 is reserved for end of object -extern SField const sfTransactionMetaData; -extern SField const sfCreatedNode; -extern SField const sfDeletedNode; -extern SField const sfModifiedNode; -extern SField const sfPreviousFields; -extern SField const sfFinalFields; -extern SField const sfNewFields; -extern SField const sfTemplateEntry; -extern SField const sfMemo; -extern SField const sfSignerEntry; -extern SField const sfNFToken; -extern SField const sfEmitDetails; -extern SField const sfHook; -extern SField const sfVoteEntry; -extern SField const sfAuctionSlot; -extern SField const sfAuthAccount; -extern SField const sfPriceData; - -extern SField const sfSigner; -extern SField const sfMajority; -extern SField const sfDisabledValidator; -extern SField const sfEmittedTxn; -extern SField const sfHookExecution; -extern SField const sfHookDefinition; -extern SField const sfHookParameter; -extern SField const sfHookGrant; -extern SField const sfXChainClaimProofSig; -extern SField const sfXChainCreateAccountProofSig; -extern SField const sfXChainClaimAttestationCollectionElement; -extern SField const sfXChainCreateAccountAttestationCollectionElement; - -// array of objects (common) -// ARRAY/1 is reserved for end of array -// extern SField const sfSigningAccounts; // Never been used. -extern SField const sfSigners; -extern SField const sfSignerEntries; -extern SField const sfTemplate; -extern SField const sfNecessary; -extern SField const sfSufficient; -extern SField const sfAffectedNodes; -extern SField const sfMemos; -extern SField const sfNFTokens; -extern SField const sfHooks; -extern SField const sfVoteSlots; -extern SField const sfAuthAccounts; -extern SField const sfPriceDataSeries; - -// array of objects (uncommon) -extern SField const sfMajorities; -extern SField const sfDisabledValidators; -extern SField const sfHookExecutions; -extern SField const sfHookParameters; -extern SField const sfHookGrants; -extern SField const sfXChainClaimAttestations; -extern SField const sfXChainCreateAccountAttestations; -//------------------------------------------------------------------------------ +#include + +#undef TYPED_SFIELD +#pragma pop_macro("TYPED_SFIELD") +#undef UNTYPED_SFIELD +#pragma pop_macro("UNTYPED_SFIELD") } // namespace ripple diff --git a/include/xrpl/protocol/TxFormats.h b/include/xrpl/protocol/TxFormats.h index a3f5cca108c..2f9121cecb4 100644 --- a/include/xrpl/protocol/TxFormats.h +++ b/include/xrpl/protocol/TxFormats.h @@ -55,168 +55,28 @@ namespace ripple { // clang-format off enum TxType : std::uint16_t { - /** This transaction type executes a payment. */ - ttPAYMENT = 0, - /** This transaction type creates an escrow object. */ - ttESCROW_CREATE = 1, +#pragma push_macro("TRANSACTION") +#undef TRANSACTION - /** This transaction type completes an existing escrow. */ - ttESCROW_FINISH = 2, +#define TRANSACTION(tag, value, name, fields) tag = value, - /** This transaction type adjusts various account settings. */ - ttACCOUNT_SET = 3, +#include - /** This transaction type cancels an existing escrow. */ - ttESCROW_CANCEL = 4, - - /** This transaction type sets or clears an account's "regular key". */ - ttREGULAR_KEY_SET = 5, +#undef TRANSACTION +#pragma pop_macro("TRANSACTION") /** This transaction type is deprecated; it is retained for historical purposes. */ ttNICKNAME_SET [[deprecated("This transaction type is not supported and should not be used.")]] = 6, - /** This transaction type creates an offer to trade one asset for another. */ - ttOFFER_CREATE = 7, - - /** This transaction type cancels existing offers to trade one asset for another. */ - ttOFFER_CANCEL = 8, - /** This transaction type is deprecated; it is retained for historical purposes. */ ttCONTRACT [[deprecated("This transaction type is not supported and should not be used.")]] = 9, - /** This transaction type creates a new set of tickets. */ - ttTICKET_CREATE = 10, - /** This identifier was never used, but the slot is reserved for historical purposes. */ ttSPINAL_TAP [[deprecated("This transaction type is not supported and should not be used.")]] = 11, - /** This transaction type modifies the signer list associated with an account. */ - ttSIGNER_LIST_SET = 12, - - /** This transaction type creates a new unidirectional XRP payment channel. */ - ttPAYCHAN_CREATE = 13, - - /** This transaction type funds an existing unidirectional XRP payment channel. */ - ttPAYCHAN_FUND = 14, - - /** This transaction type submits a claim against an existing unidirectional payment channel. */ - ttPAYCHAN_CLAIM = 15, - - /** This transaction type creates a new check. */ - ttCHECK_CREATE = 16, - - /** This transaction type cashes an existing check. */ - ttCHECK_CASH = 17, - - /** This transaction type cancels an existing check. */ - ttCHECK_CANCEL = 18, - - /** This transaction type grants or revokes authorization to transfer funds. */ - ttDEPOSIT_PREAUTH = 19, - - /** This transaction type modifies a trustline between two accounts. */ - ttTRUST_SET = 20, - - /** This transaction type deletes an existing account. */ - ttACCOUNT_DELETE = 21, - /** This transaction type installs a hook. */ ttHOOK_SET [[maybe_unused]] = 22, - - /** This transaction mints a new NFT. */ - ttNFTOKEN_MINT = 25, - - /** This transaction burns (i.e. destroys) an existing NFT. */ - ttNFTOKEN_BURN = 26, - - /** This transaction creates a new offer to buy or sell an NFT. */ - ttNFTOKEN_CREATE_OFFER = 27, - - /** This transaction cancels an existing offer to buy or sell an existing NFT. */ - ttNFTOKEN_CANCEL_OFFER = 28, - - /** This transaction accepts an existing offer to buy or sell an existing NFT. */ - ttNFTOKEN_ACCEPT_OFFER = 29, - - /** This transaction claws back issued tokens. */ - ttCLAWBACK = 30, - - /** This transaction type creates an AMM instance */ - ttAMM_CREATE = 35, - - /** This transaction type deposits into an AMM instance */ - ttAMM_DEPOSIT = 36, - - /** This transaction type withdraws from an AMM instance */ - ttAMM_WITHDRAW = 37, - - /** This transaction type votes for the trading fee */ - ttAMM_VOTE = 38, - - /** This transaction type bids for the auction slot */ - ttAMM_BID = 39, - - /** This transaction type deletes AMM in the empty state */ - ttAMM_DELETE = 40, - - /** This transactions creates a crosschain sequence number */ - ttXCHAIN_CREATE_CLAIM_ID = 41, - - /** This transactions initiates a crosschain transaction */ - ttXCHAIN_COMMIT = 42, - - /** This transaction completes a crosschain transaction */ - ttXCHAIN_CLAIM = 43, - - /** This transaction initiates a crosschain account create transaction */ - ttXCHAIN_ACCOUNT_CREATE_COMMIT = 44, - - /** This transaction adds an attestation to a claimid*/ - ttXCHAIN_ADD_CLAIM_ATTESTATION = 45, - - /** This transaction adds an attestation to a claimid*/ - ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION = 46, - - /** This transaction modifies a sidechain */ - ttXCHAIN_MODIFY_BRIDGE = 47, - - /** This transactions creates a sidechain */ - ttXCHAIN_CREATE_BRIDGE = 48, - - /** This transaction type creates or updates a DID */ - ttDID_SET = 49, - - /** This transaction type deletes a DID */ - ttDID_DELETE = 50, - - /** This transaction type creates an Oracle instance */ - ttORACLE_SET = 51, - - /** This transaction type deletes an Oracle instance */ - ttORACLE_DELETE = 52, - - /** This transaction type fixes a problem in the ledger state */ - ttLEDGER_STATE_FIX = 53, - - - /** This system-generated transaction type is used to update the status of the various amendments. - - For details, see: https://xrpl.org/amendments.html - */ - ttAMENDMENT = 100, - - /** This system-generated transaction type is used to update the network's fee settings. - - For details, see: https://xrpl.org/fee-voting.html - */ - ttFEE = 101, - - /** This system-generated transaction type is used to update the network's negative UNL - - For details, see: https://xrpl.org/negative-unl.html - */ - ttUNL_MODIFY = 102, }; // clang-format on diff --git a/include/xrpl/protocol/detail/features.macro b/include/xrpl/protocol/detail/features.macro new file mode 100644 index 00000000000..159bc3720b7 --- /dev/null +++ b/include/xrpl/protocol/detail/features.macro @@ -0,0 +1,112 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2024 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#if !defined(XRPL_FEATURE) +#error "undefined macro: XRPL_FEATURE" +#endif +#if !defined(XRPL_FIX) +#error "undefined macro: XRPL_FIX" +#endif + +// Add new amendments to the top of this list. +// Keep it sorted in reverse chronological order. +// If you add an amendment here, then do not forget to increment `numFeatures` +// in include/xrpl/protocol/Feature.h. + +// InvariantsV1_1 will be changes to Supported::yes when all the +// invariants expected to be included under it are complete. +XRPL_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo) +XRPL_FIX (NFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (InnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (EnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (ReducedOffersV2, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(NFTokenMintOffer, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMv1_1, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (PreviousTxnID, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (XChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (EmptyDID, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(PriceOracle, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (AMMOverflowOffer, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (InnerObjTemplate, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (NFTokenReserve, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (FillOrKill, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(DID, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (DisallowIncomingV1, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(XChainBridge, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (ReducedOffersV1, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (NFTokenRemint, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (NonFungibleTokensV1_2, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (UniversalNumber, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(DisallowIncoming, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(ImmediateOfferKilled, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (RemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (TrustLinesToSelf, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(NonFungibleTokensV1_1, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(ExpandedSignerList, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FEATURE(CheckCashMakesTrustLine, Supported::yes, VoteBehavior::DefaultNo) +XRPL_FIX (RmSmallIncreasedQOffers, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (STAmountCanonicalize, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(TicketBatch, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(NegativeUNL, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (AmendmentMajorityCalc, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(HardenedValidations, Supported::yes, VoteBehavior::DefaultYes) +// fix1781: XRPEndpointSteps should be included in the circular payment check +XRPL_FIX (1781, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes) +// fixQualityUpperBound should be activated before FlowCross +XRPL_FIX (QualityUpperBound, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (PayChanRecipientOwnerDir, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (CheckThreading, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (MasterKeyAsRegularKey, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (TakerDryOfferRemoval, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(MultiSignReserve, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (1578, Supported::yes, VoteBehavior::DefaultYes) +// fix1515: Use liquidity from strands that consume max offers, but mark as dry +XRPL_FIX (1515, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(DepositPreauth, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (1623, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (1543, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (1571, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(Checks, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(DepositAuth, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FIX (1513, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(FlowCross, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes) +XRPL_FEATURE(OwnerPaysFee, Supported::no, VoteBehavior::DefaultNo) + +// The following amendments are obsolete, but must remain supported +// because they could potentially get enabled. +// +// Obsolete features are (usually) not in the ledger, and may have code +// controlled by the feature. They need to be supported because at some +// time in the past, the feature was supported and votable, but never +// passed. So the feature needs to be supported in case it is ever +// enabled (added to the ledger). +// +// If a feature remains obsolete for long enough that no clients are able +// to vote for it, the feature can be removed (entirely?) from the code. +XRPL_FIX (NFTokenNegOffer, Supported::yes, VoteBehavior::Obsolete) +XRPL_FIX (NFTokenDirV1, Supported::yes, VoteBehavior::Obsolete) +XRPL_FEATURE(NonFungibleTokensV1, Supported::yes, VoteBehavior::Obsolete) +XRPL_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete) diff --git a/include/xrpl/protocol/detail/ledger_entries.macro b/include/xrpl/protocol/detail/ledger_entries.macro new file mode 100644 index 00000000000..359000cbbf3 --- /dev/null +++ b/include/xrpl/protocol/detail/ledger_entries.macro @@ -0,0 +1,394 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2024 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#if !defined(LEDGER_ENTRY) +#error "undefined macro: LEDGER_ENTRY" +#endif + +/** + * These objects are listed in order of increasing ledger type ID. + * There are many gaps between these IDs. + * You are welcome to fill them with new object types. + */ + +/** A ledger object which identifies an offer to buy or sell an NFT. + + \sa keylet::nftoffer + */ +LEDGER_ENTRY(ltNFTOKEN_OFFER, 0x0037, NFTokenOffer, ({ + {sfOwner, soeREQUIRED}, + {sfNFTokenID, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfNFTokenOfferNode, soeREQUIRED}, + {sfDestination, soeOPTIONAL}, + {sfExpiration, soeOPTIONAL}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object which describes a check. + + \sa keylet::check + */ +LEDGER_ENTRY(ltCHECK, 0x0043, Check, ({ + {sfAccount, soeREQUIRED}, + {sfDestination, soeREQUIRED}, + {sfSendMax, soeREQUIRED}, + {sfSequence, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfDestinationNode, soeREQUIRED}, + {sfExpiration, soeOPTIONAL}, + {sfInvoiceID, soeOPTIONAL}, + {sfSourceTag, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** The ledger object which tracks the DID. + + \sa keylet::did +*/ +LEDGER_ENTRY(ltDID, 0x0049, DID, ({ + {sfAccount, soeREQUIRED}, + {sfDIDDocument, soeOPTIONAL}, + {sfURI, soeOPTIONAL}, + {sfData, soeOPTIONAL}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** The ledger object which tracks the current negative UNL state. + + \note This is a singleton: only one such object exists in the ledger. + + \sa keylet::negativeUNL + */ +LEDGER_ENTRY(ltNEGATIVE_UNL, 0x004e, NegativeUNL, ({ + {sfDisabledValidators, soeOPTIONAL}, + {sfValidatorToDisable, soeOPTIONAL}, + {sfValidatorToReEnable, soeOPTIONAL}, + {sfPreviousTxnID, soeOPTIONAL}, + {sfPreviousTxnLgrSeq, soeOPTIONAL}, +})) + +/** A ledger object which contains a list of NFTs + + \sa keylet::nftpage_min, keylet::nftpage_max, keylet::nftpage + */ +LEDGER_ENTRY(ltNFTOKEN_PAGE, 0x0050, NFTokenPage, ({ + {sfPreviousPageMin, soeOPTIONAL}, + {sfNextPageMin, soeOPTIONAL}, + {sfNFTokens, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object which contains a signer list for an account. + + \sa keylet::signers + */ +// All fields are soeREQUIRED because there is always a SignerEntries. +// If there are no SignerEntries the node is deleted. +LEDGER_ENTRY(ltSIGNER_LIST, 0x0053, SignerList, ({ + {sfOwnerNode, soeREQUIRED}, + {sfSignerQuorum, soeREQUIRED}, + {sfSignerEntries, soeREQUIRED}, + {sfSignerListID, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object which describes a ticket. + + \sa keylet::ticket + */ +LEDGER_ENTRY(ltTICKET, 0x0054, Ticket, ({ + {sfAccount, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfTicketSequence, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object which describes an account. + + \sa keylet::account + */ +LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, ({ + {sfAccount, soeREQUIRED}, + {sfSequence, soeREQUIRED}, + {sfBalance, soeREQUIRED}, + {sfOwnerCount, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfAccountTxnID, soeOPTIONAL}, + {sfRegularKey, soeOPTIONAL}, + {sfEmailHash, soeOPTIONAL}, + {sfWalletLocator, soeOPTIONAL}, + {sfWalletSize, soeOPTIONAL}, + {sfMessageKey, soeOPTIONAL}, + {sfTransferRate, soeOPTIONAL}, + {sfDomain, soeOPTIONAL}, + {sfTickSize, soeOPTIONAL}, + {sfTicketCount, soeOPTIONAL}, + {sfNFTokenMinter, soeOPTIONAL}, + {sfMintedNFTokens, soeDEFAULT}, + {sfBurnedNFTokens, soeDEFAULT}, + {sfFirstNFTokenSequence, soeOPTIONAL}, + {sfAMMID, soeOPTIONAL}, +})) + +/** A ledger object which contains a list of object identifiers. + + \sa keylet::page, keylet::quality, keylet::book, keylet::next and + keylet::ownerDir + */ +LEDGER_ENTRY(ltDIR_NODE, 0x0064, DirectoryNode, ({ + {sfOwner, soeOPTIONAL}, // for owner directories + {sfTakerPaysCurrency, soeOPTIONAL}, // order book directories + {sfTakerPaysIssuer, soeOPTIONAL}, // order book directories + {sfTakerGetsCurrency, soeOPTIONAL}, // order book directories + {sfTakerGetsIssuer, soeOPTIONAL}, // order book directories + {sfExchangeRate, soeOPTIONAL}, // order book directories + {sfIndexes, soeREQUIRED}, + {sfRootIndex, soeREQUIRED}, + {sfIndexNext, soeOPTIONAL}, + {sfIndexPrevious, soeOPTIONAL}, + {sfNFTokenID, soeOPTIONAL}, + {sfPreviousTxnID, soeOPTIONAL}, + {sfPreviousTxnLgrSeq, soeOPTIONAL}, +})) + +/** The ledger object which lists details about amendments on the network. + + \note This is a singleton: only one such object exists in the ledger. + + \sa keylet::amendments + */ +LEDGER_ENTRY(ltAMENDMENTS, 0x0066, Amendments, ({ + {sfAmendments, soeOPTIONAL}, // Enabled + {sfMajorities, soeOPTIONAL}, + {sfPreviousTxnID, soeOPTIONAL}, + {sfPreviousTxnLgrSeq, soeOPTIONAL}, +})) + +/** A ledger object that contains a list of ledger hashes. + + This type is used to store the ledger hashes which the protocol uses + to implement skip lists that allow for efficient backwards (and, in + theory, forward) forward iteration across large ledger ranges. + + \sa keylet::skip + */ +LEDGER_ENTRY(ltLEDGER_HASHES, 0x0068, LedgerHashes, ({ + {sfFirstLedgerSequence, soeOPTIONAL}, + {sfLastLedgerSequence, soeOPTIONAL}, + {sfHashes, soeREQUIRED}, +})) + +/** The ledger object which lists details about sidechains. + + \sa keylet::bridge +*/ +LEDGER_ENTRY(ltBRIDGE, 0x0069, Bridge, ({ + {sfAccount, soeREQUIRED}, + {sfSignatureReward, soeREQUIRED}, + {sfMinAccountCreateAmount, soeOPTIONAL}, + {sfXChainBridge, soeREQUIRED}, + {sfXChainClaimID, soeREQUIRED}, + {sfXChainAccountCreateCount, soeREQUIRED}, + {sfXChainAccountClaimCount, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object which describes an offer on the DEX. + + \sa keylet::offer + */ +LEDGER_ENTRY(ltOFFER, 0x006f, Offer, ({ + {sfAccount, soeREQUIRED}, + {sfSequence, soeREQUIRED}, + {sfTakerPays, soeREQUIRED}, + {sfTakerGets, soeREQUIRED}, + {sfBookDirectory, soeREQUIRED}, + {sfBookNode, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfExpiration, soeOPTIONAL}, +})) + +/** A ledger object which describes a deposit preauthorization. + + \sa keylet::depositPreauth + */ +LEDGER_ENTRY(ltDEPOSIT_PREAUTH, 0x0070, DepositPreauth, ({ + {sfAccount, soeREQUIRED}, + {sfAuthorize, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A claim id for a cross chain transaction. + + \sa keylet::xChainClaimID +*/ +LEDGER_ENTRY(ltXCHAIN_OWNED_CLAIM_ID, 0x0071, XChainOwnedClaimID, ({ + {sfAccount, soeREQUIRED}, + {sfXChainBridge, soeREQUIRED}, + {sfXChainClaimID, soeREQUIRED}, + {sfOtherChainSource, soeREQUIRED}, + {sfXChainClaimAttestations, soeREQUIRED}, + {sfSignatureReward, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object which describes a bidirectional trust line. + + @note Per Vinnie Falco this should be renamed to ltTRUST_LINE + + \sa keylet::line + */ +LEDGER_ENTRY(ltRIPPLE_STATE, 0x0072, RippleState, ({ + {sfBalance, soeREQUIRED}, + {sfLowLimit, soeREQUIRED}, + {sfHighLimit, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfLowNode, soeOPTIONAL}, + {sfLowQualityIn, soeOPTIONAL}, + {sfLowQualityOut, soeOPTIONAL}, + {sfHighNode, soeOPTIONAL}, + {sfHighQualityIn, soeOPTIONAL}, + {sfHighQualityOut, soeOPTIONAL}, +})) + +/** The ledger object which lists the network's fee settings. + + \note This is a singleton: only one such object exists in the ledger. + + \sa keylet::fees + */ +LEDGER_ENTRY(ltFEE_SETTINGS, 0x0073, FeeSettings, ({ + // Old version uses raw numbers + {sfBaseFee, soeOPTIONAL}, + {sfReferenceFeeUnits, soeOPTIONAL}, + {sfReserveBase, soeOPTIONAL}, + {sfReserveIncrement, soeOPTIONAL}, + // New version uses Amounts + {sfBaseFeeDrops, soeOPTIONAL}, + {sfReserveBaseDrops, soeOPTIONAL}, + {sfReserveIncrementDrops, soeOPTIONAL}, + {sfPreviousTxnID, soeOPTIONAL}, + {sfPreviousTxnLgrSeq, soeOPTIONAL}, +})) + +/** A claim id for a cross chain create account transaction. + + \sa keylet::xChainCreateAccountClaimID +*/ +LEDGER_ENTRY(ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, 0x0074, XChainOwnedCreateAccountClaimID, ({ + {sfAccount, soeREQUIRED}, + {sfXChainBridge, soeREQUIRED}, + {sfXChainAccountCreateCount, soeREQUIRED}, + {sfXChainCreateAccountAttestations, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) + +/** A ledger object describing a single escrow. + + \sa keylet::escrow + */ +LEDGER_ENTRY(ltESCROW, 0x0075, Escrow, ({ + {sfAccount, soeREQUIRED}, + {sfDestination, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfCondition, soeOPTIONAL}, + {sfCancelAfter, soeOPTIONAL}, + {sfFinishAfter, soeOPTIONAL}, + {sfSourceTag, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfDestinationNode, soeOPTIONAL}, +})) + +/** A ledger object describing a single unidirectional XRP payment channel. + + \sa keylet::payChan + */ +LEDGER_ENTRY(ltPAYCHAN, 0x0078, PayChannel, ({ + {sfAccount, soeREQUIRED}, + {sfDestination, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfBalance, soeREQUIRED}, + {sfPublicKey, soeREQUIRED}, + {sfSettleDelay, soeREQUIRED}, + {sfExpiration, soeOPTIONAL}, + {sfCancelAfter, soeOPTIONAL}, + {sfSourceTag, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, + {sfDestinationNode, soeOPTIONAL}, +})) + +/** The ledger object which tracks the AMM. + + \sa keylet::amm +*/ +LEDGER_ENTRY(ltAMM, 0x0079, AMM, ({ + {sfAccount, soeREQUIRED}, + {sfTradingFee, soeDEFAULT}, + {sfVoteSlots, soeOPTIONAL}, + {sfAuctionSlot, soeOPTIONAL}, + {sfLPTokenBalance, soeREQUIRED}, + {sfAsset, soeREQUIRED}, + {sfAsset2, soeREQUIRED}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeOPTIONAL}, + {sfPreviousTxnLgrSeq, soeOPTIONAL}, +})) + +/** A ledger object which tracks Oracle + \sa keylet::oracle + */ +LEDGER_ENTRY(ltORACLE, 0x0080, Oracle, ({ + {sfOwner, soeREQUIRED}, + {sfProvider, soeREQUIRED}, + {sfPriceDataSeries, soeREQUIRED}, + {sfAssetClass, soeREQUIRED}, + {sfLastUpdateTime, soeREQUIRED}, + {sfURI, soeOPTIONAL}, + {sfOwnerNode, soeREQUIRED}, + {sfPreviousTxnID, soeREQUIRED}, + {sfPreviousTxnLgrSeq, soeREQUIRED}, +})) diff --git a/include/xrpl/protocol/detail/sfields.macro b/include/xrpl/protocol/detail/sfields.macro new file mode 100644 index 00000000000..bdfcf5dfafd --- /dev/null +++ b/include/xrpl/protocol/detail/sfields.macro @@ -0,0 +1,357 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2024 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED AS IS AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#if !defined(UNTYPED_SFIELD) +#error "undefined macro: UNTYPED_SFIELD" +#endif +#if !defined(TYPED_SFIELD) +#error "undefined macro: TYPED_SFIELD" +#endif + +// untyped +UNTYPED_SFIELD(sfLedgerEntry, LEDGERENTRY, 257) +UNTYPED_SFIELD(sfTransaction, TRANSACTION, 257) +UNTYPED_SFIELD(sfValidation, VALIDATION, 257) +UNTYPED_SFIELD(sfMetadata, METADATA, 257) + +// 8-bit integers (common) +TYPED_SFIELD(sfCloseResolution, UINT8, 1) +TYPED_SFIELD(sfMethod, UINT8, 2) +TYPED_SFIELD(sfTransactionResult, UINT8, 3) +TYPED_SFIELD(sfScale, UINT8, 4) + +// 8-bit integers (uncommon) +TYPED_SFIELD(sfTickSize, UINT8, 16) +TYPED_SFIELD(sfUNLModifyDisabling, UINT8, 17) +TYPED_SFIELD(sfHookResult, UINT8, 18) +TYPED_SFIELD(sfWasLockingChainSend, UINT8, 19) + +// 16-bit integers (common) +TYPED_SFIELD(sfLedgerEntryType, UINT16, 1, SField::sMD_Never) +TYPED_SFIELD(sfTransactionType, UINT16, 2) +TYPED_SFIELD(sfSignerWeight, UINT16, 3) +TYPED_SFIELD(sfTransferFee, UINT16, 4) +TYPED_SFIELD(sfTradingFee, UINT16, 5) +TYPED_SFIELD(sfDiscountedFee, UINT16, 6) + +// 16-bit integers (uncommon) +TYPED_SFIELD(sfVersion, UINT16, 16) +TYPED_SFIELD(sfHookStateChangeCount, UINT16, 17) +TYPED_SFIELD(sfHookEmitCount, UINT16, 18) +TYPED_SFIELD(sfHookExecutionIndex, UINT16, 19) +TYPED_SFIELD(sfHookApiVersion, UINT16, 20) +TYPED_SFIELD(sfLedgerFixType, UINT16, 21) + +// 32-bit integers (common) +TYPED_SFIELD(sfNetworkID, UINT32, 1) +TYPED_SFIELD(sfFlags, UINT32, 2) +TYPED_SFIELD(sfSourceTag, UINT32, 3) +TYPED_SFIELD(sfSequence, UINT32, 4) +TYPED_SFIELD(sfPreviousTxnLgrSeq, UINT32, 5, SField::sMD_DeleteFinal) +TYPED_SFIELD(sfLedgerSequence, UINT32, 6) +TYPED_SFIELD(sfCloseTime, UINT32, 7) +TYPED_SFIELD(sfParentCloseTime, UINT32, 8) +TYPED_SFIELD(sfSigningTime, UINT32, 9) +TYPED_SFIELD(sfExpiration, UINT32, 10) +TYPED_SFIELD(sfTransferRate, UINT32, 11) +TYPED_SFIELD(sfWalletSize, UINT32, 12) +TYPED_SFIELD(sfOwnerCount, UINT32, 13) +TYPED_SFIELD(sfDestinationTag, UINT32, 14) +TYPED_SFIELD(sfLastUpdateTime, UINT32, 15) + +// 32-bit integers (uncommon) +TYPED_SFIELD(sfHighQualityIn, UINT32, 16) +TYPED_SFIELD(sfHighQualityOut, UINT32, 17) +TYPED_SFIELD(sfLowQualityIn, UINT32, 18) +TYPED_SFIELD(sfLowQualityOut, UINT32, 19) +TYPED_SFIELD(sfQualityIn, UINT32, 20) +TYPED_SFIELD(sfQualityOut, UINT32, 21) +TYPED_SFIELD(sfStampEscrow, UINT32, 22) +TYPED_SFIELD(sfBondAmount, UINT32, 23) +TYPED_SFIELD(sfLoadFee, UINT32, 24) +TYPED_SFIELD(sfOfferSequence, UINT32, 25) +TYPED_SFIELD(sfFirstLedgerSequence, UINT32, 26) +TYPED_SFIELD(sfLastLedgerSequence, UINT32, 27) +TYPED_SFIELD(sfTransactionIndex, UINT32, 28) +TYPED_SFIELD(sfOperationLimit, UINT32, 29) +TYPED_SFIELD(sfReferenceFeeUnits, UINT32, 30) +TYPED_SFIELD(sfReserveBase, UINT32, 31) +TYPED_SFIELD(sfReserveIncrement, UINT32, 32) +TYPED_SFIELD(sfSetFlag, UINT32, 33) +TYPED_SFIELD(sfClearFlag, UINT32, 34) +TYPED_SFIELD(sfSignerQuorum, UINT32, 35) +TYPED_SFIELD(sfCancelAfter, UINT32, 36) +TYPED_SFIELD(sfFinishAfter, UINT32, 37) +TYPED_SFIELD(sfSignerListID, UINT32, 38) +TYPED_SFIELD(sfSettleDelay, UINT32, 39) +TYPED_SFIELD(sfTicketCount, UINT32, 40) +TYPED_SFIELD(sfTicketSequence, UINT32, 41) +TYPED_SFIELD(sfNFTokenTaxon, UINT32, 42) +TYPED_SFIELD(sfMintedNFTokens, UINT32, 43) +TYPED_SFIELD(sfBurnedNFTokens, UINT32, 44) +TYPED_SFIELD(sfHookStateCount, UINT32, 45) +TYPED_SFIELD(sfEmitGeneration, UINT32, 46) +// 47 reserved for Hooks +TYPED_SFIELD(sfVoteWeight, UINT32, 48) +TYPED_SFIELD(sfFirstNFTokenSequence, UINT32, 50) +TYPED_SFIELD(sfOracleDocumentID, UINT32, 51) + +// 64-bit integers (common) +TYPED_SFIELD(sfIndexNext, UINT64, 1) +TYPED_SFIELD(sfIndexPrevious, UINT64, 2) +TYPED_SFIELD(sfBookNode, UINT64, 3) +TYPED_SFIELD(sfOwnerNode, UINT64, 4) +TYPED_SFIELD(sfBaseFee, UINT64, 5) +TYPED_SFIELD(sfExchangeRate, UINT64, 6) +TYPED_SFIELD(sfLowNode, UINT64, 7) +TYPED_SFIELD(sfHighNode, UINT64, 8) +TYPED_SFIELD(sfDestinationNode, UINT64, 9) +TYPED_SFIELD(sfCookie, UINT64, 10) +TYPED_SFIELD(sfServerVersion, UINT64, 11) +TYPED_SFIELD(sfNFTokenOfferNode, UINT64, 12) +TYPED_SFIELD(sfEmitBurden, UINT64, 13) + +// 64-bit integers (uncommon) +TYPED_SFIELD(sfHookOn, UINT64, 16) +TYPED_SFIELD(sfHookInstructionCount, UINT64, 17) +TYPED_SFIELD(sfHookReturnCode, UINT64, 18) +TYPED_SFIELD(sfReferenceCount, UINT64, 19) +TYPED_SFIELD(sfXChainClaimID, UINT64, 20) +TYPED_SFIELD(sfXChainAccountCreateCount, UINT64, 21) +TYPED_SFIELD(sfXChainAccountClaimCount, UINT64, 22) +TYPED_SFIELD(sfAssetPrice, UINT64, 23) + +// 128-bit +TYPED_SFIELD(sfEmailHash, UINT128, 1) + +// 160-bit (common) +TYPED_SFIELD(sfTakerPaysCurrency, UINT160, 1) +TYPED_SFIELD(sfTakerPaysIssuer, UINT160, 2) +TYPED_SFIELD(sfTakerGetsCurrency, UINT160, 3) +TYPED_SFIELD(sfTakerGetsIssuer, UINT160, 4) + +// 256-bit (common) +TYPED_SFIELD(sfLedgerHash, UINT256, 1) +TYPED_SFIELD(sfParentHash, UINT256, 2) +TYPED_SFIELD(sfTransactionHash, UINT256, 3) +TYPED_SFIELD(sfAccountHash, UINT256, 4) +TYPED_SFIELD(sfPreviousTxnID, UINT256, 5, SField::sMD_DeleteFinal) +TYPED_SFIELD(sfLedgerIndex, UINT256, 6) +TYPED_SFIELD(sfWalletLocator, UINT256, 7) +TYPED_SFIELD(sfRootIndex, UINT256, 8, SField::sMD_Always) +TYPED_SFIELD(sfAccountTxnID, UINT256, 9) +TYPED_SFIELD(sfNFTokenID, UINT256, 10) +TYPED_SFIELD(sfEmitParentTxnID, UINT256, 11) +TYPED_SFIELD(sfEmitNonce, UINT256, 12) +TYPED_SFIELD(sfEmitHookHash, UINT256, 13) +TYPED_SFIELD(sfAMMID, UINT256, 14) + +// 256-bit (uncommon) +TYPED_SFIELD(sfBookDirectory, UINT256, 16) +TYPED_SFIELD(sfInvoiceID, UINT256, 17) +TYPED_SFIELD(sfNickname, UINT256, 18) +TYPED_SFIELD(sfAmendment, UINT256, 19) +// 20 unused +TYPED_SFIELD(sfDigest, UINT256, 21) +TYPED_SFIELD(sfChannel, UINT256, 22) +TYPED_SFIELD(sfConsensusHash, UINT256, 23) +TYPED_SFIELD(sfCheckID, UINT256, 24) +TYPED_SFIELD(sfValidatedHash, UINT256, 25) +TYPED_SFIELD(sfPreviousPageMin, UINT256, 26) +TYPED_SFIELD(sfNextPageMin, UINT256, 27) +TYPED_SFIELD(sfNFTokenBuyOffer, UINT256, 28) +TYPED_SFIELD(sfNFTokenSellOffer, UINT256, 29) +TYPED_SFIELD(sfHookStateKey, UINT256, 30) +TYPED_SFIELD(sfHookHash, UINT256, 31) +TYPED_SFIELD(sfHookNamespace, UINT256, 32) +TYPED_SFIELD(sfHookSetTxnID, UINT256, 33) + +// currency amount (common) +TYPED_SFIELD(sfAmount, AMOUNT, 1) +TYPED_SFIELD(sfBalance, AMOUNT, 2) +TYPED_SFIELD(sfLimitAmount, AMOUNT, 3) +TYPED_SFIELD(sfTakerPays, AMOUNT, 4) +TYPED_SFIELD(sfTakerGets, AMOUNT, 5) +TYPED_SFIELD(sfLowLimit, AMOUNT, 6) +TYPED_SFIELD(sfHighLimit, AMOUNT, 7) +TYPED_SFIELD(sfFee, AMOUNT, 8) +TYPED_SFIELD(sfSendMax, AMOUNT, 9) +TYPED_SFIELD(sfDeliverMin, AMOUNT, 10) +TYPED_SFIELD(sfAmount2, AMOUNT, 11) +TYPED_SFIELD(sfBidMin, AMOUNT, 12) +TYPED_SFIELD(sfBidMax, AMOUNT, 13) + +// currency amount (uncommon) +TYPED_SFIELD(sfMinimumOffer, AMOUNT, 16) +TYPED_SFIELD(sfRippleEscrow, AMOUNT, 17) +TYPED_SFIELD(sfDeliveredAmount, AMOUNT, 18) +TYPED_SFIELD(sfNFTokenBrokerFee, AMOUNT, 19) + +// Reserve 20 & 21 for Hooks. + +// currency amount (fees) +TYPED_SFIELD(sfBaseFeeDrops, AMOUNT, 22) +TYPED_SFIELD(sfReserveBaseDrops, AMOUNT, 23) +TYPED_SFIELD(sfReserveIncrementDrops, AMOUNT, 24) + +// currency amount (AMM) +TYPED_SFIELD(sfLPTokenOut, AMOUNT, 25) +TYPED_SFIELD(sfLPTokenIn, AMOUNT, 26) +TYPED_SFIELD(sfEPrice, AMOUNT, 27) +TYPED_SFIELD(sfPrice, AMOUNT, 28) +TYPED_SFIELD(sfSignatureReward, AMOUNT, 29) +TYPED_SFIELD(sfMinAccountCreateAmount, AMOUNT, 30) +TYPED_SFIELD(sfLPTokenBalance, AMOUNT, 31) + +// variable length (common) +TYPED_SFIELD(sfPublicKey, VL, 1) +TYPED_SFIELD(sfMessageKey, VL, 2) +TYPED_SFIELD(sfSigningPubKey, VL, 3) +TYPED_SFIELD(sfTxnSignature, VL, 4, SField::sMD_Default, SField::notSigning) +TYPED_SFIELD(sfURI, VL, 5) +TYPED_SFIELD(sfSignature, VL, 6, SField::sMD_Default, SField::notSigning) +TYPED_SFIELD(sfDomain, VL, 7) +TYPED_SFIELD(sfFundCode, VL, 8) +TYPED_SFIELD(sfRemoveCode, VL, 9) +TYPED_SFIELD(sfExpireCode, VL, 10) +TYPED_SFIELD(sfCreateCode, VL, 11) +TYPED_SFIELD(sfMemoType, VL, 12) +TYPED_SFIELD(sfMemoData, VL, 13) +TYPED_SFIELD(sfMemoFormat, VL, 14) + +// variable length (uncommon) +TYPED_SFIELD(sfFulfillment, VL, 16) +TYPED_SFIELD(sfCondition, VL, 17) +TYPED_SFIELD(sfMasterSignature, VL, 18, SField::sMD_Default, SField::notSigning) +TYPED_SFIELD(sfUNLModifyValidator, VL, 19) +TYPED_SFIELD(sfValidatorToDisable, VL, 20) +TYPED_SFIELD(sfValidatorToReEnable, VL, 21) +TYPED_SFIELD(sfHookStateData, VL, 22) +TYPED_SFIELD(sfHookReturnString, VL, 23) +TYPED_SFIELD(sfHookParameterName, VL, 24) +TYPED_SFIELD(sfHookParameterValue, VL, 25) +TYPED_SFIELD(sfDIDDocument, VL, 26) +TYPED_SFIELD(sfData, VL, 27) +TYPED_SFIELD(sfAssetClass, VL, 28) +TYPED_SFIELD(sfProvider, VL, 29) + +// account (common) +TYPED_SFIELD(sfAccount, ACCOUNT, 1) +TYPED_SFIELD(sfOwner, ACCOUNT, 2) +TYPED_SFIELD(sfDestination, ACCOUNT, 3) +TYPED_SFIELD(sfIssuer, ACCOUNT, 4) +TYPED_SFIELD(sfAuthorize, ACCOUNT, 5) +TYPED_SFIELD(sfUnauthorize, ACCOUNT, 6) +// 7 unused +TYPED_SFIELD(sfRegularKey, ACCOUNT, 8) +TYPED_SFIELD(sfNFTokenMinter, ACCOUNT, 9) +TYPED_SFIELD(sfEmitCallback, ACCOUNT, 10) + +// account (uncommon) +TYPED_SFIELD(sfHookAccount, ACCOUNT, 16) +TYPED_SFIELD(sfOtherChainSource, ACCOUNT, 18) +TYPED_SFIELD(sfOtherChainDestination, ACCOUNT, 19) +TYPED_SFIELD(sfAttestationSignerAccount, ACCOUNT, 20) +TYPED_SFIELD(sfAttestationRewardAccount, ACCOUNT, 21) +TYPED_SFIELD(sfLockingChainDoor, ACCOUNT, 22) +TYPED_SFIELD(sfIssuingChainDoor, ACCOUNT, 23) + +// vector of 256-bit +TYPED_SFIELD(sfIndexes, VECTOR256, 1, SField::sMD_Never) +TYPED_SFIELD(sfHashes, VECTOR256, 2) +TYPED_SFIELD(sfAmendments, VECTOR256, 3) +TYPED_SFIELD(sfNFTokenOffers, VECTOR256, 4) + +// path set +UNTYPED_SFIELD(sfPaths, PATHSET, 1) + +// currency +TYPED_SFIELD(sfBaseAsset, CURRENCY, 1) +TYPED_SFIELD(sfQuoteAsset, CURRENCY, 2) + +// issue +TYPED_SFIELD(sfLockingChainIssue, ISSUE, 1) +TYPED_SFIELD(sfIssuingChainIssue, ISSUE, 2) +TYPED_SFIELD(sfAsset, ISSUE, 3) +TYPED_SFIELD(sfAsset2, ISSUE, 4) + +// bridge +TYPED_SFIELD(sfXChainBridge, XCHAIN_BRIDGE, 1) + +// inner object +// OBJECT/1 is reserved for end of object +UNTYPED_SFIELD(sfTransactionMetaData, OBJECT, 2) +UNTYPED_SFIELD(sfCreatedNode, OBJECT, 3) +UNTYPED_SFIELD(sfDeletedNode, OBJECT, 4) +UNTYPED_SFIELD(sfModifiedNode, OBJECT, 5) +UNTYPED_SFIELD(sfPreviousFields, OBJECT, 6) +UNTYPED_SFIELD(sfFinalFields, OBJECT, 7) +UNTYPED_SFIELD(sfNewFields, OBJECT, 8) +UNTYPED_SFIELD(sfTemplateEntry, OBJECT, 9) +UNTYPED_SFIELD(sfMemo, OBJECT, 10) +UNTYPED_SFIELD(sfSignerEntry, OBJECT, 11) +UNTYPED_SFIELD(sfNFToken, OBJECT, 12) +UNTYPED_SFIELD(sfEmitDetails, OBJECT, 13) +UNTYPED_SFIELD(sfHook, OBJECT, 14) + +// inner object (uncommon) +UNTYPED_SFIELD(sfSigner, OBJECT, 16) +// 17 unused +UNTYPED_SFIELD(sfMajority, OBJECT, 18) +UNTYPED_SFIELD(sfDisabledValidator, OBJECT, 19) +UNTYPED_SFIELD(sfEmittedTxn, OBJECT, 20) +UNTYPED_SFIELD(sfHookExecution, OBJECT, 21) +UNTYPED_SFIELD(sfHookDefinition, OBJECT, 22) +UNTYPED_SFIELD(sfHookParameter, OBJECT, 23) +UNTYPED_SFIELD(sfHookGrant, OBJECT, 24) +UNTYPED_SFIELD(sfVoteEntry, OBJECT, 25) +UNTYPED_SFIELD(sfAuctionSlot, OBJECT, 26) +UNTYPED_SFIELD(sfAuthAccount, OBJECT, 27) +UNTYPED_SFIELD(sfXChainClaimProofSig, OBJECT, 28) +UNTYPED_SFIELD(sfXChainCreateAccountProofSig, OBJECT, 29) +UNTYPED_SFIELD(sfXChainClaimAttestationCollectionElement, OBJECT, 30) +UNTYPED_SFIELD(sfXChainCreateAccountAttestationCollectionElement, OBJECT, 31) +UNTYPED_SFIELD(sfPriceData, OBJECT, 32) + +// array of objects (common) +// ARRAY/1 is reserved for end of array +// sfSigningAccounts has never been used. +//UNTYPED_SFIELD(sfSigningAccounts, ARRAY, 2) +UNTYPED_SFIELD(sfSigners, ARRAY, 3, SField::sMD_Default, SField::notSigning) +UNTYPED_SFIELD(sfSignerEntries, ARRAY, 4) +UNTYPED_SFIELD(sfTemplate, ARRAY, 5) +UNTYPED_SFIELD(sfNecessary, ARRAY, 6) +UNTYPED_SFIELD(sfSufficient, ARRAY, 7) +UNTYPED_SFIELD(sfAffectedNodes, ARRAY, 8) +UNTYPED_SFIELD(sfMemos, ARRAY, 9) +UNTYPED_SFIELD(sfNFTokens, ARRAY, 10) +UNTYPED_SFIELD(sfHooks, ARRAY, 11) +UNTYPED_SFIELD(sfVoteSlots, ARRAY, 12) + +// array of objects (uncommon) +UNTYPED_SFIELD(sfMajorities, ARRAY, 16) +UNTYPED_SFIELD(sfDisabledValidators, ARRAY, 17) +UNTYPED_SFIELD(sfHookExecutions, ARRAY, 18) +UNTYPED_SFIELD(sfHookParameters, ARRAY, 19) +UNTYPED_SFIELD(sfHookGrants, ARRAY, 20) +UNTYPED_SFIELD(sfXChainClaimAttestations, ARRAY, 21) +UNTYPED_SFIELD(sfXChainCreateAccountAttestations, ARRAY, 22) +// 23 unused +UNTYPED_SFIELD(sfPriceDataSeries, ARRAY, 24) +UNTYPED_SFIELD(sfAuthAccounts, ARRAY, 25) diff --git a/include/xrpl/protocol/detail/transactions.macro b/include/xrpl/protocol/detail/transactions.macro new file mode 100644 index 00000000000..98678e9d509 --- /dev/null +++ b/include/xrpl/protocol/detail/transactions.macro @@ -0,0 +1,423 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2024 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#if !defined(TRANSACTION) +#error "undefined macro: TRANSACTION" +#endif + +/** + * TRANSACTION(tag, value, name, fields) + * + * You must define a transactor class in the `ripple` namespace named `name`, + * and include its header in `src/xrpld/app/tx/detail/applySteps.cpp`. + */ + +/** This transaction type executes a payment. */ +TRANSACTION(ttPAYMENT, 0, Payment, ({ + {sfDestination, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfSendMax, soeOPTIONAL}, + {sfPaths, soeDEFAULT}, + {sfInvoiceID, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, + {sfDeliverMin, soeOPTIONAL}, +})) + +/** This transaction type creates an escrow object. */ +TRANSACTION(ttESCROW_CREATE, 1, EscrowCreate, ({ + {sfDestination, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfCondition, soeOPTIONAL}, + {sfCancelAfter, soeOPTIONAL}, + {sfFinishAfter, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, +})) + +/** This transaction type completes an existing escrow. */ +TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish, ({ + {sfOwner, soeREQUIRED}, + {sfOfferSequence, soeREQUIRED}, + {sfFulfillment, soeOPTIONAL}, + {sfCondition, soeOPTIONAL}, +})) + + +/** This transaction type adjusts various account settings. */ +TRANSACTION(ttACCOUNT_SET, 3, AccountSet, ({ + {sfEmailHash, soeOPTIONAL}, + {sfWalletLocator, soeOPTIONAL}, + {sfWalletSize, soeOPTIONAL}, + {sfMessageKey, soeOPTIONAL}, + {sfDomain, soeOPTIONAL}, + {sfTransferRate, soeOPTIONAL}, + {sfSetFlag, soeOPTIONAL}, + {sfClearFlag, soeOPTIONAL}, + {sfTickSize, soeOPTIONAL}, + {sfNFTokenMinter, soeOPTIONAL}, +})) + +/** This transaction type cancels an existing escrow. */ +TRANSACTION(ttESCROW_CANCEL, 4, EscrowCancel, ({ + {sfOwner, soeREQUIRED}, + {sfOfferSequence, soeREQUIRED}, +})) + +/** This transaction type sets or clears an account's "regular key". */ +TRANSACTION(ttREGULAR_KEY_SET, 5, SetRegularKey, ({ + {sfRegularKey, soeOPTIONAL}, +})) + +// 6 deprecated + +/** This transaction type creates an offer to trade one asset for another. */ +TRANSACTION(ttOFFER_CREATE, 7, OfferCreate, ({ + {sfTakerPays, soeREQUIRED}, + {sfTakerGets, soeREQUIRED}, + {sfExpiration, soeOPTIONAL}, + {sfOfferSequence, soeOPTIONAL}, +})) + +/** This transaction type cancels existing offers to trade one asset for another. */ +TRANSACTION(ttOFFER_CANCEL, 8, OfferCancel, ({ + {sfOfferSequence, soeREQUIRED}, +})) + +// 9 deprecated + +/** This transaction type creates a new set of tickets. */ +TRANSACTION(ttTICKET_CREATE, 10, TicketCreate, ({ + {sfTicketCount, soeREQUIRED}, +})) + +// 11 deprecated + +/** This transaction type modifies the signer list associated with an account. */ +// The SignerEntries are optional because a SignerList is deleted by +// setting the SignerQuorum to zero and omitting SignerEntries. +TRANSACTION(ttSIGNER_LIST_SET, 12, SignerListSet, ({ + {sfSignerQuorum, soeREQUIRED}, + {sfSignerEntries, soeOPTIONAL}, +})) + +/** This transaction type creates a new unidirectional XRP payment channel. */ +TRANSACTION(ttPAYCHAN_CREATE, 13, PaymentChannelCreate, ({ + {sfDestination, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfSettleDelay, soeREQUIRED}, + {sfPublicKey, soeREQUIRED}, + {sfCancelAfter, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, +})) + +/** This transaction type funds an existing unidirectional XRP payment channel. */ +TRANSACTION(ttPAYCHAN_FUND, 14, PaymentChannelFund, ({ + {sfChannel, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfExpiration, soeOPTIONAL}, +})) + +/** This transaction type submits a claim against an existing unidirectional payment channel. */ +TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim, ({ + {sfChannel, soeREQUIRED}, + {sfAmount, soeOPTIONAL}, + {sfBalance, soeOPTIONAL}, + {sfSignature, soeOPTIONAL}, + {sfPublicKey, soeOPTIONAL}, +})) + +/** This transaction type creates a new check. */ +TRANSACTION(ttCHECK_CREATE, 16, CheckCreate, ({ + {sfDestination, soeREQUIRED}, + {sfSendMax, soeREQUIRED}, + {sfExpiration, soeOPTIONAL}, + {sfDestinationTag, soeOPTIONAL}, + {sfInvoiceID, soeOPTIONAL}, +})) + +/** This transaction type cashes an existing check. */ +TRANSACTION(ttCHECK_CASH, 17, CheckCash, ({ + {sfCheckID, soeREQUIRED}, + {sfAmount, soeOPTIONAL}, + {sfDeliverMin, soeOPTIONAL}, +})) + +/** This transaction type cancels an existing check. */ +TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel, ({ + {sfCheckID, soeREQUIRED}, +})) + +/** This transaction type grants or revokes authorization to transfer funds. */ +TRANSACTION(ttDEPOSIT_PREAUTH, 19, DepositPreauth, ({ + {sfAuthorize, soeOPTIONAL}, + {sfUnauthorize, soeOPTIONAL}, +})) + +/** This transaction type modifies a trustline between two accounts. */ +TRANSACTION(ttTRUST_SET, 20, TrustSet, ({ + {sfLimitAmount, soeOPTIONAL}, + {sfQualityIn, soeOPTIONAL}, + {sfQualityOut, soeOPTIONAL}, +})) + +/** This transaction type deletes an existing account. */ +TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete, ({ + {sfDestination, soeREQUIRED}, + {sfDestinationTag, soeOPTIONAL}, +})) + +// 22 reserved + +/** This transaction mints a new NFT. */ +TRANSACTION(ttNFTOKEN_MINT, 25, NFTokenMint, ({ + {sfNFTokenTaxon, soeREQUIRED}, + {sfTransferFee, soeOPTIONAL}, + {sfIssuer, soeOPTIONAL}, + {sfURI, soeOPTIONAL}, + {sfAmount, soeOPTIONAL}, + {sfDestination, soeOPTIONAL}, + {sfExpiration, soeOPTIONAL}, +})) + +/** This transaction burns (i.e. destroys) an existing NFT. */ +TRANSACTION(ttNFTOKEN_BURN, 26, NFTokenBurn, ({ + {sfNFTokenID, soeREQUIRED}, + {sfOwner, soeOPTIONAL}, +})) + +/** This transaction creates a new offer to buy or sell an NFT. */ +TRANSACTION(ttNFTOKEN_CREATE_OFFER, 27, NFTokenCreateOffer, ({ + {sfNFTokenID, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfDestination, soeOPTIONAL}, + {sfOwner, soeOPTIONAL}, + {sfExpiration, soeOPTIONAL}, +})) + +/** This transaction cancels an existing offer to buy or sell an existing NFT. */ +TRANSACTION(ttNFTOKEN_CANCEL_OFFER, 28, NFTokenCancelOffer, ({ + {sfNFTokenOffers, soeREQUIRED}, +})) + +/** This transaction accepts an existing offer to buy or sell an existing NFT. */ +TRANSACTION(ttNFTOKEN_ACCEPT_OFFER, 29, NFTokenAcceptOffer, ({ + {sfNFTokenBuyOffer, soeOPTIONAL}, + {sfNFTokenSellOffer, soeOPTIONAL}, + {sfNFTokenBrokerFee, soeOPTIONAL}, +})) + +/** This transaction claws back issued tokens. */ +TRANSACTION(ttCLAWBACK, 30, Clawback, ({ + {sfAmount, soeREQUIRED}, +})) + +/** This transaction type creates an AMM instance */ +TRANSACTION(ttAMM_CREATE, 35, AMMCreate, ({ + {sfAmount, soeREQUIRED}, + {sfAmount2, soeREQUIRED}, + {sfTradingFee, soeREQUIRED}, +})) + +/** This transaction type deposits into an AMM instance */ +TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, ({ + {sfAsset, soeREQUIRED}, + {sfAsset2, soeREQUIRED}, + {sfAmount, soeOPTIONAL}, + {sfAmount2, soeOPTIONAL}, + {sfEPrice, soeOPTIONAL}, + {sfLPTokenOut, soeOPTIONAL}, + {sfTradingFee, soeOPTIONAL}, +})) + +/** This transaction type withdraws from an AMM instance */ +TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, ({ + {sfAsset, soeREQUIRED}, + {sfAsset2, soeREQUIRED}, + {sfAmount, soeOPTIONAL}, + {sfAmount2, soeOPTIONAL}, + {sfEPrice, soeOPTIONAL}, + {sfLPTokenIn, soeOPTIONAL}, +})) + +/** This transaction type votes for the trading fee */ +TRANSACTION(ttAMM_VOTE, 38, AMMVote, ({ + {sfAsset, soeREQUIRED}, + {sfAsset2, soeREQUIRED}, + {sfTradingFee, soeREQUIRED}, +})) + +/** This transaction type bids for the auction slot */ +TRANSACTION(ttAMM_BID, 39, AMMBid, ({ + {sfAsset, soeREQUIRED}, + {sfAsset2, soeREQUIRED}, + {sfBidMin, soeOPTIONAL}, + {sfBidMax, soeOPTIONAL}, + {sfAuthAccounts, soeOPTIONAL}, +})) + +/** This transaction type deletes AMM in the empty state */ +TRANSACTION(ttAMM_DELETE, 40, AMMDelete, ({ + {sfAsset, soeREQUIRED}, + {sfAsset2, soeREQUIRED}, +})) + +/** This transactions creates a crosschain sequence number */ +TRANSACTION(ttXCHAIN_CREATE_CLAIM_ID, 41, XChainCreateClaimID, ({ + {sfXChainBridge, soeREQUIRED}, + {sfSignatureReward, soeREQUIRED}, + {sfOtherChainSource, soeREQUIRED}, +})) + +/** This transactions initiates a crosschain transaction */ +TRANSACTION(ttXCHAIN_COMMIT, 42, XChainCommit, ({ + {sfXChainBridge, soeREQUIRED}, + {sfXChainClaimID, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfOtherChainDestination, soeOPTIONAL}, +})) + +/** This transaction completes a crosschain transaction */ +TRANSACTION(ttXCHAIN_CLAIM, 43, XChainClaim, ({ + {sfXChainBridge, soeREQUIRED}, + {sfXChainClaimID, soeREQUIRED}, + {sfDestination, soeREQUIRED}, + {sfDestinationTag, soeOPTIONAL}, + {sfAmount, soeREQUIRED}, +})) + +/** This transaction initiates a crosschain account create transaction */ +TRANSACTION(ttXCHAIN_ACCOUNT_CREATE_COMMIT, 44, XChainAccountCreateCommit, ({ + {sfXChainBridge, soeREQUIRED}, + {sfDestination, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfSignatureReward, soeREQUIRED}, +})) + +/** This transaction adds an attestation to a claim */ +TRANSACTION(ttXCHAIN_ADD_CLAIM_ATTESTATION, 45, XChainAddClaimAttestation, ({ + {sfXChainBridge, soeREQUIRED}, + + {sfAttestationSignerAccount, soeREQUIRED}, + {sfPublicKey, soeREQUIRED}, + {sfSignature, soeREQUIRED}, + {sfOtherChainSource, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfAttestationRewardAccount, soeREQUIRED}, + {sfWasLockingChainSend, soeREQUIRED}, + + {sfXChainClaimID, soeREQUIRED}, + {sfDestination, soeOPTIONAL}, +})) + +/** This transaction adds an attestation to an account */ +TRANSACTION(ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, 46, XChainAddAccountCreateAttestation, ({ + {sfXChainBridge, soeREQUIRED}, + + {sfAttestationSignerAccount, soeREQUIRED}, + {sfPublicKey, soeREQUIRED}, + {sfSignature, soeREQUIRED}, + {sfOtherChainSource, soeREQUIRED}, + {sfAmount, soeREQUIRED}, + {sfAttestationRewardAccount, soeREQUIRED}, + {sfWasLockingChainSend, soeREQUIRED}, + + {sfXChainAccountCreateCount, soeREQUIRED}, + {sfDestination, soeREQUIRED}, + {sfSignatureReward, soeREQUIRED}, +})) + +/** This transaction modifies a sidechain */ +TRANSACTION(ttXCHAIN_MODIFY_BRIDGE, 47, XChainModifyBridge, ({ + {sfXChainBridge, soeREQUIRED}, + {sfSignatureReward, soeOPTIONAL}, + {sfMinAccountCreateAmount, soeOPTIONAL}, +})) + +/** This transactions creates a sidechain */ +TRANSACTION(ttXCHAIN_CREATE_BRIDGE, 48, XChainCreateBridge, ({ + {sfXChainBridge, soeREQUIRED}, + {sfSignatureReward, soeREQUIRED}, + {sfMinAccountCreateAmount, soeOPTIONAL}, +})) + +/** This transaction type creates or updates a DID */ +TRANSACTION(ttDID_SET, 49, DIDSet, ({ + {sfDIDDocument, soeOPTIONAL}, + {sfURI, soeOPTIONAL}, + {sfData, soeOPTIONAL}, +})) + +/** This transaction type deletes a DID */ +TRANSACTION(ttDID_DELETE, 50, DIDDelete, ({})) + +/** This transaction type creates an Oracle instance */ +TRANSACTION(ttORACLE_SET, 51, OracleSet, ({ + {sfOracleDocumentID, soeREQUIRED}, + {sfProvider, soeOPTIONAL}, + {sfURI, soeOPTIONAL}, + {sfAssetClass, soeOPTIONAL}, + {sfLastUpdateTime, soeREQUIRED}, + {sfPriceDataSeries, soeREQUIRED}, +})) + +/** This transaction type deletes an Oracle instance */ +TRANSACTION(ttORACLE_DELETE, 52, OracleDelete, ({ + {sfOracleDocumentID, soeREQUIRED}, +})) + +/** This transaction type fixes a problem in the ledger state */ +TRANSACTION(ttLEDGER_STATE_FIX, 53, LedgerStateFix, ({ + {sfLedgerFixType, soeREQUIRED}, + {sfOwner, soeOPTIONAL}, +})) + +/** This system-generated transaction type is used to update the status of the various amendments. + + For details, see: https://xrpl.org/amendments.html + */ +TRANSACTION(ttAMENDMENT, 100, EnableAmendment, ({ + {sfLedgerSequence, soeREQUIRED}, + {sfAmendment, soeREQUIRED}, +})) + +/** This system-generated transaction type is used to update the network's fee settings. + + For details, see: https://xrpl.org/fee-voting.html + */ +TRANSACTION(ttFEE, 101, SetFee, ({ + {sfLedgerSequence, soeOPTIONAL}, + // Old version uses raw numbers + {sfBaseFee, soeOPTIONAL}, + {sfReferenceFeeUnits, soeOPTIONAL}, + {sfReserveBase, soeOPTIONAL}, + {sfReserveIncrement, soeOPTIONAL}, + // New version uses Amounts + {sfBaseFeeDrops, soeOPTIONAL}, + {sfReserveBaseDrops, soeOPTIONAL}, + {sfReserveIncrementDrops, soeOPTIONAL}, +})) + +/** This system-generated transaction type is used to update the network's negative UNL + + For details, see: https://xrpl.org/negative-unl.html + */ +TRANSACTION(ttUNL_MODIFY, 102, UNLModify, ({ + {sfUNLModifyDisabling, soeREQUIRED}, + {sfLedgerSequence, soeREQUIRED}, + {sfUNLModifyValidator, soeREQUIRED}, +})) diff --git a/include/xrpl/protocol/jss.h b/include/xrpl/protocol/jss.h index e3eda80b44f..1e4e22cd73a 100644 --- a/include/xrpl/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -41,20 +41,13 @@ namespace jss { error: Common properties of RPC error responses. */ +// clang-format off JSS(AL_size); // out: GetCounts JSS(AL_hit_rate); // out: GetCounts JSS(Account); // in: TransactionSign; field. -JSS(AccountDelete); // transaction type. JSS(AccountRoot); // ledger type. -JSS(AccountSet); // transaction type. JSS(AMM); // ledger type -JSS(AMMBid); // transaction type JSS(AMMID); // field -JSS(AMMCreate); // transaction type -JSS(AMMDeposit); // transaction type -JSS(AMMDelete); // transaction type -JSS(AMMVote); // transaction type -JSS(AMMWithdraw); // transaction type JSS(Amendments); // ledger type. JSS(Amount); // in: TransactionSign; field. JSS(Amount2); // in/out: AMM IOU/XRP pool, deposit, withdraw amount @@ -67,25 +60,14 @@ JSS(AuthAccounts); // in: AMM Auction Slot JSS(BaseAsset); // in: Oracle JSS(Bridge); // ledger type. JSS(Check); // ledger type. -JSS(CheckCancel); // transaction type. -JSS(CheckCash); // transaction type. -JSS(CheckCreate); // transaction type. -JSS(Clawback); // transaction type. JSS(ClearFlag); // field. JSS(DID); // ledger type. -JSS(DIDDelete); // transaction type. -JSS(DIDSet); // transaction type. JSS(DeliverMax); // out: alias to Amount JSS(DeliverMin); // in: TransactionSign -JSS(DepositPreauth); // transaction and ledger type. JSS(Destination); // in: TransactionSign; field. JSS(DirectoryNode); // ledger type. -JSS(EnableAmendment); // transaction type. JSS(EPrice); // in: AMM Deposit option JSS(Escrow); // ledger type. -JSS(EscrowCancel); // transaction type. -JSS(EscrowCreate); // transaction type. -JSS(EscrowFinish); // transaction type. JSS(Fee); // in/out: TransactionSign; field. JSS(FeeSettings); // ledger type. JSS(Flags); // in/out: TransactionSign; field. @@ -97,68 +79,40 @@ JSS(LimitAmount); // field. JSS(BidMax); // in: AMM Bid JSS(BidMin); // in: AMM Bid JSS(NetworkID); // field. -JSS(NFTokenBurn); // transaction type. -JSS(NFTokenMint); // transaction type. JSS(NFTokenOffer); // ledger type. -JSS(NFTokenAcceptOffer); // transaction type. -JSS(NFTokenCancelOffer); // transaction type. -JSS(NFTokenCreateOffer); // transaction type. JSS(NFTokenPage); // ledger type. -JSS(LedgerStateFix); // transaction type. JSS(LPTokenOut); // in: AMM Liquidity Provider deposit tokens JSS(LPTokenIn); // in: AMM Liquidity Provider withdraw tokens JSS(LPToken); // out: AMM Liquidity Provider tokens info JSS(Offer); // ledger type. -JSS(OfferCancel); // transaction type. -JSS(OfferCreate); // transaction type. JSS(OfferSequence); // field. JSS(Oracle); // ledger type. -JSS(OracleDelete); // transaction type. JSS(OracleDocumentID); // field -JSS(OracleSet); // transaction type. JSS(Owner); // field JSS(Paths); // in/out: TransactionSign JSS(PayChannel); // ledger type. -JSS(Payment); // transaction type. -JSS(PaymentChannelClaim); // transaction type. -JSS(PaymentChannelCreate); // transaction type. -JSS(PaymentChannelFund); // transaction type. JSS(PriceDataSeries); // field. JSS(PriceData); // field. JSS(Provider); // field. JSS(QuoteAsset); // in: Oracle. JSS(RippleState); // ledger type. JSS(SLE_hit_rate); // out: GetCounts. -JSS(SetFee); // transaction type. -JSS(UNLModify); // transaction type. JSS(Scale); // field. JSS(SettleDelay); // in: TransactionSign JSS(SendMax); // in: TransactionSign JSS(Sequence); // in/out: TransactionSign; field. JSS(SetFlag); // field. -JSS(SetRegularKey); // transaction type. JSS(SignerList); // ledger type. -JSS(SignerListSet); // transaction type. JSS(SigningPubKey); // field. JSS(TakerGets); // field. JSS(TakerPays); // field. JSS(Ticket); // ledger type. -JSS(TicketCreate); // transaction type. JSS(TxnSignature); // field. JSS(TradingFee); // in/out: AMM trading fee JSS(TransactionType); // in: TransactionSign. JSS(TransferRate); // in: TransferRate. -JSS(TrustSet); // transaction type. JSS(URI); // field. JSS(VoteSlots); // out: AMM Vote -JSS(XChainAddAccountCreateAttestation); // transaction type. -JSS(XChainAddClaimAttestation); // transaction type. -JSS(XChainAccountCreateCommit); // transaction type. -JSS(XChainClaim); // transaction type. -JSS(XChainCommit); // transaction type. -JSS(XChainCreateBridge); // transaction type. -JSS(XChainCreateClaimID); // transaction type. -JSS(XChainModifyBridge); // transaction type. JSS(XChainOwnedClaimID); // ledger type. JSS(XChainOwnedCreateAccountClaimID); // ledger type. JSS(aborted); // out: InboundLedger @@ -764,6 +718,18 @@ JSS(write_load); // out: GetCounts JSS(xchain_owned_claim_id); // in: LedgerEntry, AccountObjects JSS(xchain_owned_create_account_claim_id); // in: LedgerEntry JSS(NegativeUNL); // out: ValidatorList; ledger type +// clang-format on + +#pragma push_macro("TRANSACTION") +#undef TRANSACTION + +#define TRANSACTION(tag, value, name, fields) JSS(name); + +#include + +#undef TRANSACTION +#pragma pop_macro("TRANSACTION") + #undef JSS } // namespace jss diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 078369bf20c..3f6e760577a 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -409,114 +409,27 @@ featureToName(uint256 const& f) return featureCollections.featureToName(f); } -#pragma push_macro("REGISTER_FEATURE") -#undef REGISTER_FEATURE +// All known amendments must be registered either here or below with the +// "retired" amendments -/** -Takes the name of a feature, whether it's supported, and the default vote. Will -register the feature, and create a variable whose name is "feature" plus the -feature name. -*/ -#define REGISTER_FEATURE(fName, supported, votebehavior) \ - uint256 const feature##fName = \ - registerFeature(#fName, supported, votebehavior) +#pragma push_macro("XRPL_FEATURE") +#undef XRPL_FEATURE +#pragma push_macro("XRPL_FIX") +#undef XRPL_FIX -#pragma push_macro("REGISTER_FIX") -#undef REGISTER_FIX +#define XRPL_FEATURE(name, supported, vote) \ + uint256 const feature##name = registerFeature(#name, supported, vote); +#define XRPL_FIX(name, supported, vote) \ + uint256 const fix##name = registerFeature("fix" #name, supported, vote); -/** -Takes the name of a feature, whether it's supported, and the default vote. Will -register the feature, and create a variable whose name is the unmodified feature -name. -*/ -#define REGISTER_FIX(fName, supported, votebehavior) \ - uint256 const fName = registerFeature(#fName, supported, votebehavior) +#include -// clang-format off +#undef XRPL_FIX +#pragma pop_macro("XRPL_FIX") +#undef XRPL_FEATURE +#pragma pop_macro("XRPL_FEATURE") -// All known amendments must be registered either here or below with the -// "retired" amendments -REGISTER_FEATURE(OwnerPaysFee, Supported::no, VoteBehavior::DefaultNo); -REGISTER_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(FlowCross, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fix1513, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(DepositAuth, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(Checks, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fix1571, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fix1543, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fix1623, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(DepositPreauth, Supported::yes, VoteBehavior::DefaultYes); -// Use liquidity from strands that consume max offers, but mark as dry -REGISTER_FIX (fix1515, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fix1578, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(MultiSignReserve, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixTakerDryOfferRemoval, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixMasterKeyAsRegularKey, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixCheckThreading, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixPayChanRecipientOwnerDir, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(DeletableAccounts, Supported::yes, VoteBehavior::DefaultYes); -// fixQualityUpperBound should be activated before FlowCross -REGISTER_FIX (fixQualityUpperBound, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(RequireFullyCanonicalSig, Supported::yes, VoteBehavior::DefaultYes); -// fix1781: XRPEndpointSteps should be included in the circular payment check -REGISTER_FIX (fix1781, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(HardenedValidations, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixAmendmentMajorityCalc, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(NegativeUNL, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(TicketBatch, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(FlowSortStrands, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixSTAmountCanonicalize, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FIX (fixRmSmallIncreasedQOffers, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(CheckCashMakesTrustLine, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(ExpandedSignerList, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(NonFungibleTokensV1_1, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixTrustLinesToSelf, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixRemoveNFTokenAutoTrustLine, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(ImmediateOfferKilled, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(DisallowIncoming, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(XRPFees, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixUniversalNumber, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixNonFungibleTokensV1_2, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixNFTokenRemint, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixReducedOffersV1, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(Clawback, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(AMM, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(XChainBridge, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixDisallowIncomingV1, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(DID, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixFillOrKill, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixNFTokenReserve, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixInnerObjTemplate, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixAMMOverflowOffer, Supported::yes, VoteBehavior::DefaultYes); -REGISTER_FEATURE(PriceOracle, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixEmptyDID, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixXChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixPreviousTxnID, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixAMMv1_1, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FEATURE(NFTokenMintOffer, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixReducedOffersV2, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixEnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixInnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixNFTokenPageLinks, Supported::yes, VoteBehavior::DefaultNo); -// InvariantsV1_1 will be changes to Supported::yes when all the -// invariants expected to be included under it are complete. -REGISTER_FEATURE(InvariantsV1_1, Supported::no, VoteBehavior::DefaultNo); - -// The following amendments are obsolete, but must remain supported -// because they could potentially get enabled. -// -// Obsolete features are (usually) not in the ledger, and may have code -// controlled by the feature. They need to be supported because at some -// time in the past, the feature was supported and votable, but never -// passed. So the feature needs to be supported in case it is ever -// enabled (added to the ledger). -// -// If a feature remains obsolete for long enough that no clients are able -// to vote for it, the feature can be removed (entirely?) from the code. -REGISTER_FEATURE(CryptoConditionsSuite, Supported::yes, VoteBehavior::Obsolete); -REGISTER_FEATURE(NonFungibleTokensV1, Supported::yes, VoteBehavior::Obsolete); -REGISTER_FIX (fixNFTokenDirV1, Supported::yes, VoteBehavior::Obsolete); -REGISTER_FIX (fixNFTokenNegOffer, Supported::yes, VoteBehavior::Obsolete); +// clang-format off // The following amendments have been active for at least two years. Their // pre-amendment code has been removed and the identifiers are deprecated. @@ -542,12 +455,6 @@ uint256 const // clang-format on -#undef REGISTER_FIX -#pragma pop_macro("REGISTER_FIX") - -#undef REGISTER_FEATURE -#pragma pop_macro("REGISTER_FEATURE") - // All of the features should now be registered, since variables in a cpp file // are initialized from top to bottom. // diff --git a/src/libxrpl/protocol/LedgerFormats.cpp b/src/libxrpl/protocol/LedgerFormats.cpp index 9401c00278b..d66b085e0d0 100644 --- a/src/libxrpl/protocol/LedgerFormats.cpp +++ b/src/libxrpl/protocol/LedgerFormats.cpp @@ -25,347 +25,28 @@ namespace ripple { LedgerFormats::LedgerFormats() { - // clang-format off // Fields shared by all ledger formats: static const std::initializer_list commonFields{ - {sfLedgerIndex, soeOPTIONAL}, - {sfLedgerEntryType, soeREQUIRED}, - {sfFlags, soeREQUIRED}, + {sfLedgerIndex, soeOPTIONAL}, + {sfLedgerEntryType, soeREQUIRED}, + {sfFlags, soeREQUIRED}, }; - add(jss::AccountRoot, - ltACCOUNT_ROOT, - { - {sfAccount, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfBalance, soeREQUIRED}, - {sfOwnerCount, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfAccountTxnID, soeOPTIONAL}, - {sfRegularKey, soeOPTIONAL}, - {sfEmailHash, soeOPTIONAL}, - {sfWalletLocator, soeOPTIONAL}, - {sfWalletSize, soeOPTIONAL}, - {sfMessageKey, soeOPTIONAL}, - {sfTransferRate, soeOPTIONAL}, - {sfDomain, soeOPTIONAL}, - {sfTickSize, soeOPTIONAL}, - {sfTicketCount, soeOPTIONAL}, - {sfNFTokenMinter, soeOPTIONAL}, - {sfMintedNFTokens, soeDEFAULT}, - {sfBurnedNFTokens, soeDEFAULT}, - {sfFirstNFTokenSequence, soeOPTIONAL}, - {sfAMMID, soeOPTIONAL}, - }, - commonFields); +#pragma push_macro("UNWRAP") +#undef UNWRAP +#pragma push_macro("LEDGER_ENTRY") +#undef LEDGER_ENTRY - add(jss::DirectoryNode, - ltDIR_NODE, - { - {sfOwner, soeOPTIONAL}, // for owner directories - {sfTakerPaysCurrency, soeOPTIONAL}, // order book directories - {sfTakerPaysIssuer, soeOPTIONAL}, // order book directories - {sfTakerGetsCurrency, soeOPTIONAL}, // order book directories - {sfTakerGetsIssuer, soeOPTIONAL}, // order book directories - {sfExchangeRate, soeOPTIONAL}, // order book directories - {sfIndexes, soeREQUIRED}, - {sfRootIndex, soeREQUIRED}, - {sfIndexNext, soeOPTIONAL}, - {sfIndexPrevious, soeOPTIONAL}, - {sfNFTokenID, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, - }, - commonFields); +#define UNWRAP(...) __VA_ARGS__ +#define LEDGER_ENTRY(tag, value, name, fields) \ + add(jss::name, tag, UNWRAP fields, commonFields); - add(jss::Offer, - ltOFFER, - { - {sfAccount, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfTakerPays, soeREQUIRED}, - {sfTakerGets, soeREQUIRED}, - {sfBookDirectory, soeREQUIRED}, - {sfBookNode, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - }, - commonFields); +#include - add(jss::RippleState, - ltRIPPLE_STATE, - { - {sfBalance, soeREQUIRED}, - {sfLowLimit, soeREQUIRED}, - {sfHighLimit, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfLowNode, soeOPTIONAL}, - {sfLowQualityIn, soeOPTIONAL}, - {sfLowQualityOut, soeOPTIONAL}, - {sfHighNode, soeOPTIONAL}, - {sfHighQualityIn, soeOPTIONAL}, - {sfHighQualityOut, soeOPTIONAL}, - }, - commonFields); - - add(jss::Escrow, - ltESCROW, - { - {sfAccount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfCondition, soeOPTIONAL}, - {sfCancelAfter, soeOPTIONAL}, - {sfFinishAfter, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfDestinationNode, soeOPTIONAL}, - }, - commonFields); - - add(jss::LedgerHashes, - ltLEDGER_HASHES, - { - {sfFirstLedgerSequence, soeOPTIONAL}, - {sfLastLedgerSequence, soeOPTIONAL}, - {sfHashes, soeREQUIRED}, - }, - commonFields); - - add(jss::Amendments, - ltAMENDMENTS, - { - {sfAmendments, soeOPTIONAL}, // Enabled - {sfMajorities, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, - }, - commonFields); - - add(jss::FeeSettings, - ltFEE_SETTINGS, - { - // Old version uses raw numbers - {sfBaseFee, soeOPTIONAL}, - {sfReferenceFeeUnits, soeOPTIONAL}, - {sfReserveBase, soeOPTIONAL}, - {sfReserveIncrement, soeOPTIONAL}, - // New version uses Amounts - {sfBaseFeeDrops, soeOPTIONAL}, - {sfReserveBaseDrops, soeOPTIONAL}, - {sfReserveIncrementDrops, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, - }, - commonFields); - - add(jss::Ticket, - ltTICKET, - { - {sfAccount, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfTicketSequence, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - }, - commonFields); - - // All fields are soeREQUIRED because there is always a - // SignerEntries. If there are no SignerEntries the node is deleted. - add(jss::SignerList, - ltSIGNER_LIST, - { - {sfOwnerNode, soeREQUIRED}, - {sfSignerQuorum, soeREQUIRED}, - {sfSignerEntries, soeREQUIRED}, - {sfSignerListID, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - }, - commonFields); - - add(jss::PayChannel, - ltPAYCHAN, - { - {sfAccount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfBalance, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSettleDelay, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfCancelAfter, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - {sfDestinationNode, soeOPTIONAL}, - }, - commonFields); - - add(jss::Check, - ltCHECK, - { - {sfAccount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfSendMax, soeREQUIRED}, - {sfSequence, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfDestinationNode, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfInvoiceID, soeOPTIONAL}, - {sfSourceTag, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - }, - commonFields); - - add(jss::DepositPreauth, - ltDEPOSIT_PREAUTH, - { - {sfAccount, soeREQUIRED}, - {sfAuthorize, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED}, - }, - commonFields); - - add(jss::NegativeUNL, - ltNEGATIVE_UNL, - { - {sfDisabledValidators, soeOPTIONAL}, - {sfValidatorToDisable, soeOPTIONAL}, - {sfValidatorToReEnable, soeOPTIONAL}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, - }, - commonFields); - - add(jss::NFTokenPage, - ltNFTOKEN_PAGE, - { - {sfPreviousPageMin, soeOPTIONAL}, - {sfNextPageMin, soeOPTIONAL}, - {sfNFTokens, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - add(jss::NFTokenOffer, - ltNFTOKEN_OFFER, - { - {sfOwner, soeREQUIRED}, - {sfNFTokenID, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfNFTokenOfferNode, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, - {sfExpiration, soeOPTIONAL}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - add(jss::AMM, - ltAMM, - { - {sfAccount, soeREQUIRED}, - {sfTradingFee, soeDEFAULT}, - {sfVoteSlots, soeOPTIONAL}, - {sfAuctionSlot, soeOPTIONAL}, - {sfLPTokenBalance, soeREQUIRED}, - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeOPTIONAL}, - {sfPreviousTxnLgrSeq, soeOPTIONAL}, - }, - commonFields); - - add(jss::Bridge, - ltBRIDGE, - { - {sfAccount, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfMinAccountCreateAmount, soeOPTIONAL}, - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfXChainAccountClaimCount, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - add(jss::XChainOwnedClaimID, - ltXCHAIN_OWNED_CLAIM_ID, - { - {sfAccount, soeREQUIRED}, - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - {sfXChainClaimAttestations, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - add(jss::XChainOwnedCreateAccountClaimID, - ltXCHAIN_OWNED_CREATE_ACCOUNT_CLAIM_ID, - { - {sfAccount, soeREQUIRED}, - {sfXChainBridge, soeREQUIRED}, - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfXChainCreateAccountAttestations, soeREQUIRED}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - add(jss::DID, - ltDID, - { - {sfAccount, soeREQUIRED}, - {sfDIDDocument, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfData, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - add(jss::Oracle, - ltORACLE, - { - {sfOwner, soeREQUIRED}, - {sfProvider, soeREQUIRED}, - {sfPriceDataSeries, soeREQUIRED}, - {sfAssetClass, soeREQUIRED}, - {sfLastUpdateTime, soeREQUIRED}, - {sfURI, soeOPTIONAL}, - {sfOwnerNode, soeREQUIRED}, - {sfPreviousTxnID, soeREQUIRED}, - {sfPreviousTxnLgrSeq, soeREQUIRED} - }, - commonFields); - - // clang-format on +#undef LEDGER_ENTRY +#pragma pop_macro("LEDGER_ENTRY") +#undef UNWRAP +#pragma pop_macro("UNWRAP") } LedgerFormats const& diff --git a/src/libxrpl/protocol/SField.cpp b/src/libxrpl/protocol/SField.cpp index f8eb2d6f877..18226008504 100644 --- a/src/libxrpl/protocol/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -49,386 +49,37 @@ TypedField::TypedField(private_access_tag_t pat, Args&&... args) // database: // Use macros for most SField construction to enforce naming conventions. -#pragma push_macro("CONSTRUCT_UNTYPED_SFIELD") -#undef CONSTRUCT_UNTYPED_SFIELD - -// It would be possible to design the macros so that sfName and txtName would -// be constructed from a single macro parameter. We chose not to take that -// path because then you cannot grep for the exact SField name and find -// where it is constructed. These macros allow that grep to succeed. -#define CONSTRUCT_UNTYPED_SFIELD(sfName, txtName, stiSuffix, fieldValue, ...) \ - SField const sfName( \ - access, STI_##stiSuffix, fieldValue, txtName, ##__VA_ARGS__); \ - static_assert( \ - std::string_view(#sfName) == "sf" txtName, \ - "Declaration of SField does not match its text name") - -#pragma push_macro("CONSTRUCT_TYPED_SFIELD") -#undef CONSTRUCT_TYPED_SFIELD - -#define CONSTRUCT_TYPED_SFIELD(sfName, txtName, stiSuffix, fieldValue, ...) \ - SF_##stiSuffix const sfName( \ - access, STI_##stiSuffix, fieldValue, txtName, ##__VA_ARGS__); \ - static_assert( \ - std::string_view(#sfName) == "sf" txtName, \ - "Declaration of SField does not match its text name") - -// clang-format off +#pragma push_macro("UNTYPED_SFIELD") +#undef UNTYPED_SFIELD +#pragma push_macro("TYPED_SFIELD") +#undef TYPED_SFIELD + +#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \ + SField const sfName( \ + access, \ + STI_##stiSuffix, \ + fieldValue, \ + std::string_view(#sfName).substr(2).data(), \ + ##__VA_ARGS__); +#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \ + SF_##stiSuffix const sfName( \ + access, \ + STI_##stiSuffix, \ + fieldValue, \ + std::string_view(#sfName).substr(2).data(), \ + ##__VA_ARGS__); // SFields which, for historical reasons, do not follow naming conventions. SField const sfInvalid(access, -1); SField const sfGeneric(access, 0); SField const sfHash(access, STI_UINT256, 257, "hash"); -SField const sfIndex(access, STI_UINT256, 258, "index"); - -// Untyped SFields -CONSTRUCT_UNTYPED_SFIELD(sfLedgerEntry, "LedgerEntry", LEDGERENTRY, 257); -CONSTRUCT_UNTYPED_SFIELD(sfTransaction, "Transaction", TRANSACTION, 257); -CONSTRUCT_UNTYPED_SFIELD(sfValidation, "Validation", VALIDATION, 257); -CONSTRUCT_UNTYPED_SFIELD(sfMetadata, "Metadata", METADATA, 257); - -// 8-bit integers -CONSTRUCT_TYPED_SFIELD(sfCloseResolution, "CloseResolution", UINT8, 1); -CONSTRUCT_TYPED_SFIELD(sfMethod, "Method", UINT8, 2); -CONSTRUCT_TYPED_SFIELD(sfTransactionResult, "TransactionResult", UINT8, 3); -CONSTRUCT_TYPED_SFIELD(sfScale, "Scale", UINT8, 4); - -// 8-bit integers (uncommon) -CONSTRUCT_TYPED_SFIELD(sfTickSize, "TickSize", UINT8, 16); -CONSTRUCT_TYPED_SFIELD(sfUNLModifyDisabling, "UNLModifyDisabling", UINT8, 17); -CONSTRUCT_TYPED_SFIELD(sfHookResult, "HookResult", UINT8, 18); -CONSTRUCT_TYPED_SFIELD(sfWasLockingChainSend, "WasLockingChainSend", UINT8, 19); - -// 16-bit integers -CONSTRUCT_TYPED_SFIELD(sfLedgerEntryType, "LedgerEntryType", UINT16, 1, SField::sMD_Never); -CONSTRUCT_TYPED_SFIELD(sfTransactionType, "TransactionType", UINT16, 2); -CONSTRUCT_TYPED_SFIELD(sfSignerWeight, "SignerWeight", UINT16, 3); -CONSTRUCT_TYPED_SFIELD(sfTransferFee, "TransferFee", UINT16, 4); -CONSTRUCT_TYPED_SFIELD(sfTradingFee, "TradingFee", UINT16, 5); -CONSTRUCT_TYPED_SFIELD(sfDiscountedFee, "DiscountedFee", UINT16, 6); - -// 16-bit integers (uncommon) -CONSTRUCT_TYPED_SFIELD(sfVersion, "Version", UINT16, 16); -CONSTRUCT_TYPED_SFIELD(sfHookStateChangeCount, "HookStateChangeCount", UINT16, 17); -CONSTRUCT_TYPED_SFIELD(sfHookEmitCount, "HookEmitCount", UINT16, 18); -CONSTRUCT_TYPED_SFIELD(sfHookExecutionIndex, "HookExecutionIndex", UINT16, 19); -CONSTRUCT_TYPED_SFIELD(sfHookApiVersion, "HookApiVersion", UINT16, 20); -CONSTRUCT_TYPED_SFIELD(sfLedgerFixType, "LedgerFixType", UINT16, 21); - -// 32-bit integers (common) -CONSTRUCT_TYPED_SFIELD(sfNetworkID, "NetworkID", UINT32, 1); -CONSTRUCT_TYPED_SFIELD(sfFlags, "Flags", UINT32, 2); -CONSTRUCT_TYPED_SFIELD(sfSourceTag, "SourceTag", UINT32, 3); -CONSTRUCT_TYPED_SFIELD(sfSequence, "Sequence", UINT32, 4); -CONSTRUCT_TYPED_SFIELD(sfPreviousTxnLgrSeq, "PreviousTxnLgrSeq", UINT32, 5, SField::sMD_DeleteFinal); -CONSTRUCT_TYPED_SFIELD(sfLedgerSequence, "LedgerSequence", UINT32, 6); -CONSTRUCT_TYPED_SFIELD(sfCloseTime, "CloseTime", UINT32, 7); -CONSTRUCT_TYPED_SFIELD(sfParentCloseTime, "ParentCloseTime", UINT32, 8); -CONSTRUCT_TYPED_SFIELD(sfSigningTime, "SigningTime", UINT32, 9); -CONSTRUCT_TYPED_SFIELD(sfExpiration, "Expiration", UINT32, 10); -CONSTRUCT_TYPED_SFIELD(sfTransferRate, "TransferRate", UINT32, 11); -CONSTRUCT_TYPED_SFIELD(sfWalletSize, "WalletSize", UINT32, 12); -CONSTRUCT_TYPED_SFIELD(sfOwnerCount, "OwnerCount", UINT32, 13); -CONSTRUCT_TYPED_SFIELD(sfDestinationTag, "DestinationTag", UINT32, 14); -CONSTRUCT_TYPED_SFIELD(sfLastUpdateTime, "LastUpdateTime", UINT32, 15); - -// 32-bit integers (uncommon) -CONSTRUCT_TYPED_SFIELD(sfHighQualityIn, "HighQualityIn", UINT32, 16); -CONSTRUCT_TYPED_SFIELD(sfHighQualityOut, "HighQualityOut", UINT32, 17); -CONSTRUCT_TYPED_SFIELD(sfLowQualityIn, "LowQualityIn", UINT32, 18); -CONSTRUCT_TYPED_SFIELD(sfLowQualityOut, "LowQualityOut", UINT32, 19); -CONSTRUCT_TYPED_SFIELD(sfQualityIn, "QualityIn", UINT32, 20); -CONSTRUCT_TYPED_SFIELD(sfQualityOut, "QualityOut", UINT32, 21); -CONSTRUCT_TYPED_SFIELD(sfStampEscrow, "StampEscrow", UINT32, 22); -CONSTRUCT_TYPED_SFIELD(sfBondAmount, "BondAmount", UINT32, 23); -CONSTRUCT_TYPED_SFIELD(sfLoadFee, "LoadFee", UINT32, 24); -CONSTRUCT_TYPED_SFIELD(sfOfferSequence, "OfferSequence", UINT32, 25); -CONSTRUCT_TYPED_SFIELD(sfFirstLedgerSequence, "FirstLedgerSequence", UINT32, 26); -CONSTRUCT_TYPED_SFIELD(sfLastLedgerSequence, "LastLedgerSequence", UINT32, 27); -CONSTRUCT_TYPED_SFIELD(sfTransactionIndex, "TransactionIndex", UINT32, 28); -CONSTRUCT_TYPED_SFIELD(sfOperationLimit, "OperationLimit", UINT32, 29); -CONSTRUCT_TYPED_SFIELD(sfReferenceFeeUnits, "ReferenceFeeUnits", UINT32, 30); -CONSTRUCT_TYPED_SFIELD(sfReserveBase, "ReserveBase", UINT32, 31); -CONSTRUCT_TYPED_SFIELD(sfReserveIncrement, "ReserveIncrement", UINT32, 32); -CONSTRUCT_TYPED_SFIELD(sfSetFlag, "SetFlag", UINT32, 33); -CONSTRUCT_TYPED_SFIELD(sfClearFlag, "ClearFlag", UINT32, 34); -CONSTRUCT_TYPED_SFIELD(sfSignerQuorum, "SignerQuorum", UINT32, 35); -CONSTRUCT_TYPED_SFIELD(sfCancelAfter, "CancelAfter", UINT32, 36); -CONSTRUCT_TYPED_SFIELD(sfFinishAfter, "FinishAfter", UINT32, 37); -CONSTRUCT_TYPED_SFIELD(sfSignerListID, "SignerListID", UINT32, 38); -CONSTRUCT_TYPED_SFIELD(sfSettleDelay, "SettleDelay", UINT32, 39); -CONSTRUCT_TYPED_SFIELD(sfTicketCount, "TicketCount", UINT32, 40); -CONSTRUCT_TYPED_SFIELD(sfTicketSequence, "TicketSequence", UINT32, 41); -CONSTRUCT_TYPED_SFIELD(sfNFTokenTaxon, "NFTokenTaxon", UINT32, 42); -CONSTRUCT_TYPED_SFIELD(sfMintedNFTokens, "MintedNFTokens", UINT32, 43); -CONSTRUCT_TYPED_SFIELD(sfBurnedNFTokens, "BurnedNFTokens", UINT32, 44); -CONSTRUCT_TYPED_SFIELD(sfHookStateCount, "HookStateCount", UINT32, 45); -CONSTRUCT_TYPED_SFIELD(sfEmitGeneration, "EmitGeneration", UINT32, 46); -// 47 is reserved for LockCount(Hooks) -CONSTRUCT_TYPED_SFIELD(sfVoteWeight, "VoteWeight", UINT32, 48); -CONSTRUCT_TYPED_SFIELD(sfFirstNFTokenSequence, "FirstNFTokenSequence", UINT32, 50); -CONSTRUCT_TYPED_SFIELD(sfOracleDocumentID, "OracleDocumentID", UINT32, 51); - -// 64-bit integers (common) -CONSTRUCT_TYPED_SFIELD(sfIndexNext, "IndexNext", UINT64, 1); -CONSTRUCT_TYPED_SFIELD(sfIndexPrevious, "IndexPrevious", UINT64, 2); -CONSTRUCT_TYPED_SFIELD(sfBookNode, "BookNode", UINT64, 3); -CONSTRUCT_TYPED_SFIELD(sfOwnerNode, "OwnerNode", UINT64, 4); -CONSTRUCT_TYPED_SFIELD(sfBaseFee, "BaseFee", UINT64, 5); -CONSTRUCT_TYPED_SFIELD(sfExchangeRate, "ExchangeRate", UINT64, 6); -CONSTRUCT_TYPED_SFIELD(sfLowNode, "LowNode", UINT64, 7); -CONSTRUCT_TYPED_SFIELD(sfHighNode, "HighNode", UINT64, 8); -CONSTRUCT_TYPED_SFIELD(sfDestinationNode, "DestinationNode", UINT64, 9); -CONSTRUCT_TYPED_SFIELD(sfCookie, "Cookie", UINT64, 10); -CONSTRUCT_TYPED_SFIELD(sfServerVersion, "ServerVersion", UINT64, 11); -CONSTRUCT_TYPED_SFIELD(sfNFTokenOfferNode, "NFTokenOfferNode", UINT64, 12); -CONSTRUCT_TYPED_SFIELD(sfEmitBurden, "EmitBurden", UINT64, 13); - -// 64-bit integers (uncommon) -CONSTRUCT_TYPED_SFIELD(sfHookOn, "HookOn", UINT64, 16); -CONSTRUCT_TYPED_SFIELD(sfHookInstructionCount, "HookInstructionCount", UINT64, 17); -CONSTRUCT_TYPED_SFIELD(sfHookReturnCode, "HookReturnCode", UINT64, 18); -CONSTRUCT_TYPED_SFIELD(sfReferenceCount, "ReferenceCount", UINT64, 19); -CONSTRUCT_TYPED_SFIELD(sfXChainClaimID, "XChainClaimID", UINT64, 20); -CONSTRUCT_TYPED_SFIELD(sfXChainAccountCreateCount, "XChainAccountCreateCount", UINT64, 21); -CONSTRUCT_TYPED_SFIELD(sfXChainAccountClaimCount, "XChainAccountClaimCount", UINT64, 22); -CONSTRUCT_TYPED_SFIELD(sfAssetPrice, "AssetPrice", UINT64, 23); - -// 128-bit -CONSTRUCT_TYPED_SFIELD(sfEmailHash, "EmailHash", UINT128, 1); - -// 160-bit (common) -CONSTRUCT_TYPED_SFIELD(sfTakerPaysCurrency, "TakerPaysCurrency", UINT160, 1); -CONSTRUCT_TYPED_SFIELD(sfTakerPaysIssuer, "TakerPaysIssuer", UINT160, 2); -CONSTRUCT_TYPED_SFIELD(sfTakerGetsCurrency, "TakerGetsCurrency", UINT160, 3); -CONSTRUCT_TYPED_SFIELD(sfTakerGetsIssuer, "TakerGetsIssuer", UINT160, 4); - -// 256-bit (common) -CONSTRUCT_TYPED_SFIELD(sfLedgerHash, "LedgerHash", UINT256, 1); -CONSTRUCT_TYPED_SFIELD(sfParentHash, "ParentHash", UINT256, 2); -CONSTRUCT_TYPED_SFIELD(sfTransactionHash, "TransactionHash", UINT256, 3); -CONSTRUCT_TYPED_SFIELD(sfAccountHash, "AccountHash", UINT256, 4); -CONSTRUCT_TYPED_SFIELD(sfPreviousTxnID, "PreviousTxnID", UINT256, 5, SField::sMD_DeleteFinal); -CONSTRUCT_TYPED_SFIELD(sfLedgerIndex, "LedgerIndex", UINT256, 6); -CONSTRUCT_TYPED_SFIELD(sfWalletLocator, "WalletLocator", UINT256, 7); -CONSTRUCT_TYPED_SFIELD(sfRootIndex, "RootIndex", UINT256, 8, SField::sMD_Always); -CONSTRUCT_TYPED_SFIELD(sfAccountTxnID, "AccountTxnID", UINT256, 9); -CONSTRUCT_TYPED_SFIELD(sfNFTokenID, "NFTokenID", UINT256, 10); -CONSTRUCT_TYPED_SFIELD(sfEmitParentTxnID, "EmitParentTxnID", UINT256, 11); -CONSTRUCT_TYPED_SFIELD(sfEmitNonce, "EmitNonce", UINT256, 12); -CONSTRUCT_TYPED_SFIELD(sfEmitHookHash, "EmitHookHash", UINT256, 13); -CONSTRUCT_TYPED_SFIELD(sfAMMID, "AMMID", UINT256, 14); - -// 256-bit (uncommon) -CONSTRUCT_TYPED_SFIELD(sfBookDirectory, "BookDirectory", UINT256, 16); -CONSTRUCT_TYPED_SFIELD(sfInvoiceID, "InvoiceID", UINT256, 17); -CONSTRUCT_TYPED_SFIELD(sfNickname, "Nickname", UINT256, 18); -CONSTRUCT_TYPED_SFIELD(sfAmendment, "Amendment", UINT256, 19); -// 20 is currently unused -CONSTRUCT_TYPED_SFIELD(sfDigest, "Digest", UINT256, 21); -CONSTRUCT_TYPED_SFIELD(sfChannel, "Channel", UINT256, 22); -CONSTRUCT_TYPED_SFIELD(sfConsensusHash, "ConsensusHash", UINT256, 23); -CONSTRUCT_TYPED_SFIELD(sfCheckID, "CheckID", UINT256, 24); -CONSTRUCT_TYPED_SFIELD(sfValidatedHash, "ValidatedHash", UINT256, 25); -CONSTRUCT_TYPED_SFIELD(sfPreviousPageMin, "PreviousPageMin", UINT256, 26); -CONSTRUCT_TYPED_SFIELD(sfNextPageMin, "NextPageMin", UINT256, 27); -CONSTRUCT_TYPED_SFIELD(sfNFTokenBuyOffer, "NFTokenBuyOffer", UINT256, 28); -CONSTRUCT_TYPED_SFIELD(sfNFTokenSellOffer, "NFTokenSellOffer", UINT256, 29); -CONSTRUCT_TYPED_SFIELD(sfHookStateKey, "HookStateKey", UINT256, 30); -CONSTRUCT_TYPED_SFIELD(sfHookHash, "HookHash", UINT256, 31); -CONSTRUCT_TYPED_SFIELD(sfHookNamespace, "HookNamespace", UINT256, 32); -CONSTRUCT_TYPED_SFIELD(sfHookSetTxnID, "HookSetTxnID", UINT256, 33); - -// currency amount (common) -CONSTRUCT_TYPED_SFIELD(sfAmount, "Amount", AMOUNT, 1); -CONSTRUCT_TYPED_SFIELD(sfBalance, "Balance", AMOUNT, 2); -CONSTRUCT_TYPED_SFIELD(sfLimitAmount, "LimitAmount", AMOUNT, 3); -CONSTRUCT_TYPED_SFIELD(sfTakerPays, "TakerPays", AMOUNT, 4); -CONSTRUCT_TYPED_SFIELD(sfTakerGets, "TakerGets", AMOUNT, 5); -CONSTRUCT_TYPED_SFIELD(sfLowLimit, "LowLimit", AMOUNT, 6); -CONSTRUCT_TYPED_SFIELD(sfHighLimit, "HighLimit", AMOUNT, 7); -CONSTRUCT_TYPED_SFIELD(sfFee, "Fee", AMOUNT, 8); -CONSTRUCT_TYPED_SFIELD(sfSendMax, "SendMax", AMOUNT, 9); -CONSTRUCT_TYPED_SFIELD(sfDeliverMin, "DeliverMin", AMOUNT, 10); -CONSTRUCT_TYPED_SFIELD(sfAmount2, "Amount2", AMOUNT, 11); -CONSTRUCT_TYPED_SFIELD(sfBidMin, "BidMin", AMOUNT, 12); -CONSTRUCT_TYPED_SFIELD(sfBidMax, "BidMax", AMOUNT, 13); - -// currency amount (uncommon) -CONSTRUCT_TYPED_SFIELD(sfMinimumOffer, "MinimumOffer", AMOUNT, 16); -CONSTRUCT_TYPED_SFIELD(sfRippleEscrow, "RippleEscrow", AMOUNT, 17); -CONSTRUCT_TYPED_SFIELD(sfDeliveredAmount, "DeliveredAmount", AMOUNT, 18); -CONSTRUCT_TYPED_SFIELD(sfNFTokenBrokerFee, "NFTokenBrokerFee", AMOUNT, 19); - -// Reserve 20 & 21 for Hooks - -// currency amount (fees) -CONSTRUCT_TYPED_SFIELD(sfBaseFeeDrops, "BaseFeeDrops", AMOUNT, 22); -CONSTRUCT_TYPED_SFIELD(sfReserveBaseDrops, "ReserveBaseDrops", AMOUNT, 23); -CONSTRUCT_TYPED_SFIELD(sfReserveIncrementDrops, "ReserveIncrementDrops", AMOUNT, 24); - -// currency amount (AMM) -CONSTRUCT_TYPED_SFIELD(sfLPTokenOut, "LPTokenOut", AMOUNT, 25); -CONSTRUCT_TYPED_SFIELD(sfLPTokenIn, "LPTokenIn", AMOUNT, 26); -CONSTRUCT_TYPED_SFIELD(sfEPrice, "EPrice", AMOUNT, 27); -CONSTRUCT_TYPED_SFIELD(sfPrice, "Price", AMOUNT, 28); -CONSTRUCT_TYPED_SFIELD(sfSignatureReward, "SignatureReward", AMOUNT, 29); -CONSTRUCT_TYPED_SFIELD(sfMinAccountCreateAmount, "MinAccountCreateAmount", AMOUNT, 30); -CONSTRUCT_TYPED_SFIELD(sfLPTokenBalance, "LPTokenBalance", AMOUNT, 31); - -// variable length (common) -CONSTRUCT_TYPED_SFIELD(sfPublicKey, "PublicKey", VL, 1); -CONSTRUCT_TYPED_SFIELD(sfMessageKey, "MessageKey", VL, 2); -CONSTRUCT_TYPED_SFIELD(sfSigningPubKey, "SigningPubKey", VL, 3); -CONSTRUCT_TYPED_SFIELD(sfTxnSignature, "TxnSignature", VL, 4, SField::sMD_Default, SField::notSigning); -CONSTRUCT_TYPED_SFIELD(sfURI, "URI", VL, 5); -CONSTRUCT_TYPED_SFIELD(sfSignature, "Signature", VL, 6, SField::sMD_Default, SField::notSigning); -CONSTRUCT_TYPED_SFIELD(sfDomain, "Domain", VL, 7); -CONSTRUCT_TYPED_SFIELD(sfFundCode, "FundCode", VL, 8); -CONSTRUCT_TYPED_SFIELD(sfRemoveCode, "RemoveCode", VL, 9); -CONSTRUCT_TYPED_SFIELD(sfExpireCode, "ExpireCode", VL, 10); -CONSTRUCT_TYPED_SFIELD(sfCreateCode, "CreateCode", VL, 11); -CONSTRUCT_TYPED_SFIELD(sfMemoType, "MemoType", VL, 12); -CONSTRUCT_TYPED_SFIELD(sfMemoData, "MemoData", VL, 13); -CONSTRUCT_TYPED_SFIELD(sfMemoFormat, "MemoFormat", VL, 14); - -// variable length (uncommon) -CONSTRUCT_TYPED_SFIELD(sfFulfillment, "Fulfillment", VL, 16); -CONSTRUCT_TYPED_SFIELD(sfCondition, "Condition", VL, 17); -CONSTRUCT_TYPED_SFIELD(sfMasterSignature, "MasterSignature", VL, 18, SField::sMD_Default, SField::notSigning); -CONSTRUCT_TYPED_SFIELD(sfUNLModifyValidator, "UNLModifyValidator", VL, 19); -CONSTRUCT_TYPED_SFIELD(sfValidatorToDisable, "ValidatorToDisable", VL, 20); -CONSTRUCT_TYPED_SFIELD(sfValidatorToReEnable, "ValidatorToReEnable", VL, 21); -CONSTRUCT_TYPED_SFIELD(sfHookStateData, "HookStateData", VL, 22); -CONSTRUCT_TYPED_SFIELD(sfHookReturnString, "HookReturnString", VL, 23); -CONSTRUCT_TYPED_SFIELD(sfHookParameterName, "HookParameterName", VL, 24); -CONSTRUCT_TYPED_SFIELD(sfHookParameterValue, "HookParameterValue", VL, 25); -CONSTRUCT_TYPED_SFIELD(sfDIDDocument, "DIDDocument", VL, 26); -CONSTRUCT_TYPED_SFIELD(sfData, "Data", VL, 27); -CONSTRUCT_TYPED_SFIELD(sfAssetClass, "AssetClass", VL, 28); -CONSTRUCT_TYPED_SFIELD(sfProvider, "Provider", VL, 29); - -// account -CONSTRUCT_TYPED_SFIELD(sfAccount, "Account", ACCOUNT, 1); -CONSTRUCT_TYPED_SFIELD(sfOwner, "Owner", ACCOUNT, 2); -CONSTRUCT_TYPED_SFIELD(sfDestination, "Destination", ACCOUNT, 3); -CONSTRUCT_TYPED_SFIELD(sfIssuer, "Issuer", ACCOUNT, 4); -CONSTRUCT_TYPED_SFIELD(sfAuthorize, "Authorize", ACCOUNT, 5); -CONSTRUCT_TYPED_SFIELD(sfUnauthorize, "Unauthorize", ACCOUNT, 6); -// 7 is currently unused -CONSTRUCT_TYPED_SFIELD(sfRegularKey, "RegularKey", ACCOUNT, 8); -CONSTRUCT_TYPED_SFIELD(sfNFTokenMinter, "NFTokenMinter", ACCOUNT, 9); -CONSTRUCT_TYPED_SFIELD(sfEmitCallback, "EmitCallback", ACCOUNT, 10); - -// account (uncommon) -CONSTRUCT_TYPED_SFIELD(sfHookAccount, "HookAccount", ACCOUNT, 16); -CONSTRUCT_TYPED_SFIELD(sfOtherChainSource, "OtherChainSource", ACCOUNT, 18); -CONSTRUCT_TYPED_SFIELD(sfOtherChainDestination, "OtherChainDestination",ACCOUNT, 19); -CONSTRUCT_TYPED_SFIELD(sfAttestationSignerAccount, "AttestationSignerAccount", ACCOUNT, 20); -CONSTRUCT_TYPED_SFIELD(sfAttestationRewardAccount, "AttestationRewardAccount", ACCOUNT, 21); -CONSTRUCT_TYPED_SFIELD(sfLockingChainDoor, "LockingChainDoor", ACCOUNT, 22); -CONSTRUCT_TYPED_SFIELD(sfIssuingChainDoor, "IssuingChainDoor", ACCOUNT, 23); - -// vector of 256-bit -CONSTRUCT_TYPED_SFIELD(sfIndexes, "Indexes", VECTOR256, 1, SField::sMD_Never); -CONSTRUCT_TYPED_SFIELD(sfHashes, "Hashes", VECTOR256, 2); -CONSTRUCT_TYPED_SFIELD(sfAmendments, "Amendments", VECTOR256, 3); -CONSTRUCT_TYPED_SFIELD(sfNFTokenOffers, "NFTokenOffers", VECTOR256, 4); - -// path set -CONSTRUCT_UNTYPED_SFIELD(sfPaths, "Paths", PATHSET, 1); - -// currency -CONSTRUCT_TYPED_SFIELD(sfBaseAsset, "BaseAsset", CURRENCY, 1); -CONSTRUCT_TYPED_SFIELD(sfQuoteAsset, "QuoteAsset", CURRENCY, 2); - -// issue -CONSTRUCT_TYPED_SFIELD(sfLockingChainIssue, "LockingChainIssue", ISSUE, 1); -CONSTRUCT_TYPED_SFIELD(sfIssuingChainIssue, "IssuingChainIssue", ISSUE, 2); -CONSTRUCT_TYPED_SFIELD(sfAsset, "Asset", ISSUE, 3); -CONSTRUCT_TYPED_SFIELD(sfAsset2, "Asset2", ISSUE, 4); - -// Bridge -CONSTRUCT_TYPED_SFIELD(sfXChainBridge, "XChainBridge", XCHAIN_BRIDGE, - 1); -// inner object -// OBJECT/1 is reserved for end of object -CONSTRUCT_UNTYPED_SFIELD(sfTransactionMetaData, "TransactionMetaData", OBJECT, 2); -CONSTRUCT_UNTYPED_SFIELD(sfCreatedNode, "CreatedNode", OBJECT, 3); -CONSTRUCT_UNTYPED_SFIELD(sfDeletedNode, "DeletedNode", OBJECT, 4); -CONSTRUCT_UNTYPED_SFIELD(sfModifiedNode, "ModifiedNode", OBJECT, 5); -CONSTRUCT_UNTYPED_SFIELD(sfPreviousFields, "PreviousFields", OBJECT, 6); -CONSTRUCT_UNTYPED_SFIELD(sfFinalFields, "FinalFields", OBJECT, 7); -CONSTRUCT_UNTYPED_SFIELD(sfNewFields, "NewFields", OBJECT, 8); -CONSTRUCT_UNTYPED_SFIELD(sfTemplateEntry, "TemplateEntry", OBJECT, 9); -CONSTRUCT_UNTYPED_SFIELD(sfMemo, "Memo", OBJECT, 10); -CONSTRUCT_UNTYPED_SFIELD(sfSignerEntry, "SignerEntry", OBJECT, 11); -CONSTRUCT_UNTYPED_SFIELD(sfNFToken, "NFToken", OBJECT, 12); -CONSTRUCT_UNTYPED_SFIELD(sfEmitDetails, "EmitDetails", OBJECT, 13); -CONSTRUCT_UNTYPED_SFIELD(sfHook, "Hook", OBJECT, 14); - -// inner object (uncommon) -CONSTRUCT_UNTYPED_SFIELD(sfSigner, "Signer", OBJECT, 16); -// 17 has not been used yet -CONSTRUCT_UNTYPED_SFIELD(sfMajority, "Majority", OBJECT, 18); -CONSTRUCT_UNTYPED_SFIELD(sfDisabledValidator, "DisabledValidator", OBJECT, 19); -CONSTRUCT_UNTYPED_SFIELD(sfEmittedTxn, "EmittedTxn", OBJECT, 20); -CONSTRUCT_UNTYPED_SFIELD(sfHookExecution, "HookExecution", OBJECT, 21); -CONSTRUCT_UNTYPED_SFIELD(sfHookDefinition, "HookDefinition", OBJECT, 22); -CONSTRUCT_UNTYPED_SFIELD(sfHookParameter, "HookParameter", OBJECT, 23); -CONSTRUCT_UNTYPED_SFIELD(sfHookGrant, "HookGrant", OBJECT, 24); -CONSTRUCT_UNTYPED_SFIELD(sfVoteEntry, "VoteEntry", OBJECT, 25); -CONSTRUCT_UNTYPED_SFIELD(sfAuctionSlot, "AuctionSlot", OBJECT, 26); -CONSTRUCT_UNTYPED_SFIELD(sfAuthAccount, "AuthAccount", OBJECT, 27); -CONSTRUCT_UNTYPED_SFIELD(sfXChainClaimProofSig, "XChainClaimProofSig", OBJECT, 28); -CONSTRUCT_UNTYPED_SFIELD(sfXChainCreateAccountProofSig, - "XChainCreateAccountProofSig", - OBJECT, 29); -CONSTRUCT_UNTYPED_SFIELD(sfXChainClaimAttestationCollectionElement, - "XChainClaimAttestationCollectionElement", - OBJECT, 30); -CONSTRUCT_UNTYPED_SFIELD(sfXChainCreateAccountAttestationCollectionElement, - "XChainCreateAccountAttestationCollectionElement", - OBJECT, 31); -CONSTRUCT_UNTYPED_SFIELD(sfPriceData, "PriceData", OBJECT, 32); - -// array of objects -// ARRAY/1 is reserved for end of array -// 2 has never been used -CONSTRUCT_UNTYPED_SFIELD(sfSigners, "Signers", ARRAY, 3, SField::sMD_Default, SField::notSigning); -CONSTRUCT_UNTYPED_SFIELD(sfSignerEntries, "SignerEntries", ARRAY, 4); -CONSTRUCT_UNTYPED_SFIELD(sfTemplate, "Template", ARRAY, 5); -CONSTRUCT_UNTYPED_SFIELD(sfNecessary, "Necessary", ARRAY, 6); -CONSTRUCT_UNTYPED_SFIELD(sfSufficient, "Sufficient", ARRAY, 7); -CONSTRUCT_UNTYPED_SFIELD(sfAffectedNodes, "AffectedNodes", ARRAY, 8); -CONSTRUCT_UNTYPED_SFIELD(sfMemos, "Memos", ARRAY, 9); -CONSTRUCT_UNTYPED_SFIELD(sfNFTokens, "NFTokens", ARRAY, 10); -CONSTRUCT_UNTYPED_SFIELD(sfHooks, "Hooks", ARRAY, 11); -CONSTRUCT_UNTYPED_SFIELD(sfVoteSlots, "VoteSlots", ARRAY, 12); - -// array of objects (uncommon) -CONSTRUCT_UNTYPED_SFIELD(sfMajorities, "Majorities", ARRAY, 16); -CONSTRUCT_UNTYPED_SFIELD(sfDisabledValidators, "DisabledValidators", ARRAY, 17); -CONSTRUCT_UNTYPED_SFIELD(sfHookExecutions, "HookExecutions", ARRAY, 18); -CONSTRUCT_UNTYPED_SFIELD(sfHookParameters, "HookParameters", ARRAY, 19); -CONSTRUCT_UNTYPED_SFIELD(sfHookGrants, "HookGrants", ARRAY, 20); -CONSTRUCT_UNTYPED_SFIELD(sfXChainClaimAttestations, - "XChainClaimAttestations", - ARRAY, 21); -CONSTRUCT_UNTYPED_SFIELD(sfXChainCreateAccountAttestations, - "XChainCreateAccountAttestations", - ARRAY, 22); -// 23 is unused and available for use -CONSTRUCT_UNTYPED_SFIELD(sfPriceDataSeries, "PriceDataSeries", ARRAY, 24); -CONSTRUCT_UNTYPED_SFIELD(sfAuthAccounts, "AuthAccounts", ARRAY, 25); - -// clang-format on -#undef CONSTRUCT_TYPED_SFIELD -#undef CONSTRUCT_UNTYPED_SFIELD +#include -#pragma pop_macro("CONSTRUCT_TYPED_SFIELD") -#pragma pop_macro("CONSTRUCT_UNTYPED_SFIELD") +#undef TYPED_SFIELD +#pragma pop_macro("TYPED_SFIELD") +#undef UNTYPED_SFIELD +#pragma pop_macro("UNTYPED_SFIELD") SField::SField( private_access_tag_t, diff --git a/src/libxrpl/protocol/TxFormats.cpp b/src/libxrpl/protocol/TxFormats.cpp index 8a93232604e..76b1ae8ad4f 100644 --- a/src/libxrpl/protocol/TxFormats.cpp +++ b/src/libxrpl/protocol/TxFormats.cpp @@ -47,472 +47,21 @@ TxFormats::TxFormats() {sfNetworkID, soeOPTIONAL}, }; - add(jss::AccountSet, - ttACCOUNT_SET, - { - {sfEmailHash, soeOPTIONAL}, - {sfWalletLocator, soeOPTIONAL}, - {sfWalletSize, soeOPTIONAL}, - {sfMessageKey, soeOPTIONAL}, - {sfDomain, soeOPTIONAL}, - {sfTransferRate, soeOPTIONAL}, - {sfSetFlag, soeOPTIONAL}, - {sfClearFlag, soeOPTIONAL}, - {sfTickSize, soeOPTIONAL}, - {sfNFTokenMinter, soeOPTIONAL}, - }, - commonFields); +#pragma push_macro("UNWRAP") +#undef UNWRAP +#pragma push_macro("TRANSACTION") +#undef TRANSACTION - add(jss::TrustSet, - ttTRUST_SET, - { - {sfLimitAmount, soeOPTIONAL}, - {sfQualityIn, soeOPTIONAL}, - {sfQualityOut, soeOPTIONAL}, - }, - commonFields); +#define UNWRAP(...) __VA_ARGS__ +#define TRANSACTION(tag, value, name, fields) \ + add(jss::name, tag, UNWRAP fields, commonFields); - add(jss::OfferCreate, - ttOFFER_CREATE, - { - {sfTakerPays, soeREQUIRED}, - {sfTakerGets, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfOfferSequence, soeOPTIONAL}, - }, - commonFields); +#include - add(jss::AMMCreate, - ttAMM_CREATE, - { - {sfAmount, soeREQUIRED}, - {sfAmount2, soeREQUIRED}, - {sfTradingFee, soeREQUIRED}, - }, - commonFields); - - add(jss::AMMDeposit, - ttAMM_DEPOSIT, - { - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - {sfAmount, soeOPTIONAL}, - {sfAmount2, soeOPTIONAL}, - {sfEPrice, soeOPTIONAL}, - {sfLPTokenOut, soeOPTIONAL}, - {sfTradingFee, soeOPTIONAL}, - }, - commonFields); - - add(jss::AMMWithdraw, - ttAMM_WITHDRAW, - { - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - {sfAmount, soeOPTIONAL}, - {sfAmount2, soeOPTIONAL}, - {sfEPrice, soeOPTIONAL}, - {sfLPTokenIn, soeOPTIONAL}, - }, - commonFields); - - add(jss::AMMVote, - ttAMM_VOTE, - { - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - {sfTradingFee, soeREQUIRED}, - }, - commonFields); - - add(jss::AMMBid, - ttAMM_BID, - { - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - {sfBidMin, soeOPTIONAL}, - {sfBidMax, soeOPTIONAL}, - {sfAuthAccounts, soeOPTIONAL}, - }, - commonFields); - - add(jss::AMMDelete, - ttAMM_DELETE, - { - {sfAsset, soeREQUIRED}, - {sfAsset2, soeREQUIRED}, - }, - commonFields); - - add(jss::OfferCancel, - ttOFFER_CANCEL, - { - {sfOfferSequence, soeREQUIRED}, - }, - commonFields); - - add(jss::SetRegularKey, - ttREGULAR_KEY_SET, - { - {sfRegularKey, soeOPTIONAL}, - }, - commonFields); - - add(jss::Payment, - ttPAYMENT, - { - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfSendMax, soeOPTIONAL}, - {sfPaths, soeDEFAULT}, - {sfInvoiceID, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfDeliverMin, soeOPTIONAL}, - }, - commonFields); - - add(jss::EscrowCreate, - ttESCROW_CREATE, - { - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfCondition, soeOPTIONAL}, - {sfCancelAfter, soeOPTIONAL}, - {sfFinishAfter, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - }, - commonFields); - - add(jss::EscrowFinish, - ttESCROW_FINISH, - { - {sfOwner, soeREQUIRED}, - {sfOfferSequence, soeREQUIRED}, - {sfFulfillment, soeOPTIONAL}, - {sfCondition, soeOPTIONAL}, - }, - commonFields); - - add(jss::EscrowCancel, - ttESCROW_CANCEL, - { - {sfOwner, soeREQUIRED}, - {sfOfferSequence, soeREQUIRED}, - }, - commonFields); - - add(jss::EnableAmendment, - ttAMENDMENT, - { - {sfLedgerSequence, soeREQUIRED}, - {sfAmendment, soeREQUIRED}, - }, - commonFields); - - add(jss::SetFee, - ttFEE, - { - {sfLedgerSequence, soeOPTIONAL}, - // Old version uses raw numbers - {sfBaseFee, soeOPTIONAL}, - {sfReferenceFeeUnits, soeOPTIONAL}, - {sfReserveBase, soeOPTIONAL}, - {sfReserveIncrement, soeOPTIONAL}, - // New version uses Amounts - {sfBaseFeeDrops, soeOPTIONAL}, - {sfReserveBaseDrops, soeOPTIONAL}, - {sfReserveIncrementDrops, soeOPTIONAL}, - }, - commonFields); - - add(jss::UNLModify, - ttUNL_MODIFY, - { - {sfUNLModifyDisabling, soeREQUIRED}, - {sfLedgerSequence, soeREQUIRED}, - {sfUNLModifyValidator, soeREQUIRED}, - }, - commonFields); - - add(jss::TicketCreate, - ttTICKET_CREATE, - { - {sfTicketCount, soeREQUIRED}, - }, - commonFields); - - // The SignerEntries are optional because a SignerList is deleted by - // setting the SignerQuorum to zero and omitting SignerEntries. - add(jss::SignerListSet, - ttSIGNER_LIST_SET, - { - {sfSignerQuorum, soeREQUIRED}, - {sfSignerEntries, soeOPTIONAL}, - }, - commonFields); - - add(jss::PaymentChannelCreate, - ttPAYCHAN_CREATE, - { - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfSettleDelay, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfCancelAfter, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - }, - commonFields); - - add(jss::PaymentChannelFund, - ttPAYCHAN_FUND, - { - {sfChannel, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - }, - commonFields); - - add(jss::PaymentChannelClaim, - ttPAYCHAN_CLAIM, - { - {sfChannel, soeREQUIRED}, - {sfAmount, soeOPTIONAL}, - {sfBalance, soeOPTIONAL}, - {sfSignature, soeOPTIONAL}, - {sfPublicKey, soeOPTIONAL}, - }, - commonFields); - - add(jss::CheckCreate, - ttCHECK_CREATE, - { - {sfDestination, soeREQUIRED}, - {sfSendMax, soeREQUIRED}, - {sfExpiration, soeOPTIONAL}, - {sfDestinationTag, soeOPTIONAL}, - {sfInvoiceID, soeOPTIONAL}, - }, - commonFields); - - add(jss::CheckCash, - ttCHECK_CASH, - { - {sfCheckID, soeREQUIRED}, - {sfAmount, soeOPTIONAL}, - {sfDeliverMin, soeOPTIONAL}, - }, - commonFields); - - add(jss::CheckCancel, - ttCHECK_CANCEL, - { - {sfCheckID, soeREQUIRED}, - }, - commonFields); - - add(jss::AccountDelete, - ttACCOUNT_DELETE, - { - {sfDestination, soeREQUIRED}, - {sfDestinationTag, soeOPTIONAL}, - }, - commonFields); - - add(jss::DepositPreauth, - ttDEPOSIT_PREAUTH, - { - {sfAuthorize, soeOPTIONAL}, - {sfUnauthorize, soeOPTIONAL}, - }, - commonFields); - - add(jss::NFTokenMint, - ttNFTOKEN_MINT, - { - {sfNFTokenTaxon, soeREQUIRED}, - {sfTransferFee, soeOPTIONAL}, - {sfIssuer, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfAmount, soeOPTIONAL}, - {sfDestination, soeOPTIONAL}, - {sfExpiration, soeOPTIONAL}, - }, - commonFields); - - add(jss::NFTokenBurn, - ttNFTOKEN_BURN, - { - {sfNFTokenID, soeREQUIRED}, - {sfOwner, soeOPTIONAL}, - }, - commonFields); - - add(jss::NFTokenCreateOffer, - ttNFTOKEN_CREATE_OFFER, - { - {sfNFTokenID, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, - {sfOwner, soeOPTIONAL}, - {sfExpiration, soeOPTIONAL}, - }, - commonFields); - - add(jss::NFTokenCancelOffer, - ttNFTOKEN_CANCEL_OFFER, - { - {sfNFTokenOffers, soeREQUIRED}, - }, - commonFields); - - add(jss::NFTokenAcceptOffer, - ttNFTOKEN_ACCEPT_OFFER, - { - {sfNFTokenBuyOffer, soeOPTIONAL}, - {sfNFTokenSellOffer, soeOPTIONAL}, - {sfNFTokenBrokerFee, soeOPTIONAL}, - }, - commonFields); - - add(jss::Clawback, - ttCLAWBACK, - { - {sfAmount, soeREQUIRED}, - }, - commonFields); - - add(jss::XChainCreateBridge, - ttXCHAIN_CREATE_BRIDGE, - { - {sfXChainBridge, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfMinAccountCreateAmount, soeOPTIONAL}, - }, - commonFields); - - add(jss::XChainModifyBridge, - ttXCHAIN_MODIFY_BRIDGE, - { - {sfXChainBridge, soeREQUIRED}, - {sfSignatureReward, soeOPTIONAL}, - {sfMinAccountCreateAmount, soeOPTIONAL}, - }, - commonFields); - - add(jss::XChainCreateClaimID, - ttXCHAIN_CREATE_CLAIM_ID, - { - {sfXChainBridge, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - }, - commonFields); - - add(jss::XChainCommit, - ttXCHAIN_COMMIT, - { - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfOtherChainDestination, soeOPTIONAL}, - }, - commonFields); - - add(jss::XChainClaim, - ttXCHAIN_CLAIM, - { - {sfXChainBridge, soeREQUIRED}, - {sfXChainClaimID, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfDestinationTag, soeOPTIONAL}, - {sfAmount, soeREQUIRED}, - }, - commonFields); - - add(jss::XChainAddClaimAttestation, - ttXCHAIN_ADD_CLAIM_ATTESTATION, - { - {sfXChainBridge, soeREQUIRED}, - - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, - - {sfXChainClaimID, soeREQUIRED}, - {sfDestination, soeOPTIONAL}, - }, - commonFields); - - add(jss::XChainAddAccountCreateAttestation, - ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION, - { - {sfXChainBridge, soeREQUIRED}, - - {sfAttestationSignerAccount, soeREQUIRED}, - {sfPublicKey, soeREQUIRED}, - {sfSignature, soeREQUIRED}, - {sfOtherChainSource, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfAttestationRewardAccount, soeREQUIRED}, - {sfWasLockingChainSend, soeREQUIRED}, - - {sfXChainAccountCreateCount, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - }, - commonFields); - - add(jss::XChainAccountCreateCommit, - ttXCHAIN_ACCOUNT_CREATE_COMMIT, - { - {sfXChainBridge, soeREQUIRED}, - {sfDestination, soeREQUIRED}, - {sfAmount, soeREQUIRED}, - {sfSignatureReward, soeREQUIRED}, - }, - commonFields); - - add(jss::DIDSet, - ttDID_SET, - { - {sfDIDDocument, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfData, soeOPTIONAL}, - }, - commonFields); - - add(jss::DIDDelete, ttDID_DELETE, {}, commonFields); - - add(jss::OracleSet, - ttORACLE_SET, - { - {sfOracleDocumentID, soeREQUIRED}, - {sfProvider, soeOPTIONAL}, - {sfURI, soeOPTIONAL}, - {sfAssetClass, soeOPTIONAL}, - {sfLastUpdateTime, soeREQUIRED}, - {sfPriceDataSeries, soeREQUIRED}, - }, - commonFields); - - add(jss::OracleDelete, - ttORACLE_DELETE, - { - {sfOracleDocumentID, soeREQUIRED}, - }, - commonFields); - - add(jss::LedgerStateFix, - ttLEDGER_STATE_FIX, - { - {sfLedgerFixType, soeREQUIRED}, - {sfOwner, soeOPTIONAL}, - }, - commonFields); +#undef TRANSACTION +#pragma pop_macro("TRANSACTION") +#undef UNWRAP +#pragma pop_macro("UNWRAP") } TxFormats const& diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index 8c369e68527..4ef4fef7c1e 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -140,7 +140,7 @@ AMM::create( if (flags) jv[jss::Flags] = *flags; if (fee_ != 0) - jv[jss::Fee] = std::to_string(fee_); + jv[sfFee] = std::to_string(fee_); else jv[jss::Fee] = std::to_string(env_.current()->fees().increment.drops()); submit(jv, seq, ter); diff --git a/src/xrpld/app/tx/detail/CancelCheck.h b/src/xrpld/app/tx/detail/CancelCheck.h index 582d8559e50..d9b70f919c1 100644 --- a/src/xrpld/app/tx/detail/CancelCheck.h +++ b/src/xrpld/app/tx/detail/CancelCheck.h @@ -43,6 +43,8 @@ class CancelCheck : public Transactor doApply() override; }; +using CheckCancel = CancelCheck; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/CancelOffer.h b/src/xrpld/app/tx/detail/CancelOffer.h index 1e3b4a5c983..0942e61282b 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.h +++ b/src/xrpld/app/tx/detail/CancelOffer.h @@ -46,6 +46,8 @@ class CancelOffer : public Transactor doApply() override; }; +using OfferCancel = CancelOffer; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/CashCheck.h b/src/xrpld/app/tx/detail/CashCheck.h index c90cd93a9f8..da7ef22e3c3 100644 --- a/src/xrpld/app/tx/detail/CashCheck.h +++ b/src/xrpld/app/tx/detail/CashCheck.h @@ -43,6 +43,8 @@ class CashCheck : public Transactor doApply() override; }; +using CheckCash = CashCheck; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/Change.h b/src/xrpld/app/tx/detail/Change.h index 7a569bc920e..b0780a75c04 100644 --- a/src/xrpld/app/tx/detail/Change.h +++ b/src/xrpld/app/tx/detail/Change.h @@ -69,6 +69,10 @@ class Change : public Transactor applyUNLModify(); }; +using EnableAmendment = Change; +using SetFee = Change; +using UNLModify = Change; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/CreateCheck.h b/src/xrpld/app/tx/detail/CreateCheck.h index 86daad07061..0e414ce0123 100644 --- a/src/xrpld/app/tx/detail/CreateCheck.h +++ b/src/xrpld/app/tx/detail/CreateCheck.h @@ -43,6 +43,8 @@ class CreateCheck : public Transactor doApply() override; }; +using CheckCreate = CreateCheck; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/CreateOffer.h b/src/xrpld/app/tx/detail/CreateOffer.h index 47129df5b04..234267804c9 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.h +++ b/src/xrpld/app/tx/detail/CreateOffer.h @@ -142,6 +142,8 @@ class CreateOffer : public Transactor OfferStream::StepCounter stepCounter_; }; +using OfferCreate = CreateOffer; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/CreateTicket.h b/src/xrpld/app/tx/detail/CreateTicket.h index edfcaa787c9..099dcde9347 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.h +++ b/src/xrpld/app/tx/detail/CreateTicket.h @@ -84,6 +84,8 @@ class CreateTicket : public Transactor doApply() override; }; +using TicketCreate = CreateTicket; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/DeleteAccount.h b/src/xrpld/app/tx/detail/DeleteAccount.h index e1da2f45964..5f88a9ba718 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.h +++ b/src/xrpld/app/tx/detail/DeleteAccount.h @@ -48,6 +48,8 @@ class DeleteAccount : public Transactor doApply() override; }; +using AccountDelete = DeleteAccount; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/DeleteOracle.h b/src/xrpld/app/tx/detail/DeleteOracle.h index 8f1402563a2..bbbfc6f5256 100644 --- a/src/xrpld/app/tx/detail/DeleteOracle.h +++ b/src/xrpld/app/tx/detail/DeleteOracle.h @@ -59,6 +59,8 @@ class DeleteOracle : public Transactor beast::Journal j); }; +using OracleDelete = DeleteOracle; + } // namespace ripple #endif // RIPPLE_TX_DELETEORACLE_H_INCLUDED diff --git a/src/xrpld/app/tx/detail/PayChan.h b/src/xrpld/app/tx/detail/PayChan.h index 8bb3a6d9379..5eef7e51c0c 100644 --- a/src/xrpld/app/tx/detail/PayChan.h +++ b/src/xrpld/app/tx/detail/PayChan.h @@ -46,6 +46,8 @@ class PayChanCreate : public Transactor doApply() override; }; +using PaymentChannelCreate = PayChanCreate; + //------------------------------------------------------------------------------ class PayChanFund : public Transactor @@ -67,6 +69,8 @@ class PayChanFund : public Transactor doApply() override; }; +using PaymentChannelFund = PayChanFund; + //------------------------------------------------------------------------------ class PayChanClaim : public Transactor @@ -85,6 +89,8 @@ class PayChanClaim : public Transactor doApply() override; }; +using PaymentChannelClaim = PayChanClaim; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/SetAccount.h b/src/xrpld/app/tx/detail/SetAccount.h index 8e9b74d860b..62cae28e51c 100644 --- a/src/xrpld/app/tx/detail/SetAccount.h +++ b/src/xrpld/app/tx/detail/SetAccount.h @@ -51,6 +51,8 @@ class SetAccount : public Transactor doApply() override; }; +using AccountSet = SetAccount; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/SetOracle.h b/src/xrpld/app/tx/detail/SetOracle.h index 13c4d7a0cc9..656b6560192 100644 --- a/src/xrpld/app/tx/detail/SetOracle.h +++ b/src/xrpld/app/tx/detail/SetOracle.h @@ -52,6 +52,8 @@ class SetOracle : public Transactor doApply() override; }; +using OracleSet = SetOracle; + } // namespace ripple #endif // RIPPLE_TX_SETORACLE_H_INCLUDED diff --git a/src/xrpld/app/tx/detail/SetSignerList.h b/src/xrpld/app/tx/detail/SetSignerList.h index c2006945eca..35951645c21 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.h +++ b/src/xrpld/app/tx/detail/SetSignerList.h @@ -97,6 +97,8 @@ class SetSignerList : public Transactor const; }; +using SignerListSet = SetSignerList; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/SetTrust.h b/src/xrpld/app/tx/detail/SetTrust.h index a86c8498d48..6e5a72b3062 100644 --- a/src/xrpld/app/tx/detail/SetTrust.h +++ b/src/xrpld/app/tx/detail/SetTrust.h @@ -47,6 +47,8 @@ class SetTrust : public Transactor doApply() override; }; +using TrustSet = SetTrust; + } // namespace ripple #endif diff --git a/src/xrpld/app/tx/detail/XChainBridge.h b/src/xrpld/app/tx/detail/XChainBridge.h index 822f687729a..2e5e927d120 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.h +++ b/src/xrpld/app/tx/detail/XChainBridge.h @@ -67,6 +67,9 @@ class BridgeModify : public Transactor TER doApply() override; }; + +using XChainModifyBridge = BridgeModify; + //------------------------------------------------------------------------------ // Claim funds from a `XChainCommit` transaction. This is normally not needed, @@ -248,6 +251,8 @@ class XChainCreateAccountCommit : public Transactor doApply() override; }; +using XChainAccountCreateCommit = XChainCreateAccountCommit; + //------------------------------------------------------------------------------ } // namespace ripple diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index cbeabb6fc9c..f39c61abeac 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -76,98 +76,18 @@ with_txn_type(TxType txnType, F&& f) { switch (txnType) { - case ttACCOUNT_DELETE: - return f.template operator()(); - case ttACCOUNT_SET: - return f.template operator()(); - case ttCHECK_CANCEL: - return f.template operator()(); - case ttCHECK_CASH: - return f.template operator()(); - case ttCHECK_CREATE: - return f.template operator()(); - case ttDEPOSIT_PREAUTH: - return f.template operator()(); - case ttOFFER_CANCEL: - return f.template operator()(); - case ttOFFER_CREATE: - return f.template operator()(); - case ttESCROW_CREATE: - return f.template operator()(); - case ttESCROW_FINISH: - return f.template operator()(); - case ttESCROW_CANCEL: - return f.template operator()(); - case ttLEDGER_STATE_FIX: - return f.template operator()(); - case ttPAYCHAN_CLAIM: - return f.template operator()(); - case ttPAYCHAN_CREATE: - return f.template operator()(); - case ttPAYCHAN_FUND: - return f.template operator()(); - case ttPAYMENT: - return f.template operator()(); - case ttREGULAR_KEY_SET: - return f.template operator()(); - case ttSIGNER_LIST_SET: - return f.template operator()(); - case ttTICKET_CREATE: - return f.template operator()(); - case ttTRUST_SET: - return f.template operator()(); - case ttAMENDMENT: - case ttFEE: - case ttUNL_MODIFY: - return f.template operator()(); - case ttNFTOKEN_MINT: - return f.template operator()(); - case ttNFTOKEN_BURN: - return f.template operator()(); - case ttNFTOKEN_CREATE_OFFER: - return f.template operator()(); - case ttNFTOKEN_CANCEL_OFFER: - return f.template operator()(); - case ttNFTOKEN_ACCEPT_OFFER: - return f.template operator()(); - case ttCLAWBACK: - return f.template operator()(); - case ttAMM_CREATE: - return f.template operator()(); - case ttAMM_DEPOSIT: - return f.template operator()(); - case ttAMM_WITHDRAW: - return f.template operator()(); - case ttAMM_VOTE: - return f.template operator()(); - case ttAMM_BID: - return f.template operator()(); - case ttAMM_DELETE: - return f.template operator()(); - case ttXCHAIN_CREATE_BRIDGE: - return f.template operator()(); - case ttXCHAIN_MODIFY_BRIDGE: - return f.template operator()(); - case ttXCHAIN_CREATE_CLAIM_ID: - return f.template operator()(); - case ttXCHAIN_COMMIT: - return f.template operator()(); - case ttXCHAIN_CLAIM: - return f.template operator()(); - case ttXCHAIN_ADD_CLAIM_ATTESTATION: - return f.template operator()(); - case ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION: - return f.template operator()(); - case ttXCHAIN_ACCOUNT_CREATE_COMMIT: - return f.template operator()(); - case ttDID_SET: - return f.template operator()(); - case ttDID_DELETE: - return f.template operator()(); - case ttORACLE_SET: - return f.template operator()(); - case ttORACLE_DELETE: - return f.template operator()(); +#pragma push_macro("TRANSACTION") +#undef TRANSACTION + +#define TRANSACTION(tag, value, name, fields) \ + case tag: \ + return f.template operator()(); + +#include + +#undef TRANSACTION +#pragma pop_macro("TRANSACTION") + default: throw UnknownTxnType(txnType); }