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

Add mpt_id to ledger_data #23

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/ripple/rpc/handlers/LedgerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ 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(getMptID(
sle->getAccountID(sfIssuer), (*sle)[sfSequence]));
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/test/rpc/LedgerData_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,35 @@ class LedgerData_test : public beast::unit_test::suite
}
}

void
testSyntheticMptID()
{
testcase("Synthetic MPT ID");

using namespace test::jtx;
Account const alice("alice"); // issuer

Env env{*this, envconfig(validator, "")};

MPTTester mptAlice(env, alice);

mptAlice.create({.ownerCount = 1});
Json::Value jvParams;
jvParams[jss::ledger_index] = "current";
jvParams[jss::type] = jss::mpt_issuance;
auto const jrr = env.rpc(
"json",
"ledger_data",
boost::lexical_cast<std::string>(jvParams))[jss::result];

for (auto const& j : jrr[jss::state])
{
BEAST_EXPECT(j["LedgerEntryType"] == jss::MPTokenIssuance);
BEAST_EXPECT(
j[jss::mpt_issuance_id] == to_string(mptAlice.issuanceID()));
}
}

void
run() override
{
Expand All @@ -508,6 +537,7 @@ class LedgerData_test : public beast::unit_test::suite
testMarkerFollow();
testLedgerHeader();
testLedgerType();
testSyntheticMptID();
}
};

Expand Down
Loading