Skip to content

feat: implement party acceptance flow and webhook retry mechanism#360

Open
SharifIbrahimDev wants to merge 3 commits into
StayLitCodes:mainfrom
SharifIbrahimDev:feat/party-acceptance-flow
Open

feat: implement party acceptance flow and webhook retry mechanism#360
SharifIbrahimDev wants to merge 3 commits into
StayLitCodes:mainfrom
SharifIbrahimDev:feat/party-acceptance-flow

Conversation

@SharifIbrahimDev

Copy link
Copy Markdown

🚀 Feature: Party Acceptance Flow & Webhook Retry Mechanism

📜 Description

This PR resolves two major issues in Vaultix:

  1. [Issue Implement Party Invitation Acceptance/Rejection Flow #58] Escrow Party Acceptance Flow: Implementing a robust mutual-consent mechanism before escrows can be funded and activated.
  2. [Issue Backend: Webhook retry mechanism with exponential backoff #197] Webhook Retry Mechanism: Ensuring durability of outgoing webhooks with exponential backoff and a dead-letter queue.

🛠️ Changes Made

  • Escrow State Machine: Escrows can no longer transition from PENDING to ACTIVE unless all invited parties explicitly have an ACCEPTED status.
  • Party Acceptance Endpoints: Added endpoints POST /escrows/:id/parties/:partyId/accept and reject.
  • Durable Webhooks: Introduced WebhookDelivery entity to track individual delivery attempts, logging response codes, error messages, and next retry times.
  • Exponential Backoff: Configured an asynchronous retry queue with an exponential backoff schedule (1s, 2s, 4s, 8s, 16s) up to 5 max attempts.
  • Admin Visibility: Added endpoints to view permanently failed webhooks (/admin/failed), manually trigger retries (/admin/deliveries/:id/retry), and check health stats (/health).
  • Cron Jobs: Integrated @nestjs/schedule to run a durable sweep for delayed/crashed deliveries.

✅ Verification & Testing

  • ✅ Added Unit Tests to verify the acceptance workflow and the EscrowService.fund constraint.
  • ✅ Appended an E2E testing block for Party Acceptance inside test/e2e/escrow.e2e-spec.ts.
  • ✅ All services inject the required Repositories safely.

📌 Related Issues

Closes #58
Closes #197

@drips-wave

drips-wave Bot commented Jun 1, 2026

Copy link
Copy Markdown

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

@SharifIbrahimDev

Copy link
Copy Markdown
Author

Hi maintainer,

I've resolved the merge conflicts and pushed the updates.

During the resolution, I noticed that main had already implemented similar party acceptance endpoints (acceptPartyInvitation and rejectPartyInvitation). To keep things clean, I removed the redundant duplicate methods from my branch and integrated the functionality seamlessly with the existing code from main.

I also fixed a minor TypeScript type inference error in webhook.service.ts that would have caused the build to fail.

Everything builds successfully (npm run build) and the test suite is fully passing (npm run test) locally. Let me know if you need any further adjustments before merging! 🚀

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: Webhook retry mechanism with exponential backoff Implement Party Invitation Acceptance/Rejection Flow

1 participant