From b2abfc0bd2dd13260387fe04eeb4dd559e0a740f Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Fri, 25 Apr 2025 13:03:43 +0100 Subject: [PATCH] Minor cleanup in MPTokenIssuanceCreate --- .../app/tx/detail/MPTokenIssuanceCreate.cpp | 26 ++++++++++--------- .../app/tx/detail/MPTokenIssuanceCreate.h | 2 +- src/xrpld/app/tx/detail/VaultCreate.cpp | 3 +-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp b/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp index b150e7af4f..1b96b27f24 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp +++ b/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp @@ -75,14 +75,14 @@ MPTokenIssuanceCreate::create( { auto const acct = view.peek(keylet::account(args.account)); if (!acct) - return Unexpected(tecINTERNAL); + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE if (args.priorBalance && *(args.priorBalance) < view.fees().accountReserve((*acct)[sfOwnerCount] + 1)) return Unexpected(tecINSUFFICIENT_RESERVE); - auto mptId = makeMptID(args.sequence, args.account); + auto const mptId = makeMptID(args.sequence, args.account); auto const mptIssuanceKeylet = keylet::mptIssuance(mptId); // create the MPTokenIssuance @@ -93,7 +93,7 @@ MPTokenIssuanceCreate::create( describeOwnerDir(args.account)); if (!ownerNode) - return Unexpected(tecDIR_FULL); + return Unexpected(tecDIR_FULL); // LCOV_EXCL_LINE auto mptIssuance = std::make_shared(mptIssuanceKeylet); (*mptIssuance)[sfFlags] = args.flags & ~tfUniversal; @@ -130,17 +130,19 @@ TER MPTokenIssuanceCreate::doApply() { auto const& tx = ctx_.tx; - auto result = create( + auto const result = create( view(), j_, - {.account = account_, - .sequence = tx.getSeqValue(), - .flags = tx.getFlags(), - .maxAmount = tx[~sfMaximumAmount], - .assetScale = tx[~sfAssetScale], - .transferFee = tx[~sfTransferFee], - .metadata = tx[~sfMPTokenMetadata], - .priorBalance = mPriorBalance}); + { + .priorBalance = mPriorBalance, + .account = account_, + .sequence = tx.getSeqValue(), + .flags = tx.getFlags(), + .maxAmount = tx[~sfMaximumAmount], + .assetScale = tx[~sfAssetScale], + .transferFee = tx[~sfTransferFee], + .metadata = tx[~sfMPTokenMetadata], + }); return result ? tesSUCCESS : result.error(); } diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h b/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h index 09212c1b99..ea01908dff 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h +++ b/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h @@ -29,6 +29,7 @@ namespace ripple { struct MPTCreateArgs { + std::optional priorBalance; AccountID const& account; std::uint32_t sequence; std::uint32_t flags = 0; @@ -37,7 +38,6 @@ struct MPTCreateArgs std::optional transferFee{}; std::optional const& metadata{}; std::optional domainId{}; - std::optional priorBalance{}; }; class MPTokenIssuanceCreate : public Transactor diff --git a/src/xrpld/app/tx/detail/VaultCreate.cpp b/src/xrpld/app/tx/detail/VaultCreate.cpp index 024455aff7..aca44a581e 100644 --- a/src/xrpld/app/tx/detail/VaultCreate.cpp +++ b/src/xrpld/app/tx/detail/VaultCreate.cpp @@ -188,8 +188,7 @@ VaultCreate::doApply() view(), j_, { - // The operator-> gives the underlying STAccount, - // whose value function returns a const&. + .priorBalance = std::nullopt, .account = pseudoId->value(), .sequence = 1, .flags = mptFlags,