Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TW-1187: Mark scam tokens #1091

Merged
merged 8 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review fix
  • Loading branch information
lendihop committed Feb 27, 2024
commit 2fc1e674c63c7ec5327195865ed71c7edf1698e6
49 changes: 46 additions & 3 deletions src/app/pages/Home/OtherComponents/Tokens/Tokens.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.apyTag {
background: #4299e1;
.tagBase {
border-radius: 4px;
font-family: Inter, Helvetica, Arial, Verdana, Tahoma, sans-serif;
font-style: normal;
Expand All @@ -9,10 +8,54 @@
color: #ffffff;
}

.apyTag:hover {
.delegateTag {
background: #4299e1;
}

.delegateTag:hover {
background-color: #68ADE7;
}

.kusdTag {
background: #3EBD93;
}

.kusdTag:hover {
background-color: #65CAA9;
}

.tzbtcTag {
background: #1373E4;
}

.tzbtcTag:hover {
background-color: #428FE9;
}

.usdtTag {
background: #009393;
}

.usdtTag:hover {
background-color: #52AF95;
}

.youvesTag {
background: #143A3A;
}

.youvesTag:hover {
background-color: #4F6B6B;
}

.scamTag {
background: #C53030;
}

.scamTag:hover {
background-color: #D15A59;
}

.tokenInfoWidth {
max-width: 19rem;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { FC, useState, useMemo } from 'react';
import React, { FC, useMemo } from 'react';

import BigNumber from 'bignumber.js';
import classNames from 'clsx';

import { Button } from 'app/atoms/Button';
import type { TokenApyInfo } from 'app/hooks/use-token-apy.hook';
import { KNOWN_TOKENS_SLUGS, TOKENS_BRAND_COLORS } from 'lib/assets/known-tokens';
import { KNOWN_TOKENS_SLUGS } from 'lib/assets/known-tokens';
import { isTruthy, openLink } from 'lib/utils';

import { AssetsSelectors } from '../../../Assets.selectors';
Expand All @@ -20,11 +20,17 @@ interface Props {
const APR = 'APR';
const APY = 'APY';
const YOUVES_TOKENS_WITH_APR = [KNOWN_TOKENS_SLUGS.UUSD, KNOWN_TOKENS_SLUGS.UBTC, KNOWN_TOKENS_SLUGS.YOU];
const TAGS_CLASSNAME_RECORD: Record<string, string> = {
[KNOWN_TOKENS_SLUGS.KUSD]: 'kusdTag',
[KNOWN_TOKENS_SLUGS.TZBTC]: 'tzbtcTag',
[KNOWN_TOKENS_SLUGS.USDT]: 'usdtTag',
[KNOWN_TOKENS_SLUGS.UUSD]: 'youvesTag',
[KNOWN_TOKENS_SLUGS.UBTC]: 'youvesTag',
[KNOWN_TOKENS_SLUGS.YOU]: 'youvesTag'
};

lendihop marked this conversation as resolved.
Show resolved Hide resolved
export const TokenApyTag: FC<Props> = ({ slug, symbol, apyInfo }) => {
const [hovered, setHovered] = useState(false);

const colors = useMemo(() => TOKENS_BRAND_COLORS[slug], [slug]);
const tokenClassName = useMemo(() => TAGS_CLASSNAME_RECORD[slug], [slug]);

const label = useMemo(() => (YOUVES_TOKENS_WITH_APR.includes(slug) ? APR : APY), [slug]);

Expand All @@ -41,12 +47,9 @@ export const TokenApyTag: FC<Props> = ({ slug, symbol, apyInfo }) => {
e.stopPropagation();
openLink(link);
}}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
testID={AssetsSelectors.assetItemApyButton}
testIDProperties={{ slug, symbol, apyRate: rate }}
className={classNames('ml-2 px-2 py-1', modStyles['apyTag'])}
style={{ backgroundColor: hovered ? colors.bgHover : colors.bg }}
className={classNames('ml-2 px-2 py-1', modStyles['tagBase'], modStyles[tokenClassName])}
>
{label}: {displayRate}%
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export const DelegateTezosTag = memo(() => {
() => (
<Button
onClick={handleTagClick}
className={classNames('inline-flex items-center px-1.5 ml-2 py-1', modStyles['apyTag'])}
className={classNames(
'inline-flex items-center px-1.5 ml-2 py-1',
modStyles['tagBase'],
modStyles['delegateTag']
lendihop marked this conversation as resolved.
Show resolved Hide resolved
)}
testID={AssetsSelectors.assetItemApyButton}
>
APY: 5.6%
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { memo, useCallback, useState } from 'react';
import React, { memo, useCallback } from 'react';

import clsx from 'clsx';

import { Button } from 'app/atoms/Button';
import { AssetsSelectors } from 'app/pages/Home/OtherComponents/Assets.selectors';
import { dispatch } from 'app/store';
import { setTokenStatusAction } from 'app/store/assets/actions';
import { SCAM_COLORS } from 'lib/assets/known-tokens';
import { t, T } from 'lib/i18n';
import { useAccount, useChainId } from 'lib/temple/front';
import { useConfirm } from 'lib/ui/dialog';
Expand All @@ -18,8 +17,6 @@ interface Props {
}

export const ScamTag = memo<Props>(({ assetSlug }) => {
const [hovered, setHovered] = useState(false);

const chainId = useChainId(true)!;
const { publicKeyHash } = useAccount();

Expand Down Expand Up @@ -52,18 +49,20 @@ export const ScamTag = memo<Props>(({ assetSlug }) => {
[chainId, publicKeyHash, confirm]
);

const handleClick = useCallback(
(e: React.MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
e.stopPropagation();
removeToken(assetSlug);
},
[assetSlug, removeToken]
);

return (
<Button
onClick={e => {
e.preventDefault();
e.stopPropagation();
removeToken(assetSlug);
}}
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
onClick={handleClick}
className={clsx('uppercase ml-2 px-2 py-1', modStyles['tagBase'], modStyles['scamTag'])}
testID={AssetsSelectors.assetItemScamButton}
className={clsx('uppercase ml-2 px-2 py-1', modStyles['apyTag'])}
style={{ backgroundColor: hovered ? SCAM_COLORS.bgHover : SCAM_COLORS.bg }}
>
<T id="scam" />
</Button>
Expand Down
1 change: 0 additions & 1 deletion src/app/store/assets/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { createReducer } from '@reduxjs/toolkit';
import { persistReducer } from 'redux-persist';
//import hardSet from 'redux-persist/lib/stateReconciler/hardSet';

import { toTokenSlug } from 'lib/assets';
import { storageConfig, createTransformsBeforePersist } from 'lib/store';
Expand Down
14 changes: 0 additions & 14 deletions src/lib/assets/known-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,13 @@ export namespace KNOWN_TOKENS_SLUGS {
export const KUSD = toTokenSlug('KT1K9gCRgaLRFKTErYt1wVxA3Frb9FjasjTV', 0);
export const UUSD = toTokenSlug('KT1XRPEPXbZK25r3Htzp2o1x7xdMMmfocKNW', 0);
export const QUIPU = toTokenSlug('KT193D4vozYnhGJQVtw7CoxxqphqUEEwK6Vb', 0);
export const WWBTC = toTokenSlug('KT18fp5rcTW7mbWDmzFwjLDUhs5MeJmagDSZ', 19);
export const USDT = toTokenSlug('KT1XnTn74bUtxHfDtBmm2bGZAQfhPbvKWR8o', 0);
export const UBTC = toTokenSlug('KT1XRPEPXbZK25r3Htzp2o1x7xdMMmfocKNW', 2);
export const YOU = toTokenSlug('KT1Xobej4mc6XgEjDoJoHtTKgbD1ELMvcQuL', 0);
export const SIRS = toTokenSlug('KT1AafHA1C1vk959wvHWBispY9Y2f3fxBUUo', 0);
export const TEMPLE = toTokenSlug(TempleToken.contract, TempleToken.id);
}

const YOUVES_COLORS = { bg: '#143A3A', bgHover: '#4F6B6B' };

export const SCAM_COLORS = { bg: '#C53030', bgHover: '#D15A59' };

export const TOKENS_BRAND_COLORS: Record<string, { bg: string; bgHover?: string }> = {
[KNOWN_TOKENS_SLUGS.KUSD]: { bg: '#3EBD93', bgHover: '#65CAA9' },
[KNOWN_TOKENS_SLUGS.TZBTC]: { bg: '#1373E4', bgHover: '#428FE9' },
[KNOWN_TOKENS_SLUGS.USDT]: { bg: '#009393', bgHover: '#52AF95' },
[KNOWN_TOKENS_SLUGS.UUSD]: YOUVES_COLORS,
[KNOWN_TOKENS_SLUGS.UBTC]: YOUVES_COLORS,
[KNOWN_TOKENS_SLUGS.YOU]: YOUVES_COLORS
};

const DEPRECATED_TKEY_METADATA: TokenMetadata = {
id: '0',
address: 'KT1WihWRnmzhfebi6zqQ4tvNGiPeVxiGwTi2',
Expand Down
Loading