-
Notifications
You must be signed in to change notification settings - Fork 16
feat: unify Midnight wallet onboarding flow [LW-13693] #2103
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
base: main
Are you sure you want to change the base?
Conversation
Allure Report
processReports: ❌ test report for 3f179f81
|
abecbef to
9ca9d2d
Compare
abfa24b to
57cf49a
Compare
DominikGuzei
left a comment
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.
Great work 👏
57cf49a to
a96354e
Compare
| const keyMaterialBytes = await Wallet.KeyManagement.emip3decrypt( | ||
| new Uint8Array(Buffer.from(walletToReuse.encryptedRecoveryPhrase, 'hex')), | ||
| new Uint8Array(Buffer.from(password)) | ||
| ); | ||
| mnemonic = Buffer.from(keyMaterialBytes).toString('utf8').split(' '); |
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 have created some getMnemonicForWallet somewhere in the lmp utils? :)
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.
Yep! Thanks. I am currently applying some of the improvements, like this one. :)
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.
Btw, this is the same as what is happening here. Maybe you can reuse
| import { Portal } from '@views/browser/features/wallet-setup/components/Portal'; | ||
| import { APP_MODE, lmpModeStorage } from '@src/utils/lmp'; | ||
|
|
||
| const CAME_FROM_LMP_KEY = 'lace-came-from-lmp'; |
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.
We should centralize this key and not repeat it
| wallet !== null && typeof wallet === 'object' && 'walletName' in wallet; | ||
|
|
||
| const getWalletDisplayName = (wallet: unknown): string | undefined => | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any |
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.
Use a more exact type
| // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| type MidnightWallet = { walletId: string; walletName: string; encryptedRecoveryPhrase?: string }; | ||
|
|
||
| const isMidnightWallet = (wallet: unknown): wallet is MidnightWallet => | ||
| wallet !== null && typeof wallet === 'object' && 'walletName' in wallet; |
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 something like this? We don't need to create this MidnightWallet type and LmpBundleWallet has a blockchain property which is a more deterministic way to check this
| type MidnightWallet = { walletId: string; walletName: string; encryptedRecoveryPhrase?: string }; | |
| const isMidnightWallet = (wallet: unknown): wallet is MidnightWallet => | |
| wallet !== null && typeof wallet === 'object' && 'walletName' in wallet; | |
| const isMidnightWallet = (wallet: unknown): wallet is LmpBundleWallet => | |
| wallet !== null && typeof wallet === 'object' && (wallet as LmpBundleWallet).blockchain === 'Midnight'; |
| const keyMaterialBytes = await Wallet.KeyManagement.emip3decrypt( | ||
| new Uint8Array(Buffer.from(walletToReuse.encryptedRecoveryPhrase, 'hex')), | ||
| new Uint8Array(Buffer.from(password)) | ||
| ); | ||
| mnemonic = Buffer.from(keyMaterialBytes).toString('utf8').split(' '); |
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.
Btw, this is the same as what is happening here. Maybe you can reuse
|
|
||
| export type ReusableWallet = | ||
| | AnyWallet<Wallet.WalletMetadata, Wallet.AccountMetadata> | ||
| | { walletId: string; walletName: string; encryptedRecoveryPhrase?: string }; |
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.
| | { walletId: string; walletName: string; encryptedRecoveryPhrase?: string }; | |
| | LmpBundleWallet; |
f328133 to
b3a2493
Compare
- Add Midnight to "Select Blockchain" screen (create/restore wallet) - Remove separate AddNewMidnightWalletLink from dropdown menu - Add useLMP hook with startMidnightCreate/Restore methods
b3a2493 to
4bd853f
Compare
|



Checklist
Please see the commits.