Skip to content

feat: add expiration to posts in contract#1399

Open
bochaco wants to merge 4 commits into
midnightntwrk:mainfrom
bochaco:capstone/bochaco
Open

feat: add expiration to posts in contract#1399
bochaco wants to merge 4 commits into
midnightntwrk:mainfrom
bochaco:capstone/bochaco

Conversation

@bochaco

@bochaco bochaco commented Apr 21, 2026

Copy link
Copy Markdown

Add post expiration to the bulletin board

Posts now expire after 3 minutes:

  • Once a post has expired, anyone can remove it — not just the original poster.
  • Before expiration, only the owner can take it down.

Changes made:

  • Contract:

    • Added a postTimestamp ledger field to track when each post expires.
    • post now takes a nowSecs timestamp argument and validates it is more recent than the previous post (prevents replay).
    • takeDown now allows removal if the caller is the owner or the block time has passed the expiration timestamp — whichever comes first.
  • API

    • post() automatically passes the current time (epoch seconds) to the contract, so callers don't need to handle it.
  • Tests

    • Added setBlockTime to the simulator to allow tests to control the on-chain clock.
    • New test cases:
      • A non-owner cannot remove a post before it expires.
      • The original poster can still take down their post early.
      • Anyone can remove a post after it expires.
      • The sequence counter increments correctly through both the normal and expiration-based take-down paths.
  • CLI

    • The "display derived state" option now shows two additional lines when a board is occupied:
      • Post age — how long ago the message was posted.
      • Expires in / Expired X ago — how much time is left, or how long ago it expired (with a note that the post can be removed by anyone once expired).
  • UI

    • The post card's action bar now shows the expiration date/time in the user's local timezone (e.g. "Expires 4/21/26, 4:30 PM") on the right side when a board is occupied.
    • When a non-owned post expires, it automatically enables the button to take down the post.

@bochaco bochaco marked this pull request as ready for review April 21, 2026 19:57
@bochaco bochaco requested review from a team as code owners April 21, 2026 19:57
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.

1 participant