tick
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
# telegram_utils.py
|
||||
import sys
|
||||
import os
|
||||
|
||||
from base58 import b58decode
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import aiohttp
|
||||
@ -65,7 +67,8 @@ class CSVFormatter(logging.Formatter):
|
||||
record.wallet_address
|
||||
])
|
||||
return ''
|
||||
class Log:
|
||||
|
||||
class Logging:
|
||||
# Set up success logger for accounting CSV
|
||||
|
||||
def __init__(self):
|
||||
@ -105,6 +108,26 @@ class Log:
|
||||
})
|
||||
|
||||
|
||||
|
||||
def decode_instruction_data(data: str) -> dict:
|
||||
try:
|
||||
# Decode base58 data
|
||||
decoded = b58decode(data)
|
||||
|
||||
# First byte usually represents instruction type
|
||||
instruction_type = decoded[0] if decoded else None
|
||||
|
||||
# Rest of the data might contain amounts, token info etc
|
||||
# Exact parsing depends on the program (Raydium, Orca, etc)
|
||||
params = decoded[1:] if len(decoded) > 1 else None
|
||||
|
||||
return {
|
||||
"instruction_type": instruction_type,
|
||||
"params": params.hex() if params else None
|
||||
}
|
||||
except Exception as e:
|
||||
return {"error": str(e)}
|
||||
|
||||
def safe_get_property(info, property_name, default='Unknown'):
|
||||
if not isinstance(info, dict):
|
||||
return str(default)
|
||||
@ -154,7 +177,7 @@ async def async_safe_call(
|
||||
|
||||
# Create a global instance of TelegramUtils
|
||||
telegram_utils = TelegramUtils()
|
||||
log = Log().logger
|
||||
log = Logging().logger
|
||||
# You can add more Telegram-related methods to the TelegramUtils class if needed
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user