Skip to content

[#438] Backend: Replace simulated Soroban RPC stub with real stellar-sdk integration in vaultEndpoints#471

Open
broda-spendy wants to merge 1 commit into
Junirezz:mainfrom
broda-spendy:fix/438-backend-replace-simulated-soroban-rpc-stub-with-real-stellar-sdk-integration-in-vaultendpoints
Open

[#438] Backend: Replace simulated Soroban RPC stub with real stellar-sdk integration in vaultEndpoints#471
broda-spendy wants to merge 1 commit into
Junirezz:mainfrom
broda-spendy:fix/438-backend-replace-simulated-soroban-rpc-stub-with-real-stellar-sdk-integration-in-vaultendpoints

Conversation

@broda-spendy
Copy link
Copy Markdown

Closes #438

Changes

This PR replaces the simulated Soroban RPC stub with real stellar-sdk integration for vault operations (deposits and withdrawals).

Implementation Details

  1. Added @stellar/stellar-sdk dependency - Installed the official Stellar SDK for contract invocation
  2. Created sorobanClient.ts module - Encapsulates all Soroban RPC logic:
    • Keypair management from STELLAR_SECRET_KEY env var
    • Contract instance creation using vault contract ID
    • Transaction building, simulation, and submission
    • Comprehensive error handling with structured error types
  3. Updated vaultEndpoints.ts - Integrated real contract calls:
    • submitSorobanTx now calls submitVaultOperation from sorobanClient
    • Added SorobanSimulationError handling for 502 Bad Gateway responses
    • Maintained circuit breaker pattern around RPC calls
    • Kept trace span instrumentation intact
  4. Environment configuration - Updated .env.example with:
    • STELLAR_SECRET_KEY (required for signing transactions)
    • VAULT_CONTRACT_ID (contract address)
    • STELLAR_NETWORK_PASSPHRASE (already present)
  5. Test mocking - Added jest mock for sorobanClient in api.test.ts to enable tests to run without live Stellar network

Acceptance Criteria Met

✅ Deposit calls submit real transactions to Stellar Testnet with on-chain hash
✅ Error handling returns readable 502 responses for simulation failures
✅ Circuit breaker pattern maintained around RPC calls
✅ Trace spans preserved for observability
✅ Signing keys loaded securely from environment (never hard-coded)

Testing

Tests use mock transactions to avoid requiring live Stellar network connectivity. In production, real transactions are submitted to the configured Testnet RPC endpoint.

…ezz#438)

- Install @stellar/stellar-sdk package
- Create sorobanClient.ts with real contract invocation logic
- Replace submitSorobanTx stub with real Soroban transaction submission
- Add proper error handling for Soroban simulation failures (502 responses)
- Load signing keypair from STELLAR_SECRET_KEY environment variable
- Maintain circuit breaker and trace span wrappers around RPC calls
- Add comprehensive logging for transaction lifecycle

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Backend: Replace simulated Soroban RPC stub with real stellar-sdk integration in vaultEndpoints

1 participant