Skip to content

Commit

Permalink
Deprecate writeFileTextEnvelopeWithOwnerPermissions. Use writeLazyByt…
Browse files Browse the repository at this point in the history
…eStringFileWithOwnerPermissions and textEnvelopeToJSON instead
  • Loading branch information
newhoggy committed Apr 4, 2023
1 parent 288a39a commit b54b187
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion cardano-api/src/Cardano/Api/SerialiseTextEnvelope.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ writeFileTextEnvelopeWithOwnerPermissions
-> IO (Either (FileError ()) ())
writeFileTextEnvelopeWithOwnerPermissions targetPath mbDescr a =
writeLazyByteStringFileWithOwnerPermissions targetPath $ textEnvelopeToJSON mbDescr a

{-# DEPRECATED writeFileTextEnvelopeWithOwnerPermissions
"Use writeLazyByteStringFileWithOwnerPermissions and textEnvelopeToJSON instead" #-}

textEnvelopeToJSON :: HasTextEnvelope a => Maybe TextEnvelopeDescr -> a -> LBS.ByteString
textEnvelopeToJSON mbDescr a =
Expand Down
3 changes: 2 additions & 1 deletion cardano-cli/src/Cardano/CLI/Shelley/Run/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ runNodeKeyGenVRF (VerificationKeyFile vkeyPath) (SigningKeyFile skeyPath) = do
let vkey = getVerificationKey skey
firstExceptT ShelleyNodeCmdWriteFileError
. newExceptT
$ writeFileTextEnvelopeWithOwnerPermissions skeyPath (Just skeyDesc) skey
$ writeLazyByteStringFileWithOwnerPermissions skeyPath
$ textEnvelopeToJSON (Just skeyDesc) skey
firstExceptT ShelleyNodeCmdWriteFileError
. newExceptT
$ writeLazyByteStringFile vkeyPath
Expand Down
16 changes: 8 additions & 8 deletions cardano-node/test/Test/Cardano/Node/FilePermissions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ import System.Directory (removeFile)
import Cardano.Api
import Cardano.Node.Run (checkVRFFilePermissions)
import Control.Exception (bracket)
import Control.Monad (Monad(..))
import Control.Monad.Except(MonadIO(liftIO), runExceptT )
import Control.Monad (Monad (..))
import Control.Monad.Except (MonadIO (liftIO), runExceptT)
import Data.Bool (Bool, not)
import Data.Either (Either(..))
import Data.Either (Either (..))
import Data.Eq ((==))
import Data.Foldable (foldl', length)
import Data.Function (($), (.), const)
import Data.Maybe (Maybe(..))
import Data.Semigroup (Semigroup(..))
import Data.Function (const, ($), (.))
import qualified Data.List as L
import Data.Maybe (Maybe (..))
import Data.Semigroup (Semigroup (..))
import Hedgehog (Property, PropertyT, property, success)
import qualified Hedgehog
import Hedgehog.Internal.Property (Group (..), failWith)
import System.IO (FilePath, IO)
import Text.Show (Show(..))
import Text.Show (Show (..))

#ifdef UNIX
import Cardano.Node.Types (VRFPrivateKeyFilePermissionError (..))
Expand Down Expand Up @@ -63,7 +63,7 @@ prop_createVRFFileWithOwnerPermissions =

createFileWithOwnerPermissions :: HasTextEnvelope a => FilePath -> a -> PropertyT IO ()
createFileWithOwnerPermissions targetfp value = do
result <- liftIO $ writeFileTextEnvelopeWithOwnerPermissions targetfp Nothing value
result <- liftIO $ writeLazyByteStringFileWithOwnerPermissions targetfp $ textEnvelopeToJSON Nothing value
case result of
Left err -> failWith Nothing $ displayError err
Right () -> return ()
Expand Down

0 comments on commit b54b187

Please sign in to comment.