Skip to content

Commit

Permalink
front: update FT icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Thykof committed Jun 5, 2024
1 parent c472d1e commit b4eec42
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 98 deletions.
34 changes: 17 additions & 17 deletions wails-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions web-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions web-frontend/src/pages/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useState } from 'react';

import { Token, getAssetIcons } from '@massalabs/react-ui-kit';
import { Token } from '@massalabs/react-ui-kit';

import { useFTTransfer } from '@/custom/smart-contract/useFTTransfer';
import Intl from '@/i18n/i18n';
import { Asset } from '@/models/AssetModel';
import { DeleteAssetModal } from '@/pages/Assets/DeleteAssets';
import { symbolDict } from '@/utils/tokenIcon';
import { tokenIcon } from '@/utils/tokenIcon';

interface AssetsListProps {
assets: Asset[] | undefined;
Expand All @@ -23,20 +22,13 @@ export function AssetsList(props: AssetsListProps) {
setModal(true);
}

const { isMainnet } = useFTTransfer();

return (
<>
{assets
?.filter((a) => a.balance !== undefined && a.balance !== '')
.map((token: Asset, index: number) => (
<Token
logo={getAssetIcons(
symbolDict[token.symbol as keyof typeof symbolDict],
true,
isMainnet,
32,
)}
logo={tokenIcon(token.symbol, 32)}
name={token.name}
symbol={token.symbol}
decimals={token.decimals}
Expand Down
18 changes: 2 additions & 16 deletions web-frontend/src/pages/TransferCoins/ReceiveCoins/GenerateLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ import {
PopupModalHeader,
Clipboard,
formatAmount,
getAssetIcons,
Selector,
Identicon,
} from '@massalabs/react-ui-kit';

import { useFTTransfer } from '@/custom/smart-contract/useFTTransfer';
import Intl from '@/i18n/i18n';
import { AccountObject } from '@/models/AccountModel';
import { Asset } from '@/models/AssetModel';
import { AssetSelector } from '@/pages/TransferCoins/SendCoins/AssetSelector';
import { parseForm } from '@/utils/';
import { symbolDict } from '@/utils/tokenIcon';
import { tokenIcon } from '@/utils/tokenIcon';
import { SendInputsErrors } from '@/validation/sendInputs';

interface MoneyForm {
Expand All @@ -37,8 +35,6 @@ interface GenerateLinkProps {
function GenerateLink(props: GenerateLinkProps) {
const { account, presetURL, setURL, setModal } = props;

const { isMainnet } = useFTTransfer();

const [amount, setAmount] = useState<string>('');
const [link, setLink] = useState('');
const [error, setError] = useState<SendInputsErrors | null>(null);
Expand Down Expand Up @@ -121,17 +117,7 @@ function GenerateLink(props: GenerateLinkProps) {
preIcon={<Identicon username={account.nickname} />}
content={account.nickname}
amount={formattedBalance}
posIcon={
getAssetIcons(
symbolDict[
selectedAsset?.symbol as keyof typeof symbolDict
],
true,
isMainnet,
24,
'mr-3',
) as JSX.Element
}
posIcon={tokenIcon(selectedAsset?.symbol || '', 24)}
variant="secondary"
/>
</div>
Expand Down
18 changes: 3 additions & 15 deletions web-frontend/src/pages/TransferCoins/SendCoins/AssetSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { useEffect } from 'react';

import {
Dropdown,
formatAmount,
getAssetIcons,
IOption,
} from '@massalabs/react-ui-kit';
import { Dropdown, formatAmount, IOption } from '@massalabs/react-ui-kit';
import { useParams } from 'react-router-dom';

import { useResource } from '@/custom/api';
import { useFTTransfer } from '@/custom/smart-contract/useFTTransfer';
import Intl from '@/i18n/i18n';
import { Asset } from '@/models/AssetModel';
import { symbolDict } from '@/utils/tokenIcon';
import { tokenIcon } from '@/utils/tokenIcon';

interface AssetSelectorProps {
selectedAsset: Asset | undefined;
Expand All @@ -23,7 +17,6 @@ interface AssetSelectorProps {
export function AssetSelector(props: AssetSelectorProps) {
const { selectedAsset, setSelectedAsset, selectSymbol } = props;
const { nickname } = useParams();
const { isMainnet } = useFTTransfer();

const { data: assets, isLoading: isAssetsLoading } = useResource<Asset[]>(
`accounts/${nickname}/assets`,
Expand Down Expand Up @@ -60,12 +53,7 @@ export function AssetSelector(props: AssetSelectorProps) {
</p>
</div>
),
icon: getAssetIcons(
symbolDict[asset.symbol as keyof typeof symbolDict],
true,
isMainnet,
28,
),
icon: tokenIcon(asset.symbol, 28),
onClick: () => setSelectedAsset(asset),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
Button,
Tooltip,
formatFTAmount,
getAssetIcons,
parseAmount,
Clipboard,
Mns,
Expand All @@ -14,8 +13,7 @@ import { FiChevronLeft } from 'react-icons/fi';
import { PRESET_HIGH, PRESET_LOW, PRESET_STANDARD } from './Advanced';
import Intl from '@/i18n/i18n';
import { Asset } from '@/models/AssetModel';
import { useMassaWeb3Store } from '@/store/store';
import { symbolDict } from '@/utils/tokenIcon';
import { tokenIcon } from '@/utils/tokenIcon';

export interface SendConfirmationData {
amount: string;
Expand All @@ -33,7 +31,6 @@ interface SendConfirmationProps {

export function SendConfirmation(props: SendConfirmationProps) {
const { data, handleConfirm, isLoading } = props;
const { isMainnet } = useMassaWeb3Store();

const { amount, asset, fees, recipientAddress, recipientDomainName } = data;
const { symbol, decimals } = asset;
Expand Down Expand Up @@ -106,13 +103,7 @@ export function SendConfirmation(props: SendConfirmationProps) {
customClass="p-0 bg-transparent"
amount={formattedAmount}
symbol={symbol}
icon={getAssetIcons(
symbolDict[symbol as keyof typeof symbolDict],
true,
isMainnet,
32,
'mr-3',
)}
icon={tokenIcon(symbol, 28)}
/>
<div className="flex flex-col gap-4 p-4">
<div className="flex items-center gap-8">
Expand Down
15 changes: 4 additions & 11 deletions web-frontend/src/utils/tokenIcon.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { MAS } from '@/const/assets/assets';
import { getAssetIcons } from '@massalabs/react-ui-kit';

export const symbolDict = {
MAS: MAS,
WMAS: 'WMAS',
'WETH.e': 'WETH',
'WETH.s': 'WETH',
'USDC.e': 'USDC',
'USDC.s': 'USDC',
'DAI.e': 'DAI',
'tDAI.s': 'DAI',
};
export function tokenIcon(symbol: string, size: number) {
return getAssetIcons(symbol, undefined, false, size) as JSX.Element;
}

0 comments on commit b4eec42

Please sign in to comment.