mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
Upload Bitcollar Max (#1896)
* Add files via upload * Add script moving 0xX..X.png from toor to it's folder in assets assuming file ETH. Co-authored-by: Mykola <kolya182@gmail.com>
This commit is contained in:
parent
99ee8f9ca1
commit
d2a6283b29
blockchains/ethereum/assets/0xF5Bb691215fd2839Bc14Aa93335e13d839A4767f
package-lock.jsonpackage.jsonscript
src/test
Binary file not shown.
After ![]() (image error) Size: 10 KiB |
15
package-lock.json
generated
15
package-lock.json
generated
|
@ -3989,6 +3989,12 @@
|
|||
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==",
|
||||
"dev": true
|
||||
},
|
||||
"image-extensions": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/image-extensions/-/image-extensions-1.1.0.tgz",
|
||||
"integrity": "sha1-uOa/YDnfAFbjM1AqALZjejEF2JQ=",
|
||||
"dev": true
|
||||
},
|
||||
"image-size": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.8.3.tgz",
|
||||
|
@ -4164,6 +4170,15 @@
|
|||
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=",
|
||||
"dev": true
|
||||
},
|
||||
"is-image": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-image/-/is-image-3.0.0.tgz",
|
||||
"integrity": "sha512-NNPLvwKZ/hqx1Wv+ayKvVeDOylIapVKSxK/guzmB9doAk0FEdK0KqFKbnwNbuMLEPqEY4NaBhxzB4e98fVOq2Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"image-extensions": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"is-my-ip-valid": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz",
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
"ethereum-checksum-address": "0.0.5",
|
||||
"eztz-lib": "^0.1.2",
|
||||
"image-size": "^0.8.3",
|
||||
"is-image": "^3.0.0",
|
||||
"jest": "^25.2.7",
|
||||
"jest-expect-message": "^1.0.2",
|
||||
"nested-property": "^2.0.0",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import * as fs from "fs"
|
||||
const isImage = require("is-image");
|
||||
import {
|
||||
ethSidechains,
|
||||
getChainAssetPath,
|
||||
|
@ -12,27 +13,43 @@ import {
|
|||
makeDirIfDoestExist,
|
||||
readDirSync,
|
||||
toChecksum,
|
||||
getRootDirFilesList,
|
||||
rootDirAllowedFiles,
|
||||
isEthereumAddress
|
||||
} from "../src/test/helpers"
|
||||
|
||||
ethSidechains.forEach(chain => {
|
||||
const assetsPath = getChainAssetsPath(chain)
|
||||
const chainAssets = readDirSync(assetsPath)
|
||||
const chainAssetsPath = getChainAssetsPath(chain)
|
||||
|
||||
chainAssets.forEach(async asset => {
|
||||
readDirSync(chainAssetsPath).forEach(async asset => {
|
||||
const assetPath = getChainAssetPath(chain, asset)
|
||||
const isDir = await isPathDir(assetPath)
|
||||
|
||||
if (!isDir) {
|
||||
const assetName = getFileName(asset)
|
||||
const checksum = toChecksum(assetName)
|
||||
const checksum = toChecksum(getFileName(asset))
|
||||
|
||||
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}`
|
||||
// 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 asset/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}`)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ export const getChainBlacklist = (chain: string): string[] => {
|
|||
}
|
||||
return []
|
||||
}
|
||||
export const getRootDirFilesList = (): string[] => readDirSync(root)
|
||||
|
||||
export const readDirSync = (path: string): string[] => fs.readdirSync(path)
|
||||
export const makeDirSync = (path: string) => fs.mkdirSync(path)
|
||||
|
@ -107,6 +108,10 @@ export const isTRC20 = (address: string) => {
|
|||
isUpperCase(address) == false
|
||||
}
|
||||
|
||||
export const isEthereumAddress = (address: string): boolean => {
|
||||
return web3.utils.isAddress(address)
|
||||
}
|
||||
|
||||
export const isWavesAddress = (address: string) => {
|
||||
return address.length == 35 &&
|
||||
address.startsWith("3P") &&
|
||||
|
@ -258,10 +263,7 @@ export function isAssetInfoHasAllKeys(path: string): [boolean, string] {
|
|||
return [isKeysCorrentType, `Check keys ${requiredKeys} vs ${infoKeys}`]
|
||||
}
|
||||
|
||||
function getArraysDiff(arr1 :string[], arr2: string[]): string[] {
|
||||
return arr1.filter(d => !arr2.includes(d))
|
||||
}
|
||||
|
||||
export const getArraysDiff = (arr1 :string[], arr2: string[]): string[] => arr1.filter(d => !arr2.includes(d))
|
||||
export const getFileSizeInKilobyte = (path: string): number => fs.statSync(path).size / 1000
|
||||
|
||||
export const rootDirAllowedFiles = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user