skip scam check on whitelisted tokens
OmarHatem committed
Apr 11, 2025 at 14:51 UTC
277dde461432fe8f08b4a6bddd1ee4f4e266cf68
2 files changed
+8
-7
lib/src/screens/dashboard/edit_token_page.dart
+6
-6
@@ -207,15 +207,15 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
207
onPressed: () async {
208
if (_formKey.currentState!.validate() &&
209
(!_showDisclaimer || _disclaimerChecked)) {
210
- final hasPotentialError = await widget.homeSettingsViewModel
210
+ final isWhitelisted = await widget.homeSettingsViewModel
211
+ .checkIfTokenIsWhitelisted(_contractAddressController.text);
212
+
213
+ final hasPotentialError = !isWhitelisted && await widget.homeSettingsViewModel
214
.checkIfERC20TokenContractAddressIsAPotentialScamAddress(
215
_contractAddressController.text,
216
);
217
215
- final isWhitelisted = await widget.homeSettingsViewModel
216
- .checkIfTokenIsWhitelisted(_contractAddressController.text);
217
-
218
- bool isPotentialScam = hasPotentialError;
218
+ bool isPotentialScam = hasPotentialError && !isWhitelisted;
219
final tokenSymbol = _tokenSymbolController.text.toUpperCase();
220
221
// check if the token symbol is the same as any of the base currencies symbols (ETH, SOL, POL, TRX, etc):
@@ -258,7 +258,7 @@ class _EditTokenPageBodyState extends State<EditTokenPageBody> {
258
}
259
};
260
261
- if (hasPotentialError) {
261
+ if (hasPotentialError && !isWhitelisted) {
262
showPopUp<void>(
263
context: context,
264
builder: (dialogContext) {
lib/view_model/dashboard/home_settings_view_model.dart
+2
-1
@@ -221,7 +221,8 @@ abstract class HomeSettingsViewModelBase with Store {
221
}
222
223
// check if the contractAddress is in the defaultTokenAddresses
224
- bool isInWhitelist = defaultTokenAddresses.any((element) => element == contractAddress);
224
+ bool isInWhitelist = defaultTokenAddresses
225
+ .any((element) => element.toLowerCase() == contractAddress.toLowerCase());
226
return isInWhitelist;
227
}
228