CLI: one-line program error messages + alw vault deposit --amount - #717
Merged
Conversation
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.
Two operator-facing CLI fixes from the miner-setup feedback notes.
1. Program rejections reached the operator as a traceback
alw bind-hotkeywith no SOL collateral dumped a 40-line traceback ending in the raw RPC dict. Every command that catches onlySolanaClientErrorhad the same hole:_sendraisesSolanaRpcError(a separate class) on pre-flight reject, landed-tx failure, and confirm timeout.StyledGroup.invokeis now the single choke point: anySolanaClientError/SolanaRpcErrorescaping a subcommand routes throughfail()(exit 1, JSON-mode aware). No command needs its own wrapper for this class.program_error_code()insolana/client.pyreads the Anchor code from all three shapes:Error Number: N,custom program error: 0xHEX,{'Custom': N}.PROGRAM_ERRORSis loaded from the packaged IDL, so every one of the 68 codes has a one-line message._ERROR_CODESis now derived from it instead of hand-typed.PROGRAM_ERROR_HINTSoverrides 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.messageline, never the dict.2. SOL vs TAO collateral commands read as two different tools
Before:
alw collateral deposit --amount X(SOL) vsalw vault post-collateral X(TAO). Different verb, different arg style.alw vault post-collateral AMOUNT→alw vault deposit --amount X.post-collateralstays as an alias.alw vault withdraw AMOUNT→alw vault withdraw --amount X.allways-docs-uiandoptimal-allways-minerREADME 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 --amountand thepost-collateralalias both post the right rao.Full suite: 2064 passed; the 3
test_bitcoin_signing.pyfailures are pre-existing ontest.