-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat: add account_network section to re-designed confirmation page #11698
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5cd6b9a
Add account_network section to re-designed confirmation page
jpuri aaa656d
update
jpuri df5782b
update
jpuri a7e3f36
update
jpuri 84a3928
update
jpuri edc2aac
update
jpuri d3b6c65
update
jpuri 8193218
Merge branch 'main' into acc_network_info
jpuri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
455 changes: 327 additions & 128 deletions
455
app/components/Views/confirmations/Confirm/__snapshots__/Confirm.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
...nts/Views/confirmations/components/Confirm/AccountNetworkInfo/AccountNetworkInfo.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import React from 'react'; | ||
|
|
||
| import renderWithProvider from '../../../../../../util/test/renderWithProvider'; | ||
| import { personalSignatureConfirmationState } from '../../../../../../util/test/confirm-data-helpers'; | ||
| import AccountNetworkInfo from './AccountNetworkInfo'; | ||
|
|
||
| describe('AccountNetworkInfo', () => { | ||
| it('should match snapshot for personal sign', async () => { | ||
| const container = renderWithProvider(<AccountNetworkInfo />, { | ||
| state: personalSignatureConfirmationState, | ||
| }); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); |
25 changes: 25 additions & 0 deletions
25
...mponents/Views/confirmations/components/Confirm/AccountNetworkInfo/AccountNetworkInfo.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { strings } from '../../../../../../../locales/i18n'; | ||
| import useApprovalRequest from '../../../hooks/useApprovalRequest'; | ||
| import ExpandableSection from '../../UI/ExpandableSection'; | ||
| import AccountNetworkInfoCollapsed from './AccountNetworkInfoCollapsed'; | ||
| import AccountNetworkInfoExpanded from './AccountNetworkInfoExpanded'; | ||
|
|
||
| const AccountNetworkInfo = () => { | ||
| const { approvalRequest } = useApprovalRequest(); | ||
|
|
||
| if (!approvalRequest) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <ExpandableSection | ||
| collapsedContent={<AccountNetworkInfoCollapsed />} | ||
| expandedContent={<AccountNetworkInfoExpanded />} | ||
| modalTitle={strings('confirm.details')} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default AccountNetworkInfo; |
33 changes: 33 additions & 0 deletions
33
...firm/AccountNetworkInfo/AccountNetworkInfoCollapsed/AccountNetworkInfoCollapsed.styles.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { StyleSheet } from 'react-native'; | ||
|
|
||
| import { Theme } from '../../../../../../../util/theme/models'; | ||
| import { fontStyles } from '../../../../../../../styles/common'; | ||
|
|
||
| const styleSheet = (params: { theme: Theme }) => { | ||
| const { theme } = params; | ||
|
|
||
| return StyleSheet.create({ | ||
| container: { | ||
| display: 'flex', | ||
| flexDirection: 'row', | ||
| }, | ||
| badgeWrapper: { | ||
| marginRight: 16, | ||
| alignSelf: 'center', | ||
| }, | ||
| accountName: { | ||
| color: theme.colors.text.default, | ||
| ...fontStyles.normal, | ||
| fontSize: 14, | ||
| fontWeight: '500', | ||
| }, | ||
| networkName: { | ||
| color: theme.colors.text.default, | ||
| ...fontStyles.normal, | ||
| fontSize: 14, | ||
| fontWeight: '400', | ||
| }, | ||
| }); | ||
| }; | ||
|
|
||
| export default styleSheet; |
14 changes: 14 additions & 0 deletions
14
...nfirm/AccountNetworkInfo/AccountNetworkInfoCollapsed/AccountNetworkInfoCollapsed.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import React from 'react'; | ||
|
|
||
| import renderWithProvider from '../../../../../../../util/test/renderWithProvider'; | ||
| import { personalSignatureConfirmationState } from '../../../../../../../util/test/confirm-data-helpers'; | ||
| import AccountNetworkInfoCollapsed from './AccountNetworkInfoCollapsed'; | ||
|
|
||
| describe('AccountNetworkInfoCollapsed', () => { | ||
| it('should match snapshot for personal sign', async () => { | ||
| const container = renderWithProvider(<AccountNetworkInfoCollapsed />, { | ||
| state: personalSignatureConfirmationState, | ||
| }); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); |
64 changes: 64 additions & 0 deletions
64
...ts/Confirm/AccountNetworkInfo/AccountNetworkInfoCollapsed/AccountNetworkInfoCollapsed.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import React from 'react'; | ||
| import { Text, View } from 'react-native'; | ||
| import { useSelector } from 'react-redux'; | ||
|
|
||
| import Avatar, { | ||
| AvatarAccountType, | ||
| AvatarVariant, | ||
| } from '../../../../../../../component-library/components/Avatars/Avatar'; | ||
| import Badge, { | ||
| BadgeVariant, | ||
| } from '../../../../../../../component-library/components/Badges/Badge'; | ||
| import BadgeWrapper from '../../../../../../../component-library/components/Badges/BadgeWrapper'; | ||
| import { RootState } from '../../../../../../UI/BasicFunctionality/BasicFunctionalityModal/BasicFunctionalityModal.test'; | ||
| import { useStyles } from '../../../../../../../component-library/hooks'; | ||
| import { | ||
| selectNetworkImageSource, | ||
| selectNetworkName, | ||
| } from '../../../../../../../selectors/networkInfos'; | ||
| import useAccountInfo from '../../../../hooks/useAccountInfo'; | ||
| import useApprovalRequest from '../../../../hooks/useApprovalRequest'; | ||
| import styleSheet from './AccountNetworkInfoCollapsed.styles'; | ||
|
|
||
| const AccountNetworkInfoCollapsed = () => { | ||
| const { approvalRequest } = useApprovalRequest(); | ||
| const networkName = useSelector(selectNetworkName); | ||
| const networkImage = useSelector(selectNetworkImageSource); | ||
| const useBlockieIcon = useSelector( | ||
| (state: RootState) => state.settings.useBlockieIcon, | ||
| ); | ||
| const fromAddress = approvalRequest?.requestData?.from; | ||
| const { accountName } = useAccountInfo(fromAddress); | ||
| const { styles } = useStyles(styleSheet, {}); | ||
|
|
||
| return ( | ||
| <View style={styles.container}> | ||
| <BadgeWrapper | ||
| badgeElement={ | ||
| <Badge | ||
| variant={BadgeVariant.Network} | ||
| name={networkName} | ||
| imageSource={networkImage} | ||
| /> | ||
| } | ||
| style={styles.badgeWrapper} | ||
| > | ||
| <Avatar | ||
| variant={AvatarVariant.Account} | ||
| type={ | ||
| useBlockieIcon | ||
| ? AvatarAccountType.Blockies | ||
| : AvatarAccountType.JazzIcon | ||
| } | ||
| accountAddress={fromAddress} | ||
| /> | ||
| </BadgeWrapper> | ||
| <View> | ||
| <Text style={styles.accountName}>{accountName}</Text> | ||
| <Text style={styles.networkName}>{networkName}</Text> | ||
| </View> | ||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| export default AccountNetworkInfoCollapsed; |
161 changes: 161 additions & 0 deletions
161
...kInfo/AccountNetworkInfoCollapsed/__snapshots__/AccountNetworkInfoCollapsed.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
.../confirmations/components/Confirm/AccountNetworkInfo/AccountNetworkInfoCollapsed/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { default } from './AccountNetworkInfoCollapsed'; |
14 changes: 14 additions & 0 deletions
14
...Confirm/AccountNetworkInfo/AccountNetworkInfoExpanded/AccountNetworkInfoExpanded.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import React from 'react'; | ||
|
|
||
| import renderWithProvider from '../../../../../../../util/test/renderWithProvider'; | ||
| import { personalSignatureConfirmationState } from '../../../../../../../util/test/confirm-data-helpers'; | ||
| import AccountNetworkInfoExpanded from './AccountNetworkInfoExpanded'; | ||
|
|
||
| describe('AccountNetworkInfoExpanded', () => { | ||
| it('should match snapshot for personal sign', async () => { | ||
| const container = renderWithProvider(<AccountNetworkInfoExpanded />, { | ||
| state: personalSignatureConfirmationState, | ||
| }); | ||
| expect(container).toMatchSnapshot(); | ||
| }); | ||
| }); |
44 changes: 44 additions & 0 deletions
44
...ents/Confirm/AccountNetworkInfo/AccountNetworkInfoExpanded/AccountNetworkInfoExpanded.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import React from 'react'; | ||
| import { View } from 'react-native'; | ||
| import { useSelector } from 'react-redux'; | ||
|
|
||
| import { strings } from '../../../../../../../../locales/i18n'; | ||
| import { selectRpcUrl } from '../../../../../../../selectors/networkController'; | ||
| import { selectNetworkName } from '../../../../../../../selectors/networkInfos'; | ||
| import useAccountInfo from '../../../../hooks/useAccountInfo'; | ||
| import useApprovalRequest from '../../../../hooks/useApprovalRequest'; | ||
| import InfoSection from '../../../UI/InfoRow/InfoSection'; | ||
| import InfoRow from '../../../UI/InfoRow'; | ||
| import InfoURL from '../../../UI/InfoRow/InfoValue/InfoURL'; | ||
|
|
||
| // todo: use value component for address, network, currency value | ||
| const AccountNetworkInfoExpanded = () => { | ||
| const { approvalRequest } = useApprovalRequest(); | ||
| const networkName = useSelector(selectNetworkName); | ||
| const networkRpcUrl = useSelector(selectRpcUrl); | ||
| const fromAddress = approvalRequest?.requestData?.from; | ||
| const { accountAddress, accountBalance } = useAccountInfo(fromAddress); | ||
|
|
||
| return ( | ||
| <View> | ||
| <InfoSection> | ||
| <InfoRow label={strings('confirm.account')}>{accountAddress}</InfoRow> | ||
| <InfoRow label={strings('confirm.balance')}>{accountBalance}</InfoRow> | ||
| </InfoSection> | ||
| <InfoSection> | ||
| <InfoRow | ||
| label={strings('confirm.network')} | ||
| // todo: add tooltip content when available | ||
| tooltip={strings('confirm.network')} | ||
| > | ||
| {networkName} | ||
| </InfoRow> | ||
| <InfoRow label={strings('confirm.rpc_url')}> | ||
| <InfoURL url={networkRpcUrl} /> | ||
| </InfoRow> | ||
| </InfoSection> | ||
jpuri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </View> | ||
| ); | ||
| }; | ||
|
|
||
| export default AccountNetworkInfoExpanded; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.