refactor(mint): split monolithic ledger.py into ledger/ package#1032
refactor(mint): split monolithic ledger.py into ledger/ package#1032KvngMikey wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors the mint ledger implementation from a single large module into a structured package, separating mint/melt/swap and blind-signature logic while adding protocol typing for watchdog functionality.
Changes:
- Split
cashu/mint/ledger.pyinto multiple modules undercashu/mint/ledger/(mint, melt, swap, blind_signatures, ledger). - Introduced
SupportsWatchdogprotocol to type the watchdog balance/fee API used during mint quoting. - Added
cashu.mint.ledgerpackage export via__init__.py.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| cashu/mint/protocols.py | Adds SupportsWatchdog protocol and supporting imports for typed watchdog integration. |
| cashu/mint/ledger/ledger.py | New composed Ledger class wiring together split ledger mixins and startup/shutdown routines. |
| cashu/mint/ledger/blind_signatures.py | Extracts blind signature storage/signing + fee-change promise generation. |
| cashu/mint/ledger/mint.py | Extracts mint quote, mint, and batch mint flows into a dedicated mixin. |
| cashu/mint/ledger/melt.py | Extracts melt quoting and payment execution logic into a dedicated mixin. |
| cashu/mint/ledger/swap.py | Extracts swap + restore logic into a dedicated mixin. |
| cashu/mint/ledger/init.py | Exposes the new package-level Ledger import. |
| cashu/mint/ledger.py | Removes the previous monolithic ledger module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1032 +/- ##
==========================================
+ Coverage 75.04% 75.23% +0.19%
==========================================
Files 111 116 +5
Lines 12244 12288 +44
==========================================
+ Hits 9188 9245 +57
+ Misses 3056 3043 -13 ☔ View full report in Codecov by Sentry. |
Fixes #865
Summary
Extracts the monolithic
1413-line cashu/mint/ledger.pyinto a package with focused mixin classes, making the code easier to navigate and understand. Each mixin inherits from the mixin that provides the methods it calls, this way all existing imports continue to work unchanged.Changes
cashu/mint/ledger.pyhas been replaced with acashu/mint/ledger/package containing focused submodules.ledger/__init__.pybarrel exportsfrom .ledger import Ledger.