Skip to content

Commit

Permalink
remove unused components and code
Browse files Browse the repository at this point in the history
  • Loading branch information
owencraston committed Sep 18, 2023
1 parent cb7286e commit dfd3355
Show file tree
Hide file tree
Showing 17 changed files with 36 additions and 230 deletions.
12 changes: 0 additions & 12 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,6 @@ export function setupController(
controller.approvalController.accept(id, false);
break;
case 'snap_manageAccounts:confirmation':
console.log(
'SNAPS/ background.js: snap_manageAccounts:confirmation',
);
controller.approvalController.accept(id, false);
break;
///: END:ONLY_INCLUDE_IN
Expand Down
13 changes: 0 additions & 13 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1982,19 +1982,6 @@ export default class MetamaskController extends EventEmitter {
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
getSnapKeyring: this.getSnapKeyring.bind(this),
showSnapAccountConfirmation: (origin, type, content, placeholder) => {
console.log('SNAPS/ showSnapAccountConfirmation called with:', {
origin,
type,
content,
placeholder,
});
return this.approvalController.addAndShowApprovalRequest({
origin,
type: SNAP_DIALOG_TYPES[type],
requestData: { content, placeholder },
});
},
requestUserApproval:
this.approvalController.addAndShowApprovalRequest.bind(
this.approvalController,
Expand Down
13 changes: 0 additions & 13 deletions ui/components/multichain/account-list-menu/account-list-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {
CONNECT_HARDWARE_ROUTE,
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
ADD_SNAP_ACCOUNT_ROUTE,
CREATE_SNAP_ACCOUNT_ROUTE,
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
CUSTODY_ACCOUNT_ROUTE,
Expand Down Expand Up @@ -285,18 +284,6 @@ export const AccountListMenu = ({ onClose }) => {
{t('settingAddSnapAccount')}
</ButtonLink>
</Box>
<Box marginTop={4}>
<ButtonLink
size={Size.SM}
startIconName={IconName.Snaps}
onClick={() => {
dispatch(toggleAccountMenu());
history.push(CREATE_SNAP_ACCOUNT_ROUTE);
}}
>
Create Snap Account TEST
</ButtonLink>
</Box>
</>
///: END:ONLY_INCLUDE_IN
}
Expand Down
3 changes: 0 additions & 3 deletions ui/helpers/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const NOTIFICATIONS_ROUTE = '/notifications';
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
const ADD_SNAP_ACCOUNT_ROUTE = '/add-snap-account';
const CREATE_SNAP_ACCOUNT_ROUTE = '/create-snap-account';
///: END:ONLY_INCLUDE_IN
const CONNECTED_ROUTE = '/connected';
const CONNECTED_ACCOUNTS_ROUTE = '/connected/accounts';
Expand Down Expand Up @@ -136,7 +135,6 @@ const PATH_NAME_MAP = {
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
[ADD_SNAP_ACCOUNT_ROUTE]: 'Add Snap Account List Page',
[`${ADD_SNAP_ACCOUNT_ROUTE}/:snapId`]: `Add Snap Account Page`,
[CREATE_SNAP_ACCOUNT_ROUTE]: 'Create Snap Account Page',
///: END:ONLY_INCLUDE_IN
[CONFIRM_ADD_SUGGESTED_NFT_ROUTE]: 'Confirm Add Suggested NFT Page',
[CONNECT_HARDWARE_ROUTE]: 'Connect Hardware Wallet Page',
Expand Down Expand Up @@ -254,7 +252,6 @@ export {
///: END:ONLY_INCLUDE_IN
///: BEGIN:ONLY_INCLUDE_IN(keyring-snaps)
ADD_SNAP_ACCOUNT_ROUTE,
CREATE_SNAP_ACCOUNT_ROUTE,
///: END:ONLY_INCLUDE_IN
CONNECTED_ROUTE,
CONNECTED_ACCOUNTS_ROUTE,
Expand Down
26 changes: 19 additions & 7 deletions ui/pages/confirmation/confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,8 @@ export default function ConfirmationPage({
getUnapprovedTemplatedConfirmations,
isEqual,
);

console.log(
'SNAPS/ ConfirmationPage called with pendingConfirmations: ',
pendingConfirmations,
);
// State variable to hold the previous snapName
const [prevSnapInfo, setPrevSnapInfo] = useState(null);
const unapprovedTxsCount = useSelector(getUnapprovedTxCount);
const approvalFlows = useSelector(getApprovalFlows, isEqual);
const totalUnapprovedCount = useSelector(getTotalUnapprovedCount);
Expand Down Expand Up @@ -220,6 +217,7 @@ export default function ConfirmationPage({
ApprovalType.SnapDialogAlert,
ApprovalType.SnapDialogConfirmation,
ApprovalType.SnapDialogPrompt,
'snap_manageAccounts:confirmation',
];

const isSnapDialog = SNAP_DIALOG_TYPE.includes(pendingConfirmation?.type);
Expand All @@ -228,7 +226,6 @@ export default function ConfirmationPage({
const INPUT_STATE_CONFIRMATIONS = [
///: BEGIN:ONLY_INCLUDE_IN(snaps)
ApprovalType.SnapDialogPrompt,
'snap_manageAccounts:confirmation',
///: END:ONLY_INCLUDE_IN
];

Expand Down Expand Up @@ -261,6 +258,15 @@ export default function ConfirmationPage({
///: END:ONLY_INCLUDE_IN
]);

useEffect(() => {
// Check if the current pendingConfirmation.type is 'snap_manageAccounts:confirmation' to store the snap info for the success/error screen
if (pendingConfirmation?.type === 'snap_manageAccounts:confirmation') {
setPrevSnapInfo({
origin: pendingConfirmation.origin,
});
}
}, [pendingConfirmation]);

useEffect(() => {
// If the number of pending confirmations reduces to zero when the user
// return them to the default route. Otherwise, if the number of pending
Expand Down Expand Up @@ -378,7 +384,8 @@ export default function ConfirmationPage({
///: BEGIN:ONLY_INCLUDE_IN(snaps)
!isSnapDialog &&
///: END:ONLY_INCLUDE_IN
pendingConfirmation.origin === 'metamask' && (
pendingConfirmation.origin === 'metamask' &&
!prevSnapInfo && (
<Box
alignItems={AlignItems.center}
paddingTop={2}
Expand All @@ -404,6 +411,11 @@ export default function ConfirmationPage({
)
///: END:ONLY_INCLUDE_IN
}
{prevSnapInfo && pendingConfirmation?.origin === 'metamask' && (
///: BEGIN:ONLY_INCLUDE_IN(snaps)
<SnapAuthorshipHeader snapId={prevSnapInfo.origin} />
///: END:ONLY_INCLUDE_IN
)}
<MetaMaskTemplateRenderer sections={templatedValues.content} />
{showWarningModal && (
<ConfirmationWarningModal
Expand Down
24 changes: 3 additions & 21 deletions ui/pages/confirmation/templates/create-snap-account.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
// Import whatever you need to support your logic

function getValues(pendingApproval, t, actions, _history, setInputState) {
console.log(
'SNAPS/ create-snap-account-template.ts: getValues called with:',
pendingApproval,
t,
actions,
);

function getValues(pendingApproval, t, actions, _history) {
const { origin: snapId, snapName } = pendingApproval;

return {
Expand All @@ -18,22 +9,13 @@ function getValues(pendingApproval, t, actions, _history, setInputState) {
props: {
snapId,
snapName,
onAccountNameChange: (accountName) => {
setInputState('snap_manageAccounts:confirmation', accountName);
},
},
},
],
cancelText: t('cancel'),
submitText: t('create'),
onSubmit: (accountName) => {
actions.resolvePendingApproval(pendingApproval.id, {
confirmed: true,
accountName,
});
},
onCancel: () =>
actions.resolvePendingApproval(pendingApproval.id, { confirmed: false }),
onSubmit: () => actions.resolvePendingApproval(pendingApproval.id, true),
onCancel: () => actions.resolvePendingApproval(pendingApproval.id, false),
};
}

Expand Down
18 changes: 0 additions & 18 deletions ui/pages/confirmation/templates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ const ALLOWED_TEMPLATE_KEYS = [
* @param {object} state - The state object consist of required info to determine alerts.
*/
export async function getTemplateAlerts(pendingApproval, state) {
console.log(
'SNAPS/ getTemplateAlerts called with pendingApproval: ',
pendingApproval,
' and state: ',
state,
);
const fn = APPROVAL_TEMPLATES[pendingApproval.type]?.getAlerts;
const results = fn ? await fn(pendingApproval, state) : [];
if (!Array.isArray(results)) {
Expand Down Expand Up @@ -149,18 +143,6 @@ export function getTemplateValues(
history,
setInputState,
) {
console.log(
'SNAPS/ getTemplateValues called with pendingApproval: ',
pendingApproval,
' and t: ',
t,
' and dispatch: ',
dispatch,
' and history: ',
history,
' and setInputState: ',
setInputState,
);
const fn = APPROVAL_TEMPLATES[pendingApproval.type]?.getValues;
if (!fn) {
throw new Error(
Expand Down
10 changes: 0 additions & 10 deletions ui/pages/confirmation/templates/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import {
import { processString } from '../util';

function getValues(pendingApproval, t, actions, _history) {
console.log(
'SNAPS/ success getValue called with pendingApproval: ',
pendingApproval,
' and t: ',
t,
' and actions: ',
actions,
' and _history: ',
_history,
);
return {
content: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import React from 'react';
import {
Box,
IconSize,
Text,
TextField,
} from '../../../components/component-library';
import { Box, IconSize, Text } from '../../../components/component-library';
import {
AlignItems,
BlockSize,
Display,
FlexDirection,
JustifyContent,
Expand All @@ -21,15 +15,11 @@ import { useI18nContext } from '../../../hooks/useI18nContext';
interface CreateSnapAccountContentProps {
snapName: string;
snapId: string;
accountName: string;
onAccountNameChange: (newAccountName: string) => void;
}

const CreateSnapAccountContent = ({
snapName,
snapId,
onAccountNameChange,
accountName,
}: CreateSnapAccountContentProps) => {
const t = useI18nContext();

Expand All @@ -53,7 +43,7 @@ const CreateSnapAccountContent = ({
/>
</Box>
<Text textAlign={TextAlign.Center} variant={TextVariant.headingLg}>
{t('createSnapAccount')}
{t('createSnapAccountTitle')}
</Text>
<Text
variant={TextVariant.bodyMd}
Expand All @@ -64,35 +54,6 @@ const CreateSnapAccountContent = ({
{t('createSnapAccountDescription', [snapName])}
</Text>
</Box>
<Box paddingTop={4} paddingLeft={4} paddingRight={4} paddingBottom={2}>
<Text
variant={TextVariant.bodyMd}
textAlign={TextAlign.Left}
overflowWrap={OverflowWrap.Anywhere}
>
{t('accountName')}
</Text>
<TextField
id={snapId}
data-testid={snapId}
autoFocus
required
onChange={(event) => {
event.preventDefault();
onAccountNameChange(event.target.value);
}}
placeholder={'New Account 1'}
value={accountName}
autoComplete="off"
width={BlockSize.Full}
onPaste={(event) => {
const newAccountName: string = event.clipboardData.getData('text');
if (newAccountName) {
onAccountNameChange(newAccountName);
}
}}
/>
</Box>
</Box>
);
};
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion ui/pages/create-snap-account/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { default as CreateSnapAccountContent } from './create-snap-account-content';
export { default as CreateSnapAccountSuccess } from './create-snap-account-success';
Loading

0 comments on commit dfd3355

Please sign in to comment.