"Updation for frontend"#6
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes frontend-related updates to improve the position synchronization behavior and transaction monitoring in the backend. The main focus is on preventing duplicate position creation errors and improving blockchain transaction polling.
- Adds duplicate position check before creating a new position in the sync endpoint
- Changes HTTP status code from CREATED to OK for the sync-position endpoint to better reflect idempotent behavior
- Adds explicit polling interval configuration for blockchain transaction monitoring
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/backend/src/modules/solvency/controllers/solvency.controller.ts | Added duplicate position check logic to prevent database errors when syncing positions, and changed HTTP status code from CREATED to OK for idempotent behavior |
| packages/backend/src/modules/blockchain/services/blockchain.service.ts | Added explicit pollingInterval parameter (2 seconds) to transaction receipt waiting configuration |
| packages/backend/configs/approved_admins.json | Added a new admin wallet address to the approved admins list |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (existingPosition) { | ||
| return { | ||
| success: true, | ||
| message: 'Position already exists.', | ||
| position: existingPosition, | ||
| }; | ||
| } |
There was a problem hiding this comment.
The duplicate check logic has an issue. According to the service implementation, getPosition throws a NotFoundException when a position is not found. This means that if the position doesn't exist, the code will catch the exception at line 235, check if it's a NotFoundException at line 238, and then continue execution. However, the check at line 228 'if (existingPosition)' will never be reached when the position doesn't exist because an exception is thrown before the return statement. The early return at lines 229-233 will only execute when the position exists, which is the intended behavior, but the try-catch structure is confusing and could be simplified.
| if (existingPosition) { | |
| return { | |
| success: true, | |
| message: 'Position already exists.', | |
| position: existingPosition, | |
| }; | |
| } | |
| return { | |
| success: true, | |
| message: 'Position already exists.', | |
| position: existingPosition, | |
| }; |
No description provided.