Skip to content

Refactor Tools_View #369

Merged
3rdIteration merged 12 commits into
devfrom
Refactor-Tools
Jun 14, 2026
Merged

Refactor Tools_View #369
3rdIteration merged 12 commits into
devfrom
Refactor-Tools

Conversation

@3rdIteration

Copy link
Copy Markdown
Owner

Was getting huge :)

Copilot AI review requested due to automatic review settings June 13, 2026 13:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new password_generator_views.py module to pull the password-generator flow out of the previously “huge” tools_views area, aiming to improve organization and maintainability.

Changes:

  • Added a dedicated ToolsPassword* view module for password generation, entropy collection, review, and save flows.
  • Wired in support paths for multiple password formats (Diceware, Dice Rolls, Hex/Base64/Base85, custom charset) and multiple entropy sources (camera, system RNG, BIP85).
  • Added Seedkeeper save support for generated passwords.

Comment on lines +29 to +31
from seedsigner.models.seed import Seed
from seedsigner.models.settings_definition import SettingsConstants
from .view import View, Destination, BackStackView, MainMenuView
Comment on lines +299 to +322
if selected == dice:
if self.password_type == PASSWORD_TYPE_DICE_ROLLS and self.dice_sides is not None and self.roll_count is not None:
return Destination(
ToolsPasswordDiceEntryView,
view_args=dict(
password_type=self.password_type,
random_options=self.random_options,
strength_bits=self.strength_bits,
total_rolls=self.roll_count,
word_count=None,
entropy_source=PASSWORD_ENTROPY_DICE,
dice_sides=self.dice_sides,
),
skip_current_view=True,
)
return Destination(
ToolsPasswordDiceRollCountView,
view_args=dict(
password_type=self.password_type,
strength_bits=self.strength_bits,
random_options=self.random_options,
entropy_source=PASSWORD_ENTROPY_DICE,
),
)
Copilot AI added a commit that referenced this pull request Jun 13, 2026
- Move BIP85/GPG imports from tools_views to gpg_views
- Remove duplicate local imports of _bip85_key_type_choices
- Update tests and tools to use correct import paths

Fixes import errors in:
- tests/test_bip85_gpg.py
- tests/test_bip85_bipsea_vectors.py
- tests/test_bip85_pgp_cli.py
- tools/bip85_pgp.py
Add pythonpath=["src"] to pyproject.toml and remove redundant pip install . from CI workflow. Rework view imports and exports so internal helpers (including underscore-prefixed symbols and shared TextQR/BIP85 helpers) are explicitly re-exported from tools_views for backward compatibility. Propagate shared helpers across gpg_views, password_generator_views, and smartcard_views (also fix a logging call and add hmac, seedkeeper utils, and seed-related imports). Update tests to patch the appropriate modules (smartcard_views and password_generator_views) so monkeypatches target the modules that actually import the helpers.
Add a Testing guidance section to AGENTS.md describing how to run pytest, expected platform-dependent failures, a star-import caveat for underscore-prefixed names, and guidance for adding tests. Re-export _check_future_key_creation from gpg_views in tools_views.py for backward compatibility with tests and callers. Update tests/test_gpg_message.py: improve _msys2_path to detect the installed gpg via shutil.which and only convert Windows paths to MSYS2 style when the GPG binary is from Git-for-Windows/MSYS2, leaving native Gpg4win paths unchanged to avoid writable keyring errors.
Define a MIN_RSA_KEY_BITS = 2048 constant in gpg_views.py (used by bip85_rsa_from_root) to enforce a minimum RSA key size. Update AGENTS.md to refresh the test table (clarify satochip test entry) and adjust the baseline test counts to 716 passing, 134 skipped, 7 failing, noting satochip tests require physical hardware.
Add missing imports and helpers to smartcard_views: binascii (hexlify/unhexlify), embit.descriptor.Descriptor, and embit_utils plus XprvSeed from models. Also reorder/clean imports and expose SeedExportXpubVerifyAddressView. Update unit test to patch HDKey in the smartcard_views module instead of tools_views to match the refactor. These changes prepare the smartcard view code for using embit utilities and the Xprv-backed seed model.
Refactor tests/test_bip85_gpg.py to import and reference seedsigner.views.gpg_views rather than the older tools_views alias. Update monkeypatch.setattr targets, class instantiations, and BIP85_DATA assertions to use gpg_views. Add seed_bytes attribute to test SeedObj classes and make a few related minor adjustments (imports and subprocess/microsd references) to ensure tests target the correct module.
Add multiple .cap applet binaries under javacard-cap/ to ship built applets. Refactor smartcard views: move the GlobalPlatform presence check into the BUILD_APPLETS path and show a clear warning when DIY tools are not available. Rewrite ToolsDIYInstallAppletView to gather .cap files from both the internal repo and the MicroSD javacard-cap directory, merge results, prefix duplicate names with (Internal)/(MicroSD) to disambiguate, and handle missing/unreadable MicroSD gracefully. Also add a docstring and improve selection logging.
Add a new javacard-cap/javacard-cap.sha256 manifest containing SHA256 sums for various CAP files. Update smartcard_views.py to detect the DIY toolchain by checking for the ANT executable path (ant/bin/ant) instead of looking for gp.jar, with host-specific path locations adjusted accordingly and the existence check updated to use the ant path.
Extracts the internal javacard-cap path into a module-level _get_internal_cap_dir() function and updates ToolsDIYInstallAppletView to use it. Tests updated to monkeypatch this helper (and adjust the logger target) so the test suite can isolate from the real filesystem. No behavioral change beyond making the internal cap directory retrieval testable.
@3rdIteration 3rdIteration merged commit be5e52c into dev Jun 14, 2026
9 of 13 checks passed
@3rdIteration 3rdIteration deleted the Refactor-Tools branch June 14, 2026 20:06
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.

2 participants