Skip to content

Commit

Permalink
Fix ledger_entry
Browse files Browse the repository at this point in the history
  • Loading branch information
oleks-rip committed Nov 21, 2024
1 parent cf6281b commit 391e266
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions include/xrpl/protocol/detail/features.macro
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
// If you add an amendment here, then do not forget to increment `numFeatures`
// in include/xrpl/protocol/Feature.h.

XRPL_FEATURE(PermissionedDomains, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(Credentials, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FEATURE(AMMClawback, Supported::yes, VoteBehavior::DefaultNo)
XRPL_FIX (AMMv1_2, Supported::yes, VoteBehavior::DefaultNo)
Expand Down Expand Up @@ -98,8 +99,6 @@ XRPL_FIX (1513, Supported::yes, VoteBehavior::DefaultYe
XRPL_FEATURE(FlowCross, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(Flow, Supported::yes, VoteBehavior::DefaultYes)
XRPL_FEATURE(OwnerPaysFee, Supported::no, VoteBehavior::DefaultNo)
XRPL_FEATURE(PermissionedDomains, Supported::no, VoteBehavior::DefaultNo)


// The following amendments are obsolete, but must remain supported
// because they could potentially get enabled.
Expand Down
12 changes: 12 additions & 0 deletions src/test/rpc/LedgerRPC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,18 @@ class LedgerRPC_test : public beast::unit_test::suite
"json", "ledger", "{ \"ledger_index\" : 1000000000000000 }");
checkErrorValue(ret, "invalidParams", "Invalid parameters.");
}

{
// ask for an zero index
Json::Value jvParams;
jvParams[jss::ledger_index] = "validated";
jvParams[jss::index] =
"00000000000000000000000000000000000000000000000000000000000000"
"0000";
auto const jrr = env.rpc(
"json", "ledger_entry", to_string(jvParams))[jss::result];
checkErrorValue(jrr, "malformedRequest", "");
}
}

void
Expand Down
6 changes: 6 additions & 0 deletions src/xrpld/rpc/handlers/LedgerEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ doLedgerEntry(RPC::JsonContext& context)
}
else if (context.params.isMember(jss::permissioned_domain))
{
expectedType = ltPERMISSIONED_DOMAIN;
uNodeIndex = beast::zero;
auto const& pd = context.params[jss::permissioned_domain];
if (pd.isString())
Expand All @@ -822,6 +823,7 @@ doLedgerEntry(RPC::JsonContext& context)
else if (
!pd.isObject() || !pd.isMember(jss::account) ||
!pd[jss::account].isString() || !pd.isMember(jss::seq) ||
(pd[jss::seq].isInt() && pd[jss::seq].asInt() < 0) ||
(!pd[jss::seq].isInt() && !pd[jss::seq].isUInt()))
{
jvResult[jss::error] = "malformedRequest";
Expand Down Expand Up @@ -905,6 +907,10 @@ doLedgerEntry(RPC::JsonContext& context)
jvResult[jss::index] = to_string(uNodeIndex);
}
}
else if (!jvResult.isMember(jss::error))
{
jvResult[jss::error] = "malformedRequest";
}

return jvResult;
}
Expand Down

0 comments on commit 391e266

Please sign in to comment.