diff --git a/cardano-api/internal/Cardano/Api/Hash.hs b/cardano-api/internal/Cardano/Api/Hash.hs index d77c18f578..8fed5cf3a9 100644 --- a/cardano-api/internal/Cardano/Api/Hash.hs +++ b/cardano-api/internal/Cardano/Api/Hash.hs @@ -5,11 +5,16 @@ module Cardano.Api.Hash ( Hash , CastHash(..) , AsType(AsHash) + , renderSafeHashAsHex ) where import Cardano.Api.HasTypeProxy +import qualified Cardano.Crypto.Hash as Hash +import qualified Cardano.Ledger.SafeHash as Ledger + import Data.Kind (Type) +import qualified Data.Text as Text data family Hash keyrole :: Type @@ -23,3 +28,6 @@ instance HasTypeProxy a => HasTypeProxy (Hash a) where data AsType (Hash a) = AsHash (AsType a) proxyToAsType _ = AsHash (proxyToAsType (Proxy :: Proxy a)) + +renderSafeHashAsHex :: Ledger.SafeHash c tag -> Text.Text +renderSafeHashAsHex = Hash.hashToTextAsHex . Ledger.extractHash diff --git a/cardano-api/src/Cardano/Api.hs b/cardano-api/src/Cardano/Api.hs index 2fdcd77eed..1d2fa88b8c 100644 --- a/cardano-api/src/Cardano/Api.hs +++ b/cardano-api/src/Cardano/Api.hs @@ -195,6 +195,7 @@ module Cardano.Api ( -- used in many other places. Hash, castHash, + renderSafeHashAsHex, -- * Payment addresses -- | Constructing and inspecting normal payment addresses