Skip to main content

check_approval

Function check_approval 

Source
pub async fn check_approval(
    module_def: &Value,
    auto_approve: bool,
    timeout: Option<u64>,
) -> Result<(), ApprovalError>
Expand description

Gate module execution behind an interactive approval prompt.

Returns Ok(()) immediately if requires_approval is not true. Bypasses the prompt if auto_approve is true or the env var APCORE_CLI_AUTO_APPROVE is set to exactly "1". Returns Err(ApprovalError::NonInteractive) if stdin is not a TTY. Otherwise prompts the user with a per-call timeout.

timeout accepts Option<u64> for cross-SDK parity with Python and TS, which both expose (module_def, auto_approve, timeout) 3-arg signatures. None falls back to DEFAULT_APPROVAL_TIMEOUT_SECS; Some(n) selects an explicit window. Internally delegates to check_approval_with_timeout (Rust convention: _with_* suffix for the concrete-parameter variant).

ยงErrors

  • ApprovalError::NonInteractive โ€” stdin is not an interactive terminal
  • ApprovalError::Denied โ€” user typed anything other than y/yes
  • ApprovalError::Timeout โ€” prompt timed out