Skip to content

chore: refactor models.py into modular package structure#960

Open
KvngMikey wants to merge 1 commit intocashubtc:mainfrom
KvngMikey:models_refactor
Open

chore: refactor models.py into modular package structure#960
KvngMikey wants to merge 1 commit intocashubtc:mainfrom
KvngMikey:models_refactor

Conversation

@KvngMikey
Copy link
Copy Markdown
Contributor

@KvngMikey KvngMikey commented Mar 30, 2026

Fixes #951

Summary

Refactors cashu/core/models.py into a module, splitting the monolithic file into focused submodules grouped by API concern.

Changes

cashu/core/models.py has been replaced with a cashu/core/models/ package containing focused submodules

__init__.py barrel-exports all public classes from the submodules, so all existing import sites across the codebase continue to work without any changes and pointed back test files relying on BlindedMessage and Proof incorrectly exported from models file to the correct base file.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 98.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.99%. Comparing base (a1ff72c) to head (2fe17ec).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
cashu/core/models/info.py 94.64% 3 Missing ⚠️
cashu/core/models/melt_quote.py 97.43% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #960      +/-   ##
==========================================
+ Coverage   74.90%   74.99%   +0.08%     
==========================================
  Files          99      109      +10     
  Lines       11685    11727      +42     
==========================================
+ Hits         8753     8795      +42     
  Misses       2932     2932              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors cashu/core/models.py into a cashu/core/models/ package, splitting API request/response models into focused modules and centralizing re-exports via a package __init__.py.

Changes:

  • Replaced the monolithic cashu/core/models.py with a modular cashu/core/models/ package (info/keys/mint/melt/swap/etc.).
  • Added a barrel-export cashu/core/models/__init__.py for API models.
  • Updated a few import sites to pull core types directly from cashu.core.base.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/fuzz/test_fuzz_mint_api_deprecated.py Switches imports for shared base models from cashu.core.models to cashu.core.base.
tests/fuzz/test_fuzz_mint_api.py Switches imports for shared base models from cashu.core.models to cashu.core.base.
cashu/mint/auth/server.py Consolidates base-type imports from cashu.core.base and removes cashu.core.models import.
cashu/core/models/init.py Barrel-exports API request/response models from the new submodules.
cashu/core/models/blind_auth.py New dedicated module for blind-auth API request/response models.
cashu/core/models/check.py New dedicated module for check-state API request/response models (incl. deprecated).
cashu/core/models/info.py New dedicated module for mint info API models (incl. deprecated preprocessing).
cashu/core/models/keys.py New dedicated module for keys/keysets API response models (incl. deprecated).
cashu/core/models/melt.py New dedicated module for melt API request/response models (incl. deprecated).
cashu/core/models/melt_quote.py New dedicated module for melt-quote API models and conversion helper.
cashu/core/models/mint.py New dedicated module for mint API request/response models (incl. deprecated).
cashu/core/models/mint_quote.py New dedicated module for mint-quote API models and conversion helper.
cashu/core/models/restore.py New dedicated module for restore API request/response models (incl. deprecated).
cashu/core/models/swap.py New dedicated module for swap API request/response models (incl. deprecated).
cashu/core/models.py Removes the prior monolithic module in favor of the package structure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

chore: refactor models file

2 participants