mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-17 18:25:51 +00:00
@@ -57,9 +57,7 @@ NFTInfoHandler::process(NFTInfoHandler::Input input, Context const& ctx) const
|
||||
output.issuer = toBase58(nft::getIssuer(nft.tokenID));
|
||||
output.taxon = nft::toUInt32(nft::getTaxon(nft.tokenID));
|
||||
output.serial = nft::getSerial(nft.tokenID);
|
||||
|
||||
if (not nft.isBurned)
|
||||
output.uri = strHex(nft.uri);
|
||||
output.uri = strHex(nft.uri);
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -68,7 +66,7 @@ void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, NFTInfoHandler::Output const& output)
|
||||
{
|
||||
// TODO: use JStrings when they become available
|
||||
auto object = boost::json::object{
|
||||
jv = boost::json::object{
|
||||
{JS(nft_id), output.nftID},
|
||||
{JS(ledger_index), output.ledgerIndex},
|
||||
{JS(owner), output.owner},
|
||||
@@ -79,12 +77,8 @@ tag_invoke(boost::json::value_from_tag, boost::json::value& jv, NFTInfoHandler::
|
||||
{"nft_taxon", output.taxon},
|
||||
{JS(nft_serial), output.serial},
|
||||
{JS(validated), output.validated},
|
||||
{JS(uri), output.uri},
|
||||
};
|
||||
|
||||
if (output.uri)
|
||||
object[JS(uri)] = *(output.uri);
|
||||
|
||||
jv = std::move(object);
|
||||
}
|
||||
|
||||
NFTInfoHandler::Input
|
||||
|
||||
@@ -46,10 +46,9 @@ public:
|
||||
uint32_t transferFee;
|
||||
std::string issuer;
|
||||
uint32_t taxon;
|
||||
uint32_t serial; // TODO: documented as 'nft_sequence' atm.
|
||||
// https://github.com/XRPLF/xrpl-dev-portal/issues/1841
|
||||
std::optional<std::string> uri; // TODO: documented can be null vs. empty string
|
||||
// https://github.com/XRPLF/xrpl-dev-portal/issues/1841
|
||||
uint32_t serial; // TODO: documented as 'nft_sequence' atm.
|
||||
// https://github.com/XRPLF/xrpl-dev-portal/issues/1841
|
||||
std::string uri;
|
||||
|
||||
// validated should be sent via framework
|
||||
bool validated = true;
|
||||
|
||||
@@ -288,7 +288,7 @@ TEST_F(RPCNFTInfoHandlerTest, NonExistNFT)
|
||||
// normal case when only provide nft_id
|
||||
TEST_F(RPCNFTInfoHandlerTest, DefaultParameters)
|
||||
{
|
||||
constexpr static auto correntOutput = R"({
|
||||
constexpr static auto currentOutput = R"({
|
||||
"nft_id": "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004",
|
||||
"ledger_index": 30,
|
||||
"owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
@@ -322,14 +322,14 @@ TEST_F(RPCNFTInfoHandlerTest, DefaultParameters)
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correntOutput), *output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
}
|
||||
|
||||
// nft is burned -> should omit uri
|
||||
// nft is burned -> should not omit uri
|
||||
TEST_F(RPCNFTInfoHandlerTest, BurnedNFT)
|
||||
{
|
||||
constexpr static auto correntOutput = R"({
|
||||
constexpr static auto currentOutput = R"({
|
||||
"nft_id": "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004",
|
||||
"ledger_index": 30,
|
||||
"owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
@@ -339,6 +339,7 @@ TEST_F(RPCNFTInfoHandlerTest, BurnedNFT)
|
||||
"issuer": "rGJUF4PvVkMNxG6Bg6AKg3avhrtQyAffcm",
|
||||
"nft_taxon": 0,
|
||||
"nft_serial": 4,
|
||||
"uri": "757269",
|
||||
"validated": true
|
||||
})";
|
||||
MockBackend* rawBackendPtr = static_cast<MockBackend*>(mockBackendPtr.get());
|
||||
@@ -363,14 +364,14 @@ TEST_F(RPCNFTInfoHandlerTest, BurnedNFT)
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correntOutput), *output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
}
|
||||
|
||||
// nft is not burned and uri is not available -> should specify null
|
||||
TEST_F(RPCNFTInfoHandlerTest, NotBurnedNFTWithoutURI)
|
||||
{
|
||||
constexpr static auto correntOutput = R"({
|
||||
constexpr static auto currentOutput = R"({
|
||||
"nft_id": "00010000A7CAD27B688D14BA1A9FA5366554D6ADCF9CE0875B974D9F00000004",
|
||||
"ledger_index": 30,
|
||||
"owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
@@ -404,14 +405,14 @@ TEST_F(RPCNFTInfoHandlerTest, NotBurnedNFTWithoutURI)
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correntOutput), *output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
}
|
||||
|
||||
// check taxon field, transfer fee and serial
|
||||
TEST_F(RPCNFTInfoHandlerTest, NFTWithExtraFieldsSet)
|
||||
{
|
||||
constexpr static auto correntOutput = R"({
|
||||
constexpr static auto currentOutput = R"({
|
||||
"nft_id": "00081388319F12E15BCA13E1B933BF4C99C8E1BBC36BD4910A85D52F00000022",
|
||||
"ledger_index": 30,
|
||||
"owner": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
@@ -445,6 +446,6 @@ TEST_F(RPCNFTInfoHandlerTest, NFTWithExtraFieldsSet)
|
||||
auto handler = AnyHandler{NFTInfoHandler{this->mockBackendPtr}};
|
||||
auto const output = handler.process(input, Context{std::ref(yield)});
|
||||
ASSERT_TRUE(output);
|
||||
EXPECT_EQ(json::parse(correntOutput), *output);
|
||||
EXPECT_EQ(json::parse(currentOutput), *output);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user