diff --git a/src/ripple/app/tx/impl/applySteps.cpp b/src/ripple/app/tx/impl/applySteps.cpp index 5c3c76771..b1d9608fa 100644 --- a/src/ripple/app/tx/impl/applySteps.cpp +++ b/src/ripple/app/tx/impl/applySteps.cpp @@ -59,8 +59,138 @@ #include #include +#include + namespace ripple { +namespace { + +struct UnknownTxnType : std::exception +{ + TxType txnType; + UnknownTxnType(TxType t) : txnType{t} + { + } +}; + +// Call a lambda with the concrete transaction type as a template parameter +// throw an "UnknownTxnType" exception on error +template +auto +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 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: + case ttUNL_REPORT: + case ttEMIT_FAILURE: + return f.template operator()(); + case ttHOOK_SET: + 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 ttCLAIM_REWARD: + return f.template operator()(); + case ttGENESIS_MINT: + return f.template operator()(); + case ttIMPORT: + return f.template operator()(); + case ttINVOKE: + return f.template operator()(); + case ttREMIT: + return f.template operator()(); + case ttREMARKS_SET: + return f.template operator()(); + case ttURITOKEN_MINT: + case ttURITOKEN_BURN: + case ttURITOKEN_BUY: + case ttURITOKEN_CREATE_SELL_OFFER: + case ttURITOKEN_CANCEL_SELL_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()(); + default: + throw UnknownTxnType(txnType); + } +} +} // namespace + // Templates so preflight does the right thing with T::ConsequencesFactory. // // This could be done more easily using if constexpr, but Visual Studio @@ -69,426 +199,122 @@ namespace ripple { // templates with a single template function that uses if constexpr. // // For Transactor::Normal -template < - class T, - std::enable_if_t = 0> +// + +// clang-format off +// Current formatter for rippled is based on clang-10, which does not handle `requires` clauses +template +requires(T::ConsequencesFactory == Transactor::Normal) TxConsequences -consequences_helper(PreflightContext const& ctx) + consequences_helper(PreflightContext const& ctx) { return TxConsequences(ctx.tx); }; // For Transactor::Blocker -template < - class T, - std::enable_if_t = 0> +template +requires(T::ConsequencesFactory == Transactor::Blocker) TxConsequences -consequences_helper(PreflightContext const& ctx) + consequences_helper(PreflightContext const& ctx) { return TxConsequences(ctx.tx, TxConsequences::blocker); }; // For Transactor::Custom -template < - class T, - std::enable_if_t = 0> +template +requires(T::ConsequencesFactory == Transactor::Custom) TxConsequences -consequences_helper(PreflightContext const& ctx) + consequences_helper(PreflightContext const& ctx) { return T::makeTxConsequences(ctx); }; - -template -std::pair -invoke_preflight_helper(PreflightContext const& ctx) -{ - auto const tec = T::preflight(ctx); - return { - tec, - isTesSuccess(tec) ? consequences_helper(ctx) : TxConsequences{tec}}; -} +// clang-format on static std::pair invoke_preflight(PreflightContext const& ctx) { - switch (ctx.tx.getTxnType()) + try { - case ttACCOUNT_DELETE: - return invoke_preflight_helper(ctx); - case ttACCOUNT_SET: - return invoke_preflight_helper(ctx); - case ttCHECK_CANCEL: - return invoke_preflight_helper(ctx); - case ttCHECK_CASH: - return invoke_preflight_helper(ctx); - case ttCHECK_CREATE: - return invoke_preflight_helper(ctx); - case ttDEPOSIT_PREAUTH: - return invoke_preflight_helper(ctx); - case ttOFFER_CANCEL: - return invoke_preflight_helper(ctx); - case ttOFFER_CREATE: - return invoke_preflight_helper(ctx); - case ttESCROW_CREATE: - return invoke_preflight_helper(ctx); - case ttESCROW_FINISH: - return invoke_preflight_helper(ctx); - case ttESCROW_CANCEL: - return invoke_preflight_helper(ctx); - case ttPAYCHAN_CLAIM: - return invoke_preflight_helper(ctx); - case ttPAYCHAN_CREATE: - return invoke_preflight_helper(ctx); - case ttPAYCHAN_FUND: - return invoke_preflight_helper(ctx); - case ttPAYMENT: - return invoke_preflight_helper(ctx); - case ttREGULAR_KEY_SET: - return invoke_preflight_helper(ctx); - case ttSIGNER_LIST_SET: - return invoke_preflight_helper(ctx); - case ttTICKET_CREATE: - return invoke_preflight_helper(ctx); - case ttTRUST_SET: - return invoke_preflight_helper(ctx); - case ttAMENDMENT: - case ttFEE: - case ttUNL_MODIFY: - case ttUNL_REPORT: - case ttEMIT_FAILURE: - return invoke_preflight_helper(ctx); - case ttHOOK_SET: - return invoke_preflight_helper(ctx); - case ttNFTOKEN_MINT: - return invoke_preflight_helper(ctx); - case ttNFTOKEN_BURN: - return invoke_preflight_helper(ctx); - case ttNFTOKEN_CREATE_OFFER: - return invoke_preflight_helper(ctx); - case ttNFTOKEN_CANCEL_OFFER: - return invoke_preflight_helper(ctx); - case ttNFTOKEN_ACCEPT_OFFER: - return invoke_preflight_helper(ctx); - case ttCLAIM_REWARD: - return invoke_preflight_helper(ctx); - case ttGENESIS_MINT: - return invoke_preflight_helper(ctx); - case ttIMPORT: - return invoke_preflight_helper(ctx); - case ttINVOKE: - return invoke_preflight_helper(ctx); - case ttREMIT: - return invoke_preflight_helper(ctx); - case ttREMARKS_SET: - return invoke_preflight_helper(ctx); - case ttURITOKEN_MINT: - case ttURITOKEN_BURN: - case ttURITOKEN_BUY: - case ttURITOKEN_CREATE_SELL_OFFER: - case ttURITOKEN_CANCEL_SELL_OFFER: - return invoke_preflight_helper(ctx); - case ttCLAWBACK: - return invoke_preflight_helper(ctx); - case ttAMM_CREATE: - return invoke_preflight_helper(ctx); - case ttAMM_DEPOSIT: - return invoke_preflight_helper(ctx); - case ttAMM_WITHDRAW: - return invoke_preflight_helper(ctx); - case ttAMM_VOTE: - return invoke_preflight_helper(ctx); - case ttAMM_BID: - return invoke_preflight_helper(ctx); - case ttAMM_DELETE: - return invoke_preflight_helper(ctx); - case ttXCHAIN_CREATE_BRIDGE: - return invoke_preflight_helper(ctx); - case ttXCHAIN_MODIFY_BRIDGE: - return invoke_preflight_helper(ctx); - case ttXCHAIN_CREATE_CLAIM_ID: - return invoke_preflight_helper(ctx); - case ttXCHAIN_COMMIT: - return invoke_preflight_helper(ctx); - case ttXCHAIN_CLAIM: - return invoke_preflight_helper(ctx); - case ttXCHAIN_ADD_CLAIM_ATTESTATION: - return invoke_preflight_helper(ctx); - case ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION: - return invoke_preflight_helper( - ctx); - case ttXCHAIN_ACCOUNT_CREATE_COMMIT: - return invoke_preflight_helper(ctx); - default: - assert(false); - return {temUNKNOWN, TxConsequences{temUNKNOWN}}; + return with_txn_type(ctx.tx.getTxnType(), [&]() { + auto const tec = T::preflight(ctx); + return std::make_pair( + tec, + isTesSuccess(tec) ? consequences_helper(ctx) + : TxConsequences{tec}); + }); } -} - -/* invoke_preclaim uses name hiding to accomplish - compile-time polymorphism of (presumably) static - class functions for Transactor and derived classes. -*/ -template -static TER -invoke_preclaim(PreclaimContext const& ctx) -{ - // If the transactor requires a valid account and the transaction doesn't - // list one, preflight will have already a flagged a failure. - auto const id = ctx.tx.getAccountID(sfAccount); - - if (id != beast::zero) + catch (UnknownTxnType const& e) { - TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j); - - if (!isTesSuccess(result)) - return result; - - result = T::checkPriorTxAndLastLedger(ctx); - - if (!isTesSuccess(result)) - return result; - - result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx)); - - if (!isTesSuccess(result)) - return result; - - result = T::checkSign(ctx); - - if (!isTesSuccess(result)) - return result; + // Should never happen + JLOG(ctx.j.fatal()) + << "Unknown transaction type in preflight: " << e.txnType; + assert(false); + return {temUNKNOWN, TxConsequences{temUNKNOWN}}; } - - return T::preclaim(ctx); } static TER invoke_preclaim(PreclaimContext const& ctx) { - switch (ctx.tx.getTxnType()) + try { - case ttACCOUNT_DELETE: - return invoke_preclaim(ctx); - case ttACCOUNT_SET: - return invoke_preclaim(ctx); - case ttCHECK_CANCEL: - return invoke_preclaim(ctx); - case ttCHECK_CASH: - return invoke_preclaim(ctx); - case ttCHECK_CREATE: - return invoke_preclaim(ctx); - case ttDEPOSIT_PREAUTH: - return invoke_preclaim(ctx); - case ttOFFER_CANCEL: - return invoke_preclaim(ctx); - case ttOFFER_CREATE: - return invoke_preclaim(ctx); - case ttESCROW_CREATE: - return invoke_preclaim(ctx); - case ttESCROW_FINISH: - return invoke_preclaim(ctx); - case ttESCROW_CANCEL: - return invoke_preclaim(ctx); - case ttPAYCHAN_CLAIM: - return invoke_preclaim(ctx); - case ttPAYCHAN_CREATE: - return invoke_preclaim(ctx); - case ttPAYCHAN_FUND: - return invoke_preclaim(ctx); - case ttPAYMENT: - return invoke_preclaim(ctx); - case ttREGULAR_KEY_SET: - return invoke_preclaim(ctx); - case ttSIGNER_LIST_SET: - return invoke_preclaim(ctx); - case ttTICKET_CREATE: - return invoke_preclaim(ctx); - case ttTRUST_SET: - return invoke_preclaim(ctx); - case ttHOOK_SET: - return invoke_preclaim(ctx); - case ttAMENDMENT: - case ttFEE: - case ttUNL_MODIFY: - case ttUNL_REPORT: - case ttEMIT_FAILURE: - return invoke_preclaim(ctx); - case ttNFTOKEN_MINT: - return invoke_preclaim(ctx); - case ttNFTOKEN_BURN: - return invoke_preclaim(ctx); - case ttNFTOKEN_CREATE_OFFER: - return invoke_preclaim(ctx); - case ttNFTOKEN_CANCEL_OFFER: - return invoke_preclaim(ctx); - case ttNFTOKEN_ACCEPT_OFFER: - return invoke_preclaim(ctx); - case ttCLAIM_REWARD: - return invoke_preclaim(ctx); - case ttGENESIS_MINT: - return invoke_preclaim(ctx); - case ttIMPORT: - return invoke_preclaim(ctx); - case ttINVOKE: - return invoke_preclaim(ctx); - case ttREMIT: - return invoke_preclaim(ctx); - case ttREMARKS_SET: - return invoke_preclaim(ctx); - case ttURITOKEN_MINT: - case ttURITOKEN_BURN: - case ttURITOKEN_BUY: - case ttURITOKEN_CREATE_SELL_OFFER: - case ttURITOKEN_CANCEL_SELL_OFFER: - return invoke_preclaim(ctx); - case ttCLAWBACK: - return invoke_preclaim(ctx); - case ttAMM_CREATE: - return invoke_preclaim(ctx); - case ttAMM_DEPOSIT: - return invoke_preclaim(ctx); - case ttAMM_WITHDRAW: - return invoke_preclaim(ctx); - case ttAMM_VOTE: - return invoke_preclaim(ctx); - case ttAMM_BID: - return invoke_preclaim(ctx); - case ttAMM_DELETE: - return invoke_preclaim(ctx); - case ttXCHAIN_CREATE_BRIDGE: - return invoke_preclaim(ctx); - case ttXCHAIN_MODIFY_BRIDGE: - return invoke_preclaim(ctx); - case ttXCHAIN_CREATE_CLAIM_ID: - return invoke_preclaim(ctx); - case ttXCHAIN_COMMIT: - return invoke_preclaim(ctx); - case ttXCHAIN_CLAIM: - return invoke_preclaim(ctx); - case ttXCHAIN_ACCOUNT_CREATE_COMMIT: - return invoke_preclaim(ctx); - case ttXCHAIN_ADD_CLAIM_ATTESTATION: - return invoke_preclaim(ctx); - case ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION: - return invoke_preclaim(ctx); - default: - assert(false); - return temUNKNOWN; + // use name hiding to accomplish compile-time polymorphism of static + // class functions for Transactor and derived classes. + return with_txn_type(ctx.tx.getTxnType(), [&]() { + // If the transactor requires a valid account and the transaction + // doesn't list one, preflight will have already a flagged a + // failure. + auto const id = ctx.tx.getAccountID(sfAccount); + + if (id != beast::zero) + { + TER result = T::checkSeqProxy(ctx.view, ctx.tx, ctx.j); + + if (!isTesSuccess(result)) + return result; + + result = T::checkPriorTxAndLastLedger(ctx); + + if (!isTesSuccess(result)) + return result; + + result = T::checkFee(ctx, calculateBaseFee(ctx.view, ctx.tx)); + + if (!isTesSuccess(result)) + return result; + + result = T::checkSign(ctx); + + if (!isTesSuccess(result)) + return result; + } + + return T::preclaim(ctx); + }); + } + catch (UnknownTxnType const& e) + { + // Should never happen + JLOG(ctx.j.fatal()) + << "Unknown transaction type in preclaim: " << e.txnType; + assert(false); + return temUNKNOWN; } } XRPAmount invoke_calculateBaseFee(ReadView const& view, STTx const& tx) { - switch (tx.getTxnType()) + try { - case ttACCOUNT_DELETE: - return DeleteAccount::calculateBaseFee(view, tx); - case ttACCOUNT_SET: - return SetAccount::calculateBaseFee(view, tx); - case ttCHECK_CANCEL: - return CancelCheck::calculateBaseFee(view, tx); - case ttCHECK_CASH: - return CashCheck::calculateBaseFee(view, tx); - case ttCHECK_CREATE: - return CreateCheck::calculateBaseFee(view, tx); - case ttDEPOSIT_PREAUTH: - return DepositPreauth::calculateBaseFee(view, tx); - case ttOFFER_CANCEL: - return CancelOffer::calculateBaseFee(view, tx); - case ttOFFER_CREATE: - return CreateOffer::calculateBaseFee(view, tx); - case ttESCROW_CREATE: - return EscrowCreate::calculateBaseFee(view, tx); - case ttESCROW_FINISH: - return EscrowFinish::calculateBaseFee(view, tx); - case ttESCROW_CANCEL: - return EscrowCancel::calculateBaseFee(view, tx); - case ttPAYCHAN_CLAIM: - return PayChanClaim::calculateBaseFee(view, tx); - case ttPAYCHAN_CREATE: - return PayChanCreate::calculateBaseFee(view, tx); - case ttPAYCHAN_FUND: - return PayChanFund::calculateBaseFee(view, tx); - case ttPAYMENT: - return Payment::calculateBaseFee(view, tx); - case ttREGULAR_KEY_SET: - return SetRegularKey::calculateBaseFee(view, tx); - case ttSIGNER_LIST_SET: - return SetSignerList::calculateBaseFee(view, tx); - case ttTICKET_CREATE: - return CreateTicket::calculateBaseFee(view, tx); - case ttTRUST_SET: - return SetTrust::calculateBaseFee(view, tx); - case ttHOOK_SET: - return SetHook::calculateBaseFee(view, tx); - case ttAMENDMENT: - case ttFEE: - case ttUNL_MODIFY: - case ttUNL_REPORT: - case ttEMIT_FAILURE: - return Change::calculateBaseFee(view, tx); - case ttNFTOKEN_MINT: - return NFTokenMint::calculateBaseFee(view, tx); - case ttNFTOKEN_BURN: - return NFTokenBurn::calculateBaseFee(view, tx); - case ttNFTOKEN_CREATE_OFFER: - return NFTokenCreateOffer::calculateBaseFee(view, tx); - case ttNFTOKEN_CANCEL_OFFER: - return NFTokenCancelOffer::calculateBaseFee(view, tx); - case ttNFTOKEN_ACCEPT_OFFER: - return NFTokenAcceptOffer::calculateBaseFee(view, tx); - case ttCLAIM_REWARD: - return ClaimReward::calculateBaseFee(view, tx); - case ttGENESIS_MINT: - return GenesisMint::calculateBaseFee(view, tx); - case ttIMPORT: - return Import::calculateBaseFee(view, tx); - case ttINVOKE: - return Invoke::calculateBaseFee(view, tx); - case ttREMIT: - return Remit::calculateBaseFee(view, tx); - case ttREMARKS_SET: - return SetRemarks::calculateBaseFee(view, tx); - case ttURITOKEN_MINT: - case ttURITOKEN_BURN: - case ttURITOKEN_BUY: - case ttURITOKEN_CREATE_SELL_OFFER: - case ttURITOKEN_CANCEL_SELL_OFFER: - return URIToken::calculateBaseFee(view, tx); - case ttCLAWBACK: - return Clawback::calculateBaseFee(view, tx); - case ttAMM_CREATE: - return AMMCreate::calculateBaseFee(view, tx); - case ttAMM_DEPOSIT: - return AMMDeposit::calculateBaseFee(view, tx); - case ttAMM_WITHDRAW: - return AMMWithdraw::calculateBaseFee(view, tx); - case ttAMM_VOTE: - return AMMVote::calculateBaseFee(view, tx); - case ttAMM_BID: - return AMMBid::calculateBaseFee(view, tx); - case ttAMM_DELETE: - return AMMDelete::calculateBaseFee(view, tx); - case ttXCHAIN_CREATE_BRIDGE: - return XChainCreateBridge::calculateBaseFee(view, tx); - case ttXCHAIN_MODIFY_BRIDGE: - return BridgeModify::calculateBaseFee(view, tx); - case ttXCHAIN_CREATE_CLAIM_ID: - return XChainCreateClaimID::calculateBaseFee(view, tx); - case ttXCHAIN_COMMIT: - return XChainCommit::calculateBaseFee(view, tx); - case ttXCHAIN_CLAIM: - return XChainClaim::calculateBaseFee(view, tx); - case ttXCHAIN_ADD_CLAIM_ATTESTATION: - return XChainAddClaimAttestation::calculateBaseFee(view, tx); - case ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION: - return XChainAddAccountCreateAttestation::calculateBaseFee( - view, tx); - case ttXCHAIN_ACCOUNT_CREATE_COMMIT: - return XChainCreateAccountCommit::calculateBaseFee(view, tx); - default: - return XRPAmount{0}; + return with_txn_type(tx.getTxnType(), [&]() { + return T::calculateBaseFee(view, tx); + }); + } + catch (UnknownTxnType const& e) + { + assert(false); + return XRPAmount{0}; } } @@ -534,211 +360,20 @@ TxConsequences::TxConsequences(STTx const& tx, std::uint32_t sequencesConsumed) static std::pair invoke_apply(ApplyContext& ctx) { - switch (ctx.tx.getTxnType()) + try { - case ttACCOUNT_DELETE: { - DeleteAccount p(ctx); + return with_txn_type(ctx.tx.getTxnType(), [&]() { + T p(ctx); return p(); - } - case ttACCOUNT_SET: { - SetAccount p(ctx); - return p(); - } - case ttCHECK_CANCEL: { - CancelCheck p(ctx); - return p(); - } - case ttCHECK_CASH: { - CashCheck p(ctx); - return p(); - } - case ttCHECK_CREATE: { - CreateCheck p(ctx); - return p(); - } - case ttDEPOSIT_PREAUTH: { - DepositPreauth p(ctx); - return p(); - } - case ttOFFER_CANCEL: { - CancelOffer p(ctx); - return p(); - } - case ttOFFER_CREATE: { - CreateOffer p(ctx); - return p(); - } - case ttESCROW_CREATE: { - EscrowCreate p(ctx); - return p(); - } - case ttESCROW_FINISH: { - EscrowFinish p(ctx); - return p(); - } - case ttESCROW_CANCEL: { - EscrowCancel p(ctx); - return p(); - } - case ttPAYCHAN_CLAIM: { - PayChanClaim p(ctx); - return p(); - } - case ttPAYCHAN_CREATE: { - PayChanCreate p(ctx); - return p(); - } - case ttPAYCHAN_FUND: { - PayChanFund p(ctx); - return p(); - } - case ttPAYMENT: { - Payment p(ctx); - return p(); - } - case ttREGULAR_KEY_SET: { - SetRegularKey p(ctx); - return p(); - } - case ttSIGNER_LIST_SET: { - SetSignerList p(ctx); - return p(); - } - case ttTICKET_CREATE: { - CreateTicket p(ctx); - return p(); - } - case ttTRUST_SET: { - SetTrust p(ctx); - return p(); - } - case ttHOOK_SET: { - SetHook p(ctx); - return p(); - } - case ttAMENDMENT: - case ttFEE: - case ttUNL_MODIFY: - case ttUNL_REPORT: - case ttEMIT_FAILURE: { - Change p(ctx); - return p(); - } - case ttNFTOKEN_MINT: { - NFTokenMint p(ctx); - return p(); - } - case ttNFTOKEN_BURN: { - NFTokenBurn p(ctx); - return p(); - } - case ttNFTOKEN_CREATE_OFFER: { - NFTokenCreateOffer p(ctx); - return p(); - } - case ttNFTOKEN_CANCEL_OFFER: { - NFTokenCancelOffer p(ctx); - return p(); - } - case ttNFTOKEN_ACCEPT_OFFER: { - NFTokenAcceptOffer p(ctx); - return p(); - } - case ttCLAIM_REWARD: { - ClaimReward p(ctx); - return p(); - } - case ttGENESIS_MINT: { - GenesisMint p(ctx); - return p(); - } - case ttIMPORT: { - Import p(ctx); - return p(); - } - case ttINVOKE: { - Invoke p(ctx); - return p(); - } - case ttREMIT: { - Remit p(ctx); - return p(); - } - case ttREMARKS_SET: { - SetRemarks p(ctx); - return p(); - } - case ttURITOKEN_MINT: - case ttURITOKEN_BURN: - case ttURITOKEN_BUY: - case ttURITOKEN_CREATE_SELL_OFFER: - case ttURITOKEN_CANCEL_SELL_OFFER: { - URIToken p(ctx); - return p(); - } - case ttCLAWBACK: { - Clawback p(ctx); - return p(); - } - case ttAMM_CREATE: { - AMMCreate p(ctx); - return p(); - } - case ttAMM_DEPOSIT: { - AMMDeposit p(ctx); - return p(); - } - case ttAMM_WITHDRAW: { - AMMWithdraw p(ctx); - return p(); - } - case ttAMM_VOTE: { - AMMVote p(ctx); - return p(); - } - case ttAMM_BID: { - AMMBid p(ctx); - return p(); - } - case ttAMM_DELETE: { - AMMDelete p(ctx); - return p(); - } - case ttXCHAIN_CREATE_BRIDGE: { - XChainCreateBridge p(ctx); - return p(); - } - case ttXCHAIN_MODIFY_BRIDGE: { - BridgeModify p(ctx); - return p(); - } - case ttXCHAIN_CREATE_CLAIM_ID: { - XChainCreateClaimID p(ctx); - return p(); - } - case ttXCHAIN_COMMIT: { - XChainCommit p(ctx); - return p(); - } - case ttXCHAIN_CLAIM: { - XChainClaim p(ctx); - return p(); - } - case ttXCHAIN_ADD_CLAIM_ATTESTATION: { - XChainAddClaimAttestation p(ctx); - return p(); - } - case ttXCHAIN_ADD_ACCOUNT_CREATE_ATTESTATION: { - XChainAddAccountCreateAttestation p(ctx); - return p(); - } - case ttXCHAIN_ACCOUNT_CREATE_COMMIT: { - XChainCreateAccountCommit p(ctx); - return p(); - } - default: - assert(false); - return {temUNKNOWN, false}; + }); + } + catch (UnknownTxnType const& e) + { + // Should never happen + JLOG(ctx.journal.fatal()) + << "Unknown transaction type in apply: " << e.txnType; + assert(false); + return {temUNKNOWN, false}; } }