Add watchers for ChangeToRedeemed and ChangeToCanceled events with notification processing - #1661
Conversation
…tification processing
ab4c741 to
848d230
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for two new notification types (ChangeToRedeemed and ChangeToCanceled) along with their corresponding watchers and test coverage. The changes enable the system to monitor and notify when bond tokens are redeemed or share tokens are canceled.
- Adds
CHANGE_TO_REDEEMEDandCHANGE_TO_CANCELEDnotification types to the system - Implements token-specific watchers with filtering capabilities
- Enhances the base
Watcherclass with token type filtering and sync behavior options
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| app/model/db/notification.py | Adds new notification types to the enum |
| batch/processor_Notifications_Token.py | Extends Watcher class with filtering and adds new watcher implementations |
| tests/contract_modules.py | Adds utility functions for triggering token state changes |
| tests/batch/processor_Notifications_Token_test.py | Comprehensive test coverage for new watchers |
| tests/app/notification_Notifications_GET_test.py | Updates API validation tests |
| token_type_list: list[TokenType] = None, | ||
| skip_past_data_on_initial_sync: bool = False, | ||
| ): | ||
| if token_type_list is None: | ||
| token_type_list = list([]) |
There was a problem hiding this comment.
Using a mutable default argument token_type_list: list[TokenType] = None and then checking for None is an anti-pattern. Consider using token_type_list: list[TokenType] | None = None to be more explicit about the type annotation, or use an empty list as the default and avoid the None check.
| token_type_list: list[TokenType] = None, | |
| skip_past_data_on_initial_sync: bool = False, | |
| ): | |
| if token_type_list is None: | |
| token_type_list = list([]) | |
| token_type_list: list[TokenType] = [], | |
| skip_past_data_on_initial_sync: bool = False, | |
| ): |
| skip_past_data_on_initial_sync: bool = False, | ||
| ): | ||
| if token_type_list is None: | ||
| token_type_list = list([]) |
There was a problem hiding this comment.
Using list([]) is unnecessarily verbose. Simply use [] to create an empty list.
| token_type_list = list([]) | |
| token_type_list = [] |
| ) | ||
|
|
||
|
|
||
| # BONDトークン:償還状態に変更 |
There was a problem hiding this comment.
[nitpick] The comment is in Japanese while most other comments in the codebase appear to be in English. For consistency, consider using English: # BOND Token: Change to redeemed state
| # BONDトークン:償還状態に変更 | |
| # BOND Token: Change to redeemed state |
| ) | ||
|
|
||
|
|
||
| # SHAREトークン:消却状態に変更 |
There was a problem hiding this comment.
[nitpick] The comment is in Japanese while most other comments in the codebase appear to be in English. For consistency, consider using English: # SHARE Token: Change to canceled state
| # SHAREトークン:消却状態に変更 | |
| # SHARE Token: Change to canceled state |
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
📌 Description
This pull request introduces support for two new notification types,
ChangeToRedeemedandChangeToCanceled, and updates the notification processing system to handle these events. Additionally, it includes utility functions for testing these events in the contract modules.✅ Related Issues
🔄 Changes
Notification System Enhancements:
CHANGE_TO_REDEEMEDandCHANGE_TO_CANCELEDto theNotificationTypeenum inapp/model/db/notification.py.Watcherclass to support filtering bytoken_type_listand skipping past data during initial synchronization. [1] [2] [3] [4] [5] [6]WatchChangeToRedeemedandWatchChangeToCanceled, to handle the respective events for bond tokens and share tokens. These classes include logic for creating notifications with relevant metadata.mainfunction to include the new watcher classes in the list of active watchers.Testing Utilities:
bond_change_to_redeemedutility function to simulate theChangeToRedeemedevent for bond tokens intests/contract_modules.py.share_change_to_canceledutility function to simulate theChangeToCanceledevent for share tokens intests/contract_modules.py.📌 Checklist