Skip to main content

Ctx

Struct Ctx 

Source
pub struct Ctx {
Show 13 fields pub api_key: Option<String>, pub environment: Environment, pub api_base: Option<String>, pub config_path: PathBuf, pub wallet_address: Option<String>, pub keystore_path: Option<PathBuf>, pub confirm_above_budget: Option<String>, pub log_format: Option<String>, pub approval_horizon: Option<Duration>, pub receipt_timeout: Option<Duration>, pub dry_run: bool, pub quiet: bool, pub allow_custom_endpoints: bool,
}
Expand description

Shared invocation context threaded through every subcommand.

Built once in main from parsed global flags; subcommands only read.

Fields§

§api_key: Option<String>§environment: Environment§api_base: Option<String>

Explicit --api-base / TASKFAST_API override. Wins over Environment::api_base when set. Never persisted — the in-memory override is session-scoped only.

§config_path: PathBuf

Resolved path to the JSON config file (default ./.taskfast/config.json, override via --config / TASKFAST_CONFIG). Subcommands that persist state (init, config set, etc.) write here; tests construct this directly.

§wallet_address: Option<String>

Poster wallet address from config — fallback when no flag/env set on post/settle/escrow sign. Persisted by taskfast init.

§keystore_path: Option<PathBuf>

Keystore path from config — fallback for the same trio.

§confirm_above_budget: Option<String>

Stablecoin-units threshold above which mutating commands (post, settle) require an explicit --yes. None = gate disabled. Set via confirm_above_budget in the JSON config.

§log_format: Option<String>

Default log format for --verbose output. None = text. Set via log_format in the JSON config or TASKFAST_LOG_FORMAT env.

§approval_horizon: Option<Duration>

Poster approval-deadline horizon for escrow sign. Parsed from the config file’s approval_horizon at startup (fail-fast on malformed values). None = built-in default (7 days). The --approval-horizon flag / TASKFAST_APPROVAL_HORIZON env still win over this.

§receipt_timeout: Option<Duration>

Receipt-polling ceiling for escrow sign. Parsed from the config file’s receipt_timeout at startup. None = network-aware default (3min mainnet, 1min testnet). --receipt-timeout / TASKFAST_RECEIPT_TIMEOUT still win over this.

§dry_run: bool§quiet: bool§allow_custom_endpoints: bool

F2 opt-in: allow a custom api_base or tempo_rpc_url that isn’t one of the well-known TaskFast defaults. Plumbed through to subcommands (notably post) that construct their own network clients outside the TaskFastClient covered by the Ctx-level guard.

Implementations§

Source§

impl Ctx

Source

pub fn from_parts( cli_api_key: Option<String>, cli_env: Option<Environment>, cli_api_base: Option<String>, cli_config_path: Option<PathBuf>, cli_dry_run: bool, cli_quiet: bool, cli_allow_custom_endpoints: bool, cfg: &Config, ) -> Result<Self, CmdError>

Build a Ctx by layering CLI flags (including clap’s env-var folding) over the on-disk Config. Precedence:

flag > env var > config file > default

Clap already folds flag > env var for each field (via #[arg(env = "…")]), so the merge here is just “cli wins, else config, else default”. dry_run and quiet are never persisted — they’re invocation-scoped.

Source

pub fn security_warnings(&self) -> Vec<SecurityWarning>

F15: gather non-fatal security warnings derived from the effective runtime state. Computed at emit time (not at construction) so subcommand-induced signals can be folded in here if needed later. Always safe to call — never allocates for a healthy run.

Source

pub fn base_url(&self) -> &str

Resolved API base URL: override if set, else env default.

Source

pub fn client(&self) -> Result<TaskFastClient, CmdError>

Build an authenticated client, or fail with CmdError::MissingApiKey if no key was supplied (via --api-key or TASKFAST_API_KEY).

Source

pub fn rpc_http_client(&self, client: &TaskFastClient, rpc_url: &str) -> Client

Pick the reqwest client to use for a JSON-RPC URL.

Any URL whose prefix is {api_base}/rpc/ is this deployment’s authenticated proxy and must be hit with the X-API-Key-bearing client; otherwise the proxy short-circuits with 401 “missing API key” before reaching the upstream RPC. Anything else (a bare upstream Tempo gateway via --rpc-url/TEMPO_RPC_URL) gets a fresh client with no TaskFast headers.

This is selected by URL prefix, not by which resolution branch the URL came from, so a user who points --rpc-url / TEMPO_RPC_URL at the proxy still gets the authenticated client.

Source

pub fn enforce_budget_gate( &self, budget: Option<&str>, yes: bool, verb: &str, ) -> Result<(), CmdError>

Fail-closed budget gate. When confirm_above_budget is set in the config, any mutation whose budget exceeds it must be opted into via --yes. By design there’s no TTY prompt — automation-first stays intact; the gate just stops a fat-finger script before it broadcasts an oversized ERC-20 approve. verb is the action (“post a task”, “settle this task”) for the error message.

Trait Implementations§

Source§

impl Clone for Ctx

Source§

fn clone(&self) -> Ctx

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Ctx

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Ctx

§

impl RefUnwindSafe for Ctx

§

impl Send for Ctx

§

impl Sync for Ctx

§

impl Unpin for Ctx

§

impl UnsafeUnpin for Ctx

§

impl UnwindSafe for Ctx

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more