Skip to content

Fix/dividends and docs issues - #323

Merged
valoryyaa-byte merged 5 commits into
RWA-ToolKit:mainfrom
Valreb001:fix/dividends-and-docs-issues
Aug 31, 2026
Merged

Fix/dividends and docs issues#323
valoryyaa-byte merged 5 commits into
RWA-ToolKit:mainfrom
Valreb001:fix/dividends-and-docs-issues

Conversation

@Valreb001

Copy link
Copy Markdown
Contributor

Closes #303
Closes #304
Closes #305
Closes #310

SUMMARY

  1. feat(api): add GET /assets/:id/dividends/:did and test non-numeric :did** —
    added dividends::get_one, which 404s on an unknown asset or distribution,
    plus a router-level test that a non-numeric :did (e.g.
    /assets/1/dividends/abc) returns 400, mirroring the existing :id coverage.
  2. feat(api,docs): nest data routes under /v1 and add docs/public/openapi.json** —
    moved all snapshot-backed routes under /v1, added an OpenAPI spec
    documenting them, updated the docs site's examples to match, and added a
    test asserting the spec's paths match the router's mounted routes.
  3. test(api): cover did=0 and did=u64::MAX for dividends::get_one** —
    added boundary tests so malformed or malicious distribution ids 404 cleanly
    at both ends of the u64 range, matching existing asset-id boundary coverage.
  4. docs(api): clarify total_records vs compliance status field counts** —
    documented that total_records counts every allowlisted address while
    approved/suspended/rejected/pending only count addresses whose KYC
    record was read successfully that cycle, so the two should not be assumed
    to sum to the same total.

Valreb001 and others added 4 commits August 30, 2026 12:22
dividends::list took Path<u64> for the asset id only, so there was no
way to fetch a single distribution and nothing exercised a malformed
distribution-id path segment the way assets.rs covers a malformed
asset id.

Adds dividends::get_one(Path<(u64, u64)>), which 404s when the asset
or the distribution is unknown, and mounts it at
GET /assets/:id/dividends/:did. A non-numeric :did (e.g.
/assets/1/dividends/abc) is rejected with 400 by axum's path
extractor before the handler runs, mirroring the existing :id
behavior; adds a router-level test for that plus the two 404 paths.

Also restores the metrics/metrics-exporter-prometheus dependency and
imports in Cargo.toml, main.rs and indexer/mod.rs, dropped by a bad
merge conflict resolution in 59c9fdd — the crate referenced
PrometheusHandle/PrometheusBuilder without them, so it (and any test
target) could not compile. Adds tower/http-body-util dev-dependencies
and a routes::test_support helper for building a router-testable
AppState without a live Soroban RPC or the global Prometheus
recorder.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKebYLnJ68V8moDpmN8bfa
…i.json

The router mounted all data routes unprefixed (/stats, /assets, ...)
while nothing versioned the API, so there was no way to evolve the
route shape without breaking every existing consumer in place.

Nests all snapshot-backed routes under /v1 (GET / , /health and
/metrics stay unversioned), and adds docs/public/openapi.json
documenting the /v1 paths, request/response schemas, and errors, so a
generated client (RWA-ToolKit#262) matches the real routes. Updates every curl
example and <ApiEndpoint> path across the docs site (getting-started,
integration guide, and the assets/holders/compliance/dividends/
overview API pages) to the /v1 prefix, and documents the new
GET /v1/assets/:id/dividends/:did endpoint.

Router paths, the root index's endpoint list, and the OpenAPI spec now
share one list (DATA_ROUTE_PATHS in routes/mod.rs) as their source of
truth. Adds a test asserting the spec's "paths" keys equal that list
(converted to /v1/{id}-style) and that every documented path resolves
to a live handler on the router, to prevent this drift from
recurring.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKebYLnJ68V8moDpmN8bfa
Existing coverage for GET /assets/:id/dividends/:did only exercised an
unknown distribution id and an unknown asset id in the middle of the
range. Distribution ids come from on-chain state, so a malicious or
malformed id should 404 cleanly rather than panic or behave
unexpectedly at the u64 boundaries — the same guarantee already
required for asset ids (RWA-ToolKit#194/RWA-ToolKit#210).

Adds boundary tests for did=0 and did=u64::MAX against both a known
asset (exercising the "asset found, distribution not found" branch)
and an unknown asset (exercising the "asset not found" branch first).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKebYLnJ68V8moDpmN8bfa
The compliance summary docs listed total_records and the status
fields (approved/suspended/rejected/pending) without noting they can
diverge: total_records counts every allowlisted address, but the
indexer only increments a status field when that address's KYC
record is successfully read and parsed in the current cycle
(api/src/indexer/mod.rs: total_records increments unconditionally per
address, the status match only runs inside the record read's Ok/Some
branch). A reader could otherwise assume the four status counts sum
to total_records and treat a gap as a bug.

Adds a callout mirroring the existing approved-vs-on-chain-is_allowed
clarification (RWA-ToolKit#114) so consumers don't build that assumption in.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TKebYLnJ68V8moDpmN8bfa
@drips-wave

drips-wave Bot commented Aug 30, 2026

Copy link
Copy Markdown

@Valreb001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@valoryyaa-byte
valoryyaa-byte merged commit b1ebbfd into RWA-ToolKit:main Aug 31, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment