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: Only allow a transaction item to be clicked when it is a successful transaction #2945

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

rumzledz
Copy link
Contributor

@rumzledz rumzledz commented Aug 13, 2024

Description

We will now only allow transactions to be clicked if they are Successful and if their transaction hash has been processed.

disable pending click

Testing

  1. Bring up the Action Form
  2. Set the Action type to Transfer funds
  3. Transfer 0.01 CREDS
  4. As soon as the Pending button comes up, click it
  5. The UserHub should come up and and you should automatically land on the Transactions tab
  6. Click your Transaction while it's in a Pending state
  7. Verify that you are not able to
  8. Verify that the click is successful only when the Transaction exits the Pending state

Resolves #2738

@rumzledz rumzledz self-assigned this Aug 13, 2024
@rumzledz rumzledz marked this pull request as ready for review August 13, 2024 17:52
@rumzledz rumzledz requested review from a team as code owners August 13, 2024 17:52
Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Hey @rumzledz nice fix for this one! 🎉

I tested using meta-mask and can confirm the pending transaction is not clickable in the user hub transaction's list

Screen.Recording.2024-08-14.at.09.20.42.mov

However I did notice the not found action is shown for a split second after clicking the succeeded transaction. Is there anything we can do about it?

@rumzledz
Copy link
Contributor Author

However I did notice the not found action is shown for a split second after clicking the succeeded transaction. Is there anything we can do about it?

Aw man 😕 All right I'll see what I can do thanks for spotting this! 👌

@rumzledz
Copy link
Contributor Author

rumzledz commented Aug 14, 2024

@mmioana can you please try this again when you get the chance? Thank you 😄

EDIT: I know how to replicate this now, I'll put it back in draft! @mmioana

@rumzledz rumzledz requested review from mmioana and a team August 14, 2024 11:10
@rumzledz rumzledz changed the title Fix: Disable click for pending transactions in Userhub Fix: Disable click for non-successful transactions in Userhub Aug 14, 2024
@rumzledz rumzledz marked this pull request as draft August 14, 2024 11:14
@rumzledz rumzledz force-pushed the fix/2738-disable-button-click-for-pending-tx branch from 1552060 to 9a3cb25 Compare August 14, 2024 11:48
@rumzledz rumzledz marked this pull request as ready for review August 14, 2024 13:11
@rumzledz rumzledz force-pushed the fix/2738-disable-button-click-for-pending-tx branch from 9a3cb25 to b1462f9 Compare August 14, 2024 13:11
@rumzledz rumzledz force-pushed the fix/2738-disable-button-click-for-pending-tx branch from b1462f9 to fb6b83a Compare August 14, 2024 13:17
@rumzledz rumzledz changed the title Fix: Disable click for non-successful transactions in Userhub Fix: Only allow a transaction item to be clicked when it is a successful transaction Aug 14, 2024
Copy link
Contributor

@Nortsova Nortsova left a comment

Choose a reason for hiding this comment

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

Hey @rumzledz , it works great! Thanks for this fix and for the 'not found' fix as well!

pending-not-clickable

Comment on lines +97 to 99
) &&
status === TransactionStatus.Succeeded;

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice fix, but in terms of the single responsibility principle, wouldn’t it be better to move this check to where it’s used and just pass the prop as isClickable={status === TransactionStatus.Succeeded}?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @Nortsova thanks for reviewing! I actually have multiple versions of this. I had a version where I wanted to move it outside but it doesn't make sense to just move this single boolean outside, you'd have to deal with the entire lot because why stop at status === TransactionStatus.Succeeded ? 😂

const canLinkToAction =
  isClickable &&
  values.group?.key &&
  !GROUP_KEYS_WHICH_CANNOT_LINK.includes(
    values.group.key as TRANSACTION_METHODS,
  )

I also have another version where this component is stripped down to the point that it only has a few hooks. Would have to move around stuff outside the component etc. etc. If we really wanted to do proper SRP, you'd also have to group up every logical piece of responsibility in the component like the Header, the bit that handles the accordion-like behaviour etc. because simply moving the boolean isn't gonna cut it. It could easily turn into a rabbithole 🐰 and I've been trying my best not to overdo it in my PRs lately 😂 Maybe someday we are free enough to audit our components and see which ones to refactor 👌

Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

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

All good. I can confirm I can click a successful action, yet cannot cannot click a link to an action if the transaction is in a pending or failed state

Screenshot from 2024-08-21 21-07-04
Screenshot from 2024-08-21 21-16-57
Screenshot from 2024-08-21 21-17-11

Nicely done!

Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Nice work 👌 Connected with metamask and tried to click it, nothing happens, as intended 😎
image

@rumzledz rumzledz merged commit 7382137 into master Aug 27, 2024
4 of 6 checks passed
@rumzledz rumzledz deleted the fix/2738-disable-button-click-for-pending-tx branch August 27, 2024 14:13
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.

Clickable UserHub transactions before completed transaction
5 participants