From 69f963f73cfb11ba45bdf875b1bd8ea1b1c7f885 Mon Sep 17 00:00:00 2001 From: kevin <35275952+kaladinlight@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:54:25 -0600 Subject: [PATCH] chore: reduce bundle size (#7897) --- react-app-rewired/index.ts | 3 +++ scripts/generateAssetData/coingecko.ts | 4 +++- .../service => scripts/generateAssetData}/color-map.json | 0 scripts/generateAssetData/cosmos/index.ts | 4 +++- scripts/generateAssetData/ethTokens/uniswap.ts | 4 +++- scripts/generateAssetData/generateColorMap.ts | 2 +- src/lib/asset-service/service/colorMap.ts | 4 ---- src/lib/portals/utils.ts | 3 +-- 8 files changed, 14 insertions(+), 10 deletions(-) rename {src/lib/asset-service/service => scripts/generateAssetData}/color-map.json (100%) delete mode 100644 src/lib/asset-service/service/colorMap.ts diff --git a/react-app-rewired/index.ts b/react-app-rewired/index.ts index 845d5affcfb..142e8138dea 100644 --- a/react-app-rewired/index.ts +++ b/react-app-rewired/index.ts @@ -71,6 +71,9 @@ const reactAppRewireConfig = { // we should probably align with whatever solution is chosen.) _.merge(config, { resolve: { + alias: { + '@ledgerhq/cryptoassets': false, + }, fallback: { crypto: require.resolve('crypto-browserify'), http: require.resolve('stream-http'), diff --git a/scripts/generateAssetData/coingecko.ts b/scripts/generateAssetData/coingecko.ts index bfc199e53f2..cfa89c10be3 100644 --- a/scripts/generateAssetData/coingecko.ts +++ b/scripts/generateAssetData/coingecko.ts @@ -17,7 +17,6 @@ import { import type { Asset } from '@shapeshiftoss/types' import axios from 'axios' -import { colorMap } from './../../src/lib/asset-service/service/colorMap' import { arbitrum, arbitrumNova, @@ -30,6 +29,9 @@ import { polygon, solana, } from './baseAssets' +import colormap from './color-map.json' + +export const colorMap: Record = colormap type Token = { chainId: number diff --git a/src/lib/asset-service/service/color-map.json b/scripts/generateAssetData/color-map.json similarity index 100% rename from src/lib/asset-service/service/color-map.json rename to scripts/generateAssetData/color-map.json diff --git a/scripts/generateAssetData/cosmos/index.ts b/scripts/generateAssetData/cosmos/index.ts index 467f1bdf0c7..727b92f7c31 100644 --- a/scripts/generateAssetData/cosmos/index.ts +++ b/scripts/generateAssetData/cosmos/index.ts @@ -2,8 +2,10 @@ import { cosmosChainId } from '@shapeshiftoss/caip' import type { Asset } from '@shapeshiftoss/types' import axios from 'axios' -import { colorMap } from '../../../src/lib/asset-service/service/colorMap' import { atom } from '../baseAssets' +import colormap from '../color-map.json' + +export const colorMap: Record = colormap type CosmosAsset = { denom: string diff --git a/scripts/generateAssetData/ethTokens/uniswap.ts b/scripts/generateAssetData/ethTokens/uniswap.ts index a498f7405f8..0b3f0ef586d 100644 --- a/scripts/generateAssetData/ethTokens/uniswap.ts +++ b/scripts/generateAssetData/ethTokens/uniswap.ts @@ -2,7 +2,9 @@ import { ethChainId as chainId, toAssetId } from '@shapeshiftoss/caip' import type { Asset } from '@shapeshiftoss/types' import axios from 'axios' -import { colorMap } from '../../../src/lib/asset-service/service/colorMap' +import colormap from '../color-map.json' + +export const colorMap: Record = colormap type UniswapToken = { chainId: number diff --git a/scripts/generateAssetData/generateColorMap.ts b/scripts/generateAssetData/generateColorMap.ts index 531fec587d1..c9d5a3b5b52 100644 --- a/scripts/generateAssetData/generateColorMap.ts +++ b/scripts/generateAssetData/generateColorMap.ts @@ -70,7 +70,7 @@ const generateColorMap = async () => { await fs.promises.writeFile( // note: cwd is the root of the monorepo, *not* the script directory - 'src/lib/asset-service/service/color-map.json', + 'scripts/generateAssetData/color-map.json', // beautify the file for github diff. JSON.stringify(colorMap, null, 2), ) diff --git a/src/lib/asset-service/service/colorMap.ts b/src/lib/asset-service/service/colorMap.ts deleted file mode 100644 index fcda967385c..00000000000 --- a/src/lib/asset-service/service/colorMap.ts +++ /dev/null @@ -1,4 +0,0 @@ -import map from './color-map.json' - -// Record but we can't use nominals as indexers, only primitives -export const colorMap: Record = map diff --git a/src/lib/portals/utils.ts b/src/lib/portals/utils.ts index cb453564315..db542e23634 100644 --- a/src/lib/portals/utils.ts +++ b/src/lib/portals/utils.ts @@ -7,7 +7,6 @@ import { getConfig } from 'config' import qs from 'qs' import { getAddress, isAddressEqual, zeroAddress } from 'viem' import { queryClient } from 'context/QueryClientProvider/queryClient' -import { colorMap } from 'lib/asset-service/service/colorMap' import generatedAssetData from '../../lib/asset-service/service/generatedAssetData.json' import { CHAIN_ID_TO_PORTALS_NETWORK } from './constants' @@ -230,7 +229,7 @@ export const portalTokenToAsset = ({ return { ...explorerData, - color: colorMap[assetId] ?? '#FFFFFF', + color: assets[assetId]?.color ?? '#FFFFFF', // This looks weird but we need this - l.165 check above nulls the type safety of this object, so we cast it back ...(iconOrIcons as { icon: string } | { icons: string[]; icon: undefined }), name,