feat(tusdt-cli): add dry-run and Ledger hardware wallet support - #10
Merged
Conversation
Add --dry-run for gas/fee preview without submitting, and --ledger for signing with Ledger Nano S/X via USB HID (Polkadot generic app). Dry-run: - DryRunResult dataclass in client.py - _dry_run() performs read-only runtime simulation via ContractsApi::call - _estimate_fee() queries TransactionPaymentApi_query_info (best-effort) - dry_run flag on TUSDTClient, branch in _exec() - Output.dry_run_result() renders gas/fee/status/return-value panel - --dry-run global flag, sys.exit(0) after preview (no success msg) Ledger: - ledger.py: LedgerSigner (USB HID + APDU), LedgerKeypair(Keypair) subclass, find_ledger_device(), BIP44 derivation - m/44'/354'/ACCOUNT'/0'/INDEX' (SLIP-44 coin type 354 = Polkadot) - --ledger shorthand for --signer-backend ledger (btcli pattern) - --ledger-account/--ledger-index for BIP44 path selection - CLIContext.uses_ledger() dispatches in submit(), skips get_signer_keypair - hid optional via pip install tusdt-cli[ledger] - LEDGER_ERROR code + remediation in errors.py Fixes: - _gas_to_int moved before class (was closing TUSDTClient prematurely) - _exec() and all contract methods typed as dict[str, Any] | DryRunResult - ScaleBytes handled in LedgerKeypair.sign() - hid installed as dev dependency for type checking
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.
Add --dry-run for gas/fee preview without submitting, and --ledger
for signing with Ledger Nano S/X via USB HID (Polkadot generic app).
Dry-run:
Ledger:
subclass, find_ledger_device(), BIP44 derivation
Fixes: