fryorcraken ea4a149585
feat: add --account-label as alternative to --account-id across all wallet subcommands
Allow users to identify accounts by their human-readable label instead of the
full `Privacy/base58` account ID. This makes the CLI much more ergonomic for
users who have labeled their accounts.

- [x] Add `resolve_account_label()` in `helperfunctions.rs` that looks up a label,
  determines account privacy (public/private), and returns the full `Privacy/id` string
- [x] Add `--account-label` (or `--from-label`, `--to-label`, `--definition-label`,
  `--holder-label`, `--user-holding-*-label`) as mutually exclusive alternative to
  every `--account-id`-style flag across all subcommands:
  - `account get`, `account label`
  - `auth-transfer init`, `auth-transfer send`
  - `token new`, `token send`, `token burn`, `token mint`
  - `pinata claim`
  - `amm new`, `amm swap`, `amm add-liquidity`, `amm remove-liquidity`
- [x] Update zsh completion script with `_wallet_account_labels()` helper
- [x] Add bash completion script with `_wallet_get_account_labels()` helper

1. Start a local sequencer
2. Create accounts and label them: `wallet account new public --label alice`
3. Use labels in commands: `wallet account get --account-label alice`
4. Verify mutual exclusivity: `wallet account get --account-id <id> --account-label alice` should error
5. Test shell completions: `wallet account get --account-label <TAB>` should list labels

None

None

- [x] Complete PR description
- [x] Implement the core functionality
- [ ] Add/update tests
- [x] Add/update documentation and inline comments

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 10:40:41 +11:00
..

Wallet CLI Completion

Completion scripts for the LSSA wallet command.

ZSH

Works with both vanilla zsh and oh-my-zsh.

Features

  • Full completion for all wallet subcommands
  • Contextual option completion for each command
  • Dynamic account ID completion via wallet account list
  • Descriptions for all commands and options

Note that only accounts created by the user auto-complete. Preconfigured accounts and accounts only with / (no number) are not completed.

e.g.:

▶ wallet account list
Preconfigured Public/7wHg9sbJwc6h3NP1S9bekfAzB8CHifEcxKswCKUt3YQo,
Preconfigured Public/6iArKUXxhUJqS7kCaPNhwMWt3ro71PDyBj7jwAyE2VQV,
Preconfigured Private/3oCG8gqdKLMegw4rRfyaMQvuPHpcASt7xwttsmnZLSkw,
Preconfigured Private/AKTcXgJ1xoynta1Ec7y6Jso1z1JQtHqd7aPQ1h9er6xX,
/ Public/8DstRgMQrB2N9a7ymv98RDDbt8nctrP9ZzaNRSpKDZSu,
/0 Public/2gJJjtG9UivBGEhA1Jz6waZQx1cwfYupC5yvKEweHaeH,
/ Private/Bcv15B36bs1VqvQAdY6ZGFM1KioByNQQsB92KTNAx6u2

Only Public/2gJJjtG9UivBGEhA1Jz6waZQx1cwfYupC5yvKEweHaeH is used for completion.

Supported Commands

Command Description
wallet auth-transfer Authenticated transfer (init, send)
wallet chain-info Chain info queries (current-block-id, block, transaction)
wallet account Account management (get, list, new, sync-private)
wallet pinata Piñata faucet (claim)
wallet token Token operations (new, send)
wallet amm AMM operations (new, swap, add-liquidity, remove-liquidity)
wallet check-health Health check

Installation

Vanilla Zsh

  1. Create a completions directory:

    mkdir -p ~/.zsh/completions
    
  2. Copy the completion file:

    cp ./zsh/_wallet ~/.zsh/completions/
    
  3. Add to your ~/.zshrc (before any compinit call, or add these lines if you don't have one):

    fpath=(~/.zsh/completions $fpath)
    autoload -Uz compinit && compinit
    
  4. Reload your shell:

    exec zsh
    

Oh-My-Zsh

  1. Create the plugin directory and copy the file:

    mkdir -p ~/.oh-my-zsh/custom/plugins/wallet
    cp _wallet ~/.oh-my-zsh/custom/plugins/wallet/
    
  2. Add wallet to your plugins array in ~/.zshrc:

    plugins=(... wallet)
    
  3. Reload your shell:

    exec zsh
    

Requirements

The completion script calls wallet account list to dynamically fetch account IDs. Ensure the wallet command is in your $PATH.

Usage

# Main commands
wallet <TAB>

# Account subcommands
wallet account <TAB>

# Options for auth-transfer send
wallet auth-transfer send --<TAB>

# Account types when creating
wallet account new <TAB>
# Shows: public  private

# Account IDs (fetched dynamically)
wallet account get --account-id <TAB>
# Shows: Public/...  Private/...

Bash

Works with bash 4+. The bash-completion package is required for auto-sourcing from /etc/bash_completion.d/; without it, source the file directly from ~/.bashrc instead.

Features

  • Full completion for all wallet subcommands
  • Contextual option completion for each command
  • Dynamic account ID completion via wallet account list
  • Falls back to Public/ / Private/ prefixes when no accounts are available

Note that only accounts created by the user auto-complete (same filtering as zsh — see above).

Installation

Option A — source directly from ~/.bashrc (works everywhere)

echo "source $(pwd)/completions/bash/wallet" >> ~/.bashrc
exec bash

Option B — system-wide via bash-completion

  1. Copy the file:

    cp ./bash/wallet /etc/bash_completion.d/wallet
    
  2. Ensure bash-completion is initialised in every interactive shell. On many Linux distributions (e.g. Fedora) it is only sourced for login shells via /etc/profile.d/bash_completion.sh. For non-login shells (e.g. a bash session started inside zsh), add this to ~/.bashrc:

    [[ -f /usr/share/bash-completion/bash_completion ]] && source /usr/share/bash-completion/bash_completion
    
  3. Reload your shell:

    exec bash
    

Requirements

The completion script calls wallet account list to dynamically fetch account IDs. Ensure the wallet command is in your $PATH.

Usage

# Main commands
wallet <TAB>

# Account subcommands
wallet account <TAB>

# Options for auth-transfer send
wallet auth-transfer send --<TAB>

# Account types when creating
wallet account new <TAB>
# Shows: public  private

# Account IDs (fetched dynamically)
wallet account get --account-id <TAB>
# Shows: Public/...  Private/...

Troubleshooting

Zsh completions not appearing

  1. Check that compinit is called in your .zshrc

  2. Rebuild the completion cache:

    rm -f ~/.zcompdump*
    exec zsh
    

Account IDs not completing

Ensure wallet account list works from your command line.