[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:
Adam R 2021-07-08 17:40:16 +02:00 committed by GitHub
parent 62f50817bb
commit 41037d09f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 28 deletions

View File

@ -1,8 +1,8 @@
import { ActionInterface, CheckStepInterface } from "../generic/interface";
import { getChainAssetsPath } from "../generic/repo-structure";
import { Tron } from "../generic/blockchains";
import { readDirSync, isPathExistsSync } from "../generic/filesystem";
import { getChainAssetLogoPath, getChainValidatorsAssets } from "../generic/repo-structure";
import { readDirSync } from "../generic/filesystem";
import { getChainValidatorsAssets } from "../generic/repo-structure";
import { isLowerCase, isUpperCase } from "../generic/types";
import * as bluebird from "bluebird";
@ -32,10 +32,6 @@ export class TronAction implements ActionInterface {
if (!isTRC10(asset) && !isTRC20(asset)) {
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, []];
}

View File

@ -7,7 +7,6 @@ import {
logoName,
logoExtension,
logoFullName,
getChainAssetLogoPath
} from "../generic/repo-structure";
import {
getFileName,
@ -68,10 +67,6 @@ export class EthForks implements ActionInterface {
if (address !== 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, []];
}

View File

@ -18,6 +18,7 @@ import {
} from "../generic/repo-structure";
import { isLogoOK } from "../generic/image";
import { isLowerCase } from "../generic/types";
import { readJsonFile } from "../generic/json";
import * as bluebird from "bluebird";
export class FoldersFiles implements ActionInterface {
@ -82,19 +83,31 @@ export class FoldersFiles implements ActionInterface {
if (isPathExistsSync(assetsPath)) {
readDirSync(assetsPath).forEach(address => {
const logoFullPath = getChainAssetLogoPath(chain, address);
if (!isPathExistsSync(logoFullPath)) {
errors.push(`Missing logo file for asset '${chain}/${address}' -- ${logoFullPath}`);
}
const logoExists = isPathExistsSync(logoFullPath);
const infoFullPath = getChainAssetInfoPath(chain, address);
if (!isPathExistsSync(infoFullPath)) {
const msg = `Missing info file for asset '${chain}/${address}' -- ${infoFullPath}`;
// enforce that info must be present (with some exceptions)
if (chain === 'classic' || chain === 'poa' || chain === 'terra' || chain === 'thundertoken') {
//console.log(msg);
warnings.push(msg);
} else {
console.log(msg);
errors.push(msg);
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}`;
// enforce that info must be present (with some exceptions)
if (chain === 'classic' || chain === 'poa' || chain === 'terra' || chain === 'thundertoken') {
//console.log(msg);
warnings.push(msg);
} else {
console.log(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);
}
}
}
});

View File

@ -42,11 +42,13 @@ async function checkDownsize(chains: string[], checkOnly: boolean): Promise<stri
if (isPathExistsSync(assetsPath)) {
await bluebird.mapSeries(readDirSync(assetsPath), async asset => {
const path = getChainAssetLogoPath(chain, asset);
countChecked++;
const [tooLarge, updated] = await checkResizeIfTooLarge(path, checkOnly);
if (tooLarge) { largePaths.push(path); }
countTooLarge += tooLarge ? 1 : 0;
countUpdated += updated ? 1 : 0;
if (isPathExistsSync(path)) {
countChecked++;
const [tooLarge, updated] = await checkResizeIfTooLarge(path, checkOnly);
if (tooLarge) { largePaths.push(path); }
countTooLarge += tooLarge ? 1 : 0;
countUpdated += updated ? 1 : 0;
}
})
}