mirror of
				https://github.com/Instadapp/trustwallet-assets.git
				synced 2024-07-29 22:37:31 +00:00 
			
		
		
		
	Simplify script/config, make it typed.
This commit is contained in:
		
							parent
							
								
									1c5610fe4b
								
							
						
					
					
						commit
						c3ecf50d16
					
				| 
						 | 
				
			
			@ -3,7 +3,7 @@ import * as bluebird from "bluebird";
 | 
			
		|||
import * as fs from "fs";
 | 
			
		||||
import * as path from "path";
 | 
			
		||||
import * as chalk from 'chalk';
 | 
			
		||||
import * as config from "../common/config";
 | 
			
		||||
import * as config from "../config";
 | 
			
		||||
import { ActionInterface, CheckStepInterface } from "./interface";
 | 
			
		||||
import { getChainAssetsPath } from "../common/repo-structure";
 | 
			
		||||
import { Binance } from "../common/blockchains";
 | 
			
		||||
| 
						 | 
				
			
			@ -15,9 +15,9 @@ import {
 | 
			
		|||
} from "../common/repo-structure";
 | 
			
		||||
 | 
			
		||||
const binanceChain = "binance"
 | 
			
		||||
const binanceUrlTokens2 = config.getConfig("binance_url_tokens2", "https://dex-atlantic.binance.org/api/v1/tokens?limit=1000");
 | 
			
		||||
const binanceUrlTokens8 = config.getConfig("binance_url_tokens8", "https://dex-atlantic.binance.org/api/v1/mini/tokens?limit=1000");
 | 
			
		||||
const binanceUrlTokenAssets = config.getConfig("binance_url_token_assets", "https://explorer.binance.org/api/v1/assets?page=1&rows=1000");
 | 
			
		||||
const binanceUrlTokens2 = config.binanceUrlTokens2;
 | 
			
		||||
const binanceUrlTokens8 = config.binanceUrlTokens8;
 | 
			
		||||
const binanceUrlTokenAssets = config.binanceUrlTokenAssets;
 | 
			
		||||
var cachedAssets = [];
 | 
			
		||||
 | 
			
		||||
async function retrieveBep2AssetList(): Promise<any[]> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,15 +0,0 @@
 | 
			
		|||
 | 
			
		||||
const configFileName = "../config.json";
 | 
			
		||||
const configData = require(configFileName);
 | 
			
		||||
 | 
			
		||||
export function getConfig(key: string, defaultValue: any): any {
 | 
			
		||||
    if (!configData) {
 | 
			
		||||
        console.log(`Missing config, config file: ${configFileName}`);
 | 
			
		||||
        return defaultValue;
 | 
			
		||||
    }
 | 
			
		||||
    if (!(key in configData)) {
 | 
			
		||||
        console.log(`Missing config entry, key ${key}, config file: ${configFileName}`);
 | 
			
		||||
        return defaultValue;
 | 
			
		||||
    }
 | 
			
		||||
    return configData[key];
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -6,13 +6,13 @@ import {
 | 
			
		|||
    getFileSizeInKilobyte
 | 
			
		||||
} from "./filesystem";
 | 
			
		||||
import * as chalk from 'chalk';
 | 
			
		||||
import * as config from "../common/config";
 | 
			
		||||
import * as config from "../config";
 | 
			
		||||
 | 
			
		||||
export const minLogoWidth = config.getConfig("image_min_logo_width", 64);
 | 
			
		||||
export const minLogoHeight = config.getConfig("image_min_logo_height", 64);
 | 
			
		||||
export const maxLogoWidth = config.getConfig("image_max_logo_width", 512);
 | 
			
		||||
export const maxLogoHeight = config.getConfig("image_max_logo_height", 512);
 | 
			
		||||
export const maxLogoSizeInKilobyte = config.getConfig("image_logo_size_kb", 100);
 | 
			
		||||
export const minLogoWidth = config.imageMinLogoWidth;
 | 
			
		||||
export const minLogoHeight = config.imageMinLogoHeight;
 | 
			
		||||
export const maxLogoWidth = config.imageMaxLogoWidth;
 | 
			
		||||
export const maxLogoHeight = config.imageMaxLogoHeight;
 | 
			
		||||
export const maxLogoSizeInKilobyte = config.imageMaxLogoSizeKb;
 | 
			
		||||
 | 
			
		||||
export function isDimensionTooLarge(width: number, height: number): boolean {
 | 
			
		||||
    return (width > maxLogoWidth) || (height > maxLogoHeight);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ import {
 | 
			
		|||
    isPathExistsSync,
 | 
			
		||||
    readDirSync
 | 
			
		||||
} from "./filesystem";
 | 
			
		||||
import * as config from "./config";
 | 
			
		||||
import * as config from "../config";
 | 
			
		||||
 | 
			
		||||
export const logoName = `logo`;
 | 
			
		||||
export const infoName = `info`;
 | 
			
		||||
| 
						 | 
				
			
			@ -47,5 +47,4 @@ export const getChainAssetsList = (chain: string): string[] => readDirSync(getCh
 | 
			
		|||
export const getChainAssetFilesList = (chain: string, address: string) => readDirSync(getChainAssetPath(chain, address));
 | 
			
		||||
export const getChainValidatorsAssets = (chain: string): string[] => readDirSync(getChainValidatorsAssetsPath(chain));
 | 
			
		||||
 | 
			
		||||
const defaultRootDirAllowedFiles = [".github", "blockchains", "dapps", "media", "script", "test", ".gitignore", "LICENSE", "package-lock.json", "package.json", "README.md", ".git", "Gemfile", "Gemfile.lock"];
 | 
			
		||||
export const rootDirAllowedFiles = config.getConfig("folders_rootdir_allowed_files", defaultRootDirAllowedFiles);
 | 
			
		||||
export const rootDirAllowedFiles = config.foldersRootdirAllowedFiles;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +0,0 @@
 | 
			
		|||
{
 | 
			
		||||
    "image_max_logo_width": 512,
 | 
			
		||||
    "image_max_logo_height": 512,
 | 
			
		||||
    "image_min_logo_width": 64,
 | 
			
		||||
    "image_min_logo_height": 64,
 | 
			
		||||
    "image_logo_size_kb": 100,
 | 
			
		||||
    "folders_rootdir_allowed_files": [".github", "blockchains", "dapps", "media", "node_modules", "script-old", "script", "test", ".gitignore", "azure-pipelines.yml", "jest.config.js", "LICENSE", "package-lock.json", "package.json", "README.md", ".git", "pricing", "dangerfile.ts", "Gemfile", "Gemfile.lock"],
 | 
			
		||||
    "binance_url_tokens2": "https://dex-atlantic.binance.org/api/v1/tokens?limit=1000",
 | 
			
		||||
    "binance_url_tokens8": "https://dex-atlantic.binance.org/api/v1/mini/tokens?limit=1000",
 | 
			
		||||
    "binance_url_token_assets": "https://explorer.binance.org/api/v1/assets?page=1&rows=1000"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								script/config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								script/config.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,9 @@
 | 
			
		|||
export const imageMaxLogoWidth: number = 512;
 | 
			
		||||
export const imageMaxLogoHeight: number =  512;
 | 
			
		||||
export const imageMinLogoWidth: number =  64;
 | 
			
		||||
export const imageMinLogoHeight: number =  64;
 | 
			
		||||
export const imageMaxLogoSizeKb: number =  100;
 | 
			
		||||
export const foldersRootdirAllowedFiles: string[] =  [".github", "blockchains", "dapps", "media", "node_modules", "script-old", "script", "test", ".gitignore", "azure-pipelines.yml", "jest.config.js", "LICENSE", "package-lock.json", "package.json", "README.md", ".git", "pricing", "dangerfile.ts", "Gemfile", "Gemfile.lock"];
 | 
			
		||||
export const binanceUrlTokens2: string =  "https://dex-atlantic.binance.org/api/v1/tokens?limit=1000";
 | 
			
		||||
export const binanceUrlTokens8: string =  "https://dex-atlantic.binance.org/api/v1/mini/tokens?limit=1000";
 | 
			
		||||
export const binanceUrlTokenAssets: string =  "https://explorer.binance.org/api/v1/assets?page=1&rows=1000";
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user