Skip to content

Commit

Permalink
chore: move native tranfer logic directly to asset transfer component
Browse files Browse the repository at this point in the history
  • Loading branch information
shan8851 committed Jan 7, 2025
1 parent 3fb1e45 commit e95c5ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 7 additions & 5 deletions src/modules/components/asset/assetTransfer/assetTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Avatar, AvatarIcon, DataList, IconType, NumberFormat, formatterUtils }
import { ChainEntityType, useBlockExplorer } from '../../../hooks';
import { type ICompositeAddress, type IWeb3ComponentProps } from '../../../types';
import { AssetTransferAddress } from './assetTransferAddress';
import { zeroAddress } from 'viem';

export interface IAssetTransferProps extends IWeb3ComponentProps {
/**
Expand Down Expand Up @@ -55,9 +56,11 @@ export const AssetTransfer: React.FC<IAssetTransferProps> = (props) => {

const { buildEntityUrl } = useBlockExplorer({ chains: wagmiConfig?.chains, chainId });

// For native transfers we do not want to link to the block explorer
const isNativeTransfer = assetAddress === zeroAddress;
const senderUrl = buildEntityUrl({ type: ChainEntityType.ADDRESS, id: sender.address });
const recipientUrl = buildEntityUrl({ type: ChainEntityType.ADDRESS, id: recipient.address });
const assetUrl = buildEntityUrl({ type: ChainEntityType.TOKEN, id: assetAddress });
const assetUrl = isNativeTransfer ? undefined : buildEntityUrl({ type: ChainEntityType.TOKEN, id: assetAddress });

const formattedTokenValue = formatterUtils.formatNumber(assetAmount, {
format: NumberFormat.TOKEN_AMOUNT_SHORT,
Expand All @@ -74,10 +77,9 @@ export const AssetTransfer: React.FC<IAssetTransferProps> = (props) => {

const assetTransferClassNames = classNames(
'flex h-16 w-full items-center justify-between rounded-xl border border-neutral-100 bg-neutral-0 px-4', // base
assetAddress && 'hover:border-neutral-200 hover:shadow-neutral-md', // hover
assetAddress &&
'focus:outline-none focus-visible:rounded-xl focus-visible:ring focus-visible:ring-primary focus-visible:ring-offset', // focus
assetAddress && 'active:border-neutral-300 active:shadow-none', // active
'hover:border-neutral-200 hover:shadow-neutral-md', // hover
'focus:outline-none focus-visible:rounded-xl focus-visible:ring focus-visible:ring-primary focus-visible:ring-offset', // focus
'active:border-neutral-300 active:shadow-none', // active
'md:h-20 md:px-6', // responsive
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { zeroAddress } from 'viem';
import { AssetTransfer } from '../../../../asset';
import type { IProposalActionWithdrawTokenProps } from './proposalActionWithdrawToken.api';

export const ProposalActionWithdrawToken: React.FC<IProposalActionWithdrawTokenProps> = (props) => {
const { action, ...web3Props } = props;

// For native transfers we do not want to link to the block explorer
const isNativeTransfer = action.token.address === zeroAddress;

return (
<AssetTransfer
sender={action.sender}
recipient={action.receiver}
assetName={action.token.name}
assetAddress={!isNativeTransfer ? action.token.address : undefined}
assetAddress={action.token.address}
assetAmount={action.amount}
assetFiatPrice={action.token.priceUsd}
assetSymbol={action.token.symbol}
Expand Down

0 comments on commit e95c5ec

Please sign in to comment.