mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-21 04:05:51 +00:00
add nft_history and mark certain APIs as clio-only to improve error (#255)
This commit is contained in:
@@ -89,24 +89,15 @@ doNFTInfo(Context const& context)
|
||||
auto request = context.params;
|
||||
boost::json::object response = {};
|
||||
|
||||
if (!request.contains("nft_id"))
|
||||
return Status{Error::rpcINVALID_PARAMS, "Missing nft_id"};
|
||||
|
||||
auto const& jsonTokenID = request.at("nft_id");
|
||||
if (!jsonTokenID.is_string())
|
||||
return Status{Error::rpcINVALID_PARAMS, "nft_id is not a string"};
|
||||
|
||||
ripple::uint256 tokenID;
|
||||
if (!tokenID.parseHex(jsonTokenID.as_string().c_str()))
|
||||
return Status{Error::rpcINVALID_PARAMS, "Malformed nft_id"};
|
||||
|
||||
// We only need to fetch the ledger header because the ledger hash is
|
||||
// supposed to be included in the response. The ledger sequence is specified
|
||||
// in the request
|
||||
auto v = ledgerInfoFromRequest(context);
|
||||
if (auto status = std::get_if<Status>(&v))
|
||||
auto const maybeTokenID = getNFTID(request);
|
||||
if (auto const status = std::get_if<Status>(&maybeTokenID); status)
|
||||
return *status;
|
||||
ripple::LedgerInfo lgrInfo = std::get<ripple::LedgerInfo>(v);
|
||||
auto const tokenID = std::get<ripple::uint256>(maybeTokenID);
|
||||
|
||||
auto const maybeLedgerInfo = ledgerInfoFromRequest(context);
|
||||
if (auto status = std::get_if<Status>(&maybeLedgerInfo); status)
|
||||
return *status;
|
||||
auto const lgrInfo = std::get<ripple::LedgerInfo>(maybeLedgerInfo);
|
||||
|
||||
std::optional<Backend::NFT> dbResponse =
|
||||
context.backend->fetchNFT(tokenID, lgrInfo.seq, context.yield);
|
||||
@@ -130,10 +121,10 @@ doNFTInfo(Context const& context)
|
||||
{
|
||||
auto const maybeURI = getURI(*dbResponse, context);
|
||||
// An error occurred
|
||||
if (Status const* status = std::get_if<Status>(&maybeURI))
|
||||
if (Status const* status = std::get_if<Status>(&maybeURI); status)
|
||||
return *status;
|
||||
// A URI was found
|
||||
if (std::string const* uri = std::get_if<std::string>(&maybeURI))
|
||||
if (std::string const* uri = std::get_if<std::string>(&maybeURI); uri)
|
||||
response["uri"] = *uri;
|
||||
// A URI was not found, explicitly set to null
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user