Skip to content
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 mnemonic sentence support #975

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Add mnemonic sentence support #975

wants to merge 14 commits into from

Conversation

palas
Copy link
Contributor

@palas palas commented Nov 20, 2024

Changelog

- description: |
    Added support for mnemonic sentence generation and extended key derivation from mnemonic sentences.
  type:
  - feature

Context

This PR is associated to: IntersectMBO/cardano-api#678.
It is part of an effort to integrate cardano-addresses functionalities into the cardano-cli.

How to trust this PR

I would look mainly at the logic, the changes in the help golden files, and probably testing it is the best way.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I want feedback from the rest of the team before we approve and merge.

cardano-cli/src/Cardano/CLI/Commands/Key.hs Outdated Show resolved Hide resolved
cardano-cli/src/Cardano/CLI/Commands/Key.hs Show resolved Hide resolved
cardano-cli/src/Cardano/CLI/Commands/Key.hs Outdated Show resolved Hide resolved
cardano-cli/test/cardano-cli-golden/files/golden/help.cli Outdated Show resolved Hide resolved
cardano-cli/test/cardano-cli-golden/files/golden/help.cli Outdated Show resolved Hide resolved
cardano-cli/src/Cardano/CLI/Options/Key.hs Outdated Show resolved Hide resolved
cardano-cli/src/Cardano/CLI/Run/Key.hs Show resolved Hide resolved
cardano-cli/src/Cardano/CLI/Run/Key.hs Outdated Show resolved Hide resolved
cardano-cli/src/Cardano/CLI/Run/Key.hs Outdated Show resolved Hide resolved
@palas palas added next-update Needs a dependency to be updated to be merged and removed next-update Needs a dependency to be updated to be merged labels Nov 28, 2024
Copy link

This PR is stale because it has been open 45 days with no activity.

@github-actions github-actions bot added the Stale label Jan 13, 2025
@palas palas removed the Stale label Jan 15, 2025
@palas palas mentioned this pull request Jan 31, 2025
@palas palas force-pushed the add-mnemonic-support branch from 9dd7301 to eab669b Compare February 12, 2025 18:27
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. I just have one concern regarding haskeline. If we don't need it lets not use it.

cardano-cli/src/Cardano/CLI/Commands/Key.hs Show resolved Hide resolved
import System.Console.Haskeline.Completion (CompletionFunc)

-- | Generate a mnemonic and write it to a file or stdout.
generateMnemonicImpl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Impl suffix is unnecessary. It would be similar to naming it generateMnemonicFunction.

completeMnemonicWord prefix = return $ map (simpleCompletion . T.unpack . fst) $ findMnemonicWordsWithPrefix (T.pack prefix)

inputT :: (String, String) -> [Text] -> InputT IO [Text]
inputT prefill mnemonic = do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use readLine then run the validation on the input? What do we gain by using haskeline?

Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 👍 . One final question.

let newWords = map (T.toLower . T.pack) $ filter (not . null) $ words input
in case span isValidMnemonicWord newWords of
(allWords, []) -> inputT ("", "") (reverse allWords ++ mnemonic)
(validWords, invalidWord : notValidatedWords) -> do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should notValidatedWords be remainingInvalidWords?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mnemonic support
3 participants