@@ -8,6 +8,7 @@ const __dirname = path.dirname(__filename);
88
99// Define file paths
1010const assetLogoMapPath = path . join ( __dirname , '../../packages/chain-list/src/data/AssetLogoMap.json' ) ;
11+ const chainLogoMapPath = path . join ( __dirname , '../../packages/chain-list/src/data/ChainLogoMap.json' ) ;
1112const outputDir = path . join ( __dirname , '../../packages/chain-list/build/logo' ) ;
1213const assetsBaseDir = path . join ( __dirname , '../../packages/chain-list-assets/public/assets' ) ;
1314
@@ -39,23 +40,43 @@ const copyFile = (sourcePath, targetPath) => {
3940// Main function
4041const main = async ( ) => {
4142 try {
42- // Read the AssetLogoMap.json
43+ // First process AssetLogoMap.json
44+ console . log ( "Processing AssetLogoMap.json..." ) ;
4345 const assetLogoMapContent = fs . readFileSync ( assetLogoMapPath , 'utf8' ) ;
4446 const assetLogoMap = JSON . parse ( assetLogoMapContent ) ;
4547
4648 console . log ( `Found ${ Object . keys ( assetLogoMap ) . length } asset logo entries` ) ;
4749
48- // Process each asset logo file
50+ // Now process ChainLogoMap.json
51+ console . log ( "Processing ChainLogoMap.json..." ) ;
52+ const chainLogoMapContent = fs . readFileSync ( chainLogoMapPath , 'utf8' ) ;
53+ const chainLogoMap = JSON . parse ( chainLogoMapContent ) ;
54+
55+ console . log ( `Found ${ Object . keys ( chainLogoMap ) . length } chain logo entries` ) ;
56+
57+ // Combine both maps for processing
58+ const combinedLogoMap = { ...assetLogoMap , ...chainLogoMap } ;
59+
60+ // Process each logo file
4961 const operations = [ ] ;
5062 let count = 0 ;
5163
52- for ( const [ assetKey , logoUrl ] of Object . entries ( assetLogoMap ) ) {
53- // Extract the filename and path components from the URL
54- // Example URL: https://dev.sw-chain-list-assets.pages.dev/assets/chain-assets/selendra-native-sel.png
55- const urlPath = new URL ( logoUrl ) . pathname ;
56- const pathParts = urlPath . split ( '/' ) ;
57- const fileName = pathParts . pop ( ) ; // Get filename
64+ for ( const [ key , logoUrl ] of Object . entries ( combinedLogoMap ) ) {
65+ // Only process URLs that point to our GitHub Pages
66+ if ( ! logoUrl . includes ( 'bitriel.github.io' ) ) {
67+ continue ;
68+ }
5869
70+ // Extract the filename from the URL
71+ const fileName = logoUrl . split ( '/' ) . pop ( ) ;
72+ const targetPath = path . join ( outputDir , fileName ) ;
73+
74+ // Skip if the target file already exists
75+ if ( fs . existsSync ( targetPath ) ) {
76+ // console.log(`Skipping ${fileName} (already exists in target)`);
77+ continue ;
78+ }
79+
5980 // Possible source locations (in order of preference)
6081 const possiblePaths = [
6182 path . join ( assetsBaseDir , 'chain-assets' , fileName ) ,
@@ -66,14 +87,6 @@ const main = async () => {
6687 path . join ( assetsBaseDir , fileName ) // For default.png
6788 ] ;
6889
69- const targetPath = path . join ( outputDir , fileName ) ;
70-
71- // Skip if the target file already exists
72- if ( fs . existsSync ( targetPath ) ) {
73- console . log ( `Skipping ${ fileName } (already exists in target)` ) ;
74- continue ;
75- }
76-
7790 // Find the first existing source file
7891 const sourcePath = possiblePaths . find ( p => fs . existsSync ( p ) ) ;
7992
@@ -96,7 +109,7 @@ const main = async () => {
96109 // Wait for all operations to complete
97110 await Promise . all ( operations ) ;
98111
99- console . log ( `Copied ${ count } asset logo files` ) ;
112+ console . log ( `Copied ${ count } logo files` ) ;
100113 } catch ( error ) {
101114 console . error ( 'Error:' , error ) ;
102115 }
0 commit comments