extension icon indicating copy to clipboard operation
extension copied to clipboard

fix: send send form high fee dialog

Open kyranjamie opened this issue 9 months ago • 5 comments

Try out Leather build acfa71a — Extension 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.

kyranjamie avatar May 07 '24 17:05 kyranjamie

Walkthrough

The changes mainly focus on refactoring the handling of high fee warnings across various components in the app. A new context and container (StacksHighFeeWarningContainer) have been introduced to manage high fee warnings uniformly. The HighFeeDialog component has been updated to be more context-driven. Import paths and component structures have been adjusted accordingly. The overall goal is to consolidate and simplify high fee warning logic.

Changes

File Change Summary
src/app/features/stacks-high-fee-warning/stacks-high-fee-dialog.tsx Refactored HighFeeDialog component, updated imports, and modified button functionalities
src/app/features/stacks-high-fee-warning/stacks-high-fee-warning-container.tsx Introduced context and provider for high fee warning dialog management
src/app/features/stacks-transaction-request/stacks-transaction-signer.tsx Updated imports and refactored component structure
src/app/features/stacks-transaction-request/submit-action.tsx Refactored SubmitAction into StacksTxSubmitAction and updated high fee handling logic
src/app/pages/rpc-sign-stacks-transaction/rpc-sign-stacks-transaction.tsx Wrapped StacksTransactionSigner with StacksHighFeeWarningContainer
src/app/pages/send/send-crypto-asset-form/family/stacks/use-stacks-common-send-form.tsx Updated high fee warning logic and context usage
src/app/pages/send/send-crypto-asset-form/form/btc/btc-send-form.tsx Removed HighFeeDialog functionality from Bitcoin send form
src/app/pages/send/send-crypto-asset-form/form/sip10/use-sip10-send-form.tsx Adjusted import path for useStacksCommonSendForm
src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-common-send-form.tsx Simplified fee comparison logic and updated HighFeeDialog import path
src/app/pages/send/send-crypto-asset-form/form/stx/stx-send-form.tsx Modified type declaration for symbol and updated useStxSendForm logic
src/app/pages/send/send-crypto-asset-form/form/stx/use-stx-send-form.tsx Updated import path and removed fee from return object
src/app/pages/send/send-crypto-asset-form/send-crypto-asset-form.routes.tsx Wrapped relevant forms with StacksHighFeeWarningContainer
src/app/pages/transaction-request/transaction-request.tsx Replaced SubmitAction with StacksTxSubmitAction and updated HighFeeDialog import path
src/app/routes/request-routes.tsx Wrapped TransactionRequest with StacksHighFeeWarningContainer

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant StacksHighFeeWarningContainer
    participant StacksTransactionSigner
    participant HighFeeDialog

    User ->> UI: Initiates transaction
    UI ->> StacksHighFeeWarningContainer: Wrap transaction component
    StacksHighFeeWarningContainer ->> StacksTransactionSigner: Render transaction signer
    StacksTransactionSigner ->> StacksHighFeeWarningContainer: Check fee
    StacksHighFeeWarningContainer ->> HighFeeDialog: Show high fee warning
    User ->> HighFeeDialog: Interact with high fee warning
    HighFeeDialog ->> StacksHighFeeWarningContainer: Handle user response
    StacksHighFeeWarningContainer ->> StacksTransactionSigner: Proceed based on user response

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.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.

coderabbitai[bot] avatar May 08 '24 14:05 coderabbitai[bot]

@coderabbitai review

kyranjamie avatar May 08 '24 14:05 kyranjamie

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.

coderabbitai[bot] avatar May 08 '24 14:05 coderabbitai[bot]

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 avatar May 15 '24 09:05 314159265359879

Related, users have shown interest in also seeing similar warning when increasing fees (typos have been made, leading to some unintended excessive fees) https://github.com/leather-wallet/extension/issues/4800

Probably out of scope for this.

314159265359879 avatar May 15 '24 09:05 314159265359879

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

fbwoolf avatar May 22 '24 00:05 fbwoolf

Needs test

markmhendrickson avatar Jun 03 '24 15:06 markmhendrickson

rebased and added integration test for showing high fee warning link fixed here https://github.com/leather-wallet/mono/pull/218

alter-eggo avatar Jun 13 '24 13:06 alter-eggo

Can't approve as it's my PR

kyranjamie avatar Jun 17 '24 10:06 kyranjamie