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

Alert user if insufficient tokens for tip #3058

Merged
merged 6 commits into from
Apr 12, 2019

Conversation

dylanjw
Copy link
Contributor

@dylanjw dylanjw commented Dec 3, 2018

Description

See #2250

Checklist
  • linter status: 100% pass
  • changes don't break existing behavior
  • commit message follows commit guidelines
Affected core subsystem(s)

ui

Testing

I tested locally with docker. I both test the validation message on sending a tip, and on submitting a bounty.

Refers/Fixes

Fixes #2250

denomFactor = Math.pow(10, tokenDetails.decimals);

check_balance_and_alert_user_if_not_enough(
tokenAddress,

Choose a reason for hiding this comment

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

Trailing spaces not allowed. (no-trailing-spaces)


check_balance_and_alert_user_if_not_enough(
tokenAddress,
amount,

Choose a reason for hiding this comment

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

Trailing spaces not allowed. (no-trailing-spaces)

if (!isETH) {
check_balance_and_alert_user_if_not_enough(tokenAddress, amount);
check_balance_and_alert_user_if_not_enough(
tokenAddress,

Choose a reason for hiding this comment

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

Trailing spaces not allowed. (no-trailing-spaces)

check_balance_and_alert_user_if_not_enough(tokenAddress, amount);
check_balance_and_alert_user_if_not_enough(
tokenAddress,
amount,

Choose a reason for hiding this comment

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

Trailing spaces not allowed. (no-trailing-spaces)

@@ -1336,3 +1336,29 @@ function shuffleArray(array) {
}
return array;
}

function check_balance_and_alert_user_if_not_enough(
tokenAddress,

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 4. (indent)
Trailing spaces not allowed. (no-trailing-spaces)


function check_balance_and_alert_user_if_not_enough(
tokenAddress,
amount,

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 4. (indent)
Trailing spaces not allowed. (no-trailing-spaces)

function check_balance_and_alert_user_if_not_enough(
tokenAddress,
amount,
msg='You do not have enough tokens to perform this action.') {

Choose a reason for hiding this comment

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

Expected indentation of 2 spaces but found 4. (indent)
Infix operators must be spaced. (space-infix-ops)

var balance_rounded = Math.round(balance * 10) / 10;

if (parseFloat(amount) > balance) {
var msg1 = gettext(msg)

Choose a reason for hiding this comment

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

Missing semicolon. (semi)

}
});

};

Choose a reason for hiding this comment

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

Unnecessary semicolon. (no-extra-semi)

@dylanjw dylanjw force-pushed the alert-underfunded-tip branch from 79cf7dc to 88c9817 Compare December 3, 2018 22:57
function check_balance_and_alert_user_if_not_enough(
tokenAddress,
amount,
msg='You do not have enough tokens to perform this action.') {

Choose a reason for hiding this comment

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

Infix operators must be spaced. (space-infix-ops)

@dylanjw dylanjw force-pushed the alert-underfunded-tip branch from 88c9817 to 7843701 Compare December 3, 2018 22:58
@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #3058 into master will decrease coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3058      +/-   ##
==========================================
- Coverage   29.77%   29.72%   -0.05%     
==========================================
  Files         180      180              
  Lines       13734    13734              
  Branches     1842     1842              
==========================================
- Hits         4089     4083       -6     
- Misses       9507     9513       +6     
  Partials      138      138
Impacted Files Coverage Δ
app/dashboard/embed.py 28.16% <0%> (-3.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d417fa4...7843701. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 3, 2018

Codecov Report

Merging #3058 into master will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3058      +/-   ##
==========================================
- Coverage   30.37%   30.33%   -0.04%     
==========================================
  Files         206      206              
  Lines       16404    16404              
  Branches     2156     2156              
==========================================
- Hits         4982     4976       -6     
- Misses      11242    11248       +6     
  Partials      180      180
Impacted Files Coverage Δ
app/dashboard/embed.py 28.16% <0%> (-3.45%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dc2c030...f2f4a80. Read the comment docs.

Copy link
Member

@thelostone-mc thelostone-mc left a comment

Choose a reason for hiding this comment

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

@dylanjw could you

  • fix travis CI failures
  • throw in a recording of the fix

And if you are up for making the code base a lil better
L81 - L96. Update var with let / const

@dylanjw
Copy link
Contributor Author

dylanjw commented Feb 25, 2019

@thelostone-mc The CI is throwing the following error:

django.core.management.base.CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0012_merge_20190221_2246, 0014_matchpledge in grants).
E           To fix them run 'python manage.py makemigrations --merge'

I dont think this is related to the changes in the PR.

@thelostone-mc
Copy link
Member

@dylanjw My bad ! I'll fix up travis ^_^
Could you throw in a recording of the PR ?

@owocki
Copy link
Contributor

owocki commented Feb 25, 2019

migration issues have been resolved upstream

@dylanjw dylanjw force-pushed the alert-underfunded-tip branch from 93d5026 to 4c3506c Compare February 26, 2019 02:25
@dylanjw
Copy link
Contributor Author

dylanjw commented Feb 27, 2019

After testing this again recently it looks like there has been a regression with Eth based tips. When I first worked on this, I think insufficient Eth had a warning already, and I just needed to implement the alternative token warning. Now Im only getting the warning for the alternative token. I will include a fix for the insufficient Eth in this PR.

@dylanjw
Copy link
Contributor Author

dylanjw commented Mar 5, 2019

The regression when sending an ETH tip looks a little deeper than I anticipated. I opened this issue: #3877.

Im surprised by that issue, because there looks like a lot of areas where that issue could be breaking things.

@dylanjw dylanjw force-pushed the alert-underfunded-tip branch from 6aace8f to 34a9ccb Compare March 5, 2019 05:45
@dylanjw
Copy link
Contributor Author

dylanjw commented Mar 5, 2019

While it is decided if #3877 is a bug or not, I have updated this PR to normalize 0x0 to the full length address.

Here are screenshots of the tip error message displaying with Eth and with an alternate token:

screenshot from 2019-03-05 14-42-15
screenshot from 2019-03-05 14-42-57

@thelostone-mc
Copy link
Member

@dylanjw will test this out but could you fix the CI errors ?

@dylanjw dylanjw force-pushed the alert-underfunded-tip branch from ee6f0fc to 69a9ae0 Compare March 6, 2019 07:26
@dylanjw
Copy link
Contributor Author

dylanjw commented Mar 7, 2019

@thelostone-mc Im getting a CI error from the code coverage calculation. The file with the change in coverage looks unrelated to my changes.

@dylanjw dylanjw force-pushed the alert-underfunded-tip branch from 69a9ae0 to 978207a Compare April 1, 2019 22:21
@dylanjw
Copy link
Contributor Author

dylanjw commented Apr 1, 2019

@thelostone-mc Ready to merge

@SaptakS SaptakS merged commit 80d30f3 into gitcoinco:master Apr 12, 2019
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.

bug (er... UX thing) -- tips flow should warn you when u dont ahve enough ERC20 tokens to send tip
5 participants