Skip to content

closea #92 feat: add tri-state anchor_status read for anchor lifecycle tracking#220

Open
emmyoat wants to merge 3 commits into
AnchorNet-Org:mainfrom
emmyoat:feat/anchor-status
Open

closea #92 feat: add tri-state anchor_status read for anchor lifecycle tracking#220
emmyoat wants to merge 3 commits into
AnchorNet-Org:mainfrom
emmyoat:feat/anchor-status

Conversation

@emmyoat

@emmyoat emmyoat commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Adds an anchor_status(env, anchor) -> AnchorStatus read function to distinguish between addresses that have never been registered, addresses that are currently active, and addresses that were previously registered and later deregistered.

is_anchor returns a single boolean and cannot distinguish between "never registered" and "previously registered then deregistered". This tri-state distinction allows off-chain services (frontend detail page and backend sync logic) to query anchor registration lifecycle status directly from the contract.

Key Changes

  • src/types.rs: Added AnchorStatus enum with variants NeverRegistered, Active, and Deregistered.
  • src/storage.rs: Implemented anchor_status reader that checks persistent storage:
    • None $\rightarrow$ AnchorStatus::NeverRegistered
    • Some(true) $\rightarrow$ AnchorStatus::Active (with TTL bump)
    • Some(false) $\rightarrow$ AnchorStatus::Deregistered (with TTL bump)
  • src/lib.rs: Re-exported AnchorStatus and exposed AnchornetContract::anchor_status.
  • src/test.rs: Added test_anchor_status_lifecycle and test_anchor_status_read_bumps_ttl.
  • README.md: Updated contract interface table with anchor_status(anchor).

Backward Compatibility

is_anchor and all existing contract callers remain completely unaffected.

Checklist

  • Tri-state status distinguishing all three states correctly implemented.
  • Existing is_anchor behavior and callers unaffected.
  • Full test coverage added in src/test.rs.
  • Documented in README.md.

@emmyoat
emmyoat force-pushed the feat/anchor-status branch from 77004cb to d7ce5f2 Compare July 22, 2026 23:52
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