feat: Hook up nft_uri, nft_issuer, nft_taxon, nft_flags, nft_xfer_fee, nft_serial host functions

This commit is contained in:
TimothyBanks
2026-08-11 09:44:00 -04:00
parent 98cf3a0532
commit 7d52867e3c
11 changed files with 671 additions and 1 deletions

View File

@@ -874,4 +874,101 @@ HostContext::updateData(rust::Slice<std::uint8_t const> data) const noexcept
});
}
std::int32_t
HostContext::getNFT(
rust::Slice<std::uint8_t const> account,
rust::Slice<std::uint8_t const> nftId,
rust::Slice<std::uint8_t> out) const noexcept
{
return guarded(hostFunctions_.getJournal(), kHostInternal, [&] {
if (account.size() != AccountID::size() || nftId.size() != uint256::size())
return hfErrorToInt(HostFunctionError::InvalidParams);
auto const value = hostFunctions_.getNFT(
AccountID::fromVoid(account.data()), uint256::fromVoid(nftId.data()));
if (!value)
return hfErrorToInt(value.error());
return answer(out, value->data(), value->size());
});
}
std::int32_t
HostContext::getNFTIssuer(rust::Slice<std::uint8_t const> nftId, rust::Slice<std::uint8_t> out)
const noexcept
{
return guarded(hostFunctions_.getJournal(), kHostInternal, [&] {
if (nftId.size() != uint256::size())
return hfErrorToInt(HostFunctionError::InvalidParams);
auto const value = hostFunctions_.getNFTIssuer(uint256::fromVoid(nftId.data()));
if (!value)
return hfErrorToInt(value.error());
return answer(out, value->data(), value->size());
});
}
std::int32_t
HostContext::getNFTTaxon(rust::Slice<std::uint8_t const> nftId, rust::Slice<std::uint8_t> out)
const noexcept
{
return guarded(hostFunctions_.getJournal(), kHostInternal, [&] {
if (nftId.size() != uint256::size())
return hfErrorToInt(HostFunctionError::InvalidParams);
auto const value = hostFunctions_.getNFTTaxon(uint256::fromVoid(nftId.data()));
if (!value)
return hfErrorToInt(value.error());
return answerScalar(out, *value);
});
}
std::int32_t
HostContext::getNFTFlags(rust::Slice<std::uint8_t const> nftId) const noexcept
{
return guarded(hostFunctions_.getJournal(), kHostInternal, [&] {
if (nftId.size() != uint256::size())
return hfErrorToInt(HostFunctionError::InvalidParams);
auto const value = hostFunctions_.getNFTFlags(uint256::fromVoid(nftId.data()));
if (!value)
return hfErrorToInt(value.error());
return *value;
});
}
std::int32_t
HostContext::getNFTTransferFee(rust::Slice<std::uint8_t const> nftId) const noexcept
{
return guarded(hostFunctions_.getJournal(), kHostInternal, [&] {
if (nftId.size() != uint256::size())
return hfErrorToInt(HostFunctionError::InvalidParams);
auto const value = hostFunctions_.getNFTTransferFee(uint256::fromVoid(nftId.data()));
if (!value)
return hfErrorToInt(value.error());
return *value;
});
}
std::int32_t
HostContext::getNFTSequence(rust::Slice<std::uint8_t const> nftId, rust::Slice<std::uint8_t> out)
const noexcept
{
return guarded(hostFunctions_.getJournal(), kHostInternal, [&] {
if (nftId.size() != uint256::size())
return hfErrorToInt(HostFunctionError::InvalidParams);
auto const value = hostFunctions_.getNFTSequence(uint256::fromVoid(nftId.data()));
if (!value)
return hfErrorToInt(value.error());
return answerScalar(out, *value);
});
}
} // namespace xrpl