rework refund approvals#47
Merged
MaryammAli merged 3 commits intoJun 21, 2026
Merged
Conversation
MaryammAli
approved these changes
Jun 21, 2026
MaryammAli
left a comment
Contributor
There was a problem hiding this comment.
LGTM
thanks for ur contribution @Noble-Devbase
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 #3
📌 Description
Critical Operational Gap - The refund approval process currently updates the database status to
approvedbut does not execute or track the actual on-chain contract refund operation. This creates a dangerous disconnect where operators believe refunds have been processed while escrow funds remain locked on-chain. Users may be told refunds are complete when they haven't been executed, leading to trust and compliance issues.🧩 Changes
1. Refund State Machine (
refunds.types.ts,refunds.service.ts)Introduced explicit states with clear transitions:
State Transitions:
2. On-Chain Execution (
refunds.service.ts,soroban-rpc.service.ts)approve()to trigger contract refund function via Soroban RPC3. Database Schema (
supabase/migrations/*refund*)Added columns for tracking on-chain operations:
4. Idempotency & Retry Logic
refund_{userId}_{timestamp}_{nonce}5. API Enhancements (
refunds.controller.ts)Response now includes:
{ "id": "ref_123", "state": "submitted", "transactionHash": "0xabc...", "contractId": "C...", "network": "mainnet", "failureReason": null, "retryable": true, "retryCount": 1, "updatedAt": "2024-01-01T00:00:00Z" }6. Background Job Processor
process_refund_submission7. Error Handling (
common/soroban-errors/*)Enhanced error categorization:
SorobanTimeoutError→ mark as FAILED, retry laterSorobanInsufficientBalanceError→ FAILED (terminal)SorobanInvalidContractError→ FAILED (terminal)SorobanNetworkError→ retry with backoff🔍 Why This Matters
📁 Files Changed