Skip to content

Add watchers for ChangeToRedeemed and ChangeToCanceled events with notification processing - #1661

Merged
purplesmoke05 merged 1 commit into
dev-25.9from
feature/#1650
Jul 30, 2025
Merged

Add watchers for ChangeToRedeemed and ChangeToCanceled events with notification processing#1661
purplesmoke05 merged 1 commit into
dev-25.9from
feature/#1650

Conversation

@purplesmoke05

Copy link
Copy Markdown
Member

📌 Description

This pull request introduces support for two new notification types, ChangeToRedeemed and ChangeToCanceled, 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:

  • Added new notification types CHANGE_TO_REDEEMED and CHANGE_TO_CANCELED to the NotificationType enum in app/model/db/notification.py.
  • Extended the Watcher class to support filtering by token_type_list and skipping past data during initial synchronization. [1] [2] [3] [4] [5] [6]
  • Introduced two new watcher classes, WatchChangeToRedeemed and WatchChangeToCanceled, to handle the respective events for bond tokens and share tokens. These classes include logic for creating notifications with relevant metadata.
  • Updated the main function to include the new watcher classes in the list of active watchers.

Testing Utilities:

  • Added bond_change_to_redeemed utility function to simulate the ChangeToRedeemed event for bond tokens in tests/contract_modules.py.
  • Added share_change_to_canceled utility function to simulate the ChangeToCanceled event for share tokens in tests/contract_modules.py.

📌 Checklist

  • I have added tests where necessary.
  • I have updated the documentation where necessary.

@github-actions
github-actions Bot requested a review from YoshihitoAso July 30, 2025 01:05
@purplesmoke05
purplesmoke05 marked this pull request as draft July 30, 2025 04:16
@purplesmoke05
purplesmoke05 marked this pull request as ready for review July 30, 2025 04:19
@YoshihitoAso
YoshihitoAso requested a review from Copilot July 30, 2025 04:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_REDEEMED and CHANGE_TO_CANCELED notification types to the system
  • Implements token-specific watchers with filtering capabilities
  • Enhances the base Watcher class 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

Comment on lines +79 to +83
token_type_list: list[TokenType] = None,
skip_past_data_on_initial_sync: bool = False,
):
if token_type_list is None:
token_type_list = list([])

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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,
):

Copilot uses AI. Check for mistakes.
skip_past_data_on_initial_sync: bool = False,
):
if token_type_list is None:
token_type_list = list([])

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using list([]) is unnecessarily verbose. Simply use [] to create an empty list.

Suggested change
token_type_list = list([])
token_type_list = []

Copilot uses AI. Check for mistakes.
Comment thread tests/contract_modules.py
)


# BONDトークン:償還状態に変更

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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

Suggested change
# BONDトークン:償還状態に変更
# BOND Token: Change to redeemed state

Copilot uses AI. Check for mistakes.
Comment thread tests/contract_modules.py
)


# SHAREトークン:消却状態に変更

Copilot AI Jul 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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

Suggested change
# SHAREトークン:消却状態に変更
# SHARE Token: Change to canceled state

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown

Coverage

Coverage Report •
FileStmtsMissCoverMissing
app/model/db
   notification.py63395%49, 110, 119
batch
   processor_Notifications_Token.py2832890%137, 171, 193, 195, 220–223, 351, 396, 441, 640, 651, 653–654, 656–657, 660–662, 664–665, 667–668, 672–675
tests
   contract_modules.py4092693%209–211, 218–220, 377–379, 461–462, 669, 671–672, 790–792, 866–868, 998–999, 1002, 1086–1087, 1090
tests/app
   notification_Notifications_GET_test.py1330100% 
tests/batch
   processor_Notifications_Token_test.py1091199%67
TOTAL44729157296% 

Tests Skipped Failures Errors Time
1497 0 💤 0 ❌ 0 🔥 13m 9s ⏱️

@purplesmoke05
purplesmoke05 merged commit a2a25d2 into dev-25.9 Jul 30, 2025
12 checks passed
@purplesmoke05
purplesmoke05 deleted the feature/#1650 branch July 30, 2025 04:46
@YoshihitoAso YoshihitoAso mentioned this pull request Jul 31, 2025
2 tasks
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.

[FEATURE] Add notification triggers for 'is_redeemed' and 'is_canceled' statuses of ibet bonds and ibet share

3 participants