Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,7 @@ The Bridgelet SDK is a NestJS-based backend service that manages the lifecycle o

The following services/imports are currently **commented out** to allow `npm run start:dev` to run without errors. These are **NOT removed** and **MUST be restored** once proper implementations exist.

### Missing Services:

1. **WebhooksService** (referenced in `src/modules/claims/providers/claim-redemption.provider.ts`)
- **Location:** `src/modules/webhooks/` (does not exist yet)
- **What was commented out:**
- Constructor dependency injection (line ~25)
- Webhook trigger for `sweep.completed` event (line ~106)
- Webhook trigger for `sweep.failed` event (line ~137)
- **Why:** Service implementation does not exist, causing TypeScript compilation errors
- **Impact:** Webhook notifications will NOT fire when claims are redeemed or when sweeps fail
- **Restoration required:** Once `WebhooksService` is implemented in `src/modules/webhooks/`, uncomment all marked sections
### Temporary Development Notes:

### How to Find Temporary Changes:

Expand Down
41 changes: 41 additions & 0 deletions src/modules/claims/providers/claim-redemption.provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,23 @@ describe('ClaimRedemptionProvider', () => {
});
});

it('should trigger sweep.completed webhook event on successful redemption', async () => {
await provider.redeemClaim(VALID_TOKEN, VALID_DESTINATION);

expect(mockWebhooksService.triggerEvent).toHaveBeenCalledWith(
'sweep.completed',
expect.objectContaining({
accountId: mockAccount.id,
amount: mockAccount.amount,
asset: mockAccount.asset,
destination: VALID_DESTINATION,
txHash: mockSweepResult.txHash,
sweptAt: mockClaim.claimedAt,
metadata: mockAccount.metadata,
}),
);
});

it('should acquire SELECT FOR UPDATE lock before setting status to CLAIMING', async () => {
// Rebuild with a spy-able dataSource so we can inspect the qb inside the callback
const ds = makeHappyPathDataSource();
Expand Down Expand Up @@ -371,6 +388,30 @@ describe('ClaimRedemptionProvider', () => {
p.redeemClaim(VALID_TOKEN, VALID_DESTINATION),
).rejects.toThrow('Stellar network error');
});

it('should trigger sweep.failed webhook event when sweep fails', async () => {
const ds = makeHappyPathDataSource();
const p = await buildModule(ds);
mockSweepsService.executeSweep.mockRejectedValue(
new Error('Stellar network error'),
);

await expect(
p.redeemClaim(VALID_TOKEN, VALID_DESTINATION),
).rejects.toThrow('Stellar network error');

expect(mockWebhooksService.triggerEvent).toHaveBeenCalledWith(
'sweep.failed',
expect.objectContaining({
accountId: mockAccount.id,
amount: mockAccount.amount,
asset: mockAccount.asset,
destination: VALID_DESTINATION,
error: 'Stellar network error',
timestamp: expect.any(Date),
}),
);
});
});

describe('redeemClaim - propagates TokenVerification errors (issue #167)', () => {
Expand Down
Loading