Keep existing order of checks

This commit is contained in:
Bronek Kozicki
2025-04-24 14:21:56 +01:00
parent 5cd3b1fb59
commit 270355f77a
2 changed files with 8 additions and 6 deletions

View File

@@ -77,6 +77,11 @@ MPTokenIssuanceCreate::create(
if (!acct)
return Unexpected(tecINTERNAL);
if (args.priorBalance &&
*(args.priorBalance) <
view.fees().accountReserve((*acct)[sfOwnerCount] + 1))
return Unexpected(tecINSUFFICIENT_RESERVE);
auto mptId = makeMptID(args.sequence, args.account);
auto const mptIssuanceKeylet = keylet::mptIssuance(mptId);
@@ -125,11 +130,6 @@ TER
MPTokenIssuanceCreate::doApply()
{
auto const& tx = ctx_.tx;
auto const acct = view().peek(keylet::account(account_));
if (mPriorBalance < view().fees().accountReserve((*acct)[sfOwnerCount] + 1))
return tecINSUFFICIENT_RESERVE;
auto result = create(
view(),
j_,
@@ -139,7 +139,8 @@ MPTokenIssuanceCreate::doApply()
.maxAmount = tx[~sfMaximumAmount],
.assetScale = tx[~sfAssetScale],
.transferFee = tx[~sfTransferFee],
.metadata = tx[~sfMPTokenMetadata]});
.metadata = tx[~sfMPTokenMetadata],
.priorBalance = mPriorBalance});
return result ? tesSUCCESS : result.error();
}

View File

@@ -37,6 +37,7 @@ struct MPTCreateArgs
std::optional<std::uint16_t> transferFee{};
std::optional<Slice> const& metadata{};
std::optional<uint256> domainId{};
std::optional<XRPAmount> priorBalance{};
};
class MPTokenIssuanceCreate : public Transactor