Skip to content

Feat/281 query paginated user participation history - #321

Merged
josephchimebuka merged 4 commits into
TevaLabs:mainfrom
owohdora-stack:feat/281-query-paginated-user-participation-history
Aug 8, 2026
Merged

Feat/281 query paginated user participation history#321
josephchimebuka merged 4 commits into
TevaLabs:mainfrom
owohdora-stack:feat/281-query-paginated-user-participation-history

Conversation

@owohdora-stack

@owohdora-stack owohdora-stack commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #281
Implements paginated archived participation history for user profiles (Issue #281). Users can now query which archived rounds they participated in, with standard offset/limit pagination.

Changes

New on-chain storage

  • DataKey::UserArchivedRoundIds(Address)Vec<u64> — per-user index of archived round IDs they participated in

Modified internal function

  • _archive_round — now accepts the full &Vec<Address> participant list instead of just a count, and writes each participant's round ID to their UserArchivedRoundIds index

New public query

  • get_user_archive_history(env, user, offset, limit)Vec<ArchivedRoundSummary>
    • Reads the user's per-user index, applies offset/limit pagination, resolves each round ID to its ArchivedRoundSummary
    • Stale entries (rounds pruned by FIFO retention) are silently skipped
    • offset past the end → empty page
    • limit == 0 → empty page
    • limit capped at MAX_PAGE_SIZE (100)
    • Ordering is newest-first (descending round ID)

Tests (archive_participation.rs)

Test Group
test_archived_participation_after_resolve ✅ Recorded after resolve
test_archived_participation_after_cancel ✅ Recorded after cancel
test_archived_participation_after_fallback_refund ✅ Recorded after fallback
test_archived_participation_no_history ✅ Empty for non-participant
test_archived_participation_non_participant_after_round ✅ Isolation
test_archived_participation_newest_first ✅ Stable ordering
test_archived_participation_page_respects_offset_and_limit ✅ Offset/limit
test_archived_participation_full_page_matches_all ✅ Full page
test_archived_participation_offset_past_end_is_empty ✅ Bounds validated
test_archived_participation_zero_limit_is_empty ✅ Zero limit
test_archived_participation_limit_is_capped ✅ Capped at MAX_PAGE_SIZE
test_archived_participation_multi_user_isolation ✅ Per-user isolation
test_archived_participation_precision_mode ✅ Precision mode

TypeScript bindings

  • Added get_user_archive_history method to Client interface and fromJSON marshalling map

Build fixes

  • Removed invalid [dev-dependencies] section from root virtual manifest Cargo.toml
  • Pinned soroban-sdk to exact =23.0.1 to prevent accidental upgrades to breaking SDK versions

Retention alignment

The UserArchivedRoundIds index is written alongside the ArchivedRoundSummary during _archive_round. When FIFO pruning evicts old archived rounds, stale entries in the per-user index are silently filtered at query time (the query checks ArchivedRound existence and skips None entries). This avoids expensive reverse-pruning of user indices while maintaining correctness.

Notes

  • The contract spec array in bindings/src/index.ts should be regenerated once the contract compiles cleanly: run soroban contract bindings typescript against the compiled WASM
  • The pre-existing #[contracterror] variant limit (53 > 50) and symbol_short! length limit (≥10 chars) are addressed in a separate fix ticket as they affect the entire codebase

Dubemtopsite and others added 4 commits July 29, 2026 09:26
- Add DataKey::UserArchivedRoundIds(Address) to track per-user archived round participation
- Modify _archive_round to accept participant list and write per-user round ID indices
- Add get_user_archive_history(env, user, offset, limit) query with pagination
- Add comprehensive tests: resolve, cancel, fallback, precision mode, pagination ordering,
  offset/limit, bounds, multi-user isolation, empty history
- Update TypeScript bindings with get_user_archive_history method
- Fix root Cargo.toml (remove invalid dev-dependencies from virtual manifest, pin SDK)
…ted-user-participation-history

# Conflicts resolved:
#   Cargo.toml - kept SDK pin =23.0.1 + workspace deps
#   contracts/src/contract.rs - kept delegation pattern for
#     get_updown_positions_page to queries.rs; kept my
#     get_user_archive_history as delegation to queries.rs
#   contracts/src/types.rs - accepted incoming refactored DataKey
#     with additional variants; added UserArchivedRoundIds(Address)
#
# Additional changes to make feature work with refactored modules:
#   contracts/src/queries.rs - added get_user_archive_history fn
#   contracts/src/settlement.rs - changed _archive_round signature
#     from participant_count: u32 to participants: &[Address] and
#     added UserArchivedRoundIds recording inside
@owohdora-stack

Copy link
Copy Markdown
Contributor Author

@precious @Depo-dev Conflicts has been fixed

@josephchimebuka
josephchimebuka merged commit 1c82c3e into TevaLabs:main Aug 8, 2026
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.

Query: paginated user participation history

3 participants