Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronfigueiredo committed Oct 24, 2024
1 parent cbc3616 commit ab2e5f0
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions ui/pages/confirmations/components/confirm/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,20 @@ import { DAppInitiatedHeader } from './dapp-initiated-header';
import HeaderInfo from './header-info';
import { WalletInitiatedHeader } from './wallet-initiated-header';

const CONFIRMATIONS_WITH_NEW_HEADER = [
TransactionType.tokenMethodTransfer,
TransactionType.tokenMethodTransferFrom,
TransactionType.tokenMethodSafeTransferFrom,
];

const Header = () => {
const { networkImageUrl, networkDisplayName } = useConfirmationNetworkInfo();
const { senderAddress: fromAddress, senderName: fromName } =
useConfirmationRecipientInfo();

const { currentConfirmation } = useConfirmContext<Confirmation>();

const CONFIRMATIONS_WITH_NEW_HEADER = [
TransactionType.tokenMethodTransfer,
TransactionType.tokenMethodTransferFrom,
TransactionType.tokenMethodSafeTransferFrom,
];

if (
currentConfirmation?.type &&
CONFIRMATIONS_WITH_NEW_HEADER.includes(currentConfirmation.type)
) {
const isWalletInitiated =
(currentConfirmation as TransactionMeta).origin === 'metamask';

if (isWalletInitiated) {
return <WalletInitiatedHeader />;
}
return <DAppInitiatedHeader />;
}

return (
const DefaultHeader = () => (
<Box
display={Display.Flex}
className="confirm_header__wrapper"
Expand Down Expand Up @@ -92,6 +79,22 @@ const Header = () => {
</Box>
</Box>
);

// The new header includes only a heading, the advanced details toggle, and a
// back button if it's a wallet initiated confirmation. The default header is
// the original header for the redesigns and includes the sender and recipient
// addresses as well.
const isConfirmationWithNewHeader =
currentConfirmation?.type &&
CONFIRMATIONS_WITH_NEW_HEADER.includes(currentConfirmation.type);
const isWalletInitiated =
(currentConfirmation as TransactionMeta).origin === 'metamask';
if (isConfirmationWithNewHeader && isWalletInitiated) {
return <WalletInitiatedHeader />;
} else if (isConfirmationWithNewHeader && !isWalletInitiated) {
return <DAppInitiatedHeader />;
}
return <DefaultHeader />;
};

export default Header;

0 comments on commit ab2e5f0

Please sign in to comment.