From 58fcf7f276205b8f126d970ba6208c3dca94e0a3 Mon Sep 17 00:00:00 2001 From: YoshihitoAso Date: Wed, 2 Oct 2024 22:51:49 +0900 Subject: [PATCH] Add a token_address field to the Metainfo of BULK_TRANSFER_ERROR notification --- app/model/schema/notification.py | 1 + batch/processor_bulk_transfer.py | 5 +++++ docs/ibet_prime.yaml | 5 +++++ tests/app/test_notifications_ListAllNotifications.py | 11 +++++++++++ tests/batch/test_processor_bulk_transfer.py | 5 +++++ 5 files changed, 27 insertions(+) diff --git a/app/model/schema/notification.py b/app/model/schema/notification.py index 3e84160d..c3883396 100644 --- a/app/model/schema/notification.py +++ b/app/model/schema/notification.py @@ -35,6 +35,7 @@ class IssueErrorMetaInfo(BaseModel): class BulkTransferErrorMetaInfo(BaseModel): upload_id: str token_type: TokenType + token_address: Optional[str] = None error_transfer_id: list[int] diff --git a/batch/processor_bulk_transfer.py b/batch/processor_bulk_transfer.py index 76445e09..e58e169c 100644 --- a/batch/processor_bulk_transfer.py +++ b/batch/processor_bulk_transfer.py @@ -120,6 +120,7 @@ async def process(self): code=0, upload_id=_upload.upload_id, token_type=_upload.token_type, + token_address=_upload.token_address, error_transfer_id=[], ) await db_session.commit() @@ -145,6 +146,7 @@ async def process(self): code=1, upload_id=_upload.upload_id, token_type=_upload.token_type, + token_address=_upload.token_address, error_transfer_id=[], ) await db_session.commit() @@ -285,6 +287,7 @@ async def process(self): code=2, upload_id=_upload.upload_id, token_type=_upload.token_type, + token_address=_upload.token_address, error_transfer_id=error_transfer_id, ) @@ -537,6 +540,7 @@ async def __error_notification( code: int, upload_id: str, token_type: str, + token_address: str | None, error_transfer_id: List[int], ): notification = Notification() @@ -548,6 +552,7 @@ async def __error_notification( notification.metainfo = { "upload_id": upload_id, "token_type": token_type, + "token_address": token_address, "error_transfer_id": error_transfer_id, } db_session.add(notification) diff --git a/docs/ibet_prime.yaml b/docs/ibet_prime.yaml index 01ea3bc7..f25faa09 100644 --- a/docs/ibet_prime.yaml +++ b/docs/ibet_prime.yaml @@ -10043,6 +10043,11 @@ components: title: Upload Id token_type: $ref: '#/components/schemas/TokenType' + token_address: + anyOf: + - type: string + - type: 'null' + title: Token Address error_transfer_id: items: type: integer diff --git a/tests/app/test_notifications_ListAllNotifications.py b/tests/app/test_notifications_ListAllNotifications.py index ba500a60..2440230a 100644 --- a/tests/app/test_notifications_ListAllNotifications.py +++ b/tests/app/test_notifications_ListAllNotifications.py @@ -41,6 +41,8 @@ class TestListAllNotifications: # # Non filtered def test_normal_1(self, client, db): + test_token_address = "test_token_address" + user_1 = config_eth_account("user1") issuer_address_1 = user_1["address"] user_2 = config_eth_account("user2") @@ -56,6 +58,7 @@ def test_normal_1(self, client, db): _notification_1.metainfo = { "upload_id": str(uuid.uuid4()), "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": test_token_address, "error_transfer_id": [], } _notification_1.created = datetime.strptime( @@ -241,6 +244,7 @@ def test_normal_1(self, client, db): "metainfo": { "upload_id": ANY, "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": test_token_address, "error_transfer_id": [], }, "created": "2022-01-02T00:20:30+09:00", @@ -378,6 +382,8 @@ def test_normal_1(self, client, db): # # filtered def test_normal_2(self, client, db): + test_token_address = "test_token_address" + user_1 = config_eth_account("user1") issuer_address_1 = user_1["address"] user_2 = config_eth_account("user2") @@ -393,6 +399,7 @@ def test_normal_2(self, client, db): _notification_1.metainfo = { "upload_id": str(uuid.uuid4()), "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": test_token_address, "error_transfer_id": [], } _notification_1.created = datetime.strptime( @@ -424,6 +431,7 @@ def test_normal_2(self, client, db): _notification_3.metainfo = { "upload_id": str(uuid.uuid4()), "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": test_token_address, "error_transfer_id": [], } _notification_3.created = datetime.strptime( @@ -483,6 +491,8 @@ def test_normal_2(self, client, db): # # limit-offset def test_normal_3(self, client, db): + test_token_address = "test_token_address" + user_1 = config_eth_account("user1") issuer_address_1 = user_1["address"] user_2 = config_eth_account("user2") @@ -498,6 +508,7 @@ def test_normal_3(self, client, db): _notification_1.metainfo = { "upload_id": str(uuid.uuid4()), "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": test_token_address, "error_transfer_id": [], } _notification_1.created = datetime.strptime( diff --git a/tests/batch/test_processor_bulk_transfer.py b/tests/batch/test_processor_bulk_transfer.py index 67fd47fd..75b07681 100644 --- a/tests/batch/test_processor_bulk_transfer.py +++ b/tests/batch/test_processor_bulk_transfer.py @@ -734,6 +734,7 @@ async def test_error_1(self, processor, db): assert _notification.metainfo == { "upload_id": self.upload_id_list[0], "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": self.bulk_transfer_token[0], "error_transfer_id": [], } @@ -782,6 +783,7 @@ async def test_error_2(self, processor, db): assert _notification.metainfo == { "upload_id": self.upload_id_list[0], "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": self.bulk_transfer_token[0], "error_transfer_id": [], } @@ -864,6 +866,7 @@ async def test_error_3_1(self, processor, db): assert _notification.metainfo == { "upload_id": self.upload_id_list[0], "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": self.bulk_transfer_token[0], "error_transfer_id": [1], } @@ -951,6 +954,7 @@ async def test_error_3_2(self, processor, db): assert _notification.metainfo == { "upload_id": self.upload_id_list[0], "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": self.bulk_transfer_token[0], "error_transfer_id": [1], } @@ -1173,5 +1177,6 @@ async def test_error_5(self, processor, db): assert _notification.metainfo == { "upload_id": self.upload_id_list[0], "token_type": TokenType.IBET_STRAIGHT_BOND.value, + "token_address": self.bulk_transfer_token[0], "error_transfer_id": [3], }