mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
ca2e0ced46
* Upload LOGO * move Co-authored-by: esmeraldz <64386988+esmeraldz@users.noreply.github.com>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import * as fs from "fs"
|
|
const isImage = require("is-image");
|
|
import {
|
|
ethSidechains,
|
|
getChainAssetPath,
|
|
getChainAssetsPath,
|
|
getFileExt,
|
|
getFileName,
|
|
isChecksum,
|
|
isPathDir,
|
|
logo,
|
|
logoExtension,
|
|
makeDirIfDoestExist,
|
|
readDirSync,
|
|
toChecksum,
|
|
getRootDirFilesList,
|
|
rootDirAllowedFiles,
|
|
isEthereumAddress
|
|
} from "../src/test/helpers"
|
|
|
|
ethSidechains.forEach(chain => {
|
|
const chainAssetsPath = getChainAssetsPath(chain)
|
|
|
|
readDirSync(chainAssetsPath).forEach(async asset => {
|
|
const assetPath = getChainAssetPath(chain, asset)
|
|
const isDir = await isPathDir(assetPath)
|
|
|
|
if (!isDir) {
|
|
const checksum = toChecksum(getFileName(asset))
|
|
|
|
if (isChecksum(checksum) && getFileExt(asset).toLocaleLowerCase() === logoExtension) {
|
|
// Moves file like blockchains/<chain>/assets/0x..XX.png => blockchains/<chain>/asstes/0x..XX/logo.png
|
|
await makeDirIfDoestExist(chainAssetsPath, checksum)
|
|
const newPath = `${chainAssetsPath}/${checksum}/${logo}`
|
|
fs.renameSync(assetPath, newPath)
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
// Moves assets/0xXX...XX.png => assets/blockchains/assets/0xXX...XX/logo.png
|
|
getRootDirFilesList().forEach(async file => {
|
|
const fileName = getFileName(file)
|
|
if(isImage(file) && !rootDirAllowedFiles.includes(file) && isEthereumAddress(fileName)) {
|
|
console.log({file})
|
|
const checksum = toChecksum(fileName)
|
|
const ethreumAssetsPath = getChainAssetsPath("ethereum")
|
|
await makeDirIfDoestExist(ethreumAssetsPath, checksum)
|
|
fs.renameSync(`./${file}`, `${ethreumAssetsPath}/${checksum}/${logo}`)
|
|
}
|
|
});
|