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

fix: send send form high fee dialog #5350

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

kyranjamie
Copy link
Collaborator

@kyranjamie kyranjamie commented May 7, 2024

Try out Leather build acfa71aExtension build, Test report, Storybook, Chromatic

In investigating the Gamma issue, I noticed the Stacks send form is broken in a few ways. Also some funky type casting, where a type is cast to a type it isn't to satisfy the compiler.

TODO:

  • Add integration test for high fee functionality

Summary by CodeRabbit

  • New Features

    • Introduced a high fee warning dialog system to enhance user awareness of transaction costs.
    • Implemented a context provider to manage visibility and interactions of the high fee warning dialog across various components.
  • Refactor

    • Centralized high fee warning management using a new context provider, improving code maintainability and user experience.
    • Updated various components to utilize the new context provider for high fee warnings, ensuring consistent behavior across the application.
  • Bug Fixes

    • Adjusted import paths and refactored components to ensure smooth integration of the new high fee warning system.
  • Documentation

    • Updated component documentation to reflect changes in state management and context usage.

Copy link

coderabbitai bot commented May 8, 2024

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent updates focus on enhancing the handling of high fee warnings across various components in a React application. The primary change involves centralizing the state management for high fee warnings using a context provider, thereby simplifying interactions and improving maintainability. This affects multiple components related to transaction forms and fee handling, streamlining their integration and interaction with the new context system.

Changes

File Path Change Summary
.../stacks-high-fee-warning/stacks-high-fee-dialog.tsx
.../stacks-high-fee-warning/stacks-high-fee-warning-container.tsx
Introduced a context provider for high fee warnings and refactored HighFeeDialog to utilize this context.
.../stacks-transaction-request/stacks-transaction-signer.tsx
.../stacks-transaction-request/submit-action.tsx
.../transaction-request/transaction-request.tsx
Updated import paths and component usage to align with the new high fee warning system.
.../send/send-crypto-asset-form/.../use-stacks-common-send-form.tsx
.../send/send-crypto-asset-form/.../stx-send-form.tsx
.../send/send-crypto-asset-form/.../use-sip10-send-form.tsx
Adjusted imports and initial state to integrate with the high fee warning context.
.../send/send-crypto-asset-form/send-crypto-asset-form.routes.tsx
.../routes/request-routes.tsx
Wrapped components with StacksHighFeeWarningContainer to ensure consistent high fee warning handling.

🐇💻
CodeRabbit hopped along,
Refactoring code, from dusk till dawn.
With a context twist and a dialog pop,
High fees beware, the warnings won't stop!
🚀🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@kyranjamie
Copy link
Collaborator Author

@coderabbitai review

Copy link

coderabbitai bot commented May 8, 2024

Actions Performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 1

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b5c9c79 and 675bd34.
Files selected for processing (14)
  • src/app/features/stacks-high-fee-warning/stacks-high-fee-dialog.tsx (3 hunks)
  • src/app/features/stacks-high-fee-warning/stacks-high-fee-warning-container.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (5 hunks)
  • src/app/features/stacks-transaction-request/submit-action.tsx (1 hunks)
  • src/app/pages/rpc-sign-stacks-transaction/rpc-sign-stacks-transaction.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/family/stacks/use-stacks-common-send-form.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks-sip10/use-sip10-send-form.tsx (1 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx (5 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stx/stx-send-form.tsx (3 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (2 hunks)
  • src/app/pages/send/send-crypto-asset-form/send-crypto-asset-form.routes.tsx (3 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (4 hunks)
  • src/app/routes/request-routes.tsx (2 hunks)
Files skipped from review due to trivial changes (2)
  • src/app/pages/send/send-crypto-asset-form/form/stacks-sip10/use-sip10-send-form.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx
Additional Context Used
GitHub Check Runs (1)
typecheck failure (4)

src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form.tsx: [failure] 11-11:
Cannot find module '@app/features/high-fee-dialog/high-fee-dialog' or its corresponding type declarations.


src/app/pages/transaction-request/transaction-request.tsx: [failure] 1-1:
'useState' is declared but its value is never read.

Additional comments not posted (17)
src/app/pages/rpc-sign-stacks-transaction/rpc-sign-stacks-transaction.tsx (2)

1-1: Ensure that the imported modules are used appropriately and check for any unnecessary imports.

Verification successful

The verification script executed successfully and did not find any instances where the specified imports were unused in the file rpc-sign-stacks-transaction.tsx. This indicates that all the imports mentioned in the script are indeed utilized within the file, confirming the appropriate use of imported modules.

  • All imports in rpc-sign-stacks-transaction.tsx are confirmed to be used appropriately.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all imported modules in `rpc-sign-stacks-transaction.tsx` are used.

# Test: Search for unused imports. Expect: No output if all imports are used.
rg --type typescript --files-without-match 'StacksHighFeeWarningContainer|StacksTransactionSigner|useRpcSignStacksTransaction|useBreakOnNonCompliantEntity' src/app/pages/rpc-sign-stacks-transaction/rpc-sign-stacks-transaction.tsx

Length of output: 266



Script:

#!/bin/bash
# Description: Verify that all imported modules in `rpc-sign-stacks-transaction.tsx` are used.

# Test: Search for unused imports. Expect: No output if all imports are used.
rg --glob '*.tsx' --files-without-match 'StacksHighFeeWarningContainer|StacksTransactionSigner|useRpcSignStacksTransaction|useBreakOnNonCompliantEntity' src/app/pages/rpc-sign-stacks-transaction/rpc-sign-stacks-transaction.tsx

Length of output: 228


20-29: The usage of StacksHighFeeWarningContainer and StacksTransactionSigner appears to be correctly implemented according to the new context-based management system.

src/app/features/stacks-transaction-request/submit-action.tsx (2)

9-10: The import of useStacksHighFeeWarningContext is correctly placed and used within the component to manage high fee warnings.


21-28: The function onConfirmTransaction correctly uses the high fee context to manage the display of high fee warnings. Ensure that the logic for handling form errors and high fees is thoroughly tested.

src/app/pages/send/send-crypto-asset-form/form/stx/stx-send-form.tsx (2)

13-13: The constant symbol is correctly defined and used within the component. Ensure that it matches the expected type from CryptoCurrencies.


29-29: The autoComplete="off" attribute is correctly used in the AmountField to enhance security by preventing browsers from storing input values.

src/app/features/stacks-high-fee-warning/stacks-high-fee-warning-container.tsx (1)

1-51: The implementation of the StacksHighFeeWarningContext and its provider is robust, providing clear methods for managing the high fee warning state. Ensure that the context is correctly integrated across all components that require access to high fee information.

Verification successful

The useStacksHighFeeWarningContext hook is indeed integrated across multiple components within the application, as evidenced by its presence in various files related to different features and pages. This confirms that the context is being utilized as intended across the application.

  • Files using useStacksHighFeeWarningContext:
    • src/app/features/stacks-high-fee-warning/stacks-high-fee-warning-container.tsx
    • src/app/features/stacks-high-fee-warning/stacks-high-fee-dialog.tsx
    • src/app/features/stacks-transaction-request/submit-action.tsx
    • src/app/pages/send/send-crypto-asset-form/family/stacks/use-stacks-common-send-form.tsx
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of `StacksHighFeeWarningContext` across the application.

# Test: Search for the usage of `useStacksHighFeeWarningContext`. Expect: Multiple files using this context.
rg --type typescript 'useStacksHighFeeWarningContext' --files-with-matches src/

Length of output: 114



Script:

#!/bin/bash
# Description: Verify the integration of `StacksHighFeeWarningContext` across the application.

# Test: Search for the usage of `useStacksHighFeeWarningContext`. Expect: Multiple files using this context.
rg 'useStacksHighFeeWarningContext' --files-with-matches src/

Length of output: 358

src/app/features/stacks-high-fee-warning/stacks-high-fee-dialog.tsx (1)

Line range hint 14-60: The HighFeeDialog component correctly utilizes the high fee warning context for managing dialog visibility and actions. The implementation of the dialog's buttons for editing fees and confirming transactions is appropriate. Ensure that the dialog's behavior is consistent with user expectations and that all edge cases are handled.

src/app/pages/send/send-crypto-asset-form/family/stacks/use-stacks-common-send-form.tsx (1)

Line range hint 15-53: The useStacksCommonSendForm hook correctly integrates the high fee warning context and provides comprehensive form validation logic. Ensure that the initial form values and validation schema are correctly set up and that the hook's functionality is covered by unit tests.

src/app/routes/request-routes.tsx (1)

Line range hint 10-27: The integration of StacksHighFeeWarningContainer in the routing configuration is correctly implemented, ensuring that the high fee warning functionality is available across different routes. Verify that the routes are correctly set up and that there are no accessibility or performance issues.

src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx (1)

25-25: The import and use of useStacksCommonSendForm within useStxSendForm is correctly implemented, ensuring that common functionalities are reused effectively. Verify that the integration works as expected and that there are no issues with data flow or state management.

src/app/pages/send/send-crypto-asset-form/send-crypto-asset-form.routes.tsx (2)

87-94: Integration of StacksHighFeeWarningContainer for STX transactions.

This change aligns with the PR's objective to centralize high fee warning management using a context provider. Ensure that all dependent components are updated to use this new structure.


105-112: Integration of StacksHighFeeWarningContainer for SIP10 token transactions.

This modification is consistent with the PR's goal of improving fee management across different assets. Verify that the SIP10 token send form and other related components are properly utilizing the new context provider.

src/app/pages/transaction-request/transaction-request.tsx (2)

126-126: Addition of HighFeeDialog to the transaction request flow.

This addition is crucial for informing users about high fees, which enhances transparency and user decision-making. Ensure that the learnMoreUrl is correctly set and accessible.


124-124: Addition of StacksTxSubmitAction to handle transaction submissions.

Integrating StacksTxSubmitAction helps centralize the transaction submission logic, which is a positive change for maintainability and consistency. Confirm that this component interacts correctly with the form's state and handles submissions appropriately.

src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx (2)

133-133: Addition of HighFeeDialog to the Stacks transaction signer.

This is a beneficial addition for user awareness regarding high transaction fees. Ensure that the learnMoreUrl is properly set to provide users with additional information on high fees.


132-132: Addition of StacksTxSubmitAction in the Stacks transaction signer.

This change centralizes the submission logic within the Stacks transaction signer, which is a good practice for reducing redundancy and improving code clarity. Verify that this component is properly integrated and interacts correctly with the transaction signing flow.

@kyranjamie kyranjamie force-pushed the fix/stx-send-form-high-fee branch 3 times, most recently from effefd5 to 9e64286 Compare May 10, 2024 11:54
@kyranjamie kyranjamie linked an issue May 13, 2024 that may be closed by this pull request
@314159265359879
Copy link
Contributor

warning looks good, I can transmit the transaction again with this fix.
image
The link here points an unavailable page.

I noticed these only cover bitcoin transaction fees
https://leather.io/guides/increase-fee
https://leather.io/guides/configure-transaction-fees

Want to link this older guide for now?
https://leather.gitbook.io/guides/transactions/fees

@314159265359879
Copy link
Contributor

Related, users have shown interest in also seeing similar warning when increasing fees (typos have been made, leading to some unintended excessive fees) #4800

Probably out of scope for this.

@fbwoolf
Copy link
Contributor

fbwoolf commented May 22, 2024

@kyranjamie should I rebase this and take it over to see if helps the fee loading issue? Our fee row seems really broken atm.

@markmhendrickson
Copy link
Collaborator

Needs test

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.

Broken Stacks high fee warning
5 participants