fix(toolkit): contract-address --untagged handling and stdout cleanliness (#1402)#1486
Draft
m2ux wants to merge 4 commits into
Draft
fix(toolkit): contract-address --untagged handling and stdout cleanliness (#1402)#1486m2ux wants to merge 4 commits into
m2ux wants to merge 4 commits into
Conversation
Initial empty commit to open a draft PR tracking work on the toolkit `contract-address` --untagged option deprecation warning. Refs #1402 Signed-off-by: Mike Clay <mike.clay@shielded.io>
- Hide the deprecated --untagged flag from --help via `hide = true`. - Declare --tagged and --untagged as `conflicts_with` so passing both is a clap parse error rather than a silent "tagged wins" outcome. - Replace the eprintln! deprecation warning with log::warn! so it participates in the toolkit's logging contract (RUST_LOG, --quiet, --verbose), matching the show-address sister-command pattern. - Update the inline unit test to set `untagged: false` for the tagged case (the field has no runtime effect under --tagged and the new conflict relation makes `tagged: true, untagged: true` semantically inconsistent at the CLI layer). Refs: #1402 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Mike Clay <mike.clay@shielded.io>
Establish the tests/cmd/ directory (picked up by the existing trycmd glob in tests/cli_tests.rs) and add five snapshot cases covering the contract-address subcommand's output discipline: - contract-address-help.toml: --help no longer advertises --untagged. - contract-address-default.toml: no-flag path emits the bare untagged address on stdout and empty stderr. - contract-address-tagged.toml: --tagged emits the tagged hex form on stdout and empty stderr. - contract-address-untagged-deprecated.toml: --untagged still works (writes the untagged address on stdout) but emits the log::warn deprecation line on stderr. - contract-address-tagged-untagged-conflict.toml: passing both flags is rejected by clap with exit code 2. Refs: #1402 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: Mike Clay <mike.clay@shielded.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Align
midnight-node-toolkit contract-addresshelp output with runtime behaviour. Hide the deprecated--untaggedflag from--help, move its deprecation warning fromeprintln!tolog::warn!so it participates in the toolkit's logging contract (RUST_LOG,--quiet,--verbose), and reject--tagged --untaggedat parse time viaconflicts_with. Success path now emits empty stderr, matching theshow-addresssister-command pattern.🐛 Issue 📐 Engineering
Jira: PM-19934
Motivation
The toolkit
contract-addresscommand advertises an--untaggedoption in its--helpoutput, but the implementation already moved to untagged-by-default. Passing--untaggedemitsWarning: \--untagged` flag is deprecated (now default)viaeprintln!on stderr while still returning the same address--no-flagwould have returned. Help text and runtime behaviour disagree, and the warning channel bypasses the toolkit'stracing_subscriberlogging contract — so it is not suppressible viaRUST_LOG, not gated by--quiet`, and does not pick up the standard log prefix. Downstream consumers that merge stdout/stderr observe the warning mixed in with the address.The sister command
show-addressalready handles its own deprecated alias (--unshielded-user-address-untagged) cleanly by pairingconflicts_withdeclarations on the current and deprecated flags and emittinglog::warn!only when the deprecated alias is selected. This PR bringscontract-addressinto alignment with that pattern.Changes
Implementation (Path A — backward-compatible cleanup):
ContractAddressArgs::untaggedwithhide = trueso it disappears from--helpwhile remaining parseable for existing callersconflicts_withdeclarations between--taggedand--untaggedso passing both is a clap parse error rather than a silent "tagged wins" outcomeeprintln!deprecation warning withlog::warn!matching theshow-addressidiom; the warning is now suppressible viaRUST_LOG=errorand picks up the standard toolkit log prefixtrycmdsnapshot tests underutil/toolkit/tests/cmd/covering: (a)--helpdoes not advertise--untagged, (b) success path emits empty stderr, (c)--untaggedalone still works but logs a warning, (d)--tagged --untaggedis rejected by clapchanges/toolkit/changed/contract-address-untagged-flag-cleanup.mdchange-file entryThe
--taggedalternative output mode and the default-no-flag output are unchanged. Path B (full flag removal) was considered and rejected for this Low-priority UX bug on external-caller-risk grounds; see the linked Engineering README for the design rationale.📌 Submission Checklist
🔱 Fork Strategy
🗹 TODO before merging
Closes #1402