Skip to content

feat: derive network defaults from -u moniker in shreds CLI#313

Draft
martinsander00 wants to merge 3 commits intomainfrom
improve-cli-network-defaults
Draft

feat: derive network defaults from -u moniker in shreds CLI#313
martinsander00 wants to merge 3 commits intomainfrom
improve-cli-network-defaults

Conversation

@martinsander00
Copy link
Contributor

@martinsander00 martinsander00 commented Mar 24, 2026

Summary

  • Shreds subcommands (list, pay, payments, price, withdraw) now resolve monikers (-u t, -u m) to DZ Ledger URLs instead of public Solana URLs, since the shred subscription program lives on the DZ Ledger
  • DZ Ledger URL resolution is scoped to shreds only via into_dz_ledger_solana_connection() — non-shreds CLIs (passport, revenue-distribution, validator-debt, etc.) continue using Solana public URLs
  • USDC mint is auto-detected from network environment (mainnet vs development), removing the need for --usdc-mint on testnet
  • Network environment is derived from the moniker directly, skipping the genesis hash RPC query (which misidentifies the DZ Ledger testnet as "Localnet")
  • Default keypair path changed to ~/.config/doublezero/id.json with fallback to ~/.config/solana/id.json

Before:

doublezero-solana shreds --dz-ledger-url https://doublezerolocalnet.rpcpool.com/... \
  withdraw -u https://doublezerolocalnet.rpcpool.com/... \
  --device <key> --client-ip <ip> \
  --keypair .config/doublezero/id.json \
  --usdc-mint uSDZq2RMuxrEf7gqgDjR8wJCtCyaDAQk2e5jLAaoeeM

After:

doublezero-solana shreds withdraw -u t --device <key> --client-ip <ip>

Lines of Code

Section Added Removed
client-tools (moniker env, DZ Ledger connection, keypair fallback, tests) +99/-12
sdk (USDC mint constants) +7/-3
cli (shreds subcommands + changelog) +38/-9

Testing

  • All existing tests pass
  • Added tests for keypair fallback path behavior and moniker_env() resolution
  • Needs manual testing on testnet to verify end-to-end with -u t

When using a moniker like `-u t`, the CLI now automatically resolves the
DZ Ledger URL, USDC mint, and keypair path without requiring explicit
flags. This eliminates the need to pass --dz-ledger-url, --usdc-mint,
and --keypair for standard testnet/mainnet usage.

- Monikers resolve to DZ Ledger URLs (where the program lives)
- USDC mint auto-detected from network (mainnet vs development)
- Network environment derived from moniker, skipping genesis hash query
- Default keypair path changed to ~/.config/doublezero/id.json with
  fallback to ~/.config/solana/id.json
@martinsander00 martinsander00 force-pushed the improve-cli-network-defaults branch from 8421926 to 04239d2 Compare March 25, 2026 16:56
Revert the shared From<SolanaConnectionOptions> impl back to Solana
public URLs so non-shreds CLIs (passport, revenue-distribution, etc.)
are unaffected. Add into_dz_ledger_solana_connection() for shreds
commands. Also fix USDC doc comments and add moniker_env() tests.

// 3. Try default path
// 3. Try default path (~/.config/doublezero/id.json)
match read_keypair_from_path(&default_path) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

make default solana keypair path AND be able to pass -k

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant