Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display snap name #11511

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4268967
chore(js-ts): Convert app/util/browserScripts.js to TypeScript (#11405)
devin-ai-integration[bot] Sep 24, 2024
4925d4b
revert: changes in ios/MetaMask.xcodeproj/project.pbxproj
k-g-j Sep 23, 2024
3dc8a9c
feat: renamed 'getLabelTextByAddress' to 'getLabelTextByKeyring' and …
k-g-j Sep 23, 2024
b94f0fd
feat: added 'createMockAccountsControllerStateWithSnap' to accounts c…
k-g-j Sep 23, 2024
6521b04
revert: changes in xcodeproj
k-g-j Sep 23, 2024
851dfc9
fix: code fence on KeyringTypes import
k-g-j Sep 23, 2024
ff26e48
feat: debugging mocked testing
k-g-j Sep 23, 2024
938f762
fix: unit test for 'getAccountLabelTextByKeyring'
k-g-j Sep 24, 2024
ec08690
feat: use KeyringTypes in accounts controller test utils
k-g-j Sep 24, 2024
2db83c0
feat: remove 'should' from test description
k-g-j Sep 24, 2024
85ce19e
fix: import KeyringTypes
k-g-j Sep 24, 2024
78cbde1
feat: updated 'getAccountLabelTextByKeyring' JSDOC
k-g-j Sep 24, 2024
81528df
revert: changes in ios/MetaMask.xcodeproj/project.pbxproj
k-g-j Sep 24, 2024
10202b8
feat: added getInternalAccount by address util
k-g-j Sep 24, 2024
8cb828b
feat: JSDOC for 'getInternalAccountByAddress'
k-g-j Sep 26, 2024
cab68fd
feat: update getLabelTextByAddress to apply translation and remove st…
k-g-j Sep 30, 2024
f75b721
debugging
k-g-j Oct 3, 2024
c62a395
feat: testing wip
k-g-j Oct 9, 2024
044617c
test: debugging address utils test
k-g-j Oct 9, 2024
fa846ba
test: debugging unit tests
k-g-j Oct 9, 2024
2a6239b
feat: updated test to not use translation key
k-g-j Oct 15, 2024
55bdacb
feat: remove console logs in Tag
k-g-j Oct 15, 2024
a32ecd0
chore: update AccountsSelector snapshot
k-g-j Oct 15, 2024
c45f778
feat: testing getLabelTextByAddress modifying test utils wip
k-g-j Oct 15, 2024
f34f146
feat: remove unused strings functions and fix address util tests
k-g-j Oct 16, 2024
78a9fdb
fix: unused import in PickerAccount
k-g-j Oct 17, 2024
cbd2df6
Merge branch 'main' into feat/display-snap-name
k-g-j Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import Text from '../../../component-library/components/Texts/Text';
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 @@ -200,7 +200,7 @@ const AccountSelectorList = ({
type: accountAvatarType,
accountAddress: address,
}}
tagLabel={tagLabel ? strings(tagLabel) : tagLabel}
tagLabel={tagLabel}
disabled={isDisabled}
style={cellStyle}
>
Expand Down
27 changes: 1 addition & 26 deletions app/components/UI/AddressInputs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ const createStyles = (colors, layout = 'horizontal') => {
});
};

const AddressName = ({
toAddressName,
confusableCollection = [],
accountLabel,
}) => {
const AddressName = ({ toAddressName, confusableCollection = [] }) => {
const { colors } = useTheme();
const styles = createStyles(colors);
if (confusableCollection.length) {
Expand Down Expand Up @@ -214,22 +210,13 @@ const AddressName = ({
<Text style={styles.textAddress} numberOfLines={1}>
{toAddressName}
</Text>
{accountLabel && (
<Text
variant={TextVariant.BodySMBold}
style={styles.accountNameLabelText}
>
{strings(accountLabel)}
</Text>
)}
</View>
);
};

AddressName.propTypes = {
toAddressName: PropTypes.string,
confusableCollection: PropTypes.array,
accountLabel: PropTypes.string,
};

export const AddressTo = (props) => {
Expand All @@ -252,7 +239,6 @@ export const AddressTo = (props) => {
isFromAddressBook = false,
layout = 'horizontal',
} = props;
const accountLabel = getLabelTextByAddress(toSelectedAddress);
const { colors, themeAppearance } = useTheme();
const styles = createStyles(colors, layout);

Expand Down Expand Up @@ -292,7 +278,6 @@ export const AddressTo = (props) => {
<AddressName
toAddressName={toAddressName}
confusableCollection={confusableCollection}
accountLabel={accountLabel}
/>
)}
<View style={styles.addressWrapper}>
Expand Down Expand Up @@ -414,7 +399,6 @@ export const AddressTo = (props) => {
<AddressName
toAddressName={toAddressName}
confusableCollection={confusableCollection}
accountLabel={accountLabel}
/>

<View style={styles.addressWrapper}>
Expand Down Expand Up @@ -582,7 +566,6 @@ export const AddressFrom = (props) => {
fromAccountAddress,
layout = 'horizontal',
} = props;
const accountLabel = getLabelTextByAddress(fromAccountAddress);
const { colors } = useTheme();
const styles = createStyles(colors, layout);

Expand All @@ -603,14 +586,6 @@ export const AddressFrom = (props) => {
<View style={[baseStyles.flexGrow, styles.address]}>
<View style={styles.accountNameLabel}>
<Text style={styles.textAddress}>{fromAccountName}</Text>
{accountLabel && (
<Text
variant={TextVariant.BodySMBold}
style={styles.accountNameLabelText}
>
{strings(accountLabel)}
</Text>
)}
</View>
<Text style={styles.textBalance}>{`${strings(
'transactions.address_from_balance',
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/DrawerView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ class DrawerView extends PureComponent {
return label ? (
<View style={[styles.importedWrapper]}>
<Text numberOfLines={1} style={styles.importedText}>
{strings(label)}
{label}
</Text>
</View>
) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const AccountConnectSingle = ({
type: accountAvatarType,
accountAddress: address,
}}
tagLabel={tagLabel ? strings(tagLabel) : ''}
tagLabel={tagLabel || ''}
disabled={isLoading}
style={isLoading && styles.disabled}
>
Expand Down
Loading
Loading