Skip to content

fix: wire the basic swap-lookup read path (GET /v1/swap/{swap_id}) to the RPC layer - #948

Merged
fejilaup-cloud merged 2 commits into
AtomicIP:mainfrom
petermuazu:fix/wire-swap-lookup-read-path
Aug 28, 2026
Merged

fix: wire the basic swap-lookup read path (GET /v1/swap/{swap_id}) to the RPC layer#948
fejilaup-cloud merged 2 commits into
AtomicIP:mainfrom
petermuazu:fix/wire-swap-lookup-read-path

Conversation

@petermuazu

@petermuazu petermuazu commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Closes #845
Closes #846
Closes #847
Closes #848

Summary

get_swap in api-server/src/handlers.rs was an unwired stub: GET /v1/swap/{swap_id} returned 404 on any cache miss and never consulted a data source (the // TODO: Call Soroban RPC line was never implemented). This PR wires the basic swap-lookup read path to the existing SorobanRpcClient abstraction — the same one the GraphQL swap resolver already uses — so a cache miss triggers an RPC read-through that backfills the cache and returns the record.

Changes

  • api-server/src/handlers.rsget_swap now extracts State<Arc<dyn graphql::SorobanRpcClient>>; on cache miss it calls get_swap_record(swap_id), converts the result to the REST SwapRecord, caches it (30s TTL), and returns 200. RPC miss/error returns 404 with no-store. Added From<graphql::SwapRecord> for schemas::SwapRecord.
  • api-server/src/main.rsAppState gains rpc_client: Arc<dyn graphql::SorobanRpcClient> (+ FromRef), constructed in both main() and build_app(). Restored the AppState construction in build_app() that had been dropped (.with_state(state) referenced an undefined state, so the crate did not compile). Extracted app_with_rpc_client() so tests can inject a stub client.
  • api-server/src/schemas.rs — added Disputed to the REST SwapStatus (already supported by the contract and the GraphQL layer).
  • api-server/src/graphql.rs — added ip_registry_id to the RPC-layer SwapRecord so the REST-required field can flow through the trait.
  • Tests — a stub RPC client plus coverage for: RPC read-through (200 + record body), cache backfill, and 404 on an unknown swap.

Testing

⚠️ No Rust toolchain was available in the authoring environment, so cargo test could not be run here. The handler follows the existing State + #[utoipa::path] pattern already used by events_handler. Please run:

cargo test --manifest-path api-server/Cargo.toml

Notes

  • Production still wires MockSorobanRpcClient (no real Soroban client exists yet), so unknown swaps return 404 until a real client lands — the missing wiring is what this PR restores.
  • get_ip has the identical stub pattern and is a natural follow-up.

get_swap (GET /v1/swap/{swap_id}) was an unwired stub: it returned 404 on
any cache miss and never consulted a data source. It now reads through to
the SorobanRpcClient on cache miss, backfills the cache, and returns the
record (or 404), mirroring how the GraphQL swap resolver is wired.

Also restores the AppState construction in build_app() that was dropped,
which left the crate uncompilable (undefined `state` in `.with_state`),
adds the Disputed status to the REST schema so the read path can represent
it, and adds ip_registry_id to the RPC-layer SwapRecord so the REST-required
field flows through the trait. Adds tests for the RPC read-through, cache
backfill, and 404 paths.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <[email protected]>
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@petermuazu 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

@fejilaup-cloud
fejilaup-cloud merged commit 1a14bf0 into AtomicIP:main Aug 28, 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

2 participants