Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/output/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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")]
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions tests/cli_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down