Skip to main content

polyoxide_data/api/
approvals.rs

1use polyoxide_core::{HttpClient, QueryBuilder, Request};
2
3use crate::{error::DataApiError, types::ApprovalsResponse};
4
5/// Approvals namespace (`/v1/approvals`).
6///
7/// # Upstream status
8///
9/// As of 2026-08-15 the route is deployed but non-functional: it returns
10/// `400` when `user` is missing (so the route exists and validates) yet
11/// `{"error":"internal server error"}` with HTTP 500 for **every** valid
12/// address tried, including active wallets. The client is modelled from the
13/// published spec and covered by mock tests; there is deliberately no live
14/// test, because `nightly-behavioral.yml` runs `--ignored` tests and a
15/// permanently red one would file a tracking issue every night.
16///
17/// Add a live test once upstream starts returning `200`.
18#[derive(Clone)]
19pub struct ApprovalsApi {
20    pub(crate) http_client: HttpClient,
21}
22
23impl ApprovalsApi {
24    /// Get token approval state for a wallet (`GET /v1/approvals`).
25    ///
26    /// Reports whether the wallet has granted the approvals Polymarket needs,
27    /// so a client can prompt for the missing ones instead of reading each
28    /// allowance onchain. Every tracked token and spender pair is returned,
29    /// including pairs the wallet has never approved.
30    pub fn get(&self, user_address: impl Into<String>) -> Request<ApprovalsResponse, DataApiError> {
31        Request::new(self.http_client.clone(), "/v1/approvals").query("user", user_address.into())
32    }
33}