CW-475-Better-error-message-if-there-isnt-enough-network-fee-asset-available (#1092)

* Better error message

* minor fixes

* localization

* Update strings_tl.arb

* Update append_translation.sh
This commit is contained in:
Serhii
2023-09-25 15:20:11 +03:00
committed by GitHub
parent 04f5391be1
commit d6c641242f
28 changed files with 46 additions and 5 deletions
+13 -1
View File
@@ -30,6 +30,7 @@ import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
import 'package:cake_wallet/entities/parsed_address.dart';
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/haven/haven.dart';
import 'package:cake_wallet/generated/i18n.dart';
part 'send_view_model.g.dart';
@@ -325,7 +326,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
state = TransactionCommitted();
} catch (e) {
state = FailureState(e.toString());
String translatedError = translateErrorMessage(e.toString(), wallet.type, wallet.currency);
state = FailureState(translatedError);
}
}
@@ -412,4 +414,14 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
selectedCryptoCurrency = wallet.currency;
}
}
String translateErrorMessage(String error, WalletType walletType, CryptoCurrency currency,) {
if (walletType == WalletType.ethereum || walletType == WalletType.haven) {
if (error.contains('gas required exceeds allowance (0)') || error.contains('insufficient funds for gas')) {
return S.current.do_not_have_enough_gas_asset(currency.toString());
}
}
return error;
}
}