Skip to content

Commit

Permalink
fix(suite): select token fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Nov 5, 2024
1 parent dc7bfe3 commit db25fc3
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 337 deletions.
7 changes: 3 additions & 4 deletions packages/components/src/components/AssetLogo/AssetLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const AssetLogo = ({

const logoUrl = getAssetLogoUrl({ coingeckoId, contractAddress });
const logoUrl2x = getAssetLogoUrl({ coingeckoId, contractAddress, quality: '@2x' });

const frameProps = pickAndPrepareFrameProps(rest, allowedAssetLogoFrameProps);

const handleLoad = () => {
Expand All @@ -81,10 +82,8 @@ export const AssetLogo = ({
setIsPlaceholder(true);
};
useEffect(() => {
if (shouldTryToFetch) {
setIsPlaceholder(false);
}
}, [shouldTryToFetch, fileName]);
setIsPlaceholder(!shouldTryToFetch);
}, [shouldTryToFetch]);

return (
<Container $size={size} {...frameProps}>
Expand Down
12 changes: 6 additions & 6 deletions packages/components/src/components/form/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ type WrapperProps = TransientProps<
$isWithPlaceholder: boolean;
$hasBottomPadding: boolean;
$elevation: Elevation;
$focusEnabled: boolean;
$isFocusEnabled: boolean;
};

const Wrapper = styled.div<WrapperProps>`
Expand Down Expand Up @@ -163,8 +163,8 @@ const Wrapper = styled.div<WrapperProps>`
}
&:focus-within {
${({ $focusEnabled }) =>
$focusEnabled
${({ $isFocusEnabled }) =>
$isFocusEnabled
? css`
.${reactSelectClassNamePrefix}__dropdown-indicator {
transform: rotate(180deg);
Expand Down Expand Up @@ -278,7 +278,7 @@ interface CommonProps extends Omit<ReactSelectProps<Option>, 'onChange' | 'menuI
* @description pass `null` if bottom text can be `undefined`
*/
bottomText?: ReactNode;
focusEnabled?: boolean;
isFocusEnabled?: boolean;
hasBottomPadding?: boolean;
minValueWidth?: string; // TODO: should be probably removed
inputState?: InputState;
Expand All @@ -305,7 +305,7 @@ export const Select = ({
useKeyPressScroll,
isSearchable = false,
minValueWidth = 'initial',
focusEnabled = true,
isFocusEnabled = true,
isMenuOpen,
inputState,
components,
Expand Down Expand Up @@ -368,7 +368,7 @@ export const Select = ({
$minValueWidth={minValueWidth}
$isDisabled={isDisabled}
$isMenuOpen={isMenuOpen}
$focusEnabled={focusEnabled}
$isFocusEnabled={isFocusEnabled}
$isWithLabel={!!label}
$isWithPlaceholder={!!placeholder}
$hasBottomPadding={hasBottomPadding === true && bottomText === null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const BadgeWrapper = styled.div`

type AssetItemProps = {
name?: string;
symbol: NetworkSymbol;
symbol: string;
badge: string | undefined;
networkSymbol: NetworkSymbol;
networkSymbol: NetworkSymbol | ({} & string);
coingeckoId: string;
logo: JSX.Element;
isFavorite?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useIntl } from 'react-intl';
import { AssetItemNotFound } from './AssetItemNotFound';
import { getNetworkByCoingeckoId, Network, NetworkSymbol } from '@suite-common/wallet-config';
import { SendTokenTabs } from './SendTokenTabs';
import { getContractAddressForNetwork } from '@suite-common/wallet-utils';

export interface SelectAssetOptionCurrencyProps {
type: 'currency';
Expand Down Expand Up @@ -254,17 +255,24 @@ export const SelectAssetModal = ({
<AssetItem
key={`${symbol}-${name}`}
name={name}
symbol={symbol as NetworkSymbol}
symbol={symbol}
coingeckoId={coingeckoId}
contractAddress={contractAddress || null}
networkSymbol={networkSymbol as NetworkSymbol}
networkSymbol={networkSymbol}
isFavorite={isFavorite}
badge={badge}
logo={
<AssetLogo
size={24}
coingeckoId={coingeckoId}
contractAddress={contractAddress?.toLowerCase()}
contractAddress={
networkSymbol && contractAddress
? getContractAddressForNetwork(
networkSymbol as NetworkSymbol,
contractAddress,
)
: undefined
}
placeholder={symbol.toUpperCase()}
/>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AssetLogo, useElevation } from '@trezor/components';
import { getCoingeckoId, NetworkSymbol } from '@suite-common/wallet-config';
import { TokenInfo } from '@trezor/connect';
import { getContractAddressForNetwork } from '@suite-common/wallet-utils';

import styled, { css } from 'styled-components';
import { borders, Elevation, mapElevationToBackground, mapElevationToBorder } from '@trezor/theme';
Expand Down Expand Up @@ -56,7 +57,7 @@ export const TokenIconSet = ({ network, tokens }: TokenIconSetProps) => {
key={token.contract}
size={20}
coingeckoId={coingeckoId ?? ''}
contractAddress={token.contract.toLowerCase()}
contractAddress={getContractAddressForNetwork(network, token.contract)}
placeholder={token.symbol?.toUpperCase() ?? ''}
placeholderWithTooltip={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import {
SelectAssetOptionCurrencyProps,
SelectAssetOptionProps,
} from '@trezor/product-components';
import { networks, NetworkSymbol } from '@suite-common/wallet-config';
import {
getNetworkByCoingeckoNativeId,
networks,
NetworkSymbol,
} from '@suite-common/wallet-config';
import {
FORM_CRYPTO_CURRENCY_SELECT,
FORM_RECEIVE_CRYPTO_CURRENCY_SELECT,
Expand Down Expand Up @@ -76,7 +80,9 @@ export const CoinmarketFormInputCryptoSelect = <
? {
...option,
symbol: option.label.toUpperCase(),
networkSymbol: parseCryptoId(option.value).networkId,
networkSymbol:
getNetworkByCoingeckoNativeId(parseCryptoId(option.value).networkId)
?.symbol || parseCryptoId(option.value).networkId,
contractAddress: option.contractAddress ?? null,
}
: option,
Expand Down
208 changes: 0 additions & 208 deletions packages/suite/src/views/wallet/send/Outputs/Amount/TokenSelect.tsx

This file was deleted.

Loading

0 comments on commit db25fc3

Please sign in to comment.