Skip to content

feat(frontend): implement API client layer for Axum backend with retry, timeout, and signature auth (#801)#877

Open
D-Lord-15 wants to merge 1 commit into
Fracverse:masterfrom
D-Lord-15:Backend-REST
Open

feat(frontend): implement API client layer for Axum backend with retry, timeout, and signature auth (#801)#877
D-Lord-15 wants to merge 1 commit into
Fracverse:masterfrom
D-Lord-15:Backend-REST

Conversation

@D-Lord-15

Copy link
Copy Markdown

Summary

Closes #801

Implements the frontend API client layer to communicate with the Axum backend for inheritance plan management.

Changes

New Files

  • frontend/app/lib/api/inheritance.ts — InheritanceAPI client with handlers for all 5 inheritance endpoints:
    • createPlan() — POST /api/plans (signature auth)
    • getPlans() — GET /api/plans (public, with owner/beneficiary filters)
    • pingPlan() — POST /api/plans/ping (signature auth)
    • triggerPayout() — POST /api/plans/payout (signature auth)
    • getPayoutStatus() — GET /api/anchor/payout-status (public, paginated)
  • frontend/tests/api/inheritance.test.ts — 18 unit tests covering success, validation errors, and auth failures

Enhanced Files

  • frontend/app/lib/api/client.ts — Enhanced ApiClient with:
    • Configurable request timeout via Promise.race (30s default)
    • Exponential backoff retry with full jitter (3 retries, 408/429/5xx)
    • Ed25519 signature auth (X-Public-Key + X-Signature headers)
    • Per-request RequestConfig overrides (timeout, retry, headers)
    • Clean TypeScript interfaces: RetryConfig, RequestConfig, SignatureAuth
  • frontend/app/lib/api/index.ts — Exports new types and InheritanceAPI singleton
  • frontend/tests/mocks/handlers.ts — MSW handlers for /api/plans and /api/anchor/payout-status with validation logic and pagination

Architecture Decisions

  • Timeout: Promise.race-based timeout avoids jsdom/MSW AbortSignal class incompatibility in test environments
  • Retry: Exponential backoff with full jitter, configurable per-request
  • Auth: Dual auth — JWT Bearer for admin, ed25519 signature for Stellar wallet users (X-Public-Key + X-Signature)
  • DTOs: Clean TypeScript interfaces mapping 1:1 to backend Rust response types

Testing

npx vitest run tests/api/inheritance.test.ts
# 18/18 tests passing

Coverage includes:

  • Plan creation with validation (400 errors, allocation_bps sum check, empty beneficiaries)
  • Plan fetching with owner/beneficiary filters
  • Plan pinging with auth (401 on invalid signature, 404 on missing plan)
  • Payout triggers
  • Payout status with pagination and beneficiary filtering
  • Server error scenarios (500)

Type Check

npx tsc --noEmit  # passes clean

…nd communication (Fracverse#801)

- Add InheritanceAPI client with handlers for createPlan, getPlans,
  pingPlan, triggerPayout, and getPayoutStatus endpoints
- Enhance ApiClient with configurable timeout via Promise.race, exponential
  backoff retry policies, and ed25519 signature auth support (X-Public-Key +
  X-Signature headers)
- Add clean TypeScript DTOs mapping to backend response types
- Add MSW mock handlers for /api/plans and /api/anchor/payout-status
- Add 18 unit tests covering success, validation error, and auth failure
  scenarios
- Fix jsdom/MSW AbortSignal compatibility by replacing AbortController
  with Promise.race for timeout handling
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@D-Lord-15 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

@ONEONUORA

Copy link
Copy Markdown
Contributor

@D-Lord-15
Pls make implementation to pass CI checks

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.

[Frontend] Integrate Backend REST API Client

2 participants