Commit c4e60414 authored by artem-bv's avatar artem-bv

add name and id min size check, issue #354

parent f24a1626
......@@ -36,7 +36,8 @@ namespace Platform
if (nftProto.nftRegSign < static_cast<uint8_t>(NftRegSignMin) || nftProto.nftRegSign > static_cast<uint8_t>(NftRegSignMax))
return state.DoS(10, false, REJECT_INVALID, "bad-nft-proto-reg-tx-reg-sign");
if (nftProto.tokenProtocolName.size() > NfTokenProtocol::TOKEN_PROTOCOL_NAME_MAX)
if (nftProto.tokenProtocolName.size() < NfTokenProtocol::TOKEN_PROTOCOL_NAME_MIN
|| nftProto.tokenProtocolName.size() > NfTokenProtocol::TOKEN_PROTOCOL_NAME_MAX)
return state.DoS(10, false, REJECT_INVALID, "bad-nft-proto-reg-tx-proto-name");
if (nftProto.tokenMetadataMimeType.size() > NfTokenProtocol::TOKEN_METADATA_MIMETYPE_MAX)
......
......@@ -57,7 +57,9 @@ namespace Platform
CKeyID tokenProtocolOwnerId;
//TODO: add admin key to the protocol structure. add option to use setup admin key rights including tranfering ownership
static const unsigned TOKEN_PROTOCOL_ID_MIN = 3;
static const unsigned TOKEN_PROTOCOL_ID_MAX = 12;
static const unsigned TOKEN_PROTOCOL_NAME_MIN = 3;
static const unsigned TOKEN_PROTOCOL_NAME_MAX = 24;
static const unsigned TOKEN_METADATA_SCHEMA_URI_MAX = 128;
static const unsigned TOKEN_METADATA_MIMETYPE_MAX = 32;
......
......@@ -20,8 +20,8 @@ namespace Platform
NftProtocolRegTxBuilder & SetTokenProtocol(const json_spirit::Value & tokenProtocolId)
{
auto nftProtoStr = tokenProtocolId.get_str();
if (nftProtoStr.size() > NfTokenProtocol::TOKEN_PROTOCOL_ID_MAX)
throw JSONRPCError(RPC_INVALID_PARAMETER, "NFT protocol ID is longer than permitted");
if (nftProtoStr.size() < NfTokenProtocol::TOKEN_PROTOCOL_ID_MIN || nftProtoStr.size() > NfTokenProtocol::TOKEN_PROTOCOL_ID_MAX)
throw JSONRPCError(RPC_INVALID_PARAMETER, "NFT protocol ID must be between 3 and 12 symbols long");
m_nftProto.tokenProtocolId = StringToProtocolName(nftProtoStr.c_str());
return *this;
}
......@@ -29,8 +29,9 @@ namespace Platform
NftProtocolRegTxBuilder & SetTokenProtocolName(const json_spirit::Value & tokenProtocolName)
{
m_nftProto.tokenProtocolName = tokenProtocolName.get_str();
if (m_nftProto.tokenProtocolName.size() > NfTokenProtocol::TOKEN_PROTOCOL_NAME_MAX)
throw JSONRPCError(RPC_INVALID_PARAMETER, "NFT Protocol name is longer than permitted");
if (m_nftProto.tokenProtocolName.size() < NfTokenProtocol::TOKEN_PROTOCOL_NAME_MIN
|| m_nftProto.tokenProtocolName.size() > NfTokenProtocol::TOKEN_PROTOCOL_NAME_MAX)
throw JSONRPCError(RPC_INVALID_PARAMETER, "NFT Protocol name must be between 3 and 24 symbols long");
return *this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment