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

request Destination tag for ripple #16915

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

vytick
Copy link
Contributor

@vytick vytick commented Feb 11, 2025

By default request Destination tag for ripple

Related Issue

Resolve #16636

Screenshots:

Simulator.Screen.Recording.-.iPhone.16.-.2025-02-11.at.01.29.41.mp4

@vytick vytick added mobile Suite Lite issues and PRs Ripple XRP labels Feb 11, 2025
@vytick vytick requested a review from a team as a code owner February 11, 2025 00:43
Copy link

github-actions bot commented Feb 11, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

@PeKne
Copy link
Contributor

PeKne commented Feb 11, 2025

Why is dbdd244 part of this PR? It is probably mistake

/>
</Animated.View>
)}
{isInputDisplayed && (
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: isInputDisplayed ternanry operator is already used few lines above. I would prefer if this code block would be rendered under the same condition next to the TextInputField to avoid condition duplication.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a benefit it can be a single Animated.View. We also have AnimatedBox and AnimatedVStack defined, that might come handy to you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -194,10 +194,36 @@ export const sendOutputsFormValidationSchema = yup.object({
}),
)
.required(),
enableDestinationTagValidation: yup.boolean(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: what about this name?

Suggested change
enableDestinationTagValidation: yup.boolean(),
isRippleDestinationTagEnabled: yup.boolean(),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.matches(/^\d*$/, 'You can only use positive numbers for the destination tag.')
.test(
'is-destination-tag-set',
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I would change name of this validation to this:

Suggested change
'is-destination-tag-set',
'is-destination-tag-required',

Because it runs even for non XRP coins where it is not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@PeKne PeKne left a comment

Choose a reason for hiding this comment

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

Few nits, nothing major

@vytick vytick changed the title fixup! feat(suite-native): introduce crypto icon with network request Destination tag for ripple Feb 11, 2025
@vytick vytick force-pushed the icons-tokens-with-networks branch from 6bc67e3 to 39c7218 Compare February 11, 2025 09:53
@trezor-ci trezor-ci force-pushed the icons-tokens-with-networks branch from 39c7218 to 6f6ceab Compare February 11, 2025 09:55
Base automatically changed from icons-tokens-with-networks to develop February 11, 2025 10:45
@vytick vytick force-pushed the feat/native/xrp-destination-tag-enhancement branch from d44a491 to b23fb40 Compare February 11, 2025 11:03
Copy link

coderabbitai bot commented Feb 11, 2025

Walkthrough

The changes across the modules introduce enhanced support for XRP transactions by updating both UI components and validation logic. The localization strings now include detailed instructions and warnings for XRP destination tags, while the label for destination tags in the sending module is restructured into an object with multiple descriptive fields. Changes in the DestinationTagInput component update its layout, control flow, and import dependencies, incorporating toggling functionality via a switch to show or hide the input field. The SendOutputsScreen now accepts a new parameter to determine if the Ripple destination tag feature is enabled, and the corresponding validation schema conditionally requires the tag based on this flag. Additionally, the ReceiveAddressScreen now displays an informational alert when the account’s network type is XRP, ensuring users receive context-specific guidance.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
suite-native/module-send/src/components/DestinationTagInput.tsx (1)

45-57: Consider adding error handling for focus timing.

The setTimeout for input focus has no error handling and might fail silently if the input ref is not ready.

 const handleShowInputChange = () => {
     if (!isInputDisplayed) {
         setValue(isRippleDestinationTagEnabledName, true);
-        // Wait for input element to be mounted.
-        setTimeout(() => {
+        const focusTimeout = setTimeout(() => {
             inputRef.current?.focus();
-        });
+        }, 0);
+        return () => clearTimeout(focusTimeout);
     } else {
         setValue(isRippleDestinationTagEnabledName, false);
     }
     trigger(destinationTagFieldName);
     setIsInputDisplayed(!isInputDisplayed);
 };
suite-native/module-send/src/screens/SendOutputsScreen.tsx (1)

211-216: Address the TODO comment about using reset().

The code contains a TODO suggesting to use reset() instead of setValue().

Would you like me to help implement the form reset functionality to replace the setValue() calls?

suite-native/intl/src/en.ts (1)

1135-1141: LGTM! Well-structured translations for destination tag fields.

The translations are clear, informative, and properly structured with label, warning, info, and linkText fields. The messages effectively guide users through the destination tag requirement for exchange transactions.

Consider adding a placeholder text for the destination tag input field to provide an example of what a valid tag looks like.

Add a placeholder field to the destinationTag object:

 destinationTag: {
     label: 'Destination tag',
     warning:
         'Online exchanges require this to identify your account. Get your destination tag from your Ripple account. Make sure you really don't need it.',
     info: 'Online exchanges require this to identify your account. Get your destination tag from your exchange.',
     linkText: '<link>What's this?</link>',
+    placeholder: 'e.g., 123456',
 },
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65583b2 and b23fb40.

📒 Files selected for processing (5)
  • suite-native/intl/src/en.ts (2 hunks)
  • suite-native/module-send/src/components/DestinationTagInput.tsx (2 hunks)
  • suite-native/module-send/src/screens/SendOutputsScreen.tsx (2 hunks)
  • suite-native/module-send/src/sendOutputsFormSchema.ts (1 hunks)
  • suite-native/receive/src/screens/ReceiveAddressScreen.tsx (3 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
suite-native/module-send/src/sendOutputsFormSchema.ts

[error] 202-202: Do not add then to an object.

(lint/suspicious/noThenProperty)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: EAS Update
  • GitHub Check: prepare_android_test_app
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Setup and Cache Dependencies
🔇 Additional comments (6)
suite-native/receive/src/screens/ReceiveAddressScreen.tsx (1)

70-115: LGTM! Well-structured implementation of XRP info alert.

The implementation effectively adds an informative alert for XRP accounts with proper localization and helpful documentation link.

suite-native/module-send/src/components/DestinationTagInput.tsx (1)

111-138: Consolidate animation logic to reduce duplication.

The animation logic is duplicated between the input and alert box sections.

As suggested in the previous review, consider consolidating the animation logic under a single condition to avoid duplication.

suite-native/module-send/src/sendOutputsFormSchema.ts (2)

197-204: LGTM! Well-structured conditional validation.

The validation logic correctly handles the conditional requirement of the destination tag based on the enabled state.

🧰 Tools
🪛 Biome (1.9.4)

[error] 202-202: Do not add then to an object.

(lint/suspicious/noThenProperty)


206-226: Consider renaming the test for clarity.

The test name 'is-destination-tag-required' could be misleading as it runs for non-XRP coins where it's not required.

As suggested in the previous review, consider renaming to better reflect its purpose.

suite-native/module-send/src/screens/SendOutputsScreen.tsx (1)

119-122: LGTM! Clean implementation of default values.

The implementation correctly sets the default state of the destination tag based on the network type.

suite-native/intl/src/en.ts (1)

520-521: LGTM! Clear and helpful message for XRP destination tags.

The message effectively communicates that while exchanges may require destination tags, Trezor itself does not, and provides a link for more information.

const debounce = useDebounce();

const { trigger } = useFormContext<SendOutputsFormValues>();
const isRippleDestinationTagEnabledName: SendFieldName = 'isRippleDestinationTagEnabled';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const isRippleDestinationTagEnabledName: SendFieldName = 'isRippleDestinationTagEnabled';
const isRippleDestinationTagEnabledFieldName: SendFieldName = 'isRippleDestinationTagEnabled';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good spot, fixed and rebased

@vytick
Copy link
Contributor Author

vytick commented Feb 11, 2025

/rebase

Copy link

@trezor-ci trezor-ci force-pushed the feat/native/xrp-destination-tag-enhancement branch from 061645b to 8b0b18e Compare February 11, 2025 11:10
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
suite-native/module-send/src/components/DestinationTagInput.tsx (1)

111-138: Consider consolidating the animation components.

The animation logic is duplicated between the input field and alert box sections. Consider using a single AnimatedVStack or AnimatedBox to wrap both conditions.

-            {isInputDisplayed ? (
-                <AnimatedVStack spacing="sp8" entering={FadeIn} exiting={FadeOut}>
-                    <TextInputField
-                        valueTransformer={integerTransformer}
-                        ref={inputRef}
-                        onChangeText={handleChangeValue}
-                        name={destinationTagFieldName}
-                        testID={destinationTagFieldName}
-                        onFocus={handleInputFocus}
-                        accessibilityLabel="address input"
-                    />
-                    <HStack paddingHorizontal="sp12" spacing="sp4">
-                        <Icon name="info" color="iconSubdued" size="medium" />
-                        <Text variant="label" color="textSubdued">
-                            <Translation id="moduleSend.outputs.recipients.destinationTag.info" />
-                        </Text>
-                    </HStack>
-                </AnimatedVStack>
-            ) : (
-                <Animated.View entering={FadeIn} exiting={FadeOut}>
-                    <AlertBox
-                        variant="warning"
-                        title={
-                            <Translation id="moduleSend.outputs.recipients.destinationTag.warning" />
-                        }
-                    />
-                </Animated.View>
-            )}
+            <AnimatedVStack entering={FadeIn} exiting={FadeOut}>
+                {isInputDisplayed ? (
+                    <>
+                        <TextInputField
+                            valueTransformer={integerTransformer}
+                            ref={inputRef}
+                            onChangeText={handleChangeValue}
+                            name={destinationTagFieldName}
+                            testID={destinationTagFieldName}
+                            onFocus={handleInputFocus}
+                            accessibilityLabel="address input"
+                        />
+                        <HStack paddingHorizontal="sp12" spacing="sp4">
+                            <Icon name="info" color="iconSubdued" size="medium" />
+                            <Text variant="label" color="textSubdued">
+                                <Translation id="moduleSend.outputs.recipients.destinationTag.info" />
+                            </Text>
+                        </HStack>
+                    </>
+                ) : (
+                    <AlertBox
+                        variant="warning"
+                        title={
+                            <Translation id="moduleSend.outputs.recipients.destinationTag.warning" />
+                        }
+                    />
+                )}
+            </AnimatedVStack>
suite-native/module-send/src/sendOutputsFormSchema.ts (2)

197-204: Fix the Yup schema syntax to avoid the then property warning.

The current implementation triggers a static analysis warning about using the then property. Consider using the alternative syntax for conditional validation.

-    rippleDestinationTag: yup
-        .string()
-        .when('isRippleDestinationTagEnabled', {
-            is: true,
-            then: schema => schema.required('Destination Tag is required'),
-            otherwise: schema => schema.notRequired(),
-        })
+    rippleDestinationTag: yup
+        .string()
+        .when('isRippleDestinationTagEnabled', ([isEnabled], schema) =>
+            isEnabled
+                ? schema.required('Destination Tag is required')
+                : schema.notRequired()
+        )
🧰 Tools
🪛 Biome (1.9.4)

[error] 202-202: Do not add then to an object.

(lint/suspicious/noThenProperty)


206-226: The validation test name could be more descriptive.

The test name 'is-destination-tag-required' doesn't fully convey its purpose since it runs for all coins but only enforces the tag for Ripple.

-            'is-destination-tag-required',
+            'is-ripple-destination-tag-required',
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b23fb40 and 8b0b18e.

📒 Files selected for processing (5)
  • suite-native/intl/src/en.ts (2 hunks)
  • suite-native/module-send/src/components/DestinationTagInput.tsx (2 hunks)
  • suite-native/module-send/src/screens/SendOutputsScreen.tsx (2 hunks)
  • suite-native/module-send/src/sendOutputsFormSchema.ts (1 hunks)
  • suite-native/receive/src/screens/ReceiveAddressScreen.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • suite-native/module-send/src/screens/SendOutputsScreen.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
suite-native/module-send/src/sendOutputsFormSchema.ts

[error] 202-202: Do not add then to an object.

(lint/suspicious/noThenProperty)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: prepare_android_test_app
  • GitHub Check: EAS Update
  • GitHub Check: Analyze with CodeQL (javascript)
🔇 Additional comments (3)
suite-native/receive/src/screens/ReceiveAddressScreen.tsx (1)

70-115: LGTM! The XRP destination tag information is well-integrated.

The changes effectively integrate the XRP destination tag information into the receive screen:

  • The condition for showing XRP info is correctly implemented
  • The alert box provides clear information with a properly configured link
  • The UI components are well-structured and follow the design system
suite-native/module-send/src/components/DestinationTagInput.tsx (1)

37-57: The state management and form context updates are well-implemented.

The toggle functionality is properly implemented with appropriate form context updates and state management.

suite-native/intl/src/en.ts (1)

520-522: LGTM! The translation strings are clear and well-structured.

The new translation strings effectively communicate the purpose and requirements of the XRP destination tag feature:

  • Clear instructions for users
  • Proper explanation of when tags are required
  • Well-structured messages with appropriate placeholders

Also applies to: 1135-1141

@vytick vytick merged commit 903dd5c into develop Feb 11, 2025
16 checks passed
@vytick vytick deleted the feat/native/xrp-destination-tag-enhancement branch February 11, 2025 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Suite Lite issues and PRs Ripple XRP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mobile: XRP destination tag improvement
2 participants