cast/cmd/tempo.rs
1use clap::Parser;
2use eyre::Result;
3use foundry_common::tempo::{EnsureAccessKeyConfig, ensure_access_key};
4
5/// Tempo wallet integration commands.
6#[derive(Debug, Parser)]
7pub enum TempoSubcommand {
8 /// Authorize a new access key against your Tempo wallet via wallet.tempo.
9 ///
10 /// Persists the key to `$TEMPO_HOME/wallet/keys.toml` (default
11 /// `~/.tempo/wallet/keys.toml`). Also runs automatically on a 402 from a
12 /// Tempo RPC when no local key is configured.
13 ///
14 /// Env: `TEMPO_HOME`, `TEMPO_CLI_AUTH_URL` (override auth service).
15 Login {
16 /// Chain ID to authorize the key for. Defaults to Tempo mainnet (4217).
17 #[arg(long, default_value_t = 4217)]
18 chain_id: u64,
19
20 /// Print the authorization URL to stderr instead of opening a browser.
21 #[arg(long)]
22 no_browser: bool,
23 },
24}
25
26impl TempoSubcommand {
27 pub async fn run(self) -> Result<()> {
28 match self {
29 Self::Login { chain_id, no_browser } => {
30 let mut cfg = EnsureAccessKeyConfig::from_env(chain_id);
31 if no_browser {
32 cfg.no_browser = true;
33 }
34 let outcome = ensure_access_key(cfg).await?;
35 let _ = foundry_common::sh_println!(
36 "Authorized key {} for wallet {} on chain {}",
37 outcome.key_address,
38 outcome.wallet_address,
39 outcome.chain_id,
40 );
41 Ok(())
42 }
43 }
44 }
45}