Skip to content

feat: add named RPC endpoint profiles for dev/staging/prod workflows#165

Open
okwn wants to merge 2 commits intoopen-wallet-standard:mainfrom
okwn:feat/rpc-endpoint-profile-management
Open

feat: add named RPC endpoint profiles for dev/staging/prod workflows#165
okwn wants to merge 2 commits intoopen-wallet-standard:mainfrom
okwn:feat/rpc-endpoint-profile-management

Conversation

@okwn
Copy link
Copy Markdown

@okwn okwn commented Apr 2, 2026

Summary

Adds named RPC endpoint profiles to OWS so users can manage chain-specific endpoint sets for different environments such as dev, staging, and prod.

This introduces config support for named profiles, CLI commands for profile management, and endpoint resolution that uses the active profile when no explicit RPC override is provided.

What’s included

  • rpc_config support in ~/.ows/config.json
  • named RPC profiles with chain-specific endpoint mappings
  • active profile selection
  • CLI commands:
    • ows rpc add
    • ows rpc list
    • ows rpc show
    • ows rpc use
    • ows rpc remove
    • ows rpc clear
  • endpoint resolution integration in signing/broadcast flow
  • docs updates for config format and CLI usage
  • tests for config helpers, CLI behavior, and RPC resolution precedence

RPC resolution precedence

RPC endpoint resolution now follows this order:

  1. explicit rpcUrl argument
  2. active RPC profile endpoint for the requested chain
  3. global rpc config
  4. built-in defaults

Backward compatibility

This change preserves the legacy flat rpc config format.

Existing configs continue to work as before. The new rpc_config section is optional, and profile-based resolution is only used when configured.

Testing

Ran the following checks:

  • cargo fmt --check
  • cargo clippy -p ows-core -p ows-lib -p ows-cli
  • cargo test -p ows-core
  • cargo test -p ows-cli
  • cargo test -p ows-lib -- resolve_rpc_url

All RPC-profile-related checks pass.

Reviewer notes

  • Two #[cfg(not(windows))] tests in resolve_rpc_url remain intentionally gated with explanatory comments. The tested behaviors are still covered elsewhere in the suite.
  • Pre-existing policy_engine::executable_* failures in ows-lib are unrelated to this feature and predate this branch.
  • An internal config helper returns Option<String> due to a lifetime-safe implementation choice; this is internal-only and not part of the public API.

Note

Medium Risk
Changes how RPC endpoints are resolved for signing/broadcasting by introducing profile precedence and new config serialization behavior, which could impact transaction submission if misconfigured or if defaults/overrides are merged unexpectedly.

Overview
Adds named RPC endpoint profiles to ~/.ows/config.json (rpc_config with activeProfile and per-chain URLs) and updates RPC resolution to prefer explicit --rpc-url → active profile → global rpc → built-in defaults.

Introduces a new ows rpc CLI command group (add, list, show, use, remove, clear), enhances ows config show to display active/available profiles, and updates docs/tests to cover the new config format, persistence behavior (avoid baking defaults into saved config), and precedence rules.

Written by Cursor Bugbot for commit bc0b0bd. This will update automatically on new commits. Configure here.

@okwn okwn requested a review from njdawn as a code owner April 2, 2026 18:48
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

@okwn is attempting to deploy a commit to the MoonPay Team on Vercel.

A member of the Team first needs to authorize it.

@okwn okwn force-pushed the feat/rpc-endpoint-profile-management branch from 634100a to bc0b0bd Compare April 2, 2026 20:09
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

.map_err(|e| CliError::InvalidArgs(format!("failed to write config: {}", e)))?;

Ok(())
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Config save fails if .ows directory doesn't exist

Medium Severity

save_config calls std::fs::write on ~/.ows/config.json without first ensuring the ~/.ows directory exists via create_dir_all. If a user runs ows rpc add before ever creating a wallet (which normally creates the .ows directory), the write fails with a confusing OS-level "No such file or directory" error. Other parts of the codebase (e.g., audit.rs) consistently call create_dir_all before writing to the .ows tree.

Fix in Cursor Fix in Web

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