Skip to main content

taskfast_cli/cmd/
platform.rs

1// SPDX-License-Identifier: MIT
2//! `taskfast platform` — read global platform configuration.
3//!
4//! Single verb `config` → `GET /platform/config`. Surface the
5//! chain-agnostic server defaults (fee splits, review windows, supported
6//! tokens, contract addresses) needed before composing EIP-712 payloads
7//! locally.
8
9use clap::{Parser, Subcommand};
10use serde_json::json;
11
12use super::{CmdResult, Ctx};
13use crate::envelope::Envelope;
14
15use taskfast_client::map_api_error;
16
17#[derive(Debug, Subcommand)]
18pub enum Command {
19    /// Fetch the platform configuration snapshot.
20    Config,
21}
22
23#[derive(Debug, Parser)]
24pub struct Args;
25
26pub async fn run(ctx: &Ctx, cmd: Command) -> CmdResult {
27    match cmd {
28        Command::Config => config(ctx).await,
29    }
30}
31
32async fn config(ctx: &Ctx) -> CmdResult {
33    let client = ctx.client()?;
34    let resp = match client.inner().get_platform_config().await {
35        Ok(v) => v.into_inner(),
36        Err(e) => return Err(map_api_error(e).await.into()),
37    };
38    Ok(Envelope::success(
39        ctx.environment,
40        ctx.dry_run,
41        json!({ "config": resp }),
42    ))
43}