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

(Bug) #1052 Prevent to run multiple transaction #1053

Merged
merged 8 commits into from
Dec 18, 2019

Conversation

yaroslav-fedyshyn-nordwhale
Copy link
Contributor

@yaroslav-fedyshyn-nordwhale yaroslav-fedyshyn-nordwhale commented Dec 11, 2019

Description

Prevent users to click on the confirm button multiple times as then multiple transactions will be sent. The finally block was executed right after the try block as the result wasn't awaited. SO the fix is to wait for generateLink fn to be performed.

About #1052

How Has This Been Tested?

Create a receive link.
Use it with another account.
Go to the last/confirm step.
Try to press the confirm button quickly many times.
It should be disabled with a loader after the first press.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request ( for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

Video: https://www.screencast.com/t/VBuFHCgSI

src/lib/gundb/UserStorageClass.js Outdated Show resolved Hide resolved
Copy link
Contributor

@sirpy sirpy left a comment

Choose a reason for hiding this comment

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

  1. send should be immediate, we don't await for it. if there's a button double click issue, you need to disable the button on click. I think we already implemented this somewhere. maybe add it as a feature to all buttons
  2. yaroslav already did a pr that checks if feeditem is undefined, we should not have undefined items, double check his previous fix for undefined. it could also be solved by the latest gun fix I've pushed.

@AlexeyKosinski
Copy link
Contributor

AlexeyKosinski commented Dec 11, 2019

  1. send should be immediate, we don't await for it. if there's a button double click issue, you need to disable the button.

we already have a disable button here. it is setLoading to state. but it happens at an incorrect time. so we need add await. or remove setLoading(false) from finally section and add setLoading(false)in onTxHash and onError. for user it will be the same as just add await.

@AlexeyKosinski
Copy link
Contributor

  1. yaroslav already did a pr that checks if feeditem is undefined, we should not have undefined items, double check his previous fix for undefined. it could also be solved by the latest gun fix I've pushed.

I've added just filter not show undefined items I think it will be good to have them. but if u want we can delete this fix

@sirpy
Copy link
Contributor

sirpy commented Dec 12, 2019

  1. it's not the same. the promise is resolved on receipt.
  2. we need to understand why there's undefined, why the fix yaroslav did doesn't work

@yaroslav-fedyshyn-nordwhale
Copy link
Contributor Author

yaroslav-fedyshyn-nordwhale commented Dec 13, 2019

  1. it's not the same. the promise is resolved on receipt.
  2. we need to understand why there's undefined, why the fix yaroslav did doesn't work

@sirpy

  1. made the setLoading fn to be called from callback handler

@AlexeyKosinski
Copy link
Contributor

AlexeyKosinski commented Dec 13, 2019

2. we need to understand why there's undefined, why the fix yaroslav did doesn't work

I think the problem was with duplicate transactions when I press confirm button. because once I clicked 5 times. and it ran 5 transactions. but the I saw popup error not enough GD. this case is not real if we will merge this PR

Copy link
Contributor

@sirpy sirpy left a comment

Choose a reason for hiding this comment

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

@yaroslav-fedyshyn-nordwhale @AlexeyKosinski we have to ways 2 send GD

  1. directly
  2. via payment link

@sirpy
Copy link
Contributor

sirpy commented Dec 15, 2019

@yaroslav-fedyshyn-nordwhale @AlexeyKosinski also please check all buttons functionality and how we can prevent double clicking issues

@yaroslav-fedyshyn-nordwhale
Copy link
Contributor Author

@yaroslav-fedyshyn-nordwhale @AlexeyKosinski also please check all buttons functionality and how we can prevent double clicking issues

@sirpy we already have the functionality to prevent double-clicking. We can block the button to be clicked multiple times by passing the 'loading' (boolean) property to the CustomButton component. It was already implemented in the place we had an issue, but the setLoading(false); was called in 'finally' clause of 'try' block, so the button was unlocked without waiting for any transaction response. That is why we could confirm multiple times. After we place the setLoading(false) to the correct place (after the response received) - confirm button will be unlocked correctly.

I checked the button across the app and didn't find the same behavior.

Copy link
Contributor

@sirpy sirpy left a comment

Choose a reason for hiding this comment

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

in SendLinkSummary.js i dont see any usage of loading.
scenario seems the same to me, user clicks confirms and a tx is generated. dont see how loading is implemented there

@yaroslav-fedyshyn-nordwhale
Copy link
Contributor Author

in SendLinkSummary.js i dont see any usage of loading.
scenario seems the same to me, user clicks confirms and a tx is generated. dont see how loading is implemented there

We don't need loading there as after the user press confirm button he will be redirected to next step or share dialog will be shown in case of mobile. The hash we waiting from onTxHash callback needed just to create a feed card (async).

@yaroslav-fedyshyn-nordwhale
Copy link
Contributor Author

@sirpy I pushed new commit

# Conflicts:
#	src/components/profile/__tests__/OptionsRow.js
#	src/components/profile/__tests__/__snapshots__/OptionsRow.js.snap
({ paymentLink, code }) => (hash: string) => {
log.debug({ hash })
const generateLinkResponse = goodWallet.generateLink(amount, reason, {
onTransactionHash: ({ hash, paymentLink, code }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for special ontxhash
take paymetlink and code from generatelinkresponse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -560,7 +559,7 @@ export class GoodWallet {
})

//pass extra data
const onTransactionHash = getOnTxHash({ paymentLink, code })
const onTransactionHash = hash => events.onTransactionHash({ hash, paymentLink, code })
Copy link
Contributor

Choose a reason for hiding this comment

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

no need

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@sirpy sirpy merged commit 908acf2 into master Dec 18, 2019
@serdiukov-o-nordwhale serdiukov-o-nordwhale deleted the 1052-Prevent_to_run_multiple_transaction branch July 8, 2021 21:19
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.

3 participants