Add CHALLENGE-CLG Logo (#2316)

* Add CHALLENGE-CLG Logo

* Add script that moves file to correct location

Co-authored-by: Mykola <kolya182@gmail.com>
This commit is contained in:
CHALLENG-CLG 2020-06-11 04:43:17 +06:00 committed by GitHub
parent 18aaf49f1a
commit 20bb9c155c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -1,21 +1,24 @@
import * as fs from "fs"
const isImage = require("is-image");
import {
Ethereum,
chainsFolderPath,
ethSidechains,
getChainAssetPath,
getChainAssetsPath,
getChainPath,
getFileExt,
getFileName,
getRootDirFilesList,
isChecksum,
isEthereumAddress,
isPathDir,
logo,
logoExtension,
makeDirIfDoestExist,
readDirSync,
toChecksum,
getRootDirFilesList,
rootDirAllowedFiles,
isEthereumAddress
toChecksum,
} from "../src/test/helpers"
ethSidechains.forEach(chain => {
@ -49,3 +52,20 @@ getRootDirFilesList().forEach(async file => {
fs.renameSync(`./${file}`, `${ethreumAssetsPath}/${checksum}/${logo}`)
}
});
// Moves blockchains/0xXX...XX.png => assets/blockchains/ethereum/0xXX...XX/logo.png
readDirSync(chainsFolderPath).forEach(async chainFile => {
const chainPath = getChainPath(chainFile)
const isDir = isPathDir(chainPath)
if (!isDir) {
const checksum = toChecksum(getFileName(chainFile))
const chainAssetsPath = getChainAssetsPath(Ethereum)
if (isChecksum(checksum) && getFileExt(chainFile).toLocaleLowerCase() === logoExtension) {
await makeDirIfDoestExist(chainAssetsPath, checksum)
const newPath = `${chainAssetsPath}/${checksum}/${logo}`
fs.renameSync(chainPath, newPath)
}
}
})

View File

@ -106,7 +106,7 @@ export const isChecksum = (address: string): boolean => web3.utils.checkAddressC
export const toChecksum = (address: string): string => web3.utils.toChecksumAddress(address)
export const getBinanceBEP2Symbols = async () => axios.get(`https://dex-atlantic.binance.org/api/v1/tokens?limit=1000`).then(res => res.data.map(({ symbol }) => symbol))
export const getFileName = (fileName: string): string => path.basename(fileName, path.extname(fileName))
export const getFileName = (name: string): string => path.basename(name, path.extname(name))
export const getFileExt = (name: string): string => name.slice((Math.max(0, name.lastIndexOf(".")) || Infinity) + 1)
export const isTRC10 = (str: string): boolean => (/^\d+$/.test(str))

View File

@ -125,7 +125,7 @@ describe(`Test "blockchains" folder`, () => {
})
describe(`Check "binace" folder`, () => {
it("Asset must exist on chain and", async () => {
it("Asset must exist on chain", async () => {
const tokenSymbols = await getBinanceBEP2Symbols()
const assets = readDirSync(getChainAssetsPath(Binance))