Skip to content

fix: Fix gas inputs to handle comma instead of dot#17360

Merged
OGPoyraz merged 11 commits into
mainfrom
ogp/17195
Jul 23, 2025
Merged

fix: Fix gas inputs to handle comma instead of dot#17360
OGPoyraz merged 11 commits into
mainfrom
ogp/17195

Conversation

@OGPoyraz

@OGPoyraz OGPoyraz commented Jul 18, 2025

Copy link
Copy Markdown
Member

Description

This PR aims to fix gas inputs to replace comma , input to dot .

Changelog

CHANGELOG entry: Fixed a bug on comma inputs on gas text boxes.

Related issues

Fixes: #17195

Manual testing steps

  1. Trigger any transaction
  2. Try changing gas values with decimal value - use a comma separator
  3. It should immediately replace with dot and shouldn't throw error.

Screenshots/Recordings

Before

After

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.

@OGPoyraz OGPoyraz requested a review from a team as a code owner July 18, 2025 10:08
@OGPoyraz OGPoyraz added the No QA Needed Apply this label when your PR does not need any QA effort. label Jul 18, 2025
@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Jul 18, 2025
@OGPoyraz OGPoyraz added Run Smoke E2E and removed team-confirmations Push issues to confirmations team labels Jul 18, 2025
@github-actions

github-actions Bot commented Jul 18, 2025

Copy link
Copy Markdown
Contributor

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 758ac7b
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/9b4430f1-a051-4706-9b8b-29bfe14d0599

Note

  • You can rerun any failed steps by opening the Bitrise build, tapping Rebuild on the upper right then Rebuild unsuccessful Workflows
  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@github-actions

github-actions Bot commented Jul 21, 2025

Copy link
Copy Markdown
Contributor

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 0ba6596
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/8d3da504-7773-410e-92c3-0d51847b3642

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@github-actions

github-actions Bot commented Jul 22, 2025

Copy link
Copy Markdown
Contributor

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: ebe2fd3
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/da7a68f1-47ac-411f-b2c9-10e8ea7eeb81

Note

  • You can rerun any failed steps by opening the Bitrise build, tapping Rebuild on the upper right then Rebuild unsuccessful Workflows
  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

cursor[bot]

This comment was marked as outdated.

@github-actions

github-actions Bot commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 515cb31
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/20303a12-09b2-4f65-b160-e1dd10aaf6bd

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Comma Parsing Error in Validation Functions

The validateValueIsPositive and validateGasLimitValueIsGreaterThanMinimum functions exhibit inconsistent validation behavior for comma-separated numerical inputs. Unlike other validation functions, they directly use parseFloat(value) instead of first normalizing the input with normalizeGasInput(). This causes parseFloat to incorrectly parse values (e.g., "0,5" as 0, "21,000" as 21), leading to erroneous validation results and undermining the PR's intent to handle comma inputs.

app/components/Views/confirmations/utils/validations/gas.ts#L99-L124

function validateValueIsPositive(
value: string,
field: string,
): string | boolean {
if (parseFloat(value) > 0) {
return false;
}
if (parseFloat(value) === 0) {
return strings('transactions.gas_modal.no_zero_value', {
field,
});
}
return strings('transactions.gas_modal.negative_values_not_allowed');
}
function validateGasLimitValueIsGreaterThanMinimum(
value: string,
): string | boolean {
if (parseFloat(value) >= 21000) {
return false;
}
return strings('transactions.gas_modal.gas_limit_too_low');
}

Fix in CursorFix in Web


Bug: Comma Replacement Bug in Gas Input Normalization

The normalizeGasInput function incorrectly uses replace(',', '.'), which only replaces the first occurrence of a comma. This leaves subsequent commas in the input (e.g., "1,234,56" becomes "1.234,56"), resulting in an invalid number format. It should use replace(/,/g, '.') or replaceAll(',', '.') to replace all commas.

app/components/Views/confirmations/utils/gas.ts#L168-L171

export function normalizeGasInput(value: string) {
return value.replace(',', '.');
}

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@sonarqubecloud

Copy link
Copy Markdown

@OGPoyraz OGPoyraz enabled auto-merge July 23, 2025 09:48
@OGPoyraz OGPoyraz added this pull request to the merge queue Jul 23, 2025
Merged via the queue into main with commit 6955a8d Jul 23, 2025
63 of 72 checks passed
@OGPoyraz OGPoyraz deleted the ogp/17195 branch July 23, 2025 10:10
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 23, 2025
@metamaskbot metamaskbot added the release-7.53.0 Issue or pull request that will be included in release 7.53.0 label Jul 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

No QA Needed Apply this label when your PR does not need any QA effort. release-7.53.0 Issue or pull request that will be included in release 7.53.0 team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Unable to edit gas fee on iOS "Only numbers are allowed" message

3 participants