mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +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,
|
.isRequired,
|
||||||
|
|
||||||
/** Severity level */
|
/** 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 to be passed as <BannerAlert> param */
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
@ -96,7 +96,7 @@ SecurityProviderBannerAlert.propTypes = {
|
|||||||
details: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
details: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
||||||
|
|
||||||
/** Name of the security provider */
|
/** Name of the security provider */
|
||||||
provider: PropTypes.oneOfType(Object.values(SecurityProvider)),
|
provider: PropTypes.oneOf(Object.values(SecurityProvider)),
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SecurityProviderBannerAlert;
|
export default SecurityProviderBannerAlert;
|
||||||
|
@ -22,6 +22,9 @@ import {
|
|||||||
} from '../../../helpers/constants/design-system';
|
} from '../../../helpers/constants/design-system';
|
||||||
import { ConfirmPageContainerWarning } from '../../../components/app/confirm-page-container/confirm-page-container-content';
|
import { ConfirmPageContainerWarning } from '../../../components/app/confirm-page-container/confirm-page-container-content';
|
||||||
import LedgerInstructionField from '../../../components/app/ledger-instruction-field';
|
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 { isSuspiciousResponse } from '../../../../shared/modules/security-provider.utils';
|
||||||
|
|
||||||
import { TokenStandard } from '../../../../shared/constants/transaction';
|
import { TokenStandard } from '../../../../shared/constants/transaction';
|
||||||
@ -551,6 +554,13 @@ export default class ConfirmApproveContent extends Component {
|
|||||||
'confirm-approve-content--full': showFullTxDetails,
|
'confirm-approve-content--full': showFullTxDetails,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
{
|
||||||
|
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
|
||||||
|
<BlockaidBannerAlert
|
||||||
|
securityAlertResponse={txData?.securityAlertResponse}
|
||||||
|
/>
|
||||||
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
}
|
||||||
{isSuspiciousResponse(txData?.securityProviderResponse) && (
|
{isSuspiciousResponse(txData?.securityProviderResponse) && (
|
||||||
<SecurityProviderBannerMessage
|
<SecurityProviderBannerMessage
|
||||||
securityProviderResponse={txData.securityProviderResponse}
|
securityProviderResponse={txData.securityProviderResponse}
|
||||||
|
@ -3,6 +3,7 @@ import configureMockStore from 'redux-mock-store';
|
|||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
import { renderWithProvider } from '../../../../test/jest/rendering';
|
import { renderWithProvider } from '../../../../test/jest/rendering';
|
||||||
import { TokenStandard } from '../../../../shared/constants/transaction';
|
import { TokenStandard } from '../../../../shared/constants/transaction';
|
||||||
|
import { BlockaidResultType } from '../../../../shared/constants/security-provider';
|
||||||
import ConfirmApproveContent from '.';
|
import ConfirmApproveContent from '.';
|
||||||
|
|
||||||
const renderComponent = (props) => {
|
const renderComponent = (props) => {
|
||||||
@ -343,4 +344,21 @@ describe('ConfirmApproveContent Component', () => {
|
|||||||
|
|
||||||
expect(getByText(securityProviderResponse.reason)).toBeInTheDocument();
|
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