@@ -140,6 +140,7 @@ export interface TokenRatesState extends BaseState {
140
140
141
141
const CoinGeckoApi = {
142
142
BASE_URL : 'https://api.coingecko.com/api/v3' ,
143
+ headers : { 'X-Requested-With' : 'metamask.dec.jan.2024' } ,
143
144
getTokenPriceURL ( chainSlug : string , query : string ) {
144
145
return `${ this . BASE_URL } /simple/token_price/${ chainSlug } ?${ query } ` ;
145
146
} ,
@@ -380,7 +381,9 @@ export class TokenRatesController extends PollingControllerV1<
380
381
) : Promise < CoinGeckoResponse > {
381
382
const tokenPairs = tokenAddresses . join ( ',' ) ;
382
383
const query = `contract_addresses=${ tokenPairs } &vs_currencies=${ vsCurrency . toLowerCase ( ) } ` ;
383
- return handleFetch ( CoinGeckoApi . getTokenPriceURL ( chainSlug , query ) ) ;
384
+ return handleFetch ( CoinGeckoApi . getTokenPriceURL ( chainSlug , query ) , {
385
+ headers : CoinGeckoApi . headers ,
386
+ } ) ;
384
387
}
385
388
386
389
/**
@@ -399,6 +402,7 @@ export class TokenRatesController extends PollingControllerV1<
399
402
if ( now - timestamp > threshold ) {
400
403
const currencies = await handleFetch (
401
404
CoinGeckoApi . getSupportedVsCurrencies ( ) ,
405
+ { headers : CoinGeckoApi . headers } ,
402
406
) ;
403
407
this . supportedVsCurrencies = {
404
408
data : currencies ,
@@ -426,7 +430,9 @@ export class TokenRatesController extends PollingControllerV1<
426
430
const now = Date . now ( ) ;
427
431
428
432
if ( now - timestamp > threshold ) {
429
- const platforms = await handleFetch ( CoinGeckoApi . getPlatformsURL ( ) ) ;
433
+ const platforms = await handleFetch ( CoinGeckoApi . getPlatformsURL ( ) , {
434
+ headers : CoinGeckoApi . headers ,
435
+ } ) ;
430
436
this . supportedChains = {
431
437
data : platforms ,
432
438
timestamp : Date . now ( ) ,
0 commit comments