Repository: dusk-network/rusk (language: rust)

Issue:
Fix gas settings reset and validation in preferences
**Describe the bug**
We have two wrong behaviours after introducing the "reset to defaults" button for gas settings.

1. the "back" button of the preferences screen stays disabled after entering an invalid value and using the "reset to defaults" button, even if the values are now correct
2. after inserting an invalid value for either price or limit the "reset" button works only under special conditions.

For example if the default value for gas limit is `100_000_000`, and I add a zero to make it `1_000_000_000` (also valid). In this case the valid value is written in the settings and it's different from the default. In this situation the reset button works, because Svelte's reactivity is triggered (the value written in the settings is different from the default).

On the other hand if I start from the default value of `100_000_000` and I add, say, a nine at the end (`1_000_000_009`) the value becomes immediately invalid and the value written in the store, which is the last valid value, is equal to the default: in this case the reset button does nothing as Svelte's reactivity is not triggered.

**Proposed solution**
For the first behaviour the solution is quite straightforward: update the validation flag when the reset is clicked.

For the second behaviour the most immediate solution is to allow storing values out of limits: this way the reactivity works properly. Only drawback is that if the user closes the tab he will restart with invalid values in the settings and he has to fix them before being allowed to do any operation.


Discussion / hints:

Fix patch:
diff --git a/web-wallet/CHANGELOG.md b/web-wallet/CHANGELOG.md
index 73e800f99b..c2fe6b4748 100644
--- a/web-wallet/CHANGELOG.md
+++ b/web-wallet/CHANGELOG.md
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
+- Fix gas settings reset and validation in preferences [#3212]
+
 ## [0.10.0] - 2024-12-17
 
 ### Added
@@ -455,6 +457,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 [#3178]: https://github.com/dusk-network/rusk/issues/3178
 [#3179]: https://github.com/dusk-network/rusk/issues/3179
 [#3203]: https://github.com/dusk-network/rusk/issues/3203
+[#3212]: https://github.com/dusk-network/rusk/issues/3212
 
 <!-- VERSIONS -->
 
diff --git a/web-wallet/src/lib/components/BigIntInput/BigIntInput.svelte b/web-wallet/src/lib/components/BigIntInput/BigIntInput.svelte
index 55e5ec05b0..a4ac58e4e1 100644
--- a/web-wallet/src/lib/components/BigIntInput/BigIntInput.svelte
+++ b/web-wallet/src/lib/components/BigIntInput/BigIntInput.svelte
@@ -20,7 +20,8 @@
   /** @type {bigint} */
   export let value = 0n;
 
-  let internalValue = value.toString();
+  /** @type {string} */
+  let internalValue;
 
   /** @type {(v: bigint, min: bigint, max: bigint) => boolean} */
   const isInvalidInput = (v, min, max) => !!(min > v || v > max);
diff --git a/web-wallet/src/routes/(app)/settings/+page.svelte b/web-wallet/src/routes/(app)/settings/+page.svelte
index c75de6a9a2..bfe6f698c6 100644
--- a/web-wallet/src/routes/(app)/settings/+page.svelte
+++ b/web-wallet/src/routes/(app)/settings/+page.svelte
@@ -45,6 +45,7 @@
     // eslint-disable-next-line no-alert
     if (confirm(confirmResetGasMessage)) {
       settingsStore.resetGasSettings();
+      isGasValid = true;
     }
   }
 
@@ -88,13 +89,11 @@
 
             isGasValid = areValidGasSettings(price, limit);
 
-            if (isGasValid) {
-              settingsStore.update((store) => ({
-                ...store,
-                gasLimit: limit,
-                gasPrice: price,
-              }));
-            }
+            settingsStore.update((store) => ({
+              ...store,
+              gasLimit: limit,
+              gasPrice: price,
+            }));
           }}
           limit={gasLimit}
           limitLower={gasLimitLower}


Test patch: