Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a token_address field to the Metainfo of BULK_TRANSFER_ERROR notification #702

Merged
merged 1 commit into from
Oct 3, 2024
Merged
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
1 change: 1 addition & 0 deletions app/model/schema/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]


Expand Down
5 changes: 5 additions & 0 deletions batch/processor_bulk_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions docs/ibet_prime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions tests/app/test_notifications_ListAllNotifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class TestListAllNotifications:
# <Normal_1>
# 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")
Expand All @@ -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(
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -378,6 +382,8 @@ def test_normal_1(self, client, db):
# <Normal_2>
# 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")
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -483,6 +491,8 @@ def test_normal_2(self, client, db):
# <Normal_3>
# 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")
Expand All @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions tests/batch/test_processor_bulk_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
}

Expand Down Expand Up @@ -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": [],
}

Expand Down Expand Up @@ -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],
}

Expand Down Expand Up @@ -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],
}

Expand Down Expand Up @@ -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],
}
Loading