Skip to content

Commit

Permalink
Merge branch 'main' into STAKE-817-fe-show-staked-eth-position-in-hom…
Browse files Browse the repository at this point in the history
…epage-along-with-other-tokens
  • Loading branch information
nickewansmith authored Nov 8, 2024
2 parents 126aeb5 + 2af2f67 commit 37f91d9
Show file tree
Hide file tree
Showing 61 changed files with 2,424 additions and 2,020 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
ACCOUNT_BASE_TEST_ID,
} from './AccountBase.constants';
import styles from './AccountBase.styles';
import { strings } from '../../../../../locales/i18n';
import { AccountBaseProps } from './AccountBase.types';

const AccountBase = ({
Expand Down Expand Up @@ -56,7 +55,7 @@ const AccountBase = ({
variant={TextVariant.BodyMDBold}
style={styles.accountNameLabelText}
>
{strings(accountTypeLabel)}
{accountTypeLabel}
</Text>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import Avatar, { AvatarSize, AvatarVariant } from '../../Avatars/Avatar';
import Text, { TextVariant } from '../../Texts/Text';
import { formatAddress } from '../../../../util/address';
import { useStyles } from '../../../hooks';
import { strings } from '../../../../../locales/i18n';

// Internal dependencies.
import PickerBase from '../PickerBase';
import { PickerAccountProps } from './PickerAccount.types';
import styleSheet from './PickerAccount.styles';
import { WalletViewSelectorsIDs } from '../../../../../e2e/selectors/wallet/WalletView.selectors';
import { AccountListViewSelectorsIDs } from '../../../../../e2e/selectors/AccountListView.selectors';

const PickerAccount: React.ForwardRefRenderFunction<
TouchableOpacity,
Expand Down Expand Up @@ -56,15 +54,6 @@ const PickerAccount: React.ForwardRefRenderFunction<
>
{accountName}
</Text>
{accountTypeLabel && (
<Text
variant={TextVariant.BodySM}
style={styles.accountNameLabelText}
testID={AccountListViewSelectorsIDs.ACCOUNT_TYPE_LABEL}
>
{strings(accountTypeLabel)}
</Text>
)}
{showAddress && (
<Text variant={TextVariant.BodyMD} style={styles.accountAddressLabel}>
{shortenedAddress}
Expand Down
5 changes: 5 additions & 0 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import AccountConnect from '../../../components/Views/AccountConnect';
import AccountPermissions from '../../../components/Views/AccountPermissions';
import { AccountPermissionsScreens } from '../../../components/Views/AccountPermissions/AccountPermissions.types';
import AccountPermissionsConfirmRevokeAll from '../../../components/Views/AccountPermissions/AccountPermissionsConfirmRevokeAll';
import ConnectionDetails from '../../../components/Views/AccountPermissions/ConnectionDetails';
import { SRPQuiz } from '../../Views/Quiz';
import { TurnOffRememberMeModal } from '../../../components/UI/TurnOffRememberMeModal';
import AssetHideConfirmation from '../../Views/AssetHideConfirmation';
Expand Down Expand Up @@ -424,6 +425,10 @@ const RootModalFlow = () => (
name={Routes.SHEET.REVOKE_ALL_ACCOUNT_PERMISSIONS}
component={AccountPermissionsConfirmRevokeAll}
/>
<Stack.Screen
name={Routes.SHEET.CONNECTION_DETAILS}
component={ConnectionDetails}
/>
<Stack.Screen
name={Routes.SHEET.NETWORK_SELECTOR}
component={NetworkSelector}
Expand Down
46 changes: 27 additions & 19 deletions app/components/UI/AccountApproval/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,35 @@ import { backgroundState } from '../../../util/test/initial-root-state';
import renderWithProvider from '../../../util/test/renderWithProvider';
import { MOCK_ACCOUNTS_CONTROLLER_STATE } from '../../../util/test/accountsControllerTestUtils';

jest.mock('../../../core/Engine', () => ({
context: {
PhishingController: {
maybeUpdateState: jest.fn(),
test: jest.fn((url: string) => {
if (url === 'phishing.com') return { result: true };
return { result: false };
}),
},
KeyringController: {
getAccountKeyringType: () => Promise.resolve('HD Key Tree'),
state: {
keyrings: [
{
accounts: ['0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756'],
},
],
jest.mock('../../../core/Engine', () => {
const { MOCK_ACCOUNTS_CONTROLLER_STATE: mockAccountsControllerState } =
jest.requireActual('../../../util/test/accountsControllerTestUtils');
return {
context: {
PhishingController: {
maybeUpdateState: jest.fn(),
test: jest.fn((url: string) => {
if (url === 'phishing.com') return { result: true };
return { result: false };
}),
},
KeyringController: {
getAccountKeyringType: () => Promise.resolve('HD Key Tree'),
state: {
keyrings: [
{
accounts: ['0xC4966c0D659D99699BFD7EB54D8fafEE40e4a756'],
},
],
},
},
AccountsController: {
...mockAccountsControllerState,
state: mockAccountsControllerState,
},
},
},
}));
};
});

const mockInitialState = {
engine: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,37 @@ jest.mock('../../../util/address', () => ({
}));
const mockGetERC20BalanceOf = jest.fn().mockReturnValue(0x0186a0);

jest.mock('../../../core/Engine', () => ({
context: {
TokensController: {
addToken: () => undefined,
},
KeyringController: {
state: {
keyrings: [
{
accounts: [
'0xe64dD0AB5ad7e8C5F2bf6Ce75C34e187af8b920A',
'0x519d2CE57898513F676a5C3b66496c3C394c9CC7',
'0x07Be9763a718C0539017E2Ab6fC42853b4aEeb6B',
],
},
],
jest.mock('../../../core/Engine', () => {
const { MOCK_ACCOUNTS_CONTROLLER_STATE: mockAccountsControllerState } =
jest.requireActual('../../../util/test/accountsControllerTestUtils');
return {
context: {
TokensController: {
addToken: () => undefined,
},
KeyringController: {
state: {
keyrings: [
{
accounts: [
'0xe64dD0AB5ad7e8C5F2bf6Ce75C34e187af8b920A',
'0x519d2CE57898513F676a5C3b66496c3C394c9CC7',
'0x07Be9763a718C0539017E2Ab6fC42853b4aEeb6B',
],
},
],
},
},
AccountsController: {
...mockAccountsControllerState,
state: mockAccountsControllerState,
},
AssetsContractController: {
getERC20BalanceOf: mockGetERC20BalanceOf,
} as Partial<AssetsContractController> as AssetsContractController,
},
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
AssetsContractController: {
getERC20BalanceOf: mockGetERC20BalanceOf,
} as Partial<AssetsContractController> as AssetsContractController,
},
}));
};
});

jest.mock('../../../util/ENSUtils', () => ({
...jest.requireActual('../../../util/ENSUtils'),
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/AccountInfoCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class AccountInfoCard extends PureComponent {
{accountLabelTag && (
<View style={styles.tag}>
<Text variant={TextVariant.BodySMBold} style={styles.tagText}>
{strings(accountLabelTag)}
{accountLabelTag}
</Text>
</View>
)}
Expand Down
30 changes: 19 additions & 11 deletions app/components/UI/AccountInfoCard/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,27 @@ import { RootState } from '../../../reducers';
import { RpcEndpointType } from '@metamask/network-controller';
import { mockNetworkState } from '../../../util/test/network';

jest.mock('../../../core/Engine', () => ({
resetState: jest.fn(),
context: {
KeyringController: {
state: {
keyrings: [],
jest.mock('../../../core/Engine', () => {
const { MOCK_ACCOUNTS_CONTROLLER_STATE: mockAccountsControllerState } =
jest.requireActual('../../../util/test/accountsControllerTestUtils');
return {
resetState: jest.fn(),
context: {
KeyringController: {
state: {
keyrings: [],
},
createNewVaultAndKeychain: () => jest.fn(),
setLocked: () => jest.fn(),
getAccountKeyringType: () => Promise.resolve('HD Key Tree'),
},
AccountsController: {
...mockAccountsControllerState,
state: mockAccountsControllerState,
},
createNewVaultAndKeychain: () => jest.fn(),
setLocked: () => jest.fn(),
getAccountKeyringType: () => Promise.resolve('HD Key Tree'),
},
},
}));
};
});

const mockInitialState: DeepPartial<RootState> = {
settings: {
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/AccountOverview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ class AccountOverview extends PureComponent {
variant={TextVariant.BodySMBold}
style={styles.tagText}
>
{strings(accountLabelTag)}
{accountLabelTag}
</Text>
</View>
)}
Expand Down
38 changes: 23 additions & 15 deletions app/components/UI/AccountOverview/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,31 @@ import {

const mockedEngine = Engine;

jest.mock('../../../core/Engine.ts', () => ({
init: () => mockedEngine.init({}),
context: {
KeyringController: {
getQRKeyringState: async () => ({ subscribe: () => ({}) }),
state: {
keyrings: [
{
accounts: ['0xC4955C0d639D99699Bfd7Ec54d9FaFEe40e4D272'],
index: 0,
type: 'HD Key Tree',
},
],
jest.mock('../../../core/Engine.ts', () => {
const { MOCK_ACCOUNTS_CONTROLLER_STATE: mockAccountsControllerState } =
jest.requireActual('../../../util/test/accountsControllerTestUtils');
return {
init: () => mockedEngine.init({}),
context: {
KeyringController: {
getQRKeyringState: async () => ({ subscribe: () => ({}) }),
state: {
keyrings: [
{
accounts: ['0xC4955C0d639D99699Bfd7Ec54d9FaFEe40e4D272'],
index: 0,
type: 'HD Key Tree',
},
],
},
},
AccountsController: {
...mockAccountsControllerState,
state: mockAccountsControllerState,
},
},
},
}));
};
});

const mockInitialState = {
settings: {},
Expand Down
12 changes: 6 additions & 6 deletions app/components/UI/AccountSelectorList/AccountSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ describe('AccountSelectorList', () => {
expect(within(accountNameItems[1]).getByText('Account 2')).toBeDefined();
});
});
it('renders "Snaps (beta)" tag for Snap accounts', async () => {
const mockAccountsWithSnap = createMockAccountsControllerStateWithSnap([
MOCK_ADDRESS_1,
MOCK_ADDRESS_2,
]);
it('renders the snap name tag for Snap accounts', async () => {
const mockAccountsWithSnap = createMockAccountsControllerStateWithSnap(
[MOCK_ADDRESS_1, MOCK_ADDRESS_2],
'MetaMask Simple Snap Keyring',
);

const stateWithSnapAccount = {
...initialState,
Expand All @@ -225,7 +225,7 @@ describe('AccountSelectorList', () => {
const { queryByText } = renderComponent(stateWithSnapAccount);

await waitFor(async () => {
const snapTag = await queryByText('Snaps (beta)');
const snapTag = await queryByText('MetaMask Simple Snap Keyring');
expect(snapTag).toBeDefined();
});
});
Expand Down
4 changes: 2 additions & 2 deletions app/components/UI/AccountSelectorList/AccountSelectorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import SensitiveText, {
import AvatarGroup from '../../../component-library/components/Avatars/AvatarGroup';
import {
formatAddress,
safeToChecksumAddress,
getLabelTextByAddress,
safeToChecksumAddress,
} from '../../../util/address';
import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount';
import { isDefaultAccountName } from '../../../util/ENSUtils';
Expand Down Expand Up @@ -219,7 +219,7 @@ const AccountSelectorList = ({
type: accountAvatarType,
accountAddress: address,
}}
tagLabel={tagLabel ? strings(tagLabel) : tagLabel}
tagLabel={tagLabel}
disabled={isDisabled}
style={cellStyle}
>
Expand Down
Loading

0 comments on commit 37f91d9

Please sign in to comment.