Skip to content

Commit

Permalink
Remove some icons
Browse files Browse the repository at this point in the history
  • Loading branch information
dmihal committed Aug 3, 2022
1 parent 0dee410 commit a1a1e3a
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 106 deletions.
3 changes: 1 addition & 2 deletions components/Row.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -21,7 +20,7 @@ const Row: React.FC<RowProps> = ({ 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';

Expand Down
6 changes: 3 additions & 3 deletions components/SocialCard/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { ProtocolData } from 'data/types';
import icons from '../icons';

interface RowProps {
protocol: ProtocolData;
Expand All @@ -12,15 +11,16 @@ const font = 'SofiaProRegular, Sofia Pro, sofia-pro';
const Row: React.FC<RowProps> = ({ 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');
svgImg = buffer.toString('ascii');
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 (
<g transform={`translate(28, ${117 + 37 * index})`}>
Expand Down
6 changes: 0 additions & 6 deletions components/icons/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions components/year/YearRow.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,7 +18,7 @@ const Row: React.FC<RowProps> = ({ 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';

Expand Down
2 changes: 0 additions & 2 deletions data/adapters/dfyn.ts
Original file line number Diff line number Diff line change
@@ -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<number> {
const graphQuery = `query fees($date: Int!) {
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 0 additions & 2 deletions data/adapters/ren.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { RegisterFunction } from '../types';
import { dateToTimestamp } from '../lib/time';
import icon from 'icons/ren.svg';

const ONE_DAY = 86400;

Expand Down Expand Up @@ -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.',
Expand Down
2 changes: 0 additions & 2 deletions data/adapters/swapr.ts
Original file line number Diff line number Diff line change
@@ -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<number> {
const graphQuery = `query fees($date: Int!) {
Expand Down Expand Up @@ -48,7 +47,6 @@ export default function registerSwapr(register: RegisterFunction) {
adapter: 'swpar',
tokenTicker: 'SWPR',
website: 'https://swapr.eth.link',
icon,
protocolLaunch: '2020-12-10',
};

Expand Down
25 changes: 0 additions & 25 deletions icons/arbitrum.svg

This file was deleted.

12 changes: 0 additions & 12 deletions icons/dfyn.svg

This file was deleted.

5 changes: 0 additions & 5 deletions icons/liquity.svg

This file was deleted.

6 changes: 0 additions & 6 deletions icons/optimism.svg

This file was deleted.

17 changes: 0 additions & 17 deletions icons/ren.svg

This file was deleted.

10 changes: 0 additions & 10 deletions icons/swapr.svg

This file was deleted.

17 changes: 9 additions & 8 deletions pages/api/social/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand All @@ -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 {
Expand All @@ -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,
})
);

Expand Down
7 changes: 3 additions & 4 deletions pages/protocol/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/';

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -459,7 +458,7 @@ export const getStaticProps: GetStaticProps<ProtocolDetailsProps> = 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];
Expand Down Expand Up @@ -521,7 +520,7 @@ export const getStaticProps: GetStaticProps<ProtocolDetailsProps> = 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 {
Expand Down

1 comment on commit a1a1e3a

@vercel
Copy link

@vercel vercel bot commented on a1a1e3a Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.