fix: wire the basic swap-lookup read path (GET /v1/swap/{swap_id}) to the RPC layer - #948
Merged
fejilaup-cloud merged 2 commits intoAug 28, 2026
Conversation
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]>
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #845
Closes #846
Closes #847
Closes #848
Summary
get_swapinapi-server/src/handlers.rswas an unwired stub:GET /v1/swap/{swap_id}returned 404 on any cache miss and never consulted a data source (the// TODO: Call Soroban RPCline was never implemented). This PR wires the basic swap-lookup read path to the existingSorobanRpcClientabstraction — the same one the GraphQLswapresolver already uses — so a cache miss triggers an RPC read-through that backfills the cache and returns the record.Changes
api-server/src/handlers.rs—get_swapnow extractsState<Arc<dyn graphql::SorobanRpcClient>>; on cache miss it callsget_swap_record(swap_id), converts the result to the RESTSwapRecord, caches it (30s TTL), and returns 200. RPC miss/error returns 404 withno-store. AddedFrom<graphql::SwapRecord> for schemas::SwapRecord.api-server/src/main.rs—AppStategainsrpc_client: Arc<dyn graphql::SorobanRpcClient>(+FromRef), constructed in bothmain()andbuild_app(). Restored theAppStateconstruction inbuild_app()that had been dropped (.with_state(state)referenced an undefinedstate, so the crate did not compile). Extractedapp_with_rpc_client()so tests can inject a stub client.api-server/src/schemas.rs— addedDisputedto the RESTSwapStatus(already supported by the contract and the GraphQL layer).api-server/src/graphql.rs— addedip_registry_idto the RPC-layerSwapRecordso the REST-required field can flow through the trait.Testing
cargo testcould not be run here. The handler follows the existingState+#[utoipa::path]pattern already used byevents_handler. Please run:cargo test --manifest-path api-server/Cargo.tomlNotes
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_iphas the identical stub pattern and is a natural follow-up.