Commit Graph

44 Commits

Author SHA1 Message Date
bohd4nx 2d1a119768 feat: update purchase and giveaway methods; improve header management and add example scripts 2026-03-21 16:16:14 +02:00
bohd4nx 902b692dcb Refactor methods for Telegram Premium and Stars giveaways
- Added new methods for handling giveaways: `giveaway_premium` and `giveaway_stars`.
- Refactored existing purchase methods into separate files: `purchase_premium.py` and `purchase_stars.py`.
- Removed old premium and stars methods from the codebase.
- Updated `__init__.py` to include new giveaway methods in the public API.
- Introduced new result types for giveaways: `PremiumGiveawayResult` and `StarsGiveawayResult`.
- Updated constants for new giveaway pages.
- Enhanced error handling for configuration and user validation in giveaway methods.
- Updated tests to cover new functionality and refactored existing tests to match new method locations.
2026-03-21 16:05:38 +02:00
bohd4nx 0af5ce5935 chore: release 2026.0.2 2026-03-20 20:57:37 +02:00
bohd4nx b07b4670fb docs: update installation instructions to include unreleased changes from the dev branch 2026-03-20 20:45:35 +02:00
bohd4nx 581886938b chore: update setup-uv action to v7.6.0 in CI and publish workflows; fix image source in README 2026-03-20 20:36:59 +02:00
bohd4nx 949796df17 chore: streamline CI linting steps and update changelog with recent changes 2026-03-20 20:25:35 +02:00
bohd4nx 75ee76b60e fix: cast cookies to dict for type safety and improve error handling in FragmentClient 2026-03-20 20:22:33 +02:00
bohd4nx 3e14a01c92 refactor: harden client, clean tests, and fix timeouts
- Security & validation: tighten hash regex, add HTTP timeouts to all
  requests, pass client.timeout through get_fragment_hash and AsyncClient
- Constants: move all constants to types/constants.py; remove re-exports
  from types/__init__.py; add DEFAULT_TIMEOUT, REQUIRED_COOKIE_KEYS
- FragmentClient: add timeout param (default 30 s); async-context-manager
  support; remove WALLET_CLASSES from public API
- Exceptions: remove dead INVALID_USERNAME constant (Fragment validates
  server-side); keep full hierarchy intact
- Tests: add 006_test_methods_mock.py (6 mock tests for all 3 methods);
  DRY-refactor 004_test_balance.py (_patch_wallet context manager);
  clean up 005_test_methods.py (remove fragile network test, rename tests)
- Examples: switch all 4 examples to async-with; align error messages;
  replace %-format with f-strings
- README: rewrite usage section with single comprehensive async-with
  example covering all 3 methods and full exception hierarchy
- CI: add mypy step to lint job; add pytest-mock and mypy to dev deps;
  set FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 on all jobs; fix COOKIES_JSON
  to job-level env var
2026-03-20 20:16:43 +02:00
bohd4nx c5edfad06f feat: add context manager support to FragmentClient; update README and tests 2026-03-16 19:21:43 +02:00
bohd4nx 20b73444ab feat: rename gift methods to purchase for clarity; update examples and changelog 2026-03-16 19:13:07 +02:00
bohd4nx b726a2274c feat: update bug report template to reflect terminology change from "gift" to "purchase" for Stars 2026-03-16 19:00:55 +02:00
bohd4nx 8d58ed890d feat: add examples for purchasing Telegram Premium and Stars 2026-03-16 18:41:27 +02:00
bohd4nx f5d2e8490a feat: restructure GitHub workflows; add CI workflow, update publish process, and remove obsolete test and lint workflows 2026-03-16 18:22:58 +02:00
bohd4nx 520153dfb1 feat: update terminology from "gift" to "purchase" for Telegram Premium and Stars; enhance README and example scripts 2026-03-16 01:14:12 +02:00
bohd4nx 67f8a882c2 feat: add MIT License to the project 2026-03-15 23:05:22 +02:00
bohd4nx 041081b919 feat: add API key validation and corresponding error handling; update tests for validation 2026-03-15 23:01:37 +02:00
bohd4nx f4a96bb01a fix: restrict workflow triggers to the master branch for linting and publishing 2026-03-15 22:45:00 +02:00
bohd4nx d8f0240807 feat: add wallet management features and enhance error handling; update tests and examples 2026-03-15 22:41:52 +02:00
bohd4nx 8135a9da7e Refactor FragmentAPI to pyfragment
- Renamed the package from `fragmentapi` to `pyfragment` across all modules and tests.
- Removed the old wallet utility functions and replaced them with new implementations.
- Updated the `pyproject.toml` to reflect the new package name and repository links.
- Adjusted all import statements in tests to use the new package name.
- Implemented new methods for gifting Telegram Premium, Stars, and topping up TON balance.
- Added exception handling for various error scenarios in the API interactions.
- Created new utility functions for handling HTTP requests and decoding payloads.
- Established a clear structure for types and constants used throughout the library.
2026-03-15 22:07:01 +02:00
bohd4nx 7f269d9a87 refactor: rename error classes for consistency and clarity; update related code and tests 2026-03-15 22:03:32 +02:00
bohd4nx 9a090e3dbc feat: implement CI/CD workflows for testing, linting, and publishing to PyPI 2026-03-15 21:45:24 +02:00
bohd4nx d2d046a2b9 refactor: restructure as installable PyPI package
- Rename app/ → fragmentapi/ for proper package naming
- Add FragmentClient class with gift_premium, gift_stars, topup_ton methods
- Restructure core/ → types/ (exceptions, results, constants)
- Merge utils/hash.py into utils/client.py
- Replace _version.py with importlib.metadata
- Add input validation with min/max bounds
- Add unit tests: decode, client init/cookies
- Rename 002_test_hash → 003_test_hash
- Clean up pyproject.toml: pin deps, production classifiers
2026-03-15 21:03:03 +02:00
bohd4nx 4e017cb7a1 refactor: update methods to include show_sender parameter and clean up tests 2026-03-14 01:34:51 +02:00
bohd4nx 6c869428aa refactor: streamline error messages and improve code formatting for consistency 2026-03-09 03:32:45 +02:00
bohd4nx c3de8a8ca3 refactor: enhance transaction logging for premium, stars, and TON topup methods 2026-03-08 04:37:07 +02:00
bohd4nx 38a4619e42 fix: pass cookies to AsyncClient instead of per-request
Fixes httpx DeprecationWarning: Setting per-request cookies is deprecated.
Cookies are now set on the AsyncClient instance and removed from all
individual post() calls and internal function signatures.
2026-03-08 04:26:45 +02:00
bohd4nx 8cf57b58b7 refactor: enhance test workflow and integration tests with cookies handling and configuration checks 2026-03-08 03:58:07 +02:00
bohd4nx 2cdc102a74 refactor: reorganize imports across multiple files for consistency and clarity 2026-03-05 06:36:27 +02:00
bohd4nx 7f3c3ea1c3 refactor: update API key source in .env.example and enhance README with badges and feature descriptions
feat: improve logging levels for HTTP clients and add detailed logging in premium and stars purchase methods
chore: remove unused transaction utility and adjust wallet processing logic
test: add end-to-end integration test for buying Stars
2026-03-05 06:26:49 +02:00
bohd4nx efcdda6b74 refactor: migrate to tonutils 2.0.0 and restructure codebase
- Migrate from tonutils 0.5.x to 2.0.0 API:
  - ToncenterClient → TonapiClient with NetworkGlobalID
  - tonutils.client → tonutils.clients
  - tonutils.wallet → tonutils.contracts.wallet
  - pub_key.as_hex property, wallet.balance nanotons
  - async with client context manager

- Centralize TON client init into initialize_ton_client() in wallet.py
- Move process_transaction logic into wallet.py, transaction.py re-exports
- Add WALLET_VERSION config (V4R2/V5R1, default V5R1)
- Add WALLET_CLASSES and SUPPORTED_WALLET_VERSIONS to constants.py
- Restore balance check before broadcasting
- Wait for seqno confirmation after transfer (120×2s) to prevent duplicate seqno

- Fix Fragment hash fetching: use browser navigation headers
- Remove accept-encoding from BASE_HEADERS (httpx handles decompression)
- Add cookies.example.json template
- Add cookies.json to .gitignore
2026-03-05 05:47:27 +02:00
bohd4nx b9c02646be chore: remove cookies.json from tracking, add to .gitignore 2026-03-05 05:05:24 +02:00
bohd4nx 2d7860682d fix: tonutils 2.0.0 API — as_hex property, wallet.refresh(), balance as int nanotons 2026-03-05 05:04:17 +02:00
bohd4nx 64f8058c60 fix: don't sys.exit in config at import time, support CI env vars 2026-03-05 04:23:34 +02:00
bohd4nx f57f8271c3 test: add pytest test files (were missing from previous commit) 2026-03-05 04:18:55 +02:00
bohd4nx 5dc3cddf1a refactor: replace manual base64 decoder with pytoniq_core Cell parser
- clean_decode now uses Cell.one_from_boc + load_snake_string
- no more regex/string hacks, native BOC parsing
- added full transaction_data debug log in process_transaction
2026-03-05 04:16:49 +02:00
bohd4nx d2faa27c5c ci: update actions to checkout@v6, setup-python@v6 2026-03-05 04:12:09 +02:00
bohd4nx 91d33a0972 ci: add dependabot and pytest workflow 2026-03-05 04:10:57 +02:00
bohd4nx e3706f01bf refactor: migrate to tonutils v2, pytest, pyproject.toml
- tonutils 2.0.0: TonapiClient → ToncenterV3Client, wallet.transfer()
- classes → plain async functions across all utils and methods
- core/: constants.py, cookies.py, exceptions.py extracted
- DEVICE constant in constants.py (single source of truth)
- account/device serialised with json.dumps() in all tx payloads
- tests: unittest → pytest, conftest.py fixtures, 001/002 naming
- pyproject.toml: pytest + ruff config
- min balance check: 0.056 TON
2026-03-05 04:08:35 +02:00
bohd4nx b1eae1dcb7 feat: Refactor cookie handling and hash retrieval; update environment configuration and improve logging levels 2026-01-19 19:02:28 +02:00
bohd4nx d299a1f804 feat: Refactor configuration handling and enhance logging setup; update imports and improve error handling in API methods 2026-01-18 06:41:08 +02:00
bohd4nx 76473993e2 feat: Enhance Fragment API with improved error handling and clean_decode utility; (#1) update version and dependencies 2025-11-24 19:52:22 +02:00
bohd4nx 49cf8843bc fix: Update README and SVG logo, correct import paths in utils 2025-11-03 06:01:56 +08:00
bohd4nx 8adfaf4ad2 feat: Implement ApiClient and WalletLinker classes for transaction handling 2025-11-03 06:01:53 +08:00
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