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

feat: remove increase fee summary dialog, closes #5305 #5377

Merged
merged 1 commit into from
May 20, 2024

Conversation

alter-eggo
Copy link
Contributor

@alter-eggo alter-eggo commented May 16, 2024

Try out Leather build 1abf358Extension build, Test report, Storybook, Chromatic

This pr removes increase fee summary step, and just shows toast on broadcasting RBF transaction both in btc and all stacks related send flows. discussed here

Summary by CodeRabbit

  • New Features

    • Enhanced transaction submission with tailored toast messages based on transaction type.
    • Success toast messages added for Bitcoin fee increase transactions and swap transactions.
  • Improvements

    • Updated transaction dialogs to reflect broadcasting status dynamically.
    • Simplified transaction handling by consolidating parameters into objects.
  • Bug Fixes

    • Fixed navigation issues post Bitcoin fee increase transactions, ensuring users are directed to the activity route.
  • Removals

    • Removed the IncreaseFeeSent route and associated dialog, streamlining the transaction process.

Copy link

coderabbitai bot commented May 16, 2024

Walkthrough

This update enhances the transaction submission process by adding new parameters and success messages. Key changes include the introduction of an isIncreaseFeeTransaction parameter to differentiate between normal and fee increase transactions, updating toast messages, and modifying navigation routes. Additionally, the IncreaseFeeSent route has been removed, and related components have been adjusted accordingly.

Changes

Files/Paths Change Summaries
src/.../use-submit-stx-transaction.ts Added isIncreaseFeeTransaction parameter to useSubmitTransactionCallback and updated toast messages accordingly.
src/.../increase-fee-actions.tsx Added disabled prop to IncreaseFeeActions component.
src/.../use-btc-increase-fee.ts Updated behavior to show success toast and navigate to activity route after fee increase.
src/.../increase-btc-fee-dialog.tsx Set isDisabled property to isBroadcasting in IncreaseFeeActions component.
src/.../increase-stx-fee-dialog.tsx Modified useStacksBroadcastTransaction call to include { token: 'STX', isIncreaseFeeTransaction: true }.
src/.../use-stacks-broadcast-transaction.tsx Added isIncreaseFeeTransaction argument to handle transactions and navigation.
src/.../stacks-send-form-confirmation.tsx Updated useStacksBroadcastTransaction call to pass an object with token and decimals properties.
src/.../use-stacks-broadcast-swap.tsx Added success toast message "Transaction submitted!" to onSuccess callback.
src/.../transaction-request.tsx Modified useStacksBroadcastTransaction call to pass an object with token set to 'STX'.
src/.../app-routes.tsx Removed IncreaseFeeSentDialog component import and route.
src/shared/route-urls.ts Removed IncreaseFeeSent route from RouteUrls enum.

In the realm of code, where transactions flow,
A rabbit hops with joy, updates in tow.
Fees increase with ease, messages toast,
To the activity route, we now coast.
With routes refined, and dialogs clear,
The code runs smoother, let’s cheer!
🐇✨


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.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9f73b24 and f845cef.
Files selected for processing (10)
  • src/app/common/hooks/use-submit-stx-transaction.ts (3 hunks)
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (1 hunks)
  • src/app/routes/app-routes.tsx (2 hunks)
  • src/shared/route-urls.ts (1 hunks)
Files skipped from review due to trivial changes (5)
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx
  • src/app/routes/app-routes.tsx
  • src/shared/route-urls.ts
Additional comments not posted (13)
src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx (2)

Line range hint 14-14: LGTM! The function correctly retrieves state values.


28-31: LGTM! The integration of useStacksBroadcastTransaction with the new parameter is correct.

src/app/common/hooks/use-submit-stx-transaction.ts (4)

22-22: LGTM! The new isIncreaseFeeTransaction parameter is correctly added to the interface.


29-32: LGTM! The function signature is correctly updated to include the new parameter.


60-64: LGTM! The toast messages are correctly updated based on the new parameter.


86-86: LGTM! The new parameter is correctly included in the dependency array.

src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (5)

26-30: LGTM! The new isIncreaseFeeTransaction parameter is correctly added to the interface.


32-36: LGTM! The function signature is correctly updated to include the new parameter.


47-47: LGTM! The new parameter is correctly passed to the useSubmitTransactionCallback hook.


63-66: LGTM! The navigation logic correctly handles the new parameter.


136-136: LGTM! The new parameter is correctly included in the dependency array.

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

53-53: LGTM! The integration of useStacksBroadcastTransaction with the new parameter is correct.

src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (1)

48-51: LGTM! The added parameters token: 'STX' and isIncreaseFeeTransaction: true are consistent with the PR objectives.

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between f845cef and 67058a1.
Files selected for processing (10)
  • src/app/common/hooks/use-submit-stx-transaction.ts (3 hunks)
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (1 hunks)
  • src/app/routes/app-routes.tsx (2 hunks)
  • src/shared/route-urls.ts (1 hunks)
Files skipped from review as they are similar to previous changes (10)
  • src/app/common/hooks/use-submit-stx-transaction.ts
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx
  • src/app/pages/transaction-request/transaction-request.tsx
  • src/app/routes/app-routes.tsx
  • src/shared/route-urls.ts

@@ -53,7 +57,11 @@ export function useSubmitTransactionCallback({ loadingKey }: UseSubmitTransactio
txId: safelyFormatHexTxid(response.txid),
});
await delay(500);
toast.success('Transaction submitted!');
const toastMessage = isIncreaseFeeTransaction
Copy link
Contributor

Choose a reason for hiding this comment

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

We could define this as a function outside the hook?

Copy link
Collaborator

Choose a reason for hiding this comment

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

and pass in as callback 👍🏼

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe better to put in onSuccess callback, that was good idea

export function useSubmitTransactionCallback({ loadingKey }: UseSubmitTransactionArgs) {
export function useSubmitTransactionCallback({
loadingKey,
isIncreaseFeeTransaction,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not big on this API decision here. What if we want to show another toast for a contract call transaction? Do we add isContractCallTransaction:boolean as well?

By adding a callback, or a custom toast message, we don't couple useSubmitTransactionCallback to a specific use case of it.

IMO the toast should be outside this function and called within the onSuccess() handler. Or at least, isSuccessfulToastMessage param.

@markmhendrickson
Copy link
Collaborator

markmhendrickson commented May 17, 2024

@alter-eggo mind attaching a screen recording of the new UX to this PR as part of the description? 🙏 Ideally for all flows affected (e.g. BTC and STX sends)

@markmhendrickson
Copy link
Collaborator

Also, do have an issue to link to this PR?

onCancel(): void;
}
export function IncreaseFeeActions(props: IncreaseFeeActionsProps) {
const { onCancel, isDisabled } = props;
const { onCancel, isDisabled, isBroadcasting } = props;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to avoid further bigger senseless refactoring, just have put it here. this component would be removed in scope of Approval UX

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

Out of diff range and nitpick comments (2)
src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (1)

26-30: Ensure the new interface UseStacksBroadcastTransactionArgs is well-documented.

Adding comments to explain each property, especially isIncreaseFeeTransaction, would improve code maintainability and clarity.

src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx (1)

Line range hint 17-17: Remove unused import to clean up the code.

- import { LoadingSpinner } from '@app/components/loading-spinner';

The LoadingSpinner is imported but not used in the component. Removing unused imports can help reduce confusion and maintain cleaner code.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 67058a1 and e72473f.
Files selected for processing (11)
  • src/app/common/hooks/use-submit-stx-transaction.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx (2 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx (2 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (5 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx (1 hunks)
  • src/app/pages/swap/hooks/use-stacks-broadcast-swap.tsx (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (1 hunks)
  • src/app/routes/app-routes.tsx (2 hunks)
  • src/shared/route-urls.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/app/pages/swap/hooks/use-stacks-broadcast-swap.tsx
Files skipped from review as they are similar to previous changes (8)
  • src/app/common/hooks/use-submit-stx-transaction.ts
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx
  • src/app/pages/transaction-request/transaction-request.tsx
  • src/app/routes/app-routes.tsx
  • src/shared/route-urls.ts
Additional Context Used
GitHub Check Runs (2)
typecheck failure (3)

src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx: [failure] 17-17:
'LoadingSpinner' is declared but its value is never read.

lint-eslint failure (13)

src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx: [failure] 133-133:
React Hook useMemo has a missing dependency: 'showToast'. Either include it or remove the dependency array

Additional comments not posted (3)
src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (2)

49-55: The showToast function is well-implemented to handle different toast messages based on the transaction type.


70-73: The navigation logic after a fee increase transaction is clear and concise.

src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx (1)

75-79: The IncreaseFeeActions component is correctly updated to handle the broadcasting state.

@@ -79,6 +102,7 @@
},
onSuccess(txId) {
handlePreviewSuccess(signedTx, txId);
showToast();
Copy link

Choose a reason for hiding this comment

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

The showToast function is called here but is not included in the dependency array of useMemo.

-  }, [isBroadcasting, requestToken, tabId, navigate, token, formSentSummaryTxState, decimals, toast, broadcastTransactionFn, signStacksTransaction, isIncreaseFeeTransaction]);
+  }, [isBroadcasting, requestToken, tabId, navigate, token, formSentSummaryTxState, decimals, toast, broadcastTransactionFn, signStacksTransaction, isIncreaseFeeTransaction, showToast]);

Including showToast in the dependency array ensures that the memoized value updates correctly when showToast changes.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
showToast();
}, [isBroadcasting, requestToken, tabId, navigate, token, formSentSummaryTxState, decimals, toast, broadcastTransactionFn, signStacksTransaction, isIncreaseFeeTransaction, showToast]);

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

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between e72473f and 1abf358.
Files selected for processing (11)
  • src/app/common/hooks/use-submit-stx-transaction.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx (2 hunks)
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts (1 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx (3 hunks)
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (4 hunks)
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx (1 hunks)
  • src/app/pages/swap/hooks/use-stacks-broadcast-swap.tsx (1 hunks)
  • src/app/pages/transaction-request/transaction-request.tsx (1 hunks)
  • src/app/routes/app-routes.tsx (2 hunks)
  • src/shared/route-urls.ts (1 hunks)
Files skipped from review as they are similar to previous changes (11)
  • src/app/common/hooks/use-submit-stx-transaction.ts
  • src/app/features/dialogs/increase-fee-dialog/components/increase-fee-actions.tsx
  • src/app/features/dialogs/increase-fee-dialog/hooks/use-btc-increase-fee.ts
  • src/app/features/dialogs/increase-fee-dialog/increase-btc-fee-dialog.tsx
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx
  • src/app/pages/swap/hooks/use-stacks-broadcast-swap.tsx
  • src/app/pages/transaction-request/transaction-request.tsx
  • src/app/routes/app-routes.tsx
  • src/shared/route-urls.ts

@alter-eggo alter-eggo added this pull request to the merge queue May 20, 2024
Merged via the queue into dev with commit 2db97bd May 20, 2024
28 checks passed
@alter-eggo alter-eggo deleted the fix/increase-fee branch May 20, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants