mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
add claim reward flag (#139)
This commit is contained in:
@@ -45,7 +45,7 @@ ClaimReward::preflight(PreflightContext const& ctx)
|
||||
return ret;
|
||||
|
||||
// can have flag 1 set to opt-out of rewards
|
||||
if (ctx.tx.isFieldPresent(sfFlags) && ctx.tx.getFieldU32(sfFlags) > 1)
|
||||
if (ctx.tx.isFieldPresent(sfFlags) && ctx.tx.getFieldU32(sfFlags) > tfOptOut)
|
||||
return temINVALID_FLAG;
|
||||
|
||||
if (ctx.tx.isFieldPresent(sfIssuer) && ctx.tx.getAccountID(sfIssuer) == ctx.tx.getAccountID(sfAccount))
|
||||
@@ -73,7 +73,7 @@ ClaimReward::preclaim(PreclaimContext const& ctx)
|
||||
std::optional<uint32_t> flags = ctx.tx[~sfFlags];
|
||||
std::optional<AccountID const> issuer = ctx.tx[~sfIssuer];
|
||||
|
||||
bool isOptOut = flags && *flags == 1;
|
||||
bool isOptOut = flags && *flags == tfOptOut;
|
||||
if ((issuer && isOptOut) || (!issuer && !isOptOut))
|
||||
return temMALFORMED;
|
||||
|
||||
@@ -92,7 +92,7 @@ ClaimReward::doApply()
|
||||
|
||||
std::optional<uint32_t> flags = ctx_.tx[~sfFlags];
|
||||
|
||||
bool isOptOut = flags && *flags == 1;
|
||||
bool isOptOut = flags && *flags == tfOptOut;
|
||||
if (isOptOut)
|
||||
{
|
||||
if (sle->isFieldPresent(sfRewardLgrFirst))
|
||||
|
||||
@@ -164,6 +164,9 @@ constexpr std::uint32_t const tfNFTokenAcceptOfferMask = ~tfUniversal;
|
||||
constexpr std::uint32_t const tfURITokenMintMask = ~(tfUniversal | tfBurnable);
|
||||
constexpr std::uint32_t const tfURITokenNonMintMask = ~tfUniversal;
|
||||
|
||||
// ClaimReward flags:
|
||||
constexpr std::uint32_t const tfOptOut = 0x00000001;
|
||||
|
||||
// clang-format on
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
@@ -275,7 +275,7 @@ struct ClaimReward_test : public beast::unit_test::suite
|
||||
env.fund(XRP(1000), alice, issuer);
|
||||
env.close();
|
||||
|
||||
env(claim(alice, issuer, 1), ter(temMALFORMED));
|
||||
env(claim(alice, issuer, tfOptOut), ter(temMALFORMED));
|
||||
env.close();
|
||||
}
|
||||
// (!issuer && !isOptOut)
|
||||
@@ -345,7 +345,7 @@ struct ClaimReward_test : public beast::unit_test::suite
|
||||
true);
|
||||
|
||||
// test claim rewards - opt out
|
||||
env(claim(alice, std::nullopt, 1), ter(tesSUCCESS));
|
||||
env(claim(alice, std::nullopt, tfOptOut), ter(tesSUCCESS));
|
||||
env.close();
|
||||
|
||||
BEAST_EXPECT(expectNoRewards(env, alice) == true);
|
||||
|
||||
Reference in New Issue
Block a user