Add ShareTotal to ledger_entry output

This commit is contained in:
Bronek Kozicki
2025-03-21 16:33:31 +00:00
parent 3d2102106c
commit 58f15307ba
3 changed files with 35 additions and 0 deletions

View File

@@ -90,6 +90,7 @@ JSS(SendMax); // in: TransactionSign
JSS(Sequence); // in/out: TransactionSign; field.
JSS(SetFlag); // field.
JSS(Share); // out: Vault
JSS(ShareTotal); // out: Vault
JSS(Signer); // field.
JSS(Signers); // field.
JSS(SigningPubKey); // field.

View File

@@ -28,6 +28,7 @@
#include <xrpl/basics/base_uint.h>
#include <xrpl/beast/unit_test/suite.h>
#include <xrpl/json/json_forwards.h>
#include <xrpl/protocol/Asset.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/STAmount.h>

View File

@@ -894,6 +894,37 @@ struct LedgerEntry
LedgerEntryType expectedType;
};
template <LedgerEntryType Type>
static void
supplementJson(
ReadView const&,
std::shared_ptr<SLE const> const& sle,
Json::Value&)
{
XRPL_ASSERT(
sle->getType() == Type, "ripple::supplementJson : matching type");
}
template <>
void
supplementJson<ltVAULT>(
ReadView const& view,
std::shared_ptr<SLE const> const& vault,
Json::Value& node)
{
XRPL_ASSERT(
vault->getType() == ltVAULT,
"ripple::supplementJson<ltVAULT> : matching type");
auto const share = vault->at(sfMPTokenIssuanceID);
auto const sleIssuance = view.read(keylet::mptIssuance(share));
if (!sleIssuance)
return;
node[jss::ShareTotal] =
Number(sleIssuance->getFieldU64(sfOutstandingAmount));
}
// {
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
@@ -1033,6 +1064,8 @@ doLedgerEntry(RPC::JsonContext& context)
else
{
jvResult[jss::node] = sleNode->getJson(JsonOptions::none);
if (sleNode->getType() == ltVAULT)
supplementJson<ltVAULT>(*lpLedger, sleNode, jvResult[jss::node]);
jvResult[jss::index] = to_string(uNodeIndex);
}