From 81ca2e7c32d180d846b5c930540c3190b1cb9b26 Mon Sep 17 00:00:00 2001 From: bigeez Date: Sat, 4 Apr 2026 02:04:46 +0100 Subject: [PATCH 1/2] fix: search_token returns None for chainless queries due to incorrect guard placement --- onchain/tokens/metadata.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/onchain/tokens/metadata.py b/onchain/tokens/metadata.py index 32db697..3e98d21 100644 --- a/onchain/tokens/metadata.py +++ b/onchain/tokens/metadata.py @@ -175,9 +175,9 @@ async def _search_token_on_dexscreener( # Filter by chain if specified if chain: - pairs = [pair for pair in pairs if pair["chainId"] == chain] - if len(pairs) == 0: - return None + chain = chain.lower() + if chain not in SUPPORTED_CHAINS: + return None token_address = pairs[0]["baseToken"]["address"] token_chain = pairs[0]["chainId"] From c54ae8ce46e3c3ad7cac72da1277aff293634acf Mon Sep 17 00:00:00 2001 From: bigeez Date: Sat, 4 Apr 2026 02:17:24 +0100 Subject: [PATCH 2/2] fix: replace unsupported regex in allow_origins with explicit URLs and allow_origin_regex --- server/fastapi_server.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/fastapi_server.py b/server/fastapi_server.py index 3b62382..383ad2d 100644 --- a/server/fastapi_server.py +++ b/server/fastapi_server.py @@ -84,13 +84,24 @@ def create_fastapi_app() -> FastAPI: app = FastAPI() # Configure CORS - app.add_middleware( + app.add_middleware( CORSMiddleware, allow_origins=[ "https://bitquant.io", "https://www.bitquant.io", - r"^http://localhost:(3000|3001|3002|4000|4200|5000|5173|8000|8080|8081|9000)$", - r"^https://defi-chat-hub-git-[\w-]+-open-gradient\.vercel\.app$", + "http://localhost:3000", + "http://localhost:3001", + "http://localhost:3002", + "http://localhost:4000", + "http://localhost:4200", + "http://localhost:5000", + "http://localhost:5173", + "http://localhost:8000", + "http://localhost:8080", + "http://localhost:8081", + "http://localhost:9000", + ], + allow_origin_regex=r"^https://defi-chat-hub-git-[\w-]+-open-gradient\.vercel\.app$", ], allow_credentials=True, allow_methods=["*"],