Skip to content

feat: deposit transaction builder for wallet#100

Merged
greatest0fallt1me merged 8 commits intoCalloraOrg:mainfrom
precious-akpan:feature/deposit-tx-builder
Feb 26, 2026
Merged

feat: deposit transaction builder for wallet#100
greatest0fallt1me merged 8 commits intoCalloraOrg:mainfrom
precious-akpan:feature/deposit-tx-builder

Conversation

@precious-akpan
Copy link
Copy Markdown
Contributor

Description

Implements POST /api/vault/deposit/prepare endpoint that builds unsigned Stellar/Soroban transactions for USDC deposits.

Changes

  • ✅ Amount validator with 7-decimal USDC validation
  • ✅ Transaction builder service for creating unsigned Stellar transactions
  • ✅ Deposit controller with comprehensive validation and error handling
  • ✅ POST /api/vault/deposit/prepare endpoint with authentication
  • ✅ Complete API documentation

Key Features

  • Non-custodial: Backend never signs transactions or holds user keys
  • Validation: Strict amount format (7 decimals), network, and source account validation
  • Error handling: Comprehensive error responses for all failure scenarios
  • Documentation: Complete API docs with examples and usage guide

Testing

Tests have been written for:

  • Amount validator edge cases
  • Transaction builder functionality
  • Deposit controller integration

Note: Tests require npm install to complete due to network issues during development.

Resolves

Closes #40

Amount Format

USDC amounts must have exactly 7 decimal places:

  • ✅ Valid: "100.0000000"
  • ❌ Invalid: "100.00", "100"

Example Usage

// 1. Prepare transaction
const response = await fetch('/api/vault/deposit/prepare', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-user-id': userPublicKey
  },
  body: JSON.stringify({ amount_usdc: '100.0000000' })
});

const { xdr } = await response.json();

// 2. Sign with wallet
const signedXdr = await window.freighterApi.signTransaction(xdr);

// 3. Submit to network
const result = await server.submitTransaction(signedXdr);

@greatest0fallt1me greatest0fallt1me self-requested a review February 26, 2026 10:55
@greatest0fallt1me greatest0fallt1me merged commit 46052cc into CalloraOrg:main Feb 26, 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

Development

Successfully merging this pull request may close these issues.

Add Deposit Transaction Builder (Stellar XDR or Instructions)

2 participants