Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor mpt_issuance_id into SLE::getJson #42

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/libxrpl/protocol/STLedgerEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ STLedgerEntry::getJson(JsonOptions options) const

ret[jss::index] = to_string(key_);

if (getType() == ltMPTOKEN_ISSUANCE)
ret[jss::mpt_issuance_id] = to_string(
makeMptID(getFieldU32(sfSequence), getAccountID(sfIssuer)));

return ret;
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/rpc/LedgerRPC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,9 @@ class LedgerRPC_test : public beast::unit_test::suite
BEAST_EXPECT(
jrr[jss::node][sfMPTokenMetadata.jsonName] ==
strHex(std::string{"123"}));
BEAST_EXPECT(
jrr[jss::node][jss::mpt_issuance_id] ==
strHex(mptAlice.issuanceID()));
}
{
// Request an index that is not a MPTIssuance.
Expand Down
8 changes: 1 addition & 7 deletions src/xrpld/rpc/detail/RPCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,7 @@ getAccountObjects(
if (!typeFilter.has_value() ||
typeMatchesFilter(typeFilter.value(), sleNode->getType()))
{
auto sleJson = sleNode->getJson(JsonOptions::none);
if (sleNode->getType() == ltMPTOKEN_ISSUANCE)
sleJson[jss::mpt_issuance_id] = to_string(makeMptID(
(*sleNode)[sfSequence],
sleNode->getAccountID(sfIssuer)));

jvObjects.append(sleJson);
jvObjects.append(sleNode->getJson(JsonOptions::none));
}

if (++i == mlimit)
Expand Down
4 changes: 0 additions & 4 deletions src/xrpld/rpc/handlers/LedgerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ doLedgerData(RPC::JsonContext& context)
Json::Value& entry =
nodes.append(sle->getJson(JsonOptions::none));
entry[jss::index] = to_string(sle->key());

if (sle->getType() == ltMPTOKEN_ISSUANCE)
entry[jss::mpt_issuance_id] = to_string(makeMptID(
(*sle)[sfSequence], sle->getAccountID(sfIssuer)));
}
}
}
Expand Down
Loading