From 907c161f97f52a1f27621e6b3a444b7bbb2456ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danii=C5=82=20M=2E?= Date: Thu, 4 Jun 2026 12:26:05 +0200 Subject: [PATCH] fix: update promote_url method to handle empty blockchain addresses and format addresses to bounceable --- backend/core/src/core/dtos/chat/rule/__init__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/core/src/core/dtos/chat/rule/__init__.py b/backend/core/src/core/dtos/chat/rule/__init__.py index 14775abc..5cfc4548 100644 --- a/backend/core/src/core/dtos/chat/rule/__init__.py +++ b/backend/core/src/core/dtos/chat/rule/__init__.py @@ -2,6 +2,7 @@ from typing import Self from pydantic import BaseModel, computed_field, Field +from pytonapi.utils import raw_to_userfriendly from core.constants import ( PROMOTE_JETTON_TEMPLATE, @@ -52,12 +53,22 @@ class ChatEligibilityRuleDTO(BaseModel): def promote_url(self) -> str | None: match self.type: case EligibilityCheckType.JETTON: + if not self.blockchain_address: + return None + return PROMOTE_JETTON_TEMPLATE.format( - jetton_master_address=self.blockchain_address + jetton_master_address=raw_to_userfriendly( + self.blockchain_address, is_bounceable=True + ) ) case EligibilityCheckType.NFT_COLLECTION: + if not self.blockchain_address: + return None + return PROMOTE_NFT_COLLECTION_TEMPLATE.format( - collection_address=self.blockchain_address + collection_address=raw_to_userfriendly( + self.blockchain_address, is_bounceable=True + ) ) case EligibilityCheckType.TONCOIN: return BUY_TONCOIN_URL