Skip to content

Commit 70ea05b

Browse files
authored
Merge pull request #23 from ChipaDevTeam/fix-tools
Fix tools
2 parents 1699a87 + e7c2570 commit 70ea05b

5 files changed

Lines changed: 25 additions & 20 deletions

File tree

axiomtradeapi/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ def get_dev_tokens(self, dev_address: str) -> Dict:
428428
except Exception as e:
429429
raise Exception(f"Failed to get dev tokens: {e}")
430430

431-
async def get_active_axiom_users(self, callback=None, duration: int = None):
431+
async def get_active_axiom_users(self, callback=None, duration: int = None, token_address: str = "FFcYgSSgWHforA9rXXkA48p8YFoz8TSW85Jpo3CQHDyS"):
432432
"""
433433
Subscribe to active Axiom users count updates via WebSocket.
434434
@@ -440,6 +440,7 @@ async def get_active_axiom_users(self, callback=None, duration: int = None):
440440
If not provided, prints the count to console.
441441
duration: Optional duration in seconds to listen for updates.
442442
If None, listens indefinitely until interrupted.
443+
token_address: The token address to track active users for (default is Axiom token)
443444
444445
Returns:
445446
None - runs until interrupted or duration expires
@@ -471,7 +472,7 @@ async def default_callback(count: int):
471472
ws_client = self.get_websocket_client()
472473

473474
# Subscribe to active users
474-
await ws_client.subscribe_active_users(callback)
475+
await ws_client.subscribe_active_users(callback, token_address=token_address)
475476

476477
# Start message handler
477478
if duration:

axiomtradeapi/websocket/_client.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,12 @@ async def subscribe_wallet_transactions(self, wallet_address: str, callback: Cal
245245
self.logger.error(f"Failed to subscribe to wallet transactions: {e}")
246246
return False
247247

248-
async def subscribe_active_users(self, callback: Callable[[int], None]):
249-
"""Subscribe to active Axiom users count updates.
248+
async def subscribe_active_users(self, callback: Callable[[int], None], token_address: str = "FFcYgSSgWHforA9rXXkA48p8YFoz8TSW85Jpo3CQHDyS"):
249+
"""Subscribe to active Axiom users count updates for a specific token.
250250
251251
Args:
252252
callback: Async function that receives the active user count as an integer
253+
token_address: The token address to track active users for (default is Axiom token)
253254
254255
Returns:
255256
bool: True if subscription was successful, False otherwise
@@ -262,22 +263,22 @@ async def handle_user_count(count: int):
262263
263264
Response format:
264265
{
265-
"room": "e-FFcYgSSgWHforA9rXXkA48p8YFoz8TSW85Jpo3CQHDyS",
266+
"room": "e-<TOKEN_ADDRESS>",
266267
"content": "49"
267268
}
268269
"""
269270
if not self.ws:
270271
if not await self.connect():
271272
return False
272273

273-
self._callbacks["active_users"] = callback
274+
self._callbacks[f"active_users_{token_address}"] = callback
274275

275276
try:
276277
await self.ws.send(json.dumps({
277278
"action": "join",
278-
"room": "e-FFcYgSSgWHforA9rXXkA48p8YFoz8TSW85Jpo3CQHDyS"
279+
"room": f"e-{token_address}"
279280
}))
280-
self.logger.info("Subscribed to active Axiom users updates")
281+
self.logger.info(f"Subscribed to active users updates for token {token_address}")
281282
return True
282283
except Exception as e:
283284
self.logger.error(f"Failed to subscribe to active users: {e}")
@@ -298,15 +299,18 @@ async def _message_handler(self):
298299
await self._callbacks["new_pairs"]([content])
299300

300301
# Handle active users updates
301-
if "active_users" in self._callbacks and data.get("room") == "e-FFcYgSSgWHforA9rXXkA48p8YFoz8TSW85Jpo3CQHDyS":
302-
content = data.get("content")
303-
if content is not None:
304-
# Convert string content to integer
305-
try:
306-
user_count = int(content)
307-
await self._callbacks["active_users"](user_count)
308-
except (ValueError, TypeError):
309-
self.logger.error(f"Failed to parse active users count: {content}")
302+
for key, callback in self._callbacks.items():
303+
if key.startswith("active_users_"):
304+
token_addr = key.replace("active_users_", "")
305+
if data.get("room") == f"e-{token_addr}":
306+
content = data.get("content")
307+
if content is not None:
308+
# Convert string content to integer
309+
try:
310+
user_count = int(content)
311+
await callback(user_count)
312+
except (ValueError, TypeError):
313+
self.logger.error(f"Failed to parse active users count: {content}")
310314

311315
# Handle token price updates
312316
for key, callback in self._callbacks.items():

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "axiomtradeapi"
7-
version = "1.0.8"
7+
version = "1.0.9"
88
description = "A comprehensive Python client for the AxiomTrade API with automatic token management, secure authentication, and extensive trading analytics for Solana meme tokens."
99
readme = "README.md"
1010
license = "MIT"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="axiomtradeapi",
8-
version="1.0.8",
8+
version="1.0.9",
99
description="A comprehensive Python client for the AxiomTrade API with automatic token management, secure authentication, and extensive trading analytics for Solana meme tokens.",
1010
author="ChipaDevTeam",
1111
author_email="",

test_active_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async def tracking_callback(count: int):
5858
print(f"Update #{update_count[0]}: {count} active users")
5959

6060
try:
61-
await client.get_active_axiom_users(callback=tracking_callback, duration=15)
61+
await client.get_active_axiom_users(callback=tracking_callback, duration=15, token_address="8P5kBTzvG7xyjTZRzi4ftzpy6mnL74AHLtHDqyDq44ST")
6262
except KeyboardInterrupt:
6363
print("\n\n⚠️ Test interrupted by user")
6464
except Exception as e:

0 commit comments

Comments
 (0)