Skip to content

fix(chequebook): handle nil cumulative payout in cheque processing - #5656

Merged
akrem-chabchoub merged 4 commits into
masterfrom
fix/chequebook
Oct 13, 2026
Merged

akrem-chabchoub merged 4 commits into
masterfrom
fix/chequebook

Conversation

@akrem-chabchoub

Copy link
Copy Markdown
Contributor

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have added or updated fuzz targets for any code handling untrusted input.
  • I have filled out the description and linked the related issues.

Description

A stored cheque with a blank cumulative payout is now rejected as a broken cheque, so the settlements list does not crash on it and the next issued cheque does not start again from zero. The same check applies to cheques we sent and cheques we received.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

Screenshots (if appropriate):

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
  • I possess the technical expertise to responsibly review the code generated in this PR.

@akrem-chabchoub akrem-chabchoub changed the title Fix/chequebook fix(chequebook): handle nil cumulative payout in cheque processing Oct 9, 2026
@akrem-chabchoub
akrem-chabchoub marked this pull request as ready for review October 9, 2026 08:38
}

// LastCheque returns the last cheque we issued for the beneficiary.
func (s *service) LastCheque(beneficiary common.Address) (*SignedCheque, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i find it dangerously confusing that this method is named the same like the chequestore one that you changed, since they are semantically different and use different keys

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, they are two different stores behind the same name.
Since the naming already exists on master I'll open a follow-up that do the update, wdyt ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok

@acud

acud commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

btw @akrem-chabchoub, i still think that the better way to handle this would be to actually implement the marshal/unmarshal JSON interface on the cheque types and while you would just call the normal json marshal/unmarshal methods, you could just do the validation inside the marshaling code, which i find to be much more in place rather than scattering checks everywhere. this should already be rejected on unmarshal from my perspective, and seals the deal with any future change - you solve things at the root this way.

@akrem-chabchoub
akrem-chabchoub merged commit 78a84db into master Oct 13, 2026
17 checks passed
@akrem-chabchoub
akrem-chabchoub deleted the fix/chequebook branch October 13, 2026 11:45
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.

4 participants