mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +01:00
Security Alert Blockaid: fix propType and add instance to ConfirmApprove page (#20494)
* fix: SecurityProviderBannerAlert propTypes * feat: add ConfirmApprove BlockaidBannerAlert
This commit is contained in:
parent
65c13d3490
commit
8807d06535
@ -83,7 +83,7 @@ SecurityProviderBannerAlert.propTypes = {
|
||||
.isRequired,
|
||||
|
||||
/** Severity level */
|
||||
severity: PropTypes.oneOfType([Severity.Danger, Severity.Warning]).isRequired,
|
||||
severity: PropTypes.oneOf([Severity.Danger, Severity.Warning]).isRequired,
|
||||
|
||||
/** Title to be passed as <BannerAlert> param */
|
||||
title: PropTypes.string.isRequired,
|
||||
@ -96,7 +96,7 @@ SecurityProviderBannerAlert.propTypes = {
|
||||
details: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
||||
|
||||
/** Name of the security provider */
|
||||
provider: PropTypes.oneOfType(Object.values(SecurityProvider)),
|
||||
provider: PropTypes.oneOf(Object.values(SecurityProvider)),
|
||||
};
|
||||
|
||||
export default SecurityProviderBannerAlert;
|
||||
|
@ -22,6 +22,9 @@ import {
|
||||
} from '../../../helpers/constants/design-system';
|
||||
import { ConfirmPageContainerWarning } from '../../../components/app/confirm-page-container/confirm-page-container-content';
|
||||
import LedgerInstructionField from '../../../components/app/ledger-instruction-field';
|
||||
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
|
||||
import BlockaidBannerAlert from '../../../components/app/security-provider-banner-alert/blockaid-banner-alert/blockaid-banner-alert';
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
import { isSuspiciousResponse } from '../../../../shared/modules/security-provider.utils';
|
||||
|
||||
import { TokenStandard } from '../../../../shared/constants/transaction';
|
||||
@ -551,6 +554,13 @@ export default class ConfirmApproveContent extends Component {
|
||||
'confirm-approve-content--full': showFullTxDetails,
|
||||
})}
|
||||
>
|
||||
{
|
||||
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
|
||||
<BlockaidBannerAlert
|
||||
securityAlertResponse={txData?.securityAlertResponse}
|
||||
/>
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
}
|
||||
{isSuspiciousResponse(txData?.securityProviderResponse) && (
|
||||
<SecurityProviderBannerMessage
|
||||
securityProviderResponse={txData.securityProviderResponse}
|
||||
|
@ -3,6 +3,7 @@ import configureMockStore from 'redux-mock-store';
|
||||
import { fireEvent } from '@testing-library/react';
|
||||
import { renderWithProvider } from '../../../../test/jest/rendering';
|
||||
import { TokenStandard } from '../../../../shared/constants/transaction';
|
||||
import { BlockaidResultType } from '../../../../shared/constants/security-provider';
|
||||
import ConfirmApproveContent from '.';
|
||||
|
||||
const renderComponent = (props) => {
|
||||
@ -343,4 +344,21 @@ describe('ConfirmApproveContent Component', () => {
|
||||
|
||||
expect(getByText(securityProviderResponse.reason)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render security alert if provided', () => {
|
||||
const mockSecurityAlertResponse = {
|
||||
result_type: BlockaidResultType.Malicious,
|
||||
reason: 'blur_farming',
|
||||
};
|
||||
|
||||
const { getByText } = renderComponent({
|
||||
...props,
|
||||
txData: {
|
||||
...props.txData,
|
||||
securityAlertResponse: mockSecurityAlertResponse,
|
||||
},
|
||||
});
|
||||
|
||||
expect(getByText('This is a deceptive request')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user