-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathpolymarket-apis.ts
More file actions
80 lines (78 loc) · 2.42 KB
/
polymarket-apis.ts
File metadata and controls
80 lines (78 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* Default mock responses for Polymarket API endpoints.
*
* These defaults cover the calls fired by the wallet's Explore tab
* (TrendingView / usePredictMarketData) so that non-predict specs that pass
* through Explore (e.g. via navigateToBrowserView()) don't leak live requests
* to Polymarket. Predict and trending specs override these via
* POLYMARKET_COMPLETE_MOCKS registered as testSpecificMock at higher priority.
*
* clob.polymarket.com is intentionally not covered here — it only fires on
* trade actions, never during Explore render.
*/
/** Single source of truth for geoblock mock (eligible region). Reused in defaults and in POLYMARKET_COMPLETE_MOCKS. */
export const POLYMARKET_GEOBLOCK_ELIGIBLE = {
urlEndpoint: 'https://polymarket.com/api/geoblock',
responseCode: 200,
response: {
blocked: false,
country: 'PT', // Portugal – not in GEO_BLOCKED_COUNTRIES
},
} as const;
export const POLYMARKET_API_MOCKS = {
GET: [
POLYMARKET_GEOBLOCK_ELIGIBLE,
// gamma-api: events pagination — consumer reads `data?.data`
{
urlEndpoint:
/^https:\/\/gamma-api\.polymarket\.com\/events\/pagination(\?.*)?$/,
responseCode: 200,
response: { data: [] },
},
// gamma-api: public-search — consumer reads `data?.events`
{
urlEndpoint:
/^https:\/\/gamma-api\.polymarket\.com\/public-search(\?.*)?$/,
responseCode: 200,
response: { events: [] },
},
// gamma-api: markets list
{
urlEndpoint: /^https:\/\/gamma-api\.polymarket\.com\/markets(\?.*)?$/,
responseCode: 200,
response: [],
},
// polymarket.com: homepage carousel
{
urlEndpoint: 'https://polymarket.com/api/homepage/carousel',
responseCode: 200,
response: [],
},
// polymarket.com: crypto price feed
{
urlEndpoint: /^https:\/\/polymarket\.com\/api\/crypto\/crypto-price.*$/,
responseCode: 200,
response: {},
},
// data-api: positions / activity / upnl
{
urlEndpoint: /^https:\/\/data-api\.polymarket\.com\/positions(\?.*)?$/,
responseCode: 200,
response: [],
},
{
urlEndpoint: /^https:\/\/data-api\.polymarket\.com\/activity(\?.*)?$/,
responseCode: 200,
response: [],
},
{
urlEndpoint: /^https:\/\/data-api\.polymarket\.com\/upnl(\?.*)?$/,
responseCode: 200,
response: [],
},
],
POST: [],
PUT: [],
DELETE: [],
PATCH: [],
};