-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
1 parent
d421b9f
commit 0f88116
Showing
4 changed files
with
574 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '"' ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.