Skip to content

Commit

Permalink
[WIP] Move NFT headers from rippled to libxrpl (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
cindyyan317 authored Jul 24, 2023
1 parent d927f9e commit 31802ac
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 35 deletions.
7 changes: 4 additions & 3 deletions Builds/CMake/RippledCore.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ target_sources (xrpl_core PRIVATE
src/ripple/protocol/impl/UintTypes.cpp
src/ripple/protocol/impl/digest.cpp
src/ripple/protocol/impl/tokens.cpp
src/ripple/protocol/impl/NFTSyntheticSerializer.cpp
src/ripple/protocol/impl/NFTokenID.cpp
src/ripple/protocol/impl/NFTokenOfferID.cpp
#[===============================[
main sources:
subdir: crypto
Expand Down Expand Up @@ -284,6 +287,7 @@ install (
src/ripple/protocol/nft.h
src/ripple/protocol/nftPageMask.h
src/ripple/protocol/tokens.h
src/ripple/protocol/NFTSyntheticSerializer.h
DESTINATION include/ripple/protocol)
install (
FILES
Expand Down Expand Up @@ -728,9 +732,6 @@ target_sources (rippled PRIVATE
src/ripple/rpc/impl/ShardVerificationScheduler.cpp
src/ripple/rpc/impl/Status.cpp
src/ripple/rpc/impl/TransactionSign.cpp
src/ripple/rpc/impl/NFTokenID.cpp
src/ripple/rpc/impl/NFTokenOfferID.cpp
src/ripple/rpc/impl/NFTSyntheticSerializer.cpp
#[===============================[
main sources:
subdir: perflog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ namespace ripple {
class TxMeta;
class STTx;

namespace RPC {

struct JsonContext;

/**
Adds common synthetic fields to transaction-related JSON responses
Expand All @@ -47,12 +43,10 @@ struct JsonContext;
void
insertNFTSyntheticInJson(
Json::Value&,
RPC::JsonContext const&,
std::shared_ptr<STTx const> const&,
TxMeta const&);
/** @} */

} // namespace RPC
} // namespace ripple

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ namespace ripple {
class TxMeta;
class STTx;

namespace RPC {

/**
Add a `nftoken_ids` field to the `meta` output parameter.
The field is only added to successful NFTokenMint, NFTokenAcceptOffer,
Expand All @@ -62,7 +60,6 @@ insertNFTokenID(
TxMeta const& transactionMeta);
/** @} */

} // namespace RPC
} // namespace ripple

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ namespace ripple {
class TxMeta;
class STTx;

namespace RPC {

/**
Add an `offer_id` field to the `meta` output parameter.
The field is only added to successful NFTokenCreateOffer transactions.
Expand All @@ -58,7 +56,6 @@ insertNFTokenOfferID(
TxMeta const& transactionMeta);
/** @} */

} // namespace RPC
} // namespace ripple

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,29 @@
*/
//==============================================================================

#include <ripple/rpc/NFTSyntheticSerializer.h>

#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/ledger/OpenLedger.h>
#include <ripple/app/misc/Transaction.h>
#include <ripple/ledger/View.h>
#include <ripple/net/RPCErr.h>
#include <ripple/protocol/AccountID.h>
#include <ripple/protocol/Feature.h>
#include <ripple/protocol/NFTSyntheticSerializer.h>
#include <ripple/protocol/NFTokenID.h>
#include <ripple/protocol/NFTokenOfferID.h>
#include <ripple/rpc/Context.h>
#include <ripple/rpc/NFTokenID.h>
#include <ripple/rpc/NFTokenOfferID.h>
#include <ripple/rpc/impl/RPCHelpers.h>
#include <boost/algorithm/string/case_conv.hpp>

namespace ripple {
namespace RPC {

void
insertNFTSyntheticInJson(
Json::Value& response,
RPC::JsonContext const& context,
std::shared_ptr<STTx const> const& transaction,
TxMeta const& transactionMeta)
{
insertNFTokenID(response[jss::meta], transaction, transactionMeta);
insertNFTokenOfferID(response[jss::meta], transaction, transactionMeta);
}

} // namespace RPC
} // namespace ripple
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
*/
//==============================================================================

#include <ripple/rpc/NFTokenID.h>
#include <ripple/protocol/NFTokenID.h>

#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/ledger/OpenLedger.h>
#include <ripple/app/misc/Transaction.h>
#include <ripple/ledger/View.h>
Expand All @@ -31,7 +30,6 @@
#include <boost/algorithm/string/case_conv.hpp>

namespace ripple {
namespace RPC {

bool
canHaveNFTokenID(
Expand Down Expand Up @@ -198,5 +196,4 @@ insertNFTokenID(
}
}

} // namespace RPC
} // namespace ripple
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
*/
//==============================================================================

#include <ripple/rpc/NFTokenOfferID.h>
#include <ripple/protocol/NFTokenOfferID.h>

#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/app/ledger/OpenLedger.h>
#include <ripple/app/misc/Transaction.h>
#include <ripple/ledger/View.h>
Expand All @@ -31,7 +30,6 @@
#include <boost/algorithm/string/case_conv.hpp>

namespace ripple {
namespace RPC {

bool
canHaveNFTokenOfferID(
Expand Down Expand Up @@ -81,5 +79,4 @@ insertNFTokenOfferID(
response[jss::offer_id] = to_string(result.value());
}

} // namespace RPC
} // namespace ripple
4 changes: 2 additions & 2 deletions src/ripple/rpc/handlers/AccountTx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
#include <ripple/ledger/ReadView.h>
#include <ripple/net/RPCErr.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/NFTSyntheticSerializer.h>
#include <ripple/protocol/UintTypes.h>
#include <ripple/protocol/jss.h>
#include <ripple/resource/Fees.h>
#include <ripple/rpc/Context.h>
#include <ripple/rpc/DeliveredAmount.h>
#include <ripple/rpc/NFTSyntheticSerializer.h>
#include <ripple/rpc/Role.h>
#include <ripple/rpc/impl/RPCHelpers.h>

Expand Down Expand Up @@ -334,7 +334,7 @@ populateJsonResponse(
insertDeliveredAmount(
jvObj[jss::meta], context, txn, *txnMeta);
insertNFTSyntheticInJson(
jvObj, context, txn->getSTransaction(), *txnMeta);
jvObj, txn->getSTransaction(), *txnMeta);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/rpc/handlers/Tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include <ripple/basics/ToString.h>
#include <ripple/net/RPCErr.h>
#include <ripple/protocol/ErrorCodes.h>
#include <ripple/protocol/NFTSyntheticSerializer.h>
#include <ripple/protocol/jss.h>
#include <ripple/rpc/Context.h>
#include <ripple/rpc/DeliveredAmount.h>
#include <ripple/rpc/GRPCHandlers.h>
#include <ripple/rpc/NFTSyntheticSerializer.h>
#include <ripple/rpc/impl/RPCHelpers.h>

namespace ripple {
Expand Down Expand Up @@ -297,7 +297,7 @@ populateJsonResponse(
insertDeliveredAmount(
response[jss::meta], context, result.txn, *meta);
insertNFTSyntheticInJson(
response, context, result.txn->getSTransaction(), *meta);
response, result.txn->getSTransaction(), *meta);
}
}
response[jss::validated] = result.validated;
Expand Down

0 comments on commit 31802ac

Please sign in to comment.