mirror of
https://github.com/Instadapp/trustwallet-assets.git
synced 2024-07-29 22:37:31 +00:00
[Internal] Allow assets to exist with no logo, info only (typically spam) (#11530)
* Allow assets to exist with no logo, info only (typically spam) * Allow missing logo only for spam assets * Lint fix * Remove logo for a few spam tokens * Revert "Remove logo for a few spam tokens" This reverts commit 95e93cd7b2e9c3c03f4e8369f59a5c56c593e13d. Co-authored-by: Catenocrypt <catenocrypt@users.noreply.github.com>
This commit is contained in:
parent
62f50817bb
commit
41037d09f0
|
@ -1,8 +1,8 @@
|
||||||
import { ActionInterface, CheckStepInterface } from "../generic/interface";
|
import { ActionInterface, CheckStepInterface } from "../generic/interface";
|
||||||
import { getChainAssetsPath } from "../generic/repo-structure";
|
import { getChainAssetsPath } from "../generic/repo-structure";
|
||||||
import { Tron } from "../generic/blockchains";
|
import { Tron } from "../generic/blockchains";
|
||||||
import { readDirSync, isPathExistsSync } from "../generic/filesystem";
|
import { readDirSync } from "../generic/filesystem";
|
||||||
import { getChainAssetLogoPath, getChainValidatorsAssets } from "../generic/repo-structure";
|
import { getChainValidatorsAssets } from "../generic/repo-structure";
|
||||||
import { isLowerCase, isUpperCase } from "../generic/types";
|
import { isLowerCase, isUpperCase } from "../generic/types";
|
||||||
import * as bluebird from "bluebird";
|
import * as bluebird from "bluebird";
|
||||||
|
|
||||||
|
@ -32,10 +32,6 @@ export class TronAction implements ActionInterface {
|
||||||
if (!isTRC10(asset) && !isTRC20(asset)) {
|
if (!isTRC10(asset) && !isTRC20(asset)) {
|
||||||
errors.push(`Asset ${asset} at path '${path}' is not TRC10 nor TRC20`);
|
errors.push(`Asset ${asset} at path '${path}' is not TRC10 nor TRC20`);
|
||||||
}
|
}
|
||||||
const assetsLogoPath = getChainAssetLogoPath(Tron, asset);
|
|
||||||
if (!isPathExistsSync(assetsLogoPath)) {
|
|
||||||
errors.push(`Missing file at path '${assetsLogoPath}'`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return [errors, []];
|
return [errors, []];
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import {
|
||||||
logoName,
|
logoName,
|
||||||
logoExtension,
|
logoExtension,
|
||||||
logoFullName,
|
logoFullName,
|
||||||
getChainAssetLogoPath
|
|
||||||
} from "../generic/repo-structure";
|
} from "../generic/repo-structure";
|
||||||
import {
|
import {
|
||||||
getFileName,
|
getFileName,
|
||||||
|
@ -68,10 +67,6 @@ export class EthForks implements ActionInterface {
|
||||||
if (address !== inChecksum) {
|
if (address !== inChecksum) {
|
||||||
errors.push(`Expect asset at path ${assetPath} in checksum: '${inChecksum}'`);
|
errors.push(`Expect asset at path ${assetPath} in checksum: '${inChecksum}'`);
|
||||||
}
|
}
|
||||||
const assetLogoPath = getChainAssetLogoPath(chain, address);
|
|
||||||
if (!isPathExistsSync(assetLogoPath)) {
|
|
||||||
errors.push(`Missing file at path '${assetLogoPath}'`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return [errors, []];
|
return [errors, []];
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import {
|
||||||
} from "../generic/repo-structure";
|
} from "../generic/repo-structure";
|
||||||
import { isLogoOK } from "../generic/image";
|
import { isLogoOK } from "../generic/image";
|
||||||
import { isLowerCase } from "../generic/types";
|
import { isLowerCase } from "../generic/types";
|
||||||
|
import { readJsonFile } from "../generic/json";
|
||||||
import * as bluebird from "bluebird";
|
import * as bluebird from "bluebird";
|
||||||
|
|
||||||
export class FoldersFiles implements ActionInterface {
|
export class FoldersFiles implements ActionInterface {
|
||||||
|
@ -82,11 +83,14 @@ export class FoldersFiles implements ActionInterface {
|
||||||
if (isPathExistsSync(assetsPath)) {
|
if (isPathExistsSync(assetsPath)) {
|
||||||
readDirSync(assetsPath).forEach(address => {
|
readDirSync(assetsPath).forEach(address => {
|
||||||
const logoFullPath = getChainAssetLogoPath(chain, address);
|
const logoFullPath = getChainAssetLogoPath(chain, address);
|
||||||
if (!isPathExistsSync(logoFullPath)) {
|
const logoExists = isPathExistsSync(logoFullPath);
|
||||||
errors.push(`Missing logo file for asset '${chain}/${address}' -- ${logoFullPath}`);
|
|
||||||
}
|
|
||||||
const infoFullPath = getChainAssetInfoPath(chain, address);
|
const infoFullPath = getChainAssetInfoPath(chain, address);
|
||||||
if (!isPathExistsSync(infoFullPath)) {
|
const infoExists = isPathExistsSync(infoFullPath);
|
||||||
|
// Assets should have a logo and an info file. Exceptions:
|
||||||
|
// - status=spam tokens may have no logo
|
||||||
|
// - on some chains some valid tokens have no info (should be fixed)
|
||||||
|
if (!infoExists || !logoExists) {
|
||||||
|
if (!infoExists && logoExists) {
|
||||||
const msg = `Missing info file for asset '${chain}/${address}' -- ${infoFullPath}`;
|
const msg = `Missing info file for asset '${chain}/${address}' -- ${infoFullPath}`;
|
||||||
// enforce that info must be present (with some exceptions)
|
// enforce that info must be present (with some exceptions)
|
||||||
if (chain === 'classic' || chain === 'poa' || chain === 'terra' || chain === 'thundertoken') {
|
if (chain === 'classic' || chain === 'poa' || chain === 'terra' || chain === 'thundertoken') {
|
||||||
|
@ -97,6 +101,15 @@ export class FoldersFiles implements ActionInterface {
|
||||||
errors.push(msg);
|
errors.push(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!logoExists && infoExists) {
|
||||||
|
const info: unknown = readJsonFile(infoFullPath);
|
||||||
|
if (!info['status'] || info['status'] !== 'spam') {
|
||||||
|
const msg = `Missing logo file for non-spam asset '${chain}/${address}' -- ${logoFullPath}`;
|
||||||
|
console.log(msg);
|
||||||
|
errors.push(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,11 +42,13 @@ async function checkDownsize(chains: string[], checkOnly: boolean): Promise<stri
|
||||||
if (isPathExistsSync(assetsPath)) {
|
if (isPathExistsSync(assetsPath)) {
|
||||||
await bluebird.mapSeries(readDirSync(assetsPath), async asset => {
|
await bluebird.mapSeries(readDirSync(assetsPath), async asset => {
|
||||||
const path = getChainAssetLogoPath(chain, asset);
|
const path = getChainAssetLogoPath(chain, asset);
|
||||||
|
if (isPathExistsSync(path)) {
|
||||||
countChecked++;
|
countChecked++;
|
||||||
const [tooLarge, updated] = await checkResizeIfTooLarge(path, checkOnly);
|
const [tooLarge, updated] = await checkResizeIfTooLarge(path, checkOnly);
|
||||||
if (tooLarge) { largePaths.push(path); }
|
if (tooLarge) { largePaths.push(path); }
|
||||||
countTooLarge += tooLarge ? 1 : 0;
|
countTooLarge += tooLarge ? 1 : 0;
|
||||||
countUpdated += updated ? 1 : 0;
|
countUpdated += updated ? 1 : 0;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user