feat: add credit payment support for STORE messages#130
Conversation
Add an optional `payment` field to `StoreContent`, matching the Python aleph-message implementation. Only `hold` and `credit` payment types are accepted; `superfluid` is rejected. The CLI defaults to credit payment for file uploads.
foxpatch-aleph
left a comment
There was a problem hiding this comment.
This PR correctly implements optional payment support for STORE messages, matching the Python aleph-message implementation. The code adds a payment field to StoreContent with proper serialization (skipped when None), validation that rejects superfluid while allowing hold and credit, and comprehensive tests covering all scenarios. The CLI defaults to credit payment for file uploads as intended. The changes are well-structured, backward-compatible, and follow existing code patterns.
crates/aleph-types/src/message/store.rs (line 104): The has_valid_payment() method name is clear and the logic correctly allows None, Credit, and Hold while rejecting Superfluid.
crates/heph/src/handlers/store.rs (line 25): Good placement of the payment validation check early in the handler, before any database operations.
crates/aleph-cli/src/commands/file.rs (line 62): Defaulting to Payment::credits() for CLI file uploads is appropriate and matches the PR description.
crates/aleph-types/src/message/store.rs (line 224): Test coverage is excellent — covers missing payment, credit payment, hold payment, superfluid rejection, round-trip serialization, and skip-when-none behavior.
Add an optional
paymentfield toStoreContent, matching the Python aleph-message implementation. Onlyholdandcreditpayment types are accepted;superfluidis rejected. The CLI defaults to credit payment for file uploads.