-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add genesis create-cardano command #3832
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -559,7 +559,7 @@ module Cardano.Api ( | |
mkLocalNodeClientParams, | ||
LocalChainSyncClient(..), | ||
CardanoMode, | ||
-- connectToRemoteNode, | ||
-- connectToRemoteNode, | ||
|
||
-- *** Chain sync protocol | ||
-- | To construct a @ChainSyncClient@ see @Cardano.Api.Client@ or | ||
|
@@ -663,7 +663,9 @@ module Cardano.Api ( | |
|
||
chainPointToSlotNo, | ||
chainPointToHeaderHash, | ||
makeChainTip | ||
makeChainTip, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should not be exposed here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, these could be moved until a cardano-cli utils file |
||
parseFilePath, | ||
writeSecrets | ||
|
||
) where | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE CPP #-} | ||
|
||
#if !defined(mingw32_HOST_OS) | ||
#define UNIX | ||
#endif | ||
|
||
-- | Internal utils for the other Api modules | ||
-- | ||
module Cardano.Api.Utils | ||
( (?!) | ||
, (?!.) | ||
, formatParsecError | ||
, noInlineMaybeToStrictMaybe | ||
, runParsecParser | ||
, failEither | ||
, failEitherWith | ||
, noInlineMaybeToStrictMaybe | ||
, note | ||
, parseFilePath | ||
, runParsecParser | ||
, writeSecrets | ||
) where | ||
|
||
import Prelude | ||
|
||
import Control.Monad (forM_) | ||
import qualified Data.Aeson.Types as Aeson | ||
import qualified Data.ByteString as BS | ||
import Data.Maybe.Strict | ||
import Data.Text (Text) | ||
import qualified Data.Text as Text | ||
import qualified Text.Parsec as Parsec | ||
import qualified Text.Parsec.String as Parsec | ||
import qualified Text.ParserCombinators.Parsec.Error as Parsec | ||
import Text.Printf (printf) | ||
import qualified Options.Applicative as Opt | ||
import System.FilePath ((</>)) | ||
#ifdef UNIX | ||
import System.Posix.Files (ownerReadMode, setFileMode) | ||
#else | ||
import System.Directory (emptyPermissions, readable, setPermissions) | ||
#endif | ||
|
||
(?!) :: Maybe a -> e -> Either e a | ||
Nothing ?! e = Left e | ||
|
@@ -50,3 +70,29 @@ failEither = either fail pure | |
|
||
failEitherWith :: MonadFail m => (e -> String) -> Either e a -> m a | ||
failEitherWith f = either (fail . f) pure | ||
|
||
note :: MonadFail m => String -> Maybe a -> m a | ||
note msg = \case | ||
Nothing -> fail msg | ||
Just a -> pure a | ||
|
||
parseFilePath :: String -> String -> Opt.Parser FilePath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these do not belong in Cardano.Api. They should live in cadano-cli. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, these could be moved until a cardano-cli utils file |
||
parseFilePath optname desc = | ||
Opt.strOption | ||
( Opt.long optname | ||
<> Opt.metavar "FILEPATH" | ||
<> Opt.help desc | ||
<> Opt.completer (Opt.bashCompleter "file") | ||
) | ||
|
||
writeSecrets :: FilePath -> [Char] -> [Char] -> (a -> BS.ByteString) -> [a] -> IO () | ||
writeSecrets outDir prefix suffix secretOp xs = | ||
forM_ (zip xs [0::Int ..]) $ | ||
\(secret, nr)-> do | ||
let filename = outDir </> prefix <> "." <> printf "%03d" nr <> "." <> suffix | ||
BS.writeFile filename $ secretOp secret | ||
#ifdef UNIX | ||
setFileMode filename ownerReadMode | ||
#else | ||
setPermissions filename (emptyPermissions {readable = True}) | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be exposed @cleverca22. I will be undoing this in a future PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how else is this code going to convert keys into json?