feat: add campaign comment system via off-chain attestation (#542) - #728
feat: add campaign comment system via off-chain attestation (#542)#728bbkenny wants to merge 4 commits into
Conversation
|
@bbkenny Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
davidmaronio
left a comment
There was a problem hiding this comment.
the design direction here is right: hash-only comments emitted as events with a per-campaign counter and a tombstone key for moderation keeps on-chain storage tiny, and the creator-or-admin removal gate plus double-remove protection is sensible. but the branch does not compile, and a few things look like they were never run locally:
- src/errors.rs:148-155 - the new variants
InvalidCommentId = 46andCommentAlreadyRemoved = 47were pasted inside thename()match arm block ofimpl Error, not into theErrorenum itself. this is a syntax error and is why CI is red. move the variants into the enum and add matching arms toname(). - src/tests/test_comments.rs:5 - the tests use
ProofOfHeartContractClientand asetup_env_with_active_campaign(100)helper returning a 5-tuple. please double check those against src/tests/helpers.rs on this branch; other test files in the repo use a different setup shape, and since CI never got past the errors.rs syntax error these tests have never actually compiled or run. please runcargo test --features testutilslocally and paste the output. - src/campaigns/comments.rs:add_campaign_comment - anyone can spam comments for free apart from tx fees, and each one bumps a persistent counter. that's fine, but consider requiring the campaign to be active (you only check existence) so closed or cancelled campaigns don't keep accepting comments.
- same file, remove flow - removal only writes a tombstone and emits an event, which matches the off-chain attestation model, but the
CommentRemovedtombstone grows one persistent entry per removal forever. acceptable, just worth a comment noting the trade-off. - this pr also carries the unrelated test_campaign_update.rs 2-tuple to 4-tuple event assertion change and the trailing-newline touches to the orphaned
ProofOfHeartContractblocks, same as your #724/#725/#726. drop the duplicates and let one pr own that cleanup, then rebase the others.
gate: branch is DIRTY and CI is red, so fix the errors.rs compile break, verify the tests actually run, resolve conflicts, and rebase on main.
Closes #542
Summary of Changes
Added a campaign comment system using off-chain attestation to keep storage costs low.
add_campaign_comment: Allows users to post a comment to an active campaign. The function takes an off-chaincomment_hash(which could be a CID or text hash depending on the frontend) and emits an eventcampaign_comment_addedwithout storing the full string on-chain.remove_campaign_comment: Gives moderation tools to campaign creators and admins. This flags a specificcomment_idas removed using a newCommentRemoveddata key and emits acampaign_comment_removedevent, signaling the indexer or frontend to hide it.src/campaigns/comments.rsfor the logic and updatederrors.rsto track invalid or previously removed comment targets cleanly.