Skip to content

feat: implement strict address validation in forest-wallet CLI #6012

@coderabbitai

Description

@coderabbitai

Summary

Similar to the improvements made to forest-cli in PR #6011, the forest-wallet binary should implement stricter address validation to improve user experience and prevent invalid address inputs.

Background

PR #6011 implemented stricter checks for address arguments in forest-cli by:

  • Using typed addresses (StrictAddress) instead of raw strings for safer input handling
  • Adding early network detection before CLI parsing to ensure correct network context during validation
  • Migrating CLI to an asynchronous runtime for improved responsiveness

Current State

The forest-wallet binary currently handles addresses in the following commands but uses runtime string-to-address conversion instead of compile-time type safety:

  • balance: address parameter
  • export: address parameter
  • has: key parameter (address)
  • delete: address parameter
  • set-default: key parameter (address)
  • sign: address parameter
  • verify: address parameter
  • send: from and target_address parameters

All these currently accept String parameters and convert using StrictAddress::from_str() at runtime.

Proposed Changes

  1. Update command definitions: Change string parameters to StrictAddress types for all address-handling commands
  2. Add early network detection: Implement similar network detection logic as in forest-cli before CLI parsing
  3. Migrate to async runtime: Follow the same pattern as forest-cli for consistent architecture

Commands to Update

  • Balance { address: StrictAddress }
  • Export { address: StrictAddress }
  • Has { key: StrictAddress }
  • Delete { address: StrictAddress }
  • SetDefault { key: StrictAddress }
  • Sign { address: StrictAddress }
  • Verify { address: StrictAddress }
  • Send { from: Option<StrictAddress>, target_address: StrictAddress }

Benefits

  • Early validation of address arguments before command execution
  • Better error messages for invalid addresses
  • Consistent user experience across Forest CLI tools
  • Reduced runtime errors due to invalid address formats

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions