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: new mobile wallet create flow #8760

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

NeOMakinG
Copy link
Collaborator

@NeOMakinG NeOMakinG commented Feb 6, 2025

Description

Implement the new mobile flow of creating a wallet, backing up mnemonic

Using the dialog component

As a follow up, we should replace this flow from the splash screen too

Issue (if applicable)

closes #8706

Risk

High (create wallet on mobile, mnemonic memory leaks...)

High Risk PRs Require 2 approvals

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

Testing

  • Create a wallet using the mobile app (desktop and responsive shouldn't change yet)
  • Create wallet from the splash screen mobile app didn't change yet (because the drawer is not initialized on this part yet)
  • Try to select a wallet and hit backup, the mobile should ask for the password/faceid and show the right backup phrase, next button shouldn't be shown

Engineering

A small concern on memory clean up that I'll add as a self-review comment

Operations

n.a

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots (if applicable)

https://jam.dev/c/0e88ee55-607f-485a-a705-deb03c002e53

Pushed to gome so we can test!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a legacy component from the initial dialog implementation, not used anymore

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this file to it's proper folder, this is a feature by itself as we also redirect to this view one level upper in the tree (when backing up already created wallet)

@@ -18,10 +24,12 @@ export const CarouselDots = ({ length, activeIndex, onClick }: CarouselDotsProps
width='7px'
height='7px'
borderRadius='50%'
backgroundColor={i === activeIndex - 1 ? activeDotBackgroundColor : 'text.subtle'}
backgroundColor={
i === activeIndex - 1 ? activeDotBackgroundColor : inactiveDotBackgroundColor
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it more customizable anywhere

Comment on lines +67 to +72
useEffect(() => {
try {
if (!vault) setVault(location.state?.vault ?? createWallet())
} catch (e) {
console.log(e)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My biggest concern:

Should we revoke the wallet and recreate it in every screens? It's a lot of boilerplate/verbose code that I avoided, because I mean, if a not-memoized component is unmounted, it shouldn't stay in memory

But happy to bring it if we feel like we need some extra safety

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be safe indeed since this is a state var.
Revoker basically just revokes whichever secret (seed, master key, isolated mnemonic or whatever the isolation wallet does magic-wise...), but indeed, vault is also nuked from cache on unmount in theory.

With that being said,I'm not sure that it being theoretically safe is a good enough reason not to revoke, especially given how routing works (definitely seen many instances of routes still being mounted), and not super confident with security relying on such assumption.

@NeOMakinG can we keep it non-revoked and assume routes being unmounted means garbage collect kicking in and nuking vault for that PR but do a direct follow-up with revoke() boilerplate?

@NeOMakinG NeOMakinG marked this pull request as ready for review February 7, 2025 10:58
@NeOMakinG NeOMakinG requested a review from a team as a code owner February 7, 2025 10:58
@gomesalexandre gomesalexandre self-requested a review February 7, 2025 20:21
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What a beast of a PR ser. Functionally looks sane minus a few smolish comments, runtime test incoming.

@@ -2,6 +2,8 @@ import { AnimatePresence } from 'framer-motion'
import { MemoryRouter, Redirect, Route, Switch } from 'react-router'
import { Dialog } from 'components/Modal/components/Dialog'

import { CreateRouter } from './routes/CreateWallet/CreateRouter'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: CreateWalletRouter

@@ -87,7 +101,7 @@ export const SavedWallets: React.FC<SavedWalletsProps> = ({ onClose }) => {
variant='ghost'
colorScheme='blue'
leftIcon={addIcon}
onClick={handleCreate}
onClick={handleCreateClick}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💜

setSelectedWordIndex(prev => {
const next = (prev ?? -1) + 1
if (next >= TEST_COUNT_REQUIRED) {
;(async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: should this method be an async callback instead of IIAFE?

Comment on lines +67 to +72
useEffect(() => {
try {
if (!vault) setVault(location.state?.vault ?? createWallet())
} catch (e) {
console.log(e)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this should be safe indeed since this is a state var.
Revoker basically just revokes whichever secret (seed, master key, isolated mnemonic or whatever the isolation wallet does magic-wise...), but indeed, vault is also nuked from cache on unmount in theory.

With that being said,I'm not sure that it being theoretically safe is a good enough reason not to revoke, especially given how routing works (definitely seen many instances of routes still being mounted), and not super confident with security relying on such assumption.

@NeOMakinG can we keep it non-revoked and assume routes being unmounted means garbage collect kicking in and nuking vault for that PR but do a direct follow-up with revoke() boilerplate?


<Box bg={bgColor} borderRadius='xl' p={4} width='full'>
<SimpleGrid columns={2} spacing={2}>
{words.map((word, index) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: can be memoized

Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, confirmed we're still looking good create (in splash and in wallet-connected state) and backup-wise (on new create backup state as well as in wallet-connected state).

Some smallish visual shenanigans to be tackled, though nothing major blocking functionally.

  • Manual backup hints that there is a next step, however showContinueButton is false when in the context of a connected wallet we're backing up, and this copy should probably be hidden?
image
  • Similarly re: flow not being adapter to the "backing up a connected wallet" flow and assuming this is the backup step when creating a wallet, there is a stepper which is also confusing and probably shouldn't be here
image
  • Seed looks sane above ✅

  • Creating a wallet is sane ✅

One lil weird flash of testing a word at around 51 seconds if we want to tackle this @NeOMakinG https://jam.dev/c/566a5b5a-5320-4057-a362-6750a886a775?startFrom=51.70

image image
  • Creating a wallet from splash is still happy ✅

https://jam.dev/c/a5507c51-4732-4538-a9a8-630fa8cc60e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create new wallet mobile flow
2 participants