decdn_common/cli/setup.rs
1//! Arguments for the `decdn setup` onboarding wizard (ADR 019 Phases 1–2).
2//!
3//! `setup` is thin orchestration over the existing primitives — `key-gen`,
4//! `node bond`, `node register` — gated by pre-flight checks that catch the
5//! mis-ordered-step / under-funded-wallet failure class ADR 019 § Context
6//! calls out, *before* any transaction is submitted. It introduces no new
7//! on-chain logic of its own (#933).
8
9use clap::Args;
10
11use super::node::ChainArgs;
12
13/// `decdn setup --mbps <N> --region <CC>` — run the operator through Phase 1
14/// pre-flight checks and Phase 2 on-chain setup, then print a go/no-go
15/// readiness summary. The flattened [`ChainArgs`] supplies the same
16/// `--rpc-url` / `--capacity-bond-address` / `--keystore` / `--dry-run` /
17/// `--json` flags as `node bond` / `node register`.
18#[derive(Args, Debug)]
19pub struct SetupArgs {
20 /// Declared serving capacity in Mbps. The TOKEN bond is read on-chain as
21 /// `max(minBond, bondRequired(mbps))` (same as `decdn node bond`); you do
22 /// not pass a token amount. Must fall within the governable
23 /// `[minCapacityMbps, maxCapacityMbps]` band.
24 #[arg(long, value_name = "MBPS")]
25 pub mbps: u64,
26
27 /// ISO 3166-1 alpha-2 country code submitted as the on-chain `regionHint`
28 /// (ADR 030) at registration — e.g. `US`, `DE`. Self-reported.
29 #[arg(long, value_name = "CODE")]
30 pub region: String,
31
32 /// QUIC multiaddr to register, e.g. `/ip4/203.0.113.10/udp/4433/quic-v1`.
33 /// Repeatable. The node listens on the same port over IPv4 and IPv6, so a
34 /// dual-stack host also registers `/ip6/2001:db8::10/udp/4433/quic-v1`.
35 /// Omitted, it defaults to the host's public address on
36 /// `network.bind_port` when the default route has one. A host behind NAT
37 /// registers none, and peers reach it through the relay; pass the
38 /// forwarded address here if UDP `network.bind_port` is forwarded.
39 #[arg(long = "multiaddr", value_name = "MA")]
40 pub multiaddrs: Vec<String>,
41
42 /// Skip the interactive confirmation of the bond amount and submit without
43 /// prompting (for non-interactive / CI use). The keystore password still
44 /// comes from `DECDN_KEYSTORE_PASSWORD` / `--keystore-password-file`.
45 #[arg(long)]
46 pub yes: bool,
47
48 /// Accept the network's current operator terms non-interactively (ADR 019
49 /// § Terms Acceptance). Separate from `--yes` (which only skips the bond
50 /// confirmation): terms acceptance is always its own explicit act. On a
51 /// terminal the terms are shown and confirmed interactively instead.
52 #[arg(long = "accept-terms")]
53 pub accept_terms: bool,
54
55 /// Chain coordinates: RPC endpoint, contract addresses, and keystore.
56 #[command(flatten)]
57 pub chain: ChainArgs,
58}