Skip to content

Commit eaa0c07

Browse files
0x4139dongowu
authored andcommitted
fix: default transport client in clob.NewClient when httpClient is nil
gamma.NewClient and data.NewClient both create a default transport when passed nil, but clob.NewClient stored the nil pointer directly, causing a nil dereference panic on any subsequent API call. Add BaseURL constant and a nil guard matching the gamma/data pattern.
1 parent c508815 commit eaa0c07

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

pkg/clob/constants.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package clob
22

33
const (
4+
// BaseURL is the default production endpoint for the CLOB.
5+
BaseURL = "https://clob.polymarket.com"
6+
47
// DefaultGeoblockHost is the default host for the geoblock endpoint.
58
DefaultGeoblockHost = "https://polymarket.com"
69
)

pkg/clob/impl.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ func NewClientWithGeoblock(httpClient *transport.Client, geoblockHost string) Cl
7171
geoblockHost = DefaultGeoblockHost
7272
}
7373

74+
if httpClient == nil {
75+
httpClient = transport.NewClient(nil, BaseURL)
76+
}
77+
7478
c := &clientImpl{
7579
httpClient: httpClient,
7680
cache: newClientCache(),

0 commit comments

Comments
 (0)