Skip to content

Commit

Permalink
Merge branch 'develop' into fix/use-counter-pending-transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Prithpal-Sooriya authored Aug 1, 2024
2 parents 634bec5 + ed28508 commit 7e6b5d7
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 235 deletions.
7 changes: 0 additions & 7 deletions app/scripts/lib/snap-keyring/snap-keyring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ describe('Snap Keyring Methods', () => {

await showAccountNameSuggestionDialog(
mockSnapId,
mockAccount.address,
controllerMessenger,
accountNameSuggestion,
);
Expand All @@ -182,7 +181,6 @@ describe('Snap Keyring Methods', () => {
origin: mockSnapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address: mockAccount.address,
snapSuggestedAccountName: accountNameSuggestion,
},
},
Expand Down Expand Up @@ -229,7 +227,6 @@ describe('Snap Keyring Methods', () => {
origin: mockSnapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address: mockInternalAccount.address.toLowerCase(),
snapSuggestedAccountName: '',
},
},
Expand Down Expand Up @@ -294,7 +291,6 @@ describe('Snap Keyring Methods', () => {
origin: mockSnapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address: mockInternalAccount.address.toLowerCase(),
// No user defined name
snapSuggestedAccountName: '',
},
Expand Down Expand Up @@ -355,7 +351,6 @@ describe('Snap Keyring Methods', () => {
origin: mockSnapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address: mockInternalAccount.address.toLowerCase(),
snapSuggestedAccountName: mockNameSuggestion,
},
},
Expand Down Expand Up @@ -428,7 +423,6 @@ describe('Snap Keyring Methods', () => {
origin: mockSnapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address: mockInternalAccount.address.toLowerCase(),
snapSuggestedAccountName: mockNameSuggestion,
},
},
Expand Down Expand Up @@ -492,7 +486,6 @@ describe('Snap Keyring Methods', () => {
origin: mockSnapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address: mockInternalAccount.address.toLowerCase(),
snapSuggestedAccountName: mockNameSuggestion,
},
},
Expand Down
4 changes: 0 additions & 4 deletions app/scripts/lib/snap-keyring/snap-keyring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ export async function showAccountCreationDialog(
* Show the account name suggestion confirmation dialog for a given Snap.
*
* @param snapId - Snap ID to show the account name suggestion dialog for.
* @param address - The address of the new account.
* @param controllerMessenger - The controller messenger instance.
* @param accountNameSuggestion - Suggested name for the new account.
* @returns The user's confirmation result.
*/
export async function showAccountNameSuggestionDialog(
snapId: string,
address: string,
controllerMessenger: SnapKeyringBuilderMessenger,
accountNameSuggestion: string,
): Promise<{ success: boolean; name?: string }> {
Expand All @@ -83,7 +81,6 @@ export async function showAccountNameSuggestionDialog(
origin: snapId,
type: SNAP_MANAGE_ACCOUNTS_CONFIRMATION_TYPES.showNameSnapAccount,
requestData: {
address,
snapSuggestedAccountName: accountNameSuggestion,
},
},
Expand Down Expand Up @@ -227,7 +224,6 @@ export const snapKeyringBuilder = (
const accountNameConfirmationResult =
await showAccountNameSuggestionDialog(
snapId,
address,
controllerMessenger,
accountNameSuggestion,
);
Expand Down

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions ui/components/multichain/create-btc-account/create-btc-account.tsx

This file was deleted.

1 change: 0 additions & 1 deletion ui/components/multichain/create-btc-account/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@ import { fireEvent, renderWithProvider, waitFor } from '../../../../test/jest';
import configureStore from '../../../store/store';
import mockState from '../../../../test/data/mock-state.json';
import messages from '../../../../app/_locales/en/messages.json';
import { createMockInternalAccount } from '../../../../test/jest/mocks';
import { ETH_EOA_METHODS } from '../../../../shared/constants/eth-methods';
import {
CreateNamedSnapAccount,
CreateNamedSnapAccountProps,
} from './create-named-snap-account';

const mockAddress = '0x3f9658179a5c053bb2faaf7badbb95f6c9be0fa7';
const mockAccount = createMockInternalAccount({
address: mockAddress,
name: 'New account',
});
const mockSnapSuggestedAccountName = 'Suggested Account Name';

jest.mock('../../../store/actions', () => ({
Expand Down Expand Up @@ -61,7 +55,6 @@ const mockSnapAccount2 = {
const render = (
props: CreateNamedSnapAccountProps = {
onActionComplete: jest.fn().mockResolvedValue({ success: true }),
address: mockAccount.address,
snapSuggestedAccountName: mockSnapSuggestedAccountName,
},
) => {
Expand Down Expand Up @@ -105,7 +98,6 @@ describe('CreateNamedSnapAccount', () => {
const onActionComplete = jest.fn();
const { getByText, getByPlaceholderText } = render({
onActionComplete,
address: mockAccount.address,
snapSuggestedAccountName: mockSnapSuggestedAccountName,
});

Expand Down Expand Up @@ -150,7 +142,6 @@ describe('CreateNamedSnapAccount', () => {
const onActionComplete = jest.fn();
const { getByText, getByPlaceholderText } = render({
onActionComplete,
address: mockAccount.address,
});

fireEvent.click(getByText(messages.addAccount.message));
Expand All @@ -170,7 +161,6 @@ describe('CreateNamedSnapAccount', () => {
const onActionComplete = jest.fn();
const { getByText } = render({
onActionComplete,
address: mockAccount.address,
snapSuggestedAccountName: mockSnapSuggestedAccountName,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import React, { useCallback, useMemo } from 'react';
import React, { useCallback } from 'react';
import { useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
import { InternalAccount } from '@metamask/keyring-api';
import { KeyringTypes } from '@metamask/keyring-controller';
import { CreateAccount, CreateBtcAccount } from '..';
import { CreateAccount } from '..';
import { Box, ModalHeader } from '../../component-library';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { getMostRecentOverviewPage } from '../../../ducks/history/history';
import {
isBtcMainnetAddress,
isBtcTestnetAddress,
} from '../../../../shared/lib/multichain';
import { getNextAvailableAccountName } from '../../../store/actions';

export type CreateNamedSnapAccountProps = {
Expand All @@ -22,11 +18,6 @@ export type CreateNamedSnapAccountProps = {
reject?: boolean,
) => Promise<void>;

/**
* Address of the account to create
*/
address: string;

/**
* Suggested account name from the snap
*/
Expand All @@ -35,17 +26,12 @@ export type CreateNamedSnapAccountProps = {

export const CreateNamedSnapAccount: React.FC<CreateNamedSnapAccountProps> = ({
onActionComplete,
address,
snapSuggestedAccountName,
}) => {
const t = useI18nContext();
const history = useHistory();

const mostRecentOverviewPage = useSelector(getMostRecentOverviewPage);
const isBtcAccount = useMemo(
() => isBtcMainnetAddress(address) || isBtcTestnetAddress(address),
[address],
);

const rejectAction = useCallback(async (completed: boolean) => {
await onActionComplete({ success: completed });
Expand Down Expand Up @@ -81,23 +67,13 @@ export const CreateNamedSnapAccount: React.FC<CreateNamedSnapAccountProps> = ({
<ModalHeader padding={4} onClose={onClose}>
{t('addAccountToMetaMask')}
</ModalHeader>
{isBtcAccount ? (
<CreateBtcAccount
// onActionComplete is called when a user rejects the action
// onCreateAccount will call onActionComplete if a user confirms the action
onActionComplete={rejectAction}
onCreateAccount={onCreateAccount}
address={address}
/>
) : (
<CreateAccount
// onActionComplete is called when a user rejects the action
// onCreateAccount will call onActionComplete if a user confirms the action
onActionComplete={rejectAction}
onCreateAccount={onCreateAccount}
getNextAvailableAccountName={getNextAccountName}
/>
)}
<CreateAccount
// onActionComplete is called when a user rejects the action
// onCreateAccount will call onActionComplete if a user confirms the action
onActionComplete={rejectAction}
onCreateAccount={onCreateAccount}
getNextAvailableAccountName={getNextAccountName}
/>
</Box>
);
};
Loading

0 comments on commit 7e6b5d7

Please sign in to comment.