Files
pyfragment/app/utils/linkWallet.py
T
bohd4nx 760c853acd feat: Add Fragment API for TON topups, Telegram Premium purchases, and Stars transactions
- Implemented Fragment API with methods for TON topups, Premium gifts, and Stars purchases.
- Created configuration management using environment variables.
- Added detailed README documentation for installation, configuration, and usage.
- Developed utility classes for API client, wallet linking, and transaction processing.
- Included example usage in main.py for easy demonstration of API functionalities.
- Updated requirements.txt with necessary dependencies.
2025-11-03 05:58:34 +08:00

32 lines
989 B
Python

from typing import Dict, Any
import httpx
class WalletLinker:
def __init__(self, config: dict, headers: dict, transaction_processor):
self.config = config
self.headers = headers
self.transaction_processor = transaction_processor
async def link_wallet(self, account: Dict[str, Any]) -> bool:
async with httpx.AsyncClient() as client:
data = {
'account': account,
'device': "iPhone15,2",
'method': 'linkWallet'
}
response = await client.post(f"https://fragment.com/api?hash={self.config['hash']}",
headers=self.headers, data=data)
result = response.json()
if result.get("ok"):
return True
if "transaction" in result:
success, _, _ = await self.transaction_processor.process_transaction(result)
return success
return False