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

Clear clipboard of the mnemonic #130

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

yorickdowne
Copy link

@yorickdowne yorickdowne commented Sep 2, 2024

Partially addresses #32

Changes

Use pyperclip, which works on macOS, Linux and Windows, to set the clipboard to a space character after user is done inputting data

Types of changes

What types of changes does your code introduce?

  • New feature (a non-breaking change that adds functionality)

Testing

Requires testing

  • Yes
  • No

Remarks

This introduces some host dependencies. Notably on Linux, clipboard mechanisms only exist if a window manager is present. So as to not bomb out on headless Linux, the code is in a try: except:

"On Windows, no additional modules are needed.

On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.

On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run “sudo apt-get install xclip” or “sudo apt-get install xsel” (Note: xsel does not always seem to work.)"

@yorickdowne yorickdowne added the run-tests Request tests to run on the CI label Sep 2, 2024
@yorickdowne yorickdowne marked this pull request as draft September 2, 2024 01:03
@yorickdowne yorickdowne marked this pull request as ready for review September 2, 2024 01:31
Copy link

github-actions bot commented Sep 2, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     33      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          31      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               70      3    96%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     51    75%
-------------------------------------------------------------------------------
TOTAL                                                        1333    184    86%

Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

This should be documented in:

and probably on the CLI help and on the user screen when performing the task with something along the lines of We will attempt to clear your clipboard after confirming your mnemonic so make sure to write it down somewhere safe first..

@yorickdowne
Copy link
Author

existing-mnemonic, the user already has the mnemonic outside the clipboard somewhere. We don't need to warn.

Added a warning (and a note in docs) for new-mnemonic.

Copy link

Test Coverage: Download HTML Report

Name                                                                 Stmts   Miss  Cover
----------------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                            1      0   100%
ethstaker_deposit/bls_to_execution_change_keystore.py                   33      2    94%
ethstaker_deposit/cli/__init__.py                                        0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                              33      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py                      41      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py                      63      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py               59     11    81%
ethstaker_deposit/cli/generate_bls_to_execution_change_keystore.py      42      2    95%
ethstaker_deposit/cli/generate_keys.py                                  41      2    95%
ethstaker_deposit/cli/new_mnemonic.py                                   31      0   100%
ethstaker_deposit/cli/partial_deposit.py                                62      5    92%
ethstaker_deposit/cli/test_keystore.py                                  20      0   100%
ethstaker_deposit/credentials.py                                       197     68    65%
ethstaker_deposit/deposit.py                                            58     10    83%
ethstaker_deposit/exceptions.py                                          2      0   100%
ethstaker_deposit/key_handling/__init__.py                               0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py                0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py               90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py                   17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py                   36      0   100%
ethstaker_deposit/key_handling/keystore.py                             100      0   100%
ethstaker_deposit/settings.py                                           26      0   100%
ethstaker_deposit/utils/__init__.py                                      0      0   100%
ethstaker_deposit/utils/ascii_art.py                                     2      0   100%
ethstaker_deposit/utils/click.py                                        72      3    96%
ethstaker_deposit/utils/config.py                                        3      0   100%
ethstaker_deposit/utils/constants.py                                    29      0   100%
ethstaker_deposit/utils/crypto.py                                       29      1    97%
ethstaker_deposit/utils/deposit.py                                       9      0   100%
ethstaker_deposit/utils/exit_transaction.py                             24      0   100%
ethstaker_deposit/utils/file_handling.py                                 8      0   100%
ethstaker_deposit/utils/intl.py                                         54      3    94%
ethstaker_deposit/utils/ssz.py                                          60      7    88%
ethstaker_deposit/utils/validation.py                                  244     52    79%
----------------------------------------------------------------------------------------
TOTAL                                                                 1486    184    88%

@yorickdowne yorickdowne mentioned this pull request Sep 17, 2024
5 tasks
Copy link
Member

@remyroy remyroy left a comment

Choose a reason for hiding this comment

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

Everything seems good.

@remyroy remyroy merged commit 79c2b09 into eth-educators:main Sep 17, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-tests Request tests to run on the CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants