Skip to content

feat(tusdt-cli): add dry-run and Ledger hardware wallet support - #10

Merged
Benup211 merged 1 commit into
mainfrom
feature/dry-run-ledger
Jul 14, 2026
Merged

feat(tusdt-cli): add dry-run and Ledger hardware wallet support#10
Benup211 merged 1 commit into
mainfrom
feature/dry-run-ledger

Conversation

@Benup211

Copy link
Copy Markdown
Collaborator

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

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
@Benup211
Benup211 merged commit 846c9fb into main Jul 14, 2026
2 checks passed
@Benup211
Benup211 deleted the feature/dry-run-ledger branch July 14, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant