diff --git a/components/Row.tsx b/components/Row.tsx index c02de7b..bb292a4 100644 --- a/components/Row.tsx +++ b/components/Row.tsx @@ -1,6 +1,5 @@ import React, { Fragment, useState } from 'react'; import { ProtocolData } from 'data/types'; -import icons from './icons'; import { CSSTransition } from 'react-transition-group'; import ReactGA from 'react-ga'; import { usePlausible } from 'next-plausible'; @@ -21,7 +20,7 @@ const Row: React.FC = ({ protocol, sort }) => { const plausible = usePlausible(); const [open, setOpen] = useState(false); - const icon = protocol.icon || icons[protocol.id]; + const icon = protocol.icon || null; const isApp = protocol.category !== 'l1' && protocol.category !== 'l2'; diff --git a/components/SocialCard/Row.tsx b/components/SocialCard/Row.tsx index aedd2a9..296c596 100644 --- a/components/SocialCard/Row.tsx +++ b/components/SocialCard/Row.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { ProtocolData } from 'data/types'; -import icons from '../icons'; interface RowProps { protocol: ProtocolData; @@ -12,7 +11,7 @@ const font = 'SofiaProRegular, Sofia Pro, sofia-pro'; const Row: React.FC = ({ protocol, index }) => { let svgImg; - const icon = protocol.icon || icons[protocol.id]; + const icon = protocol.icon || null; if (icon?.indexOf('data:image/svg+xml;base64,') === 0) { const buffer = new Buffer(icon.substr(26), 'base64'); @@ -20,7 +19,8 @@ const Row: React.FC = ({ protocol, index }) => { svgImg = svgImg.replace(/">/, '" width="24" height="24">'); } - const background = protocol.category === 'l1' || protocol.category === 'l2' ? '#ffffff' : '#fad3f6'; + const background = + protocol.category === 'l1' || protocol.category === 'l2' ? '#ffffff' : '#fad3f6'; return ( diff --git a/components/icons/index.ts b/components/icons/index.ts index 2a83205..9f2050d 100644 --- a/components/icons/index.ts +++ b/components/icons/index.ts @@ -1,6 +1,3 @@ -import bancor from './bancor.png'; -import hegic from './hegic.png'; -import honeyswap from './honeyswap.png'; import mstable from './mstable.svg'; import polymarket from './polymarket.svg'; import tbtc from './tbtc.svg'; @@ -10,9 +7,6 @@ import zilliqa from './zilliqa.svg'; // Legacy, don't add new icons here const icons: { [id: string]: string } = { - bancor, - hegic, - honeyswap, mstable, polymarket, tbtc, diff --git a/components/year/YearRow.tsx b/components/year/YearRow.tsx index 82227fe..414d28c 100644 --- a/components/year/YearRow.tsx +++ b/components/year/YearRow.tsx @@ -1,6 +1,5 @@ import React, { Fragment, useState } from 'react'; import { ProtocolData } from 'data/types'; -import icons from '../icons'; import { CSSTransition } from 'react-transition-group'; import { usePlausible } from 'next-plausible'; import { ChevronDown, ChevronUp } from 'react-feather'; @@ -19,7 +18,7 @@ const Row: React.FC = ({ protocol }) => { const plausible = usePlausible(); const [open, setOpen] = useState(false); - const icon = protocol.icon || icons[protocol.id]; + const icon = protocol.icon || null; const isApp = protocol.category !== 'l1' && protocol.category !== 'l2'; diff --git a/data/adapters/dfyn.ts b/data/adapters/dfyn.ts index 20bdf1e..a420e45 100644 --- a/data/adapters/dfyn.ts +++ b/data/adapters/dfyn.ts @@ -1,7 +1,6 @@ import { dateToTimestamp } from '../lib/time'; import { query } from '../lib/graph'; import { RegisterFunction } from '../types'; -import icon from 'icons/dfyn.svg'; export async function getDfynData(date: string): Promise { const graphQuery = `query fees($date: Int!) { @@ -37,7 +36,6 @@ export default function registerUniswap(register: RegisterFunction) { }; register('dfyn', query, { - icon, name: 'Dfyn', category: 'dex', description: 'A multi-chain AMM decentralized exchange', diff --git a/data/adapters/ren.ts b/data/adapters/ren.ts index 70bdac8..b6a9c48 100644 --- a/data/adapters/ren.ts +++ b/data/adapters/ren.ts @@ -1,6 +1,5 @@ import { RegisterFunction } from '../types'; import { dateToTimestamp } from '../lib/time'; -import icon from 'icons/ren.svg'; const ONE_DAY = 86400; @@ -78,7 +77,6 @@ export default function registerRen(register: RegisterFunction) { }; register('ren', query, { - icon, name: 'Ren Protocol', category: 'xchain', description: 'Ren Protocol is a protocol for cross-chain asset transfers.', diff --git a/data/adapters/swapr.ts b/data/adapters/swapr.ts index 122eced..63ae8fe 100644 --- a/data/adapters/swapr.ts +++ b/data/adapters/swapr.ts @@ -1,7 +1,6 @@ import { dateToTimestamp } from '../lib/time'; import { query } from '../lib/graph'; import { RegisterFunction, Category } from '../types'; -import icon from 'icons/swapr.svg'; async function getSwaprData(subgraph: string, date: string): Promise { const graphQuery = `query fees($date: Int!) { @@ -48,7 +47,6 @@ export default function registerSwapr(register: RegisterFunction) { adapter: 'swpar', tokenTicker: 'SWPR', website: 'https://swapr.eth.link', - icon, protocolLaunch: '2020-12-10', }; diff --git a/icons/arbitrum.svg b/icons/arbitrum.svg deleted file mode 100644 index ce2b8c7..0000000 --- a/icons/arbitrum.svg +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - diff --git a/icons/dfyn.svg b/icons/dfyn.svg deleted file mode 100644 index 241618e..0000000 --- a/icons/dfyn.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/icons/liquity.svg b/icons/liquity.svg deleted file mode 100644 index 4d9ecb6..0000000 --- a/icons/liquity.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/icons/optimism.svg b/icons/optimism.svg deleted file mode 100644 index 334b5a0..0000000 --- a/icons/optimism.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/icons/ren.svg b/icons/ren.svg deleted file mode 100644 index 4972125..0000000 --- a/icons/ren.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/icons/swapr.svg b/icons/swapr.svg deleted file mode 100644 index f435741..0000000 --- a/icons/swapr.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/pages/api/social/[id].ts b/pages/api/social/[id].ts index 33331f0..5097e1c 100644 --- a/pages/api/social/[id].ts +++ b/pages/api/social/[id].ts @@ -8,7 +8,6 @@ import path from 'path'; import { formatDate } from 'data/lib/time'; import { getDateRangeData } from 'data/queries'; import subDays from 'date-fns/subDays'; -import icons from 'components/icons'; // These statements causes Next to bundle these files path.resolve(process.cwd(), 'fonts', 'fonts.conf'); @@ -27,14 +26,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { metadata = getBundle(id); bundle = true; } catch (e) { - e // Avoid eslint bugs + e; // Avoid eslint bugs } } if (!metadata) { return res.json({ error: `Unknown ${id}` }); } - let data: { date: number, primary: number }[] = [] + let data: { date: number; primary: number }[] = []; const startDate = subDays(new Date(), 30); const endDate = subDays(new Date(), 1); @@ -43,13 +42,15 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const adapterIds = getIDs().filter((adapterId: string) => { const metadata = getMetadata(adapterId); return metadata.bundle === id; - }) + }); - const feeData = await Promise.all(adapterIds.map((id: string) => getDateRangeData(id, startDate, endDate))) + const feeData = await Promise.all( + adapterIds.map((id: string) => getDateRangeData(id, startDate, endDate)) + ); for (let i = 0; i < feeData[0].length; i += 1) { - const date = Math.floor(new Date(feeData[0][i].date).getTime() / 1000) - const primary = feeData.reduce((total: number, protocol: any) => total + protocol[i].fee, 0) + const date = Math.floor(new Date(feeData[0][i].date).getTime() / 1000); + const primary = feeData.reduce((total: number, protocol: any) => total + protocol[i].fee, 0); data.push({ date, primary }); } } else { @@ -65,7 +66,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { data, date: formatDate(subDays(new Date(), 1), '/'), name: metadata.name, - icon: metadata.icon || icons[id], + icon: metadata.icon || null, }) ); diff --git a/pages/protocol/[id].tsx b/pages/protocol/[id].tsx index 441a8a9..8e0ff7f 100644 --- a/pages/protocol/[id].tsx +++ b/pages/protocol/[id].tsx @@ -14,7 +14,6 @@ import { getIDs, getBundleIDs, getMetadata, getBundle, ensureListLoaded } from ' import { Metadata } from 'data/types'; import { getDateRangeData, getMarketData } from 'data/queries'; import { formatDate } from 'data/lib/time'; -import _icons from 'components/icons'; const GITHUB_URL = 'https://github.com/dmihal/crypto-fees/blob/master/data/adapters/'; @@ -61,7 +60,7 @@ const nextDay = (date: Date) => { d.setUTCDate(d.getUTCDate() + 1); d.setUTCHours(0, 0, 0, 0); return d; -} +}; function formatData( data: FeeCache, @@ -459,7 +458,7 @@ export const getStaticProps: GetStaticProps = async ({ par for (const id of ids) { const metadata = getMetadata(id); protocols[id] = metadata.subtitle ? `${metadata.name} (${metadata.subtitle})` : metadata.name; - icons[id] = metadata.icon || _icons[id]; + icons[id] = metadata.icon || null; if (metadata.bundle) { protocolsByBundle[metadata.bundle] = [...(protocolsByBundle[metadata.bundle] || []), id]; @@ -521,7 +520,7 @@ export const getStaticProps: GetStaticProps = async ({ par for (const bundleId of bundleIds) { const metadata = getBundle(bundleId); protocols[bundleId] = metadata.name; - icons[bundleId] = metadata.icon; + icons[bundleId] = metadata.icon || null; } return {