feat: align mint quote accounting with NUT-04#2119
Conversation
cdk-bot
left a comment
There was a problem hiding this comment.
Verified findings approved for disclosure:
- Missing Supabase migration for mint_quote.updated_at (high) - Existing Supabase wallet databases can fail mint quote insert/update paths after this PR because the application sends an
updated_atfield that the deployedmint_quotetable does not have, while startup compatibility checks still accept the old schema version.
Unanchored locations included in summary:- crates/cdk-supabase/src/wallet.rs:2570
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf37f626a0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
bf37f62 to
d5257c1
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2119 +/- ##
==========================================
+ Coverage 71.48% 71.53% +0.05%
==========================================
Files 356 356
Lines 73857 74154 +297
==========================================
+ Hits 52798 53049 +251
- Misses 21059 21105 +46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| self.is_finalized = true; | ||
| Poll::Ready(None) | ||
| } | ||
| None => self.poll_event(cx), |
There was a problem hiding this comment.
We should also implement a recursion limit and a sleep interval between events to reduce the load.
There was a problem hiding this comment.
If I remember correctly, this is fine because the next future would exit the call stack with a Pending
There was a problem hiding this comment.
It looks like the recursion limit issue you bring up is valid but as @crodas said its "mostly" okay based on the next future. However, I still think we should clean it up but as a separate focused PR as its an existing pattern not introduced by this pr.
| if r.amount_paid > Amount::ZERO || r.amount_issued > Amount::ZERO { | ||
| Some(quote_state_from_amounts(r.amount_paid, r.amount_issued)) | ||
| } else { | ||
| Some(r.state) | ||
| } |
There was a problem hiding this comment.
Why are we using the state here ? I think we want to deprecate this.
| if r.amount_paid > Amount::ZERO || r.amount_issued > Amount::ZERO { | |
| Some(quote_state_from_amounts(r.amount_paid, r.amount_issued)) | |
| } else { | |
| Some(r.state) | |
| } | |
| Some(quote_state_from_amounts(r.amount_paid, r.amount_issued)) |
There was a problem hiding this comment.
The bolt11 portion highlighted in the comments we need for backwards compatibility with mints that have not updated. We could move this logic of computing the amount_paid and amount_issued to the deserlizer and that would remove some of this logic. But I don't love computing fields in the serialize/deserialized but maybe for this it makes sense?
| if amount_paid == Amount::ZERO && amount_issued == Amount::ZERO { | ||
| return QuoteState::Unpaid; | ||
| } | ||
|
|
There was a problem hiding this comment.
| if amount_paid == Amount::ZERO { | |
| return QuoteState::Unpaid; | |
| } | |
| if amount_issued == Amount::ZERO { | |
| return QuoteState::Paid; | |
| } | |
There was a problem hiding this comment.
This is not a state that should happen but I cleaned it up in a830f779.
Implement the mint quote accounting changes from cashubtc/nuts#377 by exposing amount_paid, amount_issued, and updated_at on mint quote responses. Keep the deprecated state field only for BOLT11 compatibility while deriving local quote state from the canonical counters for all mint methods. Persist updated_at in wallet quote storage so stale responses cannot move amount_paid or amount_issued backwards.
Add the Supabase mint_quote.updated_at migration and require schema version 8. Keep imported unpaid NpubCash quotes at updated_at 0 so legacy BOLT11 status responses can still advance them, and suppress stale websocket notifications after monotonic quote accounting rejects an update.
d5257c1 to
841b53c
Compare
Implement the mint quote accounting changes from cashubtc/nuts#377 by exposing amount_paid, amount_issued, and updated_at on mint quote responses.
Keep the deprecated state field only for BOLT11 compatibility while deriving local quote state from the canonical counters for all mint methods. Persist updated_at in wallet quote storage so stale responses cannot move amount_paid or amount_issued backwards.
Description
Notes to the reviewers
Suggested CHANGELOG Updates
CHANGED
ADDED
REMOVED
FIXED
Checklist
just quick-checkbefore committingcrates/cdk-ffi)