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: cancel stacks pending transaction #5501

Closed

Conversation

Aman-zishan
Copy link
Contributor

@Aman-zishan Aman-zishan commented Jun 7, 2024

Screenshot 2024-06-07 at 11 16 04 AM
  • Attempts to cancel a transaction by crafting a new Tx that sends 1µSTX to burn address with a increase of 1µSTX to the previous fee.

  • Notifies the user once the transaction is fired

  • test case video (sending max to an address and trying to cancel that trasaction)

Screen.Recording.2024-06-07.at.11.02.00.AM.mov

https://explorer.hiro.so/txid/0x454c0b34dcaefd619766472652309dce44b95ad1b7795f3b9763d7403c28c2f1?chain=testnet

Summary by CodeRabbit

  • New Features

    • Introduced a new CancelTransactionButton component for canceling transactions.
    • Added CancelStxTransactionDialog for managing Stacks transaction cancellations.
    • Implemented CancelTransactionActions component with cancel and submit buttons.
  • Enhancements

    • Updated IncreaseFeeButton to conditionally render based on the isActive state.
    • Added a new route for CancelStxTransaction.
  • Refactor

    • Renamed rightElement prop to actionButtonGroupElement in various components for better clarity.
  • Bug Fixes

    • Improved transaction cancellation logic and user feedback messages.

Copy link

coderabbitai bot commented Jun 7, 2024

Walkthrough

The recent changes introduce a new feature for canceling Stacks transactions, including UI components, hooks, and routes. Enhancements include a new CancelTransactionButton, conditional rendering in IncreaseFeeButton, and updates to transaction item components to support action buttons. Additionally, a new utility function getBurnAddress and an enum value CANCEL_TRANSACTION_DRAWER were added. The routing and dialogs were updated to handle transaction cancellation, with modifications to support success messaging and transaction state management.

Changes

File(s) Change Summary
src/app/common/hooks/use-loading.ts Added CANCEL_TRANSACTION_DRAWER to LoadingKeys enum.
src/app/common/utils/get-burn-address.ts Introduced getBurnAddress function to return a burn address based on the provided Stacks network.
src/app/components/bitcoin-transaction-item/bitcoin-transaction-item.tsx Renamed rightElement prop to actionButtonGroupElement in BitcoinTransactionItem component.
src/app/components/stacks-transaction-item/cancel-transaction-button.tsx Added new CancelTransactionButton component for canceling transactions.
src/app/components/stacks-transaction-item/increase-fee-button.tsx Updated IncreaseFeeButton component to conditionally render based on isActive state.
src/app/components/stacks-transaction-item/stacks-transaction-item.tsx Integrated CancelTransactionButton and updated layout to include cancel functionality alongside IncreaseFeeButton.
src/app/components/transaction-item/transaction-item.layout.tsx Renamed rightElement prop to actionButtonGroupElement and updated layout to include a VStack for rendering it.
src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx Added CancelStxTransactionDialog component for managing the cancellation of Stacks transactions, including various hooks and components for transaction details and cancellation.
src/app/features/dialogs/cancel-transaction-dialog/components/cancel-transaction-actions.tsx Introduced CancelTransactionActions component for handling cancel and submit actions.
src/app/features/dialogs/cancel-transaction-dialog/hooks/use-selected-tx.ts Added useSelectedTx hook to fetch transaction data based on raw transaction ID.
src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts Introduced useStxCancelTransaction hook for handling the cancellation of Stacks transactions, generating unsigned transactions, and broadcasting them.
src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx Updated useStacksBroadcastTransaction to accept and handle isCancelTransaction parameter for displaying success messages based on transaction type.
src/app/routes/app-routes.tsx Added route for CancelStxTransaction utilizing CancelStxTransactionDialog.
src/shared/route-urls.ts Added CancelStxTransaction to RouteUrls enum.

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.

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

Outside diff range and nitpick comments (4)
src/app/components/stacks-transaction-item/cancel-transaction-button.tsx (1)

19-21: Consider adding a comment explaining why e.stopPropagation() is used here, to help future maintainers understand its purpose.

src/app/components/transaction-item/transaction-item.layout.tsx (1)

Line range hint 22-50: Consider using destructuring for props in the function signature to improve readability.

- export function TransactionItemLayout({
+ export function TransactionItemLayout({ actionButtonGroupElement, txCaption, txIcon, txStatus, txTitle, txValue, ...props }: TransactionItemLayoutProps) {
src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts (1)

25-89: Consider adding detailed comments explaining the transaction crafting and broadcasting process within the useStxCancelTransaction hook to aid future maintainers.

src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx (1)

63-63: Add a user-friendly message or UI element when waiting for transaction details.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3ef09f1 and e44e80c.

Files selected for processing (14)
  • src/app/common/hooks/use-loading.ts (1 hunks)
  • src/app/common/utils/get-burn-address.ts (1 hunks)
  • src/app/components/bitcoin-transaction-item/bitcoin-transaction-item.tsx (1 hunks)
  • src/app/components/stacks-transaction-item/cancel-transaction-button.tsx (1 hunks)
  • src/app/components/stacks-transaction-item/increase-fee-button.tsx (1 hunks)
  • src/app/components/stacks-transaction-item/stacks-transaction-item.tsx (4 hunks)
  • src/app/components/transaction-item/transaction-item.layout.tsx (3 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx (1 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/components/cancel-transaction-actions.tsx (1 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-selected-tx.ts (1 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (4 hunks)
  • src/app/routes/app-routes.tsx (2 hunks)
  • src/shared/route-urls.ts (1 hunks)
Additional comments not posted (16)
src/app/features/dialogs/cancel-transaction-dialog/hooks/use-selected-tx.ts (1)

4-7: LGTM! The hook useSelectedTx is well-implemented and correctly utilizes existing hooks to fetch transaction data.

src/app/common/utils/get-burn-address.ts (1)

4-12: LGTM! The function getBurnAddress is well-implemented. Consider adding a comment for the default case to clarify that it returns the testnet address as a fallback.

src/app/common/hooks/use-loading.ts (1)

5-5: LGTM! The addition of CANCEL_TRANSACTION_DRAWER to the LoadingKeys enum is correctly implemented.

src/app/components/stacks-transaction-item/increase-fee-button.tsx (1)

15-37: LGTM! The update to conditionally render the IncreaseFeeButton based on the isActive state is well-implemented. Ensure that the use of e.stopPropagation() in the onClick handler is intentional and necessary to prevent event bubbling.

src/app/components/stacks-transaction-item/cancel-transaction-button.tsx (1)

8-37: The implementation of CancelTransactionButton looks solid and follows best practices for conditional rendering and event handling.

src/app/features/dialogs/cancel-transaction-dialog/components/cancel-transaction-actions.tsx (1)

12-39: The CancelTransactionActions component is well-implemented with proper use of hooks and accessibility attributes.

src/app/components/transaction-item/transaction-item.layout.tsx (1)

Line range hint 22-50: The updates to TransactionItemLayout are well-executed, enhancing the component's flexibility and maintainability.

src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts (1)

25-89: The useStxCancelTransaction hook is robust, correctly managing dependencies and state with comprehensive error handling and validation.

src/app/components/bitcoin-transaction-item/bitcoin-transaction-item.tsx (1)

89-89: Renaming rightElement to actionButtonGroupElement improves clarity. Ensure all references to the old prop name are updated across the project.

Verification successful

Renaming rightElement to actionButtonGroupElement improves clarity. Ensure all references to the old prop name are updated across the project.

The search for rightElement in .tsx and .ts files returned no results, indicating that all instances have been updated.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all instances of `rightElement` have been updated to `actionButtonGroupElement`.

# Test: Search for the old prop name. Expect: No occurrences.
rg --type typescript $'rightElement'

Length of output: 70



Script:

#!/bin/bash
# Description: Verify that all instances of `rightElement` have been updated to `actionButtonGroupElement`.

# Test: Search for the old prop name in .tsx and .ts files. Expect: No occurrences.
rg 'rightElement' --glob '**/*.tsx' --glob '**/*.ts'

Length of output: 52

src/shared/route-urls.ts (1)

30-30: Addition of CancelStxTransaction route aligns with the new feature. Verify that this route is correctly handled in the routing logic.

Verification successful

The new route CancelStxTransaction is correctly handled in the routing logic and other relevant parts of the codebase.

  • src/app/routes/app-routes.tsx: The route is imported and used in the routing logic.
  • src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx: The route is used in the dialog component.
  • src/app/components/stacks-transaction-item/stacks-transaction-item.tsx: The route is used in multiple places within this component.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new route is correctly handled in the routing logic.

# Test: Search for the new route in the routing logic. Expect: At least one occurrence.
rg --type typescript $'CancelStxTransaction'

Length of output: 78



Script:

#!/bin/bash
# Description: Verify that the new route is correctly handled in the routing logic.

# Test: Search for the new route in the routing logic. Expect: At least one occurrence.
rg --type ts 'CancelStxTransaction'

Length of output: 1457

src/app/components/stacks-transaction-item/stacks-transaction-item.tsx (1)

24-24: Introduction of CancelTransactionButton and related logic for handling transaction cancellation. Ensure that the new components and methods are correctly implemented and tested.

Also applies to: 70-84, 97-120

Verification successful

The verification confirms that the CancelTransactionButton component and the onCancelTransaction method are correctly implemented and referenced in the codebase.

  • CancelTransactionButton is imported and used in src/app/components/stacks-transaction-item/stacks-transaction-item.tsx and defined in src/app/components/stacks-transaction-item/cancel-transaction-button.tsx.
  • onCancelTransaction is defined and used in src/app/components/stacks-transaction-item/stacks-transaction-item.tsx and referenced in src/app/components/stacks-transaction-item/cancel-transaction-button.tsx.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new components and methods for handling transaction cancellation are correctly implemented and tested.

# Test: Search for the new components and methods in the codebase. Expect: At least one occurrence of each.
rg --type typescript $'CancelTransactionButton'
rg --type typescript $'onCancelTransaction'

Length of output: 159



Script:

#!/bin/bash
# Description: Verify that the new components and methods for handling transaction cancellation are correctly implemented and tested.

# Test: Search for the new components and methods in the codebase. Expect: At least one occurrence of each.
rg --glob '*.ts' --glob '*.tsx' 'CancelTransactionButton'
rg --glob '*.ts' --glob '*.tsx' 'onCancelTransaction'

Length of output: 1198

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

30-30: Update to useStacksBroadcastTransaction hook to handle transaction cancellation. Ensure that the updated hook is correctly implemented and tested.

Also applies to: 37-37, 64-104, 144-144

Verification successful

The useStacksBroadcastTransaction hook is correctly implemented and used in multiple files across the codebase. Here are the locations where it is imported and utilized:

  • src/app/pages/transaction-request/transaction-request.tsx
  • src/app/pages/send/send-crypto-asset-form/form/stacks/stacks-send-form-confirmation.tsx
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts
  • src/app/features/dialogs/increase-fee-dialog/increase-stx-fee-dialog.tsx

This confirms that the hook is integrated and used in various parts of the application.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the updated hook for handling transaction cancellation is correctly implemented and tested.

# Test: Search for the updated hook in the codebase. Expect: At least one occurrence.
rg --type typescript $'useStacksBroadcastTransaction'

Length of output: 87



Script:

#!/bin/bash
# Description: Verify that the updated hook for handling transaction cancellation is correctly implemented and tested.

# Test: Search for the updated hook in the codebase. Expect: At least one occurrence.
rg 'useStacksBroadcastTransaction' --glob '*.ts' --glob '*.tsx'

Length of output: 1651

src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx (3)

26-134: The implementation of CancelStxTransactionDialog appears robust and well-structured.


47-52: Ensure proper handling of transaction statuses other than 'pending'.


70-133: Review the form validation logic to ensure it aligns with the expected transaction cancellation requirements.

Verification successful

The search results indicate that the validationSchema for the CancelStxTransactionDialog component is defined in the useStxCancelTransaction hook. The relevant snippet is:

src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts:
  validationSchema: yup.object({ fee: stxFeeValidator(availableUnlockedBalance) }),

This schema validates the fee field using the stxFeeValidator function, which likely ensures that the fee is appropriate based on the available unlocked balance.

Locations in the codebase:

  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts

Conclusion:

The form validation logic for transaction cancellation appears to be in place and aligns with the expected requirements by validating the fee against the available unlocked balance.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the form validation logic for transaction cancellation.

# Test: Search for form validation related to transaction cancellation. Expect: Comprehensive validation rules.
rg --type typescript $'validationSchema' --context 10

Length of output: 87



Script:

#!/bin/bash
# Description: Verify the form validation logic for transaction cancellation.

# Test: Search for form validation related to transaction cancellation. Expect: Comprehensive validation rules.
rg --type ts,tsx 'validationSchema' --context 10

Length of output: 79



Script:

#!/bin/bash
# Description: Verify the form validation logic for transaction cancellation.

# Test: Search for form validation related to transaction cancellation. Expect: Comprehensive validation rules.
rg --type ts 'validationSchema' --context 10
rg --type tsx 'validationSchema' --context 10

Length of output: 77600

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

104-106: The new route for CancelStxTransactionDialog is correctly set up.

Comment on lines +54 to +61
useEffect(() => {
if (!rawTxId && txIdFromParams) {
setRawTxId(txIdFromParams);
}
if (isLoading && !rawTxId) {
setIsIdle();
}
}, [isLoading, rawTxId, setIsIdle, setRawTxId, txIdFromParams]);
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search results indicate that txIdFromParams is being retrieved from the URL search parameters using searchParams.get('txId'), but there is no evidence of validation logic for txIdFromParams in the provided context.

  • File: src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx
  • Lines:
    • const txIdFromParams = searchParams.get('txId');
    • if (!rawTxId && txIdFromParams) { setRawTxId(txIdFromParams); }

There is no validation to check if txIdFromParams is valid before it is used.

Analysis chain

Consider adding error handling for cases where txIdFromParams is invalid.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the validation of `txIdFromParams`.

# Test: Search for validation logic for `txIdFromParams`. Expect: Proper validation checks.
rg --type typescript $'txIdFromParams' --context 5

Length of output: 84



Script:

#!/bin/bash
# Description: Verify the validation of `txIdFromParams`.

# Test: Search for validation logic for `txIdFromParams`. Expect: Proper validation checks.
rg --type ts 'txIdFromParams' --context 5

Length of output: 6346

@Aman-zishan Aman-zishan force-pushed the feat/cancel-pending-transaction branch from e44e80c to 7f46856 Compare June 7, 2024 05:58
@Aman-zishan Aman-zishan changed the title Feat/cancel pending transaction feat: cancel stacks pending transaction Jun 7, 2024
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 e44e80c and 7f46856.

Files selected for processing (14)
  • src/app/common/hooks/use-loading.ts (1 hunks)
  • src/app/common/utils/get-burn-address.ts (1 hunks)
  • src/app/components/bitcoin-transaction-item/bitcoin-transaction-item.tsx (1 hunks)
  • src/app/components/stacks-transaction-item/cancel-transaction-button.tsx (1 hunks)
  • src/app/components/stacks-transaction-item/increase-fee-button.tsx (1 hunks)
  • src/app/components/stacks-transaction-item/stacks-transaction-item.tsx (4 hunks)
  • src/app/components/transaction-item/transaction-item.layout.tsx (3 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx (1 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/components/cancel-transaction-actions.tsx (1 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-selected-tx.ts (1 hunks)
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts (1 hunks)
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx (4 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 (14)
  • src/app/common/hooks/use-loading.ts
  • src/app/common/utils/get-burn-address.ts
  • src/app/components/bitcoin-transaction-item/bitcoin-transaction-item.tsx
  • src/app/components/stacks-transaction-item/cancel-transaction-button.tsx
  • src/app/components/stacks-transaction-item/increase-fee-button.tsx
  • src/app/components/stacks-transaction-item/stacks-transaction-item.tsx
  • src/app/components/transaction-item/transaction-item.layout.tsx
  • src/app/features/dialogs/cancel-transaction-dialog/cancel-stx-transaction-dialog.tsx
  • src/app/features/dialogs/cancel-transaction-dialog/components/cancel-transaction-actions.tsx
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-selected-tx.ts
  • src/app/features/dialogs/cancel-transaction-dialog/hooks/use-stx-cancel-transaction.ts
  • src/app/features/stacks-transaction-request/hooks/use-stacks-broadcast-transaction.tsx
  • src/app/routes/app-routes.tsx
  • src/shared/route-urls.ts

@314159265359879
Copy link
Contributor

314159265359879 commented Jun 7, 2024

Without a dev build, it is hard for me to test this. I assume it didn't build due to the failing tests.
ah video is working now. n.v.m the previous comment about that.

I think the "cancel transaction" text on the button could be shorter. Just "Cancel" is enough. That may leave enough room for a small symbol infront of it 🚫, 🛑 ? or simply an "x" in the same color as the >> in front of "increase fee" to match?

@Aman-zishan
Copy link
Contributor Author

Aman-zishan commented Jun 7, 2024

Without a dev build, it is hard for me to test this. I assume it didn't build due to the failing tests. ah video is working now. n.v.m the previous comment about that.

Yeah the workflows are pending and i think approval is required for build process. Is there any way i can help? i can upload the build and share a link

I think the "cancel transaction" text on the button could be shorter. Just "Cancel" is enough. That may leave enough room for a small symbol infront of it 🚫, 🛑 ? or simply an "x" in the same color as the >> in front of "increase fee" to match?

I tried adding an icon but reverted it cause the longer text was resizing the icon, but making it "cancel" with an icon makes sense. I can try that and post a image here later and if it looks good i will commit the changes.

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @Aman-zishan—we'll try and review & QA this as soon as possible

Comment on lines +76 to +83
whenWallet({
ledger: () =>
whenPageMode({
full: () => navigate(RouteUrls.CancelStxTransaction),
popup: () => openIndexPageInNewTab(RouteUrls.CancelStxTransaction, urlSearchParams),
})(),
software: () => navigate(RouteUrls.CancelStxTransaction),
})();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can always just navigate? Not sure we need to handle ledger/software differently here.

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 think we can always just navigate? Not sure we need to handle ledger/software differently here.

I coped this from increase fee logic not sure why it was in that way since increase fee was working fine i thought it's better to rely on already established code

Copy link
Contributor

@alter-eggo alter-eggo left a comment

Choose a reason for hiding this comment

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

thanks for the contribution @Aman-zishan!
will test it a little bit later

amount: 1,
memo: '_cancel transaction',
network: network,
} as any,
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to avoid any here and above?

Copy link
Contributor Author

@Aman-zishan Aman-zishan Jun 7, 2024

Choose a reason for hiding this comment

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

is it possible to avoid any here and above?

I didnt look much into type casting as i found this in the codebase and actually copied the options from here and did not want to cause any breaking changes
Screenshot 2024-06-07 at 8 35 11 PM

Comment on lines +13 to +35
isActive && (
<styled.button
_hover={{ color: 'ink.text-subdued' }}
bg="ink.background-primary"
maxWidth="125px"
ml="auto"
onClick={e => {
onCancelTransaction();
e.stopPropagation();
}}
pointerEvents={!isActive ? 'none' : 'all'}
position="relative"
px="space.02"
py="space.01"
rounded="xs"
zIndex={999}
>
<HStack gap="space.01">
<styled.span textStyle="label.03" color="yellow.action-primary-default">
Cancel transaction
</styled.span>
</HStack>
</styled.button>
Copy link
Contributor

Choose a reason for hiding this comment

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

code here is pretty much similar to increase fee btn, can we create component to avoid code duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code here is pretty much similar to increase fee btn, can we create component to avoid code duplication?

Yes that makes sense, i can work on it

@Aman-zishan
Copy link
Contributor Author

@kyranjamie Thanks for the review comments. I'm starting to address them. Is QA still pending? If so, I can continue working on the feedback alongside QA to streamline the process. Let me know if that works or if you'd prefer I wait until QA is complete.

export function useStxCancelTransaction() {
const [rawTxId, setRawTxId] = useRawTxIdState();
const tx = useSelectedTx();
const [, setTxId] = useRawTxIdState();
Copy link
Contributor

Choose a reason for hiding this comment

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

Made a comment on the duplicated PR, but this code can't just be copied from the increase fee dialog. I have refactored it here bc there is code duplication causing bugs. See changes here: #5500

useRawTxIdState is an old atom being deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fbwoolf in that case i will wait for #5500 and remove redundancy

Copy link
Contributor

@fbwoolf fbwoolf left a comment

Choose a reason for hiding this comment

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

This will need to get rebased after #5500 is merged.

@Aman-zishan
Copy link
Contributor Author

closing in favour of #5533

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.

5 participants