mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
add logo in hashthereum (#1508)
* add files via upload * STK Coin (STK) * Checksum test * Add wrong asset naming * Add script checking logo extension Co-authored-by: Mykola <kolya182@gmail.com>
This commit is contained in:
parent
4d91cb645c
commit
5892457e09
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
|
@ -9,6 +9,7 @@
|
||||||
"cleanup": "find ./.. -iname '.DS_Store' -type f -delete",
|
"cleanup": "find ./.. -iname '.DS_Store' -type f -delete",
|
||||||
"update:bep2": "npm run cleanup && node ./script/updateBEP2",
|
"update:bep2": "npm run cleanup && node ./script/updateBEP2",
|
||||||
"checksum:erc20": "npm run cleanup && ts-node ./script/erc20_to_checksum",
|
"checksum:erc20": "npm run cleanup && ts-node ./script/erc20_to_checksum",
|
||||||
|
"format:all": "npm run cleanup && ts-node ./script/format_files_name",
|
||||||
"gen:list": "npm run cleanup && ts-node ./script/gen_list",
|
"gen:list": "npm run cleanup && ts-node ./script/gen_list",
|
||||||
"gen:info": "npm run cleanup && ts-node ./script/gen_info",
|
"gen:info": "npm run cleanup && ts-node ./script/gen_info",
|
||||||
"resize": "npm run cleanup && ts-node ./script/resize_images",
|
"resize": "npm run cleanup && ts-node ./script/resize_images",
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
const { execSync } = require('child_process');
|
import { ethSidechains, readDirSync, getChainAssetsPath } from "../src/test/helpers"
|
||||||
const path = require('path')
|
import { checksumAssetsFolder } from './format_files_name'
|
||||||
const Web3 = require('web3')
|
|
||||||
const web3 = new Web3('ws://localhost:8546');
|
|
||||||
import { ethSidechains, readDirSync } from "../src/test/helpers"
|
|
||||||
|
|
||||||
ethSidechains.forEach(chain => {
|
ethSidechains.forEach(chain => {
|
||||||
const assetsPath = path.resolve(`${__dirname}/../blockchains/${chain}/assets`)
|
const assetsPath = getChainAssetsPath(chain)
|
||||||
const chainAddresses = readDirSync(assetsPath)
|
|
||||||
|
|
||||||
chainAddresses.forEach(addr => {
|
readDirSync(assetsPath).forEach(addr => {
|
||||||
const isChecksum = web3.utils.checkAddressChecksum(addr)
|
checksumAssetsFolder(assetsPath, addr)
|
||||||
|
|
||||||
if (!isChecksum) {
|
|
||||||
console.log(`Renaming non checksum ${addr} ...`)
|
|
||||||
const checksum = web3.utils.toChecksumAddress(addr)
|
|
||||||
const moveToChecksum = `git mv ${addr} ${checksum}-temp && git mv ${checksum}-temp ${checksum}`
|
|
||||||
const renamed = execSync(`cd ${assetsPath} && ${moveToChecksum}`, {encoding: "utf-8"})
|
|
||||||
console.log(` Result renaming ${addr} : ${renamed}`)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
});
|
})
|
46
script/format_files_name.ts
Normal file
46
script/format_files_name.ts
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import {
|
||||||
|
ethSidechains,
|
||||||
|
readDirSync,
|
||||||
|
getChainAssetsPath,
|
||||||
|
getChainAssetFilesList,
|
||||||
|
isChecksum,
|
||||||
|
toChecksum,
|
||||||
|
getFileName,
|
||||||
|
getFileExt,
|
||||||
|
getMoveCommandFromTo,
|
||||||
|
execRename,
|
||||||
|
logoName,
|
||||||
|
logoExtension,
|
||||||
|
logo,
|
||||||
|
getChainAssetPath
|
||||||
|
} from "../src/test/helpers"
|
||||||
|
|
||||||
|
ethSidechains.forEach(chain => {
|
||||||
|
const assetsPath = getChainAssetsPath(chain)
|
||||||
|
const chainAddresses = readDirSync(assetsPath)
|
||||||
|
|
||||||
|
chainAddresses.forEach(address => {
|
||||||
|
checksumAssetsFolder(assetsPath, address)
|
||||||
|
|
||||||
|
getChainAssetFilesList(chain, address).forEach(file => {
|
||||||
|
if (getFileName(file) == logoName && getFileExt(file) !== logoExtension) {
|
||||||
|
console.log(`Renaming incorrect asset logo extension ${file} ...`)
|
||||||
|
renameAndMove(getChainAssetPath(chain, address), file, logo)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
export function checksumAssetsFolder(assetsFolderPath: string, addr: string) {
|
||||||
|
if (!isChecksum(addr)) {
|
||||||
|
const checksumAddr = toChecksum(addr)
|
||||||
|
renameAndMove(assetsFolderPath, addr, checksumAddr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function renameAndMove(path: string, oldName: string, newName: string) {
|
||||||
|
console.log(` Renaming file or folder at path ${path}: ${oldName} => ${newName} ...`)
|
||||||
|
const renamed = execRename(path, getMoveCommandFromTo(oldName, newName))
|
||||||
|
console.log(` Result renaming: ${renamed}`)
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ const Web3 = require('web3')
|
||||||
const web3 = new Web3('ws://localhost:8546');
|
const web3 = new Web3('ws://localhost:8546');
|
||||||
import { CoinTypeUtils, CoinType } from "@trustwallet/types";
|
import { CoinTypeUtils, CoinType } from "@trustwallet/types";
|
||||||
const sizeOf = require("image-size");
|
const sizeOf = require("image-size");
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
export const getChainName = (id: CoinType): string => CoinTypeUtils.id(id) // 60 => ethereum
|
export const getChainName = (id: CoinType): string => CoinTypeUtils.id(id) // 60 => ethereum
|
||||||
export const Binance = getChainName(CoinType.binance)
|
export const Binance = getChainName(CoinType.binance)
|
||||||
|
@ -25,11 +26,18 @@ export const Waves = getChainName(CoinType.waves)
|
||||||
|
|
||||||
export const ethSidechains = [Ethereum, Classic, POA, TomoChain, GoChain, Wanchain, ThunderCore]
|
export const ethSidechains = [Ethereum, Classic, POA, TomoChain, GoChain, Wanchain, ThunderCore]
|
||||||
|
|
||||||
const whiteList = 'whitelist.json'
|
export const logoName = `logo`
|
||||||
const blackList = 'blacklist.json'
|
export const infoName = `info`
|
||||||
|
|
||||||
|
export const logoExtension = "png"
|
||||||
|
export const jsonExtension = "json"
|
||||||
|
|
||||||
|
const whiteList = `whitelist.${jsonExtension}`
|
||||||
|
const blackList = `blacklist.${jsonExtension}`
|
||||||
|
|
||||||
|
export const logo = `${logoName}.${logoExtension}`
|
||||||
|
export const info = `${infoName}.${jsonExtension}`
|
||||||
|
|
||||||
export const logo = `logo.png`
|
|
||||||
export const info = `info.json`
|
|
||||||
export const root = './'
|
export const root = './'
|
||||||
export const chainsFolderPath = './blockchains'
|
export const chainsFolderPath = './blockchains'
|
||||||
export const pricingFolderPath = './pricing'
|
export const pricingFolderPath = './pricing'
|
||||||
|
@ -44,9 +52,10 @@ export const maxLogoHeight = 512
|
||||||
|
|
||||||
export const getChainAssetPath = (chain: string, address: string) => `${getChainAssetsPath(chain)}/${address}`
|
export const getChainAssetPath = (chain: string, address: string) => `${getChainAssetsPath(chain)}/${address}`
|
||||||
export const getChainAssetLogoPath = (chain: string, address: string) => `${getChainAssetsPath(chain)}/${address}/${logo}`
|
export const getChainAssetLogoPath = (chain: string, address: string) => `${getChainAssetsPath(chain)}/${address}/${logo}`
|
||||||
|
export const getChainAssetFilesList = (chain: string, address: string) => readDirSync(getChainAssetPath(chain, address))
|
||||||
export const getChainValidatorsPath = (chain: string): string => `${chainsFolderPath}/${chain}/validators`
|
export const getChainValidatorsPath = (chain: string): string => `${chainsFolderPath}/${chain}/validators`
|
||||||
export const getChainValidatorsAssets = (chain: string): string[] => readDirSync(getChainValidatorsAssetsPath(chain))
|
export const getChainValidatorsAssets = (chain: string): string[] => readDirSync(getChainValidatorsAssetsPath(chain))
|
||||||
export const getChainValidatorsListPath = (chain: string): string => `${(getChainValidatorsPath(chain))}/list.json`
|
export const getChainValidatorsListPath = (chain: string): string => `${(getChainValidatorsPath(chain))}/list.${jsonExtension}`
|
||||||
export const getChainValidatorsAssetsPath = (chain: string): string => `${getChainValidatorsPath(chain)}/assets`
|
export const getChainValidatorsAssetsPath = (chain: string): string => `${getChainValidatorsPath(chain)}/assets`
|
||||||
export const getChainValidatorAssetLogoPath = (chain: string, asset: string): string => `${getChainValidatorsAssetsPath(chain)}/${asset}/${logo}`
|
export const getChainValidatorAssetLogoPath = (chain: string, asset: string): string => `${getChainValidatorsAssetsPath(chain)}/${asset}/${logo}`
|
||||||
export const getChainWhitelistPath = (chain: string): string => `${chainsFolderPath}/${chain}/${whiteList}`
|
export const getChainWhitelistPath = (chain: string): string => `${chainsFolderPath}/${chain}/${whiteList}`
|
||||||
|
@ -79,6 +88,9 @@ export const isChecksum = (address: string): boolean => web3.utils.checkAddressC
|
||||||
export const toChecksum = (address: string): string => web3.utils.toChecksumAddress(address)
|
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 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 getFileExt = (name: string): string => name.slice((Math.max(0, name.lastIndexOf(".")) || Infinity) + 1)
|
||||||
|
|
||||||
export const isTRC10 = (string: string): boolean => (/^\d+$/.test(string))
|
export const isTRC10 = (string: string): boolean => (/^\d+$/.test(string))
|
||||||
export const isTRC20 = address => {
|
export const isTRC20 = address => {
|
||||||
return address.length == 34 &&
|
return address.length == 34 &&
|
||||||
|
@ -141,6 +153,14 @@ export const calculateAspectRatioFit = (srcWidth: number, srcHeight: number, max
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMoveCommandFromTo(oldName: string, newName: string): string {
|
||||||
|
return `git mv ${oldName} ${newName}-temp && git mv ${newName}-temp ${newName}`
|
||||||
|
}
|
||||||
|
|
||||||
|
export function execRename(path: string, command: string) {
|
||||||
|
execSync(`cd ${path} && ${command}`, {encoding: "utf-8"})
|
||||||
|
}
|
||||||
|
|
||||||
export const isValidatorHasAllKeys = (val: ValidatorModel): boolean => {
|
export const isValidatorHasAllKeys = (val: ValidatorModel): boolean => {
|
||||||
return typeof val.id === "string"
|
return typeof val.id === "string"
|
||||||
&& typeof val.name === "string"
|
&& typeof val.name === "string"
|
||||||
|
@ -168,6 +188,6 @@ export const rootDirAllowedFiles = [
|
||||||
]
|
]
|
||||||
|
|
||||||
export const assetFolderAllowedFiles = [
|
export const assetFolderAllowedFiles = [
|
||||||
"logo.png",
|
logo,
|
||||||
"info.json"
|
info
|
||||||
]
|
]
|
||||||
|
|
|
@ -72,7 +72,7 @@ describe(`Test "blockchains" folder`, () => {
|
||||||
readDirSync(assetsPath).forEach(address => {
|
readDirSync(assetsPath).forEach(address => {
|
||||||
const assetFiles = getChainAssetPath(chain, address)
|
const assetFiles = getChainAssetPath(chain, address)
|
||||||
readDirSync(assetFiles).forEach(assetFolderFile => {
|
readDirSync(assetFiles).forEach(assetFolderFile => {
|
||||||
expect(assetFolderAllowedFiles.indexOf(assetFolderFile),`File "${assetFolderFile}" not allowed at this path`).not.toBe(-1)
|
expect(assetFolderAllowedFiles.indexOf(assetFolderFile),`File "${assetFolderFile}" not allowed at this path: ${assetsPath}`).not.toBe(-1)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user