Skip to main content

Module chain_ctx

Module chain_ctx 

Source
Expand description

Shared plumbing for the on-chain node subcommands (register, bond).

Resolves the blockchain coordinates (flag > [blockchain]/[identity] TOML config > default) and loads the operator’s keystore signer. Commands then build a wallet-filled provider with decdn_client::provider::build_provider and construct their CapacityBond instance against it.

Structs§

FileConfig
Partial deserializer for the TOML config — only the [blockchain], [identity], and network.bind_port fields these commands need. Deliberately partial (like node.rs’s AdminPortConfig) so an operator’s typo in an unrelated section can’t block onboarding; serde-toml ignores unknown fields.
Resolved
Coordinates resolved from flags > config file > defaults.
ResolvedAppeal
Coordinates for decdn appeal slash, resolved from flags > config > defaults. Requires rpc_url + slash_appeal_address; unlike Resolved it does not require capacity_bond_address (the appeal path doesn’t touch CapacityBond directly).
ResolvedPublish
Publisher-command coordinates resolved from flags > config > defaults. The two contract addresses are optional here; each subcommand requires only the one it targets and errors with a specific message if it is unset.

Functions§

load_operator_signer
Load the operator’s Ethereum keystore signer, sourcing the password per password_sources — the same precedence the daemon uses.
load_optional_config
Load the partial config from config_path (or the --config flag folded in by the caller). An explicit path that is missing/unreadable is an error; the default path simply falls through to an empty config (every field can also come from a flag).
load_signer_with_password_file
Load an Ethereum keystore signer, sourcing the password per password_sources. The scrypt KDF is offloaded to spawn_blocking so it doesn’t stall the async executor.
parse_address
Parse a contract/account address with a labelled error.
parse_nonzero_address
Parse a contract address and reject the zero address. Address::ZERO parses cleanly but is never a real deployment — it would surface only as an opaque on-chain revert at call time, so reject it here with a clear, labelled error.
resolve
Resolve the chain coordinates with flag > config > default precedence. Pure so the precedence is unit-testable.
resolve_appeal
Resolve appeal-command coordinates. Pure so precedence is unit-testable. slash_appeal_flag is the command’s --slash-appeal-address override.
resolve_publish
Resolve publisher-command coordinates. Pure so precedence is unit-testable.