Skip to content

CLI: one-line program error messages + alw vault deposit --amount - #717

Merged
LandynDev merged 2 commits into
testfrom
fix/cli-program-error-messages
Sep 2, 2026
Merged

CLI: one-line program error messages + alw vault deposit --amount#717
LandynDev merged 2 commits into
testfrom
fix/cli-program-error-messages

Conversation

@LandynDev

Copy link
Copy Markdown
Collaborator

Two operator-facing CLI fixes from the miner-setup feedback notes.

1. Program rejections reached the operator as a traceback

alw bind-hotkey with no SOL collateral dumped a 40-line traceback ending in the raw RPC dict. Every command that catches only SolanaClientError had the same hole: _send raises SolanaRpcError (a separate class) on pre-flight reject, landed-tx failure, and confirm timeout.

  • StyledGroup.invoke is now the single choke point: any SolanaClientError / SolanaRpcError escaping a subcommand routes through fail() (exit 1, JSON-mode aware). No command needs its own wrapper for this class.
  • program_error_code() in solana/client.py reads the Anchor code from all three shapes: Error Number: N, custom program error: 0xHEX, {'Custom': N}.
  • PROGRAM_ERRORS is loaded from the packaged IDL, so every one of the 68 codes has a one-line message. _ERROR_CODES is now derived from it instead of hand-typed.
  • PROGRAM_ERROR_HINTS overrides the IDL text where it is not actionable from the CLI: 6002 → Deposit collateral first: alw collateral deposit, 6003 → alw miner deactivate, 6015 → alw miner activate.
  • Non-program RPC failures keep only the RPC message line, never the dict.
$ alw bind-hotkey --yes
Deposit collateral first: alw collateral deposit (InsufficientCollateral 6002)
$ echo $?
1

2. SOL vs TAO collateral commands read as two different tools

Before: alw collateral deposit --amount X (SOL) vs alw vault post-collateral X (TAO). Different verb, different arg style.

  • alw vault post-collateral AMOUNTalw vault deposit --amount X. post-collateral stays as an alias.
  • alw vault withdraw AMOUNTalw vault withdraw --amount X.
  • Both prompt for the amount when the flag is omitted, same as the SOL commands.
  • Help text on each group and command names its twin.
  • README, e2e_lock.sh, and the activation-guidance strings updated. allways-docs-ui and optimal-allways-miner README still show the positional form; the alias keeps the name working but the positional amount needs a docs follow-up.

Tests

  • test_cli_miner_solana.py: bind-hotkey on 6002 exits 1 with the one-line hint, no traceback, no RPC dict.
  • test_cli_program_errors.py: code parsing for all three shapes, IDL-sourced table, hint vs IDL fallback, RPC message line fallback.
  • test_cli_vault_admin.py: vault deposit --amount and the post-collateral alias both post the right rao.

Full suite: 2064 passed; the 3 test_bitcoin_signing.py failures are pre-existing on test.

@LandynDev
LandynDev merged commit a4e720b into test Sep 2, 2026
3 checks passed
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