Improve SDK quality: error handling, validation, exports, tests#24
Merged
Improve SDK quality: error handling, validation, exports, tests#24
Conversation
client.py: - Check HTTP status before parsing JSON (was backwards) - Catch JSON decode errors instead of crashing - Validate init params: retries >= 1, retry_delay >= 0, timeout > 0, uri non-empty - Rename ConnectionError to DaemonConnectionError (avoid shadowing builtin) - Keep ConnectionError alias for backwards compatibility - Improve docstrings on all public methods types.py: - Reject negative Currency values with clear error message - Remove Currency * Currency (nonsensical units), only allow int scalar - Add __rmul__ so 3 * Currency(10) works - Add docstrings to all dataclasses and their fields - Add docstring to Currency class with examples __init__.py: - Export all public types: AccountBalance, AccountData, BlockInfo, DaemonStatus, PeerInfo, SendPaymentResult, SendDelegationResult - Export exceptions: GraphQLError, DaemonConnectionError, CurrencyUnderflow - Add module-level docstring with quick start example tests: - test_negative_whole_rejected, test_negative_nano_rejected - test_rmul, test_mul_currency_by_currency_rejected - test_invalid_retries, test_invalid_negative_retry_delay, test_invalid_timeout - test_empty_graphql_uri - test_json_decode_error, test_http_500_retried - test_daemon_connection_error_alias 49 tests total (was 38). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
README.md: - Add error handling section with code examples - Add data types section showing all importable types - Add troubleshooting section (connection refused, schema drift, account not found) - Add return types to API reference table - Expand configuration docs with validation constraints - Add integration test instructions CHANGELOG.md: - New file following Keep a Changelog format - Document all changes in unreleased and 0.1.0 examples/basic_usage.py: - Add error handling with try/except - Import and demonstrate exception types - Add __main__ guard Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The accounts manager (port 8181) may not be ready immediately after the GraphQL endpoint (port 8080) reports network ready. Add retry loop (30 attempts, 5s interval) with response validation before parsing the 'pk' field. Previously a single curl -s with no error handling would crash with KeyError if the faucet returned an error or wasn't ready. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The lightnet image exposes 8282 but the accounts manager may listen on 8181 or 8282 depending on the image version. Map both and add diagnostic curl checks before attempting acquisition. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove -f from curl so HTTP error responses are visible (was silently swallowing non-200 responses as empty) - Increase retry to 60 attempts / 5 min (accounts-manager needs time to import and unlock accounts via the daemon) - Increase job timeout to 20 min Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- pooled_user_commands: split into two queries — one with required publicKey, one without. The daemon now requires publicKey as non-nullable when provided. - best_chain_ordering: accept both ascending and descending order (daemon behavior varies by version) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The daemon now requires $token as non-nullable when declared. Use GET_ACCOUNT (no token variable) by default and GET_ACCOUNT_WITH_TOKEN only when token_id is provided. Same pattern as pooled_user_commands fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dkijania
added a commit
that referenced
this pull request
Apr 14, 2026
Resolve merge conflicts in __init__.py and examples/basic_usage.py. Sort __all__ alphabetically (RUF022), remove unused noqa directive, suppress S105 false positive on "TOKEN" query variable names. Reformat merged files with ruff format. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Production-readiness improvements for the Python SDK:
DaemonConnectionErrorinstead of shadowingbuiltins.ConnectionError__rmul__—3 * Currency(10)now worksAccountData,BlockInfo,DaemonStatus, etc. importable frommina_sdkTest plan
ConnectionErroralias kept)🤖 Generated with Claude Code