Skip to content

Rework refund approvals into a state machine with on-chain settlement #3

@grantfox-oss

Description

@grantfox-oss

Refund approval updates database status to approved, but does not appear to execute or track the contract refund operation. This can create a dangerous gap where operators believe a refund was approved while escrow funds remain on-chain.

Affected areas: app/backend/src/refunds/refunds.service.ts, app/backend/src/refunds/refunds.controller.ts, app/backend/src/refunds/refunds.types.ts, app/backend/src/transactions/soroban-rpc.service.ts, app/backend/src/common/soroban-errors/*, app/backend/supabase/migrations/*refund*, refund tests/docs.

Implementation scope:

  • Introduce explicit states such as pending, approved, submitted, confirmed, failed, rejected.
  • Store on-chain transaction hash, contract ID, network, failure reason, and retry metadata.
  • Wire approval to a job or service that calls the contract refund function.
  • Make idempotency keys cover both database and on-chain submission paths.

Acceptance criteria:

  • Approved refunds eventually become confirmed or failed with a clear reason.
  • Duplicate approvals cannot submit duplicate contract refunds.
  • API responses expose refund state, transaction hash, and retryability.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workingenhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions