feat(minibf): add /accounts/{stake_address}/addresses/assets endpoint - #1126
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughMiniBF adds ChangesStake address assets
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Client
participant MiniBF
participant UTxOStore
participant AssetAggregator
Client->>MiniBF: GET /accounts/{stake_address}/addresses/assets
MiniBF->>UTxOStore: Load stake UTxOs and block metadata
MiniBF->>AssetAggregator: Aggregate assets by unit
AssetAggregator-->>MiniBF: Quantities and UTxO positions
MiniBF-->>Client: Ordered, paginated JSON assets
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds a Blockfrost-compatible MiniBF endpoint for listing the native assets held across all current UTxOs for a given stake address, integrating it into the existing facade/query patterns and expanding route-level coverage.
Changes:
- Added
GET /accounts/{stake_address}/addresses/assetsroute, including pagination and direction-dependent ordering based on UTxO positions. - Implemented asset aggregation logic over the account’s current UTxO set (excluding lovelace) with position tracking for ordering.
- Extended test support to allow synthetic fixture setup hooks and added route-level tests covering success/error/pagination/ordering semantics.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/content/apis/minibf.mdx | Documents the new /accounts/{stake_address}/addresses/assets endpoint in the MiniBF API list. |
| crates/minibf/src/test_support.rs | Adds a setup hook constructor to mutate synthetic fixture state before building the app. |
| crates/minibf/src/routes/accounts.rs | Implements the new account-assets endpoint and adds comprehensive route tests. |
| crates/minibf/src/mapping.rs | Adds asset aggregation helper that sums quantities per unit and tracks oldest/newest UTxO positions. |
| crates/minibf/src/lib.rs | Registers the new route on the MiniBF router. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
308d650 to
a99e953
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/minibf/src/routes/accounts.rs`:
- Around line 297-371: Bound work in by_stake_addresses_assets before decoding
all UTxOs and issuing block_meta_by_tx_hash calls, reusing the sibling
by_stake_addresses handler’s pagination.enforce_max_scan_limit-style protection.
Ensure the cap limits both UTxO scanning and the resulting unique transaction
fan-out while preserving the existing pagination ordering and results within the
allowed scan range.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 72b580db-2763-4533-ae9c-df4bcf9bbc18
📒 Files selected for processing (5)
crates/minibf/src/lib.rscrates/minibf/src/mapping.rscrates/minibf/src/routes/accounts.rscrates/minibf/src/test_support.rsdocs/content/apis/minibf.mdx
Aggregates native assets over the account's unspent UTxOs from the utxos_by_stake index, ordered by the chain position of the oldest (asc) or newest (desc) UTxO holding each asset with unit tie-breaks, matching the Blockfrost reference implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Ties resolve unit-ascending because entries leave the BTreeMap in unit order and sort_by is stable — state the invariant at the sort site. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
a99e953 to
c66271c
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Summary
Closes #1067 by adding the Blockfrost-compatible
GET /accounts/{stake_address}/addresses/assetsendpoint.count,page, andorder404for unknown accounts and existing MiniBF errors for invalid requests and storage failuresOrdering semantics
Because the directions use different keys,
descis not necessarily the reverse ofasc.asc: each asset’s oldest current UTxOdesc: each asset’s newest current UTxOThis reproduces the reference implementation (
blockfrost-backend-ryo,accounts_stake_address_addresses_assets.sql:MIN(txo.id) ASC/MAX(txo.id) DESC, tie-break(policy, name) ASC), with the tuple(slot, tx_index, output_index)standing in for db-sync's monotonetxo.id. The route testaccounts_by_stake_addresses_assets_uses_directional_orderingpins the exactascanddescsequences, including the non-reversal and the tie-break cases.Testing
TestApp::new_with_cfg_and_setup), pagination including past-the-end pages, invalid stake addresses, unknown accounts, storage failuresascanddesc, as are pagination windows and the400/404error responses.Known deviations
400(no JSON error body) — pre-existing behavior shared by all account endpoints, deliberately left untouched hereSummary by CodeRabbit
New Features
Documentation