Skip to content

refactor(cli): dedup publish chain-coordinate resolution and the submit skeleton #1080

Closed

Description

@alpergundogdu

Follow-up cleanup from the review of #1074 (decdn publish control plane). Two duplications were flagged as non-blocking; capturing them here so they don't drift.

1. resolve_publish is a near-verbatim copy of resolve

crates/cli/src/commands/chain_ctx.rs — resolve_publish duplicates resolve almost line-for-line: the rpc_url / chain_id / data_dir / keystore flag>config>default blocks are identical; only the contract-address fields differ (mandatory capacity_bond_address vs. two optional publisher_registry_address / origin_assignment_address).

The same shape repeats at the args layer: PublishChainArgs duplicates ChainArgs field-for-field (rpc_url, chain_id, keystore, data_dir, keystore_password_file, dry_run, json, config), with only the address flags differing.

Risk: a future precedence/tilde-expansion/env-source change lands in one resolver and is missed in the other, so node and publish commands resolve identical coordinates differently.

Suggested shape: extract a shared base resolver (returning rpc_url/chain_id/keystore/data_dir) that each public resolver layers its addresses onto, and a shared #[command(flatten)] common-flags struct embedded by both ChainArgs and PublishChainArgs.

2. The submit skeleton is copy-pasted across all three publish subcommands

crates/cli/src/commands/publish.rs — namespace_create, claim, and assign each repeat: preflight_chain_id → load_signer_with_password_file → build_provider → set outcome.operator → Contract::new → send/get_receipt/ensure(receipt.status()). register.rs already factors its equivalent into submit_registration; publish has no such helper, and assign additionally inlines the load_optional_config + resolve_publish + parse_address sequence that registry_ctx wraps for the other two.

Risk: a preflight change (gas/balance check, nonce read, guard reordering) must be edited in three near-identical blocks; missing one leaves a subcommand able to submit a doomed or mis-networked tx the others reject.

Suggested shape: a (signer, provider) preflight helper mirroring submit_registration, plus an assignment_ctx parallel to registry_ctx.

Both are net-new-code polish, no behavior change. Out of scope for #1074 by design.

Activity

  1. self-assigned this
    on Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

prio:low

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions