@@ -17,27 +17,30 @@ pub struct CoinGeckoPriceAPIClient {
1717
1818const DEFAULT_COINGECKO_API_URL : & str = "https://pro-api.coingecko.com" ;
1919const COINGECKO_AUTH_HEADER : & str = "x-cg-pro-api-key" ;
20+ const USER_AGENT_HEADER : & str = "User-Agent" ;
21+ const USER_AGENT_VALUE : & str = "zksync-era-node/0.1 (https://github.com/matter-labs/zksync-era)" ;
2022const ETH_ID : & str = "eth" ;
2123const ZKSYNC_ID : & str = "zksync" ;
2224
2325impl CoinGeckoPriceAPIClient {
2426 pub fn new ( config : ExternalPriceApiClientConfig ) -> Self {
25- let client = if let Some ( api_key) = & config. api_key {
26- let mut headers = reqwest:: header:: HeaderMap :: new ( ) ;
27+ let mut headers = reqwest:: header:: HeaderMap :: new ( ) ;
28+ headers. insert (
29+ reqwest:: header:: HeaderName :: from_static ( USER_AGENT_HEADER ) ,
30+ reqwest:: header:: HeaderValue :: from_static ( USER_AGENT_VALUE ) ,
31+ ) ;
32+ if let Some ( api_key) = & config. api_key {
2733 headers. insert (
2834 reqwest:: header:: HeaderName :: from_static ( COINGECKO_AUTH_HEADER ) ,
2935 reqwest:: header:: HeaderValue :: from_str ( api_key)
3036 . expect ( "Failed to create header value" ) ,
3137 ) ;
32-
33- reqwest:: Client :: builder ( )
34- . default_headers ( headers)
35- . timeout ( config. client_timeout )
36- . build ( )
37- . expect ( "Failed to build reqwest client" )
38- } else {
39- reqwest:: Client :: new ( )
40- } ;
38+ }
39+ let client = reqwest:: Client :: builder ( )
40+ . default_headers ( headers)
41+ . timeout ( config. client_timeout )
42+ . build ( )
43+ . expect ( "Failed to build reqwest client" ) ;
4144
4245 let base_url = config
4346 . base_url
0 commit comments