@@ -8,7 +8,9 @@ const USE_CACHE = (process.env.USE_CACHE ?? 'true') === 'true'
88
99const cowListUrl = 'https://files.cow.fi/tokens/CowSwap.json'
1010// const coinGeckoListUrl = "https://files.cow.fi/tokens/CoinGecko.json";
11- const coinGeckoIdListUrl = 'https://api.coingecko.com/api/v3/coins/list'
11+ const coinGeckoCoinsUrl = 'https://api.coingecko.com/api/v3/coins'
12+ const coinGeckoCoinsQuoteParams = `localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false`
13+ const coinGeckoIdListUrl = `${ coinGeckoCoinsUrl } /list`
1214
1315const LIST_DIR = path . join ( 'src' , 'cowFi' )
1416
@@ -123,10 +125,10 @@ async function getStaticData(idsData) {
123125
124126 let index = 0
125127 const totalTokens = idsData . length + 1
128+
126129 while ( index < idsData . length ) {
127130 const idItem = idsData [ index ]
128- const quoteParams = `localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false`
129- const url = `https://api.coingecko.com/api/v3/coins/${ idItem . id } ?${ quoteParams } `
131+ const url = `${ coinGeckoCoinsUrl } /${ idItem . id } ?${ coinGeckoCoinsQuoteParams } `
130132
131133 console . log ( `[${ index + 1 } /${ totalTokens } ] Fetching data for ID: ${ idItem . id } ` )
132134
@@ -182,13 +184,22 @@ async function getStaticDataFinal(data) {
182184
183185 // Filter current static list with only tokens from our 2 exists list
184186 const filtered = parsed . filter ( ( { platforms, description, id } ) => {
185- return (
186- description ?. en ?. trim ( ) . length &&
187- ! TOKENS_TO_REMOVE . includes ( id ) &&
188- Object . entries ( platforms ) . some (
189- ( [ chain , address ] ) => combined_ids [ address . toLowerCase ( ) ] && [ 'ethereum' , 'xdai' ] . includes ( chain ) ,
187+ if ( ! description ?. en ?. trim ( ) . length || TOKENS_TO_REMOVE . includes ( id ) || ! platforms ) {
188+ return false
189+ }
190+
191+ return Object . entries ( platforms ) . some ( ( [ chain , address ] ) => {
192+ if ( typeof address !== 'string' || ! address ) {
193+ console . warn (
194+ `Platform entry for chain="${ chain } " has no address. Skipping... Debug URL: ${ coinGeckoCoinsUrl } /${ id } ?${ coinGeckoCoinsQuoteParams } ` ,
195+ )
196+ return false
197+ }
198+
199+ return (
200+ combined_ids [ address . toLowerCase ( ) ] && [ 'ethereum' , 'xdai' ] . includes ( chain )
190201 )
191- )
202+ } )
192203 } )
193204
194205 // Sort the data by market cap and take limit the list
0 commit comments