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

txs: fallback icons #5456

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
114 changes: 49 additions & 65 deletions src/components/coin-row/FastTransactionCoinRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ImgixImage } from '../images';
import { CardSize } from '../unique-token/CardSize';
import { ChainBadge } from '../coin-icon';
import { Network } from '@/networks/types';
import { ETH_ADDRESS, ETH_SYMBOL } from '@/references';
import { address } from '@/utils/abbreviations';
import { Colors } from '@/styles';
import { TransactionType } from '@/resources/transactions/types';
Expand All @@ -29,34 +28,11 @@ export const getApprovalLabel = ({ approvalAmount, asset, type }: Pick<RainbowTr
};

const approvalTypeValues = (transaction: RainbowTransaction) => {
const { asset, approvalAmount, hash, contract } = transaction;
const { asset, approvalAmount } = transaction;

if (!asset || !approvalAmount) return;
transaction.protocol;
return [transaction.protocol || '', getApprovalLabel(transaction)];

// return [
// contract?.name ? (
// <Inline key={`app${hash}`} alignVertical="center" space="4px">
// {contract.iconUrl && (
// <Text size="11pt" weight="semibold" color="labelTertiary">
// {'Con Icon'}
// </Text>
// )}
// {contract.name}
// </Inline>
// ) : null,
// label && (
// <Box
// key={`approval${hash}`}
// style={{ borderStyle: 'dashed', borderRadius: 6, borderColor: 'red', borderWidth: 1 }}
// >
// <Text size="11pt" weight="semibold" color="labelTertiary">
// {label}
// </Text>
// </Box>
// ),
// ];
};

const swapTypeValues = (changes: RainbowTransaction['changes']) => {
Expand Down Expand Up @@ -297,6 +273,25 @@ export const ActivityIcon = ({
);
}

// fallback for contracts that we dont have data for
if (transaction?.type === 'contract_interaction') {
return (
<Box
alignItems="center"
background="fillSecondary"
borderRadius={10}
height={{ custom: size }}
justifyContent="center"
style={{ opacity: theme.isDarkMode ? 0.5 : 0.75 }}
width={{ custom: size }}
>
<Text align="center" color="labelQuaternary" size="icon 16px" weight="bold">
􀎭
</Text>
</Box>
);
}

if (transaction?.asset?.type === 'nft') {
return (
<View
Expand All @@ -316,18 +311,35 @@ export const ActivityIcon = ({
shadowRadius: 9,
}}
>
<ImgixImage
size={CardSize}
style={{
width: size,
height: size,
borderRadius: 10,
}}
source={{
// @ts-ignore local nft assets have diff types
uri: transaction.asset.icon_url || transaction.asset.image_url,
}}
/>
{/* @ts-ignore local nft assets have diff types */}
{transaction.asset.icon_url || transaction.asset.image_url ? (
<ImgixImage
size={CardSize}
style={{
width: size,
height: size,
borderRadius: 10,
}}
source={{
// @ts-ignore local nft assets have diff types
uri: transaction.asset.icon_url || transaction.asset.image_url,
}}
/>
) : (
<Box
alignItems="center"
background="fillSecondary"
borderRadius={10}
height={{ custom: size }}
justifyContent="center"
style={{ opacity: theme.isDarkMode ? 0.5 : 0.75 }}
width={{ custom: size }}
>
<Text align="center" color="labelQuaternary" size="icon 16px" weight="bold">
􀏆
</Text>
</Box>
)}
</View>
{transaction.network !== Network.mainnet && <ChainBadge network={transaction.network} badgeYPosition={0} />}
</View>
Expand All @@ -348,34 +360,6 @@ export const ActivityIcon = ({
);
};

const ActivityDescription = ({ transaction, colors }: { transaction: RainbowTransaction; colors: Colors }) => {
const { type, to, asset } = transaction;
let description = transaction.description;
let tag: string | undefined;
if (type === 'contract_interaction' && to) {
description = transaction.contract?.name || address(to, 6, 4);
tag = transaction.description;
}

const nftChangesAmount = transaction.changes
?.filter(c => asset?.address === c?.asset.address && c?.asset.type === 'nft')
.filter(Boolean).length;
if (nftChangesAmount) tag = nftChangesAmount.toString();

return (
<Inline space="4px" alignVertical="center" wrap={false}>
<Text size="16px / 22px (Deprecated)" weight="regular" color={{ custom: colors.dark }}>
{description}
</Text>
{tag && (
<Text size="16px / 22px (Deprecated)" weight="regular" color={{ custom: colors.dark }}>
{tag}
</Text>
)}
</Inline>
);
};

export default React.memo(function TransactionCoinRow({
item,
nativeCurrency,
Expand Down