Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
[AD-501] final PR corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
epicallan committed Dec 4, 2018
1 parent f173e0c commit d639c80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 5 additions & 3 deletions ariadne/cardano/src/Ariadne/Wallet/Backend/Restore.hs
Expand Up @@ -5,6 +5,8 @@ module Ariadne.Wallet.Backend.Restore
, restoreFromKeyFile
) where

import qualified Universum.Unsafe as Unsafe (init)

import Control.Natural (type (~>))

import Pos.Util.BackupPhrase (BackupPhrase(..))
Expand Down Expand Up @@ -46,7 +48,7 @@ getMnemonicRestore ::
=> Mnemonic
-> PassPhrase
-> m RestoreFrom
getMnemonicRestore mn@(Mnemonic mnemonic) pp = do
getMnemonicRestore (Mnemonic mnemonic) pp = do
let mnemonicWords = words mnemonic

let isAriadneMnemonic = fromMaybe False $ do
Expand All @@ -55,9 +57,9 @@ getMnemonicRestore mn@(Mnemonic mnemonic) pp = do

rFromEither <- if
| isAriadneMnemonic ->
pure $ Left mn
pure . Left $ Mnemonic (unwords $ Unsafe.init mnemonicWords)
| length mnemonicWords == 12 ->
pure $ Right (BackupPhrase mnemonicWords)
pure . Right $ BackupPhrase mnemonicWords
| otherwise -> throwM $ WrongMnemonic "Unknown mnemonic type"

pure $ RestoreFromMnemonic rFromEither pp
Expand Down
7 changes: 2 additions & 5 deletions ariadne/cardano/src/Ariadne/Wallet/Cardano/Kernel/Restore.hs
Expand Up @@ -8,8 +8,6 @@ module Ariadne.Wallet.Cardano.Kernel.Restore
, WrongMnemonic (..)
) where

import qualified Universum.Unsafe as Unsafe (init)

import Control.Exception (Exception(displayException))
import Control.Lens (at, non, (?~))
import qualified Data.ByteString as BS
Expand Down Expand Up @@ -117,8 +115,7 @@ getKeyFromMnemonic
-> m EncryptedSecretKey
getKeyFromMnemonic pp = \case
Left (Mnemonic mnemonic) ->
let mnemonicWords = words mnemonic
seed = mnemonicToSeedNoPassword (unwords $ Unsafe.init mnemonicWords)
let seed = mnemonicToSeedNoPassword mnemonic
in pure . snd $ Crypto.safeDeterministicKeyGen seed pp
Right backupPhrase ->
case safeKeysFromPhrase pp backupPhrase of
Expand Down Expand Up @@ -161,7 +158,7 @@ collectUtxo esk = do
groupAddresses :: PrefilteredUtxo -> UtxoByAccount
groupAddresses =
-- See https://hackage.haskell.org/package/lens-3.10.1/docs/Control-Lens-Iso.html#v:non
-- or a comment in Ariadne.Wallet.Cardano.kernel.AddressDiscovery.discoverHDAddressesWithUtxo
-- or a comment in Ariadne.Wallet.Cardano.Kernel.AddressDiscovery.discoverHDAddressesWithUtxo
-- for an explanation of how this works.
let step :: UtxoByAccount ->
(HdAddressId, Address) ->
Expand Down

0 comments on commit d639c80

Please sign in to comment.