#include "data/DBHelpers.hpp" #include "util/Assert.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include namespace etl { std::vector getMPTHolderFromTx(xrpl::TxMeta const& txMeta, xrpl::STTx const&) { if (txMeta.getResultTER() != xrpl::tesSUCCESS) return {}; std::vector holders; for (xrpl::STObject const& node : txMeta.getNodes()) { if (node.getFieldU16(xrpl::sfLedgerEntryType) != xrpl::ltMPTOKEN) continue; if (node.getFName() == xrpl::sfCreatedNode) { auto const& newMPT = node.peekAtField(xrpl::sfNewFields).downcast(); holders.push_back( MPTHolderData{ .mptID = newMPT[xrpl::sfMPTokenIssuanceID], .holder = newMPT.getAccountID(xrpl::sfAccount) } ); } } return holders; } std::optional getMPTHolderFromObj(std::string const& key, std::string const& blob) { // https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0033-multi-purpose-tokens#2121-mptoken-ledger-identifier ASSERT( key.size() == xrpl::uint256::size(), "The size of the key is expected to fit uint256 exactly" ); xrpl::STLedgerEntry const sle = xrpl::STLedgerEntry( xrpl::SerialIter{blob.data(), blob.size()}, xrpl::uint256::fromVoid(key.data()) ); if (sle.getFieldU16(xrpl::sfLedgerEntryType) != xrpl::ltMPTOKEN) return {}; auto const mptIssuanceID = sle[xrpl::sfMPTokenIssuanceID]; auto const holder = sle.getAccountID(xrpl::sfAccount); return MPTHolderData{.mptID = mptIssuanceID, .holder = holder}; } } // namespace etl