Skip to content

Commit

Permalink
[16] first commit
Browse files Browse the repository at this point in the history
[16] mnemonic module and unit tests working properly

[16] add mnemonic executable

[16] weeder and hlint fixes

[16] one more hlint suggestion

[16] move exec to app directory

[16] Review changes
  • Loading branch information
paweljakubas committed Mar 12, 2019
1 parent d421b9f commit 0f88116
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 4 deletions.
46 changes: 46 additions & 0 deletions app/mnemonic/GenerateMnemonic.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{-# LANGUAGE DataKinds #-}

-- |
-- Copyright: © 2018-2019 IOHK
-- License: MIT
--
-- | Mnemonic generation executable


import Prelude

import Cardano.Wallet.Mnemonic
( Mnemonic, entropyToMnemonic, genEntropy, mnemonicToText )
import Data.Function
( flip )
import Data.Text
( Text )

import qualified Data.Text as T
import qualified Data.Text.IO as T

main
:: IO ()
main = do
backupPhrase <- generateBackupPhrase
let backupPhraseString = backupPhraseToString backupPhrase
T.putStrLn $ formatOutput backupPhraseString

generateBackupPhrase
:: IO (Mnemonic 15)
generateBackupPhrase =
entropyToMnemonic <$> genEntropy

backupPhraseToString
:: Mnemonic 15
-> [Text]
backupPhraseToString = mnemonicToText

formatOutput
:: [Text]
-> Text
formatOutput =
flip T.snoc ']'
. T.append "["
. T.intercalate ","
. map (T.append "\"" . flip T.snoc '"' )
39 changes: 35 additions & 4 deletions cardano-wallet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@ library
ghc-options: -Werror
build-depends:
base
, aeson
, base58-bytestring
, basement
, binary
, bytestring
, cardano-crypto
, cryptonite
, cborg
, containers
, cryptonite
, deepseq
, digest
, fmt
, exceptions
, http-api-data
, http-media
, memory
Expand All @@ -54,12 +59,13 @@ library
exposed-modules:
Cardano.ChainProducer.RustHttpBridge.Api
Cardano.ChainProducer.RustHttpBridge.Client
Cardano.Wallet.BlockSyncer
Servant.Extra.ContentTypes
Cardano.Wallet
Cardano.Wallet.Binary
Cardano.Wallet.Binary.Packfile
Cardano.Wallet.BlockSyncer
Cardano.Wallet.Mnemonic
Cardano.Wallet.Primitive
Servant.Extra.ContentTypes
other-modules:
Paths_cardano_wallet

Expand All @@ -82,6 +88,26 @@ executable cardano-wallet-server
Main.hs


executable cardano-generate-mnemonic
default-language:
Haskell2010
default-extensions:
NoImplicitPrelude
OverloadedStrings
ghc-options:
-threaded -rtsopts
-with-rtsopts=-N
-Wall
build-depends:
base
, cardano-wallet
, text
hs-source-dirs:
app/mnemonic
main-is:
GenerateMnemonic.hs


test-suite unit
default-language:
Haskell2010
Expand All @@ -96,17 +122,21 @@ test-suite unit
ghc-options: -Werror
build-depends:
base
, aeson
, base58-bytestring
, bytestring
, cardano-crypto
, cardano-wallet
, cborg
, containers
, deepseq
, hspec
, memory
, QuickCheck
, hspec-expectations
, text
, time-units
, transformers
, QuickCheck
type:
exitcode-stdio-1.0
hs-source-dirs:
Expand All @@ -117,5 +147,6 @@ test-suite unit
Cardano.WalletSpec
Cardano.Wallet.BinarySpec
Cardano.Wallet.Binary.PackfileSpec
Cardano.Wallet.PrimitiveSpec
Cardano.Wallet.BlockSyncerSpec
Cardano.Wallet.MnemonicSpec
Cardano.Wallet.PrimitiveSpec
Loading

0 comments on commit 0f88116

Please sign in to comment.