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: Address value component for use in re-designed confirmation pages #11815

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -9,6 +9,7 @@ import useAccountInfo from '../../../../hooks/useAccountInfo';
import useApprovalRequest from '../../../../hooks/useApprovalRequest';
import InfoSection from '../../../UI/InfoRow/InfoSection';
import InfoRow from '../../../UI/InfoRow';
import Address from '../../../UI/InfoRow/InfoValue/Address';
import InfoURL from '../../../UI/InfoRow/InfoValue/InfoURL';

// todo: use value component for address, network, currency value
Expand All @@ -23,7 +24,9 @@ const AccountNetworkInfoExpanded = () => {
return (
<View>
<InfoSection>
<InfoRow label={strings('confirm.account')}>{accountAddress}</InfoRow>
<InfoRow label={strings('confirm.account')}>
<Address address={accountAddress}></Address>
</InfoRow>
<InfoRow label={strings('confirm.balance')}>{accountBalance}</InfoRow>
</InfoSection>
<InfoSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,52 @@ exports[`AccountNetworkInfoExpanded should match snapshot for personal sign 1`]
Account
</Text>
</View>
<Text
<View
style={
{
"color": "#141618",
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"marginTop": 8,
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "#f2f4f6",
"borderRadius": 99,
"flexDirection": "row",
"gap": 5,
"paddingLeft": 8,
"paddingRight": 8,
"paddingVertical": 4,
}
}
>
0x935E73EDb9fF52E23BaC7F7e043A1ecD06d05477
</Text>
<SvgMock
color="#141618"
height={20}
name="Question"
style={
{
"height": 20,
"width": 20,
}
}
width={20}
/>
<Text
accessibilityRole="text"
ellipsizeMode="middle"
numberOfLines={1}
style={
{
"color": "#141618",
"flexShrink": 1,
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
0x935E7...05477
</Text>
</View>
</View>
<View
style={
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';

import renderWithProvider from '../../../../../../../../util/test/renderWithProvider';
import { backgroundState } from '../../../../../../../../util/test/initial-root-state';
import {
MOCK_ACCOUNTS_CONTROLLER_STATE,
MOCK_ADDRESS_1,
} from '../../../../../../../../util/test/accountsControllerTestUtils';

import Address from './Address';

const mockInitialState = {
engine: {
backgroundState: {
...backgroundState,
AccountsController: {
...MOCK_ACCOUNTS_CONTROLLER_STATE,
},
},
},
};

describe('InfoAddress', () => {
it('should match snapshot', async () => {
const container = renderWithProvider(<Address address={MOCK_ADDRESS_1} />, {
state: mockInitialState,
});
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';

import Name from '../../../../../../../UI/Name';
import { NameType } from '../../../../../../../UI/Name/Name.types';

interface AddressProps {
address: string;
}

const Address = ({ address }: AddressProps) => (
<Name type={NameType.EthereumAddress} value={address} />
);

export default Address;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`InfoAddress should match snapshot 1`] = `
<View
style={
{
"alignItems": "center",
"alignSelf": "center",
"backgroundColor": "#f2f4f6",
"borderRadius": 99,
"flexDirection": "row",
"gap": 5,
"paddingLeft": 8,
"paddingRight": 8,
"paddingVertical": 4,
}
}
>
<SvgMock
color="#141618"
height={20}
name="Question"
style={
{
"height": 20,
"width": 20,
}
}
width={20}
/>
<Text
accessibilityRole="text"
ellipsizeMode="middle"
numberOfLines={1}
style={
{
"color": "#141618",
"flexShrink": 1,
"fontFamily": "EuclidCircularB-Regular",
"fontSize": 14,
"fontWeight": "400",
"letterSpacing": 0,
"lineHeight": 22,
}
}
>
0xC4955...4D272
</Text>
</View>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Address';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { render } from '@testing-library/react-native';

import InfoURL from './index';
import InfoURL from './InfoURL';

describe('InfoURL', () => {
it('should display url as expected', async () => {
Expand Down
Loading