1use foundry_cli::{
7 ExitCode,
8 introspect::{
9 Capabilities, CommandMeta, CommandRegistry, ExitCodeInfo, OutputMode, RegistryEntry,
10 SideEffects,
11 },
12};
13use std::borrow::Cow;
14
15pub const CALL_RESULT_SCHEMA: &str = "foundry:cast.call@v1";
17
18static CALL_EXIT_CODES: &[ExitCodeInfo] = &[
22 ExitCodeInfo {
23 code: ExitCode::Success.to_i32(),
24 name: Cow::Borrowed(ExitCode::Success.name()),
25 description: Cow::Borrowed("Call succeeded; envelope `success: true` with raw hex."),
26 },
27 ExitCodeInfo {
28 code: ExitCode::GenericError.to_i32(),
29 name: Cow::Borrowed(ExitCode::GenericError.name()),
30 description: Cow::Borrowed(
31 "Unclassified failure outside the typed paths (envelope `cli.unknown`).",
32 ),
33 },
34 ExitCodeInfo {
35 code: ExitCode::Usage.to_i32(),
36 name: Cow::Borrowed(ExitCode::Usage.name()),
37 description: Cow::Borrowed(
38 "Flag combination rejected under `--machine` (envelope `cli.usage.invalid`).",
39 ),
40 },
41 ExitCodeInfo {
42 code: ExitCode::Network.to_i32(),
43 name: Cow::Borrowed(ExitCode::Network.name()),
44 description: Cow::Borrowed(
45 "Provider construction or `eth_call` failed (envelope `network.rpc.error`).",
46 ),
47 },
48 ExitCodeInfo {
49 code: ExitCode::User.to_i32(),
50 name: Cow::Borrowed(ExitCode::User.name()),
51 description: Cow::Borrowed("Wallet / keystore resolution failed in non-interactive setup."),
52 },
53];
54
55static ENTRIES: &[RegistryEntry] = &[RegistryEntry {
56 path: &["call"],
57 meta: CommandMeta {
58 command_id: Some("cast.call"),
59 capabilities: Capabilities {
60 output_mode: OutputMode::Envelope,
61 result_schema_ref: Some(Cow::Borrowed(CALL_RESULT_SCHEMA)),
62 event_schema_ref: None,
63 session_schema_ref: None,
64 reads_stdin: false,
65 supports_output_path: false,
66 requires_project: false,
67 side_effects: SideEffects::Network,
68 long_running: false,
69 stateful: false,
70 },
71 capabilities_declared: true,
72 exit_codes: CALL_EXIT_CODES,
73 },
74}];
75
76pub const REGISTRY: CommandRegistry = CommandRegistry::new(ENTRIES);