Skip to content

Update word check #5232

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update word check #5232

wants to merge 1 commit into from

Conversation

SeniorZhai
Copy link
Member

No description provided.

@crossle crossle requested a review from Copilot August 16, 2025 05:11
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the mnemonic phrase input validation by adding real-time word checking against the BIP-39 word list. The update provides immediate visual feedback to users when they enter invalid mnemonic words.

  • Added import for MnemonicCode to access the BIP-39 word list
  • Implemented visual validation with color changes for invalid words
  • Added error message display for invalid mnemonic phrases
  • Updated button enable/disable logic to require valid words

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

InputBar(currentText) { word ->
inputs = inputs.toMutableList().also { it[focusIndex] = word }
if (focusIndex != -1) {
InputBar(currentText) { word ->
Copy link
Preview

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The InputBar is now conditionally rendered only when focusIndex != -1, which means users cannot interact with the input bar when no field is focused. This breaks the user experience as the input bar becomes inaccessible after losing focus.

Suggested change
InputBar(currentText) { word ->
InputBar(currentText) { word ->
if (focusIndex != -1) {

Copilot uses AI. Check for mistakes.

@@ -198,6 +199,12 @@ fun MnemonicPhraseInput(
)
}
} else {
val text = inputs[index]
val textColor = if (index != focusIndex && text.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(text).not()) {
Copy link
Preview

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

The word list lookup MnemonicCode.INSTANCE.wordList.contains(text) is being called multiple times for the same text during composition. Consider caching the validation result or extracting it to avoid redundant lookups.

Suggested change
val textColor = if (index != focusIndex && text.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(text).not()) {
val isWordInList = remember(text) { MnemonicCode.INSTANCE.wordList.contains(text) }
val textColor = if (index != focusIndex && text.isNotEmpty() && !isWordInList) {

Copilot uses AI. Check for mistakes.

@@ -393,14 +399,22 @@ fun MnemonicPhraseInput(
color = MixinAppTheme.colors.tipError,
)
Spacer(modifier = Modifier.height(8.dp))
} else if (inputs.any { it.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(it).not() }) {
Copy link
Preview

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

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

This validation logic iterates through all inputs and performs word list lookups on each composition. This could be expensive with many input fields. Consider memoizing this validation or moving it to a computed property.

Suggested change
} else if (inputs.any { it.isNotEmpty() && MnemonicCode.INSTANCE.wordList.contains(it).not() }) {
} else if (hasInvalidInput) {

Copilot uses AI. Check for mistakes.

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.

1 participant