-
Notifications
You must be signed in to change notification settings - Fork 5k
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: Support various redesign signatures in ConfirmPage Storybook #25054
Merged
digiwand
merged 9 commits into
develop
from
feat-storybook-confirm-page-signature-pages
Jun 12, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b0fb69e
refactor: Confirm Page storybook for signatures
digiwand 0b8ce23
refactor: ConfirmPage sign stories using template
digiwand c6e99ec
feat: add ConfirmPage SignTypedData signature stories
digiwand 9b804ae
Merge branch 'develop' into feat-storybook-confirm-page-signature-pages
digiwand 81e0009
refactor: update ConfirmPage storybook controls to object
digiwand 4dce1b7
refactor: update const to uppercase ConfirmPage stories
digiwand 8510dfc
chore: add @note to ConfirmPage
digiwand 6fd3ba5
Merge branch 'develop' into feat-storybook-confirm-page-signature-pages
digiwand 1076e3b
Merge branch 'develop' into feat-storybook-confirm-page-signature-pages
digiwand 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 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 |
---|---|---|
@@ -1,27 +1,96 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import configureStore from '../../../store/store'; | ||
import { cloneDeep } from 'lodash'; | ||
import { unapprovedPersonalSignMsg, signatureRequestSIWE } from '../../../../test/data/confirmations/personal_sign'; | ||
import { unapprovedTypedSignMsgV1, unapprovedTypedSignMsgV4, permitSignatureMsg } from '../../../../test/data/confirmations/typed_sign'; | ||
import mockState from '../../../../test/data/mock-state.json'; | ||
import configureStore from '../../../store/store'; | ||
import ConfirmPage from './confirm'; | ||
|
||
const store = configureStore({ | ||
confirm: { | ||
currentConfirmation: { | ||
type: 'personal_sign', | ||
}, | ||
}, | ||
metamask: { | ||
...mockState.metamask, | ||
}, | ||
}); | ||
|
||
/** | ||
* @note When we extend this storybook page to support more confirmation types, | ||
* consider creating a new storybook pages. | ||
*/ | ||
const ConfirmPageStory = { | ||
title: 'Pages/Confirm/ConfirmPage', | ||
decorators: [(story) => <Provider store={store}>{story()}</Provider>], | ||
decorators: [(story) => <div style={{ height: '600px' }}>{story()}</div>], | ||
} | ||
|
||
const ARGS_SIGNATURE = { | ||
msgParams: { ...unapprovedPersonalSignMsg.msgParams }, | ||
} | ||
|
||
const ARG_TYPES_SIGNATURE = { | ||
msgParams: { | ||
control: 'object', | ||
description: '(non-param) overrides currentConfirmation.msgParams', | ||
}, | ||
} | ||
|
||
function SignatureStoryTemplate(args, confirmation) { | ||
const mockConfirmation = cloneDeep(confirmation); | ||
mockConfirmation.msgParams = args.msgParams; | ||
|
||
const store = configureStore({ | ||
confirm: { | ||
currentConfirmation: mockConfirmation, | ||
}, | ||
metamask: { ...mockState.metamask }, | ||
}); | ||
|
||
return <Provider store={store}><ConfirmPage /></Provider>; | ||
} | ||
|
||
export const PersonalSignStory = (args) => { | ||
return SignatureStoryTemplate(args, unapprovedPersonalSignMsg); | ||
}; | ||
|
||
export const DefaultStory = (args) => <ConfirmPage {...args} />; | ||
PersonalSignStory.storyName = 'Personal Sign'; | ||
PersonalSignStory.argTypes = ARG_TYPES_SIGNATURE; | ||
PersonalSignStory.args = ARGS_SIGNATURE; | ||
|
||
DefaultStory.storyName = 'Default'; | ||
export const SignInWithEthereumSIWEStory = (args) => { | ||
return SignatureStoryTemplate(args, signatureRequestSIWE); | ||
}; | ||
|
||
SignInWithEthereumSIWEStory.storyName = 'Sign-in With Ethereum (SIWE)'; | ||
SignInWithEthereumSIWEStory.argTypes = ARG_TYPES_SIGNATURE; | ||
SignInWithEthereumSIWEStory.args = { | ||
...ARGS_SIGNATURE, | ||
msgParams: signatureRequestSIWE.msgParams, | ||
}; | ||
|
||
export const SignTypedDataStory = (args) => { | ||
return SignatureStoryTemplate(args, unapprovedTypedSignMsgV1); | ||
}; | ||
|
||
SignTypedDataStory.storyName = 'SignTypedData'; | ||
SignTypedDataStory.argTypes = ARG_TYPES_SIGNATURE; | ||
SignTypedDataStory.args = { | ||
...ARGS_SIGNATURE, | ||
msgParams: unapprovedTypedSignMsgV1.msgParams, | ||
}; | ||
|
||
export const PermitStory = (args) => { | ||
return SignatureStoryTemplate(args, permitSignatureMsg); | ||
}; | ||
|
||
PermitStory.storyName = 'SignTypedData Permit'; | ||
PermitStory.argTypes = ARG_TYPES_SIGNATURE; | ||
PermitStory.args = { | ||
...ARGS_SIGNATURE, | ||
msgParams: permitSignatureMsg.msgParams, | ||
}; | ||
|
||
export const SignTypedDataV4Story = (args) => { | ||
matthewwalsh0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return SignatureStoryTemplate(args, unapprovedTypedSignMsgV4); | ||
}; | ||
|
||
SignTypedDataV4Story.storyName = 'SignTypedData V4'; | ||
SignTypedDataV4Story.argTypes = ARG_TYPES_SIGNATURE; | ||
SignTypedDataV4Story.args = { | ||
...ARGS_SIGNATURE, | ||
msgParams: unapprovedTypedSignMsgV4.msgParams, | ||
}; | ||
|
||
export default ConfirmPageStory; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also force the width so it matches the standard MetaMask popup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. As you might have noticed, the height resembles our popup height. I added this to view the scrollToBottom feature on some of the signature pages without needing to hardcode or add a control for this.
I left out the width so that we could easily test various widths. These decisions were subjective. Open to other suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we still support re-sizing to test wrapping etc, but default to the standard width?