From de84d27019dc12ed0531e905495b1ea21b0eb051 Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Tue, 5 Dec 2023 10:30:11 +0000 Subject: [PATCH] Use `TokenName.maxLength` instead of `tokenNameMaxLength`. --- .../lib/Cardano/Wallet/Primitive/Types/TokenName.hs | 12 ++++++------ .../http/Cardano/Wallet/Api/Http/Shelley/Server.hs | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenName.hs b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenName.hs index 98dda117ba2..47b42574be0 100644 --- a/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenName.hs +++ b/lib/primitive/lib/Cardano/Wallet/Primitive/Types/TokenName.hs @@ -8,7 +8,7 @@ module Cardano.Wallet.Primitive.Types.TokenName ( TokenName (..) , empty , fromByteString - , tokenNameMaxLength + , maxLength ) where import Prelude @@ -64,13 +64,13 @@ newtype TokenName = deriving anyclass Hashable -- | Construct a 'TokenName', validating that the length does not exceed --- 'tokenNameMaxLength'. +-- 'maxLength'. -- fromByteString :: ByteString -> Either String TokenName fromByteString bs - | BS.length bs <= tokenNameMaxLength = Right $ UnsafeTokenName bs + | BS.length bs <= maxLength = Right $ UnsafeTokenName bs | otherwise = Left $ "TokenName length " ++ show (BS.length bs) - ++ " exceeds maximum of " ++ show tokenNameMaxLength + ++ " exceeds maximum of " ++ show maxLength -- | The empty asset name. -- @@ -83,8 +83,8 @@ empty = UnsafeTokenName "" -- | The maximum length of a valid token name. -- -tokenNameMaxLength :: Int -tokenNameMaxLength = 32 +maxLength :: Int +maxLength = 32 instance NFData TokenName diff --git a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs index 436ddd75842..d0a438dd356 100644 --- a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs +++ b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs @@ -604,7 +604,6 @@ import Cardano.Wallet.Primitive.Types.TokenMap ) import Cardano.Wallet.Primitive.Types.TokenName ( TokenName (..) - , tokenNameMaxLength ) import Cardano.Wallet.Primitive.Types.TokenPolicyId ( TokenPolicyId (..) @@ -2974,9 +2973,9 @@ constructTransaction api argGenChange knownPools poolStatus apiWalletId body = d where assetNameTooLong mb = case mb ^. #mintBurnData of Left (ApiMintBurnDataFromScript _ (Just (ApiT (UnsafeTokenName bs))) _) -> - BS.length bs > tokenNameMaxLength + BS.length bs > TokenName.maxLength Right (ApiMintBurnDataFromInput _ _ (Just (ApiT (UnsafeTokenName bs))) _) -> - BS.length bs > tokenNameMaxLength + BS.length bs > TokenName.maxLength _ -> error "at this moment there should be asset name attributed" guardAssetQuantityOutOfBounds