mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Upload EtherX Token (#1509)
* Add files via upload * Add script to move files /assets/0x..XX.png => /asstes/0x..XX/logo.png Co-authored-by: Mykola <3277207+kolya182@users.noreply.github.com> Co-authored-by: Mykola <kolya182@gmail.com>
This commit is contained in:
parent
5859208399
commit
9f4ed41dd6
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
|
@ -10,6 +10,7 @@
|
|||
"update:bep2": "npm run cleanup && node ./script/updateBEP2",
|
||||
"checksum:erc20": "npm run cleanup && ts-node ./script/erc20_to_checksum",
|
||||
"format:all": "npm run cleanup && ts-node ./script/format_files_name",
|
||||
"arrange:all": "npm run cleanup && ts-node ./script/arrange_files",
|
||||
"gen:list": "npm run cleanup && ts-node ./script/gen_list",
|
||||
"gen:info": "npm run cleanup && ts-node ./script/gen_info",
|
||||
"resize": "npm run cleanup && ts-node ./script/resize_images",
|
||||
|
|
38
script/arrange_files.ts
Normal file
38
script/arrange_files.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import * as fs from "fs"
|
||||
import {
|
||||
ethSidechains,
|
||||
getChainAssetPath,
|
||||
getChainAssetsPath,
|
||||
getFileExt,
|
||||
getFileName,
|
||||
isChecksum,
|
||||
isPathDir,
|
||||
logo,
|
||||
logoExtension,
|
||||
makeDirIfDoestExist,
|
||||
readDirSync,
|
||||
toChecksum,
|
||||
} from "../src/test/helpers"
|
||||
|
||||
ethSidechains.forEach(chain => {
|
||||
const assetsPath = getChainAssetsPath(chain)
|
||||
const chainAssets = readDirSync(assetsPath)
|
||||
|
||||
chainAssets.forEach(async asset => {
|
||||
const assetPath = getChainAssetPath(chain, asset)
|
||||
const isDir = await isPathDir(assetPath)
|
||||
|
||||
if (!isDir) {
|
||||
const assetName = getFileName(asset)
|
||||
const checksum = toChecksum(assetName)
|
||||
|
||||
if (isChecksum(checksum) && getFileExt(asset).toLocaleLowerCase() === logoExtension) {
|
||||
// Moves file like /assets/0x..XX.png => /asstes/0x..XX/logo.png
|
||||
await makeDirIfDoestExist(assetsPath, checksum)
|
||||
const newPath = `${assetsPath}/${checksum}/${logo}`
|
||||
fs.renameSync(assetPath, newPath)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
@ -99,6 +99,26 @@ export const isTRC20 = address => {
|
|||
isUpperCase(address) == false
|
||||
}
|
||||
|
||||
export const isPathDir = (path: string): boolean => {
|
||||
try {
|
||||
return fs.lstatSync(path).isDirectory()
|
||||
} catch (e) {
|
||||
console.log(`Path: ${path} is not a directory with error: ${e.message}`)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export const makeDirIfDoestExist = async (dirPath: string, dirName: string) => {
|
||||
const path = `${dirPath}/${dirName}`
|
||||
await fs.mkdir(path, {recursive: true}, (err) => {
|
||||
if (err) {
|
||||
console.error(`Error creating dir at path ${path} with result ${err}`)
|
||||
} else {
|
||||
console.log(`Created direcotry at ${path}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const sortDesc = arr => arr.sort((a, b) => a - b)
|
||||
export const getUnique = arr => Array.from(new Set(arr))
|
||||
export const mapList = arr => {
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
readFileSync,
|
||||
isLowerCase,
|
||||
isChecksum,
|
||||
isPathDir,
|
||||
getBinanceBEP2Symbols,
|
||||
isTRC10, isTRC20,
|
||||
isLogoOK,
|
||||
|
@ -86,10 +87,13 @@ describe(`Test "blockchains" folder`, () => {
|
|||
const assetsPath = getChainAssetsPath(chain)
|
||||
|
||||
readDirSync(assetsPath).forEach(addr => {
|
||||
const checksum: boolean = isChecksum(addr)
|
||||
expect(checksum, `Address ${addr} on chain ${chain} must be in checksum`).toBe(true)
|
||||
const assetPath = getChainAssetPath(chain, addr)
|
||||
expect(isPathDir(assetPath), `Expect directory at path: ${assetPath}`).toBe(true)
|
||||
|
||||
const checksum = isChecksum(addr)
|
||||
expect(checksum, `Expect asset at path ${assetPath} in checksum`).toBe(true)
|
||||
|
||||
const lowercase: boolean = isLowerCase(addr)
|
||||
const lowercase = isLowerCase(addr)
|
||||
if (lowercase) {
|
||||
expect(checksum, `Lowercase address ${addr} on chain ${chain} should be in checksum`).toBe(true)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user