Skip to content

feat(claim): add read-only view - #447

Merged
mikewheeleer merged 2 commits into
StableRoute-Org:mainfrom
Jagadeeshftw:feature/claim-91-view
Jul 30, 2026
Merged

feat(claim): add read-only view#447
mikewheeleer merged 2 commits into
StableRoute-Org:mainfrom
Jagadeeshftw:feature/claim-91-view

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Closes #429

Summary

The issue asks for "a read-only view exposing the current claim state... a sane default before init... covered in tests." A view that satisfies this already exists in src/lib.rs: get_pending_admin_info(env: Env) -> PendingAdminInfo, returning:

pub struct PendingAdminInfo {
    pub pending: Option<Address>,
    pub eta: Option<u64>,
}

— an aggregated, single-call snapshot of the queued admin-transfer ("claim") state, defaulting to pending: None, eta: None when nothing is queued. Its own doc comment already describes it as "a consistent snapshot" of the two individual getters (get_pending_admin, get_pending_admin_eta).

The actual gap: this function had zero test coverage anywhere in the suite — grep confirms it was never called outside its own definition. This PR adds that missing coverage instead of introducing a duplicate/competing view, since one already exists and matches the issue's ask exactly.

Changes

Three new tests in mod test:

  • test_pending_admin_info_default_before_any_transfer — sane None/None default before any transfer is proposed.
  • test_pending_admin_info_reflects_queued_transfer — after propose_admin_transfer (with a timelock set), the aggregated view matches both individual getters (info.pending == get_pending_admin(), info.eta == get_pending_admin_eta()) and the expected values.
  • test_pending_admin_info_clears_after_accept — reverts to the default once the transfer completes, mirroring the individual-getter coverage in the existing test_admin_transfer_flow.

No production code changed.

Note on this repo's domain terminology

Same reinterpretation as #422/#432: "claim" maps onto the existing two-step admin-transfer flow, whose own accept_admin_transfer doc comment already calls it the step where "the pending admin claims the role."

Verification blocker (pre-existing, unrelated to this change)

Same pre-existing, unrelated compile break documented in #422 / PR #444 (90 errors from duplicate function definitions in impl StableRouteRouter, confirmed via git stash A/B rebuild on main) — cargo test cannot actually run these new tests. What I could verify:

  • cargo fmt -- --check: no new formatting diffs near the added lines.
  • Manual review: the three assertions were checked by hand against get_pending_admin_info's implementation (env.storage().instance().get(&DataKey::PendingAdmin) / env.storage().persistent().get(&DataKey::PendingAdminEta)) and against the existing, passing test_admin_transfer_flow/test_timelock_allows_accept_after_delay tests that exercise the same storage slots with the same timestamps/timelock values (e.g. propose at t=1_000 with timelock=100eta = Some(1_100), matching test_timelock_blocks_early_accept's already-passing assertion).

Flagging this so a maintainer can re-run cargo test and confirm these three pass once the pre-existing duplicate-definition issue is fixed.

@mikewheeleer
mikewheeleer merged commit f2094b9 into StableRoute-Org:main Jul 30, 2026
0 of 2 checks passed
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.

Add a read-only view exposing the current claim state

2 participants