1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Clean up some code fencing around snaps (#18802)

* Clean up some code fencing around snaps

* Fix code fencing

* Fix more fencing issues
This commit is contained in:
Frederik Bolding 2023-05-03 10:53:58 +02:00 committed by GitHub
parent 120dfcdf32
commit c716592fd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 25 additions and 41 deletions

View File

@ -17,7 +17,7 @@ import { useTransactionInsightSnap } from '../../../../hooks/snaps/useTransactio
import Box from '../../../ui/box/box'; import Box from '../../../ui/box/box';
import { SnapUIRenderer } from '../../snaps/snap-ui-renderer'; import { SnapUIRenderer } from '../../snaps/snap-ui-renderer';
import { SnapDelineator } from '../../snaps/snap-delineator'; import { SnapDelineator } from '../../snaps/snap-delineator';
import { DelineatorType } from '../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../helpers/constants/snaps';
import { getSnapName } from '../../../../helpers/utils/util'; import { getSnapName } from '../../../../helpers/utils/util';
import { Copyable } from '../../snaps/copyable'; import { Copyable } from '../../snaps/copyable';
import { getTargetSubjectMetadata } from '../../../../selectors'; import { getTargetSubjectMetadata } from '../../../../selectors';

View File

@ -2,7 +2,7 @@ import React from 'react';
import SnapAuthorship from '.'; import SnapAuthorship from '.';
export default { export default {
title: 'Components/App/Flask/SnapAuthorship', title: 'Components/App/Snaps/SnapAuthorship',
component: SnapAuthorship, component: SnapAuthorship,
argTypes: { argTypes: {

View File

@ -2,7 +2,7 @@ import React from 'react';
import SnapAvatar from '.'; import SnapAvatar from '.';
export default { export default {
title: 'Components/App/Flask/SnapAvatar', title: 'Components/App/Snaps/SnapAvatar',
component: SnapAvatar, component: SnapAvatar,
argTypes: { argTypes: {

View File

@ -3,7 +3,7 @@ import React from 'react';
import SnapContentFooter from '.'; import SnapContentFooter from '.';
export default { export default {
title: 'Components/App/Flask/SnapContentFooter', title: 'Components/App/Snaps/SnapContentFooter',
component: SnapContentFooter, component: SnapContentFooter,
args: { args: {

View File

@ -21,7 +21,7 @@ import {
import { import {
DelineatorType, DelineatorType,
getDelineatorTitle, getDelineatorTitle,
} from '../../../../helpers/constants/flask'; } from '../../../../helpers/constants/snaps';
export const SnapDelineator = ({ export const SnapDelineator = ({
snapName, snapName,

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { DelineatorType } from '../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../helpers/constants/snaps';
import { renderWithLocalization } from '../../../../../test/lib/render-helpers'; import { renderWithLocalization } from '../../../../../test/lib/render-helpers';
import { SnapDelineator } from './snap-delineator'; import { SnapDelineator } from './snap-delineator';

View File

@ -3,7 +3,7 @@ import React from 'react';
import SnapPermissionsList from '.'; import SnapPermissionsList from '.';
export default { export default {
title: 'Components/App/flask/SnapPermissionsList', title: 'Components/App/Snaps/SnapPermissionsList',
component: SnapPermissionsList, component: SnapPermissionsList,
argTypes: { argTypes: {

View File

@ -5,7 +5,7 @@ import README from './README.mdx';
import SnapSettingsCard from '.'; import SnapSettingsCard from '.';
export default { export default {
title: 'Components/App/Flask/SnapSettingsCard', title: 'Components/App/Snaps/SnapSettingsCard',
component: SnapSettingsCard, component: SnapSettingsCard,
parameters: { parameters: {

View File

@ -18,7 +18,7 @@ import { getSnapName } from '../../../../helpers/utils/util';
import { getTargetSubjectMetadata } from '../../../../selectors'; import { getTargetSubjectMetadata } from '../../../../selectors';
import { Text } from '../../../component-library'; import { Text } from '../../../component-library';
import { Copyable } from '../copyable'; import { Copyable } from '../copyable';
import { DelineatorType } from '../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../helpers/constants/snaps';
export const UI_MAPPING = { export const UI_MAPPING = {
panel: (props, elementKey) => ({ panel: (props, elementKey) => ({

View File

@ -1,5 +1,5 @@
import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer'; import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer';
import { DelineatorType } from '../../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../../helpers/constants/snaps';
function getValues(pendingApproval, t, actions) { function getValues(pendingApproval, t, actions) {
const { const {

View File

@ -1,5 +1,5 @@
import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer'; import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer';
import { DelineatorType } from '../../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../../helpers/constants/snaps';
function getValues(pendingApproval, t, actions) { function getValues(pendingApproval, t, actions) {
const { const {

View File

@ -1,6 +1,6 @@
import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer'; import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer';
import { MESSAGE_TYPE } from '../../../../../../shared/constants/app'; import { MESSAGE_TYPE } from '../../../../../../shared/constants/app';
import { DelineatorType } from '../../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../../helpers/constants/snaps';
function getValues(pendingApproval, t, actions, _history, setInputState) { function getValues(pendingApproval, t, actions, _history, setInputState) {
const { const {

View File

@ -38,11 +38,11 @@ export default class PermissionConnect extends Component {
history: PropTypes.object.isRequired, history: PropTypes.object.isRequired,
connectPath: PropTypes.string.isRequired, connectPath: PropTypes.string.isRequired,
confirmPermissionPath: PropTypes.string.isRequired, confirmPermissionPath: PropTypes.string.isRequired,
requestType: PropTypes.string.isRequired,
///: BEGIN:ONLY_INCLUDE_IN(snaps) ///: BEGIN:ONLY_INCLUDE_IN(snaps)
snapInstallPath: PropTypes.string.isRequired, snapInstallPath: PropTypes.string.isRequired,
snapUpdatePath: PropTypes.string.isRequired, snapUpdatePath: PropTypes.string.isRequired,
snapResultPath: PropTypes.string.isRequired, snapResultPath: PropTypes.string.isRequired,
requestType: PropTypes.string.isRequired,
requestState: PropTypes.object.isRequired, requestState: PropTypes.object.isRequired,
approvePendingApproval: PropTypes.func.isRequired, approvePendingApproval: PropTypes.func.isRequired,
rejectPendingApproval: PropTypes.func.isRequired, rejectPendingApproval: PropTypes.func.isRequired,
@ -175,23 +175,20 @@ export default class PermissionConnect extends Component {
selectAccounts = (addresses) => { selectAccounts = (addresses) => {
const { const {
confirmPermissionPath, confirmPermissionPath,
requestType,
///: BEGIN:ONLY_INCLUDE_IN(snaps) ///: BEGIN:ONLY_INCLUDE_IN(snaps)
snapInstallPath, snapInstallPath,
snapUpdatePath, snapUpdatePath,
snapResultPath, snapResultPath,
requestType,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
} = this.props; } = this.props;
this.setState( this.setState(
{ {
selectedAccountAddresses: addresses, selectedAccountAddresses: addresses,
}, },
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta)
() => this.props.history.push(confirmPermissionPath),
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(snaps)
() => { () => {
switch (requestType) { switch (requestType) {
///: BEGIN:ONLY_INCLUDE_IN(snaps)
case 'wallet_installSnap': case 'wallet_installSnap':
this.props.history.push(snapInstallPath); this.props.history.push(snapInstallPath);
break; break;
@ -201,11 +198,11 @@ export default class PermissionConnect extends Component {
case 'wallet_installSnapResult': case 'wallet_installSnapResult':
this.props.history.push(snapResultPath); this.props.history.push(snapResultPath);
break; break;
///: END:ONLY_INCLUDE_IN
default: default:
this.props.history.push(confirmPermissionPath); this.props.history.push(confirmPermissionPath);
} }
}, },
///: END:ONLY_INCLUDE_IN
); );
}; };
@ -217,39 +214,26 @@ export default class PermissionConnect extends Component {
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
} = this.props; } = this.props;
let shouldRedirect = true;
///: BEGIN:ONLY_INCLUDE_IN(snaps) ///: BEGIN:ONLY_INCLUDE_IN(snaps)
const isRequestingSnap = const isRequestingSnap =
permissionsRequest?.permissions && permissionsRequest?.permissions &&
Object.keys(permissionsRequest.permissions).includes('wallet_snap'); Object.keys(permissionsRequest.permissions).includes('wallet_snap');
const shouldRedirect = !isRequestingSnap; shouldRedirect = !isRequestingSnap;
///: END:ONLY_INCLUDE_IN
this.setState({ this.setState({
redirecting: shouldRedirect, redirecting: shouldRedirect,
permissionsApproved: approved, permissionsApproved: approved,
}); });
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta)
this.setState({
redirecting: true,
permissionsApproved: approved,
});
///: END:ONLY_INCLUDE_IN
this.removeBeforeUnload(); this.removeBeforeUnload();
///: BEGIN:ONLY_INCLUDE_IN(snaps)
if (shouldRedirect && approved) { if (shouldRedirect && approved) {
setTimeout(() => history.push(DEFAULT_ROUTE), APPROVE_TIMEOUT); setTimeout(() => history.push(DEFAULT_ROUTE), APPROVE_TIMEOUT);
return; return;
} }
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-mmi)
if (approved) {
setTimeout(() => history.push(DEFAULT_ROUTE), APPROVE_TIMEOUT);
return;
}
///: END:ONLY_INCLUDE_IN
history.push(DEFAULT_ROUTE); history.push(DEFAULT_ROUTE);
} }

View File

@ -9,8 +9,8 @@ import {
///: BEGIN:ONLY_INCLUDE_IN(snaps) ///: BEGIN:ONLY_INCLUDE_IN(snaps)
getSnapInstallOrUpdateRequests, getSnapInstallOrUpdateRequests,
getRequestState, getRequestState,
getRequestType,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
getRequestType,
getTargetSubjectMetadata, getTargetSubjectMetadata,
} from '../../selectors'; } from '../../selectors';
import { getNativeCurrency } from '../../ducks/metamask/metamask'; import { getNativeCurrency } from '../../ducks/metamask/metamask';
@ -73,11 +73,11 @@ const mapStateToProps = (state, ownProps) => {
subjectType: SubjectType.Unknown, subjectType: SubjectType.Unknown,
}; };
const requestType = getRequestType(state, permissionsRequestId);
///: BEGIN:ONLY_INCLUDE_IN(snaps) ///: BEGIN:ONLY_INCLUDE_IN(snaps)
const isSnap = targetSubjectMetadata.subjectType === SubjectType.Snap; const isSnap = targetSubjectMetadata.subjectType === SubjectType.Snap;
const requestType = getRequestType(state, permissionsRequestId);
const requestState = getRequestState(state, permissionsRequestId); const requestState = getRequestState(state, permissionsRequestId);
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
@ -126,8 +126,8 @@ const mapStateToProps = (state, ownProps) => {
return { return {
isRequestingAccounts, isRequestingAccounts,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
requestType, requestType,
///: BEGIN:ONLY_INCLUDE_IN(snaps)
snapInstallPath, snapInstallPath,
snapUpdatePath, snapUpdatePath,
snapResultPath, snapResultPath,

View File

@ -36,7 +36,7 @@ import { getSnapName } from '../../../../helpers/utils/util';
import { Text, BUTTON_VARIANT } from '../../../../components/component-library'; import { Text, BUTTON_VARIANT } from '../../../../components/component-library';
import SnapPermissionsList from '../../../../components/app/snaps/snap-permissions-list'; import SnapPermissionsList from '../../../../components/app/snaps/snap-permissions-list';
import { SnapDelineator } from '../../../../components/app/snaps/snap-delineator'; import { SnapDelineator } from '../../../../components/app/snaps/snap-delineator';
import { DelineatorType } from '../../../../helpers/constants/flask'; import { DelineatorType } from '../../../../helpers/constants/snaps';
function ViewSnap() { function ViewSnap() {
const t = useI18nContext(); const t = useI18nContext();