Skip to content

feat(rpc): implement personal_sign with TUI prompt + fix chain name parsing#132

Draft
mfw78 wants to merge 2 commits into
mainfrom
feat/personal-sign
Draft

feat(rpc): implement personal_sign with TUI prompt + fix chain name parsing#132
mfw78 wants to merge 2 commits into
mainfrom
feat/personal-sign

Conversation

@mfw78

@mfw78 mfw78 commented Dec 29, 2025

Copy link
Copy Markdown
Member

Summary

This PR adds two improvements to the TUI/RPC:

  1. Fix case-insensitive chain name parsing - Chain names in config (e.g., "Mainnet", "Gnosis") were failing to parse because NamedChain expects kebab-case lowercase names. Now converts to lowercase before parsing.

  2. Implement personal_sign RPC method - Adds support for the personal_sign JSON-RPC method commonly used by dapps. Includes a TUI prompt dialog for user approval.

What

Chain name parsing fix

  • Config::chain_rpcs() now converts chain names to lowercase before parsing
  • chain_id_or_name_to_named_chain() also converts to lowercase for consistency
  • Numeric chain IDs continue to work as before

personal_sign implementation

  • Added PersonalSign variants to InteractiveRequest/InteractiveResponse
  • Registered personal_sign RPC method with reversed parameter order (message, address) per the standard
  • Added TUI prompt dialog with Accept/Reject controls
  • Message displayed as UTF-8 when decodable, hex otherwise

Why

  • Chain name parsing was broken for all default config chain names, causing warnings on startup
  • personal_sign is a commonly used RPC method that many dapps rely on for message signing

Testing

  • Verified chain names parse correctly after fix (no more VariantNotFound warnings)
  • Built and ran clippy with no warnings
  • Ran test suite

AI Assistance

AI assistance (Claude) was used for code generation and implementation of both features.

NamedChain from alloy_chains uses strum's kebab-case serialization,
which means FromStr expects lowercase names like "mainnet", "gnosis",
etc. The config defaults used Title Case ("Mainnet", "Gnosis"), causing
all chain names to fail parsing with VariantNotFound errors.

Convert chain names to lowercase before parsing to make chain name
matching case-insensitive while still supporting numeric chain IDs.
Add support for the personal_sign JSON-RPC method, which is commonly
used by dapps for message signing. Unlike eth_sign which takes
(address, message), personal_sign uses reversed parameter order
(message, address) per the de facto standard.

Implementation includes:
- PersonalSign variants in InteractiveRequest/InteractiveResponse
- personal_sign RPC method registration in eth namespace
- TUI prompt dialog with Accept/Reject controls
- UTF-8 message decoding for display when possible
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.

2 participants