Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

Commit d870fd1

Browse files
committed
add chain logo map
1 parent e145382 commit d870fd1

9 files changed

Lines changed: 465 additions & 389 deletions

File tree

.mailmap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
AnhMTV <anhmtv@subwallet.app>
1+
Sam Allen <allencode.dev@icloud.com>

.prettierrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017-2022 @subwallet/base authors & contributors
1+
// Copyright 2025 @bitriel/base authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

44
module.exports = require('@polkadot/dev/config/prettier.cjs');

jest.config.cjs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
// Copyright 2017-2022 @subwallet/base authors & contributors
1+
// Copyright 2025 @bitriel/base authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

44
const config = require('@polkadot/dev/config/jest.cjs');
55

66
module.exports = {
77
...config,
88
moduleNameMapper: {
9-
'@subwallet/base/(.*)$': '<rootDir>/packages/base/src/$1',
10-
'@subwallet/chain-services/(.*)$': '<rootDir>/packages/storage/src/$1',
11-
'@subwallet/controllers/(.*)$': '<rootDir>/packages/storage/src/$1',
12-
'@subwallet/keyring/(.*)$': '<rootDir>/packages/storage/src/$1',
13-
'@subwallet/networks/(.*)$': '<rootDir>/packages/storage/src/$1',
14-
'@subwallet/storage/(.*)$': '<rootDir>/packages/storage/src/$1',
15-
'@subwallet/stream/(.*)$': '<rootDir>/packages/storage/src/$1',
16-
'@subwallet/utils/(.*)$': '<rootDir>/packages/storage/src/$1',
17-
'@subwallet/web2-services/(.*)$': '<rootDir>/packages/storage/src/$1',
18-
'@subwallet/web3-services/(.*)$': '<rootDir>/packages/storage/src/$1'
9+
'@bitriel/base/(.*)$': '<rootDir>/packages/base/src/$1',
10+
'@bitriel/chain-services/(.*)$': '<rootDir>/packages/storage/src/$1',
11+
'@bitriel/controllers/(.*)$': '<rootDir>/packages/storage/src/$1',
12+
'@bitriel/keyring/(.*)$': '<rootDir>/packages/storage/src/$1',
13+
'@bitriel/networks/(.*)$': '<rootDir>/packages/storage/src/$1',
14+
'@bitriel/storage/(.*)$': '<rootDir>/packages/storage/src/$1',
15+
'@bitriel/stream/(.*)$': '<rootDir>/packages/storage/src/$1',
16+
'@bitriel/utils/(.*)$': '<rootDir>/packages/storage/src/$1',
17+
'@bitriel/web2-services/(.*)$': '<rootDir>/packages/storage/src/$1',
18+
'@bitriel/web3-services/(.*)$': '<rootDir>/packages/storage/src/$1'
1919
},
2020
testTimeout: 30000
2121
};

packages/chain-list/src/data/ChainLogoMap.json

Lines changed: 351 additions & 351 deletions
Large diffs are not rendered by default.

publish-gh-pages.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
echo "Updating JSON files to use GitHub Pages URLs..."
55
node scripts/patch/update-icon-urls.js
66
node scripts/patch/update-asset-logo-map.js
7+
node scripts/patch/update-chain-logo-map.js
78

89
# Build the project
910
yarn build

rollup.config.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2017-2022 @subwallet/base authors & contributors
1+
// Copyright 2025 @bitriel/base authors & contributors
22
// SPDX-License-Identifier: Apache-2.0
33

44

@@ -12,11 +12,11 @@ import path from 'path';
1212
import pluginCleanup from 'rollup-plugin-cleanup';
1313

1414
function sanitizePkg(pkg) {
15-
return pkg.replace('@subwallet/', '');
15+
return pkg.replace('@bitriel/', '');
1616
}
1717

1818
function createName(input) {
19-
return `subwallet-${sanitizePkg(input)}`
19+
return `bitriel-${sanitizePkg(input)}`
2020
.toLowerCase()
2121
.replace(/[^a-zA-Z0-9]+(.)/g, (_, c) => c.toUpperCase());
2222
}
@@ -32,7 +32,7 @@ export function createOutput(_pkg, external, globals) {
3232
const pkg = sanitizePkg(_pkg);
3333

3434
return {
35-
file: `packages/${pkg}/build/bundle-subwallet-${pkg}.js`, format: 'umd', globals: external.reduce((all, pkg) => ({
35+
file: `packages/${pkg}/build/bundle-bitriel-${pkg}.js`, format: 'umd', globals: external.reduce((all, pkg) => ({
3636
[pkg]: createName(pkg), ...all
3737
}), {...globals}), intro: 'const global = window;', name: createName(_pkg), preferConst: true
3838
};
@@ -48,13 +48,13 @@ export function createBundle({entries = {}, external, globals = {}, index, injec
4848
}
4949

5050
const pkgs = [
51-
'@subwallet/chain-list',
51+
'@bitriel/chain-list',
5252
];
5353

5454
const external = [...pkgs];
5555

5656
const entries = ['chain-list'].reduce((all, p) => ({
57-
...all, [`@subwallet/${p}`]: path.resolve(process.cwd(), `packages/${p}/build`)
57+
...all, [`@bitriel/${p}`]: path.resolve(process.cwd(), `packages/${p}/build`)
5858
}), {});
5959

6060
const overrides = {};

scripts/patch/copy-local-assets.js

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const __dirname = path.dirname(__filename);
88

99
// Define file paths
1010
const assetLogoMapPath = path.join(__dirname, '../../packages/chain-list/src/data/AssetLogoMap.json');
11+
const chainLogoMapPath = path.join(__dirname, '../../packages/chain-list/src/data/ChainLogoMap.json');
1112
const outputDir = path.join(__dirname, '../../packages/chain-list/build/logo');
1213
const assetsBaseDir = path.join(__dirname, '../../packages/chain-list-assets/public/assets');
1314

@@ -39,23 +40,43 @@ const copyFile = (sourcePath, targetPath) => {
3940
// Main function
4041
const 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
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
// Get __dirname equivalent for ES modules
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = path.dirname(__filename);
8+
9+
// Define the source and destination file paths
10+
const filePath = path.join(__dirname, '../../packages/chain-list/src/data/ChainLogoMap.json');
11+
12+
// The GitHub Pages URL
13+
const GITHUB_PAGES_URL = 'https://bitriel.github.io/BitrielWallet-ChainList/logo';
14+
15+
// Function to update the ChainLogoMap URLs
16+
const updateChainLogoMap = () => {
17+
try {
18+
console.log(`Updating ChainLogoMap.json...`);
19+
20+
// Read the JSON file
21+
const jsonContent = fs.readFileSync(filePath, 'utf8');
22+
const jsonData = JSON.parse(jsonContent);
23+
let modified = false;
24+
25+
// Process each entry in the JSON file
26+
Object.keys(jsonData).forEach(key => {
27+
const url = jsonData[key];
28+
29+
// Check if the URL still points to the old domain
30+
if (url && typeof url === 'string' && url.includes('dev.sw-chain-list-assets.pages.dev')) {
31+
// Extract just the filename from the URL
32+
const fileName = url.split('/').pop();
33+
34+
// Replace the URL with the GitHub Pages URL
35+
if (fileName) {
36+
jsonData[key] = `${GITHUB_PAGES_URL}/${fileName}`;
37+
modified = true;
38+
}
39+
}
40+
});
41+
42+
// Write the updated JSON back to file if modified
43+
if (modified) {
44+
fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 2));
45+
console.log(`Updated ChainLogoMap.json successfully`);
46+
} else {
47+
console.log(`No changes needed for ChainLogoMap.json`);
48+
}
49+
50+
return modified;
51+
} catch (error) {
52+
console.error(`Error updating ChainLogoMap.json:`, error);
53+
return false;
54+
}
55+
};
56+
57+
// Main function
58+
const main = () => {
59+
updateChainLogoMap();
60+
};
61+
62+
main();

tsconfig.base.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"compilerOptions": {
44
"composite": true,
55
"paths": {
6-
"@subwallet/chain-list": ["chain-list/src"],
7-
"@subwallet/chain-list/*": ["chain-list/src/*"]
6+
"@bitriel/chain-list": ["chain-list/src"],
7+
"@bitriel/chain-list/*": ["chain-list/src/*"]
88
},
99
"skipLibCheck": true
1010
}

0 commit comments

Comments
 (0)