Skip to content

Commit

Permalink
Consolidate errors. Remove redundant checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
gregtatcam committed Aug 6, 2024
1 parent 311bc05 commit 1b12d9d
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 33 deletions.
4 changes: 1 addition & 3 deletions include/xrpl/protocol/TER.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ enum TEMcodes : TERUnderlyingType {
temEMPTY_DID,

temARRAY_EMPTY,
temARRAY_TOO_LARGE,
temMPT_NOT_SUPPORTED,
temMPT_INVALID_USAGE
temARRAY_TOO_LARGE
};

//------------------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions src/libxrpl/protocol/TER.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ transResults()
MAKE_ERROR(temEMPTY_DID, "Malformed: No DID data provided."),
MAKE_ERROR(temINVALID, "The transaction is ill-formed."),
MAKE_ERROR(temINVALID_FLAG, "The transaction has an invalid flag."),
MAKE_ERROR(temMPT_NOT_SUPPORTED, "MPT is not supported."),
MAKE_ERROR(temMPT_INVALID_USAGE, "Invalid MPT usage."),
MAKE_ERROR(temREDUNDANT, "The transaction is redundant."),
MAKE_ERROR(temRIPPLE_EMPTY, "PathSet with no paths."),
MAKE_ERROR(temUNCERTAIN, "In process of determining result. Never returned."),
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/AMMCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AMMCreate::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

if (ctx.tx.getFlags() & tfUniversalMask)
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/AMMDeposit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AMMDeposit::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[~sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

auto const flags = ctx.tx.getFlags();
if (flags & tfDepositMask)
Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/AMMWithdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AMMWithdraw::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[~sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

auto const flags = ctx.tx.getFlags();
if (flags & tfWithdrawMask)
Expand Down
3 changes: 0 additions & 3 deletions src/xrpld/app/tx/detail/CreateCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ CreateCheck::preflight(PreflightContext const& ctx)
if (!isTesSuccess(ret))
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfSendMax]))
return temMPT_NOT_SUPPORTED;

if (ctx.tx.getFlags() & tfUniversalMask)
{
// There are no flags (other than universal) for CreateCheck yet.
Expand Down
4 changes: 0 additions & 4 deletions src/xrpld/app/tx/detail/CreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ CreateOffer::preflight(PreflightContext const& ctx)
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;

if (ctx.rules.enabled(featureMPTokensV1) &&
(isMPT(ctx.tx[sfTakerPays]) || isMPT(ctx.tx[sfTakerGets])))
return temMPT_NOT_SUPPORTED;

auto& tx = ctx.tx;
auto& j = ctx.j;

Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/NFTokenCreateOffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ NFTokenCreateOffer::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

auto const txFlags = ctx.tx.getFlags();

Expand Down
2 changes: 1 addition & 1 deletion src/xrpld/app/tx/detail/NFTokenMint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ NFTokenMint::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[~sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

// Prior to fixRemoveNFTokenAutoTrustLine, transfer of an NFToken between
// accounts allowed a TrustLine to be added to the issuer of that token
Expand Down
15 changes: 9 additions & 6 deletions src/xrpld/app/tx/detail/Payment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,17 @@ preflightHelper(PreflightContext const& ctx)
JLOG(j.trace()) << "Malformed transaction: "
<< "Paths specified for XRP to XRP or MPT to MPT.";
if (bMPTDirect)
return temMPT_NOT_SUPPORTED;
return temMALFORMED;
return temBAD_SEND_XRP_PATHS;
}
if (bXRPDirect && partialPaymentAllowed)
if (bDirect && partialPaymentAllowed)
{
// Consistent but redundant transaction.
JLOG(j.trace()) << "Malformed transaction: "
<< "Partial payment specified for XRP to XRP.";
JLOG(j.trace())
<< "Malformed transaction: "
<< "Partial payment specified for XRP to XRP or MPT to MPT.";
if (bMPTDirect)
return temMALFORMED;
return temBAD_SEND_XRP_PARTIAL;
}
if (bDirect && limitQuality)
Expand All @@ -202,7 +205,7 @@ preflightHelper(PreflightContext const& ctx)
<< "Malformed transaction: "
<< "Limit quality specified for XRP to XRP or MPT to MPT.";
if (bMPTDirect)
return temMPT_NOT_SUPPORTED;
return temMALFORMED;
return temBAD_SEND_XRP_LIMIT;
}
if (bDirect && !defaultPathsAllowed)
Expand All @@ -212,7 +215,7 @@ preflightHelper(PreflightContext const& ctx)
<< "Malformed transaction: "
<< "No ripple direct specified for XRP to XRP or MPT to MPT.";
if (bMPTDirect)
return temMPT_NOT_SUPPORTED;
return temMALFORMED;
return temBAD_SEND_XRP_NO_DIRECT;
}

Expand Down
15 changes: 5 additions & 10 deletions src/xrpld/app/tx/detail/XChainBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ attestationPreflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

if (ctx.tx.getFlags() & tfUniversalMask)
return temINVALID_FLAG;
Expand Down Expand Up @@ -1676,7 +1676,7 @@ XChainClaim::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

if (ctx.tx.getFlags() & tfUniversalMask)
return temINVALID_FLAG;
Expand Down Expand Up @@ -1917,7 +1917,7 @@ XChainCommit::preflight(PreflightContext const& ctx)
return ret;

if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfAmount]))
return temMPT_NOT_SUPPORTED;
return temMALFORMED;

if (ctx.tx.getFlags() & tfUniversalMask)
return temINVALID_FLAG;
Expand Down Expand Up @@ -2035,10 +2035,6 @@ XChainCreateClaimID::preflight(PreflightContext const& ctx)
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;

if (ctx.rules.enabled(featureMPTokensV1) &&
isMPT(ctx.tx[sfSignatureReward]))
return temMPT_NOT_SUPPORTED;

if (ctx.tx.getFlags() & tfUniversalMask)
return temINVALID_FLAG;

Expand Down Expand Up @@ -2194,9 +2190,8 @@ XChainCreateAccountCommit::preflight(PreflightContext const& ctx)
if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
return ret;

if (ctx.rules.enabled(featureMPTokensV1) &&
(isMPT(ctx.tx[sfAmount]) || isMPT(ctx.tx[sfSignatureReward])))
return temMPT_NOT_SUPPORTED;
if (ctx.rules.enabled(featureMPTokensV1) && isMPT(ctx.tx[sfAmount]))
return temMALFORMED;

if (ctx.tx.getFlags() & tfUniversalMask)
return temINVALID_FLAG;
Expand Down

0 comments on commit 1b12d9d

Please sign in to comment.