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

PERA-1353 :: Add new bottomsheet for HD Wallet flow #141

Draft
wants to merge 28 commits into
base: epic/pera-798-common-dev-update
Choose a base branch
from

Conversation

michaeltchuang
Copy link
Collaborator

@michaeltchuang michaeltchuang commented Feb 17, 2025

Pull Request Template

Description

  • Add new bottomsheet for future create and recovery HD Wallet flow
  • The bottomsheet is hidden by feature flag (only enabled for non prod release builds)
  • QR code recovery will input 24 words (recover button afterwards doesn't work or proceed)

Related Issues

Checklist

  • Have you tested your changes locally?
  • Have you reviewed the code for any potential issues?
  • Have you documented any necessary changes in the project's documentation?
  • Have you added any necessary tests for your changes?
  • Have you updated any relevant dependencies?

Additional Notes

  • Compose widget/theme code should be moved out of app module to it's own module eventually
  • We can polish colors if needed later, but I think this is usable for now

Here are some screenshots of bottom sheet

Screenshot_1739833474
Screenshot_1739833532

@michaeltchuang michaeltchuang self-assigned this Feb 17, 2025
@michaeltchuang michaeltchuang added the enhancement New feature or request label Feb 17, 2025
@michaeltchuang michaeltchuang added this to the 5.202504.0 milestone Feb 17, 2025
@michaeltchuang michaeltchuang linked an issue Feb 17, 2025 that may be closed by this pull request
@michaeltchuang
Copy link
Collaborator Author

for create wallet, we'll need to show recommended label and here are some images of that

Screenshot_1739838252
Screenshot_1739838277

@@ -111,6 +111,11 @@
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
Copy link
Collaborator

Choose a reason for hiding this comment

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

This implementation creates potential bugs. There is already mnemonic args. We can pass 24 mnemonic and 25 word counts.

Arg type can be a sealed interface with 2 different classes that implement this interface. passing two different arg that serves to same purpose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I switched to passing AccountType instead of word count so i think this issue is addressed. QR code parsing will default to word count when split checking since we don't know what account type it is (24 or 25 word passphrase)

Copy link
Collaborator

Choose a reason for hiding this comment

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

As I mentioned in some of my prvious comments. Using account type as an argument is not a correct implementation.

We are coupling a model that uses local account and account information with account creation arg.

@@ -28,6 +28,11 @@
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
Copy link
Collaborator

Choose a reason for hiding this comment

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

This implementation creates potential bugs. There is already mnemonic args. We can pass 24 mnemonic and 25 word counts.

Arg type can be a sealed interface with 2 different classes that implement this interface. passing two different arg that serves to same purpose.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

one variable is the input mnenomic string (empty for user to enter into form or qr code value that prefills the form)...the other variable is number of word text fields to show on the passphrase form. So instead of passing two input variables you want one? We can chat about this tomorrow in team meeting

Copy link
Collaborator Author

@michaeltchuang michaeltchuang Feb 22, 2025

Choose a reason for hiding this comment

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

I switched to passing AccountType instead of word count so i think this issue is addressed

@michaeltchuang michaeltchuang changed the base branch from dev to epic/pera-798-common-dev-update February 22, 2025 00:14
@michaeltchuang michaeltchuang marked this pull request as draft February 22, 2025 00:19
@michaeltchuang michaeltchuang added draft epic Extra attention is needed labels Feb 22, 2025
@michaeltchuang michaeltchuang removed the enhancement New feature or request label Feb 22, 2025
Comment on lines +20 to +29
@get:Rule
var hiltRule = HiltAndroidRule(this)

@Inject
lateinit var aesPlatformManager: AESPlatformManager

@Before
fun setup() {
hiltRule.inject()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

With this, we are testing provided AESPlatformManager. What we need to do is to create instance of the object manually like;

private val sut = AESPlatformManagerImpl(...)
  1. This adds extra processing which makes test slower
  2. This tests the implementation of the real class. Unit test needs to be isolated, that's why we should be testing implementation, not provided interface

@Test
fun testEncryptDecryptAlgo25SecretKey_shouldMatchOriginal() {
// Given
val originalSecretKey = Sdk.generateSK()
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't use Sdk functions, or any other library functions in our unit tests. By calling this function,

  • If Sdk.generateSK fails, the test will fail as well, even if sut works perfectly.
  • Any change in Sdk.generateSK may break out tests.

Our tests should be independent of external libraries

Comment on lines +51 to +52
val wordCount = Mnemonics.WordCount.COUNT_24
val originalEntropy = Mnemonics.MnemonicCode(wordCount).toEntropy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above


@Test
fun testEncryptDecryptEntropy_withEmptyArray() {
// Given
Copy link
Collaborator

Choose a reason for hiding this comment

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

there shouldn't be any given- when - then comments in our tests.

We are separating those sections by using new line.


sealed interface AccountType: Parcelable {

@Parcelize
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't use parcelize in our common-sdk domain models.

There are a few models doing that already, and I'll remove them as well. Our component needs to be platform-independent. This also makes things harder when we want to unit 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.

we seem to need this though because we're passing accountType as a nav graph bundle param between onboarding screens...i'm open to suggestions.

@@ -111,6 +111,11 @@
android:defaultValue="@null"
app:argType="string"
app:nullable="true" />
<argument
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I mentioned in some of my prvious comments. Using account type as an argument is not a correct implementation.

We are coupling a model that uses local account and account information with account creation arg.

@@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can remove this when we remove hilt injection in our test class

import com.algorand.wallet.encryption.SecretKeyEncryptionManager
import javax.inject.Inject

internal class GetHdWalletEntropyFromSeedIdUseCase @Inject constructor(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is local account specific usecase. We should move this usecase into local account package


fun updateHdSeedCustomNameAsFlow(hdSeed: HdSeed): Flow<Unit>

fun addHdSeedAsFlow(hdSeed: HdSeed, encryptedEntropy: ByteArray, encryptedSeed: ByteArray): Flow<Unit>
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this function? Why do we need to do this as flow?


suspend fun getAllHdSeed(entropyCustomName: String): List<HdSeed>

fun updateHdSeedCustomNameAsFlow(hdSeed: HdSeed): Flow<Unit>
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of this function? Why do we need to do this as flow?

@michaeltchuang michaeltchuang force-pushed the PERA-1353-bottomsheet-hd-wallet branch from 4c2a5f3 to 90e73e0 Compare February 25, 2025 03:55
@michaeltchuang michaeltchuang linked an issue Feb 28, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draft epic Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Task - Convert RegisterIntroFragment to Compose Task - New Account Recovery UI Flow
3 participants