1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/components/app/signature-request-siwe/signature-request-siwe-header/signature-request-siwe-header.js
Albert Olivé 057188d155
[MMI] Add code fences in signature-request (#18770)
* Started adding code fences in signature-request

* Finished code fencing

* Improving code

* Fixed storybook and code fences bundle

* Added missing dependency

* Fixed yarn.lock

* Fixing policies

* Updated package.json

* updating lavamoat

* lavamoat fix

* adds missing package

* runs yarn dedupe

* updates method name

* run lavamoat:auto again

* Added more code fences

* updates snapshot

* snapshot updates

* updates mmi packages to lighter versions

* updates mmi packages

* runs lavamoat auto

* updates yarn lock and runs lavamoat auto

* updates yarn lock

* updates targets file

* Removed console log and added tests

---------

Co-authored-by: António Regadas <apregadas@gmail.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
2023-05-24 13:41:21 +02:00

80 lines
2.3 KiB
JavaScript

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import AccountListItem from '../../account-list-item';
import { I18nContext } from '../../../../contexts/i18n';
import PermissionsConnectHeader from '../../permissions-connect-header';
import SignatureRequestSIWEIcon from '../signature-request-siwe-icon';
import SignatureRequestSIWETag from '../signature-request-siwe-tag';
import Tooltip from '../../../ui/tooltip';
export default function SignatureRequestSIWEHeader({
fromAccount,
domain,
isSIWEDomainValid,
subjectMetadata,
}) {
const t = useContext(I18nContext);
return (
<div className="signature-request-siwe-header">
<PermissionsConnectHeader
iconUrl={subjectMetadata.iconUrl}
iconName={subjectMetadata.name}
headerTitle={t('SIWESiteRequestTitle')}
headerText={t('SIWESiteRequestSubtitle')}
siteOrigin={domain}
className={isSIWEDomainValid ? '' : 'bad-domain'}
leftIcon={
!isSIWEDomainValid && (
<Tooltip
position="bottom"
html={<p>{t('SIWEDomainWarningBody', [domain])}</p>}
>
<SignatureRequestSIWEIcon />
</Tooltip>
)
}
rightIcon={
!isSIWEDomainValid && (
<Tooltip
position="bottom"
html={<p>{t('SIWEDomainWarningBody', [domain])}</p>}
>
<SignatureRequestSIWETag text={t('SIWEDomainWarningLabel')} />
</Tooltip>
)
}
/>
{fromAccount && (
<AccountListItem
account={fromAccount}
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
hideDefaultMismatchWarning
///: END:ONLY_INCLUDE_IN
className="signature-request-siwe-header__account-list-item"
/>
)}
</div>
);
}
SignatureRequestSIWEHeader.propTypes = {
/**
* The account that is requesting permissions
*/
fromAccount: PropTypes.object,
/**
* The domain that the request is for
*/
domain: PropTypes.string,
/**
* Whether the domain is valid
*/
isSIWEDomainValid: PropTypes.bool,
/**
* The metadata for the subject. This is used to display the icon and name
* and is selected from the domain in the SIWE request.
*/
subjectMetadata: PropTypes.object,
};