Skip to content

feat(onchain): add get_distributor_list accessor for indexers (#232)#417

Open
Moonwalker-rgb wants to merge 4 commits into
ChainForgee:mainfrom
Moonwalker-rgb:feat/onchain/232-distributor-list-accessor
Open

feat(onchain): add get_distributor_list accessor for indexers (#232)#417
Moonwalker-rgb wants to merge 4 commits into
ChainForgee:mainfrom
Moonwalker-rgb:feat/onchain/232-distributor-list-accessor

Conversation

@Moonwalker-rgb

Copy link
Copy Markdown
Contributor

Summary

Closes #232

Adds a public view function get_distributor_list to the AidEscrow contract that returns a sorted Vec<Address> of currently registered distributor addresses.

Problem

Distributor list is stored in Map<Address, bool> but there is no view function to retrieve it. Off-chain indexers and dashboards must maintain a parallel list, which can grow stale and reduce audit accuracy.

Solution

  • New view function get_distributor_list(env) -> Vec<Address> reads from KEY_DISTRIBUTORS storage and returns keys sorted for deterministic ordering
  • No auth required (read-only view function, matching existing patterns like get_admin, get_config)

Changes

File Change
src/lib.rs +16 lines — added get_distributor_list function after remove_distributor
tests/aid_escrow_tests.rs +95 lines — 6 test cases in new get_distributor_list module
README.md +1 line — documented in Admin & Config table
docs/onchain/api.md New file — high-level API reference

Test Coverage

  • ✅ Empty after init with no add_distributor calls
  • ✅ Returns single distributor after add
  • ✅ Empty after add then remove
  • ✅ Sorted list after 3 adds (verifies ordering and completeness)
  • ✅ Reflects removal correctly
  • ✅ Duplicate add is idempotent (Map key dedup)

Acceptance Criteria (from #232)

  • ✅ Returns empty Vec after init with no add_distributor calls
  • ✅ Returns sorted list after 3 add_distributor calls

…orgee#232)

Add a public view function get_distributor_list that returns a sorted
Vec<Address> of currently registered distributor addresses. This provides
a source-of-truth accessor for off-chain indexers and audit dashboards,
eliminating the need to maintain parallel distributor lists.

Changes:
- src/lib.rs: add get_distributor_list view function
- tests: 6 test cases covering empty, single, multiple, removal,
  duplicate idempotency, and sorted ordering
- README.md: document the new function
- docs/onchain/api.md: new high-level API reference

Closes ChainForgee#232
soroban_sdk::Vec does not provide a sort() method. Replace with a manual
bubble sort which is acceptable for the small expected distributor list size.
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.

get_distributor_list accessor for indexers

1 participant