forked from MetaMask/metamask-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding basic page for typed signatures V3, V4 (MetaMask#12506)
## **Description** Adding basic page for types sign V3, V4. ## **Related issues** Fixes: MetaMask/MetaMask-planning#3681 ## **Manual testing steps** 1. Enable re-designs locally 2. To to test dapp and submit V3, V4 signatures 3. Check the page that appears ## **Screenshots/Recordings** <img width="391" alt="Screenshot 2024-12-02 at 5 16 06 PM" src="https://github.com/user-attachments/assets/f198a928-70f9-48a9-ae93-2029b9ae3480"> ## **Pre-merge author checklist** - [X] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [X] I've completed the PR template to the best of my ability - [X] I’ve included tests if applicable - [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [X] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
- Loading branch information
Showing
13 changed files
with
173 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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
15 changes: 15 additions & 0 deletions
15
...s/Views/confirmations/components/Confirm/Info/Shared/InfoRowOrigin/InfoRowOrigin.test.tsx
This file contains 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,15 @@ | ||
import React from 'react'; | ||
|
||
import renderWithProvider from '../../../../../../../../util/test/renderWithProvider'; | ||
import { typedSignV1ConfirmationState } from '../../../../../../../../util/test/confirm-data-helpers'; | ||
import InfoRowOrigin from './InfoRowOrigin'; | ||
|
||
describe('InfoRowOrigin', () => { | ||
it('should contained required text', async () => { | ||
const { getByText } = renderWithProvider(<InfoRowOrigin />, { | ||
state: typedSignV1ConfirmationState, | ||
}); | ||
expect(getByText('Request from')).toBeDefined(); | ||
expect(getByText('metamask.github.io')).toBeDefined(); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
...onents/Views/confirmations/components/Confirm/Info/Shared/InfoRowOrigin/InfoRowOrigin.tsx
This file contains 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,28 @@ | ||
import React from 'react'; | ||
|
||
import { strings } from '../../../../../../../../../locales/i18n'; | ||
import useApprovalRequest from '../../../../../hooks/useApprovalRequest'; | ||
import InfoSection from '../../../../UI/InfoRow/InfoSection'; | ||
import InfoRow from '../../../../UI/InfoRow'; | ||
import DisplayURL from '../../../../UI/InfoRow/InfoValue/DisplayURL'; | ||
|
||
const InfoRowOrigin = () => { | ||
const { approvalRequest } = useApprovalRequest(); | ||
|
||
if (!approvalRequest) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<InfoSection> | ||
<InfoRow | ||
label={strings('confirm.request_from')} | ||
tooltip={strings('confirm.personal_sign_tooltip')} | ||
> | ||
<DisplayURL url={approvalRequest.origin} /> | ||
</InfoRow> | ||
</InfoSection> | ||
); | ||
}; | ||
|
||
export default InfoRowOrigin; |
1 change: 1 addition & 0 deletions
1
app/components/Views/confirmations/components/Confirm/Info/Shared/InfoRowOrigin/index.ts
This file contains 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 './InfoRowOrigin'; |
This file contains 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 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
30 changes: 30 additions & 0 deletions
30
app/components/Views/confirmations/components/Confirm/Info/TypedSignV3V4/Message.tsx
This file contains 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,30 @@ | ||
import React from 'react'; | ||
import { Text } from 'react-native'; | ||
|
||
import useApprovalRequest from '../../../../hooks/useApprovalRequest'; | ||
import SignatureMessageSection from '../../SignatureMessageSection'; | ||
|
||
const Message = () => { | ||
const { approvalRequest } = useApprovalRequest(); | ||
|
||
const typedSignData = approvalRequest?.requestData?.data; | ||
|
||
if (!typedSignData) { | ||
return null; | ||
} | ||
|
||
const parsedData = JSON.stringify(typedSignData); | ||
|
||
const firstDataValue = parsedData?.substring(0, 100); | ||
|
||
// todo: detailed data tree to be implemented | ||
return ( | ||
<SignatureMessageSection | ||
messageCollapsed={<Text>{firstDataValue}</Text>} | ||
messageExpanded={<Text>{parsedData}</Text>} | ||
copyMessageText={typedSignData} | ||
/> | ||
); | ||
}; | ||
|
||
export default Message; |
15 changes: 15 additions & 0 deletions
15
...mponents/Views/confirmations/components/Confirm/Info/TypedSignV3V4/TypedSignV3V4.test.tsx
This file contains 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,15 @@ | ||
import React from 'react'; | ||
|
||
import renderWithProvider from '../../../../../../../util/test/renderWithProvider'; | ||
import { typedSignV3ConfirmationState } from '../../../../../../../util/test/confirm-data-helpers'; | ||
import TypedSignV1 from './TypedSignV3V4'; | ||
|
||
describe('TypedSignV3V4', () => { | ||
it('should contained required text', async () => { | ||
const { getByText } = renderWithProvider(<TypedSignV1 />, { | ||
state: typedSignV3ConfirmationState, | ||
}); | ||
expect(getByText('Request from')).toBeDefined(); | ||
expect(getByText('metamask.github.io')).toBeDefined(); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
app/components/Views/confirmations/components/Confirm/Info/TypedSignV3V4/TypedSignV3V4.tsx
This file contains 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,23 @@ | ||
import React from 'react'; | ||
|
||
import useApprovalRequest from '../../../../hooks/useApprovalRequest'; | ||
import InfoRowOrigin from '../Shared/InfoRowOrigin'; | ||
import Message from './Message'; | ||
|
||
const TypedSignV3V4 = () => { | ||
const { approvalRequest } = useApprovalRequest(); | ||
|
||
if (!approvalRequest) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{/* SIMULATION TO BE ADDED */} | ||
<InfoRowOrigin /> | ||
<Message /> | ||
</> | ||
); | ||
}; | ||
|
||
export default TypedSignV3V4; |
1 change: 1 addition & 0 deletions
1
app/components/Views/confirmations/components/Confirm/Info/TypedSignV3V4/index.ts
This file contains 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 './TypedSignV3V4'; |
This file contains 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 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