-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add verification flow #1827
Add verification flow #1827
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
d71a129
to
be4d3b8
Compare
be4d3b8
to
5841c08
Compare
7554978
to
e237a51
Compare
e237a51
to
a273a77
Compare
a273a77
to
74be1e2
Compare
74be1e2
to
2b573f9
Compare
645833c
to
8d400fb
Compare
8d400fb
to
94887d6
Compare
47259df
to
589e716
Compare
const restoreFromMnemonic = useRestoreFromMnemonic(); | ||
const restoreFromSecretKey = useRestoreFromSecretKey(); | ||
const checkPassword = useValidateMasterPassword(); | ||
const getNextAvailableAccountLabels = useGetNextAvailableAccountLabels(); | ||
const isPasswordSet = useIsPasswordSet(); | ||
const getDecryptedMnemonic = useGetDecryptedMnemonic(); | ||
const currentAccount = useCurrentAccount() as MnemonicAccount; |
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.
that's a very brave type cast, please don't do that
case "verification": { | ||
const mnemonic = await getDecryptedMnemonic(currentAccount, password); | ||
|
||
return openWith(<ImportantNoticeModal seedPhrase={mnemonic} />, { size: "xl" }); |
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.
nit: for consistency, maybe it's better to use just 1 thing - either seedphrase or mnemonic
import { useHandleVerify } from "./useHandleVerify"; | ||
import { AlertIcon } from "../../../assets/icons"; | ||
import { useColor } from "../../../styles/useColor"; | ||
import { ModalCloseButton } from "../../CloseButton"; | ||
|
||
// TODO: Replace with actual copy paste |
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.
haven't you?
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.
didn't get the text content yet
} = form; | ||
|
||
const seedphraseArray = seedPhrase.split(" "); | ||
const [randomElements] = useState(selectRandomElements(seedphraseArray, 3)); |
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.
useMemo?
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.
basically they both do the same thing in this case
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.
Exactly. But we don't use scissors to cut bread even though, technically, it's possible
<form onSubmit={handleSubmit(onSubmit)}> | ||
<ModalBody> | ||
<Flex gap="12px"> | ||
{randomElements.map(({ index, value }) => { |
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.
I suggest you either define the type for the form like
useForm<{word1: string, word2: string, word3: string}>
or use useFieldArray
. as you can clearly see, the crutches are hard to deal with
|
||
return ( | ||
<FormControl key={index} isInvalid={!!error}> | ||
<Flex key={index} alignItems="center"> |
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.
doubled key?
textAlign="right" | ||
size={{ lg: "lg", base: "xs" }} | ||
> | ||
{String(index + 1).padStart(2, "0")}. |
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.
I saw a very similar component "somewhere", please eliminate the duplication and create a new component
}); | ||
|
||
it("should open ImportantNoticeModal modal if master password is set", async () => { | ||
(useGetDecryptedMnemonic as jest.Mock).mockImplementation(() => () => mnemonic1); |
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.
please avoid using type casting, use jest.mocked instead
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.
it is used here on purpose to avoid unnecessary type checking when mocking implementation
f68dc55
to
6cdcba1
Compare
6cdcba1
to
6587eeb
Compare
}) | ||
); | ||
|
||
dispatch(accountsActions.setPassword("")); |
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.
Maybe it's better to use null/undefined here? Empty string is still a string, so, technically, the password is set
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.
this is default value for password. Technically empty string is falsy, assuming no password is set
index={index} | ||
/> | ||
{error?.message && ( | ||
<FormErrorMessage>{(error as any).message}</FormErrorMessage> |
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.
As any is not needed here
const { openWith } = dynamicModalContextMock; | ||
const { result } = renderHook(useHandleVerify, { store }); | ||
|
||
await act(async () => await result.current()); |
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.
Async await is redundant
6587eeb
to
0e23b10
Compare
0e23b10
to
353e252
Compare
Proposed changes
Task link
Types of changes
Steps to reproduce
Screenshots
Add the screenshots of how the app used to look like and how it looks now
Screen.Recording.2024-09-04.at.11.55.21.mov
Checklist