mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 01:47:00 +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:
parent
120dfcdf32
commit
c716592fd1
@ -17,7 +17,7 @@ import { useTransactionInsightSnap } from '../../../../hooks/snaps/useTransactio
|
||||
import Box from '../../../ui/box/box';
|
||||
import { SnapUIRenderer } from '../../snaps/snap-ui-renderer';
|
||||
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 { Copyable } from '../../snaps/copyable';
|
||||
import { getTargetSubjectMetadata } from '../../../../selectors';
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import SnapAuthorship from '.';
|
||||
|
||||
export default {
|
||||
title: 'Components/App/Flask/SnapAuthorship',
|
||||
title: 'Components/App/Snaps/SnapAuthorship',
|
||||
|
||||
component: SnapAuthorship,
|
||||
argTypes: {
|
||||
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||
import SnapAvatar from '.';
|
||||
|
||||
export default {
|
||||
title: 'Components/App/Flask/SnapAvatar',
|
||||
title: 'Components/App/Snaps/SnapAvatar',
|
||||
|
||||
component: SnapAvatar,
|
||||
argTypes: {
|
||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||
import SnapContentFooter from '.';
|
||||
|
||||
export default {
|
||||
title: 'Components/App/Flask/SnapContentFooter',
|
||||
title: 'Components/App/Snaps/SnapContentFooter',
|
||||
|
||||
component: SnapContentFooter,
|
||||
args: {
|
||||
|
@ -21,7 +21,7 @@ import {
|
||||
import {
|
||||
DelineatorType,
|
||||
getDelineatorTitle,
|
||||
} from '../../../../helpers/constants/flask';
|
||||
} from '../../../../helpers/constants/snaps';
|
||||
|
||||
export const SnapDelineator = ({
|
||||
snapName,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { DelineatorType } from '../../../../helpers/constants/flask';
|
||||
import { DelineatorType } from '../../../../helpers/constants/snaps';
|
||||
import { renderWithLocalization } from '../../../../../test/lib/render-helpers';
|
||||
import { SnapDelineator } from './snap-delineator';
|
||||
|
||||
|
@ -3,7 +3,7 @@ import React from 'react';
|
||||
import SnapPermissionsList from '.';
|
||||
|
||||
export default {
|
||||
title: 'Components/App/flask/SnapPermissionsList',
|
||||
title: 'Components/App/Snaps/SnapPermissionsList',
|
||||
|
||||
component: SnapPermissionsList,
|
||||
argTypes: {
|
||||
|
@ -5,7 +5,7 @@ import README from './README.mdx';
|
||||
import SnapSettingsCard from '.';
|
||||
|
||||
export default {
|
||||
title: 'Components/App/Flask/SnapSettingsCard',
|
||||
title: 'Components/App/Snaps/SnapSettingsCard',
|
||||
|
||||
component: SnapSettingsCard,
|
||||
parameters: {
|
||||
|
@ -18,7 +18,7 @@ import { getSnapName } from '../../../../helpers/utils/util';
|
||||
import { getTargetSubjectMetadata } from '../../../../selectors';
|
||||
import { Text } from '../../../component-library';
|
||||
import { Copyable } from '../copyable';
|
||||
import { DelineatorType } from '../../../../helpers/constants/flask';
|
||||
import { DelineatorType } from '../../../../helpers/constants/snaps';
|
||||
|
||||
export const UI_MAPPING = {
|
||||
panel: (props, elementKey) => ({
|
||||
|
@ -1,5 +1,5 @@
|
||||
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) {
|
||||
const {
|
||||
|
@ -1,5 +1,5 @@
|
||||
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) {
|
||||
const {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { mapToTemplate } from '../../../../../components/app/snaps/snap-ui-renderer';
|
||||
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) {
|
||||
const {
|
||||
|
@ -38,11 +38,11 @@ export default class PermissionConnect extends Component {
|
||||
history: PropTypes.object.isRequired,
|
||||
connectPath: PropTypes.string.isRequired,
|
||||
confirmPermissionPath: PropTypes.string.isRequired,
|
||||
requestType: PropTypes.string.isRequired,
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
snapInstallPath: PropTypes.string.isRequired,
|
||||
snapUpdatePath: PropTypes.string.isRequired,
|
||||
snapResultPath: PropTypes.string.isRequired,
|
||||
requestType: PropTypes.string.isRequired,
|
||||
requestState: PropTypes.object.isRequired,
|
||||
approvePendingApproval: PropTypes.func.isRequired,
|
||||
rejectPendingApproval: PropTypes.func.isRequired,
|
||||
@ -175,23 +175,20 @@ export default class PermissionConnect extends Component {
|
||||
selectAccounts = (addresses) => {
|
||||
const {
|
||||
confirmPermissionPath,
|
||||
requestType,
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
snapInstallPath,
|
||||
snapUpdatePath,
|
||||
snapResultPath,
|
||||
requestType,
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
} = this.props;
|
||||
this.setState(
|
||||
{
|
||||
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) {
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
case 'wallet_installSnap':
|
||||
this.props.history.push(snapInstallPath);
|
||||
break;
|
||||
@ -201,11 +198,11 @@ export default class PermissionConnect extends Component {
|
||||
case 'wallet_installSnapResult':
|
||||
this.props.history.push(snapResultPath);
|
||||
break;
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
default:
|
||||
this.props.history.push(confirmPermissionPath);
|
||||
}
|
||||
},
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
);
|
||||
};
|
||||
|
||||
@ -217,39 +214,26 @@ export default class PermissionConnect extends Component {
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
} = this.props;
|
||||
|
||||
let shouldRedirect = true;
|
||||
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
const isRequestingSnap =
|
||||
permissionsRequest?.permissions &&
|
||||
Object.keys(permissionsRequest.permissions).includes('wallet_snap');
|
||||
|
||||
const shouldRedirect = !isRequestingSnap;
|
||||
shouldRedirect = !isRequestingSnap;
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
|
||||
this.setState({
|
||||
redirecting: shouldRedirect,
|
||||
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();
|
||||
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
if (shouldRedirect && approved) {
|
||||
setTimeout(() => history.push(DEFAULT_ROUTE), APPROVE_TIMEOUT);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ import {
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
getSnapInstallOrUpdateRequests,
|
||||
getRequestState,
|
||||
getRequestType,
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
getRequestType,
|
||||
getTargetSubjectMetadata,
|
||||
} from '../../selectors';
|
||||
import { getNativeCurrency } from '../../ducks/metamask/metamask';
|
||||
@ -73,11 +73,11 @@ const mapStateToProps = (state, ownProps) => {
|
||||
subjectType: SubjectType.Unknown,
|
||||
};
|
||||
|
||||
const requestType = getRequestType(state, permissionsRequestId);
|
||||
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
const isSnap = targetSubjectMetadata.subjectType === SubjectType.Snap;
|
||||
|
||||
const requestType = getRequestType(state, permissionsRequestId);
|
||||
|
||||
const requestState = getRequestState(state, permissionsRequestId);
|
||||
///: END:ONLY_INCLUDE_IN
|
||||
|
||||
@ -126,8 +126,8 @@ const mapStateToProps = (state, ownProps) => {
|
||||
|
||||
return {
|
||||
isRequestingAccounts,
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
requestType,
|
||||
///: BEGIN:ONLY_INCLUDE_IN(snaps)
|
||||
snapInstallPath,
|
||||
snapUpdatePath,
|
||||
snapResultPath,
|
||||
|
@ -36,7 +36,7 @@ import { getSnapName } from '../../../../helpers/utils/util';
|
||||
import { Text, BUTTON_VARIANT } from '../../../../components/component-library';
|
||||
import SnapPermissionsList from '../../../../components/app/snaps/snap-permissions-list';
|
||||
import { SnapDelineator } from '../../../../components/app/snaps/snap-delineator';
|
||||
import { DelineatorType } from '../../../../helpers/constants/flask';
|
||||
import { DelineatorType } from '../../../../helpers/constants/snaps';
|
||||
|
||||
function ViewSnap() {
|
||||
const t = useI18nContext();
|
||||
|
Loading…
Reference in New Issue
Block a user