diff --git a/src/output/data.rs b/src/output/data.rs index 2b4b7c0..92fd597 100644 --- a/src/output/data.rs +++ b/src/output/data.rs @@ -246,6 +246,12 @@ pub fn print_trades(trades: &[Trade], output: &OutputFormat) -> anyhow::Result<( Ok(()) } +/// Renders on-chain activity records to the configured output format. +/// +/// In JSON mode, all fields from the [`Activity`] struct are included — +/// notably `side`, `price`, `outcome`, `outcome_index`, `condition_id`, +/// `slug`, and `asset` which are required to distinguish buy/sell trades +/// and identify the market and outcome for non-CLOB activity records. pub fn print_activity(activity: &[Activity], output: &OutputFormat) -> anyhow::Result<()> { match output { OutputFormat::Table => { @@ -257,8 +263,14 @@ pub fn print_activity(activity: &[Activity], output: &OutputFormat) -> anyhow::R struct Row { #[tabled(rename = "Type")] activity_type: String, + #[tabled(rename = "Side")] + side: String, #[tabled(rename = "Market")] title: String, + #[tabled(rename = "Outcome")] + outcome: String, + #[tabled(rename = "Price")] + price: String, #[tabled(rename = "Size")] size: String, #[tabled(rename = "USDC")] @@ -291,6 +303,13 @@ pub fn print_activity(activity: &[Activity], output: &OutputFormat) -> anyhow::R "timestamp": a.timestamp, "transaction_hash": a.transaction_hash.to_string(), "proxy_wallet": a.proxy_wallet.to_string(), + "side": a.side.as_ref().map(|s| s.to_string()), + "price": a.price.as_ref().map(|p| p.to_string()), + "asset": a.asset.as_ref().map(|asset| asset.to_string()), + "outcome": a.outcome, + "outcome_index": a.outcome_index, + "condition_id": a.condition_id.as_ref().map(|c| c.to_string()), + "slug": a.slug, }) }) .collect(); diff --git a/tests/cli_integration.rs b/tests/cli_integration.rs index 41d3d11..65d2256 100644 --- a/tests/cli_integration.rs +++ b/tests/cli_integration.rs @@ -67,6 +67,26 @@ fn events_help_lists_subcommands() { .and(predicate::str::contains("tags")), ); } +#[test] +fn data_activity_help_shows_subcommand() { + polymarket() + .args(["data", "activity", "--help"]) + .assert() + .success() + .stdout( + predicate::str::contains("address") + .and(predicate::str::contains("limit")) + .and(predicate::str::contains("offset")), + ); +} + +#[test] +fn data_activity_requires_address() { + polymarket() + .args(["data", "activity"]) + .assert() + .failure(); +} #[test] fn wallet_help_lists_subcommands() {