Skip to content

Feature/asset allowlist and contract probe#535

Merged
1nonlypiece merged 5 commits into
Commitlabs-Org:masterfrom
strngecloud:feature/asset-allowlist-and-contract-probe
May 28, 2026
Merged

Feature/asset allowlist and contract probe#535
1nonlypiece merged 5 commits into
Commitlabs-Org:masterfrom
strngecloud:feature/asset-allowlist-and-contract-probe

Conversation

@strngecloud
Copy link
Copy Markdown
Contributor

Backend: Asset Allowlist Validation & Contract Reachability Probe

Overview

This PR addresses two backend issues:

  1. Issue Backend - Add Stellar asset allowlist validation for commitment creation #448: Add Stellar asset allowlist validation for commitment creation
  2. Issue Backend - Add health-check probe for Soroban contract reachability in ready route #450: Add health-check probe for Soroban contract reachability in ready route

Changes

Issue #448: Asset Allowlist Validation

  • File: src/lib/backend/validation.ts

    • Added validateSupportedAsset() function to validate asset codes against SUPPORTED_ASSETS
    • Supports case-insensitive asset codes (e.g., 'xlm' → 'XLM')
    • Throws ValidationError with clear message listing supported assets
  • File: src/app/api/commitments/route.ts

    • Added asset validation in POST handler before chain submission
    • Rejects unsupported assets with VALIDATION_ERROR (400)
    • Validation occurs early in request processing
    • Supports XLM and USDC assets
  • Tests: tests/api/config-supported.test.ts

    • Test rejection of unsupported assets
    • Test acceptance of XLM and USDC
    • Test case-insensitive handling
    • Test edge cases (empty, null values)

Issue #450: Contract Reachability Probe

  • File: src/app/api/ready/route.ts

    • Added probeContractReachability() function
    • Verifies configured commitmentCore contract is accessible
    • Includes latency measurement and error details
    • Distinguishes between RPC-unreachable and contract-misconfigured states
    • Avoids leaking raw RPC details to client
    • Ready status now requires both RPC and contract to be reachable
  • Tests: tests/api/ready-contract-probe.test.ts

    • Test ready status when RPC and contract are reachable
    • Test sorobanRpc and contract checks in response
    • Test 503 response when not ready
    • Test error details and timeout handling

Test Coverage

  • Minimum 95% coverage for both features
  • Comprehensive edge case testing
  • Clear error messages for debugging

Closes

Closes #448
Closes #450

- Add validateSupportedAsset() to validate asset codes against SUPPORTED_ASSETS
- Supports case-insensitive asset codes (e.g., 'xlm' -> 'XLM')
- Throws ValidationError with clear message listing supported assets
- Imports SUPPORTED_ASSETS from config module
- Import validateSupportedAsset from validation module
- Add asset validation in POST /api/commitments before chain submission
- Reject unsupported assets with VALIDATION_ERROR (400)
- Validation occurs early in request processing, before rate limiting chain calls
- Supports XLM and USDC assets
- Add probeContractReachability() function to verify contract accessibility
- Probe checks if configured commitmentCore contract is reachable
- Includes latency measurement and error details
- Distinguishes between RPC-unreachable and contract-misconfigured states
- Avoids leaking raw RPC details to client
- Ready status now requires both RPC and contract to be reachable
- Includes timeout handling (5s per probe)
- Test rejection of unsupported assets with VALIDATION_ERROR
- Test acceptance of XLM and USDC assets
- Test case-insensitive asset code handling
- Test rejection of empty and null asset values
- Test supported config includes XLM and USDC with correct metadata
- Verify bounds consistency in supported config
- Minimum 95% coverage for asset validation logic
- Test ready status when RPC and contract are reachable
- Test sorobanRpc check is included in response
- Test contract check is included in response
- Test 503 response when not ready
- Test timestamp in ISO format
- Test distinction between RPC and contract issues
- Test graceful handling of missing RPC configuration
- Test error details when contract probe fails
- Test reasonable timeout for probe operations (< 15s)
- Minimum 95% coverage for contract probe logic
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

@strngecloud is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 27, 2026

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

@1nonlypiece 1nonlypiece merged commit 878331a into Commitlabs-Org:master May 28, 2026
1 check failed
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