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: Limit amount of decimals on spending cap modal #27672

Merged
merged 2 commits into from
Oct 9, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Oct 7, 2024

Description

If the user tries to add more decimals to the spending cap than what the token supports, the spending cap cannot be submitted and a notice is displayed.

Open in GitHub Codespaces

Related issues

Fixes: #27618

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Screenshot 2024-10-08 at 13 40 02

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Oct 7, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Oct 7, 2024
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners October 7, 2024 16:36
Copy link
Contributor

github-actions bot commented Oct 7, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@@ -116,10 +128,17 @@ export const EditSpendingCapModal = ({
setCustomSpendingCapInputValue(formattedSpendingCap.toString());
}, [customSpendingCapInputValue, formattedSpendingCap]);

const showDecimalError = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, do we need a memo for this as some basic math will have negligible performance cost?

return (
<Modal
isOpen={isOpenEditSpendingCapModal}
onClose={() => setIsOpenEditSpendingCapModal(false)}
onClose={() => handleCancel()}
Copy link
Member

Choose a reason for hiding this comment

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

Minor, no need for the lambda since handleCancel is already a function reference with no arguments?

@metamaskbot
Copy link
Collaborator

Builds ready [a62e734]
Page Load Metrics (1832 ± 78 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16742320183715574
domContentLoaded16382136178912359
load16482380183216378
domInteractive25198533818
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 230 Bytes (0.00%)
  • common: 119 Bytes (0.00%)

@metamaskbot
Copy link
Collaborator

Builds ready [4255182]
Page Load Metrics (1932 ± 124 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint167429401926269129
domContentLoaded163628721894258124
load167428901932259124
domInteractive267146147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 267 Bytes (0.00%)
  • common: 119 Bytes (0.00%)

jpuri
jpuri previously approved these changes Oct 9, 2024
const decimalDigits = numberString.length - decimalPointIndex - 1;

return decimalDigits;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

return numberString.split(".")[1].length || 0;

Copy link

sonarcloud bot commented Oct 9, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [0764d25]
Page Load Metrics (1795 ± 53 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint24519811715353170
domContentLoaded15971956177110450
load16091973179511153
domInteractive1397502512
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 277 Bytes (0.00%)
  • common: 119 Bytes (0.00%)

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Oct 9, 2024
Merged via the queue into develop with commit 8f2bab5 Oct 9, 2024
78 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/27618 branch October 9, 2024 16:52
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 9, 2024
@gauthierpetetin gauthierpetetin added release-12.6.0 Issue or pull request that will be included in release 12.6.0 and removed release-12.7.0 Issue or pull request that will be included in release 12.7.0 labels Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.6.0 Issue or pull request that will be included in release 12.6.0 team-confirmations Push issues to confirmations team
Projects
None yet
6 participants