chore: Merge develop into release/2.8.0 (#3186)

This commit is contained in:
Ayaz Salikhov
2026-08-20 15:59:46 +01:00
committed by GitHub
5 changed files with 36 additions and 8 deletions

View File

@@ -363,7 +363,7 @@ CustomValidator CustomValidators::authorizeCredentialValidator =
}
// don't want to change issuer error message to be about credentials
if (!issuerValidator.verify(credObj, "issuer")) {
if (!accountBase58Validator.verify(credObj, "issuer")) {
return Error{
Status{ClioError::RpcMalformedAuthorizedCredentials, "issuer NotString"}
};

View File

@@ -590,7 +590,8 @@ struct CustomValidators final {
/**
* @brief Provides a validator for validating credential_type.
*
* Used by AuthorizeCredentialValidator in deposit_preauth.
* Used by AuthorizeCredentialValidator in deposit_preauth and by the credential
* object lookup in ledger_entry.
*/
static CustomValidator credentialTypeValidator;
};

View File

@@ -13,6 +13,7 @@
#include <boost/json/object.hpp>
#include <boost/json/value.hpp>
#include <boost/json/value_to.hpp>
#include <xrpl/basics/Blob.h>
#include <xrpl/basics/Slice.h>
#include <xrpl/basics/StringUtilities.h>
#include <xrpl/basics/base_uint.h>
@@ -32,6 +33,7 @@
#include <algorithm>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
@@ -422,20 +424,23 @@ tag_invoke(boost::json::value_to_tag<LedgerEntryHandler::Input>, boost::json::va
return xrpl::keylet::oracle(*account, documentId).key;
};
auto const parseCredentialFromJson = [](boost::json::value const& json) {
auto const parseCredentialFromJson =
[](boost::json::value const& json) -> std::optional<xrpl::uint256> {
auto const subject = util::parseBase58Wrapper<xrpl::AccountID>(
boost::json::value_to<std::string>(json.at(JS(subject)))
);
auto const issuer = util::parseBase58Wrapper<xrpl::AccountID>(
boost::json::value_to<std::string>(json.at(JS(issuer)))
);
auto const credType =
auto const credTypeOpt =
xrpl::strUnHex(boost::json::value_to<std::string>(json.at(JS(credential_type))));
return xrpl::keylet::credential(
*subject, *issuer, xrpl::Slice(credType->data(), credType->size())
)
.key;
return credTypeOpt.transform([&](xrpl::Blob const& credType) -> xrpl::uint256 {
return xrpl::keylet::credential(
*subject, *issuer, xrpl::Slice(credType.data(), credType.size())
)
.key;
});
};
auto const indexFieldType =

View File

@@ -380,6 +380,7 @@ public:
meta::WithCustomError{
validation::Type<std::string>{}, Status(ClioError::RpcMalformedRequest)
},
validation::CustomValidators::credentialTypeValidator,
},
}}},
{JS(mpt_issuance),

View File

@@ -347,6 +347,27 @@ generateTestValuesForParametersTest()
.expectedErrorMessage = "issuer NotString"
},
ParamTestCaseBundle{
.testName = "DepositPreauthAuthorizeCredentialsHexIssuer",
.testJson = fmt::format(
R"JSON({{
"deposit_preauth": {{
"owner": "{}",
"authorized_credentials": [
{{
"issuer": "0000000000000000000000000000000000000002",
"credential_type": "{}"
}}
]
}}
}})JSON",
kAccount,
kCredentialType
),
.expectedError = "malformedAuthorizedCredentials",
.expectedErrorMessage = "issuer NotString"
},
ParamTestCaseBundle{
.testName = "DepositPreauthAuthorizeCredentialsIncorrectCredentialType",
.testJson = fmt::format(